Skip to content

feat: add --skills suite mode to update for partial skill install#1600

Open
zhangheng023 wants to merge 7 commits into
mainfrom
feat/update-skills-suite-mode
Open

feat: add --skills suite mode to update for partial skill install#1600
zhangheng023 wants to merge 7 commits into
mainfrom
feat/update-skills-suite-mode

Conversation

@zhangheng023

@zhangheng023 zhangheng023 commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

lark-cli update previously always synced all official skills. This PR adds a --skills flag so users can install only a chosen subset (a "suite"), which is remembered (sticky) in skills-state.json — subsequent plain update runs sync only that subset. --skills all resets back to all official skills.

Changes

  • Add --skills flag, early format validation, suite plumbing, version-early-return bypass, skills_suite output, and exit-2 validation errors to cmd/update/update.go
  • Add SuiteSelection / ParseSuiteSelection, SyncOptions.Suite, SyncResult.Suite/InvalidInput, and suite resolution / official-name validation / set narrowing / no-fallback / persistence to internal/skillscheck/sync.go
  • Add the suite_skills (omitempty, backward compatible) field to internal/skillscheck/state.go
  • Document the flag under the update section of skills/lark-shared/SKILL.md

Test Plan

  • make unit-test passed
  • validate passed
  • skipped: local-eval (E2E + skillave) — lite mode does not run the sandbox; the update command has no existing E2E cases
  • acceptance-reviewer passed (4/4 cases)
  • manual verification: lark-cli update --help, and lark-cli update --skills "" / all,lark-im / "bad name" (text + JSON) — all exit 2 with a clear message and hint

Related Issues

N/A

Summary by CodeRabbit

  • New Features

    • lark-cli update now supports --skills to install or update only a selected subset of official skills.
    • The selected skill set is remembered for future update runs, and --skills all restores updating all skills.
  • Bug Fixes

    • Invalid or unknown skill selections now fail early with clearer validation output and a helpful hint.
    • Update output now shows the active skill suite in both JSON and human-readable formats.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The update command now accepts an explicit --skills suite, carries it through skills synchronization, persists suite-specific state, and reports suite-related validation and output details. Tests and documentation were updated for parsing, sync behavior, state round-trips, and output formats.

Changes

Suite-aware update flow

Layer / File(s) Summary
CLI suite input and validation
cmd/update/update.go, skills/lark-shared/SKILL.md
lark-cli update adds --skills, tracks whether it was explicitly set, validates raw suite input before update processing, and documents suite-mode usage and reset behavior.
Suite propagation and output formatting
cmd/update/update.go, cmd/update/update_test.go
The update path passes parsed suite selections into manual and npm update flows, only reuses the cached-version shortcut when no suite was provided, and includes suite context plus validation hints in JSON and text output; tests cover parsing, invalid input, output fields, and same-version bypass behavior.
Suite selection, sync, and state persistence
internal/skillscheck/state.go, internal/skillscheck/sync.go, internal/skillscheck/state_test.go, internal/skillscheck/sync_test.go
SyncSkills now parses explicit suite selections, reuses a sticky suite from state when none is provided, narrows official skills in suite mode, changes fallback behavior, persists suite_skills, and updates tests for parsing, state round-trips, unknown skills, and suite reset behavior.

Sequence Diagram(s)

sequenceDiagram
  participant updateRun
  participant runSkillsAndState
  participant SyncSkills
  participant reportError
  updateRun->>runSkillsAndState: pass parsed suite selection
  runSkillsAndState->>SyncSkills: SyncOptions{Suite: suite}
  SyncSkills-->>runSkillsAndState: SyncResult{Suite, InvalidInput}
  runSkillsAndState-->>updateRun: result or validation error
  updateRun->>reportError: emit JSON hint when InvalidInput is set
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • larksuite/cli#1042: Changes the same cmd/update/update.go and internal/skillscheck sync/state flow that this PR extends with explicit suite selection.
  • larksuite/cli#965: Shares the state-based incremental skills sync path and runSkillsAndState wiring.
  • larksuite/cli#1233: Adjusts the empty-ToUpdate install behavior inside SyncSkills, which this PR changes for suite mode.

