Skip to content

feat: fetch official skills index#1301

Merged
evandance merged 1 commit into
mainfrom
feat/update-skills-index-json
Jun 6, 2026
Merged

feat: fetch official skills index#1301
evandance merged 1 commit into
mainfrom
feat/update-skills-index-json

Conversation

@zhangheng023

@zhangheng023 zhangheng023 commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

lark-cli update currently discovers official skills by parsing unstable human-oriented skills add --list output. This PR prefers the stable official JSON index for skills discovery, while preserving the existing CLI-list fallback and full-install fallback for resilience.

Changes

  • Add official skills index JSON parsing in internal/skillscheck/sync.go
  • Prefer JSON index discovery before existing CLI list parsing in internal/skillscheck/sync.go
  • Add reason-chain details when both discovery layers fall back to fallbackFullInstall
  • Add bounded HTTPS fetch for https://open.feishu.cn/.well-known/skills/index.json in internal/selfupdate/updater.go
  • Add unit tests for parser behavior, discovery fallback order, and fallback detail reasons in internal/skillscheck/sync_test.go

Test Plan

  • skipped: make unit-test was not run separately; validate ran the harness build/vet/unit/integration suite
  • validate passed (docs/superpowers/verify_results/validate.json)
  • skipped: local-eval E2E/skillave not applicable in lite mode for this non-shortcut, non-skill, non-meta API change
  • acceptance-reviewer passed (2/2 cases)
  • manual verification: go test ./internal/selfupdate ./internal/skillscheck ./cmd/update
  • manual verification: live fetch shape check for https://open.feishu.cn/.well-known/skills/index.json returned root object with 26 lark- skills

Related Issues

N/A

Summary by CodeRabbit

  • New Features

    • App can fetch and use an official skills index over HTTPS (with timeout and size safeguards); index results drive faster installations and skip the slower listing command when available.
  • Behavior

    • Falls back to prior discovery when the index is unavailable or empty; aggregates reasons when both methods fail.
  • Documentation

    • Updated IM/skill docs and shortcut listings to replace Feed Group entries with Feed Shortcut commands and revised shortcut descriptions.
  • Tests

    • Added coverage for index parsing, non-prefixed names, deduping, fallbacks, redirects, timeouts, and size limits.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Looking for one thing? Review this PR in Change Stack to search files, summaries, diffs, and code without losing your place.

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8d19daa1-a985-42f7-a450-e84edeef0c89

📥 Commits

Reviewing files that changed from the base of the PR and between ed97eea and d2af44d.

📒 Files selected for processing (11)
  • cmd/update/update_test.go
  • internal/selfupdate/updater.go
  • internal/selfupdate/updater_test.go
  • internal/skillscheck/sync.go
  • internal/skillscheck/sync_test.go
  • shortcuts/im/helpers_test.go
  • shortcuts/im/im_flag_cancel.go
  • shortcuts/im/im_flag_create.go
  • shortcuts/im/shortcuts.go
  • skill-template/domains/im.md
  • skills/lark-im/SKILL.md
✅ Files skipped from review due to trivial changes (2)
  • shortcuts/im/im_flag_cancel.go
  • shortcuts/im/im_flag_create.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • internal/selfupdate/updater_test.go
  • internal/selfupdate/updater.go
  • cmd/update/update_test.go

📝 Walkthrough

Walkthrough

Adds HTTP retrieval and JSON parsing of an official skills index, extends the SkillsRunner interface, refactors sync to prefer index-first discovery with fallback to the existing list parsing flow, updates cmd/update test wiring, and removes Feed Group shortcuts/docs while updating related tests and metadata.

Changes

Official Skills Index Discovery

Layer / File(s) Summary
HTTP fetch infrastructure for official skills index
internal/selfupdate/updater.go, internal/selfupdate/updater_test.go
Adds io and net/http imports, defines skillsIndexFetchTimeout, skillsIndexMaxBodySize, and officialSkillsIndexURL, adds Updater.SkillsIndexFetchOverride, and implements ListOfficialSkillsIndex() performing a timed HTTPS GET, status validation, body size enforcement, and returning the index body in NpmResult.Stdout or Err on failure. Includes HTTP-based unit tests for success, HTTP errors, oversized responses, timeouts, non-HTTPS redirect rejection, and override fast-paths.
Index JSON parsing and SkillsRunner extension
internal/skillscheck/sync.go
Adds ParseOfficialSkillsIndexJSON() which unmarshals skills[].name, trims, validates via skillNamePattern, de-duplicates and sorts results. Removes explicit lark- prefix check in parseOfficialSkillsList and extends SkillsRunner with ListOfficialSkillsIndex() method.
Sync orchestration with index-first discovery and fallback
internal/skillscheck/sync.go, internal/skillscheck/sync_test.go
Refactors SyncSkills to call listOfficialSkills(), which first attempts ListOfficialSkillsIndex() + ParseOfficialSkillsIndexJSON(), then falls back to ListOfficialSkills() + ParseSkillsList() if needed. listOfficialSkills() returns (skills, reason, ok) and constructs combined failure reasons used by fallbackFullInstall. Updates many SyncSkills tests and the fakeSkillsRunner to support index-first paths.
cmd/update test mocks and wiring
cmd/update/update_test.go
Updates test updater mocks to provide SkillsIndexFetchOverride and a successfulSkillsIndexFetch() helper; replaces SkillsCommandOverride guards with index-fetch-based guards and updates tests that assert skills-sync behavior accordingly.

