Skip to content

Skills hub: route bare slugs through pasclaw.dev first, ClawHub fallback (PR A of 3) - #129

Merged
FMXExpress merged 2 commits into
mainfrom
claude/hub-skills
Jun 4, 2026
Merged

FMXExpress merged 2 commits into
mainfrom
claude/hub-skills

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Summary

PR A of three. Wires the pasclaw.dev skills registry into the existing skill install + search paths without disturbing the ClawHub or GitHub installers.

  • PR A (this) — skills hub-first with ClawHub fallback
  • PR B — Vault tool (default-off agent tools vault_search / vault_get, onboarding default-yes prompt, pasclaw vault search/show/install CLI where install does git clone)
  • PR C — MCP search registry with offline fallback to the built-in 5-entry catalog

What changes

New unit: src/pkg/skills/PasClaw.Skills.PasClawHub.pas — mirror of the ClawHub client targeting https://pasclaw.dev/api/public/v1. Two public entry points: SearchPasClawHub and InstallFromPasClawHub. Per the OpenAPI, the hub's /download returns a JSON envelope with a signed URL (not the zip itself), so the installer does a two-hop fetch: GET /download → parse url → GET that URL.

Cmd.Skills routing:

Target Behaviour
hub:<slug>[@<version>] NEW — pasclaw.dev only
clawhub:<slug>[@<version>] ClawHub only (unchanged)
owner/repo[@ref] GitHub (unchanged)
Bare slug code-review NEW — try pasclaw.dev, fall back to ClawHub on not found, fall back to legacy "record in config.json" only if both hubs report not-found. Network errors on pasclaw.dev surface as errors with a hint to retry via clawhub: — they don't silently demote.
Paths / malformed Legacy record-only (unchanged)

Search: pasclaw skills search <q> queries both hubs and shows aggregated results — pasclaw.dev first, ClawHub deduped. Either hub unreachable: warning + results from whichever responded. Both unreachable: both error messages surfaced. Per-result source tag (hub / claw) in the output.

What does NOT change

  • ClawHub and GitHub installers untouched. Pre-existing clawhub: / owner/repo invocations behave identically.
  • Legacy "record in config.json" path preserved for anyone who depended on it — only kicks in when BOTH hubs return not-found, with a ! no hub entry for "X" — recording in config.json only notice.

Helper duplication

PasClaw.Skills.PasClawHub copies UrlEncode / IsValidSlug / DownloadZip / CopyTree / RemoveTree / FindSkillRoot from ClawHub.pas. The codebase has accepted this duplication across installers (GitHub.pas does the same); a follow-up should factor them into a shared HubCommon unit. Noted in the unit header.

Test plan

  • FPC build clean (443958 lines)
  • make smoke 11/11 OK
  • CLI spot-check: updated help text shows hub: and bare-slug routing; pasclaw skills search queries both hubs and surfaces per-hub error attribution cleanly when network is unreachable
  • Manual: pasclaw skills install code-review (or whatever exists on pasclaw.dev) — verify the two-hop signed-URL download flow works against the real hub
  • Manual: pasclaw skills install clawhub:<slug> keeps working unchanged
  • Manual: pasclaw skills install owner/repo keeps working unchanged
  • Manual: pasclaw skills install some-name-not-on-any-hub falls through to the legacy notice

Generated by Claude Code

PR A of three (B = vault tool + onboarding, C = MCP search registry
with offline fallback). Wires pasclaw.dev's skills registry into
the existing skill install + search paths without disturbing the
ClawHub or GitHub installers.

New unit src/pkg/skills/PasClaw.Skills.PasClawHub.pas — mirror of
the ClawHub client targeting https://pasclaw.dev/api/public/v1.
Two public entry points: SearchPasClawHub and InstallFromPasClawHub.
Per the OpenAPI, the hub's /download returns a JSON envelope with
a signed URL (not the zip itself), so the installer does a two-hop
fetch: GET /download → parse "url" → GET that URL. Metadata,
moderation flags, and version fallback all follow the same advisory
semantics ClawHub uses.

