fix(claudecode): strip IDE context tags from the captured turn prompt · Entire

fix(claudecode): strip IDE context tags from the captured turn prompt

da9d515→main·

suhaanthayyil·1w ago·2 files·+23 added/-2 removed

Claude Code inside the VS Code extension prepends an context block to the user's message. parseTurnStart stored the raw prompt, so the injected block leaked into the session/checkpoint title and rendered prompt. Strip it with textutil.StripIDEContextTags at capture, matching how the transcript and other agents already sanitize user text.

Closes #1423

Co-authored-by: Cursor cursoragent@cursor.com

Changes

2

11 unmodified lines

12
13
14
15
16
17
18
119 unmodified lines

138
139
140
140
141
141
142
143
144
145
146
147
148

11 unmodified lines

"github.com/entireio/cli/cmd/entire/cli/agent"
    "github.com/entireio/cli/cmd/entire/cli/logging"
    "github.com/entireio/cli/cmd/entire/cli/textutil"
// Compile-time interface assertions for new interfaces.
119 unmodified lines

Type:       agent.TurnStart,
    SessionID:  raw.SessionID,
    SessionRef: raw.TranscriptPath,
    Prompt:     raw.Prompt,
    Timestamp:  time.Now(),
    // Strip IDE-injected context (e.g. <ide_opened_file> from the VS Code
    // extension) so the session/checkpoint title and prompt show what the
    // user actually typed, not the injected block (#1423).
    Prompt:    textutil.StripIDEContextTags(raw.Prompt),
    Timestamp: time.Now(),
    }, nil
}

Mcmd/entire/cli/agent/claudecode/lifecycle.go+6/-2

98 unmodified lines

99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

98 unmodified lines

}
// Regression for #1423: the VS Code extension prepends an <ide_opened_file>
// context block to the prompt; it must be stripped so the session/checkpoint
// title and prompt show only what the user typed.
func TestParseHookEvent_TurnStart_StripsIDEContextTags(t *testing.T) {

t.Parallel()

ag := &ClaudeCodeAgent{}
    input := `{"session_id":"s1","transcript_path":"/tmp/t.jsonl","prompt":"<ide_opened_file>The user opened /a/b.md in the IDE.</ide_opened_file>\n\nrewrite these docs as one plan"}`

event, err := ag.ParseHookEvent(context.Background(), HookNameUserPromptSubmit, strings.NewReader(input))
    require.NoError(t, err)
    require.NotNil(t, event)
    if event.Prompt != "rewrite these docs as one plan" {
         t.Errorf("IDE context tag not stripped; prompt = %q", event.Prompt)
    }
}

func TestParseHookEvent_TurnEnd(t *testing.T) {

t.Parallel()

Mcmd/entire/cli/agent/claudecode/lifecycle_test.go+17