Skip to content

feat(base): add markdown output for record reads#726

Merged
zgz2048 merged 5 commits into
mainfrom
codex/feat-record-read-sop
Apr 30, 2026
Merged

feat(base): add markdown output for record reads#726
zgz2048 merged 5 commits into
mainfrom
codex/feat-record-read-sop

Conversation

@zgz2048

@zgz2048 zgz2048 commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add markdown as the default output for Base record reads, so +record-list and +record-search render record matrix responses as compact tables with _record_id bound 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 json to get the raw JSON envelope.

Changes

  • Added markdown as the default output for +record-list and +record-search; callers can pass --format json to get the raw JSON envelope.
  • Markdown output renders record matrix responses as a compact table with _record_id metadata, result fields, and a trailing Meta: line for has_more, record scope, field scope, search scope, and ignored field count.
  • Inlined parameter-style skill content into CLI help for +record-get, +record-search, and +record-list, including minimum examples, JSON shape, JSON constraints, view_id scope semantics, field projection, and record read routing hints.
  • Added lark-base-record-read-sop.md as the unified SOP for +record-get, +record-search, and +record-list.
  • Documented record read routing: known record_id uses 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.
  • Added SOP guidance for field projection, field scope priority, temporary view preprocessing, pagination/range decisions, matrix result binding, and link field second-hop reads.
  • Removed single-method read skill docs for record-get, record-list, and record-search; updated the lark-base skill index and record index to point to the unified read SOP.
  • Preserved Base record shortcut flag order so required/core flags appear before optional/global flags in help output.
  • Added test coverage for markdown record rendering and record read help guidance.

Release note

Improved Base record-reading ergonomics for agent workflows.

+record-list and +record-search now 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

  • Unit tests pass: make unit-test
  • go vet ./...
  • gofmt -l . produced no output
  • go mod tidy && git diff --exit-code -- go.mod go.sum
  • Manual local verification confirms the commands render the expected help:
    • go run . base +record-list -h
    • go run . base +record-search -h
    • go run . base +record-get -h
  • Live local Base verification on a temporary table:
    • go run . base +record-list ... defaults to markdown
    • go run . base +record-list ... --format json returns raw JSON
    • go run . base +record-search ... defaults to markdown
    • go run . base +record-search ... --format json returns raw JSON
  • go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run --new-from-rev=origin/main
    • Fails on pre-existing issues outside this PR's files, including depguard violations in shortcuts/event, shortcuts/mail, shortcuts/sheets, and forbidigo violations in internal/keychain, shortcuts/mail, and shortcuts/minutes.

Related Issues

  • None

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

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown

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

Cohort / File(s) Summary
Tests
shortcuts/base/base_shortcuts_test.go, shortcuts/base/base_execute_test.go, shortcuts/base/record_markdown_test.go
Adds help/tips assertions for +record-list/+record-search/+record-get; updates execute tests to assert --format json usage and adds markdown-format test cases; unit-tests markdown rendering, escaping, and ignored-field truncation.
Flag-order helper
shortcuts/base/help.go
Adds preserveFlagOrder(cmd *cobra.Command) to disable Cobra's flag sorting for mounted commands.
Record-get shortcut
shortcuts/base/record_get.go
Adds Tips content and a PostMount hook calling preserveFlagOrder.
Record-list shortcut & helpers
shortcuts/base/record_list.go, shortcuts/base/...recordListFieldRefFlag, shortcuts/base/...recordListViewRefFlag
Moves flag construction to helpers, tightens --limit docs, adds `--format (json
Record-search shortcut
shortcuts/base/record_search.go
Documents richer --json contract, adds record-read --format flag, reorders validation to validate format before JSON, updates Tips/examples, and registers PostMount.
Markdown rendering & output routing
shortcuts/base/record_markdown.go, shortcuts/base/record_ops.go
New renderer validating --format (`json
Documentation reorg
skills/lark-base/SKILL.md, skills/lark-base/references/lark-base-record-read-sop.md, skills/lark-base/references/lark-base-record.md
Adds unified "record read SOP" and updates navigation/index entries to reference it for record-read guidance.
Removed docs
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
Removes three standalone record-read reference pages in favor of the unified SOP.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • kongenpei
  • zhouyue-bytedance
  • fangshuyu-768