Cmd.Skills routing changes:
  - hub:<slug>[@<version>]      → pasclaw.dev only (new explicit prefix)
  - clawhub:<slug>[@<version>]  → ClawHub only (unchanged)
  - owner/repo[@ref]            → GitHub (unchanged)
  - bare slug "code-review"     → DoInstallBareSlug: tries pasclaw.dev,
                                  falls back to ClawHub on 'not found',
                                  falls back to the legacy "record in
                                  config.json" path only if BOTH hubs
                                  return not-found. Network errors on
                                  pasclaw.dev surface as errors with
                                  a hint to retry via clawhub: — they
                                  don't silently demote to ClawHub.
  - paths / malformed targets   → legacy (unchanged)

Search now queries both hubs in parallel and shows aggregated
results: pasclaw.dev entries render first, ClawHub entries follow
with already-seen slugs deduped. Either hub being unreachable
degrades to a warning + the results from the one that responded;
both unreachable surfaces both error messages. Per-result source
tag (`hub` / `claw`) shown in the output.

Helper duplication: PasClaw.Skills.PasClawHub copies UrlEncode,
IsValidSlug, DownloadZip, CopyTree, RemoveTree, FindSkillRoot from
ClawHub.pas — the codebase has accepted that duplication across
installers (GitHub.pas does the same), and refactoring into a
shared HubCommon unit is a separate concern. Noted in the unit
header for follow-up.

Verified end-to-end with the FPC build (443958 lines clean,
smoke 11/11 OK) and a CLI spot-check: `pasclaw skills` prints the
updated help text including hub:/bare-slug routing; `pasclaw skills
search` queries both hubs and surfaces per-hub error attribution
when network is unreachable.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9848cb1dff

ℹ️ 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".

Result := False;
ErrMsg := '';
SetLength(Headers, 0);
Resp := GetJSONURL(URL, Headers, RequestTimeoutSec);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Fetch the archive with a binary stream

When the signed URL returns the actual zip bytes, routing it through GetJSONURL decodes the response via the UTF-8 TStringStream path (the HTTP unit explicitly reserves GetURLToStream for zip downloads), so arbitrary archive bytes can be corrupted before being written to archive.zip. This makes pasclaw.dev installs fail extraction or install a damaged skill; use the binary stream download path as the ClawHub installer does.

Useful? React with 👍 / 👎.

P1 — Codex flagged the pasclaw.dev installer's DownloadZip routing
binary archive bytes through GetJSONURL, which decodes the response
body as UTF-8 via TStringStream. Any zip byte outside the ASCII
printable range gets mangled before write, so pasclaw.dev installs
would either fail extraction or land a damaged skill on disk.

Fix: replace the GetJSONURL + Resp.Body + WriteBuffer path with
GetURLToStream writing into a TFileStream directly — the same
binary-safe pattern ClawHub.DownloadZip uses for its raw-bytes
/download endpoint. Also picks up the size-cap + empty-archive
checks ClawHub already had.

Build clean (444735 lines), smoke 11/11 OK.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
@FMXExpress
FMXExpress merged commit c1ba8f8 into main Jun 4, 2026
khongten001 pushed a commit to khongten001/PasClaw that referenced this pull request Jun 6, 2026
… of 3)

Adds search + get + install for the pasclaw.dev Code Vault registry,
which hosts Object Pascal source code (sample programs, reusable
components, libraries) as GitHub-backed entries. Vault is search-and-
get only on the wire — no zip/download envelope; entries link to
GitHub repos and the install path shells out to `git clone`.

Three new units:

  - src/pkg/skills/PasClaw.Vault.Client.pas — HTTP client for the
    two endpoints (GET /vault?q=… and GET /vault/<slug>) on
    https://pasclaw.dev/api/public/v1. TVaultResult + TVaultDetail
    records flatten the JSON shape (tags + delphiVersions arrays
    are comma-joined for compact rendering; moderation
    isMalwareBlocked / isSuspicious surface as Boolean fields).

  - src/pkg/tools/PasClaw.Tools.Vault.pas — registers two
    agent-callable tools, BOTH off by default:
      vault_search(query, limit?=10) — returns a JSON array of
        matching entries (slug, displayName, summary, category,
        tags, repoUrl, version).
      vault_get(slug) — full entry detail including
        descriptionMarkdown, repoUrl, license, delphiVersions,
        installSnippet.
    Both tcReadOnly. Cmd.Agent.NewBuiltinRegistry registers them
    only when EnableVault=True; callers pass Cfg.VaultToolsEnabled.

  - src/cmd/PasClaw.Cmd.Vault.pas — `pasclaw vault <search|show|
    install>`. `install <slug> [<dest>]` calls
    `git clone <repoUrl> <dest>` (default
    $PASCLAW_HOME/workspace/vault/<slug>); refuses if dest exists;
    streams git's stdout as it runs. Inherits whatever git auth
    the user already has (SSH keys, credential helper) — no
    private-repo auth handling in PasClaw itself.

Config:
  - New TConfig.VaultToolsEnabled (Boolean, default False).
  - JSON ser/deser: only serialised when True (keeps stock configs
    tidy, matches prompt_cache pattern).

Onboarding:
  - New PromptVaultTools step after PromptMCPInstalls, asks
    `Enable vault tools for the agent [Y/n]:` with default-yes.
    Pressing Enter sets VaultToolsEnabled := True; explicit `n`
    skips with a "flip vault_tools_enabled in config.json to
    enable later" hint.

Cmd.Root: new top-level `vault` subcommand in dispatch + help list.

Verified end-to-end with the FPC build (149912 lines clean,
smoke 11/11 OK) and scripted onboarding both paths:
  Enter → vault_tools_enabled: true emitted
  'n'   → field omitted (default-off, default-suppressed)

PR ordering: A (FMXExpress#129, merged) wired the skills hub-first lookup;
this is B (vault); C (MCP search registry with offline fallback)
follows next. Each is independent — vault has no dependency on A
or C beyond sharing the same hub base URL.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
khongten001 pushed a commit to khongten001/PasClaw that referenced this pull request Jun 6, 2026
Wires pasclaw.dev's MCP registry into the existing catalog +
install paths and adds a new `pasclaw mcp search` subcommand.
Hub-first by default with automatic fallback to the bundled 5-
entry catalog when the registry is unreachable.

New unit src/pkg/mcp/PasClaw.MCP.Hub.pas:
  - SearchMCPHub(query, limit) — hub-only query, no fallback
    (the bundled 5-entry list is too small to search usefully).
  - GetMCPHubEntry(slug) — single-entry lookup that projects the
    hub's response onto the existing TMCPCatalogEntry record so
    callers don't need a separate code path. Returns 'not found'
    on 404, surfaces other errors as-is.
  - ResolveMCPCatalog(out entries, out source, out hubSkipped,
    out hubErr) — `pasclaw mcp catalog` driver. 5 s hub timeout
    (keep `catalog` snappy), falls back to KnownMCPServers on
    any failure (DNS / TLS / 5xx / parse error). Source = 'hub'
    when entries came from pasclaw.dev, 'builtin' otherwise.

Transport handling: v1 maps only transport=='http' hub entries
onto TMCPCatalogEntry (URL + EnvVar + AuthFmt is HTTP-only).
Non-HTTP entries surface as a skipped-count in DoCatalog's
attribution line. Adding stdio support means extending the
TMCPCatalogEntry shape to carry command + args — separate change.

EnvSchema mapping: the hub's per-entry envSchema can declare
multiple required env vars; v1 picks the first required one for
EnvVar and assumes Bearer-token format. Most entries have a single
auth token; richer mapping (multi-var, custom header format) is a
follow-up once the hub's envSchema shape stabilises in the
OpenAPI.

Cmd.MCP changes:
  - DoCatalog now calls ResolveMCPCatalog and prefixes the table
    with "(showing N from pasclaw.dev hub)" / "(offline — showing
    built-in N entries)" / "(showing built-in N entries)".
  - DoInstall tries GetMCPHubEntry first; falls back to
    FindCatalogEntry on hub miss or network error. Both paths
    write the same TMCPServer config entry, so list/test/show
    work identically afterwards.
  - New DoSearch wired to `pasclaw mcp search <query>`.
  - Help text updated.

Verified end-to-end with the FPC build (smoke 11/11 OK) plus a
network-down spot check:
  - `pasclaw mcp catalog` falls back cleanly with a yellow "hub
    unreachable" notice and shows the bundled 5 entries
  - `pasclaw mcp search foo` fails loudly (search has no fallback)
  - All existing `mcp list/add/remove/test/show/edit` subcommands
    unchanged

PR ordering: A (FMXExpress#129 merged) wired skills hub-first; B (FMXExpress#130, in
review) added the vault tool + CLI + onboarding opt-in; this is C
— each is independent.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants