Skip to content

feat(base): add base block shortcuts#1044

Open
zgz2048 wants to merge 7 commits into
larksuite:mainfrom
zgz2048:codex/base-block-shortcuts
Open

feat(base): add base block shortcuts#1044
zgz2048 wants to merge 7 commits into
larksuite:mainfrom
zgz2048:codex/base-block-shortcuts

Conversation

@zgz2048
Copy link
Copy Markdown
Collaborator

@zgz2048 zgz2048 commented May 22, 2026

Summary

Add Base container block shortcuts for listing, creating, moving, renaming, and deleting folder/table/docx/dashboard/workflow entries.

Changes

  • Add base +base-block-list/create/move/rename/delete shortcuts backed by Base v3 /blocks APIs.
  • Keep CLI list simple: no exposed limit/offset; omitted --parent-id means root for create/move and all blocks for list.
  • Add lark-base skill references to distinguish Base container blocks from dashboard chart/widget blocks.
  • Add shortcut unit coverage and CLI dry-run e2e request-shape coverage.

Test Plan

  • git diff --check
  • go test ./shortcuts/...
  • go test ./tests/cli_e2e/base -run 'TestBaseBlockDryRun|TestBase_AttachmentDryRun|TestBaseFormDetailDryRun' -count=1
  • Manual local verification confirms lark-cli base +base-block-list --help exposes the new command.

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Added five CLI commands to list, create, move, rename, and delete Base blocks, with parent-folder filtering, reorder options (before/after), and dry-run request previews.
  • Documentation

    • Added user guide for base-block commands covering semantics (parent-id behavior, non-paginated list, move constraints, non-recursive deletion) and distinction from dashboard blocks.
  • Tests

    • Added unit and end-to-end dry-run tests covering list/create/move/rename/delete flows and request output validation.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

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 five new CLI commands for base block container management (list, create, move, rename, delete) with shared operations for dry-run preview and API execution. Includes unit and e2e tests, catalog registration, and user documentation.

Changes

Base Block CLI Commands

Layer / File(s) Summary
Command definitions, operations, and registration
shortcuts/base/base_block_ops.go, shortcuts/base/base_block_*.go (create/delete/list/move/rename), shortcuts/base/shortcuts.go
Five shortcut commands for +base-block-list, +base-block-create, +base-block-move, +base-block-rename, and +base-block-delete. Shared operations module defines dry-run builders for HTTP request preview, validation for required/mutually exclusive flags, and execution handlers that call Base V3 API endpoints and return JSON success structures. Shortcuts are registered in the catalog.
Unit testing for validation and catalog
shortcuts/base/base_dryrun_ops_test.go, shortcuts/base/base_shortcuts_test.go, shortcuts/base/base_execute_test.go
Tests verify dry-run output formatting for all operations, catalog membership, high-risk-write marking for delete, and validation rules (mutually exclusive before/after flags in move, non-blank name in create/rename). Execution tests mock HTTP endpoints and validate request payloads and CLI output.
End-to-end testing and coverage
tests/cli_e2e/base/base_block_dryrun_test.go, tests/cli_e2e/base/coverage.md
E2E subtests invoke CLI with --dry-run and assert generated request URLs, HTTP methods, and JSON body fields for each operation. Coverage metrics updated to reflect new commands.
User documentation
skills/lark-base/SKILL.md, skills/lark-base/references/lark-base-base-block.md
Skill guide adds Base Block module section in module map and inserts new section with command table distinguishing base-block-* from dashboard-block-*. Reference doc provides usage, parameters, constraints on non-paginated listing and non-recursive folder deletion, and guidance on follow-up docx/dashboard/workflow creation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • larksuite/cli#328: Both PRs extend the Base CLI shortcut catalog by modifying shortcuts/base/shortcuts.go’s Shortcuts() list, but they add different commands (+base-block-* vs +record-search).

Suggested labels

size/M

Suggested reviewers

  • kongenpei
  • zhouyue-bytedance

Poem

🐰 Five blocks hop into the CLI light,
List and create by day and night,
Move and rename with careful pace,
Delete when tidied from their place,
Dry-run shows the trail—what a sight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.23% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding base block shortcuts.
Description check ✅ Passed The description covers all required template sections: Summary, Changes, Test Plan, and Related Issues are all present and complete.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions github-actions Bot added domain/base PR touches the base domain size/L Large or sensitive change across domains or core paths labels May 22, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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 (1)
tests/cli_e2e/base/base_block_dryrun_test.go (1)

52-53: ⚡ Quick win

Assert HTTP method in every request-shape subtest.

Line 52 and Line 112 currently assert URL/body but skip method; this leaves a request-contract gap in dry-run coverage for list folder and move after.

Proposed diff
@@
 		out := result.Stdout
 		require.Equal(t, "/open-apis/base/v3/bases/app_x/blocks/list", gjson.Get(out, "api.0.url").String(), out)
+		require.Equal(t, "POST", gjson.Get(out, "api.0.method").String(), out)
 		require.Equal(t, "blk_folder", gjson.Get(out, "api.0.body.parent_id").String(), out)
@@
 		out := result.Stdout
 		require.Equal(t, "/open-apis/base/v3/bases/app_x/blocks/blk_a/move", gjson.Get(out, "api.0.url").String(), out)
+		require.Equal(t, "POST", gjson.Get(out, "api.0.method").String(), out)
 		require.Equal(t, "blk_folder", gjson.Get(out, "api.0.body.parent_id").String(), out)
 		require.Equal(t, "blk_b", gjson.Get(out, "api.0.body.after_id").String(), out)

Also applies to: 112-114

🤖 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/base/base_block_dryrun_test.go` around lines 52 - 53, Add
assertions that verify the HTTP method in each request-shape subtest by checking
gjson.Get(out, "api.<index>.method").String() with require.Equal so the dry-run
covers request method as well as URL/body; specifically, in the "list folder"
subtest (where you already assert "/open-apis/base/v3/bases/app_x/blocks/list"
and parent_id "blk_folder") add require.Equal(t, "GET", gjson.Get(out,
"api.0.method").String(), out), and in the "move after" subtest (the assertions
around lines 112-114) add the corresponding require.Equal for the expected
method (e.g., "POST") using the correct api index (e.g., "api.0.method") to
ensure method is asserted.
🤖 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 `@tests/cli_e2e/base/coverage.md`:
- Around line 4-6: The coverage numbers in the file use stale metrics: update
the “Covered” and “Coverage” lines in coverage.md to match the table (change the
“Covered: 15” entry to “Covered: 18” and update “Coverage: 19.2%” to the correct
percentage “Coverage: 23.1%”); ensure you only edit the lines containing the
text tokens “Denominator:”, “Covered:”, and “Coverage:” so they reflect the
current table values.

---

Nitpick comments:
In `@tests/cli_e2e/base/base_block_dryrun_test.go`:
- Around line 52-53: Add assertions that verify the HTTP method in each
request-shape subtest by checking gjson.Get(out, "api.<index>.method").String()
with require.Equal so the dry-run covers request method as well as URL/body;
specifically, in the "list folder" subtest (where you already assert
"/open-apis/base/v3/bases/app_x/blocks/list" and parent_id "blk_folder") add
require.Equal(t, "GET", gjson.Get(out, "api.0.method").String(), out), and in
the "move after" subtest (the assertions around lines 112-114) add the
corresponding require.Equal for the expected method (e.g., "POST") using the
correct api index (e.g., "api.0.method") to ensure method is asserted.
🪄 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: 7792882d-d7db-4d40-8897-ffea9d065319

📥 Commits

Reviewing files that changed from the base of the PR and between 5c01a7f and 85f8fda.

📒 Files selected for processing (18)
  • shortcuts/base/base_block_create.go
  • shortcuts/base/base_block_delete.go
  • shortcuts/base/base_block_list.go
  • shortcuts/base/base_block_move.go
  • shortcuts/base/base_block_ops.go
  • shortcuts/base/base_block_rename.go
  • shortcuts/base/base_dryrun_ops_test.go
  • shortcuts/base/base_shortcuts_test.go
  • shortcuts/base/shortcuts.go
  • skills/lark-base/SKILL.md
  • skills/lark-base/references/lark-base-base-block-create.md
  • skills/lark-base/references/lark-base-base-block-delete.md
  • skills/lark-base/references/lark-base-base-block-list.md
  • skills/lark-base/references/lark-base-base-block-move.md
  • skills/lark-base/references/lark-base-base-block-rename.md
  • skills/lark-base/references/lark-base-base-block.md
  • tests/cli_e2e/base/base_block_dryrun_test.go
  • tests/cli_e2e/base/coverage.md

Comment thread tests/cli_e2e/base/coverage.md Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 22, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add zgz2048/cli#codex/base-block-shortcuts -y -g

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 87.14286% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.81%. Comparing base (5c01a7f) to head (e4b8447).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/base/base_block_ops.go 83.78% 9 Missing and 9 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1044      +/-   ##
==========================================
+ Coverage   67.77%   67.81%   +0.03%     
==========================================
  Files         590      596       +6     
  Lines       55194    55334     +140     
==========================================
+ Hits        37406    37522     +116     
- Misses      14677    14691      +14     
- Partials     3111     3121      +10     

☔ View full report in Codecov by Sentry.
📢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/base PR touches the base 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.

1 participant