Skip to content

Vault tool — agent + CLI surface for the pasclaw.dev Code Vault (PR B of 3) - #130

Merged
FMXExpress merged 2 commits into
mainfrom
claude/vault
Jun 4, 2026
Merged

FMXExpress merged 2 commits into
mainfrom
claude/vault

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

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:

File Purpose
src/pkg/skills/PasClaw.Vault.Client.pas HTTP client for GET /vault?q= and GET /vault/<slug>. Returns TVaultResult[] and TVaultDetail records.
src/pkg/tools/PasClaw.Tools.Vault.pas Agent-callable vault_search(query, limit?) and vault_get(slug) tools. Both tcReadOnly.
src/cmd/PasClaw.Cmd.Vault.pas pasclaw vault <search|show|install> CLI. Install shells out to git clone <repoUrl> <dest> and streams git's stdout.

Config: new TConfig.VaultToolsEnabled: Boolean (default False). Only serialised when True so stock configs stay tidy (same pattern as prompt_cache).

Cmd.Agent.NewBuiltinRegistry gained an EnableVault: Boolean = False parameter; callers pass Cfg.VaultToolsEnabled. Vault tools register only when that's true.

Onboarding: new PromptVaultTools step after the MCP-install loop. Enable vault tools for the agent [Y/n]: — default yes (pressing Enter enables). Explicit n skips with a hint to flip the config later.

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

Usage

# CLI surface (does not require vault_tools_enabled — only the agent tools do)
pasclaw vault search "indy ssl"
pasclaw vault show indy-ssl-helper
pasclaw vault install indy-ssl-helper                 # → workspace/vault/indy-ssl-helper
pasclaw vault install indy-ssl-helper /path/to/here   # custom dest

Agent flow (when vault_tools_enabled: true):

  1. User: "find me Object Pascal SSL helper code"
  2. Model calls vault_search("ssl") → gets slugs + repoUrls
  3. Model calls vault_get("indy-ssl-helper") → reads description, license, install snippet
  4. Model either tells the user the repo URL or calls shell_exec("git clone <repoUrl>") itself

The agent already has every primitive it needs once it knows the repo URL — vault's only job is the discovery hop.

Test plan

  • FPC build clean
  • make smoke 11/11 OK
  • pasclaw top-level help shows vault row
  • pasclaw vault prints subcommand help
  • Scripted onboarding default-yes (Enter) → vault_tools_enabled: true in config
  • Scripted onboarding explicit n → field omitted (default-off, default-suppressed)
  • Manual pasclaw vault search <q> against the real pasclaw.dev hub
  • Manual pasclaw vault install <slug> — verify git clone runs with streaming stdout, lands at the expected workspace path
  • Manual With vault_tools_enabled: true, run pasclaw agent and ask for code — verify vault_search + vault_get appear in the tool-call stream

Generated by Claude Code

… 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

@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: 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".

Comment thread src/cmd/PasClaw.Cmd.Vault.pas Outdated
Exit(1);
end;

ForceDirectories(ExtractFileDir(DestDir));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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
@FMXExpress
FMXExpress merged commit bd335f0 into main Jun 4, 2026
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