mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-05 02:30:26 +08:00
- Add --agent parameter for agent-based backend/model resolution - Add --prompt-file parameter for agent prompt injection - Add opencode backend support with JSON output parsing - Add yolo field in agent config for auto-enabling dangerous flags - claude: --dangerously-skip-permissions - codex: --dangerously-bypass-approvals-and-sandbox - Add develop agent for code development tasks - Add omo skill for multi-agent orchestration with Sisyphus coordinator - Bump version to 5.5.0 Generated with SWE-Agent.ai Co-Authored-By: SWE-Agent.ai <noreply@swe-agent.ai>
51 lines
2.3 KiB
Go
51 lines
2.3 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestParseJSONStream_Opencode(t *testing.T) {
|
|
input := `{"type":"step_start","timestamp":1768187730683,"sessionID":"ses_44fced3c7ffe83sZpzY1rlQka3","part":{"id":"prt_bb0339afa001NTqoJ2NS8x91zP","sessionID":"ses_44fced3c7ffe83sZpzY1rlQka3","messageID":"msg_bb033866f0011oZxTqvfy0TKtS","type":"step-start","snapshot":"904f0fd58c125b79e60f0993e38f9d9f6200bf47"}}
|
|
{"type":"text","timestamp":1768187744432,"sessionID":"ses_44fced3c7ffe83sZpzY1rlQka3","part":{"id":"prt_bb0339cb5001QDd0Lh0PzFZpa3","sessionID":"ses_44fced3c7ffe83sZpzY1rlQka3","messageID":"msg_bb033866f0011oZxTqvfy0TKtS","type":"text","text":"Hello from opencode"}}
|
|
{"type":"step_finish","timestamp":1768187744471,"sessionID":"ses_44fced3c7ffe83sZpzY1rlQka3","part":{"id":"prt_bb033d0af0019VRZzpO2OVW1na","sessionID":"ses_44fced3c7ffe83sZpzY1rlQka3","messageID":"msg_bb033866f0011oZxTqvfy0TKtS","type":"step-finish","reason":"stop","snapshot":"904f0fd58c125b79e60f0993e38f9d9f6200bf47","cost":0}}`
|
|
|
|
message, threadID := parseJSONStream(strings.NewReader(input))
|
|
|
|
if threadID != "ses_44fced3c7ffe83sZpzY1rlQka3" {
|
|
t.Errorf("threadID = %q, want %q", threadID, "ses_44fced3c7ffe83sZpzY1rlQka3")
|
|
}
|
|
if message != "Hello from opencode" {
|
|
t.Errorf("message = %q, want %q", message, "Hello from opencode")
|
|
}
|
|
}
|
|
|
|
func TestParseJSONStream_Opencode_MultipleTextEvents(t *testing.T) {
|
|
input := `{"type":"text","sessionID":"ses_123","part":{"type":"text","text":"Part 1"}}
|
|
{"type":"text","sessionID":"ses_123","part":{"type":"text","text":" Part 2"}}
|
|
{"type":"step_finish","sessionID":"ses_123","part":{"type":"step-finish","reason":"stop"}}`
|
|
|
|
message, threadID := parseJSONStream(strings.NewReader(input))
|
|
|
|
if threadID != "ses_123" {
|
|
t.Errorf("threadID = %q, want %q", threadID, "ses_123")
|
|
}
|
|
if message != "Part 1 Part 2" {
|
|
t.Errorf("message = %q, want %q", message, "Part 1 Part 2")
|
|
}
|
|
}
|
|
|
|
func TestParseJSONStream_Opencode_NoStopReason(t *testing.T) {
|
|
input := `{"type":"text","sessionID":"ses_456","part":{"type":"text","text":"Content"}}
|
|
{"type":"step_finish","sessionID":"ses_456","part":{"type":"step-finish","reason":"tool-calls"}}`
|
|
|
|
message, threadID := parseJSONStream(strings.NewReader(input))
|
|
|
|
if threadID != "ses_456" {
|
|
t.Errorf("threadID = %q, want %q", threadID, "ses_456")
|
|
}
|
|
if message != "Content" {
|
|
t.Errorf("message = %q, want %q", message, "Content")
|
|
}
|
|
}
|