fix: fetch official skills from stable index#1190
Conversation
📝 WalkthroughWalkthroughThis PR refactors official skills discovery from npm-based listing to HTTP-based index fetching. Official skills are now fetched via a configurable well-known endpoint, validated by regex, and parsed from JSON format. Legacy text-based parsing remains as a fallback for global and available skills. ChangesOfficial Skills HTTP Index, Validation, and Parsing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@93754a9b5afe8f43824eb9b0ecc71c094951a427🧩 Skill updatenpx skills add larksuite/cli#fix/update-skills-index -y -g |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1190 +/- ##
==========================================
- Coverage 69.14% 69.13% -0.01%
==========================================
Files 630 630
Lines 59304 59359 +55
==========================================
+ Hits 41005 41040 +35
- Misses 14988 15001 +13
- Partials 3311 3318 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/selfupdate/updater.go (1)
30-30: ⚡ Quick winConsider extracting the duplicated regex pattern to a shared package.
The
officialSkillNamePatternregex is duplicated ininternal/skillscheck/sync.go(line 19). Consider moving both patterns to a shared validation package or constants file to maintain a single source of truth.🤖 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.go` at line 30, Extract the duplicated regex into a single exported constant/variable in a shared validation package (e.g., create Validation package with an exported OfficialSkillNamePattern or OfficialSkillNameRegex), replace both internal.selfupdate.updater.go's officialSkillNamePattern and internal.skillscheck.sync.go's local pattern with references to that shared symbol, update imports in the files that used the local pattern, and run/update any tests that reference the old symbol to ensure no behavior change.
🤖 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.go`:
- Line 30: Extract the duplicated regex into a single exported constant/variable
in a shared validation package (e.g., create Validation package with an exported
OfficialSkillNamePattern or OfficialSkillNameRegex), replace both
internal.selfupdate.updater.go's officialSkillNamePattern and
internal.skillscheck.sync.go's local pattern with references to that shared
symbol, update imports in the files that used the local pattern, and run/update
any tests that reference the old symbol to ensure no behavior change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a8de7961-6427-44c6-bdf4-d4a94d793a05
📒 Files selected for processing (5)
cmd/update/update_test.gointernal/selfupdate/updater.gointernal/selfupdate/updater_test.gointernal/skillscheck/sync.gointernal/skillscheck/sync_test.go
Summary
lark-cli updatediscovered official skills by parsing unstable human-orientednpx skills add --listoutput. This PR switches official skills discovery to the stable JSON index while preserving existing update and fallback behavior.Changes
internal/selfupdate/updater.gowith timeout, non-2xx handling, and a 2 MiB response limit.skills[].nameJSON index entries ininternal/skillscheck/sync.gobefore falling back to legacy text parsers.internal/skillscheck/sync.goand install-time validation ininternal/selfupdate/updater.go.internal/skillscheck/sync_test.go,internal/selfupdate/updater_test.go, andcmd/update/update_test.go.Test Plan
make unit-testpassedgo vet ./...passedgofmt -l .produced no outputgo mod tidydid not changego.modorgo.sumgo run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run --new-from-rev=origin/mainpassedgo test ./internal/skillscheck ./internal/selfupdate ./cmd/updateRelated Issues
N/A
Summary by CodeRabbit
New Features
Bug Fixes
Tests