Skip to content

docs(lark-shared): split SKILL.md into a slim core plus references - #2226

Open
leave330 wants to merge 11 commits into
mainfrom
docs/lark-shared-slim
Open

docs(lark-shared): split SKILL.md into a slim core plus references#2226
leave330 wants to merge 11 commits into
mainfrom
docs/lark-shared-slim

Conversation

@leave330

@leave330 leave330 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

lark-shared carries the cross-cutting rules every other lark-* skill depends on, and nearly all of them force-load it — 26 skills reference it from 190 places. That means its whole body is paid on almost every task. At 211 lines / ~3.6k tokens it was well past the 2k-token guidance for a skill body, and most of that weight was mechanics an agent only needs occasionally.

This restructures the monolith into a slim always-loaded core plus references/ that are read on demand. The body drops to 48 lines / ~1.3k tokens (-64%), and the mechanics stay one hop away.

The body keeps two kinds of content. Resident rules cover what fails silently if unknown: identity semantics (including that a bot reading user resources returns an empty success rather than an error), the ok == true success contract, QR forwarding for authorization URLs, write/delete intent confirmation, and the exit-10 approval gate. A trigger index then routes to the references: each row names the observable conditions — a field in an error envelope, an exit code, a command about to be run — under which the agent must read the corresponding reference before acting, so loading is driven by explicit triggers rather than a judgment call.

Changes

  • skills/lark-shared/SKILL.md — restructured into resident rules, security rules, and a trigger-indexed reference table. 211 → 48 lines.
  • New references, content largely carried over from the original body:
    • lark-shared-identity-and-permissions.md — identity model, grant layers, permission recovery, the auth quick reference, and the agent-initiated (split-flow) authorization steps
    • lark-shared-high-risk-approval.md — exit-10 envelope, field positions, risk prediction
    • lark-shared-output-contract.md — success/error envelope shapes
    • lark-shared-update-notice.md_notice handling
    • lark-shared-config-init.md — first-run configuration
  • Wording corrections where the old text had drifted from the implementation: the exit-10 recovery flag is read from hint rather than assumed to be --yes; --dry-run is suggested only where the target command supports it; --recommend is listed as a third way to scope auth login; and the credential-reuse ban is scoped to reuse across flows, so it no longer contradicts the split-flow steps it accompanies.
  • version 1.0.0 → 1.1.0. name and description are unchanged, so skill triggering is unaffected.

