Repository navigation
Vault tool — agent + CLI surface for the pasclaw.dev Code Vault (PR B of 3) - #130
Conversation
… 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 (#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
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a09530436a
ℹ️ 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".
| Exit(1); | ||
| end; | ||
|
|
||
| ForceDirectories(ExtractFileDir(DestDir)); |
There was a problem hiding this comment.
Handle bare relative install destinations
In the pasclaw vault install <slug> [<dest>] flow, a user can pass a destination like my-copy with no parent directory component. In that case ExtractFileDir(DestDir) returns an empty string, so ForceDirectories('') raises before git clone gets a chance to create the target directory; this breaks a documented custom-destination form that should be valid from the current working directory. Guard the parent creation when the extracted directory is empty.
Useful? React with 👍 / 👎.
When `pasclaw vault install <slug> <dest>` was called with a bare
relative destination (e.g. `my-copy`), ExtractFileDir returned an
empty string and ForceDirectories('') raised, breaking the
documented custom-destination form. Capture the parent into a
local var and skip the ForceDirectories call when it's empty —
git clone then creates the target itself, relative to the cwd.
Reported by Codex review on PR #130.
https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
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
Summary
PR B of three. Adds search + get + install for the pasclaw.dev Code Vault registry, which hosts Object Pascal source code (samples, 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.What's new
Three new units:
src/pkg/skills/PasClaw.Vault.Client.pasGET /vault?q=andGET /vault/<slug>. ReturnsTVaultResult[]andTVaultDetailrecords.src/pkg/tools/PasClaw.Tools.Vault.pasvault_search(query, limit?)andvault_get(slug)tools. BothtcReadOnly.src/cmd/PasClaw.Cmd.Vault.paspasclaw vault <search|show|install>CLI. Install shells out togit clone <repoUrl> <dest>and streams git's stdout.Config: new
TConfig.VaultToolsEnabled: Boolean(defaultFalse). Only serialised whenTrueso stock configs stay tidy (same pattern asprompt_cache).Cmd.Agent.NewBuiltinRegistry gained an
EnableVault: Boolean = Falseparameter; callers passCfg.VaultToolsEnabled. Vault tools register only when that's true.Onboarding: new
PromptVaultToolsstep after the MCP-install loop.Enable vault tools for the agent [Y/n]:— default yes (pressing Enter enables). Explicitnskips with a hint to flip the config later.Cmd.Root: new top-level
vaultsubcommand in dispatch + help list.Usage
Agent flow (when
vault_tools_enabled: true):vault_search("ssl")→ gets slugs + repoUrlsvault_get("indy-ssl-helper")→ reads description, license, install snippetshell_exec("git clone <repoUrl>")itselfThe agent already has every primitive it needs once it knows the repo URL — vault's only job is the discovery hop.
Test plan
make smoke11/11 OKpasclawtop-level help showsvaultrowpasclaw vaultprints subcommand helpvault_tools_enabled: truein confign→ field omitted (default-off, default-suppressed)pasclaw vault search <q>against the real pasclaw.dev hubpasclaw vault install <slug>— verify git clone runs with streaming stdout, lands at the expected workspace pathvault_tools_enabled: true, runpasclaw agentand ask for code — verifyvault_search+vault_getappear in the tool-call streamGenerated by Claude Code