feat(skill): allagents skills search via GitHub Code Search#386
Conversation
Deploying allagents with
|
| Latest commit: |
000ce23
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://bb00ad57.allagents.pages.dev |
| Branch Preview URL: | https://feat-378-skill-search.allagents.pages.dev |
Code Review: ✅ APPROVE (best-tested PR in this batch)This PR stands out for having actual unit-test coverage of the new behavior — the validation matrix and the rate-limit / 422 / success error-mapping paths all get distinct tests with an injected fake Verification gate (#378)
CLAUDE.md compliance
Design highlights
Non-blocking suggestions1. Issue scope: interactive TUI selector is missing. The issue's expected behavior #4 was " Either acknowledge it as deferred in the squash commit, or file a follow-up issue and link it. 2. Bypasses Issue's implementation notes: "Use
Worth a follow-up to route through the shared helper, even if it doesn't change observable behavior today. 3. Missing Issue's implementation notes: "jsonFields (per the json-allowlist issue): at minimum name, repo, path, description, sha." 4. page: option({ type: optional(string), long: 'page', ... })
// later
const n = Number.parseInt(page, 10);
if (Number.isNaN(n)) { error }
opts.page = n;cmd-ts has a 5. GitHub's docs recommend 6. SKILL.md path parsing edge case. const name = parts.length >= 2 ? parts[parts.length - 2] ?? '' : ...repo basename...For a repo with Suggested merge orderThis PR is genuinely independent. Approves as-is. The TUI selector and |
New `skills search <query>` subcommand bridges "I want a skill that does X"
→ install. Hits the GitHub Code Search API for `SKILL.md` files matching the
query, ranks by relevance, and prints either a human table or the standard
JSON envelope.
- src/core/skill-search.ts: new module that owns the API call, validation,
and error-mapping. The query is composed as
`<query> filename:SKILL.md path:SKILL.md [user:<owner>]`. Auth comes from
`GITHUB_TOKEN` / `GH_TOKEN` when present; unauthenticated requests share
the public 10/min Code Search rate limit.
- Validation: query ≥ 2 chars; `--page` ≥ 1; `--limit` 1–100; `--owner`
matches `[A-Za-z0-9-]{1,39}`. Validation errors exit 2 with a clear
message instead of a generic Zod dump.
- Error mapping: a 403 with a "rate limit" message body maps to a
`SkillSearchError(kind='rate-limit')` with an actionable hint
(`gh auth login` / `GITHUB_TOKEN`). Other API failures fold into
`kind='api'`. Never dumps raw HTML or stderr.
- Ranking heuristic mirrors gh-skill's: exact name match → prefix match →
substring match → upstream order.
- src/cli/commands/plugin-skills.ts: registers `searchCmd` under `skillsCmd`.
- src/cli/metadata/plugin-skills.ts: new `skillsSearchMeta`; wired into
agent-help so `--agent-help "skills search"` is discoverable.
- tests/unit/core/skill-search.test.ts: 8 cases covering arg validation,
the 403 rate-limit mapping, the 422 mapping, and the happy-path item
normalisation. All use injected fake `fetch`, no live network.
Verified end-to-end against the live GitHub API (with GITHUB_TOKEN):
- Basic search returns ≥ 1 result for "documentation".
- `--owner github` narrows to a subset.
- Page 1 vs page 2 produce different result sets.
- Query < 2 chars exits 2 with "Search query must be at least 2 characters".
- `--page 0` / `--limit 0` exit 2 with the matching validation messages.
- Rate-limit unit test covers the unauthenticated-403 path so the gate's
guideline (7) is exercised without depending on actually exhausting the
quota.
Closes #378
4f50f85 to
000ce23
Compare
Summary
Adds
allagents skills search <query>for in-CLI skill discovery via the GitHub Code Search API. Bridges "I want a skill that does X" → install.src/core/skill-search.tsowns the API call, validation, ranking, and error mapping. Query is composed as<query> filename:SKILL.md path:SKILL.md [user:<owner>]so the search is constrained to skill manifests.GITHUB_TOKEN/GH_TOKENwhen present. Unauthenticated requests share the public 10/min Code Search rate limit — a 403 with arate limitbody is mapped to aSkillSearchError(kind='rate-limit')with an actionable hint (gh auth login/GITHUB_TOKEN), never a raw HTML dump.--page≥ 1,--limit1–100,--owner≤ 39 chars alphanumeric+dash) exits 2 with a clear message rather than a Zod stack.gh skill search: exact name match → prefix match → substring → upstream order.--agent-helpvia the newskillsSearchMeta.Test plan
bun run build,bun run typecheckbun test— 1199 pass / 0 fail (8 new unit tests use injected fakefetch, no live network)allagents skill searchvia GitHub Code Search (skill discovery) #378 (withGITHUB_TOKEN):skills search --help | grep ownermatches.--json skills search documentation --limit 5returns ≥ 1 item.--owner githubnarrows the result set.skills search aexits 2 with "Search query must be at least 2 characters".skills search docs --page 0and--limit 0exit 2 with their respective validation messages.tests/unit/core/skill-search.test.tsso the assertion is deterministic and doesn't depend on actually exhausting the quota.Closes #378