Repository navigation
Skills Phase 3: ClawHub search + slug install - #59
Conversation
`pasclaw skills install <slug>[@<version>]` now resolves through ClawHub (https://clawhub.ai), the registry picoclaw and nanobot standardised on. `pasclaw skills search <query>` queries the same endpoint and prints result rows so users can discover skills without leaving the CLI. New unit src/pkg/skills/PasClaw.Skills.ClawHub: SearchClawHub(Query, Limit, out Results, out ErrMsg) GET /api/v1/search?q=<query>&limit=<n> Decodes the {results:[{slug,displayName,summary,version, score}]} envelope into a TClawHubResultArray. Missing fields fall back gracefully (DisplayName -> Slug, Summary -> ''). Empty response and an empty result array are distinct from an HTTP error. InstallFromClawHub(Slug, Version, DestRoot, out InstalledName, out ErrMsg) Pipeline: 1. Validate the slug (lowercase alphanumerics + '-'/'_') so a typo does not turn into a 404 round-trip. 2. Refuse if the destination directory already exists. 3. Best-effort metadata fetch (/api/v1/skills/<slug>) for moderation flags + latestVersion. Failure here is advisory — picoclaw treats it the same way. A malware-flagged skill refuses the install outright; a suspicious flag logs a warning and proceeds. 4. Resolve version: caller's pin -> metadata's latestVersion -> 'latest' (the endpoint default). 5. GET /api/v1/download?slug=<slug>&version=<version> into a temp zip. 64 MiB cap. 6. Extract via PasClaw.Skills.Zip. 7. FindSkillRoot looks for SKILL.md at the extraction root first, then descends into a single top-level wrapper directory (ClawHub archives sometimes have the wrapper, sometimes not — picoclaw's extractor handles both, so do we). 8. Validate by re-parsing the installed SKILL.md. 9. Copy the tree into workspace/skills/<slug>/. Cleans up the temp directory always; removes the partial destination on failure. Minimal in-unit helpers: UrlEncode (RFC 3986 percent-encoder for query-string values), IsValidSlug (matches picoclaw's utils.ValidateSkillIdentifier behaviour), PlatformTempDir + UniqueSuffix (same shape as the GitHub unit). The CopyTree / RemoveTree / DownloadZip helpers are intentionally local to this unit rather than extracted into a shared "skills.shared" — keeping each registry independent reads better and the duplication is ~80 LOC across two units. Cmd.Skills changes: install dispatches in this order: IsGitHubTarget(target) -> InstallFromGitHub IsClawHubSlug(target) -> InstallFromClawHub otherwise -> legacy "record in config.json" IsClawHubSlug enforces the same character set ClawHub validates server-side so e.g. `pasclaw skills install Foo` (mixed case) falls through to the legacy path with a clear deprecation message rather than 404'ing on ClawHub. `@<version>` suffix is permitted and split out by SplitSlugAtVersion before the install call. New `pasclaw skills search <query>` subcommand prints slug / version / displayName / summary in a tabular layout with a one-liner pointing at `pasclaw skills install <slug>` for installation. Help text refreshed; head-of-file docstring updated to reflect the new dispatch order. README documents the new install + search forms under a "ClawHub install (Phase 3, this release)" subsection alongside the existing GitHub install paragraph. Not in this PR (Phase 4 of the roadmap): - scripts/ (auto-callable helpers; agent invokes via shell_exec) + references/ (lazy-loaded into context) runtime support. Stacked as the next PR. https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8fa26d513b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| else if IsClawHubSlug(Argv[1]) then | ||
| Result := DoInstallClawHub(Argv[1]) |
There was a problem hiding this comment.
Preserve legacy installs for slug-shaped names
When the legacy skill name is any lowercase single path segment such as the documented my-skill, this new branch treats it as a ClawHub slug before the legacy path can run. Existing scripts that used pasclaw skills install my-skill to record a config-only skill will now either fail on a ClawHub 404 or install an unrelated registry skill if that slug exists, so the backward-compatible legacy flow is no longer available for common names unless they contain invalid slug characters.
Useful? React with 👍 / 👎.
| Root := TJsonObject.Parse(Body); | ||
| if Root = nil then Exit; |
There was a problem hiding this comment.
Handle malformed metadata as advisory
For a 200 response from /api/v1/skills/<slug> that is not valid JSON, TJsonObject.Parse raises EPasClawJSON, so the Root = nil fallback is never reached and skills install <slug> aborts before downloading. This contradicts the best-effort metadata behavior described in this function; wrap the parse in try/except and leave the default LatestVersion/Blocked/Suspicious values on parse errors.
Useful? React with 👍 / 👎.
…metadata Two legit P2 findings from the chatgpt-codex review on PR #59. 1. Slug-shaped legacy installs broke `pasclaw skills install my-skill` had been documented for the legacy config.json-only flow, and Phase 3's IsClawHubSlug matched any lowercase alphanumeric-with-hyphen target — so a pre-existing script using the legacy command would suddenly either 404 on ClawHub or, worse, silently install an unrelated registry skill that happened to share the slug. Fix: require an explicit `clawhub:` prefix for the ClawHub path. Rename IsClawHubSlug -> IsClawHubTarget which checks the prefix, then validates the rest as a slug. Bare slug-shaped names fall through to the legacy path unchanged, preserving backwards compat. The dispatcher now checks ClawHub before GitHub so a pathological `clawhub:owner/repo` would hit the ClawHub validator (which rejects the slash) and fall through to legacy, rather than GitHub eating the slash and trying to fetch `clawhub:owner/repo` as a real codeload URL. README, help text, and the unit-header docstring all updated to the new `clawhub:<slug>[@<version>]` form. 2. Malformed metadata JSON aborted the install FetchMetadata was documented as best-effort but TJsonObject.Parse raises EPasClawJSON on bad JSON rather than returning nil — so a 200 response with garbage in the body bypassed the `Root = nil` fallback and propagated up to Cmd.Skills as an unhandled exception, refusing the install before download. Fix: wrap TJsonObject.Parse in try/except in FetchMetadata (proceed with default Latest/Blocked/Suspicious values on parse error, matching the documented "metadata is advisory" contract). Same wrapper added to SearchClawHub, but there a parse failure IS a search error so it surfaces through ErrMsg instead of being silently swallowed. Both wrappers initialize Root to nil before the try so the outer Root.Free in the finally block is safe on the parse failure path. https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Phase 3 of the 4-PR skills roadmap. After #55 (SKILL.md format) and #56 (GitHub install), this PR ships the ClawHub slug-based registry — same one picoclaw and nanobot use. Phase 4 (
scripts/+references/runtime) stacks next.New surface
Pipeline (
PasClaw.Skills.ClawHub)-/_) before any network round-trippasclaw skills remove <slug>firstGET /api/v1/skills/<slug>) for moderation flags +latestVersion:isMalwareBlocked: true→ refuse installisSuspicious: true→ warn and proceedlatestVersion→latestGET /api/v1/download?slug=<slug>&version=<version>to a temp zip. 64 MiB cap.PasClaw.Skills.Zip(Zipper.TUnZipper↔System.Zip.TZipFile)ParseSkillMDworkspace/skills/<slug>/. Cleans up temp dir always; removes partial destination on failureSearch (
SearchClawHub)Decodes the
{results:[{slug,displayName,summary,version,score}]}envelope into aTClawHubResultArray. Missing fields fall back gracefully. Empty response and an empty result array are distinct from an HTTP error.CLI dispatch order (
Cmd.Skills)IsClawHubSlugenforces the same character set ClawHub validates server-side sopasclaw skills install Foo(mixed case) falls through to the legacy path with a clear deprecation message rather than 404'ing on ClawHub.New
pasclaw skills search <query>subcommand prints slug / version / displayName / summary in a tabular layout with a pointer atpasclaw skills install <slug>for installation.Trade-offs
The
CopyTree/RemoveTree/DownloadZiphelpers are intentionally local to this unit rather than extracted into aSkills.Shared— keeping each registry independent reads better and the duplication is ~80 LOC across two units. If a fourth registry shows up that would tip the balance toward a shared helper.Not in this PR (Phase 4)
scripts/(auto-callable helpers; agent invokes viashell_execin the sandbox) +references/(path-only in system prompt; loaded into context on demand viafs_read) runtime support. Stacked as the next PR — needs the SKILL.md parser to walk the per-skill directory rather than just parse the file.Test plan
make) + Delphi.dprojbuild cleanlypasclaw skills search code— prints any matching results from the live ClawHubpasclaw skills search asdfasdfnomatch12345— prints(no matches)pasclaw skills install <real-slug-from-search>— succeeds;pasclaw skills listshows the new entrypasclaw skills install nonexistent-slug— fails withdownload failed: not found, no temp files left overpasclaw skills install Foo(mixed case) — falls through to the legacy config-only path with the existing deprecation hintpasclaw skills install owner/repo— still routes to the GitHub installer (PR Skills Phase 2: install from GitHub via codeload zip + native zip extract #56 path unchanged)pasclaw skills install code-review@<real-version>— pins version;latestresolution unaffectedskills list/skills removepaths unchangedhttps://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Generated by Claude Code