Skip to content

Commit 0d3d1d7

Browse files
authored
Merge pull request #1715 from entireio/fix/1423-ide-tag-title
fix(claudecode): strip IDE context tags from the captured turn prompt
2 parents 888c11d + d6855b6 commit 0d3d1d7

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

cmd/entire/cli/agent/claudecode/lifecycle.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"github.com/entireio/cli/cmd/entire/cli/agent"
1414
"github.com/entireio/cli/cmd/entire/cli/logging"
15+
"github.com/entireio/cli/cmd/entire/cli/textutil"
1516
)
1617

1718
// Compile-time interface assertions for new interfaces.
@@ -137,8 +138,11 @@ func (c *ClaudeCodeAgent) parseTurnStart(stdin io.Reader) (*agent.Event, error)
137138
Type: agent.TurnStart,
138139
SessionID: raw.SessionID,
139140
SessionRef: raw.TranscriptPath,
140-
Prompt: raw.Prompt,
141-
Timestamp: time.Now(),
141+
// Strip IDE-injected context (e.g. <ide_opened_file> from the VS Code
142+
// extension) so the session/checkpoint title and prompt show what the
143+
// user actually typed, not the injected block.
144+
Prompt: textutil.StripIDEContextTags(raw.Prompt),
145+
Timestamp: time.Now(),
142146
}, nil
143147
}
144148

cmd/entire/cli/agent/claudecode/lifecycle_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,23 @@ func TestParseHookEvent_TurnStart(t *testing.T) {
9999
}
100100
}
101101

102+
// The VS Code extension prepends an <ide_opened_file> context block to the
103+
// prompt; it must be stripped so the session/checkpoint title and prompt show
104+
// only what the user typed.
105+
func TestParseHookEvent_TurnStart_StripsIDEContextTags(t *testing.T) {
106+
t.Parallel()
107+
108+
ag := &ClaudeCodeAgent{}
109+
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"}`
110+
111+
event, err := ag.ParseHookEvent(context.Background(), HookNameUserPromptSubmit, strings.NewReader(input))
112+
require.NoError(t, err)
113+
require.NotNil(t, event)
114+
if event.Prompt != "rewrite these docs as one plan" {
115+
t.Errorf("IDE context tag not stripped; prompt = %q", event.Prompt)
116+
}
117+
}
118+
102119
func TestParseHookEvent_TurnEnd(t *testing.T) {
103120
t.Parallel()
104121

0 commit comments

Comments
 (0)