Skip to content

feat(drive): add +member-list shortcut - #1795

Merged
zhaojiaxing-coding merged 2 commits into
mainfrom
feat/drive-member-list
Jul 29, 2026
Merged

feat(drive): add +member-list shortcut#1795
zhaojiaxing-coding merged 2 commits into
mainfrom
feat/drive-member-list

Conversation

@zhaojiaxing-coding

@zhaojiaxing-coding zhaojiaxing-coding commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

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

  • None

Summary by CodeRabbit

  • New Features
    • Added drive +member-list to list collaborators/authorized members for Drive documents, files, folders, and wiki nodes.
    • Supports --format pretty (human-readable) and JSON passthrough output.
    • Added --fields (* or validated comma-separated selection) and wiki-only --perm-type.
  • Bug Fixes
    • Improved target input handling for bare tokens vs Drive URLs, with conflict-checked type validation.
  • Documentation
    • Updated Drive skill listings and added command reference and workflow guidance.
  • Tests
    • Added unit and end-to-end coverage for validation, dry-run request parameters, and output formatting.

@github-actions github-actions Bot added domain/ccm PR touches the ccm domain size/L Large or sensitive change across domains or core paths labels Jul 8, 2026
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new Drive shortcut, +member-list, that resolves Drive resource targets, fetches member permissions, formats results, registers the shortcut, and updates unit, e2e, and documentation coverage.

Changes

Drive +member-list Shortcut

Layer / File(s) Summary
Spec types, constants, and target resolution
shortcuts/drive/drive_member_list.go
Defines resource types, allowed fields, permission scope constants, URL prefix mapping, and target/token resolution including URL parsing.
Fields and perm-type normalization
shortcuts/drive/drive_member_list.go
Validates and normalizes --fields and --perm-type, including * handling, deduplication, and wiki-only restriction.
Request building and shortcut execution
shortcuts/drive/drive_member_list.go
Builds the API path and query parameters, defines DriveMemberList, and renders raw or pretty member output.
Shortcut registration
shortcuts/drive/shortcuts.go, shortcuts/drive/shortcuts_test.go
Registers DriveMemberList in the drive shortcuts list and updates the expected command test.
Unit tests for shortcut behavior
shortcuts/drive/drive_member_list_test.go
Covers target resolution, typed validation errors, param generation, dry-run requests, raw data preservation, scopes/identities, and pretty output.
E2E CLI tests
tests/cli_e2e/drive/drive_member_list_test.go
Adds dry-run payload assertions and a real workflow test with skip/error handling.
Skill and workflow documentation
skills/lark-drive/SKILL.md, skills/lark-drive/references/lark-drive-member-list.md, skills/lark-drive/references/lark-drive-workflow-permission-governance*.md
Adds a new reference doc and updates SKILL.md and permission-governance workflow docs to reference +member-list.

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
Loading

Possibly related PRs

  • larksuite/cli#432: Both PRs modify shortcuts/drive/shortcuts.go’s Shortcuts() registry to add a new drive subcommand.
  • larksuite/cli#985: Both PRs add new Drive CLI shortcuts and update the same command registry and its expectation test.

Suggested reviewers: fangshuyu-768, wittam-01

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately describes the main change: adding the Drive +member-list shortcut.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/drive-member-list

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.08287% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.18%. Comparing base (b0b1ca4) to head (81d4cc6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/drive/drive_member_list.go 85.00% 14 Missing and 13 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@81d4cc6d4b85dfbf3a686a8f6c41464a4c2396e0

🧩 Skill update

npx skills add larksuite/cli#feat/drive-member-list -y -g

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
skills/lark-drive/SKILL.md (1)

153-153: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Clarify the shortcut’s scope.
The implementation and workflow docs limit +member-list to 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 value

Consider using errors.As instead of direct type assertion for *errs.ValidationError.

The direct type assertion err.(*errs.ValidationError) works because validation errors are returned unwrapped, but errors.As is more robust against future wrapping and aligns with the established pattern. Based on learnings, errors.As(err, &ve) is the recommended approach for reading ve.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

📥 Commits

Reviewing files that changed from the base of the PR and between 1a9f637 and e36a8f3.

📒 Files selected for processing (9)
  • shortcuts/drive/drive_member_list.go
  • shortcuts/drive/drive_member_list_test.go
  • shortcuts/drive/shortcuts.go
  • shortcuts/drive/shortcuts_test.go
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-member-list.md
  • skills/lark-drive/references/lark-drive-workflow-permission-governance-commands.md
  • skills/lark-drive/references/lark-drive-workflow-permission-governance.md
  • tests/cli_e2e/drive/drive_member_list_test.go

Comment thread shortcuts/drive/drive_member_list.go
Comment thread skills/lark-drive/references/lark-drive-member-list.md Outdated
Comment thread skills/lark-drive/references/lark-drive-member-list.md Outdated
@github-actions github-actions Bot added domain/base PR touches the base domain domain/contact PR touches the contact domain domain/mail PR touches the mail domain domain/vc PR touches the vc domain size/XL Architecture-level or global-impact change and removed size/L Large or sensitive change across domains or core paths labels Jul 9, 2026
@github-actions github-actions Bot added size/L Large or sensitive change across domains or core paths and removed domain/base PR touches the base domain domain/contact PR touches the contact domain domain/mail PR touches the mail domain domain/vc PR touches the vc domain size/XL Architecture-level or global-impact change labels Jul 9, 2026
@zhaojiaxing-coding
zhaojiaxing-coding force-pushed the feat/drive-member-list branch 3 times, most recently from 70f1bbb to 259cdd8 Compare July 9, 2026 11:36
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
Comment thread skills/lark-drive/references/lark-drive-member-list.md
Comment thread shortcuts/drive/drive_member_list.go
Comment thread skills/lark-drive/references/lark-drive-member-list.md
@zhaojiaxing-coding
zhaojiaxing-coding merged commit c7adff7 into main Jul 29, 2026
28 checks passed
@zhaojiaxing-coding
zhaojiaxing-coding deleted the feat/drive-member-list branch July 29, 2026 09:05
@liangshuo-1 liangshuo-1 mentioned this pull request Jul 29, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/ccm PR touches the ccm domain size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants