feat(base): add markdown output for record reads#726
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds markdown output support for record-read commands, preserves Cobra flag order via a PostMount hook, enriches help/tips for record-read shortcuts, adds tests for help and markdown rendering, and consolidates record-read documentation into a unified SOP while deleting separate reference pages. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as "lark-cli (command)"
participant Cobra as "cobra.Command (mounted)"
participant API as "Base API"
participant Formatter as "Markdown Renderer / JSON Out"
User->>CLI: invoke `+record-list|+record-search|+record-get`
CLI->>Cobra: mount shortcut (+PostMount)
Cobra->>Cobra: preserveFlagOrder(cmd)
CLI->>CLI: validate format (json|markdown)
CLI->>API: execute request
API-->>CLI: response (record matrix + query_context)
CLI->>Formatter: if format=markdown -> outputRecordMarkdown(data)
Formatter-->>User: render markdown table + Meta/Ignored fields
alt format=json
CLI->>User: output JSON
end
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🔥 ProblemsGit: Failed to clone repository. Please run the 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 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #726 +/- ##
==========================================
+ Coverage 64.14% 64.45% +0.31%
==========================================
Files 505 514 +9
Lines 44338 45617 +1279
==========================================
+ Hits 28440 29404 +964
- Misses 13421 13635 +214
- Partials 2477 2578 +101 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@3c9b81460cf952da0235fba0e1fe0fb4cc04dce2🧩 Skill updatenpx skills add larksuite/cli#codex/feat-record-read-sop -y -g |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@shortcuts/base/base_shortcuts_test.go`:
- Around line 213-289: Update TestBaseRecordReadHelpGuidesAgents to explicitly
assert flag ordering: after calling help := cmd.Flags().FlagUsages(), add one or
more assertions that required/core flag help substrings appear before optional
flag substrings (e.g., assert strings.Index(help, "<required_flag_text>") <
strings.Index(help, "<optional_flag_text>")). Reference the test function
TestBaseRecordReadHelpGuidesAgents, the help variable from
cmd.Flags().FlagUsages(), and preserveFlagOrder behavior so the test fails if
FlagUsages() reorders required flags after optional ones.
🪄 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: d6b2960a-f454-472e-aca4-db298e958e7e
📒 Files selected for processing (11)
shortcuts/base/base_shortcuts_test.goshortcuts/base/help.goshortcuts/base/record_get.goshortcuts/base/record_list.goshortcuts/base/record_search.goskills/lark-base/SKILL.mdskills/lark-base/references/lark-base-record-get.mdskills/lark-base/references/lark-base-record-list.mdskills/lark-base/references/lark-base-record-read-sop.mdskills/lark-base/references/lark-base-record-search.mdskills/lark-base/references/lark-base-record.md
💤 Files with no reviewable changes (3)
- skills/lark-base/references/lark-base-record-search.md
- skills/lark-base/references/lark-base-record-get.md
- skills/lark-base/references/lark-base-record-list.md
1944172 to
3c4e8a3
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@shortcuts/base/record_markdown.go`:
- Around line 42-44: The current validation returns an error if recordIDs is
empty, causing valid empty search results to fail; update the condition so only
missing fields or a bad response (fields == 0 or !ok) produce
output.ErrValidation, i.e., remove the len(recordIDs) == 0 check and allow empty
recordIDs/data to proceed so the markdown path can render an empty table (ensure
downstream code that uses fields, recordIDs, and data tolerates empty slices).
Keep the existing error message via output.ErrValidation when fields are empty
or ok is false.
🪄 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: 3b48702c-1cdf-422f-b9b4-bff95087c290
📒 Files selected for processing (14)
shortcuts/base/base_execute_test.goshortcuts/base/base_shortcuts_test.goshortcuts/base/help.goshortcuts/base/record_get.goshortcuts/base/record_list.goshortcuts/base/record_markdown.goshortcuts/base/record_ops.goshortcuts/base/record_search.goskills/lark-base/SKILL.mdskills/lark-base/references/lark-base-record-get.mdskills/lark-base/references/lark-base-record-list.mdskills/lark-base/references/lark-base-record-read-sop.mdskills/lark-base/references/lark-base-record-search.mdskills/lark-base/references/lark-base-record.md
💤 Files with no reviewable changes (3)
- skills/lark-base/references/lark-base-record-get.md
- skills/lark-base/references/lark-base-record-search.md
- skills/lark-base/references/lark-base-record-list.md
🚧 Files skipped from review as they are similar to previous changes (4)
- shortcuts/base/help.go
- skills/lark-base/references/lark-base-record.md
- shortcuts/base/base_shortcuts_test.go
- shortcuts/base/record_list.go
3c4e8a3 to
7622f7b
Compare
1. Add a unified lark-base record read SOP for get/search/list routing, field projection, temporary view querying, pagination, matrix result binding, and link field reads. 2. Inline command-focused parameter guidance into +record-get, +record-search, and +record-list help, including examples, JSON shape, view scope, projection, and limit constraints. 3. Preserve base shortcut flag order in help output and add tests covering record read help guidance. 4. Remove the single-method record read skill references in favor of the unified SOP.
7622f7b to
2a552a2
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@shortcuts/base/record_markdown.go`:
- Line 40: The current code that builds recordIDs (recordIDs :=
stringSliceValue(data["record_id_list"])) later drops non-string entries (around
the block near Line 214), which shortens the slice and shifts indices causing
_record_id ↔ row misbinding; keep the original slice length by preserving index
alignment: when processing record_id_list (or inside stringSliceValue) do not
remove invalid/non-string entries but instead replace them with a placeholder
(e.g., empty string or explicit nil-equivalent) so the slice length and ordering
remain unchanged; update any downstream logic that assumes filtered-out entries
were removed to handle the placeholder values accordingly (references: recordIDs
variable, stringSliceValue function and the block around the filter at Lines
~52-57 and ~209-217).
🪄 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: 0cef6869-54bb-40ee-9b39-7fae03eb60f4
📒 Files selected for processing (15)
shortcuts/base/base_execute_test.goshortcuts/base/base_shortcuts_test.goshortcuts/base/help.goshortcuts/base/record_get.goshortcuts/base/record_list.goshortcuts/base/record_markdown.goshortcuts/base/record_markdown_test.goshortcuts/base/record_ops.goshortcuts/base/record_search.goskills/lark-base/SKILL.mdskills/lark-base/references/lark-base-record-get.mdskills/lark-base/references/lark-base-record-list.mdskills/lark-base/references/lark-base-record-read-sop.mdskills/lark-base/references/lark-base-record-search.mdskills/lark-base/references/lark-base-record.md
💤 Files with no reviewable changes (3)
- skills/lark-base/references/lark-base-record-get.md
- skills/lark-base/references/lark-base-record-list.md
- skills/lark-base/references/lark-base-record-search.md
🚧 Files skipped from review as they are similar to previous changes (4)
- skills/lark-base/references/lark-base-record.md
- shortcuts/base/base_shortcuts_test.go
- skills/lark-base/SKILL.md
- shortcuts/base/record_list.go
* feat(base): add record read SOP guidance 1. Add a unified lark-base record read SOP for get/search/list routing, field projection, temporary view querying, pagination, matrix result binding, and link field reads. 2. Inline command-focused parameter guidance into +record-get, +record-search, and +record-list help, including examples, JSON shape, view scope, projection, and limit constraints. 3. Preserve base shortcut flag order in help output and add tests covering record read help guidance. 4. Remove the single-method record read skill references in favor of the unified SOP. * test(base): remove stale record list fixture * fix(base): scan record markdown output * fix(base): fallback record markdown output * fix(base): unify base token wording in shortcuts and skills
* feat(base): add record read SOP guidance 1. Add a unified lark-base record read SOP for get/search/list routing, field projection, temporary view querying, pagination, matrix result binding, and link field reads. 2. Inline command-focused parameter guidance into +record-get, +record-search, and +record-list help, including examples, JSON shape, view scope, projection, and limit constraints. 3. Preserve base shortcut flag order in help output and add tests covering record read help guidance. 4. Remove the single-method record read skill references in favor of the unified SOP. * test(base): remove stale record list fixture * fix(base): scan record markdown output * fix(base): fallback record markdown output * fix(base): unify base token wording in shortcuts and skills
Summary
Add markdown as the default output for Base record reads, so
+record-listand+record-searchrender record matrix responses as compact tables with_record_idbound to each row. This directly reduces row/column mismatch risk for agents and makes complex Base data analysis cheaper in context tokens; callers can still pass--format jsonto get the raw JSON envelope.Changes
+record-listand+record-search; callers can pass--format jsonto get the raw JSON envelope._record_idmetadata, result fields, and a trailingMeta:line forhas_more, record scope, field scope, search scope, and ignored field count.+record-get,+record-search, and+record-list, including minimum examples, JSON shape, JSON constraints,view_idscope semantics, field projection, and record read routing hints.lark-base-record-read-sop.mdas the unified SOP for+record-get,+record-search, and+record-list.record_iduses get, keyword lookup uses search, normal detail reads use list, structured filter/sort/Top/Bottom N uses temporary view projection, and aggregate-only analysis routes to+data-query.record-get,record-list, andrecord-search; updated the lark-base skill index and record index to point to the unified read SOP.Release note
Improved Base record-reading ergonomics for agent workflows.
+record-listand+record-searchnow default to Markdown output, which makes tabular record results easier for agents to parse and reduces token usage compared with raw JSON. This release also adds a unified record-read SOP for filtered, sorted, and projection-based reads, improves CLI help examples and input guidance for record access, and aligns related Base token wording in shortcut help and skill documentation.Test Plan
make unit-testgo vet ./...gofmt -l .produced no outputgo mod tidy && git diff --exit-code -- go.mod go.sumgo run . base +record-list -hgo run . base +record-search -hgo run . base +record-get -hgo run . base +record-list ...defaults to markdowngo run . base +record-list ... --format jsonreturns raw JSONgo run . base +record-search ...defaults to markdowngo run . base +record-search ... --format jsonreturns raw JSONgo run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run --new-from-rev=origin/mainshortcuts/event,shortcuts/mail,shortcuts/sheets, and forbidigo violations ininternal/keychain,shortcuts/mail, andshortcuts/minutes.Related Issues