feat: add retrospective MCP tool

Adds internal/skills/retrospective/ — an MCP skill that reads a session
log and dispatches a worker subprocess (via ExecutorFn) to identify
learnings and write them to the brain. Follows the same executor pattern
as the TDD skill.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mathias Bergqvist
2026-04-17 20:45:22 +02:00
parent a2889645fc
commit 13ee0d7114
3 changed files with 169 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
// internal/skills/retrospective/handlers_test.go
package retrospective_test
import (
"context"
"encoding/json"
"testing"
iexec "github.com/mathiasbq/supervisor/internal/exec"
"github.com/mathiasbq/supervisor/internal/skills/retrospective"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestHandle_Retrospective_RequiresSessionID(t *testing.T) {
s := retrospective.New(retrospective.Config{})
_, err := s.Handle(context.Background(), "retrospective", json.RawMessage(`{}`))
assert.Error(t, err)
assert.Contains(t, err.Error(), "session_id")
}
func TestHandle_Retrospective_BuildsPromptWithSessionLog(t *testing.T) {
var capturedReq iexec.Request
s := retrospective.New(retrospective.Config{
SkillPrompt: "retrospective discipline",
DefaultModel: "ollama/test",
SessionsDir: t.TempDir(), // empty dir, no session file — that's OK, session.Read returns nil
ExecutorFn: func(_ context.Context, req iexec.Request) (iexec.Result, error) {
capturedReq = req
return iexec.Result{
Status: "pass",
Phase: "retrospective",
Skill: "retrospective",
Verified: true,
Message: "wrote 2 entries to brain",
}, nil
},
})
args, _ := json.Marshal(map[string]string{"session_id": "empty-session"})
out, err := s.Handle(context.Background(), "retrospective", args)
require.NoError(t, err)
var result iexec.Result
require.NoError(t, json.Unmarshal(out, &result))
assert.Equal(t, "pass", result.Status)
assert.Contains(t, capturedReq.SkillPrompt, "retrospective discipline")
assert.Contains(t, capturedReq.TaskPrompt, "empty-session")
}