Skip to main content

Module init

Module init 

Source

Enums§

ClaudeSettingsTarget
Which Claude Code settings file to install hooks into.

Functions§

codex_hooks
Codex CLI hook set, mirroring tracevault_hooks() but with Codex commands. Capture hooks carry --agent codex; the injection hooks (session-start / user-prompt) are agent-agnostic. Matchers are "" (all tools).
git_remote_url
init_in_directory
install_codex_hooks
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_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_global_hooks
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.
tracevault_hooks
validate_init_flags
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_global_user_config_in
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.