Skip to content

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

Go

MUL-6648: feat(cli): add issue comment update command (#7507)

iiwish91ad87186437
diff --git a/apps/docs/content/docs/cli.ja.mdx b/apps/docs/content/docs/cli.ja.mdx
index 82d34c49be..4cbd491bb3 100644
--- a/apps/docs/content/docs/cli.ja.mdx
+++ b/apps/docs/content/docs/cli.ja.mdx
@@ -98,6 +98,7 @@ multica issue assign MUL-123 --to "Backend Agent"
# コメントと実行履歴
multica issue comment list MUL-123
multica issue comment add MUL-123 --content "まず回帰テストを確認してください"
+multica issue comment update <comment-id> --expected-revision 2 --content "回帰テストとリリースノートを確認してください"
multica issue runs MUL-123
```
@@ -106,6 +107,7 @@ multica issue runs MUL-123
```bash
multica issue create --title "アップグレードメモ" --description-stdin < notes.md
multica issue comment add MUL-123 --content-stdin < review.md
+multica issue comment update <comment-id> --expected-revision 2 --content-file revised-review.md
```
1 回の実行のメッセージを表示する、または実行を停止する:
diff --git a/apps/docs/content/docs/cli.ko.mdx b/apps/docs/content/docs/cli.ko.mdx
index 9640bac123..6e6664e02b 100644
--- a/apps/docs/content/docs/cli.ko.mdx
+++ b/apps/docs/content/docs/cli.ko.mdx
@@ -98,6 +98,7 @@ multica issue assign MUL-123 --to "Backend Agent"
# 댓글 및 실행 기록
multica issue comment list MUL-123
multica issue comment add MUL-123 --content "회귀 테스트를 먼저 확인해 주세요"
+multica issue comment update <comment-id> --expected-revision 2 --content "회귀 테스트와 릴리스 노트를 확인해 주세요"
multica issue runs MUL-123
```
@@ -106,6 +107,7 @@ multica issue runs MUL-123
```bash
multica issue create --title "업그레이드 안내" --description-stdin < notes.md
multica issue comment add MUL-123 --content-stdin < review.md
+multica issue comment update <comment-id> --expected-revision 2 --content-file revised-review.md
```
특정 실행의 메시지를 확인하거나 실행을 중지합니다.
diff --git a/apps/docs/content/docs/cli.mdx b/apps/docs/content/docs/cli.mdx
index 63fa9867e6..918ed1ac8b 100644
--- a/apps/docs/content/docs/cli.mdx
+++ b/apps/docs/content/docs/cli.mdx
@@ -98,6 +98,7 @@ multica issue assign MUL-123 --to "Backend Agent"
# Comments and runs
multica issue comment list MUL-123
multica issue comment add MUL-123 --content "Check the regression tests first"
+multica issue comment update <comment-id> --expected-revision 2 --content "Check the regression tests and release notes"
multica issue runs MUL-123
```
@@ -106,6 +107,7 @@ Read long descriptions or comments from stdin to avoid dealing with newlines and
```bash
multica issue create --title "Upgrade notes" --description-stdin < notes.md
multica issue comment add MUL-123 --content-stdin < review.md
+multica issue comment update <comment-id> --expected-revision 2 --content-file revised-review.md
```
View the messages of a single run, or stop one:
diff --git a/apps/docs/content/docs/cli.zh.mdx b/apps/docs/content/docs/cli.zh.mdx
index fef72f5b40..7917a43ace 100644
--- a/apps/docs/content/docs/cli.zh.mdx
+++ b/apps/docs/content/docs/cli.zh.mdx
@@ -98,6 +98,7 @@ multica issue assign MUL-123 --to "Backend Agent"
# 评论和执行记录
multica issue comment list MUL-123
multica issue comment add MUL-123 --content "请先检查回归测试"
+multica issue comment update <comment-id> --expected-revision 2 --content "请检查回归测试和发布说明"
multica issue runs MUL-123
```
@@ -106,6 +107,7 @@ multica issue runs MUL-123
```bash
multica issue create --title "升级说明" --description-stdin < notes.md
multica issue comment add MUL-123 --content-stdin < review.md
+multica issue comment update <comment-id> --expected-revision 2 --content-file revised-review.md
```
查看某次运行的消息,或停止运行:
diff --git a/server/cmd/multica/cmd_issue.go b/server/cmd/multica/cmd_issue.go
index 2173c4413b..d973c7fccd 100644
--- a/server/cmd/multica/cmd_issue.go
+++ b/server/cmd/multica/cmd_issue.go
@@ -267,6 +267,17 @@ var issueCommentAddCmd = &cobra.Command{
RunE: runIssueCommentAdd,
}
+var issueCommentUpdateCmd = &cobra.Command{
+ Use: "update <comment-id>",
+ Short: "Update a comment",
+ Long: "Update a comment you authored. Workspace owners and admins can update any comment.\n\n" +
+ "Pass the revision returned by `multica issue comment list <issue-id> --output json`; " +
+ "the update is rejected if another editor changed the comment first. Changing the content " +
+ "uses the same agent-trigger behavior as editing the comment in the app.",
+ Args: exactArgs(1),
+ RunE: runIssueCommentUpdate,
+}
+
var issueCommentDeleteCmd = &cobra.Command{
Use: "delete <comment-id>",
Short: "Delete a comment",
@@ -503,6 +514,7 @@ func init() {
issueCommentCmd.AddCommand(issueCommentListCmd)
issueCommentCmd.AddCommand(issueCommentAddCmd)
+ issueCommentCmd.AddCommand(issueCommentUpdateCmd)
issueCommentCmd.AddCommand(issueCommentDeleteCmd)
issueCommentCmd.AddCommand(issueCommentResolveCmd)
issueCommentCmd.AddCommand(issueCommentUnresolveCmd)
@@ -632,6 +644,14 @@ func init() {
issueCommentAddCmd.Flags().StringSlice("attachment", nil, "File path(s) to attach (can be specified multiple times)")
issueCommentAddCmd.Flags().String("output", "json", "Output format: table or json")
+ // issue comment update
+ issueCommentUpdateCmd.Flags().String("content", "", "New comment content (decodes \\n, \\r, \\t, \\\\; pipe via --content-stdin for multi-line bodies or to preserve literal backslashes)")
+ issueCommentUpdateCmd.Flags().Bool("content-stdin", false, "Read new comment content from stdin (preserves multi-line content verbatim)")
+ issueCommentUpdateCmd.Flags().String("content-file", "", "Read new comment content from a UTF-8 file (preserves multi-line content verbatim; use this on Windows when stdin piping mangles non-ASCII bytes). The path must be inside the current working directory unless --allow-external-file is set.")
+ issueCommentUpdateCmd.Flags().Bool("allow-external-file", false, "Allow --content-file to read a path outside the current working directory. Off by default so a stale file from another run/environment can't be picked up (MUL-4252).")
+ issueCommentUpdateCmd.Flags().Int64("expected-revision", 0, "Current positive comment revision from `issue comment list --output json` (required; prevents overwriting a concurrent edit)")
+ issueCommentUpdateCmd.Flags().String("output", "json", "Output format: table or json")
+
// issue comment resolve/unresolve
issueCommentResolveCmd.Flags().String("output", "json", "Output format: table or json")
issueCommentUnresolveCmd.Flags().String("output", "json", "Output format: table or json")
@@ -2262,6 +2282,49 @@ func runIssueCommentAdd(cmd *cobra.Command, args []string) error {
return cli.PrintJSON(os.Stdout, result)
}
+func runIssueCommentUpdate(cmd *cobra.Command, args []string) error {
+ expectedRevision, _ := cmd.Flags().GetInt64("expected-revision")
+ if !cmd.Flags().Changed("expected-revision") || expectedRevision < 1 {
+ return fmt.Errorf("--expected-revision is required and must be a positive integer; read the current revision with `multica issue comment list <issue-id> --output json`")
+ }
+
+ content, hasContent, err := resolveTextFlag(cmd, "content")
+ if err != nil {
+ return err
+ }
+ if !hasContent {
+ return fmt.Errorf("--content, --content-stdin, or --content-file is required")
+ }
+ if err := guardLocalPathLinks(content, "comment body",
+ "Comment updates cannot attach files; deliver the file in a new comment with `multica issue comment add <issue-id> --attachment <path>` and drop the link."); err != nil {
+ return err
+ }
+
+ client, err := newAPIClient(cmd)
+ if err != nil {
+ return err
+ }
+
+ ctx, cancel := cli.APIContext(context.Background())
+ defer cancel()
+
+ commentID := args[0]
+ var result map[string]any
+ if err := client.PutJSON(ctx, "/api/comments/"+url.PathEscape(commentID), map[string]any{
+ "content": content,
+ "expected_revision": expectedRevision,
+ }, &result); err != nil {
+ return fmt.Errorf("update comment: %w", err)
+ }
+
+ fmt.Fprintf(os.Stderr, "Comment %s updated.\n", commentID)
+ output, _ := cmd.Flags().GetString("output")
+ if output == "table" {
+ return nil
+ }
+ return cli.PrintJSON(os.Stdout, result)
+}
+
func runIssueCommentDelete(cmd *cobra.Command, args []string) error {
client, err := newAPIClient(cmd)
if err != nil {
diff --git a/server/cmd/multica/cmd_issue_test.go b/server/cmd/multica/cmd_issue_test.go
index 63ce9f3054..ef6b5a61d7 100644
--- a/server/cmd/multica/cmd_issue_test.go
+++ b/server/cmd/multica/cmd_issue_test.go
@@ -366,6 +366,205 @@ func newIssueCommentAddTestCmd() *cobra.Command {
return cmd
}
+func newIssueCommentUpdateTestCmd() *cobra.Command {
+ cmd := &cobra.Command{Use: "update"}
+ cmd.Flags().String("content", "", "")
+ cmd.Flags().Bool("content-stdin", false, "")
+ cmd.Flags().String("content-file", "", "")
+ cmd.Flags().Bool("allow-external-file", false, "")
+ cmd.Flags().Int64("expected-revision", 0, "")
+ cmd.Flags().String("output", "json", "")
+ return cmd
+}
+
+func TestIssueCommentUpdateCommandRegistration(t *testing.T) {
+ cmd, _, err := issueCommentCmd.Find([]string{"update"})
+ if err != nil {
+ t.Fatalf("find issue comment update: %v", err)
+ }
+ if cmd != issueCommentUpdateCmd {
+ t.Fatalf("found command = %q, want issue comment update", cmd.CommandPath())
+ }
+ if !strings.Contains(cmd.Long, "agent-trigger behavior") {
+ t.Fatalf("long help should disclose edit side effects, got %q", cmd.Long)
+ }
+ for _, name := range []string{"content", "content-stdin", "content-file", "allow-external-file", "expected-revision", "output"} {
+ if cmd.Flags().Lookup(name) == nil {
+ t.Errorf("issue comment update missing --%s", name)
+ }
+ }
+}
+
+func TestRunIssueCommentUpdateSendsExpectedRequest(t *testing.T) {
+ chdirWithDaemonTaskMarker(t)
+ const commentID = "11111111-1111-4111-8111-111111111111"
+ var requests int
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ requests++
+ if r.Method != http.MethodPut {
+ t.Fatalf("method = %s, want PUT", r.Method)
+ }
+ if r.URL.Path != "/api/comments/"+commentID {
+ t.Fatalf("path = %q, want /api/comments/%s", r.URL.Path, commentID)
+ }
+ if ws := r.Header.Get("X-Workspace-ID"); ws != "ws-1" {
+ t.Fatalf("X-Workspace-ID = %q, want ws-1", ws)
+ }
+ if contentType := r.Header.Get("Content-Type"); contentType != "application/json" {
+ t.Fatalf("Content-Type = %q, want application/json", contentType)
+ }
+ var body map[string]any
+ if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
+ t.Fatalf("decode request body: %v", err)
+ }
+ if len(body) != 2 || body["content"] != "updated\ncomment" || body["expected_revision"] != float64(7) {
+ t.Fatalf("body = %#v, want content plus expected revision", body)
+ }
+ _ = json.NewEncoder(w).Encode(map[string]any{
+ "id": commentID,
+ "content": body["content"],
+ })
+ }))
+ defer srv.Close()
+ setCLITestServerEnv(t, srv.URL)
+ t.Setenv("MULTICA_TOKEN", "mat_test-token")
+
+ cmd := newIssueCommentUpdateTestCmd()
+ _ = cmd.Flags().Set("content", `updated\ncomment`)
+ _ = cmd.Flags().Set("expected-revision", "7")
+ stderr := captureStderr(t)
+ defer stderr.restore()
+ out, err := captureStdout(t, func() error {
+ return runIssueCommentUpdate(cmd, []string{commentID})
+ })
+ if err != nil {
+ t.Fatalf("runIssueCommentUpdate: %v", err)
+ }
+ if requests != 1 {
+ t.Fatalf("requests = %d, want 1", requests)
+ }
+ if got := stderr.read(); got != "Comment "+commentID+" updated.\n" {
+ t.Fatalf("stderr = %q", got)
+ }
+ var got map[string]any
+ if err := json.Unmarshal([]byte(out), &got); err != nil {
+ t.Fatalf("decode stdout JSON %q: %v", out, err)
+ }
+ if got["id"] != commentID || got["content"] != "updated\ncomment" {
+ t.Fatalf("stdout = %#v", got)
+ }
+}
+
+func TestRunIssueCommentUpdateReadsContentFileAndHonorsTableOutput(t *testing.T) {
+ const commentID = "22222222-2222-4222-8222-222222222222"
+ t.Chdir(t.TempDir())
+ const content = "Updated title\n\nChinese: \u4e2d\u6587; literal \\n stays literal.\n"
+ if err := os.WriteFile("comment.md", []byte(content), 0o644); err != nil {
+ t.Fatalf("write comment file: %v", err)
+ }
+
+ var gotContent string
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ var body map[string]any
+ if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
+ t.Fatalf("decode request body: %v", err)
+ }
+ gotContent, _ = body["content"].(string)
+ _ = json.NewEncoder(w).Encode(map[string]any{"id": commentID, "content": gotContent})
+ }))
+ defer srv.Close()
+ setCLITestServerEnv(t, srv.URL)
+
+ cmd := newIssueCommentUpdateTestCmd()
+ _ = cmd.Flags().Set("content-file", "comment.md")
+ _ = cmd.Flags().Set("expected-revision", "4")
+ _ = cmd.Flags().Set("output", "table")
+ stderr := captureStderr(t)
+ defer stderr.restore()
+ out, err := captureStdout(t, func() error {
+ return runIssueCommentUpdate(cmd, []string{commentID})
+ })
+ if err != nil {
+ t.Fatalf("runIssueCommentUpdate: %v", err)
+ }
+ if gotContent != strings.TrimSuffix(content, "\n") {
+ t.Fatalf("request content = %q, want file body preserved", gotContent)
+ }
+ if out != "" {
+ t.Fatalf("table output wrote stdout %q, want empty", out)
+ }
+ if got := stderr.read(); got != "Comment "+commentID+" updated.\n" {
+ t.Fatalf("stderr = %q", got)
+ }
+}
+
+func TestRunIssueCommentUpdateRejectsMissingContentBeforeRequest(t *testing.T) {
+ var requests int
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
+ requests++
+ w.WriteHeader(http.StatusInternalServerError)
+ }))
+ defer srv.Close()
+ setCLITestServerEnv(t, srv.URL)
+
+ cmd := newIssueCommentUpdateTestCmd()
+ _ = cmd.Flags().Set("expected-revision", "1")
+ err := runIssueCommentUpdate(cmd, []string{"comment-1"})
+ if err == nil || err.Error() != "--content, --content-stdin, or --content-file is required" {
+ t.Fatalf("error = %v", err)
+ }
+ if requests != 0 {
+ t.Fatalf("requests = %d, want 0 for local validation failure", requests)
+ }
+}
+
+func TestRunIssueCommentUpdateRejectsMissingOrInvalidRevisionBeforeRequest(t *testing.T) {
+ var requests int
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
+ requests++
+ w.WriteHeader(http.StatusInternalServerError)
+ }))
+ defer srv.Close()
+ setCLITestServerEnv(t, srv.URL)
+
+ for _, revision := range []string{"", "0", "-1"} {
+ cmd := newIssueCommentUpdateTestCmd()
+ _ = cmd.Flags().Set("content", "updated")
+ if revision != "" {
+ _ = cmd.Flags().Set("expected-revision", revision)
+ }
+ err := runIssueCommentUpdate(cmd, []string{"comment-1"})
+ if err == nil || !strings.Contains(err.Error(), "--expected-revision is required and must be a positive integer") {
+ t.Fatalf("revision %q error = %v", revision, err)
+ }
+ }
+ if requests != 0 {
+ t.Fatalf("requests = %d, want 0 for local revision validation failures", requests)
+ }
+}
+
+func TestRunIssueCommentUpdateWrapsAPIError(t *testing.T) {
+ chdirWithDaemonTaskMarker(t)
+ const commentID = "33333333-3333-4333-8333-333333333333"
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
+ http.Error(w, "only comment author or admin can edit", http.StatusForbidden)
+ }))
+ defer srv.Close()
+ setCLITestServerEnv(t, srv.URL)
+ t.Setenv("MULTICA_TOKEN", "mat_test-token")
+
+ cmd := newIssueCommentUpdateTestCmd()
+ _ = cmd.Flags().Set("content", "not allowed")
+ _ = cmd.Flags().Set("expected-revision", "2")
+ err := runIssueCommentUpdate(cmd, []string{commentID})
+ if err == nil {
+ t.Fatal("expected API error")
+ }
+ if !strings.Contains(err.Error(), "update comment: PUT /api/comments/"+commentID+" returned 403") {
+ t.Fatalf("error lacks update context: %v", err)
+ }
+}
+
// TestRunIssueCommentAddRejectsExternalAttachmentWithZeroUploads is the MUL-4252
// P2 guard: `comment add` must validate every --attachment BEFORE uploading any,
// so a valid attachment followed by an invalid (external) one aborts the call
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 058fec7bfd..594ff6c7ee 100644
--- a/server/internal/service/builtin_skills/multica-platform/references/issues.md
+++ b/server/internal/service/builtin_skills/multica-platform/references/issues.md
@@ -4,6 +4,7 @@ Product contracts the runtime brief does not fully encode.
- [PR linking and close intent are two distinct contracts](#pr-linking-and-close-intent-are-two-distinct-contracts)
- [Reading a linked PR's real state](#reading-a-linked-prs-real-state)
+- [Editing comments without overwriting concurrent work](#editing-comments-without-overwriting-concurrent-work)
- [Custom properties: typed workflow state](#custom-properties-typed-workflow-state)
- [Status changes have server side effects](#status-changes-have-server-side-effects)
- [Claim ownership without duplicating a run](#claim-ownership-without-duplicating-a-run)
@@ -11,6 +12,23 @@ Product contracts the runtime brief does not fully encode.
- [Sub-issues: todo starts work now, backlog parks it](#sub-issues-todo-starts-work-now-backlog-parks-it)
- [Incorrect to correct](#incorrect-to-correct)
+## Editing comments without overwriting concurrent work
+
+Read the comment's current `revision`, then supply that positive value when
+updating its body. Agent-authored bodies must use `--content-file`.
+
+```bash
+multica issue comment list <issue-id> --output json
+multica issue comment update <comment-id> --content-file ./comment.md --expected-revision <revision>
+```
+
+If another editor changed the comment, the server rejects the stale revision.
+Read the latest body and reconcile the edits before retrying; do not simply
+advance the revision and overwrite the other edit. Authors can edit their own
+comments; workspace owners and admins can edit any comment. Existing attachments
+remain unchanged. Content edits have the same agent-trigger behavior as edits
+in the app, so do not use an update as a silent bookkeeping operation.
+
## PR linking and close intent are two distinct contracts
The GitHub webhook runs two separate scans over an incoming PR. They are not the