IM shortcuts and documentation cleanup

Layer / File(s) Summary
Shortcut test updates
shortcuts/im/helpers_test.go
TestShortcuts expected commands updated to replace +feed-group-* entries with +feed-shortcut-* variants.
Shortcut metadata text updates
shortcuts/im/im_flag_cancel.go, shortcuts/im/im_flag_create.go, shortcuts/im/shortcuts.go
Revises ImFlagCancel and ImFlagCreate description strings and updates Shortcuts() to include feed-shortcut create/remove/list entries and remove feed-group entries.
IM docs and SKILL.md edits
skill-template/domains/im.md, skills/lark-im/SKILL.md
Removes Feed Group concept and feed.groups API docs from templates and lark-im skill docs; updates shortcuts table to prefer flag and feed-shortcut entries and removes related permission scopes.

Sequence Diagram

sequenceDiagram
  participant SyncSkills
  participant listOfficialSkills
  participant ListOfficialSkillsIndex
  participant ParseOfficialSkillsIndexJSON
  participant ListOfficialSkills
  participant ParseSkillsList

  SyncSkills->>listOfficialSkills: request official skills
  listOfficialSkills->>ListOfficialSkillsIndex: attempt index fetch
  alt index fetch succeeds
    ListOfficialSkillsIndex-->>listOfficialSkills: index stdout
    listOfficialSkills->>ParseOfficialSkillsIndexJSON: parse index JSON
    alt index parse succeeds & non-empty
      ParseOfficialSkillsIndexJSON-->>listOfficialSkills: skills list
      listOfficialSkills-->>SyncSkills: (skills, ok=true)
    else parse fails or empty
      listOfficialSkills->>ListOfficialSkills: fall back to list
      ListOfficialSkills-->>listOfficialSkills: list stdout
      listOfficialSkills->>ParseSkillsList: parse list
      ParseSkillsList-->>listOfficialSkills: skills or empty
      listOfficialSkills-->>SyncSkills: (skills, reason, ok)
    end
  else index fetch fails
    ListOfficialSkillsIndex-->>listOfficialSkills: error
    listOfficialSkills->>ListOfficialSkills: fall back to list
    ListOfficialSkills-->>listOfficialSkills: list stdout/error
    listOfficialSkills->>ParseSkillsList: parse list
    ParseSkillsList-->>listOfficialSkills: skills or error
    listOfficialSkills-->>SyncSkills: (skills, reason, ok)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • larksuite/cli#1233: Both PRs modify internal/skillscheck/sync.go’s SyncSkills control flow—this PR adds official skills-index discovery affecting the skills-to-plan pipeline while #1233 adjusts fallback triggers.
  • larksuite/cli#1008: Both PRs change internal/skillscheck syncing behavior; #1008 also modifies sync/state-driven machinery that interacts with the discovery flow.
  • larksuite/cli#1042: Related changes to incremental skills synchronization and Updater.ListOfficialSkills surface; both PRs affect the official-skills discovery path.

Suggested reviewers

  • liangshuo-1
  • MaxHuang22

"🐰 I hopped to fetch the index across the net,
Trimmed each name and sorted them in a set,
If JSON hides or the list won't play,
I fall back to text and try another way,
Tests guard the burrow where each change is met."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.08% 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 'feat: fetch official skills index' accurately and concisely describes the main change: adding HTTP-based fetching of a JSON skills index as a preferred discovery method.
Description check ✅ Passed The description covers the required template sections: Summary explains motivation, Changes lists main modifications, and Test Plan documents verification steps. All key information is present and well-structured.
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.

✏️ 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 feat/update-skills-index-json

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.

@github-actions github-actions Bot added the size/M Single-domain feat or fix with limited business impact label Jun 6, 2026
@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.01%. Comparing base (5788a6c) to head (d2af44d).

Files with missing lines Patch % Lines
internal/selfupdate/updater.go 78.12% 5 Missing and 2 partials ⚠️
internal/skillscheck/sync.go 93.02% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1301      +/-   ##
==========================================
+ Coverage   70.95%   71.01%   +0.05%     
==========================================
  Files         685      681       -4     
  Lines       65702    65435     -267     
==========================================
- Hits        46622    46470     -152     
+ Misses      15401    15320      -81     
+ Partials     3679     3645      -34     

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

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/update-skills-index-json -y -g

@github-actions github-actions Bot added size/L Large or sensitive change across domains or core paths and removed size/M Single-domain feat or fix with limited business impact labels Jun 6, 2026

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