Suggested reviewers

  • MaxHuang22
  • liangshuo-1

Poem

I thump through updates, nose a-twitch,
With suite-sized hops I make the switch.
One carrot path, or all the field,
The state remembers what I yield.
🐇 Hooray for skills that stay and thrill!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.51% 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 summarizes the main change: adding a suite-mode --skills option to update for partial skill installs.
Description check ✅ Passed The description follows the required template and includes summary, changes, test plan, and related issues with sufficient detail.
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.
✨ 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 feat/update-skills-suite-mode

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.

@github-actions github-actions Bot added the size/L Large or sensitive change across domains or core paths label Jun 26, 2026
@github-actions

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/update-skills-suite-mode -y -g

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.57576% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.67%. Comparing base (40a09c8) to head (7eabb27).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
internal/skillscheck/sync.go 79.12% 14 Missing and 5 partials ⚠️
cmd/update/update.go 90.24% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1600      +/-   ##
==========================================
- Coverage   74.74%   74.67%   -0.08%     
==========================================
  Files         799      804       +5     
  Lines       80380    81145     +765     
==========================================
+ Hits        60084    60595     +511     
- Misses      15849    16043     +194     
- Partials     4447     4507      +60     

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

@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

🧹 Nitpick comments (1)
cmd/update/update_test.go (1)

1663-1712: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the invalid-suite path before side effects, and assert typed metadata.

These tests only exercise JSON / already-up-to-date flows, so they would not catch the update-available case where RunNpmInstall happens before suite validation. They also only assert exit code / JSON substrings. Please add a companion non-JSON case with currentVersion < latest, assert npm install is never invoked, then verify subtype/category via errs.ProblemOf and Param via errors.As(*errs.ValidationError).