Test Plan

  • Behavioral evaluation of the restructured skill against the previous monolith. Three questions, three answers: rules relocated to references are still read when their triggers fire; task outcomes show no systematic regression versus the always-loaded body; and the net context cost is lower, so the split pays for itself.
  • make build / make quality-gate / make unit-test — all pass. quality-gate is the meaningful automated gate here: it harvests lark-cli ... examples from the changed markdown and validates them against the command index.
  • ./lark-cli skills read lark-shared — serves the rebuilt embedded tree and reports version: 1.1.0, confirming the change is live through the skills embed; each reference is readable through the built binary.
  • Link check — every references/*.md target linked from the body resolves; no dead links.
  • Coverage walk — every rule in the previous body was traced to the resident core or a reference the body routes to, so nothing was dropped silently. This mattered more than the token number: dropping a load-bearing rule would not fail any build; it would just make agents quietly behave worse across all 26 dependent skills.

Not covered: there is no automated assertion that a given guardrail stays in the body, so a future slimming pass could weaken one without anything failing. A lightweight keyword assertion would close that gap and is worth adding separately.

Also unchanged on purpose: the path rule still states that path arguments accept cwd-relative paths only. That is not accurate for every command — some accept absolute paths — and is tracked as a follow-up.

Related Issues

None.

@leave330 leave330 added the documentation Improvements or additions to documentation label Aug 7, 2026
@github-actions github-actions Bot added the size/L Large or sensitive change across domains or core paths label Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

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

lark-shared 更新至 1.1.0,并新增共享 CLI 准则、安全规则,以及配置初始化、认证权限、JSON 输出、更新通知和高风险操作参考文档。

Changes

共享 CLI 使用规则

Layer / File(s) Summary
共享准则与场景索引
skills/lark-shared/SKILL.md
更新技能版本并声明 lark-cli 依赖。新增身份选择、JSON 成功判断、非阻塞认证、安全确认、相对路径和场景路由规则。
配置、认证与权限流程
skills/lark-shared/references/lark-shared-config-init.md, skills/lark-shared/references/lark-shared-auth-split-flow.md, skills/lark-shared/references/lark-shared-identity-and-permissions.md
新增首次配置、二维码展示、split-flow 授权、device_code 轮询,以及 user/bot 身份和权限不足处理规范。
输出契约、通知与高风险操作
skills/lark-shared/references/lark-shared-output-contract.md, skills/lark-shared/references/lark-shared-update-notice.md, skills/lark-shared/references/lark-shared-high-risk-approval.md
新增 JSON 成功与错误 envelope、_notice 处理、更新命令及 exit code 10 高风险确认流程。

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • larksuite/cli#2140:该 issue 涉及共享 Skill 精简,以及 CLI schema、认证和 exit code 10 高风险确认规则。

Possibly related PRs

  • larksuite/cli#2189:该 PR 同样涉及 --no-wait --json--device-code 两阶段授权流程。
  • larksuite/cli#2159:该 PR 使用相关的 lark-shared 认证指导,但修改不同的文档和工作流。

Suggested reviewers: fangshuyu-768

Sequence Diagram(s)

sequenceDiagram
  participant Agent
  participant LarkCLI
  participant User
  Agent->>LarkCLI: 执行 auth login --no-wait --json
  LarkCLI-->>Agent: 返回 verification_url 和授权信息
  Agent->>User: 展示 URL 和二维码
  User->>LarkCLI: 完成浏览器授权
  Agent->>LarkCLI: 后续轮次执行 --device-code
  LarkCLI-->>Agent: 返回登录结果
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title clearly and concisely describes splitting lark-shared into a slim core and reference files.
Description check ✅ Passed The description covers the summary, changes, test plan, and related issues with clear implementation and verification details.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/lark-shared-slim

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.

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

🤖 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-shared/references/lark-shared-auth-split-flow.md`:
- Line 39: Update the split-flow guidance around the prohibition on caching
verification_url or device_code to allow retaining the active device_code for
the current continuation. Require discarding it after completion or expiry, and
prohibit only stale or cross-flow reuse while preserving the required
authorization options when starting a new flow.

In `@skills/lark-shared/references/lark-shared-identity-and-permissions.md`:
- Line 63: Update the auth login rule near the documented scope requirement to
allow --recommend alongside --domain and --scope. Preserve the existing
incremental authorization and agent follow-up guidance.
🪄 Autofix

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 Plus

Run ID: 0c2580fa-6f1d-4574-b01d-daa9f51514aa

📥 Commits

Reviewing files that changed from the base of the PR and between be2a96f and a3c8388.

📒 Files selected for processing (7)
  • skills/lark-shared/SKILL.md
  • skills/lark-shared/references/lark-shared-auth-split-flow.md
  • skills/lark-shared/references/lark-shared-config-init.md
  • skills/lark-shared/references/lark-shared-high-risk-approval.md
  • skills/lark-shared/references/lark-shared-identity-and-permissions.md
  • skills/lark-shared/references/lark-shared-output-contract.md
  • skills/lark-shared/references/lark-shared-update-notice.md

Comment thread skills/lark-shared/references/lark-shared-auth-split-flow.md Outdated
Comment thread skills/lark-shared/references/lark-shared-identity-and-permissions.md Outdated
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#docs/lark-shared-slim -y -g

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.47%. Comparing base (6d6b688) to head (e34c504).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2226   +/-   ##
=======================================
  Coverage   76.46%   76.47%           
=======================================
  Files        1013     1013           
  Lines      112034   112079   +45     
=======================================
+ Hits        85665    85707   +42     
- Misses      19857    19859    +2     
- Partials     6512     6513    +1     

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

lark-shared is force-loaded by nearly every lark-* skill (26 skills, 190
references), so its body is paid on almost every task. Split the 211-line
monolith into a slim always-loaded core plus references/ that are read only
when relevant.

This is deliberately a move, not a rewrite. Existing wording is carried over
as-is wherever possible so the change stays easy to regression-test. The core
keeps the rules whose violation is silent or has no self-announcing trigger:
identity semantics, the ok == true success contract, non-blocking auth
split-flow, QR forwarding, write/delete intent confirmation, the exit-10
approval gate, path handling and the no-secrets rule. Mechanics, field paths
and step-by-step flows move to references/.

New references, all carrying over existing text:
- lark-shared-identity-and-permissions.md
- lark-shared-auth-split-flow.md
- lark-shared-high-risk-approval.md
- lark-shared-output-contract.md
- lark-shared-update-notice.md
- lark-shared-config-init.md

The body now also routes to references/lark-wiki-token-routing.md, which
already existed but was unreachable from the skill body.

Wording changes are confined to lark-shared-high-risk-approval.md, where the
exit-10 guidance was generalized to match the implementation: the recovery
flag is read from hint rather than assumed to be --yes, and --dry-run is
suggested only where the target command supports it.
Regroup the always-loaded body so the safety rules read as one block: the
no-secrets rule leads, write/delete intent confirmation and --dry-run preview
follow, and the exit-10 approval gate and path handling close it out.

Trim wording that restated consequences already covered by the linked
reference, and align a few reference passages with the command surface
(`config init` without the flag, envelope phrasing).
Replace the loose "other scenarios" link list with an explicit trigger index:
each row names the conditions that oblige the agent to open that reference
before taking the next step, and the table covers all six references rather
than the three the list happened to mention.

Trigger conditions beat prose pointers here because the failure mode is an
agent that never opens the reference at all — a link it reads as optional is
a link it skips. Emphasis markers on individual rules are dropped in favour of
plain arrows, since the obligation now lives in the index.
Name what the three `_notice` keys mean for the agent rather than listing the
keys themselves, so the trigger reads as a condition to recognize instead of a
field spec to memorize.
@leave330
leave330 force-pushed the docs/lark-shared-slim branch from 3dacd40 to af7441a Compare August 10, 2026 08:20
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Restate the identity trigger in the terms an agent actually encounters ("who am
I", "get the fields of the current identity") rather than in diagnostic
vocabulary, and gloss high-risk-write so the row is readable without already
knowing the term.

Use MUST for the read obligation, matching how the rest of the skill set marks
non-negotiable steps.

@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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@skills/lark-shared/SKILL.md`:
- Line 46: Update the trigger text in SKILL.md to use the documented
`missing_scopes` field name instead of `missing_scope`, while preserving the
existing identity-and-permissions reference mapping and other trigger terms.
🪄 Autofix

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 Plus

Run ID: 8f8270a2-6b62-4e8a-955f-31f6fe9b236c

📥 Commits

Reviewing files that changed from the base of the PR and between af7441a and 8825b6b.

📒 Files selected for processing (1)
  • skills/lark-shared/SKILL.md

Comment thread skills/lark-shared/SKILL.md Outdated
The split-flow steps require carrying device_code from the first turn into the
second, so a flat ban on caching it contradicted the procedure it accompanied.
Scope the ban to reuse across flows, which is the case that actually matters.

Also match the trigger table to the field name the error envelope carries
(missing_scopes), keeping it consistent with the reference it routes to.
…scope flags

Bring back the note that a bot reading user resources returns an empty success
rather than an error. That failure is silent, so it belongs in the body: an
agent that never learns it reads the empty result as "the user has no data".

Also list --recommend alongside --scope and --domain as a way to specify the
authorization range, matching what auth login actually accepts.
…sions

Auth split-flow and identity/permission recovery are consulted in the same
situation — an agent about to obtain or repair authorization — so a separate
file bought a second hop without buying separation. Merge the split-flow steps
into identity-and-permissions as its agent-initiated-auth section, and route
its trigger row there.

The non-blocking rule leaves the resident body with this merge; the trigger
index already forces the read before any auth login is initiated, which is the
moment the rule matters.

Also reword the _notice.skills gloss to "out of sync" — the mismatch is
bidirectional, not only the skills lagging the CLI.
Resolve the SKILL.md conflict in favor of the restructured body, and
relocate the two sections #2288 added to the old monolith into
lark-shared-identity-and-permissions.md verbatim, at the same relative
positions they held upstream: identity continuity across command
workflows (after the identity-selection principles) and the
missing-scope vs resource-ACL recovery table (inside the
permission-failure section). No upstream sentence is dropped.
Omitting --as does not keep the current identity — it hands the choice back
to the profile default, and nothing errors when that happens. That silent
switch is exactly the class of rule the resident body exists for, so state
the kernel in rule 2; the mechanics and examples stay in the
identity-and-permissions reference brought in from main.
Weaker models transcribe the visible link text when deciding what to read,
and short aliases made them reconstruct the real filename — a step that
misspells. Display the exact filename everywhere so copying the visible text
yields a resolvable path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation 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