Drop the three-layer Claude subprocess orchestration (local model →
Claude verifier → cloud escalation). Skills now call LiteLLM directly
and return plain text to Claude Code, which decides what to do with it.
- Delete executor, orchestrator, verifier, result, attempts packages
- Simplify LiteLLMExecutor: Run(Request)→Result becomes Complete(model,sys,user)→(string,int64,error)
- Replace ExecutorFn with CompleteFunc in all 6 skill configs
- Rewrite all skill handlers to call Complete and return {"text","model","duration_ms"}
- Simplify config/models: remove Verifier/LlamaSwapURL, add ModelFor
- Bump version to v0.5.0
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
77 lines
2.0 KiB
Go
77 lines
2.0 KiB
Go
// internal/skills/retrospective/handlers.go
|
|
package retrospective
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/mathiasbq/supervisor/internal/session"
|
|
)
|
|
|
|
type retroArgs struct {
|
|
SessionID string `json:"session_id"`
|
|
Model string `json:"model,omitempty"`
|
|
}
|
|
|
|
// Handle dispatches the retrospective tool call.
|
|
func (s *Skill) Handle(ctx context.Context, tool string, args json.RawMessage) (json.RawMessage, error) {
|
|
if tool != "retrospective" {
|
|
return nil, fmt.Errorf("unknown retrospective tool: %s", tool)
|
|
}
|
|
var a retroArgs
|
|
if err := json.Unmarshal(args, &a); err != nil {
|
|
return nil, fmt.Errorf("parse args: %w", err)
|
|
}
|
|
if a.SessionID == "" {
|
|
return nil, fmt.Errorf("session_id is required")
|
|
}
|
|
|
|
model := a.Model
|
|
if model == "" {
|
|
model = s.cfg.DefaultModel
|
|
}
|
|
|
|
entries, err := session.Read(s.cfg.SessionsDir, a.SessionID)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("read session log: %w", err)
|
|
}
|
|
|
|
logJSON, err := json.MarshalIndent(entries, "", " ")
|
|
if err != nil {
|
|
return nil, fmt.Errorf("marshal session log: %w", err)
|
|
}
|
|
|
|
taskPrompt := fmt.Sprintf(
|
|
"SESSION_ID: %s\n\nSESSION_LOG:\n%s\n\nReview this session log. Identify what is novel or worth preserving as organizational knowledge. Provide structured insights.",
|
|
a.SessionID, string(logJSON),
|
|
)
|
|
|
|
if s.cfg.CompleteFunc == nil {
|
|
return nil, fmt.Errorf("no executor configured")
|
|
}
|
|
t0 := time.Now()
|
|
text, dur, err := s.cfg.CompleteFunc(ctx, model, s.cfg.SkillPrompt, taskPrompt)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("retrospective model: %w", err)
|
|
}
|
|
|
|
msg := text
|
|
if len(msg) > 200 {
|
|
msg = msg[:200]
|
|
}
|
|
_ = session.Append(s.cfg.SessionsDir, a.SessionID, session.Entry{
|
|
SessionID: a.SessionID,
|
|
Timestamp: time.Now(),
|
|
Skill: "retrospective",
|
|
Phase: "retrospective",
|
|
FinalStatus: "ok",
|
|
ModelUsed: model,
|
|
DurationMs: time.Since(t0).Milliseconds(),
|
|
Message: msg,
|
|
})
|
|
|
|
return json.Marshal(map[string]any{"text": text, "model": model, "duration_ms": dur})
|
|
}
|