Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(cli): STR-208 오토파일럿 구독자 플래그 추가 (#4438)
honki12345467921758690
diff --git a/CLI_AND_DAEMON.md b/CLI_AND_DAEMON.mdindex 7ec38a43b0..c40538517d 100644--- a/CLI_AND_DAEMON.md+++ b/CLI_AND_DAEMON.md@@ -653,14 +653,18 @@ multica autopilot create \--title "Nightly bug triage" \--description "Scan todo issues and prioritize." \--agent "Lambda" \- --mode create_issue+ --mode create_issue \+ --subscriber "Alice"multica autopilot update <id> --status pausedmultica autopilot update <id> --description "New prompt"+multica autopilot update <id> --subscriber "Alice" --subscriber "Bob"+multica autopilot update <id> --clear-subscribersmultica 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.+`--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/packages/core/issues/cache-helpers.test.ts b/packages/core/issues/cache-helpers.test.tsindex 17b8a123e5..bac1fecd23 100644--- a/packages/core/issues/cache-helpers.test.ts+++ b/packages/core/issues/cache-helpers.test.ts@@ -21,6 +21,7 @@ function mk(id: string, status: Issue["status"], position: number): Issue {parent_issue_id: null,project_id: null,position,+ stage: null,start_date: null,due_date: null,metadata: {},diff --git a/packages/views/issues/utils/drag-utils.test.ts b/packages/views/issues/utils/drag-utils.test.tsindex 2898ebe606..a6fbb7621b 100644--- a/packages/views/issues/utils/drag-utils.test.ts+++ b/packages/views/issues/utils/drag-utils.test.ts@@ -19,6 +19,7 @@ function mk(id: string, position: number): Issue {parent_issue_id: null,project_id: null,position,+ stage: null,start_date: null,due_date: null,metadata: {},diff --git a/server/cmd/multica/cmd_autopilot.go b/server/cmd/multica/cmd_autopilot.goindex 671ebec95f..c10c2b93f7 100644--- a/server/cmd/multica/cmd_autopilot.go+++ b/server/cmd/multica/cmd_autopilot.go@@ -124,6 +124,7 @@ func init() {autopilotCreateCmd.Flags().String("priority", "none", "Priority for created issues (none, low, medium, high, urgent)")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.")+ autopilotCreateCmd.Flags().StringArray("subscriber", nil, "Member subscriber to notify for issues this autopilot creates (name or user ID; repeatable)")autopilotCreateCmd.Flags().String("output", "json", "Output format: table or json")// update@@ -135,6 +136,8 @@ func init() {autopilotUpdateCmd.Flags().String("status", "", "New status (active, paused)")autopilotUpdateCmd.Flags().String("mode", "", "New execution mode (create_issue or run_only)")autopilotUpdateCmd.Flags().String("issue-title-template", "", "New issue title template. Only {{date}} (UTC, YYYY-MM-DD) is interpolated; any other {{...}} token is rejected.")+ autopilotUpdateCmd.Flags().StringArray("subscriber", nil, "Replace subscribers with this member (name or user ID; repeatable)")+ autopilotUpdateCmd.Flags().Bool("clear-subscribers", false, "Remove all autopilot subscribers")autopilotUpdateCmd.Flags().String("output", "json", "Output format: table or json")// delete@@ -313,6 +316,13 @@ func runAutopilotCreate(cmd *cobra.Command, _ []string) error {if v, _ := cmd.Flags().GetString("issue-title-template"); v != "" {body["issue_title_template"] = v}+ if subscriberRefs, _ := cmd.Flags().GetStringArray("subscriber"); len(subscriberRefs) > 0 {+ subscribers, err := resolveAutopilotSubscriberInputs(ctx, client, subscriberRefs)+ if err != nil {+ return err+ }+ body["subscribers"] = subscribers+ }var result map[string]anyif err := client.PostJSON(ctx, "/api/autopilots", body, &result); err != nil {@@ -389,6 +399,20 @@ func runAutopilotUpdate(cmd *cobra.Command, args []string) error {v, _ := cmd.Flags().GetString("issue-title-template")body["issue_title_template"] = v}+ clearSubscribers, _ := cmd.Flags().GetBool("clear-subscribers")+ subscriberRefs, _ := cmd.Flags().GetStringArray("subscriber")+ if clearSubscribers && len(subscriberRefs) > 0 {+ return fmt.Errorf("--subscriber and --clear-subscribers are mutually exclusive")+ }+ if clearSubscribers {+ body["subscribers"] = []map[string]string{}+ } else if cmd.Flags().Changed("subscriber") {+ subscribers, err := resolveAutopilotSubscriberInputs(ctx, client, subscriberRefs)+ if err != nil {+ return err+ }+ body["subscribers"] = subscribers+ }if len(body) == 0 {return fmt.Errorf("no fields to update; use flags like --title, --description, --agent, --status, --mode, etc.")@@ -713,6 +737,33 @@ func runAutopilotTriggerDelete(cmd *cobra.Command, args []string) error {return nil}+func resolveAutopilotSubscriberInputs(ctx context.Context, client *cli.APIClient, refs []string) ([]map[string]string, error) {+ inputs := make([]map[string]string, 0, len(refs))+ seen := map[string]struct{}{}+ memberOnly := assigneeKinds{member: true}+ for _, ref := range refs {+ if strings.TrimSpace(ref) == "" {+ return nil, fmt.Errorf("--subscriber cannot be empty")+ }+ userType, userID, err := resolveAssignee(ctx, client, ref, memberOnly)+ if err != nil {+ return nil, fmt.Errorf("resolve subscriber %q: %w", ref, err)+ }+ if userType != "member" {+ return nil, fmt.Errorf("subscriber %q resolved to %s; autopilot subscribers must be members", ref, userType)+ }+ if _, ok := seen[userID]; ok {+ continue+ }+ seen[userID] = struct{}{}+ inputs = append(inputs, map[string]string{+ "user_type": "member",+ "user_id": userID,+ })+ }+ return inputs, nil+}+// ---------------------------------------------------------------------------// Helpers// ---------------------------------------------------------------------------diff --git a/server/cmd/multica/cmd_autopilot_test.go b/server/cmd/multica/cmd_autopilot_test.goindex bd38a5ea0b..4a230a1654 100644--- a/server/cmd/multica/cmd_autopilot_test.go+++ b/server/cmd/multica/cmd_autopilot_test.go@@ -22,6 +22,7 @@ func newAutopilotCreateTestCmd() *cobra.Command {cmd.Flags().String("priority", "none", "")cmd.Flags().String("project", "", "")cmd.Flags().String("issue-title-template", "", "")+ cmd.Flags().StringArray("subscriber", nil, "")cmd.Flags().String("output", "json", "")return cmd}@@ -36,6 +37,8 @@ func newAutopilotUpdateTestCmd() *cobra.Command {cmd.Flags().String("status", "", "")cmd.Flags().String("mode", "", "")cmd.Flags().String("issue-title-template", "", "")+ cmd.Flags().StringArray("subscriber", nil, "")+ cmd.Flags().Bool("clear-subscribers", false, "")cmd.Flags().String("output", "json", "")return cmd}@@ -172,6 +175,53 @@ func TestRunAutopilotCreateSendsProjectID(t *testing.T) {}}+func TestRunAutopilotCreateSendsSubscribers(t *testing.T) {+ const (+ agentID = "11111111-1111-1111-1111-111111111111"+ userID = "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/workspaces/ws-1/members":+ json.NewEncoder(w).Encode([]map[string]any{+ {"user_id": userID, "name": "Alice"},+ })+ 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": "Daily planner",+ "subscribers": body["subscribers"],+ })+ 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", "Daily planner")+ _ = cmd.Flags().Set("agent", agentID)+ _ = cmd.Flags().Set("mode", "create_issue")+ _ = cmd.Flags().Set("subscriber", "Alice")++ if err := runAutopilotCreate(cmd, nil); err != nil {+ t.Fatalf("runAutopilotCreate: %v", err)+ }+ assertAutopilotSubscriberBody(t, body, userID)+}+func TestRunAutopilotUpdateSendsProjectIDChanges(t *testing.T) {const (autopilotID = "33333333-3333-3333-3333-333333333333"@@ -231,6 +281,129 @@ func TestRunAutopilotUpdateSendsProjectIDChanges(t *testing.T) {})}+func TestRunAutopilotUpdateSendsSubscriberReplacement(t *testing.T) {+ const (+ autopilotID = "33333333-3333-3333-3333-333333333333"+ userID = "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/workspaces/ws-1/members":+ json.NewEncoder(w).Encode([]map[string]any{+ {"user_id": userID, "name": "Alice"},+ })+ case "/api/autopilots/" + autopilotID:+ 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",+ "subscribers": body["subscribers"],+ })+ 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 := newAutopilotUpdateTestCmd()+ _ = cmd.Flags().Set("subscriber", "Alice")+ if err := runAutopilotUpdate(cmd, []string{autopilotID}); err != nil {+ t.Fatalf("runAutopilotUpdate: %v", err)+ }+ assertAutopilotSubscriberBody(t, body, userID)+}++func TestRunAutopilotUpdateCanClearSubscribers(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 {+ 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",+ "subscribers": body["subscribers"],+ })+ }))+ 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("clear-subscribers", "true")+ if err := runAutopilotUpdate(cmd, []string{autopilotID}); err != nil {+ t.Fatalf("runAutopilotUpdate: %v", err)+ }+ subscribers, ok := body["subscribers"].([]any)+ if !ok {+ t.Fatalf("subscribers = %#v, want array", body["subscribers"])+ }+ if len(subscribers) != 0 {+ t.Fatalf("subscribers length = %d, want 0", len(subscribers))+ }+}++func TestRunAutopilotUpdateRejectsSubscriberAndClear(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 := newAutopilotUpdateTestCmd()+ _ = cmd.Flags().Set("subscriber", "Alice")+ _ = cmd.Flags().Set("clear-subscribers", "true")++ err := runAutopilotUpdate(cmd, []string{"33333333-3333-3333-3333-333333333333"})+ if err == nil {+ t.Fatal("expected mutually exclusive subscriber flags error")+ }+ if !strings.Contains(err.Error(), "mutually exclusive") {+ t.Fatalf("error = %v, want mutually exclusive", err)+ }+}++func assertAutopilotSubscriberBody(t *testing.T, body map[string]any, userID string) {+ t.Helper()+ subscribers, ok := body["subscribers"].([]any)+ if !ok {+ t.Fatalf("subscribers = %#v, want array", body["subscribers"])+ }+ if len(subscribers) != 1 {+ t.Fatalf("subscribers length = %d, want 1", len(subscribers))+ }+ sub, ok := subscribers[0].(map[string]any)+ if !ok {+ t.Fatalf("subscriber = %#v, want object", subscribers[0])+ }+ if sub["user_type"] != "member" {+ t.Fatalf("user_type = %#v, want member", sub["user_type"])+ }+ if sub["user_id"] != userID {+ t.Fatalf("user_id = %#v, want %q", sub["user_id"], userID)+ }+}+func TestUUIDRegexp(t *testing.T) {tests := []struct {in string