feat: streaming del subproceso claude-code con --output-format stream-json

Implementa la Fase 1 del issue 0036: soporte de streaming en tiempo real
para el provider claude-code.

- Tipos puros de streaming en pkg/llm/types.go: StreamEventKind,
  StreamEvent, StreamFunc (pure core, sin side effects)
- Refactor de shell/llm/claudecode.go: nuevo code path executeStreaming
  que usa cmd.StdoutPipe + bufio.Scanner para leer linea a linea
- Parser parseStreamLine que mapea eventos JSON del CLI (system, assistant,
  result) a StreamEvent del dominio
- buildClaudeArgs ahora selecciona --output-format stream-json cuando
  streaming esta habilitado y StreamFunc presente
- Campos Streaming y ShowToolProgress en ClaudeCodeCfg (config schema)
- Backward compatible: streaming=false (default) no cambia comportamiento
- 40 tests (20 existentes + 20 nuevos) pasan sin errores

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-09 22:53:41 +00:00
parent 0933099365
commit 1bdf9344a2
4 changed files with 738 additions and 39 deletions
+13 -11
View File
@@ -112,17 +112,19 @@ type LLMProviderCfg struct {
// ClaudeCodeCfg configures the claude -p subprocess provider.
type ClaudeCodeCfg struct {
Binary string `yaml:"binary"` // path to claude binary (default: "claude")
Timeout time.Duration `yaml:"timeout"` // subprocess timeout (default: 5m)
DisableTools bool `yaml:"disable_tools"` // pass --tools "" to disable all internal tools
AllowedTools []string `yaml:"allowed_tools"` // tools claude -p can use internally (e.g. Bash, Read, Edit)
DisallowedTools []string `yaml:"disallowed_tools"` // tools to block
WorkingDir string `yaml:"working_dir"` // working directory for claude -p
PermissionMode string `yaml:"permission_mode"` // default, acceptEdits, bypassPermissions, plan
Model string `yaml:"model"` // inner model: sonnet, opus, haiku, or full name
FallbackModel string `yaml:"fallback_model"` // fallback model if primary is overloaded
SessionID string `yaml:"session_id"` // fixed session ID for continuity
AddDirs []string `yaml:"add_dirs"` // additional directories accessible
Binary string `yaml:"binary"` // path to claude binary (default: "claude")
Timeout time.Duration `yaml:"timeout"` // subprocess timeout (default: 5m)
DisableTools bool `yaml:"disable_tools"` // pass --tools "" to disable all internal tools
AllowedTools []string `yaml:"allowed_tools"` // tools claude -p can use internally (e.g. Bash, Read, Edit)
DisallowedTools []string `yaml:"disallowed_tools"` // tools to block
WorkingDir string `yaml:"working_dir"` // working directory for claude -p
PermissionMode string `yaml:"permission_mode"` // default, acceptEdits, bypassPermissions, plan
Model string `yaml:"model"` // inner model: sonnet, opus, haiku, or full name
FallbackModel string `yaml:"fallback_model"` // fallback model if primary is overloaded
SessionID string `yaml:"session_id"` // fixed session ID for continuity
AddDirs []string `yaml:"add_dirs"` // additional directories accessible
Streaming bool `yaml:"streaming"` // use --output-format stream-json for realtime progress
ShowToolProgress bool `yaml:"show_tool_progress"` // edit Matrix message to show tool usage progress
}
type LLMReasoningCfg struct {