主题
cnb-rs issue comment <NUMBER> [flags]
在 Issue 上添加一条评论;用 --view <COMMENT_ID> 查看单条评论;或用 --edit-last / --id <CID> 编辑已有评论。参考 gh issue comment 的单命令 + flag 设计,比 gh 多一个能力:--id <CID> 可编辑任意 CID 的评论(gh 只能 --edit-last)。
--view <COMMENT_ID>
--edit-last
--id <CID>
gh issue comment
历史:v0.13 ~ P0-5 之前,本命令是 issue comment {add | list | view | edit} 4 子命令组;P0-5 折叠为单命令。列举评论:使用 issue view --comments;查看单条评论:使用 issue comment <NUMBER> --view <COMMENT_ID>。CNB API 没有 delete_issue_comment,所以本命令不提供 --delete-last(与 gh issue comment 略有不同)。
历史:v0.13 ~ P0-5 之前,本命令是 issue comment {add | list | view | edit} 4 子命令组;P0-5 折叠为单命令。
issue comment {add | list | view | edit}
列举评论:使用 issue view --comments;查看单条评论:使用 issue comment <NUMBER> --view <COMMENT_ID>。
issue view --comments
issue comment <NUMBER> --view <COMMENT_ID>
CNB API 没有 delete_issue_comment,所以本命令不提供 --delete-last(与 gh issue comment 略有不同)。
delete_issue_comment
--delete-last
<NUMBER>
--body
--body-file
--id
--work-mode
--attach
-b, --body <BODY>
-F, --body-file <FILE>
-
created_at
--id <COMMENT_ID>
--view
--attach <FILE>
新增或编辑评论时至少需要传 -b 或 -F 之一;--view 模式不需要正文。
-b
-F
继承的全局选项:
--repo <REPO>
group/repo
--domain <DOMAIN>
cnb.cool
--json
IssueComment
✓ 已在 Issue #N 上发表评论 (id=...)
✓ 已编辑 Issue #N 上的评论 (id=...)
# 添加一条评论 $ cnb-rs issue comment 42 -b "已确认问题,正在修复" ✓ 已在 Issue #42 上发表评论 (id=2055950878457462784) https://cnb.cool/org/repo/-/issues/42 # @ NPC 并开启工作模式 $ cnb-rs issue comment 42 --work-mode -b "@npc/CodeBuddy(deepseek-v4.1-flash) 请修复这个问题并发起 PR" # 从文件读 body(多行 markdown) $ cnb-rs issue comment 42 -F notes.md # 从 stdin 读(适合 pipe) $ echo "lgtm" | cnb-rs issue comment 42 -F - # 附件上传 $ cnb-rs issue comment 42 -b "补一个 trace" --attach trace.log # 查看单条评论(加 --json 可原样输出 IssueComment JSON) $ cnb-rs issue comment 42 --view 2055950878457462784 作者: alice 创建时间: 2026-09-16T10:00:00Z 更新时间: 2026-09-16T10:05:00Z 已确认问题,正在修复 # 编辑当前用户最近一条评论(typo 补救常用) $ cnb-rs issue comment 42 --edit-last -b "(edited) 已确认问题" ✓ 已编辑 Issue #42 上的评论 (id=2055950878457462784) # 编辑指定 CID 的评论(比 gh 多一个能力) $ cnb-rs issue comment 42 --id 2055886607480520704 -b "新内容" # 不传 body 报错 $ cnb-rs issue comment 42 错误: 请通过 -b/--body 或 -F/--body-file 提供评论正文 # --edit-last 与 --id 互斥(clap 拒绝) $ cnb-rs issue comment 42 --edit-last --id 12345 error: the argument '--edit-last' cannot be used with '--id <COMMENT_ID>' # --edit-last / --id 模式不能带 --attach $ cnb-rs issue comment 42 --edit-last -b "x" --attach trace.log 错误: --edit-last 模式不支持 --attach(编辑已存在评论加附件不在本命令范围内)
${API}/repos/{repo}/-/issues/{n}/comments
${API}/repos/{repo}/-/issues/{n}/comments/{cid}
${API}/user
--edit-last 总共 3 个 API 调用,前两个并发(tokio::join!)。
tokio::join!
与 issue create --attach 不同:评论附件没有 asset-group 批量 API,每个文件单独调 POST /{repo}/-/issues/{n}/comment-{file|image}-asset-upload-url 申请 upload URL,之后步骤一致(PUT 到 OSS → 拿 asset_link → 追加到 body 末尾)。
issue create --attach
POST /{repo}/-/issues/{n}/comment-{file|image}-asset-upload-url
asset_link
任何一步附件上传失败会直接中断,评论 不会被创建。
issue comment {add/list/view/edit}
issue comment add 42 -c "x"
issue comment 42 -b "x"
-c
issue comment add 42 -c "x" --attach FILE
issue comment 42 -b "x" --attach FILE
issue comment list 42
issue view 42 --comments
issue comment view 42 <CID>
issue comment 42 --view <CID>
issue comment edit 42 <CID> -c "x"
issue comment 42 --id <CID> -b "x"
$ cnb-rs issue comment list 42 error: unexpected argument '42' found # 因为 list 被认为是 NUMBER,42 被认为是位置参数多余
clap 直接拒绝,提示用户改用新单命令。
issue close / issue reopen 也接受 -c "评论" 选项,在状态变更前先发评论;本命令是独立的「只发评论」单命令。
issue close
issue reopen
-c "评论"
--comments
cnb-rs issue comment
在 Issue 上添加一条评论;用
--view <COMMENT_ID>查看单条评论;或用--edit-last/--id <CID>编辑已有评论。参考gh issue comment的单命令 + flag 设计,比 gh 多一个能力:--id <CID>可编辑任意 CID 的评论(gh 只能--edit-last)。选项
<NUMBER>:Issue 编号(必填)--view <COMMENT_ID>:查看指定 ID 的评论;与--body/--body-file/--edit-last/--id/--work-mode/--attach互斥-b, --body <BODY>:评论正文;与--body-file互斥-F, --body-file <FILE>:从文件读评论正文;-表示从 stdin 读;与--body互斥--edit-last:编辑当前用户在该 Issue 上最近一条评论(按created_at取最新),找不到则报错--id <COMMENT_ID>:编辑指定 ID 的评论;与--edit-last互斥;比 gh 多一个能力--work-mode:开启 NPC 工作模式(评论中需 @ NPC;授予其写代码 / 推分支 / 发 PR 权限,需开发者及以上权限);仅新增评论时可用,与--view/--edit-last/--id互斥--attach <FILE>:附件文件路径(仅新增评论模式下生效;--edit-last/--id时传--attach会报错)新增或编辑评论时至少需要传
-b或-F之一;--view模式不需要正文。继承的全局选项:
--repo <REPO>:指定仓库路径(格式:group/repo)--domain <DOMAIN>:指定目标域名(默认:cnb.cool)--json:--view模式原样输出IssueCommentJSON输出约定
✓ 已在 Issue #N 上发表评论 (id=...)✓ 已编辑 Issue #N 上的评论 (id=...)--json时原样输出IssueCommentJSON示例
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
API 调用
${API}/repos/{repo}/-/issues/{n}/comments--view${API}/repos/{repo}/-/issues/{n}/comments/{cid}--edit-last找最近${API}/user+${API}/repos/{repo}/-/issues/{n}/comments--edit-lastpatch${API}/repos/{repo}/-/issues/{n}/comments/{cid}--idpatch${API}/repos/{repo}/-/issues/{n}/comments/{cid}--attach--edit-last总共 3 个 API 调用,前两个并发(tokio::join!)。附件上传工作流(仅新增模式)
与
issue create --attach不同:评论附件没有 asset-group 批量 API,每个文件单独调POST /{repo}/-/issues/{n}/comment-{file|image}-asset-upload-url申请 upload URL,之后步骤一致(PUT 到 OSS → 拿asset_link→ 追加到 body 末尾)。任何一步附件上传失败会直接中断,评论 不会被创建。
迁移指南
从 P0-5 之前的
issue comment {add/list/view/edit}子命令组 issue comment add 42 -c "x"issue comment 42 -b "x"(注意-c→-b)issue comment add 42 -c "x" --attach FILEissue comment 42 -b "x" --attach FILEissue comment list 42issue view 42 --commentsissue comment view 42 <CID>issue comment 42 --view <CID>issue comment edit 42 <CID> -c "x"issue comment 42 --id <CID> -b "x"(cnb-rs 保留任意 CID 编辑能力,比 gh 多)旧用法 fail 行为
2
clap 直接拒绝,提示用户改用新单命令。
关联命令
issue close/issue reopen也接受-c "评论"选项,在状态变更前先发评论;本命令是独立的「只发评论」单命令。另请参阅
--comments查看 issue 上所有评论