docs: trim lark-im skill doc token cost (~40% across 3 files)#1554
docs: trim lark-im skill doc token cost (~40% across 3 files)#1554zhangheng023 wants to merge 1 commit into
Conversation
Reduce the lark-im skill doc surface by ~4455 tiktoken (cl100k) tokens across three files, with no capability or guardrail removed: - SKILL.md: fold the per-method API Resources identity index and the full permission-scope table into a short Native-API schema pointer (resident 4960->2986 tok, -40%, loaded every invocation); migrate the reactions and feed-groups entry points into the Shortcuts table so those references stay runtime-discoverable. - references/lark-im-messages-send.md: consolidate the content-flag selection rule (previously repeated 4x) into one table; compress the all-media-form Commands enumeration and the --help-mirroring Parameters/Notes into pointers (3869->1799 tok, -53%). - references/lark-im-chat-create.md: dedup the Commands<->Usage Scenarios overlap; compress the --help-mirroring Common Errors into pointers (2125->1714 tok, -19%). Removed content is runtime-recoverable (schema / --help / deterministic CLI validation errors). All routing, identity/scope mapping, flag mutual-exclusivity rules, safety constraints, and GOTCHA lines preserved. Validated via the opt-workflow eval harness: each change passed an independent adversarial review (no semantic regression, no reward-hacking) and the combined result passed a K=5 sealed evaluation with the effect guard not regressing.
📝 WalkthroughWalkthroughThree documentation files in the ChangesLark IM Documentation Revisions
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
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 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1554 +/- ##
==========================================
+ Coverage 73.97% 74.03% +0.06%
==========================================
Files 787 787
Lines 76293 76328 +35
==========================================
+ Hits 56436 56509 +73
+ Misses 15625 15572 -53
- Partials 4232 4247 +15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@bffdd6fdd0c22dc83e03b5a70367a4002e77247f🧩 Skill updatenpx skills add larksuite/cli#docs/opt-lark-im-token-trim -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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@skills/lark-im/SKILL.md`:
- Around line 113-114: The entries for `reactions.*` and `feed.groups.*` are
currently placed in the Shortcuts section (lines 113-114) but they use raw API
pattern with dot notation rather than shortcut wrappers with the plus prefix.
Move both of these entries from their current location in the Shortcuts table to
the "Native API (beyond shortcuts)" section (lines 116-125) where they belong
alongside other raw API entries like `chats.*` and `chat.members.*`, so users
correctly understand they require the schema-first pattern and are not
high-level shortcut abstractions.
🪄 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: 857ed24e-0525-4e18-9e31-46a88ddd863e
📒 Files selected for processing (3)
skills/lark-im/SKILL.mdskills/lark-im/references/lark-im-chat-create.mdskills/lark-im/references/lark-im-messages-send.md
| | `reactions.*` (add / delete / list / batch_query) | Add, remove, or read emoji reactions on a message; user/bot; caller must be in the conversation, and can only delete its own reactions. Read first: [`lark-im-reactions.md`](references/lark-im-reactions.md) | | ||
| | `feed.groups.*` (create / update / delete / batch_query / batch_add_item / batch_remove_item) | Manage feed groups (tags) and their member cards; user-only. Read first: [`lark-im-feed-groups.md`](references/lark-im-feed-groups.md) | |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check whether reactions.* and feed.groups.* have registered shortcut wrappers (+ prefix) or are native API only
ast-grep outline skills/lark-im/ --match reactions --view expanded | head -20
rg -n 'reactions-add|feed-groups-create' skills/lark-im/references/ || echo "No +reactions-* or +feed-groups-* shortcuts found"
rg -n 'Add, remove, or read emoji reactions' skills/lark-im/references/Repository: larksuite/cli
Length of output: 215
🏁 Script executed:
#!/bin/bash
# Read the SKILL.md file around the contested lines to see the table structure
cat -n skills/lark-im/SKILL.md | sed -n '100,135p'Repository: larksuite/cli
Length of output: 4650
🏁 Script executed:
#!/bin/bash
# Search for how shortcuts are defined elsewhere in the file (look for + prefix patterns)
rg -n '\+[a-z\-]+' skills/lark-im/SKILL.md | head -20Repository: larksuite/cli
Length of output: 5816
🏁 Script executed:
#!/bin/bash
# Check the references directory structure to understand what docs exist
ls -la skills/lark-im/references/Repository: larksuite/cli
Length of output: 2113
Move reactions.* and feed.groups.* from Shortcuts to Native API section — they use raw API pattern, not shortcut wrappers.
All other entries in the Shortcuts table (lines 100–112) use the + prefix (e.g., +messages-send, +flag-create) indicating shortcut wrappers. Lines 113–114 use dot notation (reactions.*, feed.groups.*) matching the raw native API pattern (lark-cli schema im.<resource>.<method> then lark-cli im <resource> <method>). These do not have corresponding shortcut wrappers (no +reactions-* or +feed-groups-* commands exist), and placing them in a table introduced as high-level abstractions is misleading.
Move both entries into the "Native API (beyond shortcuts)" section (lines 116–125) as examples alongside chats.*, chat.members.*, etc., so users understand they require the schema-first pattern.
🤖 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 `@skills/lark-im/SKILL.md` around lines 113 - 114, The entries for
`reactions.*` and `feed.groups.*` are currently placed in the Shortcuts section
(lines 113-114) but they use raw API pattern with dot notation rather than
shortcut wrappers with the plus prefix. Move both of these entries from their
current location in the Shortcuts table to the "Native API (beyond shortcuts)"
section (lines 116-125) where they belong alongside other raw API entries like
`chats.*` and `chat.members.*`, so users correctly understand they require the
schema-first pattern and are not high-level shortcut abstractions.
Summary
The lark-im skill docs carried a large amount of runtime-recoverable and repeated content that inflated the agent's context cost on every invocation. This PR trims the lark-im doc surface by ~4455 tiktoken (cl100k) tokens — about 40% across three files — without removing any capability or guardrail. The change was driven and validated by the opt-workflow eval harness.
Changes
skills/lark-im/SKILL.md: fold the per-methodAPI Resourcesidentity index and the full permission-scope table into a short Native-API schema pointer (resident 4960 -> 2986 tok, -40%, loaded on every invocation); migrate thereactionsandfeed-groupsentry points into the Shortcuts table so those references stay runtime-discoverable.skills/lark-im/references/lark-im-messages-send.md: consolidate the content-flag selection rule (previously repeated across 4 sections) into one table; compress the all-media-form Commands enumeration and the--help-mirroring Parameters/Notes into pointers (3869 -> 1799 tok, -53%).skills/lark-im/references/lark-im-chat-create.md: dedup the Commands <-> Usage Scenarios overlap; compress the--help-mirroring Common Errors into pointers (2125 -> 1714 tok, -19%).Removed content is runtime-recoverable (schema /
--help/ deterministic CLI validation errors). All routing, identity/scope mapping, flag mutual-exclusivity rules, safety constraints, and GOTCHA lines were preserved (grep-confirmed).Test Plan
make unit-test— docs-only change, no Go code touchedRelated Issues
N/A
Summary by CodeRabbit