Initial commit on Forgejo
Some checks failed
CI and releases / Test and vet (push) Failing after 1s
CI and releases / Build release binaries (push) Has been skipped
CI and releases / Publish GitHub release (push) Has been skipped

Fresh repository history for elektrine/tarakan-client hosted at
https://git.elektrine.com/elektrine/tarakan-client.
This commit is contained in:
Maxfield Luke 2026-07-29 04:56:36 -04:00
commit 58b29a7f84
70 changed files with 12994 additions and 0 deletions

View file

@ -0,0 +1,60 @@
package agent
import (
"strings"
"testing"
)
func TestParseClaudeStreamToolUse(t *testing.T) {
line := `{"type":"assistant","session_id":"s","message":{"role":"assistant","content":[{"type":"tool_use","id":"t1","name":"Read","input":{"file_path":"sample.txt"}}]}}`
ev := parseClaudeStreamLine(line)
if !ev.ok || !strings.Contains(ev.activity, "Read sample.txt") {
t.Fatalf("ev=%+v", ev)
}
}
func TestParseClaudeStreamResult(t *testing.T) {
line := `{"type":"result","subtype":"success","result":"all good","is_error":false}`
ev := parseClaudeStreamLine(line)
if !ev.ok || ev.finalResult != "all good" {
t.Fatalf("ev=%+v", ev)
}
}
func TestParseClaudeStreamSubagent(t *testing.T) {
line := `{"type":"assistant","message":{"content":[{"type":"tool_use","name":"Task","input":{"description":"find auth","subagent_type":"Explore"}}]}}`
ev := parseClaudeStreamLine(line)
if !ev.ok || !strings.Contains(ev.activity, "Subagent") {
t.Fatalf("ev=%+v", ev)
}
}
func TestParseCodexCommandExecution(t *testing.T) {
line := `{"type":"item.started","item":{"id":"item_0","type":"command_execution","command":"/usr/bin/bash -lc \"sed -n '1,200p' sample.txt\"","status":"in_progress"}}`
ev := parseCodexStreamLine(line)
if !ev.ok || !strings.Contains(ev.activity, "Shell:") || !strings.Contains(ev.activity, "sample.txt") {
t.Fatalf("ev=%+v", ev)
}
}
func TestParseCodexAgentMessage(t *testing.T) {
line := `{"type":"item.completed","item":{"id":"item_1","type":"agent_message","text":"hello world"}}`
ev := parseCodexStreamLine(line)
if !ev.ok || ev.message != "hello world" {
t.Fatalf("ev=%+v", ev)
}
}
func TestSimplifyCodexCommand(t *testing.T) {
got := simplifyCodexCommand(`/usr/bin/bash -lc "ls -la"`)
if got != "ls -la" {
t.Fatalf("got %q", got)
}
}
func TestFormatClaudeToolBash(t *testing.T) {
got := formatClaudeTool("Bash", map[string]any{"command": "git status", "description": "check git"})
if got != "Shell: check git" {
t.Fatalf("got %q", got)
}
}