As per coding guidelines, **/*_test.go error-path tests must assert typed metadata and cause preservation. Based on learnings, use errors.As for ValidationError.Param because errs.ProblemOf does not expose Param.

🤖 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 `@cmd/update/update_test.go` around lines 1663 - 1712, The current update tests
only cover JSON and up-to-date paths, so they miss the update-available flow
where `RunNpmInstall` can happen before suite validation. Add a non-JSON test
around `NewCmdUpdate` with `currentVersion < fetchLatest` that verifies npm
install is not invoked, then assert the validation subtype/category using
`errs.ProblemOf`. Also check the `Param` on the resulting `errs.ValidationError`
with `errors.As`, since `errs.ProblemOf` does not expose it, and keep the
cause/error chain preserved.

Sources: Coding guidelines, Learnings

🤖 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 `@cmd/update/update.go`:
- Around line 138-140: The validation error in update handling is missing both
the flag metadata and the wrapped cause. In the branches using reportError in
update.go, update the errs.NewValidationError call to attach the user-facing
parameter with WithParam("--skills") and preserve the original failure with
WithCause(err) before adding the hint. Make the same change in the other
matching validation branch so the typed error contract and error unwrapping stay
intact.
- Around line 317-320: Reject unknown or non-official --skills values before any
npm update side effects occur. In update.go, move the official-name validation
out of suiteInputError/runSkillsAndState flow so invalid skills are checked
before RunNpmInstall and VerifyBinary can run, and make sure update() returns
the validation error immediately for cases like lark-bogus. Keep the validation
tied to the existing skill/suite helpers used by suiteInputError and
runSkillsAndState, but split the preflight check from the sync/install
execution.

---

Nitpick comments:
In `@cmd/update/update_test.go`:
- Around line 1663-1712: The current update tests only cover JSON and up-to-date
paths, so they miss the update-available flow where `RunNpmInstall` can happen
before suite validation. Add a non-JSON test around `NewCmdUpdate` with
`currentVersion < fetchLatest` that verifies npm install is not invoked, then
assert the validation subtype/category using `errs.ProblemOf`. Also check the
`Param` on the resulting `errs.ValidationError` with `errors.As`, since
`errs.ProblemOf` does not expose it, and keep the cause/error chain preserved.
🪄 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: 07d6e86f-8aa2-4108-a776-4f3d59f272da

📥 Commits

Reviewing files that changed from the base of the PR and between 6b83325 and 7eabb27.

📒 Files selected for processing (7)
  • cmd/update/update.go
  • cmd/update/update_test.go
  • internal/skillscheck/state.go
  • internal/skillscheck/state_test.go
  • internal/skillscheck/sync.go
  • internal/skillscheck/sync_test.go
  • skills/lark-shared/SKILL.md

Comment thread cmd/update/update.go
Comment on lines +138 to +140
return reportError(opts, io, "validation",
errs.NewValidationError(errs.SubtypeInvalidArgument, "%s", err).
WithHint("e.g. --skills lark-calendar,lark-im (or --skills all to reset)"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Attach --skills metadata and preserve the underlying cause.

Both branches are surfacing user-input validation, but they currently drop the flag name and wrapped error. That weakens the typed error contract and loses errors.Is / errors.Unwrap on the original failure.

Suggested fix
-			return reportError(opts, io, "validation",
-				errs.NewValidationError(errs.SubtypeInvalidArgument, "%s", err).
-					WithHint("e.g. --skills lark-calendar,lark-im (or --skills all to reset)"))
+			return reportError(opts, io, "validation",
+				errs.NewValidationError(errs.SubtypeInvalidArgument, "%s", err).
+					WithParam("--skills").
+					WithHint("e.g. --skills lark-calendar,lark-im (or --skills all to reset)").
+					WithCause(err))
@@
-	return reportError(opts, io, "validation",
-		errs.NewValidationError(errs.SubtypeInvalidArgument, "%s", r.Err).
-			WithHint("use a valid official skill name; nothing was installed"))
+	return reportError(opts, io, "validation",
+		errs.NewValidationError(errs.SubtypeInvalidArgument, "%s", r.Err).
+			WithParam("--skills").
+			WithHint("use a valid official skill name; nothing was installed").
+			WithCause(r.Err))

As per coding guidelines, cmd/**/*.go user flag validation must use .WithParam("--flag"), and **/*.go errors must preserve underlying failures with .WithCause(err).

Also applies to: 381-383

🤖 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 `@cmd/update/update.go` around lines 138 - 140, The validation error in update
handling is missing both the flag metadata and the wrapped cause. In the
branches using reportError in update.go, update the errs.NewValidationError call
to attach the user-facing parameter with WithParam("--skills") and preserve the
original failure with WithCause(err) before adding the hint. Make the same
change in the other matching validation branch so the typed error contract and
error unwrapping stay intact.

Source: Coding guidelines

Comment thread cmd/update/update.go
Comment on lines +317 to +320
skillsResult := runSkillsAndState(updater, io, latest, opts.Force, suite)
if err := suiteInputError(opts, io, skillsResult); err != nil {
return err
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Reject unknown --skills before upgrading the CLI.

In the npm path, suiteInputError runs only after RunNpmInstall and VerifyBinary, so lark-cli update --skills lark-bogus can still replace the CLI and then exit 2. That breaks the new contract that invalid/non-official skill names fail validation without installing anything. Preflight the official-name check before npm update side effects, or split suite validation from sync execution so unknown names are rejected first.

🤖 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 `@cmd/update/update.go` around lines 317 - 320, Reject unknown or non-official
--skills values before any npm update side effects occur. In update.go, move the
official-name validation out of suiteInputError/runSkillsAndState flow so
invalid skills are checked before RunNpmInstall and VerifyBinary can run, and
make sure update() returns the validation error immediately for cases like
lark-bogus. Keep the validation tied to the existing skill/suite helpers used by
suiteInputError and runSkillsAndState, but split the preflight check from the
sync/install execution.

@github-actions

Copy link
Copy Markdown

PR Quality Summary

CI did not complete successfully. Use the failed check links below to decide whether this PR needs a code change or a rerun.

Failed checks

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

Labels

feature 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