fix(system-prompt): make identity string context-aware (matches decompiled CC 2.1.113 zN_())
Commit f9fe143 pinned CLAUDE_CODE_IDENTITY_STRING to the non-interactive
Doq string ("You are a Claude agent...") to match the capture taken via
`claude --print` (non-interactive mode). That fix was correct for the
captured context but introduced a regression for interactive OpenCode
usage, which should emit qI6 ("You are Claude Code, Anthropic's official
CLI for Claude.").
Decompilation of the CC 2.1.113 Bun-compiled binary revealed the actual
selection logic (function zN_ in the embedded JS):
if (provider === 'vertex') return qI6
if (isNonInteractive) {
if (hasAppendSystemPrompt) return joq
return Doq
}
return qI6 // interactive default
Replaces the single CLAUDE_CODE_IDENTITY_STRING constant with three named
exports (INTERACTIVE_*, NON_INTERACTIVE_CLAUDE_AGENT_*, NON_INTERACTIVE_*_AGENT_SDK_*)
plus a selectClaudeCodeIdentity(context) function mirroring zN_. Wires
the selector into buildSystemPromptBlocks (picks based on signature.provider
+ signature.hasAppendSystemPrompt) and the experimental system.transform
hook (picks based on input.model.providerID).
Adds tests/unit/system-prompt/identity-selection.test.ts (6 tests covering
all 4 zN_ branches). Updates 4 existing tests whose assertions encoded the
outdated single-identity behavior.
For backward source compat, CLAUDE_CODE_IDENTITY_STRING still exists as
an alias for INTERACTIVE_CLAUDE_CODE_IDENTITY (the interactive-mode default).
Verification:
- 1332/1332 tests pass (+6 new selector tests)
- Typecheck clean
- Lint clean (0 warnings, 0 errors)
- Re-running minimal-hi capture produces Doq (non-TTY `claude --print`)
matching CC 2.1.113 OG captures byte-for-byte
Evidence: .sisyphus/evidence/phase-1-claim-validation/2026-04-17/
(see 'decompiled zN_' function reference in the full tool output dump
from CC 2.1.113 Bun binary inspection). V
Vacbo committed
5f90d539121262ccd4f733d0415298d2e654de3e
Parent: f9fe143