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>
50 lines
1.6 KiB
Go
50 lines
1.6 KiB
Go
// 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")
|
|
}
|