Poem

🐰 I nudged the flags and kept them neat,
I stitched some tips and made the output sweet.
Markdown carrots in tidy rows,
Tests hopped by and cleaned my toes.
Hooray — the SOP shows where the garden grows.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 accurately and concisely describes the main change: adding markdown output for Base record reads, which is the central focus of this PR.
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.
Description check ✅ Passed The PR description is comprehensive and well-structured, covering all required template sections including Summary, Changes, Test Plan, and Related Issues.

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

✨ 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 codex/feat-record-read-sop

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

@codecov

codecov Bot commented Apr 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.25000% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.45%. Comparing base (0250054) to head (3c9b814).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/base/record_markdown.go 79.87% 29 Missing and 3 partials ⚠️
shortcuts/base/record_ops.go 66.66% 1 Missing and 1 partial ⚠️
shortcuts/base/record_search.go 60.00% 1 Missing and 1 partial ⚠️
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.
📢 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.

@github-actions

github-actions Bot commented Apr 30, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#codex/feat-record-read-sop -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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0250054 and 1944172.

📒 Files selected for processing (11)
  • shortcuts/base/base_shortcuts_test.go
  • shortcuts/base/help.go
  • shortcuts/base/record_get.go
  • shortcuts/base/record_list.go
  • shortcuts/base/record_search.go
  • skills/lark-base/SKILL.md
  • 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-read-sop.md
  • skills/lark-base/references/lark-base-record-search.md
  • skills/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

Comment thread shortcuts/base/base_shortcuts_test.go
@zgz2048
zgz2048 force-pushed the codex/feat-record-read-sop branch from 1944172 to 3c4e8a3 Compare April 30, 2026 05:35

@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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1944172 and 3c4e8a3.

📒 Files selected for processing (14)
  • shortcuts/base/base_execute_test.go
  • shortcuts/base/base_shortcuts_test.go
  • shortcuts/base/help.go
  • shortcuts/base/record_get.go
  • shortcuts/base/record_list.go
  • shortcuts/base/record_markdown.go
  • shortcuts/base/record_ops.go
  • shortcuts/base/record_search.go
  • skills/lark-base/SKILL.md
  • 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-read-sop.md
  • skills/lark-base/references/lark-base-record-search.md
  • skills/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

Comment thread shortcuts/base/record_markdown.go Outdated
@zgz2048
zgz2048 force-pushed the codex/feat-record-read-sop branch from 3c4e8a3 to 7622f7b Compare April 30, 2026 05:43
@zgz2048 zgz2048 changed the title feat(base): add record read SOP guidance feat(base): add markdown output for record reads Apr 30, 2026
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.
@zgz2048
zgz2048 force-pushed the codex/feat-record-read-sop branch from 7622f7b to 2a552a2 Compare April 30, 2026 06:16

@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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7622f7b and 2a552a2.

📒 Files selected for processing (15)
  • shortcuts/base/base_execute_test.go
  • shortcuts/base/base_shortcuts_test.go
  • shortcuts/base/help.go
  • shortcuts/base/record_get.go
  • shortcuts/base/record_list.go
  • shortcuts/base/record_markdown.go
  • shortcuts/base/record_markdown_test.go
  • shortcuts/base/record_ops.go
  • shortcuts/base/record_search.go
  • skills/lark-base/SKILL.md
  • 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-read-sop.md
  • skills/lark-base/references/lark-base-record-search.md
  • skills/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

Comment thread shortcuts/base/record_markdown.go
@zgz2048
zgz2048 merged commit 3ed691b into main Apr 30, 2026
22 checks passed
@zgz2048
zgz2048 deleted the codex/feat-record-read-sop branch April 30, 2026 09:09
HomyeeKing pushed a commit to HomyeeKing/cli that referenced this pull request May 6, 2026
* 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
tuxedomm pushed a commit to zhumiaoxin/cli that referenced this pull request Jun 6, 2026
* 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
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.

2 participants