Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-7821: feat(cli): mark duplicates with issue status/update --duplicate-of (#8979)

Bohan Jiang43b0571f9925
diff --git a/CLI_AND_DAEMON.md b/CLI_AND_DAEMON.md
index 181bb1b80e..25d0c7c45b 100644
--- a/CLI_AND_DAEMON.md
+++ b/CLI_AND_DAEMON.md
@@ -621,6 +621,16 @@ Built-in statuses: `backlog`, `todo`, `in_progress`, `in_review`, `done`, `block
shown in **Settings → Issue Statuses**, and passing an unknown value returns the full
list.
+To cancel an issue because it duplicates another, mark it so the original lists it:
+
+```bash
+multica issue status <id> cancelled --duplicate-of <original>
+```
+
+`--duplicate-of` takes an issue key or full UUID and requires status `cancelled`.
+`issue update <id> --duplicate-of <original>` does the same, but cannot be combined with
+description or attachment changes. Moving the issue to any other status removes the mark.
+
### Comments
```bash
diff --git a/apps/docs/content/docs/cli.fr.mdx b/apps/docs/content/docs/cli.fr.mdx
index f8be01b3d0..e771be7390 100644
--- a/apps/docs/content/docs/cli.fr.mdx
+++ b/apps/docs/content/docs/cli.fr.mdx
@@ -237,9 +237,9 @@ Les tableaux ci-dessous couvrent toutes les commandes de premier niveau actuelle
| `issue` | `list` | Lister les tâches | `--status`, `--priority`, `--assignee`, `--project`, `--metadata` (répétable), `--property` (répétable, `"Name=Value"` ; `__none__` correspond à une valeur non définie), `--limit`, `--offset`, `--sort` (y compris `property:<name-or-id>`), `--full-id`, `--resolve-properties` (JSON uniquement ; lignes avec les noms de propriété, d'option et de membre à côté des ID enregistrés) |
| | `get <id>` | Afficher une tâche | `--resolve-properties` (JSON uniquement ; lignes avec les noms de propriété, d'option et de membre à côté des ID enregistrés) |
| | `create` | Créer une tâche | `--title` (obligatoire), `--description` / `--description-stdin` / `--description-file`, `--status`, `--priority`, `--assignee`, `--parent`, `--stage`, `--project`, `--start-date`, `--due-date`, `--attachment` (répétable) |
-| | `update <id>` | Mettre à jour les champs d'une tâche | Mêmes champs que `create`, plus `--position`, `--no-start` |
+| | `update <id>` | Mettre à jour les champs d'une tâche | Mêmes champs que `create`, plus `--position`, `--no-start`, `--duplicate-of` |
| | `assign <id>` | Assigner ou désassigner | `--to` (correspondance approximative sur le nom parmi les membres, les agents et les squads), `--to-id`, `--unassign`, `--no-start` |
-| | `status <id> <status>` | Changer le statut | `--no-start` |
+| | `status <id> <status>` | Changer le statut | `--no-start`, `--duplicate-of` |
| | `reorder <id>` | Déplacer au sein d'une colonne | |
| | `search <query>` | Rechercher des tâches | `--limit`, `--include-closed` |
| | `children <id>` | Lister les sous-tâches regroupées par étape | |
diff --git a/apps/docs/content/docs/cli.ja.mdx b/apps/docs/content/docs/cli.ja.mdx
index 4cbd491bb3..3fc0fd3838 100644
--- a/apps/docs/content/docs/cli.ja.mdx
+++ b/apps/docs/content/docs/cli.ja.mdx
@@ -229,9 +229,9 @@ CLI の設定ファイルには、あなたとして Multica にアクセスで
| `issue` | `list` | タスクを一覧 | `--status`、`--priority`、`--assignee`、`--project`、`--metadata`(繰り返し可)、`--property`(繰り返し可、`"名前=値"`;`__none__` は未設定に一致)、`--limit`、`--offset`、`--sort`(`property:<名前または id>` に対応)、`--full-id`、`--resolve-properties`(JSON のみ;保存された id に加えてプロパティ名・選択肢名・メンバー名を返します) |
| | `get <id>` | 単一のタスクを表示 | `--resolve-properties`(JSON のみ;保存された id に加えてプロパティ名・選択肢名・メンバー名を返します) |
| | `create` | タスクを作成 | `--title`(必須)、`--description` / `--description-stdin` / `--description-file`、`--status`、`--priority`、`--assignee`、`--parent`、`--stage`、`--project`、`--start-date`、`--due-date`、`--attachment`(繰り返し可) |
-| | `update <id>` | タスクのフィールドを更新 | `create` と同系のフィールドに加え `--position`、`--no-start` |
+| | `update <id>` | タスクのフィールドを更新 | `create` と同系のフィールドに加え `--position`、`--no-start`、`--duplicate-of` |
| | `assign <id>` | 割り当てまたは割り当て解除 | `--to`(メンバー、エージェント、スクワッドを名前であいまいマッチ)、`--to-id`、`--unassign`、`--no-start` |
-| | `status <id> <status>` | ステータスを変更 | `--no-start` |
+| | `status <id> <status>` | ステータスを変更 | `--no-start`、`--duplicate-of` |
| | `reorder <id>` | カラム内で移動 | |
| | `search <query>` | タスクを検索 | `--limit`、`--include-closed` |
| | `children <id>` | サブタスクをステージごとに一覧 | |
diff --git a/apps/docs/content/docs/cli.ko.mdx b/apps/docs/content/docs/cli.ko.mdx
index 6e6664e02b..dee41d0fe0 100644
--- a/apps/docs/content/docs/cli.ko.mdx
+++ b/apps/docs/content/docs/cli.ko.mdx
@@ -229,9 +229,9 @@ CLI 설정 파일에는 사용자를 대신해 Multica에 접근할 수 있는 t
| `issue` | `list` | 태스크 목록 | `--status`, `--priority`, `--assignee`, `--project`, `--metadata`(반복 가능), `--property`(반복 가능, `"이름=값"`; `__none__`은 미설정과 일치), `--limit`, `--offset`, `--sort`(`property:<이름 또는 id>` 지원), `--full-id`, `--resolve-properties`(JSON 전용; 저장된 id와 함께 속성, 옵션, 멤버 이름을 반환) |
| | `get <id>` | 태스크 하나 확인 | `--resolve-properties`(JSON 전용; 저장된 id와 함께 속성, 옵션, 멤버 이름을 반환) |
| | `create` | 태스크 생성 | `--title`(필수), `--description` / `--description-stdin` / `--description-file`, `--status`, `--priority`, `--assignee`, `--parent`, `--stage`, `--project`, `--start-date`, `--due-date`, `--attachment`(반복 가능) |
-| | `update <id>` | 태스크 필드 업데이트 | `create`와 같은 종류의 필드에 `--position`, `--no-start` 추가 |
+| | `update <id>` | 태스크 필드 업데이트 | `create`와 같은 종류의 필드에 `--position`, `--no-start`, `--duplicate-of` 추가 |
| | `assign <id>` | 할당 또는 할당 해제 | `--to`(이름으로 멤버, 에이전트, 스쿼드 fuzzy match), `--to-id`, `--unassign`, `--no-start` |
-| | `status <id> <status>` | 상태 변경 | `--no-start` |
+| | `status <id> <status>` | 상태 변경 | `--no-start`, `--duplicate-of` |
| | `reorder <id>` | 열 안에서 이동 | |
| | `search <query>` | 태스크 검색 | `--limit`, `--include-closed` |
| | `children <id>` | 단계별로 묶은 하위 태스크 목록 | |
diff --git a/apps/docs/content/docs/cli.mdx b/apps/docs/content/docs/cli.mdx
index b9953b23f7..fae681ab27 100644
--- a/apps/docs/content/docs/cli.mdx
+++ b/apps/docs/content/docs/cli.mdx
@@ -252,9 +252,9 @@ The tables below cover every current top-level command, grouped the way the CLI
| `issue` | `list` | List issues | `--status`, `--priority`, `--assignee`, `--project`, `--metadata` (repeatable), `--property` (repeatable, `"Name=Value"`; `__none__` matches unset), `--limit`, `--offset`, `--sort` (incl. `property:<name-or-id>`), `--full-id`, `--resolve-properties` (JSON only; rows with property, option and member names beside the stored ids) |
| | `get <id>` | Show a single issue | `--resolve-properties` (JSON only; rows with property, option and member names beside the stored ids) |
| | `create` | Create an issue | `--title` (required), `--description` / `--description-stdin` / `--description-file`, `--status`, `--priority`, `--assignee`, `--parent`, `--stage`, `--project`, `--start-date`, `--due-date`, `--attachment` (repeatable) |
-| | `update <id>` | Update issue fields | Same fields as `create`, plus `--position`, `--no-start` |
+| | `update <id>` | Update issue fields | Same fields as `create`, plus `--position`, `--no-start`, `--duplicate-of` |
| | `assign <id>` | Assign or unassign | `--to` (fuzzy name match against members, agents, and squads), `--to-id`, `--unassign`, `--no-start` |
-| | `status <id> <status>` | Change status | `--no-start` |
+| | `status <id> <status>` | Change status | `--no-start`, `--duplicate-of` |
| | `reorder <id>` | Move within a column | |
| | `search <query>` | Search issues | `--limit`, `--include-closed` |
| | `children <id>` | List sub-issues grouped by stage | |
diff --git a/apps/docs/content/docs/cli.zh.mdx b/apps/docs/content/docs/cli.zh.mdx
index 7917a43ace..65eb81c567 100644
--- a/apps/docs/content/docs/cli.zh.mdx
+++ b/apps/docs/content/docs/cli.zh.mdx
@@ -229,9 +229,9 @@ CLI 配置文件包含可代表你访问 Multica 的令牌。不要提交到仓
| `issue` | `list` | 列出任务 | `--status`、`--priority`、`--assignee`、`--project`、`--metadata`(可重复)、`--property`(可重复,`"名称=值"`;`__none__` 匹配未设置)、`--limit`、`--offset`、`--sort`(支持 `property:<名称或 id>`)、`--full-id`、`--resolve-properties`(仅 JSON;在保存的 id 旁附上属性、选项和成员名称) |
| | `get <id>` | 查看单个任务 | `--resolve-properties`(仅 JSON;在保存的 id 旁附上属性、选项和成员名称) |
| | `create` | 创建任务 | `--title`(必填)、`--description` / `--description-stdin` / `--description-file`、`--status`、`--priority`、`--assignee`、`--parent`、`--stage`、`--project`、`--start-date`、`--due-date`、`--attachment`(可重复) |
-| | `update <id>` | 更新任务字段 | 与 `create` 同类字段,另有 `--position`、`--no-start` |
+| | `update <id>` | 更新任务字段 | 与 `create` 同类字段,另有 `--position`、`--no-start`、`--duplicate-of` |
| | `assign <id>` | 指派或取消指派 | `--to`(名称模糊匹配成员、智能体或小队)、`--to-id`、`--unassign`、`--no-start` |
-| | `status <id> <status>` | 修改状态 | `--no-start` |
+| | `status <id> <status>` | 修改状态 | `--no-start`、`--duplicate-of` |
| | `reorder <id>` | 在列内移动 | |
| | `search <query>` | 搜索任务 | `--limit`、`--include-closed` |
| | `children <id>` | 按阶段分组列出子任务 | |
diff --git a/server/cmd/multica/cmd_issue.go b/server/cmd/multica/cmd_issue.go
index f2b96ad723..0b9dfee3b1 100644
--- a/server/cmd/multica/cmd_issue.go
+++ b/server/cmd/multica/cmd_issue.go
@@ -278,7 +278,11 @@ var issueStatusCmd = &cobra.Command{
Long: "Change an issue's status. The argument is a status KEY, not its display name.\n" +
"Built-in keys: backlog, todo, in_progress, in_review, done, blocked, cancelled.\n" +
"A workspace may define custom statuses on top of these; their keys are shown in\n" +
- "Workspace Settings > Issue Statuses, and an unknown value errors with the full list.",
+ "Workspace Settings > Issue Statuses, and an unknown value errors with the full list.\n\n" +
+ "To cancel an issue because it duplicates another, mark it instead of only cancelling:\n" +
+ " multica issue status <id> cancelled --duplicate-of <original>\n" +
+ "The original then lists it as a duplicate. Moving the issue to any status other\n" +
+ "than cancelled later removes the mark.",
Args: exactArgs(2),
RunE: runIssueStatus,
}
@@ -648,10 +652,12 @@ func init() {
issueUpdateCmd.Flags().Int("stage", 0, "Stage ordinal (>=1) for this sub-issue; see `issue create --stage`")
issueUpdateCmd.Flags().Float64("position", 0, "Ordering position within the board column (lower sorts first); prefer `issue reorder` for relative moves")
issueUpdateCmd.Flags().Bool("no-start", false, "Apply the update without starting an agent run")
+ issueUpdateCmd.Flags().String("duplicate-of", "", "Mark the issue as a duplicate of this original issue (key like MUL-123, or full UUID) and cancel it; --status, if given, must be cancelled, and description/attachment changes must go in a separate update")
issueUpdateCmd.Flags().String("output", "json", "Output format: table or json")
// issue status
issueStatusCmd.Flags().Bool("no-start", false, "Change status without starting an agent run")
+ issueStatusCmd.Flags().String("duplicate-of", "", "Mark the issue as a duplicate of this original issue (key like MUL-123, or full UUID); the status must be cancelled")
issueStatusCmd.Flags().String("output", "table", "Output format: table or json")
// issue reorder
@@ -1658,6 +1664,17 @@ func runIssueUpdate(cmd *cobra.Command, args []string) error {
return err
}
}
+ duplicateOf, err := duplicateOfFlag(cmd, statusFlag, statusChanged)
+ if err != nil {
+ return err
+ }
+ // The server rejects a mark alongside description or attachment writes,
+ // and attachments upload before the update, so refuse the combination
+ // before anything is uploaded and left unbound.
+ if duplicateOf != "" && (len(attachmentPaths) > 0 || cmd.Flags().Changed("description") ||
+ cmd.Flags().Changed("description-stdin") || cmd.Flags().Changed("description-file")) {
+ return fmt.Errorf("--duplicate-of cannot be combined with --description, --description-stdin, --description-file or --attachment; mark the duplicate first, then change the description in a separate update")
+ }
client, err := newAPIClient(cmd)
if err != nil {
@@ -1740,6 +1757,13 @@ func runIssueUpdate(cmd *cobra.Command, args []string) error {
body["parent_issue_id"] = parent.ID
}
}
+ if duplicateOf != "" {
+ original, err := resolveIssueRef(ctx, client, duplicateOf)
+ if err != nil {
+ return fmt.Errorf("resolve --duplicate-of issue: %w", err)
+ }
+ body["duplicate_of_issue_id"] = original.ID
+ }
if cmd.Flags().Changed("stage") {
stage, _ := cmd.Flags().GetInt("stage")
if stage < 1 {
@@ -1802,6 +1826,11 @@ func runIssueUpdate(cmd *cobra.Command, args []string) error {
}
return fmt.Errorf("update issue: %w", err)
}
+ if duplicateOf != "" {
+ if _, err := recordedDuplicateOf(result, duplicateOf); err != nil {
+ return err
+ }
+ }
output, _ := cmd.Flags().GetString("output")
if output == "table" {
@@ -1895,6 +1924,10 @@ func runIssueStatus(cmd *cobra.Command, args []string) error {
if err := validateIssueStatus(status); err != nil {
return err
}
+ duplicateOf, err := duplicateOfFlag(cmd, status, true)
+ if err != nil {
+ return err
+ }
client, err := newAPIClient(cmd)
if err != nil {
@@ -1910,6 +1943,13 @@ func runIssueStatus(cmd *cobra.Command, args []string) error {
}
body := map[string]any{"status": status}
+ if duplicateOf != "" {
+ original, err := resolveIssueRef(ctx, client, duplicateOf)
+ if err != nil {
+ return fmt.Errorf("resolve --duplicate-of issue: %w", err)
+ }
+ body["duplicate_of_issue_id"] = original.ID
+ }
if noStart {
body["suppress_run"] = true
}
@@ -1918,7 +1958,15 @@ func runIssueStatus(cmd *cobra.Command, args []string) error {
return fmt.Errorf("update status: %w", err)
}
- fmt.Fprintf(os.Stderr, "Issue %s status changed to %s.\n", issueDisplayKey(result), status)
+ if duplicateOf != "" {
+ original, err := recordedDuplicateOf(result, duplicateOf)
+ if err != nil {
+ return err
+ }
+ fmt.Fprintf(os.Stderr, "Issue %s status changed to %s as a duplicate of %s.\n", issueDisplayKey(result), status, original)
+ } else {
+ fmt.Fprintf(os.Stderr, "Issue %s status changed to %s.\n", issueDisplayKey(result), status)
+ }
output, _ := cmd.Flags().GetString("output")
if output == "json" {
@@ -1927,6 +1975,43 @@ func runIssueStatus(cmd *cobra.Command, args []string) error {
return nil
}
+// duplicateOfFlag returns the --duplicate-of reference, or "" when the flag is
+// unset. A duplicate is a cancelled issue that remembers its original
+// (MUL-7349): the server cancels the issue along with the mark and rejects
+// any other status, so that combination fails here before any request.
+func duplicateOfFlag(cmd *cobra.Command, status string, statusSet bool) (string, error) {
+ if !cmd.Flags().Changed("duplicate-of") {
+ return "", nil
+ }
+ ref, _ := cmd.Flags().GetString("duplicate-of")
+ ref = strings.TrimSpace(ref)
+ if ref == "" {
+ return "", fmt.Errorf("--duplicate-of requires the original issue's key (e.g. MUL-123) or full UUID")
+ }
+ if statusSet && status != "cancelled" {
+ return "", fmt.Errorf("--duplicate-of cancels the issue, so the status must be cancelled, not %q", status)
+ }
+ return ref, nil
+}
+
+// recordedDuplicateOf returns the original an update response names, failing
+// when the server applied the update without the mark. Servers before v0.5.2
+// ignore duplicate_of_issue_id and have no duplicate_of field, so the key's
+// absence is the signal; a null value only means the original could not be
+// read back, so the caller's own reference names it instead.
+func recordedDuplicateOf(result map[string]any, ref string) (string, error) {
+ raw, ok := result["duplicate_of"]
+ if !ok {
+ return "", fmt.Errorf("issue %s was updated, but the server did not record the duplicate mark; marking duplicates needs server v0.5.2 or later", issueDisplayKey(result))
+ }
+ if original, ok := raw.(map[string]any); ok {
+ if key := strVal(original, "identifier"); key != "" {
+ return key, nil
+ }
+ }
+ return ref, nil
+}
+
// ---------------------------------------------------------------------------
// Reorder command
// ---------------------------------------------------------------------------
diff --git a/server/cmd/multica/cmd_issue_test.go b/server/cmd/multica/cmd_issue_test.go
index dbd8b69d31..4b2be02a4e 100644
--- a/server/cmd/multica/cmd_issue_test.go
+++ b/server/cmd/multica/cmd_issue_test.go
@@ -3749,6 +3749,7 @@ func newIssueUpdateTestCmd() *cobra.Command {
cmd.Flags().Int("stage", 0, "")
cmd.Flags().Float64("position", 0, "")
cmd.Flags().Bool("no-start", false, "")
+ cmd.Flags().String("duplicate-of", "", "")
cmd.Flags().String("output", "json", "")
return cmd
}
@@ -3863,6 +3864,7 @@ func newIssueAssignTestCmd() *cobra.Command {
func newIssueStatusTestCmd() *cobra.Command {
cmd := &cobra.Command{Use: "status"}
cmd.Flags().Bool("no-start", false, "")
+ cmd.Flags().String("duplicate-of", "", "")
cmd.Flags().String("output", "table", "")
return cmd
}
@@ -3992,6 +3994,137 @@ func TestRunIssueStatusNoStartSendsSuppressRun(t *testing.T) {
}
}
+// newDuplicateMarkTestServer serves MUL-1 (the original) and MUL-2 (the
+// duplicate) and records the body of the PUT to MUL-2. With recorded=false it
+// answers like a server older than the duplicate mark: no duplicate_of field.
+func newDuplicateMarkTestServer(t *testing.T, recorded bool, body *map[string]any) *httptest.Server {
+ t.Helper()
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ switch {
+ case r.Method == http.MethodGet && r.URL.Path == "/api/issues/MUL-1":
+ json.NewEncoder(w).Encode(map[string]any{"id": "issue-1", "identifier": "MUL-1", "status": "todo"})
+ case r.Method == http.MethodGet && r.URL.Path == "/api/issues/MUL-2":
+ json.NewEncoder(w).Encode(map[string]any{"id": "issue-2", "identifier": "MUL-2", "status": "todo"})
+ case r.Method == http.MethodPut && r.URL.Path == "/api/issues/issue-2":
+ if err := json.NewDecoder(r.Body).Decode(body); err != nil {
+ t.Errorf("decode body: %v", err)
+ }
+ resp := map[string]any{"id": "issue-2", "identifier": "MUL-2", "status": "cancelled"}
+ if recorded {
+ resp["duplicate_of"] = map[string]any{"id": "issue-1", "identifier": "MUL-1", "status": "todo"}
+ }
+ json.NewEncoder(w).Encode(resp)
+ default:
+ t.Errorf("unexpected request %s %s", r.Method, r.URL.Path)
+ http.NotFound(w, r)
+ }
+ }))
+ t.Cleanup(srv.Close)
+ setCLITestServerEnv(t, srv.URL)
+ t.Setenv("MULTICA_TASK_CONFIG_ROOT", t.TempDir())
+ t.Setenv("MULTICA_TOKEN", "mat_test-token")
+ return srv
+}
+
+func TestRunIssueStatusDuplicateOfSendsMark(t *testing.T) {
+ var body map[string]any
+ newDuplicateMarkTestServer(t, true, &body)
+
+ cmd := newIssueStatusTestCmd()
+ _ = cmd.Flags().Set("duplicate-of", "MUL-1")
+ if err := runIssueStatus(cmd, []string{"MUL-2", "cancelled"}); err != nil {
+ t.Fatalf("runIssueStatus: %v", err)
+ }
+ want := map[string]any{"status": "cancelled", "duplicate_of_issue_id": "issue-1"}
+ if !reflect.DeepEqual(body, want) {
+ t.Fatalf("body = %#v, want %#v", body, want)
+ }
+}
+
+func TestRunIssueUpdateDuplicateOfSendsMark(t *testing.T) {
+ var body map[string]any
+ newDuplicateMarkTestServer(t, true, &body)
+
+ cmd := newIssueUpdateTestCmd()
+ _ = cmd.Flags().Set("duplicate-of", "MUL-1")
+ if err := runIssueUpdate(cmd, []string{"MUL-2"}); err != nil {
+ t.Fatalf("runIssueUpdate: %v", err)
+ }
+ // The server cancels the issue with the mark; no status is needed.
+ want := map[string]any{"duplicate_of_issue_id": "issue-1"}
+ if !reflect.DeepEqual(body, want) {
+ t.Fatalf("body = %#v, want %#v", body, want)
+ }
+}
+
+func TestRunIssueDuplicateOfFailsWhenServerDropsMark(t *testing.T) {
+ var body map[string]any
+ newDuplicateMarkTestServer(t, false, &body)
+
+ statusCmd := newIssueStatusTestCmd()
+ _ = statusCmd.Flags().Set("duplicate-of", "MUL-1")
+ err := runIssueStatus(statusCmd, []string{"MUL-2", "cancelled"})
+ if err == nil || !strings.Contains(err.Error(), "did not record the duplicate mark") {
+ t.Fatalf("runIssueStatus error = %v, want a missing-mark error", err)
+ }
+
+ updateCmd := newIssueUpdateTestCmd()
+ _ = updateCmd.Flags().Set("duplicate-of", "MUL-1")
+ err = runIssueUpdate(updateCmd, []string{"MUL-2"})
+ if err == nil || !strings.Contains(err.Error(), "did not record the duplicate mark") {
+ t.Fatalf("runIssueUpdate error = %v, want a missing-mark error", err)
+ }
+}
+
+func TestRunIssueDuplicateOfRejectsInvalidCombinationsBeforeRequest(t *testing.T) {
+ t.Chdir(t.TempDir())
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ t.Errorf("unexpected request %s %s", r.Method, r.URL.Path)
+ http.NotFound(w, r)
+ }))
+ defer srv.Close()
+ setCLITestServerEnv(t, srv.URL)
+ attachment := writeIssueCreateAttachment(t, "shot.png")
+
+ t.Run("status other than cancelled", func(t *testing.T) {
+ cmd := newIssueStatusTestCmd()
+ _ = cmd.Flags().Set("duplicate-of", "MUL-1")
+ err := runIssueStatus(cmd, []string{"MUL-2", "done"})
+ if err == nil || !strings.Contains(err.Error(), "must be cancelled") {
+ t.Fatalf("error = %v, want a must-be-cancelled error", err)
+ }
+ })
+ t.Run("empty reference", func(t *testing.T) {
+ cmd := newIssueStatusTestCmd()
+ _ = cmd.Flags().Set("duplicate-of", " ")
+ err := runIssueStatus(cmd, []string{"MUL-2", "cancelled"})
+ if err == nil || !strings.Contains(err.Error(), "requires the original issue") {
+ t.Fatalf("error = %v, want a missing-reference error", err)
+ }
+ })
+
+ for _, tc := range []struct {
+ name string
+ flag string
+ value string
+ want string
+ }{
+ {"update status other than cancelled", "status", "todo", "must be cancelled"},
+ {"update description", "description", "new body", "cannot be combined"},
+ {"update attachment", "attachment", attachment, "cannot be combined"},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ cmd := newIssueUpdateTestCmd()
+ _ = cmd.Flags().Set("duplicate-of", "MUL-1")
+ _ = cmd.Flags().Set(tc.flag, tc.value)
+ err := runIssueUpdate(cmd, []string{"MUL-2"})
+ if err == nil || !strings.Contains(err.Error(), tc.want) {
+ t.Fatalf("error = %v, want %q", err, tc.want)
+ }
+ })
+ }
+}
+
func TestRunIssueAssignNoStartSendsSuppressRun(t *testing.T) {
const agentID = "5fb87ac7-23b5-4a7a-81fa-ed295a54545d"
var body map[string]any
diff --git a/server/internal/daemon/execenv/runtime_config_issue_status_test.go b/server/internal/daemon/execenv/runtime_config_issue_status_test.go
index 84cc46012e..999b63e2c2 100644
--- a/server/internal/daemon/execenv/runtime_config_issue_status_test.go
+++ b/server/internal/daemon/execenv/runtime_config_issue_status_test.go
@@ -33,6 +33,21 @@ func TestBriefStatusCatalogAbsentUsesBuiltInLine(t *testing.T) {
}
}
+// TestBriefTeachesDuplicateMark pins the duplicate-mark bullet with and
+// without a status catalog, so agents cancelling a duplicate record the mark.
+func TestBriefTeachesDuplicateMark(t *testing.T) {
+ t.Parallel()
+ base := TaskContextForEnv{IssueID: "issue-1", AgentID: "a-1", AgentName: "Eve"}
+ withCatalog := base
+ withCatalog.IssueStatuses = []IssueStatusForEnv{{Key: "later", Name: "Later", Category: "backlog"}}
+ for name, ctx := range map[string]TaskContextForEnv{"no catalog": base, "catalog": withCatalog} {
+ out := buildMetaSkillContent("claude", ctx)
+ if got := strings.Count(out, duplicateOfCommandLine); got != 1 {
+ t.Errorf("%s: duplicate-mark bullet appears %d times, want 1\n---\n%s", name, got, out)
+ }
+ }
+}
+
func TestBriefStatusCatalogRendered(t *testing.T) {
t.Parallel()
ctx := TaskContextForEnv{
diff --git a/server/internal/daemon/execenv/runtime_config_sections.go b/server/internal/daemon/execenv/runtime_config_sections.go
index 201286b6e3..d08da9ac88 100644
--- a/server/internal/daemon/execenv/runtime_config_sections.go
+++ b/server/internal/daemon/execenv/runtime_config_sections.go
@@ -264,6 +264,7 @@ func writeAvailableCommands(b *strings.Builder, ctx TaskContextForEnv) {
b.WriteString("- `multica issue update <id> [--title X] [--description-file <path>] [--priority X] [--status X] [--assignee X] [--parent <issue-id>] [--stage N] [--project <project-id>] [--due-date <YYYY-MM-DD>]` — update fields; pass `--parent \"\"` to clear parent.\n")
b.WriteString("- `multica issue assign <id> (--to X | --to-id <uuid> | --unassign)` — change ownership; assigning to an agent can start a run.\n")
writeIssueStatusCommand(b, ctx)
+ b.WriteString(duplicateOfCommandLine)
b.WriteString("- `multica issue wakeup <create|list|get|update|disable|trigger|delete|runs|events>` — persist an event, condition or time wakeup on this issue, then finish the current run. When the platform can check the fact itself, use a condition (`--until-status`, `--until-pr checks`, `--until-children-done`, `--until-issue`) so no run starts before it holds. Use `--event comment.created --filter-actor-type member --filter-actor-id USER_ID` to wait for a specific member to comment. See `multica issue wakeup --help` and the multica-platform issues reference.\n")
b.WriteString("- `multica issue children <id> [--output json]` — list a parent's sub-issues grouped by stage.\n")
b.WriteString("- `multica issue comment add <issue-id> [--content \"...\" | --content-file <path> | --content-stdin] [--parent <comment-id>] [--attachment <path>]` — post a comment. Agent-authored bodies MUST use `--content-file`; see `## Comment Formatting` for why. `multica issue comment add --help` for full flags.\n")
@@ -282,6 +283,11 @@ func writeAvailableCommands(b *strings.Builder, ctx TaskContextForEnv) {
}
}
+// duplicateOfCommandLine teaches the duplicate mark (MUL-7821). Without it
+// agents cancel duplicates with a plain status change plus a comment, which
+// leaves the original's duplicates list empty.
+const duplicateOfCommandLine = "- `multica issue status <id> cancelled --duplicate-of <original>` — cancel an issue that duplicates another and record the mark, so the original lists it; a plain cancel plus a comment leaves no link.\n"
+
// briefStatusCategoryOrder groups the briefing catalog by internal lifecycle,
// matching ListIssueStatusEntries. User-facing columns still use status keys.
var briefStatusCategoryOrder = issuestatus.Categories()
diff --git a/server/internal/service/builtin_skills/multica-platform/references/issues.md b/server/internal/service/builtin_skills/multica-platform/references/issues.md
index 04e97fcafb..29a40ceab6 100644
--- a/server/internal/service/builtin_skills/multica-platform/references/issues.md
+++ b/server/internal/service/builtin_skills/multica-platform/references/issues.md
@@ -240,7 +240,12 @@ archived statuses remain readable via an explicit status filter.
`done` it enqueues no new agent work, but it does **not** stop tasks already in
flight — a run in progress keeps going. To stop a running task, cancel the
task itself.
- A cancelled issue may also be marked as a **duplicate** of another issue
+ A cancelled issue may also be marked as a **duplicate** of another issue.
+ When you cancel an issue because the work already exists elsewhere, mark it
+ with `multica issue status <id> cancelled --duplicate-of <original>` rather
+ than cancelling and explaining in a comment: only the mark links the two.
+ The original must not itself be a duplicate, and an issue that others are
+ marked as duplicates of cannot be marked; the command reports both refusals.
(`GET /api/issues/<id>/duplicates` shows both sides; issue responses carry
the original as `duplicate_of` with its id, identifier, title and status
while the mark counts). Moving it to any