feat(drive): add +member-list shortcut - #1795
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a new Drive shortcut, ChangesDrive +member-list Shortcut
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant DriveMemberList
participant runtime
participant DriveAPI
User->>DriveMemberList: run drive +member-list --token/--type/--fields
DriveMemberList->>DriveMemberList: readDriveMemberListSpec
DriveMemberList->>DriveMemberList: apiPath() + params()
DriveMemberList->>runtime: CallAPITyped(GET permissions-members)
runtime->>DriveAPI: GET request
DriveAPI-->>runtime: members data
runtime-->>DriveMemberList: response
DriveMemberList-->>User: raw JSON or pretty formatted output
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1795 +/- ##
==========================================
+ Coverage 75.16% 75.18% +0.01%
==========================================
Files 912 913 +1
Lines 96475 96656 +181
==========================================
+ Hits 72517 72671 +154
- Misses 18381 18395 +14
- Partials 5577 5590 +13 ☔ 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@81d4cc6d4b85dfbf3a686a8f6c41464a4c2396e0🧩 Skill updatenpx skills add larksuite/cli#feat/drive-member-list -y -g |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
skills/lark-drive/SKILL.md (1)
153-153: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winClarify the shortcut’s scope.
The implementation and workflow docs limit+member-listto the target’s direct collaborators/authorized members, so the shortcut table should say that explicitly.Suggested wording
-| [`+member-list`](references/lark-drive-member-list.md) | 查询 Drive 文档、文件、文件夹或 wiki 节点的协作者/授权成员列表。 | +| [`+member-list`](references/lark-drive-member-list.md) | 查询 Drive 文档、文件、文件夹或 wiki 节点的直接协作者/授权成员列表。 |🤖 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/SKILL.md` at line 153, The `+member-list` shortcut description is too broad and should explicitly match the documented scope in the `SKILL.md` shortcut table. Update the entry for `+member-list` to state that it only queries the target’s direct collaborators/authorized members for Drive documents, files, folders, or wiki nodes, and keep the wording aligned with the existing `references/lark-drive-member-list.md` reference.shortcuts/drive/drive_member_list_test.go (1)
191-204: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider using
errors.Asinstead of direct type assertion for*errs.ValidationError.The direct type assertion
err.(*errs.ValidationError)works because validation errors are returned unwrapped, buterrors.Asis more robust against future wrapping and aligns with the established pattern. Based on learnings,errors.As(err, &ve)is the recommended approach for readingve.Param.♻️ Optional refactor
problem, ok := errs.ProblemOf(err) if !ok { t.Fatalf("error is not typed: %T %v", err, err) } if problem.Category != errs.CategoryValidation || problem.Subtype != errs.SubtypeInvalidArgument { t.Fatalf("problem = %s/%s, want validation/invalid_argument", problem.Category, problem.Subtype) } - validationErr, ok := err.(*errs.ValidationError) - if !ok { - t.Fatalf("error type = %T, want *errs.ValidationError", err) - } + var validationErr *errs.ValidationError + if !errors.As(err, &validationErr) { + t.Fatalf("error type = %T, want *errs.ValidationError", err) + } if validationErr.Param != tt.wantParam { t.Fatalf("param = %q, want %q", validationErr.Param, tt.wantParam) }Note: this requires adding
"errors"to the import block.🤖 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_member_list_test.go` around lines 191 - 204, In the validation checks inside drive_member_list_test.go, replace the direct `err.(*errs.ValidationError)` type assertion with `errors.As` so the test remains robust if the error gets wrapped. Keep the existing `errs.ProblemOf(err)` assertions, then use `errors.As(err, &ve)` to obtain the `*errs.ValidationError` and verify `ve.Param`; add the `errors` import and reference the existing `validationErr`/`ProblemOf` block to locate the change.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_member_list.go`:
- Around line 103-104: The validation error wrapping in the ResourceName checks
is losing the original cause, so preserve the unwrap chain when handling the
`validate.ResourceName` result. Update both `validate.ResourceName` call sites
in `drive_member_list.go` so the returned error is passed through
`errs.NewValidationError(...).WithParam(...)` and also chained with
`.WithCause(err)` before returning, keeping `errors.Is` and `errors.Unwrap`
functional.
---
Nitpick comments:
In `@shortcuts/drive/drive_member_list_test.go`:
- Around line 191-204: In the validation checks inside
drive_member_list_test.go, replace the direct `err.(*errs.ValidationError)` type
assertion with `errors.As` so the test remains robust if the error gets wrapped.
Keep the existing `errs.ProblemOf(err)` assertions, then use `errors.As(err,
&ve)` to obtain the `*errs.ValidationError` and verify `ve.Param`; add the
`errors` import and reference the existing `validationErr`/`ProblemOf` block to
locate the change.
In `@skills/lark-drive/SKILL.md`:
- Line 153: The `+member-list` shortcut description is too broad and should
explicitly match the documented scope in the `SKILL.md` shortcut table. Update
the entry for `+member-list` to state that it only queries the target’s direct
collaborators/authorized members for Drive documents, files, folders, or wiki
nodes, and keep the wording aligned with the existing
`references/lark-drive-member-list.md` reference.
🪄 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: b30a9005-019c-44f5-8c19-81e62777b252
📒 Files selected for processing (9)
shortcuts/drive/drive_member_list.goshortcuts/drive/drive_member_list_test.goshortcuts/drive/shortcuts.goshortcuts/drive/shortcuts_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-member-list.mdskills/lark-drive/references/lark-drive-workflow-permission-governance-commands.mdskills/lark-drive/references/lark-drive-workflow-permission-governance.mdtests/cli_e2e/drive/drive_member_list_test.go
6f441b4 to
8bd9382
Compare
8bd9382 to
6f441b4
Compare
70f1bbb to
259cdd8
Compare
259cdd8 to
b248196
Compare
Add a Drive shortcut for listing collaborators on documents, files, folders, and wiki nodes. Resolve supported resource URLs into typed permission requests, preserve raw API data for machine consumers, and keep invalid flag combinations on typed validation paths. Key features: - Infer resource type and token from supported Drive URLs while requiring --type for bare tokens - Validate optional member fields and wiki-only permission type filters - Provide pretty output, skill guidance, unit coverage, and dry-run/live E2E workflows - Read dry-run assertions from the standard data.api success envelope
b248196 to
994f9ca
Compare
Add a Drive shortcut for reading direct collaborator/member permissions from documents, files, folders, and wiki nodes. Keep the output close to the permissions API response while adding typed validation, dry-run coverage, and skill guidance for agent workflows.
Key features:
Resolve Lark Drive URLs or bare tokens with explicit type validation
Support optional fields and wiki perm_type request parameters
Preserve raw API response data while offering a concise pretty renderer
Add unit, dry-run E2E, live E2E, and lark-drive skill documentation
Related Issues
Summary by CodeRabbit
drive +member-listto list collaborators/authorized members for Drive documents, files, folders, and wiki nodes.--format pretty(human-readable) and JSON passthrough output.--fields(*or validated comma-separated selection) and wiki-only--perm-type.