🧹 Nitpick comments (1)
internal/selfupdate/updater_test.go (1)

292-312: 💤 Low value

Consider verifying the specific timeout error.

The test checks result.Err == nil but doesn't verify the error is actually a timeout error. While the controlled environment (200ms sleep vs 50ms timeout) makes a false positive unlikely, explicitly checking for timeout-related error messages would make the test more robust.

🔍 Optional enhancement
 	result := New().ListOfficialSkillsIndex()
-	if result.Err == nil {
-		t.Fatal("ListOfficialSkillsIndex() err = nil, want timeout error")
+	if result.Err == nil || !strings.Contains(result.Err.Error(), "context deadline exceeded") {
+		t.Fatalf("ListOfficialSkillsIndex() err = %v, want context deadline exceeded", result.Err)
 	}
🤖 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 `@internal/selfupdate/updater_test.go` around lines 292 - 312, Update
TestListOfficialSkillsIndexTimeout to assert that the error returned by
New().ListOfficialSkillsIndex() is a timeout error rather than just non-nil:
after calling result := New().ListOfficialSkillsIndex(), check either
errors.Is(result.Err, context.DeadlineExceeded) or, if the error may be a net
error, type-assert to net.Error and assert Timeout() == true; reference the test
function TestListOfficialSkillsIndexTimeout and the call sites New() and
ListOfficialSkillsIndex to locate where to add this explicit timeout assertion
instead of only checking result.Err == nil.
🤖 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.

Nitpick comments:
In `@internal/selfupdate/updater_test.go`:
- Around line 292-312: Update TestListOfficialSkillsIndexTimeout to assert that
the error returned by New().ListOfficialSkillsIndex() is a timeout error rather
than just non-nil: after calling result := New().ListOfficialSkillsIndex(),
check either errors.Is(result.Err, context.DeadlineExceeded) or, if the error
may be a net error, type-assert to net.Error and assert Timeout() == true;
reference the test function TestListOfficialSkillsIndexTimeout and the call
sites New() and ListOfficialSkillsIndex to locate where to add this explicit
timeout assertion instead of only checking result.Err == nil.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 53bc579b-8e4a-4cab-864b-30be4aee3fbe

📥 Commits

Reviewing files that changed from the base of the PR and between 8548876 and 3806dab.

📒 Files selected for processing (5)
  • cmd/update/update_test.go
  • internal/selfupdate/updater.go
  • internal/selfupdate/updater_test.go
  • internal/skillscheck/sync.go
  • internal/skillscheck/sync_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • internal/selfupdate/updater.go
  • internal/skillscheck/sync.go
  • internal/skillscheck/sync_test.go

lark-cli update currently discovers official skills by parsing unstable human-oriented `skills add --list` output. This prefers the stable official JSON index for skills discovery, while preserving the existing CLI-list fallback and full-install fallback for resilience.

Changes:

- Add official skills index JSON parsing in `internal/skillscheck/sync.go`

- Prefer JSON index discovery before existing CLI list parsing in `internal/skillscheck/sync.go`

- Add reason-chain details when both discovery layers fall back to `fallbackFullInstall`

- Add bounded HTTPS fetch for `https://open.feishu.cn/.well-known/skills/index.json` in `internal/selfupdate/updater.go`

- Add unit tests for parser behavior, discovery fallback order, and fallback detail reasons in `internal/skillscheck/sync_test.go`
@evandance
evandance force-pushed the feat/update-skills-index-json branch from ed97eea to d2af44d Compare June 6, 2026 10:17
@github-actions github-actions Bot added domain/im PR touches the im domain size/XL Architecture-level or global-impact change and removed size/L Large or sensitive change across domains or core paths labels Jun 6, 2026
@evandance
evandance merged commit 7c50b3d into main Jun 6, 2026
22 checks passed
@evandance
evandance deleted the feat/update-skills-index-json branch June 6, 2026 10:29
SunPeiYang996 pushed a commit that referenced this pull request Jun 8, 2026
lark-cli update currently discovers official skills by parsing unstable human-oriented `skills add --list` output. This prefers the stable official JSON index for skills discovery, while preserving the existing CLI-list fallback and full-install fallback for resilience.

Changes:

- Add official skills index JSON parsing in `internal/skillscheck/sync.go`

- Prefer JSON index discovery before existing CLI list parsing in `internal/skillscheck/sync.go`

- Add reason-chain details when both discovery layers fall back to `fallbackFullInstall`

- Add bounded HTTPS fetch for `https://open.feishu.cn/.well-known/skills/index.json` in `internal/selfupdate/updater.go`

- Add unit tests for parser behavior, discovery fallback order, and fallback detail reasons in `internal/skillscheck/sync_test.go`

Co-authored-by: zhaoyukun.yk <zhaoyukun.yk@bytedance.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/im PR touches the im domain feature size/XL Architecture-level or global-impact change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants