What init --agent amp prints after installing the plugin: headless runs
need a flag, or Amp may start the turn before the plugin is ready and
skip its agent.start / agent.end hooks; and the injected policies are
stored in the thread, where whoever can read the thread sees them.
Best-effort cleanup of the extension registration left behind by an OLDER
version of this installer: the tracevault-tracker directory (an earlier,
incorrect Codex-clone hooks.json shim that impersonated this extension
under the wrong name) and any registry entries for tracevault-tracker or
tracevault — both are inert now that gsd install manages registration.
Set up TraceVault in project_root. An existing .tracevault/config.toml
is kept and only overridden where this run says so: server_url and
user_context (None = no flag given) replace the stored values; every
other field, and any field not overridden, survives (VIS-1046).
Install the TraceVault Amp plugin as tracevault/index.ts in an Amp
plugins directory: <project_root>/.amp/plugins/ for a repo, or with
None the user-level one Amp loads for every session,
$XDG_CONFIG_HOME/amp/plugins/ or ~/.config/amp/plugins/. Amp uses
that XDG path on every platform, so this does not use dirs::config_dir
(which is ~/Library/Application Support on macOS). Returns the path
written. Fails loudly, like the other agents’ installers: a swallowed
error would report success with no plugin in place.
Deep-merge the Codex hook set into <project_root>/.codex/hooks.json,
creating it if absent (idempotent, never clobbers existing hooks/keys,
atomic write). Repo-local counterpart of install_global_codex_hooks.
Install TraceVault’s Codex hooks into <codex_dir>/hooks.json and append a
workspace-mode instruction block to <codex_dir>/AGENTS.md (idempotent,
atomic), mirroring the Claude global install’s settings.json + CLAUDE.md.
Intended for tracevault init --global --agent codex. Codex reads AGENTS.md
for agent instructions, so the workspace-mode block reaches detached Codex
sessions the same way the CLAUDE.md block reaches Claude ones.
Install TraceVault’s Claude Code hooks into claude_dir/settings.json
(deep-merged, never clobbering existing hooks/keys) and append a
workspace-mode instruction block to claude_dir/CLAUDE.md (idempotent,
guarded by a marker comment). Intended for tracevault init --global,
installing once for all Claude Code sessions rather than per-repo.
Install the TraceVault OpenCode plugin. project_root = Some(dir) installs
project-local at <dir>/.opencode/plugins/tracevault.ts; None installs
global at ~/.config/opencode/plugins/tracevault.ts (using the same
config-dir resolution as gsd_extension_source_dir above). OpenCode
auto-loads *.ts modules from that directory — no separate “install”
command. Returns an error on failure (unresolvable config dir, or a write
error) so the caller aborts init loudly, consistent with the Codex/GSD arms
— a swallowed failure would make init report success while no plugin was
written, silently disabling capture.
init --global’s step of the default_project migration (VIS-1256: it
runs in init in any mode). A global install has no project config of its
own, so it migrates the config the hooks would read from the current
directory (resolve_project_root), if that config still carries a legacy
default_project. Runs before anything is installed: an unknown or
ambiguous name is an error; no login or an unreachable server is a warning
(the legacy key stays for a later sync).
The error init fails with when no credential resolves: what went wrong,
that nothing was installed, and the exact commands that fix it. url is
the server URL already known (--server-url, TRACEVAULT_SERVER_URL or
the project config), filled into the login command when present.
Validate init flag combinations against the selected agent. --claude-settings
selects between .claude/settings.json and settings.local.json, so it only
applies to the Claude Code agent — --agent codex always writes
.codex/hooks.json. Returns a human-readable error for an incompatible combo
so the CLI rejects it instead of silently ignoring the flag.
Write the user-level config.toml (under config_root) carrying the
user-context setting. An EXISTING user config is preserved (this mirrors the
“don’t clobber” contract of the global-hooks install): requested overrides
the user_context when a flag was given; otherwise an existing value is kept,
and only a first-time setup (no existing config) defaults to enabled.
When the resulting layer is enabled, the referenced context file is seeded
(empty) if absent — a custom --user-context <path> seeds THAT file, a
disabled layer seeds nothing. Returns the active context file path (the file
the hook will read), or None when the layer is disabled. Used by init --global.