Preserve manager skill bootstrap work

This commit is contained in:
2026-10-18 15:03:22 +01:00
parent 88595ebd55
commit ab9181eee9
13 changed files with 362 additions and 4 deletions
+14
View File
@@ -139,6 +139,20 @@ func (c *Chat) Sessions(ctx context.Context) ([]protocol.ChatSession, error) {
// It deliberately sends no model or permission override here: the endpoint's own
// defaults apply, exactly as the live check creates a session. The created
// session is returned with its directory lifted from location.directory.
// ActivateSkill uses the V2 experimental session skill endpoint. resume=false
// records the skill without starting an artificial turn; the first operator prompt
// is therefore the first model turn and receives the manager instructions.
func (c *Chat) ActivateSkill(ctx context.Context, id, skill string) error {
if !sessionID.MatchString(id) {
return fmt.Errorf("invalid OpenCode session id")
}
if strings.TrimSpace(skill) == "" {
return fmt.Errorf("empty OpenCode skill id")
}
_, err := c.call(ctx, "post", "/api/experimental/session/"+id+"/skill", map[string]any{"id": skill, "resume": false})
return err
}
func (c *Chat) Create(ctx context.Context, title, directory string) (protocol.ChatSession, error) {
body := struct {
Title string `json:"title"`
+18
View File
@@ -395,3 +395,21 @@ func TestOpenChatRejectsUnrunnableCLI(t *testing.T) {
t.Fatal("a missing CLI must fail detection, not open an endpoint")
}
}
func TestChatActivateSkillV2Shape(t *testing.T) {
var path, body string
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
path = r.URL.Path
data := make([]byte, r.ContentLength)
_, _ = r.Body.Read(data)
body = string(data)
w.WriteHeader(http.StatusNoContent)
}))
defer srv.Close()
if err := NewChat(&Connection{Backend: "v2", URL: srv.URL}).ActivateSkill(context.Background(), "ses_1", "pipelines-manager"); err != nil {
t.Fatal(err)
}
if path != "/api/experimental/session/ses_1/skill" || body != `{"id":"pipelines-manager","resume":false}` {
t.Fatalf("activate request = %s %s", path, body)
}
}