Skip to content

feat(drive): add +permission-get-setting shortcut - #1738

Merged
zhaojiaxing-coding merged 3 commits into
mainfrom
feat/drive-folder-permission-get
Jul 29, 2026
Merged

feat(drive): add +permission-get-setting shortcut#1738
zhaojiaxing-coding merged 3 commits into
mainfrom
feat/drive-folder-permission-get

Conversation

@zhaojiaxing-coding

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

Copy link
Copy Markdown
Collaborator

Add a Drive shortcut for reading a folder's own public permission settings through the v2 permission endpoint. This gives agents a typed, folder-specific path when raw permission.public get does not accept folder targets, without turning folder permission checks into recursive governance scans.

Key features:

  • Accept exactly one folder locator through --url or --folder-token and validate non-folder inputs before API calls

  • Return permission_public unchanged so callers can reason from server-provided fields

  • Register the shortcut and cover unit plus dry-run E2E behavior

  • Document when to use +folder-permission-get in lark-drive permission workflows

Summary

Changes

  • Change 1
  • Change 2

Test Plan

  • Unit tests pass
  • Manual local verification confirms the lark-cli <domain> <command> flow works as expected

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Added a new Drive command to view a file, folder, or document’s permission settings.
    • Supports both direct tokens and supported Drive URLs, with clear type handling for folder lookups.
  • Documentation

    • Updated Drive guidance and workflow docs to use the new permission-settings command and clarify folder-related usage.
  • Bug Fixes

    • Improved output consistency for permission details and kept permission-setting results in the final response.
  • Tests

    • Added coverage for command input handling, dry-run output, and end-to-end execution.

@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 3, 2026
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1252f8ba-1f02-4e93-8d9a-f54e193e0a1d

📥 Commits

Reviewing files that changed from the base of the PR and between 963d8b3 and 33d18f5.

📒 Files selected for processing (9)
  • shortcuts/drive/drive_permission_get_setting.go
  • shortcuts/drive/drive_permission_get_setting_test.go
  • shortcuts/drive/shortcuts.go
  • shortcuts/drive/shortcuts_test.go
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-workflow-permission-governance-commands.md
  • skills/lark-drive/references/lark-drive-workflow-permission-governance-outputs.md
  • skills/lark-drive/references/lark-drive-workflow-permission-governance.md
  • tests/cli_e2e/drive/drive_permission_get_setting_test.go

📝 Walkthrough

Walkthrough

This PR adds a new DrivePermissionGetSetting shortcut (drive +permission-get-setting) that queries a Drive file/folder/cloud-doc's own public permission settings via GET on the permissions API, supporting both URL and bare-token input with type inference/validation. It registers the shortcut, adds unit/e2e tests, and updates skill/workflow documentation to reference the new command instead of permission.public get.

Changes

Permission get setting shortcut

Layer / File(s) Summary
Shortcut implementation
shortcuts/drive/drive_permission_get_setting.go
Adds spec parsing, URL-to-type inference/validation, request path/params construction, output shaping (unwrapping permission_public), and the DrivePermissionGetSetting shortcut with Validate/DryRun/Execute.
Registration and tests
shortcuts/drive/shortcuts.go, shortcuts/drive/shortcuts_test.go, shortcuts/drive/drive_permission_get_setting_test.go, tests/cli_e2e/drive/drive_permission_get_setting_test.go
Registers the shortcut, updates the expected-commands test, and adds unit tests for spec resolution/validation/dry-run/execute/scopes plus e2e dry-run and workflow tests.
Skill and workflow docs
skills/lark-drive/SKILL.md, skills/lark-drive/references/lark-drive-workflow-permission-governance*.md
Documents the new shortcut in SKILL.md and updates permission-governance command map, discovery rules, and output templates to use +permission-get-setting instead of permission.public get, with terminology adjustments from "文档" to "目标".

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant DrivePermissionGetSetting
  participant readDrivePermissionGetSettingSpec
  participant OpenAPI

  User->>DrivePermissionGetSetting: run with --token or --url
  DrivePermissionGetSetting->>readDrivePermissionGetSettingSpec: parse and validate input
  readDrivePermissionGetSettingSpec-->>DrivePermissionGetSetting: Token/Type spec
  DrivePermissionGetSetting->>OpenAPI: GET permissions/{token}/public
  OpenAPI-->>DrivePermissionGetSetting: permission_public response
  DrivePermissionGetSetting-->>User: formatted output
Loading

Possibly related PRs

  • larksuite/cli#470: Both PRs update the shortcuts/drive/shortcuts.go registry (and its shortcuts_test.go) to include a new Drive shortcut entry.
  • larksuite/cli#692: Both PRs modify the shared drive shortcut registry and its expected-command test to include a new drive command.
  • larksuite/cli#1292: Introduces the permission_governance workflow docs that this PR updates to reference the new +permission-get-setting shortcut.

Suggested labels: documentation

Suggested reviewers: fangshuyu-768

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a useful overview, but the required template sections are left as placeholders and not filled in. Fill the Summary, Changes, Test Plan, and Related Issues sections with concrete PR details instead of template placeholders.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main addition: a new drive folder permission 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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/drive-folder-permission-get

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.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@8b50be52311a59878156ebd12ef3fc1665043e4f

🧩 Skill update

npx skills add larksuite/cli#feat/drive-folder-permission-get -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: 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_folder_permission_get.go`:
- Around line 21-64: The validation errors in readDriveFolderPermissionGetSpec
mix the failing input with recovery guidance in the message, which should be
moved to .WithHint(...). Update the checks around rawURL/rawToken, the
unsupported URL case, and the non-folder ref.Type branch so the error message
only states what failed and .WithHint(...) carries guidance like which flag to
pass or what folder URL format is accepted; keep the param on the actual failing
input such as --url or --folder-token.
- Around line 87-95: The driveFolderPermissionGetSpec.output method is falling
back to the entire data map when permission_public is missing, which reshapes
the output unexpectedly; update output to return only the nested
permission_public object (or an empty/absent value) instead of data, and keep
the behavior localized to driveFolderPermissionGetSpec.output and common.GetMap
handling. Add a test covering the missing permission_public case to verify the
response does not expose unrelated top-level fields.
🪄 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: 57f56f6c-bd78-4676-8c24-5648173b585e

📥 Commits

Reviewing files that changed from the base of the PR and between a1506cd and 963d8b3.

📒 Files selected for processing (9)
  • shortcuts/drive/drive_folder_permission_get.go
  • shortcuts/drive/drive_folder_permission_get_test.go
  • shortcuts/drive/shortcuts.go
  • shortcuts/drive/shortcuts_test.go
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-folder-permission-get.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_folder_permission_get_dryrun_test.go

Comment thread shortcuts/drive/drive_folder_permission_get.go Outdated
Comment thread shortcuts/drive/drive_folder_permission_get.go Outdated
@zhaojiaxing-coding
zhaojiaxing-coding deleted the feat/drive-folder-permission-get branch July 7, 2026 03:37
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.00000% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.19%. Comparing base (c7adff7) to head (8b50be5).

Files with missing lines Patch % Lines
shortcuts/drive/drive_permission_get_setting.go 83.87% 12 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1738      +/-   ##
==========================================
+ Coverage   75.18%   75.19%   +0.01%     
==========================================
  Files         913      914       +1     
  Lines       96656    96781     +125     
==========================================
+ Hits        72671    72776     +105     
- Misses      18395    18407      +12     
- Partials     5590     5598       +8     

☔ 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.

@zhaojiaxing-coding
zhaojiaxing-coding restored the feat/drive-folder-permission-get branch July 27, 2026 07:32
@zhaojiaxing-coding
zhaojiaxing-coding force-pushed the feat/drive-folder-permission-get branch 2 times, most recently from 6af0efc to d7b3445 Compare July 27, 2026 11:34
@zhaojiaxing-coding zhaojiaxing-coding changed the title feat(drive): add +folder-permission-get shortcut feat(drive): add +permission-get-setting shortcut Jul 27, 2026
@zhaojiaxing-coding
zhaojiaxing-coding force-pushed the feat/drive-folder-permission-get branch 2 times, most recently from bf93327 to ec73d34 Compare July 29, 2026 02:26
Comment thread skills/lark-drive/SKILL.md
Comment thread shortcuts/drive/drive_permission_get_setting.go Outdated
Comment thread tests/cli_e2e/drive/drive_permission_get_setting_test.go Outdated
Comment thread shortcuts/drive/drive_permission_get_setting.go
Comment thread shortcuts/drive/drive_permission_get_setting.go
Comment thread shortcuts/drive/drive_permission_get_setting.go Outdated
Add a Drive shortcut for reading public permission settings across supported documents, files, folders, and wiki nodes. Resolve URLs into typed resources, preserve permission_public output for machine consumers, and document the shortcut in the permission-governance workflow.

Key features:

- Infer resource type and token from supported Drive URLs while requiring --type for bare tokens

- Query the Drive v2 public permission endpoint with typed validation and user or bot identity

- Support folder permission inspection without recursing into child resources

- Add unit, dry-run E2E, live workflow, output, and skill guidance coverage
Harden +permission-get-setting after review findings so callers receive only the documented permission payload and folder support is verified against the live workflow. This prevents malformed responses from being presented as permission settings and keeps the command guidance aligned with the shortcut contract.

Key fixes:
- Reject responses without data.permission_public instead of projecting arbitrary payload fields
- Render complete permission settings in pretty output and mark --token required
- Exercise a created Drive folder in the live workflow and add the command reference
- Correct folder resolution guidance while retaining the shortcut's documented URL forms
@zhaojiaxing-coding
zhaojiaxing-coding force-pushed the feat/drive-folder-permission-get branch from 19557f0 to 8b50be5 Compare July 29, 2026 09:16
@zhaojiaxing-coding
zhaojiaxing-coding merged commit 7988515 into main Jul 29, 2026
28 checks passed
@zhaojiaxing-coding
zhaojiaxing-coding deleted the feat/drive-folder-permission-get branch July 29, 2026 09:57
@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.

3 participants