feat: Phase 1 code-agent capabilities — file_edit, git tools, parallel execution, tool output preview
New tools: - file_edit: surgical line-range or pattern edits (yolo only) - git_status: show changed files (read-only) - git_diff: show unstaged/staged diff (read-only) - git_log: show recent commits (read-only) Agent improvements: - parallel execution for independent read-only tool calls - mutating tools (file_write, file_edit, shell_run) run sequentially - tool output preview in logs with [output] marker TUI improvements: - tool cards now show truncated output preview (up to 8 lines) - mergeToolLog updates placeholder cards with results - toolStatusText keeps activity bar single-line Documentation: - README updated with git tools and file_edit descriptions
This commit is contained in:
@@ -348,6 +348,43 @@ func TestToolMessageRendersStructuredCard(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestToolMessageRendersOutputPreview(t *testing.T) {
|
||||
m := newModel(context.Background(), nil, Options{ModelName: "test-model"})
|
||||
m.messages = append(m.messages, message{role: roleTool, content: "file_read {\"path\":\"README.md\"}\n[output]\nfirst line\nsecond line"})
|
||||
|
||||
plain := stripANSI(m.renderMessages())
|
||||
for _, want := range []string{iconTool + " file_read", "README.md", "output", "first line", "second line"} {
|
||||
if !strings.Contains(plain, want) {
|
||||
t.Fatalf("tool card missing %q:\n%s", want, plain)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestToolLogOutputUpdatesExistingToolCard(t *testing.T) {
|
||||
m := newModel(context.Background(), nil, Options{ModelName: "test-model"})
|
||||
m.messages = append(m.messages, message{role: roleTool, content: `file_read {"path":"README.md"}`})
|
||||
|
||||
updated := m.mergeToolLog("file_read {\"path\":\"README.md\"}\n[output]\nhello")
|
||||
if !updated {
|
||||
t.Fatal("expected mergeToolLog to return true")
|
||||
}
|
||||
if len(m.messages) != 1 {
|
||||
t.Fatalf("messages count = %d, want 1", len(m.messages))
|
||||
}
|
||||
plain := stripANSI(m.renderMessages())
|
||||
if !strings.Contains(plain, "hello") {
|
||||
t.Fatalf("rendered output missing 'hello':\n%s", plain)
|
||||
}
|
||||
|
||||
status := toolStatusText("file_read {\"path\":\"README.md\"}\n[output]\nhello world")
|
||||
if strings.Contains(status, "hello") {
|
||||
t.Fatalf("status should not contain output: %q", status)
|
||||
}
|
||||
if !strings.Contains(status, "file_read") {
|
||||
t.Fatalf("status missing tool name: %q", status)
|
||||
}
|
||||
}
|
||||
|
||||
type tuiCompactProvider struct{}
|
||||
|
||||
func (tuiCompactProvider) ChatStream(ctx context.Context, req llm.ChatRequest, emit func(llm.StreamEvent) error) error {
|
||||
|
||||
Reference in New Issue
Block a user