CapyClaw environment manager
CapyClaw helps set up or migrate a DSH profile across Windows, macOS, and Linux. The published starter manifest contains only portable registry package specs; machine-specific link: paths and profile directories are never shipped as defaults.
Setup wizard (GUI)
After the plugin is installed and the GUI loads, CapyClaw runs a first-run wizard:
- Scanning — a loading overlay shows “Scanning your environment” while the host detects the OS and builds an install/update/remove plan.
- Consent — a dialog lists exactly what will be installed, updated (upgrade/downgrade), or removed. Each item has a checkbox; nothing is applied until you click Agree & install. You can dismiss without applying.
- Progress — after consent, a panel shows what is being downloaded/installed/removed, a per-item status list, and an overall progress bar. You can cancel a running apply.
- Manual steps — if an item is stopped or needs human intervention, the result panel lists it with a plain-language reason and an actionable control instead of a raw error: a running bundle that blocks removal (
bundle-in-use / stop-profile) gets a Disable plugin button (calls stop-bundle, then Rescan to continue); registry/mirror lag gets a retry hint; restart-required gets a restart instruction. Classification lives in manualActionFor and is attached to each result as manual.
The wizard is a React component in the shell.overlay slot plus a launcher button in conversation.composer.dock, so it can be reopened any time. It talks to host routes under /capyclaw/environment/api/ (state, scan, jobs, apply, cancel, stop-bundle, dismiss). These are registered as GET-only webServer resource routes (query params, not POST bodies): the desktop dsh-app:// protocol bridge only answers GET/HEAD resource reads (readResource), so a POST handler route is rejected 405 there. Resource routes work over both plain HTTP and the dsh-app:// bridge. Consent is still bound to a server-side scanId and is a user action only; the agent cannot click it for you. First-run auto-open happens once per profile (tracked in a plugin-owned marker file); later runs reopen via the dock button.
The wizard is optional infrastructure: if the host has no web server (tools-only profile), the plugin still registers all agent tools and simply skips the GUI routes. The desktop can host more than one webServer instance, so the plugin registers the wizard routes on every discovered instance (cross-branch root-store scan, re-checked for 120 s to catch late starters) — registering on only the first found instance can leave the GUI-serving server without routes (HTTP 405). capyclaw_status / capyclaw_setup return a wizard diagnostics block (routesRegistered, webServerFound, registerError, origin, origins, servers, attempts) for remote debugging through the agent tool path even when HTTP is broken.
Tools
capyclaw_manifest: read the portable starter manifest.
capyclaw_status: detect the host OS and preview the starter or imported manifest without changing the profile.
capyclaw_setup: read-only scan that returns the install/update/remove plan plus wizard metadata (used by the GUI and by agents to preview setup).
capyclaw_export_environment: export the current profile's registry dependencies and enabled bundles to JSON. Local links are omitted because their paths cannot be migrated safely.
capyclaw_sync: preview by default; with apply=true, install planned packages using DSH pluginManager, enable selected bundles, back up the profile package manifest, and rescan the result.
Safety and compatibility
- The plugin uses the host package manager; it does not write profile dependencies directly or invoke npm/pnpm itself.
- Existing profile packages not named by the selected manifest are left alone.
- Changing an installed package version (upgrade or downgrade) is blocked unless
allowUpgrade=true. Review the returned plan before applying. Upgrades use the native updateBundle; downgrades use removeBundle + installBundle; explicit removals use removeBundle.
- A manifest may declare an optional
remove array of package names. Only installed registry packages named there are removed; a name that is also being installed is rejected, and machine-local packages can never be removed.
- Imported manifests must use schema version 1 and exact
name@version registry specs. A package may declare platforms as any subset of windows, macos, and linux; local links are intentionally not migrated. Starter entries are all optional and currently form a curated set, not a complete default installation profile.
- Machine-local profile dependencies (
link:, file:, path specs) are never exported as registry pins and are never replaced during apply — they are kept as-is (action: "keep", local: true) even with allowUpgrade=true, so local development checkouts cannot be overwritten by older registry versions.
- Registry installs intentionally omit the manager's strict
expected guard: that guard rejects an install whenever pnpm touches any other direct dependency, which false-positives (unexpected-package) on development profiles full of file:/link: deps. installBundle's own after-read still requires exactly one new, compatible bundle, and the planner's exact pins plus saveExact keep the installed version deterministic.
- A profile
package.json backup is made before apply when available. Package install rollback is not automatic; restore the returned backup manually if migration does not pass verification.
- DSH runtime installation/upgrades remain the responsibility of the DSH installer. CapyClaw reports version constraints and never replaces the running DSH executable.
Tests
Run npm test from this directory. The pure environment planner tests simulate Windows, macOS, and Linux without mutating a DSH profile. test/stability.test.mjs adds a stability suite: fuzzed manifests (300 seeded cases), version/platform edge cases, idempotent apply, concurrent tool calls, 500 apply/dispose leak cycles, and export robustness against corrupt or machine-local profiles. test/wizard.test.mjs covers the version comparator, removal planning, native upgrade/downgrade/remove executor paths, the job engine (consent binding, progress, exclusion, single-running guard, cancel, pruning), the wizard HTTP routes, and the client slot registration.
For a real-host end-to-end check, run node scripts/sandbox/verify-capyclaw-dsh.mjs from the repository root with DSH_CLI pointing at an installed dsh CLI. It packs the current source, boots a disposable DSH_HOME, and asserts activation, OS detection, preview-only behavior, the wizard API (scan → consent-bound apply → progress), and clean shutdown. It never touches your real profile. Set CAPYCLAW_STRESS=1 to additionally run 300 sequential + 120 concurrent tool calls and 10 byte-compare exports inside that isolated host. The headless CLI provides no webServer (that service belongs to the web/desktop GUI host), so the probe supplies a contract-faithful webServer shim backed by a real loopback HTTP server; this proves route registration and real HTTP transport, not desktop GUI rendering. Set CAPYCLAW_LIVE=1 to additionally exercise a real registry install → upgrade → remove of a clean-peer bundle (billion-context) inside that isolated host, asserting the on-disk version at each step (network required; never touches your real profile).