feat(drive): add drive preview and cover shortcuts and document quota details#1256
feat(drive): add drive preview and cover shortcuts and document quota details#1256zhoujunteng-max wants to merge 2 commits into
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR adds two new Drive shortcut commands— ChangesDrive Preview and Cover Commands
Sequence DiagramsequenceDiagram
participant User as User/CLI
participant Validator
participant DriveAPI as Drive API
participant FileSystem as File System
User->>Validator: drive +preview/+cover with flags
Validator->>Validator: validate file-token, mode, parameters
alt list-only mode
Validator-->>User: emit precomputed candidates/specs (no API call)
else download mode
Validator->>DriveAPI: fetch preview_result or download artifact
DriveAPI-->>Validator: candidate list or artifact stream
Validator->>Validator: select by type/spec, verify readiness
Validator->>FileSystem: resolve output path, infer extension
FileSystem->>FileSystem: handle --if-exists (error/overwrite/rename)
FileSystem-->>Validator: finalized path
Validator-->>User: return result with mode, selected type/spec, output
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 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 |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@a4af3a3a992b3b3717d74501e7a1b8ce31bb14d6🧩 Skill updatenpx skills add larksuite/cli#feat/drive-add-preview-cover-and-quota -y -g |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1256 +/- ##
==========================================
- Coverage 69.90% 69.75% -0.16%
==========================================
Files 645 669 +24
Lines 60233 64900 +4667
==========================================
+ Hits 42108 45268 +3160
- Misses 14823 15991 +1168
- Partials 3302 3641 +339 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tests/cli_e2e/drive/drive_preview_dryrun_test.go (1)
78-125: ⚡ Quick winAdd a dry-run E2E for
drive +cover --list-only.This file only exercises the cover download branch, but
shortcuts/drive/drive_cover.go:48-56has a separate--list-onlydry-run path with a different contract (mode=list, precomputedcandidates, and no API call). A regression there would currently ship untested.Based on learnings, "Dry-run E2E tests required for every shortcut change must validate request structure without calling real APIs and be placed in
tests/cli_e2e/dryrun/or domain directory, using--dry-runflag".🤖 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_preview_dryrun_test.go` around lines 78 - 125, Add a new dry-run E2E that covers the `--list-only` branch in the drive cover shortcut: create a test (e.g. TestDriveCoverDryRun_ListOnly) alongside TestDriveCoverDryRun_Download under tests/cli_e2e/dryrun or the drive domain tests that calls clie2e.RunCmd with the same args but include "--list-only" (and "--dry-run"), then assert there are no API calls (ensure api.0 does not exist), assert the dry-run payload contains "mode" == "list" and that precomputed "candidates" (and "selected_spec" if applicable) are present and correct; mirror existing use of gjson.Get checks from TestDriveCoverDryRun_Download to validate these fields rather than expecting a preview_download URL. Reference TestDriveCoverDryRun_Download, clie2e.RunCmd, and the drive_cover.go dry-run `--list-only` path (mode=list, candidates) when adding assertions.
🤖 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_preview_common.go`:
- Around line 620-634: The fallback mapping in drivePreviewFallbackExt
incorrectly returns ".png" for "jpg" and "jpg_lin"; update the switch in
drivePreviewFallbackExt to return ".jpg" for cases "jpg" and "jpg_lin" (while
keeping "png" and related cases returning ".png") so that
normalizeDrivePreviewRequest-driven preview types produce the correct fallback
extension used by DrivePreview.Execute and download paths.
In `@tests/cli_e2e/drive/drive_preview_workflow_test.go`:
- Around line 230-236: The test currently only inspects result.Stderr to detect
a missing bot scope and skip the test, but commands surface errors in the JSON
envelope on stdout; update the skip logic in the failing-path block that checks
result.ExitCode and result.Stderr to also inspect result.Stdout (lowercased) for
the same markers ("app scope not enabled", "space:folder:create",
"99991672")—e.g., build a combined lowercase string from result.Stdout and
result.Stderr or check both separately, and use that to decide t.Skipf so
missing-scope failures returned on stdout are correctly skipped; locate this
logic around the result variable in drive_preview_workflow_test.go.
---
Nitpick comments:
In `@tests/cli_e2e/drive/drive_preview_dryrun_test.go`:
- Around line 78-125: Add a new dry-run E2E that covers the `--list-only` branch
in the drive cover shortcut: create a test (e.g. TestDriveCoverDryRun_ListOnly)
alongside TestDriveCoverDryRun_Download under tests/cli_e2e/dryrun or the drive
domain tests that calls clie2e.RunCmd with the same args but include
"--list-only" (and "--dry-run"), then assert there are no API calls (ensure
api.0 does not exist), assert the dry-run payload contains "mode" == "list" and
that precomputed "candidates" (and "selected_spec" if applicable) are present
and correct; mirror existing use of gjson.Get checks from
TestDriveCoverDryRun_Download to validate these fields rather than expecting a
preview_download URL. Reference TestDriveCoverDryRun_Download, clie2e.RunCmd,
and the drive_cover.go dry-run `--list-only` path (mode=list, candidates) when
adding assertions.
🪄 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: 5933b3d6-ab48-4120-b96c-0abb0d9eabc6
📒 Files selected for processing (11)
shortcuts/drive/drive_cover.goshortcuts/drive/drive_preview.goshortcuts/drive/drive_preview_common.goshortcuts/drive/drive_preview_test.goshortcuts/drive/shortcuts.goshortcuts/drive/shortcuts_test.goskills/lark-drive/SKILL.mdskills/lark-drive/references/lark-drive-cover.mdskills/lark-drive/references/lark-drive-preview.mdtests/cli_e2e/drive/drive_preview_dryrun_test.gotests/cli_e2e/drive/drive_preview_workflow_test.go
- add `drive +preview` and `drive +cover` shortcuts - wrap `preview_result` output with stable preview item fields - support cover download via `preview_download` with validated preset mappings - update lark-drive skill references for preview and cover usage
e60c285 to
a4af3a3
Compare
Summary
This PR adds
drive +previewanddrive +covershortcuts for Drive file preview artifact and cover downloads, and updates thelark-driveskill metadata to expose quota detail capability and the new shortcuts to AI agents.Changes
drive +previewto list and download available preview artifactsdrive +coverto list and download built-in cover presetsskills/lark-drive/SKILL.mdand add preview/cover referencesquota_details.getinskills/lark-drive/SKILL.mdTest Plan
lark-cli drive +previewandlark-cli drive +covercommands work as expectedAdditional verification:
make unit-testgo test ./shortcuts/drive -run 'TestDrivePreview|TestDriveCover|TestShortcutsIncludesExpectedCommands'go test ./tests/cli_e2e/drive -run 'TestDrive(Preview|Cover)DryRun'go test ./tests/cli_e2e/drive -run 'TestDrive_PreviewAndCoverWorkflow'Related Issues
Summary by CodeRabbit
New Features
drive +previewto list/download Drive preview artifacts (list-only, type selection, versioning, output conflict policies, automatic extension inference).drive +coverto list/download stable cover presets (spec selection, list-only, versioning, conflict policies).Documentation
Tests