mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-10-19 09:13:28 +00:00
feat: Result monad in shared + Claude Code fixtures + SPA Result adoption (#1858)
* refactor: split SPA into helpers + main, add build script and tests Split slack-bot.ts into helpers.ts (pure functions) and main.ts (entry point) for testability. Add build.ts to bundle SPA into spa.js. Add spa.test.ts with 19 tests covering stream parsing and text helpers. Improved streaming: tool_use and tool_result events get their own Slack messages instead of concatenating everything into one. Prompt is passed via stdin to avoid CLI flag parsing issues with user content. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: drop build.ts — run main.ts directly via bun Bun runs TypeScript natively, no bundling step needed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: move Result monad to shared, add Claude Code fixtures, use Result in SPA - Move Result type/Ok/Err from packages/cli/src/shared/result.ts to packages/shared/src/result.ts and re-export from @openrouter/spawn-shared - Update CLI imports (ui.ts) to use the shared package - Add fixtures/claude-code/ with realistic stream-json events covering all event types (assistant text, tool_use, user tool_result, result) - Refactor SPA helpers to return Result<T> instead of throwing/returning null: loadState() → Result<State>, saveState() → Result<void>, downloadSlackFile() → Result<string>, addMapping() → Result<void> - Update main.ts call sites to handle Result returns - Update SPA tests to import events from fixtures and test Result returns - Bump CLI version 0.10.0 → 0.10.1 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: biome format issues in aws.test.ts, aws.ts, daytona.ts Expand inline objects/arrays to multi-line format to satisfy biome formatter rules. No logic changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude <claude@anthropic.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
65f6f1be32
commit
f5f020d250
15 changed files with 882 additions and 347 deletions
7
fixtures/claude-code/_metadata.json
Normal file
7
fixtures/claude-code/_metadata.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"agent": "claude-code",
|
||||
"recorded_at": "2026-02-24T00:00:00Z",
|
||||
"fixtures": {
|
||||
"stream-events": {"format": "stream-json", "type": "synthetic", "recorded_at": "2026-02-24T00:00:00Z"}
|
||||
}
|
||||
}
|
||||
107
fixtures/claude-code/stream-events.json
Normal file
107
fixtures/claude-code/stream-events.json
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
[
|
||||
{
|
||||
"type": "assistant",
|
||||
"message": {
|
||||
"id": "msg_01ABC",
|
||||
"type": "message",
|
||||
"role": "assistant",
|
||||
"content": [
|
||||
{"type": "text", "text": "I'll look at the issue and check the repository structure."}
|
||||
],
|
||||
"model": "claude-sonnet-4-20250514",
|
||||
"stop_reason": "end_turn"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "assistant",
|
||||
"message": {
|
||||
"id": "msg_01DEF",
|
||||
"type": "message",
|
||||
"role": "assistant",
|
||||
"content": [
|
||||
{"type": "tool_use", "id": "toolu_01ABC", "name": "Bash", "input": {"command": "gh issue list --repo OpenRouterTeam/spawn --state open --limit 5"}}
|
||||
],
|
||||
"model": "claude-sonnet-4-20250514",
|
||||
"stop_reason": "tool_use"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "user",
|
||||
"message": {
|
||||
"id": "msg_user_01",
|
||||
"type": "message",
|
||||
"role": "user",
|
||||
"content": [
|
||||
{"type": "tool_result", "tool_use_id": "toolu_01ABC", "content": "#1234 [Bug]: Fly.io deploy fails on arm64\n#1235 [CLI]: Add --json flag to list command", "is_error": false}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "assistant",
|
||||
"message": {
|
||||
"id": "msg_01GHI",
|
||||
"type": "message",
|
||||
"role": "assistant",
|
||||
"content": [
|
||||
{"type": "tool_use", "id": "toolu_01DEF", "name": "Glob", "input": {"pattern": "**/*.ts"}}
|
||||
],
|
||||
"model": "claude-sonnet-4-20250514",
|
||||
"stop_reason": "tool_use"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "user",
|
||||
"message": {
|
||||
"id": "msg_user_02",
|
||||
"type": "message",
|
||||
"role": "user",
|
||||
"content": [
|
||||
{"type": "tool_result", "tool_use_id": "toolu_01DEF", "content": "packages/cli/src/index.ts\npackages/cli/src/commands.ts\npackages/cli/src/manifest.ts", "is_error": false}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "assistant",
|
||||
"message": {
|
||||
"id": "msg_01JKL",
|
||||
"type": "message",
|
||||
"role": "assistant",
|
||||
"content": [
|
||||
{"type": "tool_use", "id": "toolu_01GHI", "name": "Read", "input": {"file_path": "/home/user/spawn/packages/cli/src/index.ts"}}
|
||||
],
|
||||
"model": "claude-sonnet-4-20250514",
|
||||
"stop_reason": "tool_use"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "user",
|
||||
"message": {
|
||||
"id": "msg_user_03",
|
||||
"type": "message",
|
||||
"role": "user",
|
||||
"content": [
|
||||
{"type": "tool_result", "tool_use_id": "toolu_01GHI", "content": "Command execution failed: Permission denied", "is_error": true}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "assistant",
|
||||
"message": {
|
||||
"id": "msg_01MNO",
|
||||
"type": "message",
|
||||
"role": "assistant",
|
||||
"content": [
|
||||
{"type": "text", "text": "I've reviewed the open issues. Here's a summary:\n\n1. **#1234** - Fly.io deploy fails on arm64 architecture\n2. **#1235** - Request to add `--json` flag to the list command\n\nWould you like me to create a new issue or work on one of these?"}
|
||||
],
|
||||
"model": "claude-sonnet-4-20250514",
|
||||
"stop_reason": "end_turn"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "result",
|
||||
"subtype": "success",
|
||||
"session_id": "abc123-def456-ghi789",
|
||||
"is_error": false,
|
||||
"result": "I've reviewed the open issues and provided a summary."
|
||||
}
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue