feat: add drive version shortcut#841
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (12)
✅ Files skipped from review due to trivial changes (6)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughAdds four Drive CLI shortcuts: ChangesDrive Version Management Feature
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI User
participant Shortcut as Drive Shortcut
participant DriveAPI as Drive API
participant FileIO as File I/O
CLI->>Shortcut: invoke +version-history / +version-get / +version-revert / +version-delete
Shortcut->>DriveAPI: HTTP GET/POST to /open-apis/drive/v1/files/:file_token/...
DriveAPI-->>Shortcut: JSON response or stream (headers + body)
alt +version-get with --output
Shortcut->>FileIO: resolve path, enforce overwrite, save stream
FileIO-->>Shortcut: saved_path, size
else stdout mode
Shortcut-->>CLI: pretty JSON with content/file_name
end
Shortcut-->>CLI: JSON result (versions, has_more/next_cursor, or empty data)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsTimed out fetching pipeline failures after 30000ms Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/cli_e2e/drive/drive_version_workflow_test.go (1)
75-86: ⚡ Quick winStrengthen workflow assertion by validating returned history payload, not only success status.
Right now Line 84–85 only proves the command ran. Add assertions on
data.versions(e.g., non-empty, and ideally at least one expected version marker) so this test verifies actual version-history behavior.Example assertion enhancement
require.NoError(t, err) historyResult.AssertExitCode(t, 0) historyResult.AssertStdoutStatus(t, true) + require.GreaterOrEqual(t, len(gjson.Get(historyResult.Stdout, "data.versions").Array()), 1, "stdout:\n%s", historyResult.Stdout)As per coding guidelines, “Live E2E tests required for new flows or behavior changes must validate real API round-trips.”
🤖 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 `@tests/cli_e2e/drive/drive_version_workflow_test.go` around lines 75 - 86, The test currently only checks exit code and success status for the "+version-history" CLI call (historyResult from clie2e.RunCmd); enhance it to parse and validate the returned payload: unmarshal historyResult.Stdout (or the captured output) into a struct/map and assert that the "data.versions" field exists, is non-empty, and contains at least one expected version marker (e.g., a known version ID or timestamp). Update the test around historyResult.AssertStdoutStatus to decode the JSON response and add assertions on data.versions (referencing historyResult and clie2e.RunCmd) to ensure the workflow actually returns version history rather than just succeeding.
🤖 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 `@internal/core/types.go`:
- Around line 45-46: The default BrandFeishu Open and Accounts URLs were changed
to pre-prod hosts causing risky global behavior; revert the BrandFeishu default
Open and Accounts values back to the production endpoints and instead add an
explicit option for pre-prod (e.g., a new BrandFeishuPre constant or an
environment/flag check) so callers can opt into pre-prod. Locate the BrandFeishu
definition (symbols: BrandFeishu, Open, Accounts) in internal/core/types.go,
restore the prod URLs for Open and Accounts, and add a clear opt-in path (new
constant, factory function, or env-driven branch) that sets the pre-prod URLs
only when explicitly requested. Ensure unknown/unspecified brands continue to
use the safe prod defaults.
---
Nitpick comments:
In `@tests/cli_e2e/drive/drive_version_workflow_test.go`:
- Around line 75-86: The test currently only checks exit code and success status
for the "+version-history" CLI call (historyResult from clie2e.RunCmd); enhance
it to parse and validate the returned payload: unmarshal historyResult.Stdout
(or the captured output) into a struct/map and assert that the "data.versions"
field exists, is non-empty, and contains at least one expected version marker
(e.g., a known version ID or timestamp). Update the test around
historyResult.AssertStdoutStatus to decode the JSON response and add assertions
on data.versions (referencing historyResult and clie2e.RunCmd) to ensure the
workflow actually returns version history rather than just succeeding.
🪄 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: e0388c04-6384-48cd-af91-283dfc5f9373
📒 Files selected for processing (12)
internal/core/types.goshortcuts/drive/drive_version.goshortcuts/drive/drive_version_test.goshortcuts/drive/shortcuts.goshortcuts/drive/shortcuts_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-version-delete.mdskills/lark-drive/references/lark-drive-version-get.mdskills/lark-drive/references/lark-drive-version-history.mdskills/lark-drive/references/lark-drive-version-revert.mdtests/cli_e2e/drive/drive_version_dryrun_test.gotests/cli_e2e/drive/drive_version_workflow_test.go
| Open: "https://open.feishu-pre.cn", | ||
| Accounts: "https://accounts.feishu-pre.cn", |
There was a problem hiding this comment.
Default Feishu endpoint now points to pre-prod hosts, which is high-risk global behavior change.
Line 45 and Line 46 switch the default BrandFeishu Open/Accounts base URLs to *.feishu-pre.cn, while other services still use prod. Since unknown brands also fall back here, this can break normal auth/API flows outside test environments.
Suggested safer change
default:
return Endpoints{
- Open: "https://open.feishu-pre.cn",
- Accounts: "https://accounts.feishu-pre.cn",
+ Open: "https://open.feishu.cn",
+ Accounts: "https://accounts.feishu.cn",
MCP: "https://mcp.feishu.cn",
AppLink: "https://applink.feishu.cn",
}If pre endpoints are required, consider introducing an explicit brand/env switch instead of changing the default branch.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Open: "https://open.feishu-pre.cn", | |
| Accounts: "https://accounts.feishu-pre.cn", | |
| Open: "https://open.feishu.cn", | |
| Accounts: "https://accounts.feishu.cn", |
🤖 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 `@internal/core/types.go` around lines 45 - 46, The default BrandFeishu Open
and Accounts URLs were changed to pre-prod hosts causing risky global behavior;
revert the BrandFeishu default Open and Accounts values back to the production
endpoints and instead add an explicit option for pre-prod (e.g., a new
BrandFeishuPre constant or an environment/flag check) so callers can opt into
pre-prod. Locate the BrandFeishu definition (symbols: BrandFeishu, Open,
Accounts) in internal/core/types.go, restore the prod URLs for Open and
Accounts, and add a clear opt-in path (new constant, factory function, or
env-driven branch) that sets the pre-prod URLs only when explicitly requested.
Ensure unknown/unspecified brands continue to use the safe prod defaults.
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@cdd96f380e35c692958b1f90f1eb298b557df695🧩 Skill updatenpx skills add larksuite/cli#feat/drive-version-shortcuts -y -g |
0983192 to
b36b07c
Compare
Change-Id: I87bb32c86e3c3362f541ccc6320c656eb795ec9b
b36b07c to
cdd96f3
Compare
• ## Summary
Add Drive file version shortcuts so agents can list, download, revert, and delete historical file versions through shortcut UX instead of raw API calls. This PR also adds documentation and test coverage for the new workflow.
Changes
drive +version-history,drive +version-get,drive +version-revert, anddrive +version-deletelark-driveskill references for the new shortcutsTest Plan
go test ./shortcuts/drive -run TestDriveVersion -count=1)lark xxxcommand works as expectedRelated Issues
Summary by CodeRabbit
New Features
Documentation
Tests