feat(drive): add comment batch-query/resolve/restore, reply CRUD and reaction shortcuts - #1898
Conversation
📝 WalkthroughWalkthroughAdds Drive comment and reply shortcuts for querying, solved-state management, reply lifecycle operations, and reactions. Shared handling supports URL/token/type resolution, Wiki unwrapping, validation, dry-run planning, output normalization, tests, registry integration, and documentation. ChangesDrive comment workflows
Estimated code review effort: 5 (Critical) | ~90 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
81c45ba to
e1e08b2
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/cli_e2e/drive/coverage.md`:
- Around line 32-35: Add a self-contained live E2E workflow test file covering
the shortcut flows in TestDrive_CommentOpsDryRun: +batch-query-comments,
+resolve-comment, +add-reply, and +delete-reply. Use the live API to create
required comments and replies, exercise each operation including both resolve
and restore behavior, verify responses and state changes, then clean up all
created resources even when assertions fail.
In `@tests/cli_e2e/drive/drive_comment_ops_dryrun_test.go`:
- Around line 18-181: Add a self-contained live E2E test alongside
TestDrive_CommentOpsDryRun covering +batch-query-comments, +resolve-comment,
+add-reply, and +delete-reply. Create the required document/comment fixture,
exercise each shortcut against the live service with assertions on the
round-trip results, and ensure cleanup runs reliably via test cleanup even when
assertions fail.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c98e4543-2937-4a11-9d83-f1381cd3423b
📒 Files selected for processing (23)
internal/qualitygate/diff/diff.gointernal/qualitygate/diff/diff_test.goshortcuts/base/base_resolve.goshortcuts/drive/drive_add_reply.goshortcuts/drive/drive_add_reply_test.goshortcuts/drive/drive_batch_query_comments.goshortcuts/drive/drive_batch_query_comments_test.goshortcuts/drive/drive_comment_common.goshortcuts/drive/drive_comment_common_test.goshortcuts/drive/drive_delete_reply.goshortcuts/drive/drive_delete_reply_test.goshortcuts/drive/drive_export.goshortcuts/drive/drive_import.goshortcuts/drive/drive_inspect.goshortcuts/drive/drive_list_comments.goshortcuts/drive/drive_resolve_comment.goshortcuts/drive/drive_resolve_comment_test.goshortcuts/drive/shortcuts.goshortcuts/drive/shortcuts_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-comments-guide.mdtests/cli_e2e/drive/coverage.mdtests/cli_e2e/drive/drive_comment_ops_dryrun_test.go
e1e08b2 to
3ea7e26
Compare
3ea7e26 to
11e1595
Compare
|
Current PR head is still For the apps regression check, I used the provided page URL: ./lark-cli drive +list-comments --url "https://bytedance.feishu.cn/page/N1BWmMrqndT5ZcamAIBcnvDLnOf/" --solved-status all --page-size 100 --as bot --format jsonThis succeeds as bot and returns |
11e1595 to
41a7462
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@skills/lark-drive/SKILL.md`:
- Around line 104-105: 更新 SKILL.md 中关于评论文本转义的说明,明确使用 drive +add-comment 或 drive
+add-reply shortcut 时传入原始文本,由 shortcut 自动转义;直接调用 drive file.comments create_v2 或
drive file.comment.replys update 时,调用方必须先将文本中的 < 和 > 转义后再提交,避免 shortcut 调用方重复转义。
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7ec789d4-d494-456d-87e5-e38253e05dac
📒 Files selected for processing (16)
shortcuts/drive/drive_add_reply.goshortcuts/drive/drive_add_reply_test.goshortcuts/drive/drive_batch_query_comments.goshortcuts/drive/drive_batch_query_comments_test.goshortcuts/drive/drive_comment_common.goshortcuts/drive/drive_comment_common_test.goshortcuts/drive/drive_delete_reply.goshortcuts/drive/drive_delete_reply_test.goshortcuts/drive/drive_resolve_comment.goshortcuts/drive/drive_resolve_comment_test.goshortcuts/drive/shortcuts.goshortcuts/drive/shortcuts_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-comments-guide.mdtests/cli_e2e/drive/coverage.mdtests/cli_e2e/drive/drive_comment_ops_dryrun_test.go
🚧 Files skipped from review as they are similar to previous changes (15)
- shortcuts/drive/drive_delete_reply_test.go
- shortcuts/drive/shortcuts.go
- shortcuts/drive/drive_batch_query_comments.go
- shortcuts/drive/drive_delete_reply.go
- shortcuts/drive/drive_batch_query_comments_test.go
- shortcuts/drive/drive_resolve_comment_test.go
- shortcuts/drive/shortcuts_test.go
- shortcuts/drive/drive_comment_common.go
- tests/cli_e2e/drive/drive_comment_ops_dryrun_test.go
- shortcuts/drive/drive_resolve_comment.go
- tests/cli_e2e/drive/coverage.md
- shortcuts/drive/drive_comment_common_test.go
- shortcuts/drive/drive_add_reply.go
- shortcuts/drive/drive_add_reply_test.go
- skills/lark-drive/references/lark-drive-comments-guide.md
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1898 +/- ##
==========================================
+ Coverage 74.96% 75.40% +0.44%
==========================================
Files 892 924 +32
Lines 94058 97923 +3865
==========================================
+ Hits 70506 73843 +3337
- Misses 18139 18452 +313
- Partials 5413 5628 +215 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@3fced0e1d3a1bae27520ac9a73b0bbc2ee4e99c5🧩 Skill updatenpx skills add larksuite/cli#feat/drive-comment-shortcuts -y -g |
41a7462 to
b7aea0b
Compare
b7aea0b to
a5e2d29
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
shortcuts/drive/drive_batch_query_comments_test.go (1)
1-1: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAPI-error propagation tests only assert on message substrings, not on typed error classification.
All four "PropagatesAPIError" tests share the same gap: they check
strings.Contains(err.Error(), "...")but never verify the error remains a typed API error (e.g., viaerrs.ProblemOf(err)→Category == errs.CategoryAPI). A regression whereruntime.CallAPITyped's typed error gets rewrapped as a plain error would pass all four tests silently.
shortcuts/drive/drive_batch_query_comments_test.go#L353-373: after the substring check, addif p, ok := errs.ProblemOf(err); !ok || p.Category != errs.CategoryAPI { t.Fatalf(...) }.shortcuts/drive/drive_add_reply_test.go#L261-282: add the sameerrs.ProblemOfCategory assertion after the substring check.shortcuts/drive/drive_resolve_comment_test.go#L266-287: add the sameerrs.ProblemOfCategory assertion after the substring check.shortcuts/drive/drive_delete_reply_test.go#L176-198: add the sameerrs.ProblemOfCategory assertion after the substring check.Based on learnings, in larksuite/cli Go test suites for shortcuts domain packages, when exercising error paths, tests should "assert
Category == errs.CategoryAPIand verifySubtypeis non-empty/populated" rather than relying only on message text. This is also consistent with the path instruction that "**/*_test.go... contract tests must assert the new field or behavior directly rather than relying only on happy-path substrings."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@shortcuts/drive/drive_batch_query_comments_test.go` at line 1, Update all four PropagatesAPIError tests in the drive shortcuts test suite to classify the returned error with errs.ProblemOf(err) after the existing message assertion. Fail unless extraction succeeds, Category equals errs.CategoryAPI, and Subtype is non-empty, preserving the current message checks while directly validating typed API-error propagation.Sources: Path instructions, Learnings
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@shortcuts/drive/drive_add_reply_test.go`:
- Around line 308-320: Update TestDriveAddReplyInvalidContent to call
assertDriveCommentValidationError(t, err, "--content") in addition to verifying
the invalid-JSON message, ensuring the returned error is typed and attributed to
the --content flag.
---
Nitpick comments:
In `@shortcuts/drive/drive_batch_query_comments_test.go`:
- Line 1: Update all four PropagatesAPIError tests in the drive shortcuts test
suite to classify the returned error with errs.ProblemOf(err) after the existing
message assertion. Fail unless extraction succeeds, Category equals
errs.CategoryAPI, and Subtype is non-empty, preserving the current message
checks while directly validating typed API-error propagation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e8d2da51-2003-4953-8cf2-384b1db7f06a
📒 Files selected for processing (17)
shortcuts/drive/drive_add_reply.goshortcuts/drive/drive_add_reply_test.goshortcuts/drive/drive_batch_query_comments.goshortcuts/drive/drive_batch_query_comments_test.goshortcuts/drive/drive_comment_common.goshortcuts/drive/drive_comment_common_test.goshortcuts/drive/drive_delete_reply.goshortcuts/drive/drive_delete_reply_test.goshortcuts/drive/drive_resolve_comment.goshortcuts/drive/drive_resolve_comment_test.goshortcuts/drive/shortcuts.goshortcuts/drive/shortcuts_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-comments-guide.mdtests/cli_e2e/drive/coverage.mdtests/cli_e2e/drive/drive_comment_ops_dryrun_test.gotests/cli_e2e/drive/drive_comment_ops_workflow_test.go
🚧 Files skipped from review as they are similar to previous changes (12)
- shortcuts/drive/shortcuts.go
- shortcuts/drive/drive_delete_reply.go
- tests/cli_e2e/drive/drive_comment_ops_dryrun_test.go
- shortcuts/drive/drive_batch_query_comments.go
- shortcuts/drive/drive_comment_common_test.go
- shortcuts/drive/drive_resolve_comment.go
- tests/cli_e2e/drive/drive_comment_ops_workflow_test.go
- shortcuts/drive/drive_comment_common.go
- shortcuts/drive/drive_add_reply.go
- shortcuts/drive/shortcuts_test.go
- tests/cli_e2e/drive/coverage.md
- skills/lark-drive/references/lark-drive-comments-guide.md
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@shortcuts/drive/drive_batch_query_comments.go`:
- Around line 43-45: After resolving the target in the drive batch query flow,
reject --need-relation whenever the resolved file type is not docx, including
Wiki targets resolving to non-docx, by returning a typed validation error with
Param("--need-relation") instead of silently omitting need_relation. Update the
existing non-docx handling message accordingly, and revise
tests/cli_e2e/drive/coverage.md at line 34 to document rejection; add direct and
Wiki rejection coverage as requested.
In `@tests/cli_e2e/drive/coverage.md`:
- Line 16: Correct the manual-verification count in TestDrive_CommentOpsDryRun
to eight, matching the eight listed drive shortcuts including +restore-comment;
leave the rest of the coverage description unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 87f15e63-83d2-4f31-be59-aa6b42ae3902
📒 Files selected for processing (30)
shortcuts/drive/drive_batch_query_comments.goshortcuts/drive/drive_batch_query_comments_test.goshortcuts/drive/drive_comment_common_test.goshortcuts/drive/drive_list_replies.goshortcuts/drive/drive_list_replies_test.goshortcuts/drive/drive_react_reply.goshortcuts/drive/drive_react_reply_test.goshortcuts/drive/drive_resolve_comment.goshortcuts/drive/drive_resolve_comment_test.goshortcuts/drive/shortcuts.goshortcuts/drive/shortcuts_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-add-comment.mdskills/lark-drive/references/lark-drive-add-reply.mdskills/lark-drive/references/lark-drive-batch-query-comments.mdskills/lark-drive/references/lark-drive-comment-content.mdskills/lark-drive/references/lark-drive-comment-location.mdskills/lark-drive/references/lark-drive-comments-guide.mdskills/lark-drive/references/lark-drive-delete-reply.mdskills/lark-drive/references/lark-drive-list-comments.mdskills/lark-drive/references/lark-drive-list-replies.mdskills/lark-drive/references/lark-drive-react-reply.mdskills/lark-drive/references/lark-drive-reactions.mdskills/lark-drive/references/lark-drive-resolve-comment.mdskills/lark-drive/references/lark-drive-restore-comment.mdskills/lark-drive/references/lark-drive-update-reply.mdskills/lark-slides/references/lark-slides-media-upload.mdtests/cli_e2e/drive/coverage.mdtests/cli_e2e/drive/drive_comment_ops_dryrun_test.gotests/cli_e2e/drive/drive_comment_ops_workflow_test.go
💤 Files with no reviewable changes (1)
- shortcuts/drive/drive_list_replies.go
🚧 Files skipped from review as they are similar to previous changes (9)
- shortcuts/drive/shortcuts.go
- shortcuts/drive/shortcuts_test.go
- shortcuts/drive/drive_react_reply.go
- tests/cli_e2e/drive/drive_comment_ops_dryrun_test.go
- shortcuts/drive/drive_react_reply_test.go
- skills/lark-drive/references/lark-drive-reactions.md
- tests/cli_e2e/drive/drive_comment_ops_workflow_test.go
- shortcuts/drive/drive_list_replies_test.go
- shortcuts/drive/drive_batch_query_comments_test.go
0555bec to
d0ae983
Compare
d0ae983 to
c50d03e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@shortcuts/drive/drive_resolve_comment_test.go`:
- Around line 253-272: Update TestDriveResolveCommentPropagatesAPIError and the
related test to inspect errs.ProblemOf(err), asserting CategoryAPI and a
non-empty subtype while retaining the existing message or cause checks. Use the
typed API-error metadata assertions for both error-path cases instead of relying
only on strings.Contains.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 142ad389-1dc1-4035-86a8-07e0cbe10adf
📒 Files selected for processing (40)
shortcuts/drive/drive_add_comment.goshortcuts/drive/drive_add_reply.goshortcuts/drive/drive_add_reply_test.goshortcuts/drive/drive_batch_query_comments.goshortcuts/drive/drive_batch_query_comments_test.goshortcuts/drive/drive_comment_common.goshortcuts/drive/drive_comment_common_test.goshortcuts/drive/drive_delete_reply.goshortcuts/drive/drive_delete_reply_test.goshortcuts/drive/drive_list_comments.goshortcuts/drive/drive_list_comments_test.goshortcuts/drive/drive_list_replies.goshortcuts/drive/drive_list_replies_test.goshortcuts/drive/drive_react_reply.goshortcuts/drive/drive_react_reply_test.goshortcuts/drive/drive_resolve_comment.goshortcuts/drive/drive_resolve_comment_test.goshortcuts/drive/drive_update_reply.goshortcuts/drive/drive_update_reply_test.goshortcuts/drive/shortcuts.goshortcuts/drive/shortcuts_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-add-comment.mdskills/lark-drive/references/lark-drive-add-reply.mdskills/lark-drive/references/lark-drive-batch-query-comments.mdskills/lark-drive/references/lark-drive-comment-content.mdskills/lark-drive/references/lark-drive-comment-location.mdskills/lark-drive/references/lark-drive-comments-guide.mdskills/lark-drive/references/lark-drive-delete-reply.mdskills/lark-drive/references/lark-drive-list-comments.mdskills/lark-drive/references/lark-drive-list-replies.mdskills/lark-drive/references/lark-drive-react-reply.mdskills/lark-drive/references/lark-drive-reactions.mdskills/lark-drive/references/lark-drive-resolve-comment.mdskills/lark-drive/references/lark-drive-restore-comment.mdskills/lark-drive/references/lark-drive-update-reply.mdskills/lark-slides/references/lark-slides-media-upload.mdtests/cli_e2e/drive/coverage.mdtests/cli_e2e/drive/drive_comment_ops_dryrun_test.gotests/cli_e2e/drive/drive_comment_ops_workflow_test.go
🚧 Files skipped from review as they are similar to previous changes (27)
- shortcuts/drive/shortcuts.go
- skills/lark-drive/references/lark-drive-list-comments.md
- skills/lark-drive/references/lark-drive-restore-comment.md
- skills/lark-drive/references/lark-drive-react-reply.md
- shortcuts/drive/shortcuts_test.go
- skills/lark-drive/references/lark-drive-comment-content.md
- shortcuts/drive/drive_list_comments_test.go
- skills/lark-drive/references/lark-drive-add-comment.md
- skills/lark-drive/references/lark-drive-add-reply.md
- skills/lark-drive/references/lark-drive-batch-query-comments.md
- skills/lark-drive/references/lark-drive-comment-location.md
- shortcuts/drive/drive_comment_common.go
- skills/lark-drive/references/lark-drive-update-reply.md
- shortcuts/drive/drive_delete_reply_test.go
- skills/lark-drive/references/lark-drive-delete-reply.md
- shortcuts/drive/drive_update_reply_test.go
- skills/lark-drive/references/lark-drive-resolve-comment.md
- tests/cli_e2e/drive/drive_comment_ops_dryrun_test.go
- skills/lark-drive/references/lark-drive-list-replies.md
- shortcuts/drive/drive_comment_common_test.go
- shortcuts/drive/drive_react_reply_test.go
- shortcuts/drive/drive_add_reply_test.go
- tests/cli_e2e/drive/drive_comment_ops_workflow_test.go
- shortcuts/drive/drive_list_replies_test.go
- skills/lark-drive/references/lark-drive-reactions.md
- shortcuts/drive/drive_batch_query_comments_test.go
- tests/cli_e2e/drive/coverage.md
c50d03e to
bf483ca
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@shortcuts/drive/drive_update_reply_test.go`:
- Around line 260-262: Update both error-path tests at
shortcuts/drive/drive_update_reply_test.go:260-262 and 287-289 to inspect
errs.ProblemOf(err) instead of relying only on message text. For the API
response case, assert CategoryAPI, a populated subtype, and preservation of the
underlying cause; for the incomplete-node case, assert its typed metadata and
applicable cause while retaining any necessary message validation.
In `@skills/lark-drive/references/lark-drive-resolve-comment.md`:
- Line 12: Update the supported URL-type list in lark-drive-resolve-comment.md
to include bitable alongside docx, doc, sheet, file, slides, base, and apps,
matching the parameter contract referenced later in the document.
In `@skills/lark-drive/SKILL.md`:
- Line 31: Update the document-comment routing instruction so comment statistics
requests use the +list-comments shortcut and requests to locate comment text use
lark-drive-comment-location.md; keep other comment operations routed through the
guide’s intent table and specific command refs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: c9798ac1-25c7-4fa9-add4-0665df0fc757
📒 Files selected for processing (41)
shortcuts/drive/drive_add_comment.goshortcuts/drive/drive_add_comment_test.goshortcuts/drive/drive_add_reply.goshortcuts/drive/drive_add_reply_test.goshortcuts/drive/drive_batch_query_comments.goshortcuts/drive/drive_batch_query_comments_test.goshortcuts/drive/drive_comment_common.goshortcuts/drive/drive_comment_common_test.goshortcuts/drive/drive_delete_reply.goshortcuts/drive/drive_delete_reply_test.goshortcuts/drive/drive_list_comments.goshortcuts/drive/drive_list_comments_test.goshortcuts/drive/drive_list_replies.goshortcuts/drive/drive_list_replies_test.goshortcuts/drive/drive_react_reply.goshortcuts/drive/drive_react_reply_test.goshortcuts/drive/drive_resolve_comment.goshortcuts/drive/drive_resolve_comment_test.goshortcuts/drive/drive_update_reply.goshortcuts/drive/drive_update_reply_test.goshortcuts/drive/shortcuts.goshortcuts/drive/shortcuts_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-add-comment.mdskills/lark-drive/references/lark-drive-add-reply.mdskills/lark-drive/references/lark-drive-batch-query-comments.mdskills/lark-drive/references/lark-drive-comment-content.mdskills/lark-drive/references/lark-drive-comment-location.mdskills/lark-drive/references/lark-drive-comments-guide.mdskills/lark-drive/references/lark-drive-delete-reply.mdskills/lark-drive/references/lark-drive-list-comments.mdskills/lark-drive/references/lark-drive-list-replies.mdskills/lark-drive/references/lark-drive-react-reply.mdskills/lark-drive/references/lark-drive-reactions.mdskills/lark-drive/references/lark-drive-resolve-comment.mdskills/lark-drive/references/lark-drive-restore-comment.mdskills/lark-drive/references/lark-drive-update-reply.mdskills/lark-slides/references/lark-slides-media-upload.mdtests/cli_e2e/drive/coverage.mdtests/cli_e2e/drive/drive_comment_ops_dryrun_test.gotests/cli_e2e/drive/drive_comment_ops_workflow_test.go
🚧 Files skipped from review as they are similar to previous changes (35)
- shortcuts/drive/shortcuts.go
- skills/lark-drive/references/lark-drive-restore-comment.md
- shortcuts/drive/drive_list_comments.go
- skills/lark-slides/references/lark-slides-media-upload.md
- shortcuts/drive/drive_update_reply.go
- shortcuts/drive/drive_react_reply.go
- skills/lark-drive/references/lark-drive-comment-location.md
- shortcuts/drive/drive_list_comments_test.go
- shortcuts/drive/drive_comment_common_test.go
- shortcuts/drive/drive_add_comment.go
- shortcuts/drive/drive_delete_reply.go
- skills/lark-drive/references/lark-drive-delete-reply.md
- shortcuts/drive/shortcuts_test.go
- skills/lark-drive/references/lark-drive-add-comment.md
- tests/cli_e2e/drive/drive_comment_ops_dryrun_test.go
- shortcuts/drive/drive_resolve_comment.go
- skills/lark-drive/references/lark-drive-update-reply.md
- skills/lark-drive/references/lark-drive-react-reply.md
- skills/lark-drive/references/lark-drive-batch-query-comments.md
- shortcuts/drive/drive_batch_query_comments.go
- tests/cli_e2e/drive/drive_comment_ops_workflow_test.go
- skills/lark-drive/references/lark-drive-add-reply.md
- shortcuts/drive/drive_comment_common.go
- shortcuts/drive/drive_resolve_comment_test.go
- skills/lark-drive/references/lark-drive-comment-content.md
- skills/lark-drive/references/lark-drive-list-replies.md
- shortcuts/drive/drive_list_replies.go
- shortcuts/drive/drive_react_reply_test.go
- shortcuts/drive/drive_list_replies_test.go
- shortcuts/drive/drive_delete_reply_test.go
- shortcuts/drive/drive_add_reply_test.go
- skills/lark-drive/references/lark-drive-reactions.md
- shortcuts/drive/drive_add_reply.go
- tests/cli_e2e/drive/coverage.md
- shortcuts/drive/drive_batch_query_comments_test.go
Add comment-domain shortcuts: +batch-query-comments, +resolve-comment, +restore-comment, +add-reply, +list-replies, +update-reply, +delete-reply and +react-reply, sharing one target resolver with per-endpoint file_type sets. Flatten the comment reference docs by dropping the comments-guide routing layer and folding its cross-command knowledge into the command refs: comment-card model, comment/reply/interaction counting and sorting rules into lark-drive-list-comments.md; the --solved-status prerequisite into lark-drive-restore-comment.md; the apps exception into lark-drive-add-comment.md. Comment intents now route straight from the drive SKILL.md Shortcuts table to each command ref. Cover the new shortcuts with unit tests, dry-run e2e and live workflow e2e behind LARK_DRIVE_MD_COMMENT_E2E=1, and register them in tests/cli_e2e/drive/coverage.md.
bf483ca to
3fced0e
Compare
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (3)
shortcuts/drive/drive_comment_common.go (1)
83-160: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider extracting the duplicated type-conflict/unsupported-type error blocks.
Lines 103-120 and 126-143 build identical errors for the
ParseResourceURLand apps-page-URL branches. A small helper taking(refType, sourceFlag)would keep the two branches in sync as types evolve.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@shortcuts/drive/drive_comment_common.go` around lines 83 - 160, The duplicated type-conflict and unsupported-type validation in resolveDriveCommentInput should be extracted into a small helper accepting refType and sourceFlag, using op to validate against the explicit type and supported types. Call the helper from both the common ParseResourceURL and parseDriveListCommentsAppsURL branches, preserving their existing error behavior before returning the parsed reference.shortcuts/drive/drive_delete_reply_test.go (1)
227-279: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider covering the destructive-confirmation gate.
+delete-replyishigh-risk-writeand every execute test passes--yes; nothing asserts the command refuses to delete without it. A single test omitting--yes(non-interactive) would lock that behavior in.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@shortcuts/drive/drive_delete_reply_test.go` around lines 227 - 279, Add a non-interactive test for the DriveDeleteReply command that omits --yes while retaining the required delete-reply arguments, and assert it returns an error without issuing a delete API call. Place it alongside TestDriveDeleteReplyDryRunDirect and TestDriveDeleteReplyDryRunWiki to cover the high-risk confirmation gate.skills/lark-drive/references/lark-drive-batch-query-comments.md (1)
27-27: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAvoid documenting undocumented-metadata/compatibility internals.
"该参数未收录于平台 metadata,但服务端支持" exposes an internal compatibility nuance rather than caller-facing guidance.
Based on learnings, when writing lark-drive skill docs, avoid exposing internal implementation/compatibility details and keep guidance for callers concise.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@skills/lark-drive/references/lark-drive-batch-query-comments.md` at line 27, Revise the guidance around --need-relation in lark-drive-batch-query.md to remove the platform-metadata and server-compatibility detail. Keep only concise caller-facing behavior: that it is sent in the request body, applies when the parsed target is docx, and returns relation and block-location data.Source: Learnings
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@shortcuts/drive/drive_add_reply_test.go`:
- Around line 265-286: Update TestDriveAddReplyPropagatesAPIError in
shortcuts/drive/drive_add_reply_test.go:265-286 to inspect errs.ProblemOf(err),
asserting category errs.CategoryAPI and a non-empty subtype in addition to the
message. Update TestDriveDeleteReplyPropagatesAPIError and
TestDriveDeleteReplyWikiNodeIncompleteResponse in
shortcuts/drive/drive_delete_reply_test.go:176-225 to assert category, non-empty
subtype, and param through errs.ProblemOf(err), with the incomplete-response
test also verifying the original cause is preserved.
In `@shortcuts/drive/drive_batch_query_comments_test.go`:
- Around line 370-372: Strengthen both API-error tests by calling
assertDriveCommentAPIError after the existing message check: update
shortcuts/drive/drive_batch_query_comments_test.go lines 370-372 with status
1069307 and shortcuts/drive/drive_list_replies_test.go lines 300-302 with status
1069301. Preserve the message assertions while using the helper to validate
typed metadata and cause preservation.
In `@shortcuts/drive/drive_batch_query_comments.go`:
- Line 58: Update the ConditionalScopes declaration in DriveBatchQueryComments
at shortcuts/drive/drive_batch_query_comments.go:58-58 from wiki:node:read to
wiki:node:retrieve, and make the same change in DriveListReplies at
shortcuts/drive/drive_list_replies.go:38-38, matching the +list-comments scope
for the get_node endpoint.
In `@shortcuts/drive/drive_react_reply_test.go`:
- Around line 237-240: Strengthen the error-path assertions in
shortcuts/drive/drive_react_reply_test.go at lines 237-240 and 257-259 by using
errs.ProblemOf plus the established validation-error helper or errors.As to
verify invalid emoji errors are validation errors for --emoji and invalid action
errors are validation errors for --action. At lines 309-311, assert the
incomplete Wiki-node failure’s typed category, subtype, and relevant parameter
instead of checking only its message.
In `@skills/lark-drive/references/lark-drive-batch-query-comments.md`:
- Around line 22-23: Update the validation handling for the --need-relation
option in the batch comment query flow so non-docx targets return a typed
validation error instead of silently omitting need_relation from RequestBody.
Preserve the existing behavior for docx targets, and ensure the error identifies
the invalid option/target combination.
In `@tests/cli_e2e/drive/drive_comment_ops_workflow_test.go`:
- Around line 1-203: Update TestDriveListCommentsDryRun_AppsPageURL in
drive_list_comments_dryrun_test.go to execute the +list-comments request with
DefaultAs set to "bot". Preserve the existing file_type=apps and /page/<token>
URL assertions, ensuring the regression explicitly covers the Bot persona
described in coverage.md.
---
Nitpick comments:
In `@shortcuts/drive/drive_comment_common.go`:
- Around line 83-160: The duplicated type-conflict and unsupported-type
validation in resolveDriveCommentInput should be extracted into a small helper
accepting refType and sourceFlag, using op to validate against the explicit type
and supported types. Call the helper from both the common ParseResourceURL and
parseDriveListCommentsAppsURL branches, preserving their existing error behavior
before returning the parsed reference.
In `@shortcuts/drive/drive_delete_reply_test.go`:
- Around line 227-279: Add a non-interactive test for the DriveDeleteReply
command that omits --yes while retaining the required delete-reply arguments,
and assert it returns an error without issuing a delete API call. Place it
alongside TestDriveDeleteReplyDryRunDirect and TestDriveDeleteReplyDryRunWiki to
cover the high-risk confirmation gate.
In `@skills/lark-drive/references/lark-drive-batch-query-comments.md`:
- Line 27: Revise the guidance around --need-relation in
lark-drive-batch-query.md to remove the platform-metadata and
server-compatibility detail. Keep only concise caller-facing behavior: that it
is sent in the request body, applies when the parsed target is docx, and returns
relation and block-location data.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: fed6d444-322a-4340-9b31-0aa99c2ce9d5
📒 Files selected for processing (41)
shortcuts/drive/drive_add_comment.goshortcuts/drive/drive_add_comment_test.goshortcuts/drive/drive_add_reply.goshortcuts/drive/drive_add_reply_test.goshortcuts/drive/drive_batch_query_comments.goshortcuts/drive/drive_batch_query_comments_test.goshortcuts/drive/drive_comment_common.goshortcuts/drive/drive_comment_common_test.goshortcuts/drive/drive_delete_reply.goshortcuts/drive/drive_delete_reply_test.goshortcuts/drive/drive_list_comments.goshortcuts/drive/drive_list_comments_test.goshortcuts/drive/drive_list_replies.goshortcuts/drive/drive_list_replies_test.goshortcuts/drive/drive_react_reply.goshortcuts/drive/drive_react_reply_test.goshortcuts/drive/drive_resolve_comment.goshortcuts/drive/drive_resolve_comment_test.goshortcuts/drive/drive_update_reply.goshortcuts/drive/drive_update_reply_test.goshortcuts/drive/shortcuts.goshortcuts/drive/shortcuts_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-add-comment.mdskills/lark-drive/references/lark-drive-add-reply.mdskills/lark-drive/references/lark-drive-batch-query-comments.mdskills/lark-drive/references/lark-drive-comment-content.mdskills/lark-drive/references/lark-drive-comment-location.mdskills/lark-drive/references/lark-drive-comments-guide.mdskills/lark-drive/references/lark-drive-delete-reply.mdskills/lark-drive/references/lark-drive-list-comments.mdskills/lark-drive/references/lark-drive-list-replies.mdskills/lark-drive/references/lark-drive-react-reply.mdskills/lark-drive/references/lark-drive-reactions.mdskills/lark-drive/references/lark-drive-resolve-comment.mdskills/lark-drive/references/lark-drive-restore-comment.mdskills/lark-drive/references/lark-drive-update-reply.mdskills/lark-slides/references/lark-slides-media-upload.mdtests/cli_e2e/drive/coverage.mdtests/cli_e2e/drive/drive_comment_ops_dryrun_test.gotests/cli_e2e/drive/drive_comment_ops_workflow_test.go
💤 Files with no reviewable changes (1)
- skills/lark-drive/references/lark-drive-comments-guide.md
🚧 Files skipped from review as they are similar to previous changes (11)
- shortcuts/drive/shortcuts_test.go
- skills/lark-slides/references/lark-slides-media-upload.md
- shortcuts/drive/drive_add_comment.go
- skills/lark-drive/references/lark-drive-restore-comment.md
- skills/lark-drive/references/lark-drive-comment-content.md
- skills/lark-drive/references/lark-drive-add-comment.md
- skills/lark-drive/references/lark-drive-comment-location.md
- tests/cli_e2e/drive/coverage.md
- skills/lark-drive/references/lark-drive-list-comments.md
- skills/lark-drive/references/lark-drive-update-reply.md
- skills/lark-drive/references/lark-drive-reactions.md
Summary
Add eight comment-operation shortcuts to the
drivedomain, covering the remaining comment APIs —+batch-query-comments,+resolve-comment/+restore-comment, the full reply family+add-reply/+list-replies/+update-reply/+delete-reply(batch_query / patch / reply create / list / update / delete), and+react-replyfor reply emoji reactions (update_reaction) — with the same URL-parsing + wiki-unwrapping UX as+list-comments.Changes
+batch-query-commentsPOST /drive/v1/files/:token/comments/batch_query—--comment-ids(CSV/repeated, max 100),--need-reaction,--need-relation(docx-gated)+resolve-commentPATCH /drive/v1/files/:token/comments/:comment_id— sendsis_solved=true+restore-commentPATCHendpoint — sendsis_solved=false(reopen a solved comment)+add-replyPOST /drive/v1/files/:token/comments/:comment_id/replies—--contentreuses the+add-commentreply_elements JSON (same escaping and 10k-rune preflight), mapped totext_run/person/docs_link+list-repliesGET .../comments/:comment_id/replies—--page-size/--page-tokenpagination,--need-reaction+update-replyPUT .../comments/:comment_id/replies/:reply_id— whole-content replacement, same--contentJSON as+add-reply+delete-replyDELETE .../comments/:comment_id/replies/:reply_id— requires--yes+react-replyPOST /drive/v2/files/:token/comments/reaction—--reply-id+--emoji+--action add|delete→ bodyreply_id/reaction_type/action--urlor--token+--typeand unwrap wiki nodes automatically; shared input resolution lives indrive_comment_common.go, parameterized by each endpoint's supportedfile_typeset. All eight accept Base (/base/URLs,bitable/basetypes) and Miaoda apps targets (/page/<token>URLs,file_type=apps), matching the platform API metadata.+resolve-comment/+restore-commentare two commands sharing one constructor over the same patch endpoint (the original single+resolve-comment --action resolve|restoreread ambiguously — a "resolve" command that can also reopen); intent mapping is documented in the skill guide.+batch-query-comments --need-relationmirrors+list-comments: docx-only (silently omitted for other targets) and sent in the request body, whereas the list endpoint takes it as a query param. The parameter is absent from the platform metadata for batch_query but honored by the server — verified live, returningrelationwith the anchoring block position. Its wiki dry-run surfaces the docx gate as aneed_relation: "<sent only when obj_type is docx>"placeholder, since the resolved type is unknown until step 1.+add-replydeclaresdocs:document.comment:create— the replies create endpoint does not acceptdocs:document.comment:write_only, so declaring both would false-reject valid create-only tokens; resolve/restore/update/delete/react keepwrite_only, batch-query/list keepcomment:read.+add-replydeliberately does not use the documented "POST .../comments withcomment_idin the body" form: verified live, that variant silently creates a new standalone comment instead of replying. The dedicated replies endpoint is used instead (noted in code and in the skill guide).items[0]of the first page only — after--page-tokenpaging,items[0]is a regular reply, so position must not be used to identify the root when paging;1069303 forbidden(verified in both user→bot and bot→user directions);reaction_type— arbitrary strings are accepted and persisted as broken reactions, so--emojiis validated locally against the 149-value platform enum from the API metadata (case-sensitive:THUMBSUPvsThumbsDown);count=0entries inneed_reactionreads, so presence checks filter bycount>0;+list-comments/+batch-query-comments/+list-repliesnow always emititemsas a JSON array (shareddriveCommentItemshelper) — previously a server response omittingitemswould surface"items": nulland break jq consumers iterating.data.items[].wiki:node:readas the wiki-unwrap conditional scope: live verification with both identities showedget_nodeacceptswiki:wiki/wiki:wiki:readonly/wiki:node:read(a token carrying onlywiki:node:retrieveis rejected with 99991679), and the sheets/slides domains already declarewiki:node:readfor the same unwrap step. Existing drive/base commands that still declarewiki:node:retrieveare intentionally left unchanged in this PR; aligning them is a candidate follow-up.SKILL.mdkeeps a single comment entry intoreferences/lark-drive-comments-guide.mdand terse command-table rows, dropping the inlined params/limits/Base/escaping/raw-API detail.lark-drive-comments-guide.mdis a second-level router (intent→command table + cross-command knowledge: target resolution, comment-card model, root reply, counting/sorting). Each shortcut gets its own ref (lark-drive-{batch-query-comments,resolve-comment,restore-comment,add-reply,list-replies,update-reply,delete-reply,react-reply}.md), and--contentschema/escaping/10k-cap/raw-body conversion is centralized in the newlark-drive-comment-content.md.lark-drive-reactions.mdandlark-drive-comment-location.mdremain cross-cutting refs. Reply preconditions are written as executable steps (checkis_whole/is_solvedvia+batch-query-comments, or+list-comments --solved-status all), and stale raw-API routing in the list-comments/location/reactions guides is reframed as fallback-only. Caveats above are retained (whole/solved comments reject replies; rapid resolve/restore flips can hit HTTP 429).Test Plan
make unit-test(-race) green; new-file statement coverage 94%+ (remaining lines are the CLI-unreachable defensive branches in DryRun/Execute closures); contract tests assert payload values directly (returned reply IDs and nested content on+list-replies, convertedtext_run.text/person.user_idin+add-reply/+update-replyrequest bodies)lark-cli drive +<command>flows work as expected — full live round trips on a real wiki→docx document with both--as userand--as bot: list → batch-query → add-reply → list-replies (incl.--page-size 1two-page paging ) → update-reply → react add/delete → resolve/restore → delete-reply, document restored to its original state afterwards; cross-identity update rejection probed in both directions, and the unvalidated-reaction_type/count=0tombstone behaviors probed livetests/cli_e2e/drive/drive_comment_ops_dryrun_test.go) pin method/URL/params/body shapes for all eight commands incl. base/apps targets, the wiki 2-step plans, the resolve/restore split, and theneed_relationbody gating (present for docx, omitted for base);tests/cli_e2e/drive/coverage.mdupdated (40 leaf commands, 21 covered, 52.5%)tests/cli_e2e/drive/drive_comment_ops_workflow_test.go, opt-in viaLARK_DRIVE_MD_COMMENT_E2E=1, same gate as the existing file-comment workflow): creates a Markdown file + file comment fixture, batch-queries it by ID, attaches a reply, lists it back, rewrites it via+update-reply(polling+list-repliesuntil the new text lands), attaches and removes a THUMBSUP reaction (polling+list-replies --need-reactionwith count>0 presence checks), resolves/restores with polling reads between state flips, deletes the reply, and cleans up — passed live in 19.8sgo vet ./...,gofmt -l .clean,go mod tidyno-op,golangci-lint run --new-from-rev=origin/main0 issuesRelated Issues
Summary by CodeRabbit
Summary
+batch-query-comments,+resolve-comment,+restore-comment,+add-reply,+list-replies,+update-reply,+delete-reply,+react-reply, including Wiki vs direct flows and--dry-runrequest planning.nullitemsto[]andcountto0for comment/reply listing outputs.