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.
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.