Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(cli): allow autopilot squad assignees (#4576 rebased onto main) (#10709)
Akkia1c2169168997
diff --git a/CLI_AND_DAEMON.md b/CLI_AND_DAEMON.mdindex 6ae04985a2..85da96f480 100644--- a/CLI_AND_DAEMON.md+++ b/CLI_AND_DAEMON.md@@ -1110,7 +1110,14 @@ multica autopilot create \--mode create_issue \--subscriber "Alice"+multica autopilot create \+ --title "Weekly dependency audit" \+ --description "Audit dependencies for security updates." \+ --squad "Backend Squad" \+ --mode create_issue+multica autopilot update <id> --status paused+multica autopilot update <id> --squad-id <squad-uuid>multica autopilot update <id> --description "New prompt"multica autopilot update <id> --subscriber "Alice" --subscriber "Bob"multica autopilot update <id> --clear-subscribers@@ -1118,6 +1125,7 @@ multica autopilot delete <id>````--mode` accepts `create_issue` (creates a new issue on each run and assigns it to the agent) or `run_only` (enqueues a direct agent task without creating an issue). `--agent` accepts either a name or UUID.+To assign a squad instead, use `--squad` (name or ID) or `--squad-id` (canonical UUID); the run goes to the squad's leader, and in `create_issue` mode the created issue is assigned to the squad. `--agent`, `--squad`, and `--squad-id` are mutually exclusive, and `create` requires one of them. On `update` they switch the assignee (sending `assignee_type` with `assignee_id`); an update without any of them leaves the current assignee untouched. Table output labels the assignee by type, e.g. `squad:Backend Squad`.`--subscriber` accepts a workspace member name or user ID and may be repeated; on update it replaces the autopilot's subscriber template. Subscribers receive inbox notifications for issues created by a `create_issue` autopilot. Use `--clear-subscribers` to remove all autopilot subscribers.### Manual Triggerdiff --git a/apps/docs/content/docs/cli.fr.mdx b/apps/docs/content/docs/cli.fr.mdxindex e0a9feed2c..197ed2bf75 100644--- a/apps/docs/content/docs/cli.fr.mdx+++ b/apps/docs/content/docs/cli.fr.mdx@@ -498,7 +498,7 @@ Les tableaux ci-dessous couvrent toutes les commandes de premier niveau actuelle| | `env get/set <agent-id>` | Lire et écrire les variables d'environnement personnalisées (propriétaire de l'agent ou owner/admin de l'espace de travail ; chaque lecture est enregistrée) | `set` : `--custom-env` / `--custom-env-file` / `--custom-env-stdin` ; remplace l'ensemble, et les clés dont la valeur est `****` gardent leur valeur || | `skills list/set/add <agent-id>` | Gérer les skills rattachés | `--skill-ids` (`set` remplace toute la liste, `add` ajoute à la suite) || | `mcp list/add/enable/disable/remove <agent-id>` | Assigner des serveurs MCP de l'espace de travail à cet agent | Récupérez l'ID du serveur avec `workspace mcp list`. Une entrée de la bibliothèque n'a aucun effet tant qu'elle n'est pas ajoutée ici ; `disable` cesse de l'envoyer sans supprimer l'assignation |-| `autopilot` | `list/get/create/update/delete` | Gérer les automatisations | `create` : `--title`, `--agent`, `--mode` (tous obligatoires), `--description`, `--issue-title-template`, `--project`, `--subscriber` (répétable) |+| `autopilot` | `list/get/create/update/delete` | Gérer les automatisations | `create` : `--title`, `--mode` (obligatoires), exactement une option parmi `--agent` / `--squad` / `--squad-id` (obligatoire), `--description`, `--issue-title-template`, `--project`, `--subscriber` (répétable) || | `trigger <id>` | Déclencher une exécution manuellement | || | `runs <id>` | Afficher l'historique des exécutions | || | `trigger-add/trigger-update/trigger-delete/trigger-rotate-url` | Gérer les déclencheurs de planification et webhook | `trigger-add` : `--kind` (`schedule` ou `webhook`), `--cron`, `--timezone` (UTC par défaut), `--label` |diff --git a/apps/docs/content/docs/cli.ja.mdx b/apps/docs/content/docs/cli.ja.mdxindex cbb6ad7e9b..80cdaf16ea 100644--- a/apps/docs/content/docs/cli.ja.mdx+++ b/apps/docs/content/docs/cli.ja.mdx@@ -490,7 +490,7 @@ CLI の設定ファイルには、あなたとして Multica にアクセスで| | `env get/set <agent-id>` | カスタム環境変数の読み書き(エージェントの所有者、またはワークスペースの owner/admin。読み取りはすべて記録される) | `set`: `--custom-env` / `--custom-env-file` / `--custom-env-stdin`。全体を置き換え、値が `****` のキーは元の値を保つ || | `skills list/set/add <agent-id>` | 紐付けられたスキルを管理 | `--skill-ids`(`set` は全置換、`add` は追加) || | `mcp list/add/enable/disable/remove <agent-id>` | ワークスペース MCP サーバーをこのエージェントに割り当て | server id は `workspace mcp list` から取得。ライブラリの項目はここで追加するまで機能しません。`disable` は割り当てを残したまま送信を停止します |-| `autopilot` | `list/get/create/update/delete` | オートパイロットを管理 | `create`: `--title`、`--agent`、`--mode`(いずれも必須)、`--description`、`--issue-title-template`、`--project`、`--subscriber`(繰り返し可) |+| `autopilot` | `list/get/create/update/delete` | オートパイロットを管理 | `create`: `--title`、`--mode`(どちらも必須)、`--agent` / `--squad` / `--squad-id` のいずれか1つ(必須)、`--description`、`--issue-title-template`、`--project`、`--subscriber`(繰り返し可) || | `trigger <id>` | 手動で 1 回トリガー | || | `runs <id>` | 実行履歴を表示 | || | `trigger-add/trigger-update/trigger-delete/trigger-rotate-url` | スケジュールと webhook のトリガーを管理 | `trigger-add`: `--kind`(`schedule` または `webhook`)、`--cron`、`--timezone`(既定は UTC)、`--label` |diff --git a/apps/docs/content/docs/cli.ko.mdx b/apps/docs/content/docs/cli.ko.mdxindex aa1e543df4..c5d4c36027 100644--- a/apps/docs/content/docs/cli.ko.mdx+++ b/apps/docs/content/docs/cli.ko.mdx@@ -490,7 +490,7 @@ CLI 설정 파일에는 사용자를 대신해 Multica에 접근할 수 있는 t| | `env get/set <agent-id>` | 사용자 지정 환경 변수 읽기/쓰기(에이전트 소유자 또는 워크스페이스 owner/admin. 읽을 때마다 기록됨) | `set`: `--custom-env` / `--custom-env-file` / `--custom-env-stdin`. 전체를 교체하며 값이 `****`인 키는 기존 값 유지 || | `skills list/set/add <agent-id>` | 연결된 스킬 관리 | `--skill-ids`(`set`은 전체 교체, `add`는 증분 추가) || | `mcp list/add/enable/disable/remove <agent-id>` | 워크스페이스 MCP 서버를 이 에이전트에 할당 | server id는 `workspace mcp list`에서 확인. 라이브러리 항목은 여기서 추가하기 전까지 동작하지 않으며, `disable`은 할당을 유지한 채 전달만 중단합니다 |-| `autopilot` | `list/get/create/update/delete` | 자동화 관리 | `create`: `--title`, `--agent`, `--mode`(모두 필수), `--description`, `--issue-title-template`, `--project`, `--subscriber`(반복 가능) |+| `autopilot` | `list/get/create/update/delete` | 자동화 관리 | `create`: `--title`, `--mode`(둘 다 필수), `--agent` / `--squad` / `--squad-id` 중 하나만(필수), `--description`, `--issue-title-template`, `--project`, `--subscriber`(반복 가능) || | `trigger <id>` | 수동으로 한 번 트리거 | || | `runs <id>` | 실행 기록 확인 | || | `trigger-add/trigger-update/trigger-delete/trigger-rotate-url` | 일정 및 webhook 트리거 관리 | `trigger-add`: `--kind`(`schedule` 또는 `webhook`), `--cron`, `--timezone`(기본값 UTC), `--label` |diff --git a/apps/docs/content/docs/cli.mdx b/apps/docs/content/docs/cli.mdxindex 31102e454d..883f413633 100644--- a/apps/docs/content/docs/cli.mdx+++ b/apps/docs/content/docs/cli.mdx@@ -525,7 +525,7 @@ Migration from CSV parsing: replace `--attachment a,b` with `--attachment a --at| | `env get/set <agent-id>` | Read and write custom environment variables (agent owner or workspace owner/admin; every read is recorded) | `set`: `--custom-env` / `--custom-env-file` / `--custom-env-stdin`; replaces the whole set, and keys whose value is `****` keep their existing value || | `skills list/set/add <agent-id>` | Manage attached skills | `--skill-ids` (`set` replaces the full list, `add` appends) || | `mcp list/add/enable/disable/remove <agent-id>` | Assign workspace MCP servers to this agent | Take the server id from `workspace mcp list`. A library entry does nothing until it is added here; `disable` stops sending it without dropping the assignment |-| `autopilot` | `list/get/create/update/delete` | Manage automations | `create`: `--title`, `--agent`, `--mode` (all required), `--description`, `--issue-title-template`, `--project`, `--subscriber` (repeatable) |+| `autopilot` | `list/get/create/update/delete` | Manage automations | `create`: `--title`, `--mode` (both required), exactly one of `--agent` / `--squad` / `--squad-id` (required), `--description`, `--issue-title-template`, `--project`, `--subscriber` (repeatable) || | `trigger <id>` | Trigger a run manually | || | `runs <id>` | View run history | || | `trigger-add/trigger-update/trigger-delete/trigger-rotate-url` | Manage schedule and webhook triggers | `trigger-add`: `--kind` (`schedule` or `webhook`), `--cron`, `--timezone` (default UTC), `--label` |diff --git a/apps/docs/content/docs/cli.zh-Hant.mdx b/apps/docs/content/docs/cli.zh-Hant.mdxindex 2e4a0e6000..42694c2d18 100644--- a/apps/docs/content/docs/cli.zh-Hant.mdx+++ b/apps/docs/content/docs/cli.zh-Hant.mdx@@ -499,7 +499,7 @@ CLI 配置檔案包含可代表你訪問 Multica 的令牌。不要提交到倉| | `env get/set <agent-id>` | 讀寫自定義環境變數(AI 代理所有者或工作區 owner/admin;每次讀取都會記錄) | `set`:`--custom-env` / `--custom-env-file` / `--custom-env-stdin`,整體替換,值為 `****` 的鍵保留原值 || | `skills list/set/add <agent-id>` | 管理繫結的 skill | `--skill-ids`(`set` 全量替換,`add` 增量新增) || | `mcp list/add/enable/disable/remove <agent-id>` | 給該 agent 分配工作區 MCP 服務 | server id 從 `workspace mcp list` 獲取。庫裡的條目在這裡新增之前不會生效;`disable` 只停止下發,保留分配 |-| `autopilot` | `list/get/create/update/delete` | 管理自動化 | `create`:`--title`、`--agent`、`--mode`(均必填)、`--description`、`--issue-title-template`、`--project`、`--subscriber`(可重複) |+| `autopilot` | `list/get/create/update/delete` | 管理自動化 | `create`:`--title`、`--mode`(均必填)、`--agent` / `--squad` / `--squad-id`(三選一,必填)、`--description`、`--issue-title-template`、`--project`、`--subscriber`(可重複) || | `trigger <id>` | 手動觸發一次 | || | `runs <id>` | 檢視執行歷史 | || | `trigger-add/trigger-update/trigger-delete/trigger-rotate-url` | 管理定時和 webhook 觸發器 | `trigger-add`:`--kind`(`schedule` 或 `webhook`)、`--cron`、`--timezone`(預設 UTC)、`--label` |diff --git a/apps/docs/content/docs/cli.zh.mdx b/apps/docs/content/docs/cli.zh.mdxindex da335db5e0..e8b035f205 100644--- a/apps/docs/content/docs/cli.zh.mdx+++ b/apps/docs/content/docs/cli.zh.mdx@@ -502,7 +502,7 @@ CLI 配置文件包含可代表你访问 Multica 的令牌。不要提交到仓| | `env get/set <agent-id>` | 读写自定义环境变量(智能体所有者或工作区 owner/admin;每次读取都会记录) | `set`:`--custom-env` / `--custom-env-file` / `--custom-env-stdin`,整体替换,值为 `****` 的键保留原值 || | `skills list/set/add <agent-id>` | 管理绑定的 skill | `--skill-ids`(`set` 全量替换,`add` 增量添加) || | `mcp list/add/enable/disable/remove <agent-id>` | 给该 agent 分配工作区 MCP 服务 | server id 从 `workspace mcp list` 获取。库里的条目在这里添加之前不会生效;`disable` 只停止下发,保留分配 |-| `autopilot` | `list/get/create/update/delete` | 管理自动化 | `create`:`--title`、`--agent`、`--mode`(均必填)、`--description`、`--issue-title-template`、`--project`、`--subscriber`(可重复) |+| `autopilot` | `list/get/create/update/delete` | 管理自动化 | `create`:`--title`、`--mode`(均必填)、`--agent` / `--squad` / `--squad-id`(三选一,必填)、`--description`、`--issue-title-template`、`--project`、`--subscriber`(可重复) || | `trigger <id>` | 手动触发一次 | || | `runs <id>` | 查看运行历史 | || | `trigger-add/trigger-update/trigger-delete/trigger-rotate-url` | 管理定时和 webhook 触发器 | `trigger-add`:`--kind`(`schedule` 或 `webhook`)、`--cron`、`--timezone`(默认 UTC)、`--label` |diff --git a/server/cmd/multica/cmd_autopilot.go b/server/cmd/multica/cmd_autopilot.goindex c0a30562ba..6aa675669d 100644--- a/server/cmd/multica/cmd_autopilot.go+++ b/server/cmd/multica/cmd_autopilot.go@@ -131,7 +131,9 @@ func init() {// createautopilotCreateCmd.Flags().String("title", "", "Autopilot title (required)")autopilotCreateCmd.Flags().String("description", "", "Autopilot description (used as the run prompt)")- autopilotCreateCmd.Flags().String("agent", "", "Assignee agent (name or ID) — required")+ autopilotCreateCmd.Flags().String("agent", "", "Assignee agent (name or ID)")+ autopilotCreateCmd.Flags().String("squad", "", "Assignee squad (name or ID)")+ autopilotCreateCmd.Flags().String("squad-id", "", "Assignee squad ID (canonical UUID)")autopilotCreateCmd.Flags().String("mode", "", "Execution mode: create_issue or run_only (required)")autopilotCreateCmd.Flags().String("project", "", "Project ID (optional)")autopilotCreateCmd.Flags().String("issue-title-template", "", "Template for issue titles (create_issue mode). Only {{date}} (UTC, YYYY-MM-DD) is interpolated; any other {{...}} token is rejected at create-time.")@@ -142,6 +144,8 @@ func init() {autopilotUpdateCmd.Flags().String("title", "", "New title")autopilotUpdateCmd.Flags().String("description", "", "New description")autopilotUpdateCmd.Flags().String("agent", "", "New assignee agent (name or ID)")+ autopilotUpdateCmd.Flags().String("squad", "", "New assignee squad (name or ID)")+ autopilotUpdateCmd.Flags().String("squad-id", "", "New assignee squad ID (canonical UUID)")autopilotUpdateCmd.Flags().String("project", "", "New project ID (use empty string to clear)")autopilotUpdateCmd.Flags().String("status", "", "New status (active, paused)")autopilotUpdateCmd.Flags().String("mode", "", "New execution mode (create_issue or run_only)")@@ -233,7 +237,7 @@ func runAutopilotList(cmd *cobra.Command, _ []string) error {strVal(a, "status"),displayLastRunStatus(strVal(a, "last_run_status")),strVal(a, "execution_mode"),- actors.agent(strVal(a, "assignee_id")),+ formatAutopilotAssignee(a, actors),relativeTimestamp(strVal(a, "next_run_at")),relativeTimestamp(strVal(a, "last_run_at")),})@@ -293,7 +297,7 @@ func runAutopilotGet(cmd *cobra.Command, args []string) error {strVal(ap, "title"),strVal(ap, "status"),strVal(ap, "execution_mode"),- actors.agent(strVal(ap, "assignee_id")),+ formatAutopilotAssignee(ap, actors),strVal(ap, "last_run_at"),}}cli.PrintTable(os.Stdout, headers, rows)@@ -401,10 +405,6 @@ func runAutopilotCreate(cmd *cobra.Command, _ []string) error {if title == "" {return fmt.Errorf("--title is required")}- agent, _ := cmd.Flags().GetString("agent")- if agent == "" {- return fmt.Errorf("--agent is required (agent name or ID)")- }mode, _ := cmd.Flags().GetString("mode")if mode == "" {return fmt.Errorf("--mode is required (create_issue or run_only)")@@ -416,14 +416,18 @@ func runAutopilotCreate(cmd *cobra.Command, _ []string) error {ctx, cancel := cli.APIContext(context.Background())defer cancel()- agentID, err := resolveAgent(ctx, client, agent)+ assigneeType, assigneeID, hasAssignee, err := resolveAutopilotAssigneeFromFlags(ctx, client, cmd, true)if err != nil {- return fmt.Errorf("resolve agent: %w", err)+ return err+ }+ if !hasAssignee {+ return fmt.Errorf("--agent, --squad, or --squad-id is required")}body := map[string]any{"title": title,- "assignee_id": agentID,+ "assignee_type": assigneeType,+ "assignee_id": assigneeID,"execution_mode": mode,}if v, _ := cmd.Flags().GetString("description"); v != "" {@@ -483,14 +487,13 @@ func runAutopilotUpdate(cmd *cobra.Command, args []string) error {v, _ := cmd.Flags().GetString("description")body["description"] = v}- if cmd.Flags().Changed("agent") {- v, _ := cmd.Flags().GetString("agent")- agentID, resolveErr := resolveAgent(ctx, client, v)- if resolveErr != nil {- return fmt.Errorf("resolve agent: %w", resolveErr)- }- body["assignee_type"] = "agent"- body["assignee_id"] = agentID+ assigneeType, assigneeID, hasAssignee, err := resolveAutopilotAssigneeFromFlags(ctx, client, cmd, false)+ if err != nil {+ return err+ }+ if hasAssignee {+ body["assignee_type"] = assigneeType+ body["assignee_id"] = assigneeID}if cmd.Flags().Changed("project") {v, _ := cmd.Flags().GetString("project")@@ -1126,6 +1129,59 @@ func resolveAutopilotSubscriberInputs(ctx context.Context, client *cli.APIClientreturn inputs, nil}+func resolveAutopilotAssigneeFromFlags(ctx context.Context, client *cli.APIClient, cmd *cobra.Command, required bool) (string, string, bool, error) {+ agentSet := cmd.Flags().Changed("agent")+ squadSet := cmd.Flags().Changed("squad")+ squadIDSet := cmd.Flags().Changed("squad-id")++ setCount := 0+ for _, set := range []bool{agentSet, squadSet, squadIDSet} {+ if set {+ setCount+++ }+ }+ if setCount > 1 {+ return "", "", false, fmt.Errorf("--agent, --squad, and --squad-id are mutually exclusive")+ }+ if setCount == 0 {+ if required {+ return "", "", false, fmt.Errorf("--agent, --squad, or --squad-id is required")+ }+ return "", "", false, nil+ }++ if agentSet {+ ref, _ := cmd.Flags().GetString("agent")+ if strings.TrimSpace(ref) == "" {+ return "", "", true, fmt.Errorf("--agent cannot be empty")+ }+ agentID, err := resolveAgent(ctx, client, ref)+ if err != nil {+ return "", "", true, fmt.Errorf("resolve agent: %w", err)+ }+ return "agent", agentID, true, nil+ }++ if squadIDSet {+ id, _ := cmd.Flags().GetString("squad-id")+ id = strings.TrimSpace(id)+ if !uuidRegexp.MatchString(id) {+ return "", "", true, fmt.Errorf("--squad-id must be a canonical UUID")+ }+ return "squad", id, true, nil+ }++ ref, _ := cmd.Flags().GetString("squad")+ if strings.TrimSpace(ref) == "" {+ return "", "", true, fmt.Errorf("--squad cannot be empty")+ }+ squadID, err := resolveSquad(ctx, client, ref)+ if err != nil {+ return "", "", true, fmt.Errorf("resolve squad: %w", err)+ }+ return "squad", squadID, true, nil+}+// Helpers// uuidRegexp matches a canonical UUID (8-4-4-4-12 hex).@@ -1157,3 +1213,32 @@ func resolveAgent(ctx context.Context, client *cli.APIClient, nameOrID string) (_, agentID, err := matchAssignee(nameOrID, assigneeKinds{agent: true}, candidates)return agentID, err}++// resolveSquad accepts either a UUID or a squad name (case-insensitive, with+// exact matches preferred by resolveAssignee) and returns the squad UUID.+func resolveSquad(ctx context.Context, client *cli.APIClient, nameOrID string) (string, error) {+ if uuidRegexp.MatchString(nameOrID) {+ return nameOrID, nil+ }+ squadOnly := assigneeKinds{squad: true}+ kind, id, err := resolveAssignee(ctx, client, nameOrID, squadOnly)+ if err != nil {+ return "", err+ }+ if kind != "squad" {+ return "", fmt.Errorf("%q resolved to %s; autopilot assignee must be an agent or squad", nameOrID, kind)+ }+ return id, nil+}++func formatAutopilotAssignee(autopilot map[string]any, actors actorDisplayLookup) string {+ aID := strVal(autopilot, "assignee_id")+ if aID == "" {+ return ""+ }+ aType := strVal(autopilot, "assignee_type")+ if aType == "" {+ aType = "agent"+ }+ return actors.actor(aType, aID)+}diff --git a/server/cmd/multica/cmd_autopilot_test.go b/server/cmd/multica/cmd_autopilot_test.goindex b9960ea038..f1fb1c34fd 100644--- a/server/cmd/multica/cmd_autopilot_test.go+++ b/server/cmd/multica/cmd_autopilot_test.go@@ -19,6 +19,8 @@ func newAutopilotCreateTestCmd() *cobra.Command {cmd.Flags().String("title", "", "")cmd.Flags().String("description", "", "")cmd.Flags().String("agent", "", "")+ cmd.Flags().String("squad", "", "")+ cmd.Flags().String("squad-id", "", "")cmd.Flags().String("mode", "", "")cmd.Flags().String("project", "", "")cmd.Flags().String("issue-title-template", "", "")@@ -32,6 +34,8 @@ func newAutopilotUpdateTestCmd() *cobra.Command {cmd.Flags().String("title", "", "")cmd.Flags().String("description", "", "")cmd.Flags().String("agent", "", "")+ cmd.Flags().String("squad", "", "")+ cmd.Flags().String("squad-id", "", "")cmd.Flags().String("project", "", "")cmd.Flags().String("status", "", "")cmd.Flags().String("mode", "", "")@@ -559,6 +563,64 @@ func TestResolveAgentOverlappingNames(t *testing.T) {}}+func TestResolveSquad(t *testing.T) {+ squadsResp := []map[string]any{+ {"id": "11111111-1111-1111-1111-111111111111", "name": "Platform Squad"},+ {"id": "22222222-2222-2222-2222-222222222222", "name": "CLI Squad"},+ {"id": "33333333-3333-3333-3333-333333333333", "name": "Archived Squad", "archived_at": "2026-01-01T00:00:00Z"},+ }++ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if r.URL.Path == "/api/squads" {+ json.NewEncoder(w).Encode(squadsResp)+ return+ }+ http.NotFound(w, r)+ }))+ defer srv.Close()++ client := cli.NewAPIClient(srv.URL, "ws-1", "test-token")+ ctx := context.Background()++ t.Run("passes through a UUID without lookup", func(t *testing.T) {+ id := "44444444-4444-4444-4444-444444444444"+ got, err := resolveSquad(ctx, client, id)+ if err != nil {+ t.Fatalf("unexpected error: %v", err)+ }+ if got != id {+ t.Errorf("got %q, want %q", got, id)+ }+ })++ t.Run("exact name match", func(t *testing.T) {+ got, err := resolveSquad(ctx, client, "CLI Squad")+ if err != nil {+ t.Fatalf("unexpected error: %v", err)+ }+ if got != "22222222-2222-2222-2222-222222222222" {+ t.Errorf("got %q, want CLI Squad's UUID", got)+ }+ })++ t.Run("short id match", func(t *testing.T) {+ got, err := resolveSquad(ctx, client, "11111111")+ if err != nil {+ t.Fatalf("unexpected error: %v", err)+ }+ if got != "11111111-1111-1111-1111-111111111111" {+ t.Errorf("got %q, want Platform Squad's UUID", got)+ }+ })++ t.Run("archived squad is ignored", func(t *testing.T) {+ _, err := resolveSquad(ctx, client, "Archived Squad")+ if err == nil {+ t.Fatal("expected error for archived squad")+ }+ })+}+func TestRunAutopilotCreateSendsProjectID(t *testing.T) {const (agentID = "11111111-1111-1111-1111-111111111111"@@ -601,6 +663,58 @@ func TestRunAutopilotCreateSendsProjectID(t *testing.T) {if got := body["project_id"]; got != projectID {t.Fatalf("project_id = %#v, want %q", got, projectID)}+ if got := body["assignee_type"]; got != "agent" {+ t.Fatalf("assignee_type = %#v, want agent", got)+ }+}++func TestRunAutopilotCreateSendsSquadAssignee(t *testing.T) {+ const squadID = "22222222-2222-2222-2222-222222222222"++ var body map[string]any+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ switch r.URL.Path {+ case "/api/squads":+ json.NewEncoder(w).Encode([]map[string]any{+ {"id": squadID, "name": "CLI Squad"},+ })+ case "/api/autopilots":+ if r.Method != http.MethodPost {+ t.Errorf("method = %s, want POST", r.Method)+ }+ if err := json.NewDecoder(r.Body).Decode(&body); err != nil {+ t.Errorf("decode body: %v", err)+ }+ json.NewEncoder(w).Encode(map[string]any{+ "id": "autopilot-1",+ "title": "Squad planner",+ "assignee_type": body["assignee_type"],+ "assignee_id": body["assignee_id"],+ })+ default:+ http.NotFound(w, r)+ }+ }))+ defer srv.Close()++ t.Setenv("MULTICA_SERVER_URL", srv.URL)+ t.Setenv("MULTICA_WORKSPACE_ID", "ws-1")+ t.Setenv("MULTICA_TOKEN", "test-token")++ cmd := newAutopilotCreateTestCmd()+ _ = cmd.Flags().Set("title", "Squad planner")+ _ = cmd.Flags().Set("squad", "CLI Squad")+ _ = cmd.Flags().Set("mode", "create_issue")++ if err := runAutopilotCreate(cmd, nil); err != nil {+ t.Fatalf("runAutopilotCreate: %v", err)+ }+ if got := body["assignee_type"]; got != "squad" {+ t.Fatalf("assignee_type = %#v, want squad", got)+ }+ if got := body["assignee_id"]; got != squadID {+ t.Fatalf("assignee_id = %#v, want %q", got, squadID)+ }}func TestRunAutopilotCreateSendsSubscribers(t *testing.T) {@@ -759,6 +873,70 @@ func TestRunAutopilotUpdateAgentSwitchesAssigneeType(t *testing.T) {}}+func TestRunAutopilotUpdateSendsSquadAssigneePair(t *testing.T) {+ const (+ autopilotID = "33333333-3333-3333-3333-333333333333"+ squadID = "22222222-2222-2222-2222-222222222222"+ )++ var body map[string]any+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if r.URL.Path != "/api/autopilots/"+autopilotID {+ http.NotFound(w, r)+ return+ }+ if r.Method != http.MethodPatch {+ t.Errorf("method = %s, want PATCH", r.Method)+ }+ if err := json.NewDecoder(r.Body).Decode(&body); err != nil {+ t.Errorf("decode body: %v", err)+ }+ json.NewEncoder(w).Encode(map[string]any{+ "id": autopilotID,+ "title": "Daily planner",+ "assignee_type": body["assignee_type"],+ "assignee_id": body["assignee_id"],+ })+ }))+ defer srv.Close()++ t.Setenv("MULTICA_SERVER_URL", srv.URL)+ t.Setenv("MULTICA_WORKSPACE_ID", "ws-1")+ t.Setenv("MULTICA_TOKEN", "test-token")++ cmd := newAutopilotUpdateTestCmd()+ _ = cmd.Flags().Set("squad-id", squadID)+ if err := runAutopilotUpdate(cmd, []string{autopilotID}); err != nil {+ t.Fatalf("runAutopilotUpdate: %v", err)+ }+ if got := body["assignee_type"]; got != "squad" {+ t.Fatalf("assignee_type = %#v, want squad", got)+ }+ if got := body["assignee_id"]; got != squadID {+ t.Fatalf("assignee_id = %#v, want %q", got, squadID)+ }+}++func TestRunAutopilotRejectsMultipleAssigneeFlags(t *testing.T) {+ t.Setenv("MULTICA_SERVER_URL", "http://127.0.0.1")+ t.Setenv("MULTICA_WORKSPACE_ID", "ws-1")+ t.Setenv("MULTICA_TOKEN", "test-token")++ cmd := newAutopilotCreateTestCmd()+ _ = cmd.Flags().Set("title", "Daily planner")+ _ = cmd.Flags().Set("agent", "11111111-1111-1111-1111-111111111111")+ _ = cmd.Flags().Set("squad-id", "22222222-2222-2222-2222-222222222222")+ _ = cmd.Flags().Set("mode", "create_issue")++ err := runAutopilotCreate(cmd, nil)+ if err == nil {+ t.Fatal("expected mutually exclusive assignee flags error")+ }+ if !strings.Contains(err.Error(), "mutually exclusive") {+ t.Fatalf("error = %v, want mutually exclusive", err)+ }+}+func TestRunAutopilotUpdateSendsSubscriberReplacement(t *testing.T) {const (autopilotID = "33333333-3333-3333-3333-333333333333"@@ -1209,3 +1387,117 @@ func TestAutopilotTriggerRequestError_SurfacesRefusalToTheUser(t *testing.T) {}})}++func TestRunAutopilotListTableShowsSquadAssignee(t *testing.T) {+ const squadID = "22222222-2222-2222-2222-222222222222"++ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ switch r.URL.Path {+ case "/api/autopilots":+ _ = json.NewEncoder(w).Encode(map[string]any{+ "autopilots": []map[string]any{{+ "id": "11111111-1111-1111-1111-111111111111",+ "title": "Weekly sync check",+ "status": "active",+ "execution_mode": "create_issue",+ "assignee_type": "squad",+ "assignee_id": squadID,+ }},+ "total": 1,+ })+ case "/api/squads":+ _ = json.NewEncoder(w).Encode([]map[string]any{{"id": squadID, "name": "Backend Squad"}})+ default:+ http.NotFound(w, r)+ }+ }))+ defer srv.Close()++ setCLITestServerEnv(t, srv.URL)++ out, err := captureStdout(t, func() error {+ return runAutopilotList(newAutopilotListTestCmd(), nil)+ })+ if err != nil {+ t.Fatalf("runAutopilotList: %v", err)+ }+ if !strings.Contains(out, "squad:Backend Squad") {+ t.Fatalf("table output missing squad assignee label:\n%s", out)+ }+ if strings.Contains(out, squadID) {+ t.Fatalf("table output shows raw squad UUID instead of its name:\n%s", out)+ }+}++func TestRunAutopilotCreateRequiresAssignee(t *testing.T) {+ t.Setenv("MULTICA_SERVER_URL", "http://127.0.0.1")+ t.Setenv("MULTICA_WORKSPACE_ID", "ws-1")+ t.Setenv("MULTICA_TOKEN", "test-token")++ cmd := newAutopilotCreateTestCmd()+ _ = cmd.Flags().Set("title", "Daily planner")+ _ = cmd.Flags().Set("mode", "create_issue")++ err := runAutopilotCreate(cmd, nil)+ if err == nil || !strings.Contains(err.Error(), "--agent, --squad, or --squad-id is required") {+ t.Fatalf("error = %v, want missing assignee error", err)+ }+}++func TestRunAutopilotUpdateWithoutAssigneeFlagsKeepsAssignee(t *testing.T) {+ const autopilotID = "33333333-3333-3333-3333-333333333333"++ var body map[string]any+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if r.URL.Path != "/api/autopilots/"+autopilotID || r.Method != http.MethodPatch {+ http.NotFound(w, r)+ return+ }+ if err := json.NewDecoder(r.Body).Decode(&body); err != nil {+ t.Errorf("decode body: %v", err)+ }+ json.NewEncoder(w).Encode(map[string]any{"id": autopilotID, "status": body["status"]})+ }))+ defer srv.Close()++ t.Setenv("MULTICA_SERVER_URL", srv.URL)+ t.Setenv("MULTICA_WORKSPACE_ID", "ws-1")+ t.Setenv("MULTICA_TOKEN", "test-token")++ cmd := newAutopilotUpdateTestCmd()+ _ = cmd.Flags().Set("status", "paused")+ if err := runAutopilotUpdate(cmd, []string{autopilotID}); err != nil {+ t.Fatalf("runAutopilotUpdate: %v", err)+ }+ for _, key := range []string{"assignee_type", "assignee_id"} {+ if _, ok := body[key]; ok {+ t.Fatalf("%s sent on a status-only update; it would retarget a squad autopilot: %#v", key, body)+ }+ }+}++func TestFormatAutopilotAssignee(t *testing.T) {+ lookup := actorDisplayLookup{state: &actorDisplayLookupState{+ agentsLoaded: true,+ agents: map[string]string{"agent-1": "Lead"},+ squadsLoaded: true,+ squads: map[string]string{"squad-1": "Backend Squad"},+ }}+ tests := []struct {+ name string+ in map[string]any+ want string+ }{+ {"squad", map[string]any{"assignee_type": "squad", "assignee_id": "squad-1"}, "squad:Backend Squad"},+ {"agent", map[string]any{"assignee_type": "agent", "assignee_id": "agent-1"}, "agent:Lead"},+ {"legacy row without type", map[string]any{"assignee_id": "agent-1"}, "agent:Lead"},+ {"no assignee", map[string]any{}, ""},+ }+ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ if got := formatAutopilotAssignee(tt.in, lookup); got != tt.want {+ t.Fatalf("formatAutopilotAssignee() = %q, want %q", got, tt.want)+ }+ })+ }+}diff --git a/server/internal/service/builtin_skills/multica-platform/references/autopilots.md b/server/internal/service/builtin_skills/multica-platform/references/autopilots.mdindex e598afc2b4..17ac166acd 100644--- a/server/internal/service/builtin_skills/multica-platform/references/autopilots.md+++ b/server/internal/service/builtin_skills/multica-platform/references/autopilots.md@@ -29,6 +29,8 @@ Execution modes:multica autopilot list --output jsonmultica autopilot get <autopilot-id> --output jsonmultica autopilot create --title "<title>" --description "<task prompt>" --agent <agent-name-or-id> --mode create_issue|run_only --output json+multica autopilot create --title "<title>" --description "<task prompt>" --squad <squad-name-or-id> --mode create_issue|run_only --output json+multica autopilot update <autopilot-id> --squad <squad-name-or-id> --output jsonmultica autopilot update <autopilot-id> --status active|paused --output jsonmultica autopilot runs <autopilot-id> --output jsonmultica autopilot trigger-add <autopilot-id> --kind schedule --cron "0 9 * * *" --timezone Asia/Shanghai --output json@@ -37,6 +39,14 @@ multica autopilot trigger <autopilot-id> --output jsonmultica autopilot trigger-rotate-url <autopilot-id> <trigger-id> --yes --output json```+The assignee flags `--agent`, `--squad`, and `--squad-id` are mutually exclusive.+On `update`, any of them retargets the autopilot (`--agent` moves a squad+autopilot back to a single agent); leave them all out to keep the current+assignee.++A CLI that answers `unknown flag: --squad` predates squad assignees: assign the+squad in the web app, or ask the user to update the CLI.+Do not run `trigger`, `delete`, `trigger-delete`, or `trigger-rotate-url` totest — those are real side effects. Use `trigger` only when the user explicitlyasks for a manual run, and `trigger-rotate-url` only when rotating a webhook