init
bunx @pivanov/agent-hooks-bridge init [<path>] [options]Scaffold a starter hook script and wire it into all three host configs in one step. Useful for the first-time setup; after that, edit the generated script and re-run install if you change paths or scope.
Usage
# default: writes ./.hooks/format.ts and runs install
bunx @pivanov/agent-hooks-bridge init
# custom path
bunx @pivanov/agent-hooks-bridge init ./hooks/guard.ts
# scaffold only; do not run install
bunx @pivanov/agent-hooks-bridge init --no-install
# overwrite an existing file
bunx @pivanov/agent-hooks-bridge init --force
# preview the template + the would-be install plan; touches no files
bunx @pivanov/agent-hooks-bridge init --dry-runOptions
| Flag | Default | Notes |
|---|---|---|
<path> (positional) | ./.hooks/format.ts | Where to write the starter hook (relative to --cwd). |
--force | off | Overwrite the file if it already exists. |
--dry-run | off | Print the template + the install plan; nothing is written. |
--no-install | off | Scaffold only; skip the install step. |
--cwd <path> | process.cwd() | Run relative to this directory. |
--help, -h | Print usage. |
What gets scaffolded
A no-op hook script with handlers for all five unified events, the rm -rf deny example from the README, and a #!/usr/bin/env bun shebang. The file is created with mode 0o755 so the host can spawn it directly.
After scaffolding
Edit the generated script. If you change the file path or which events you want it wired to, re-run install to update the host configs:
bunx @pivanov/agent-hooks-bridge install ./.hooks/format.ts --events PreToolUse,PostToolUseinit always writes to all three hosts in project-local mode. To wire only to hosts you actually have installed, or to install into a user-level (global) config, run init --no-install first and then drive install with the flags you want:
bunx @pivanov/agent-hooks-bridge init --no-install
bunx @pivanov/agent-hooks-bridge install ./.hooks/format.ts --hosts auto
# or:
bunx @pivanov/agent-hooks-bridge install ~/scripts/format.ts --globalOr run doctor to verify the install picked up your edits:
bunx @pivanov/agent-hooks-bridge doctorProgrammatic API
import { runInit } from "@pivanov/agent-hooks-bridge";
const exitCode = await runInit({ argv: ["./.hooks/format.ts"] });The CLI is a thin wrapper around runInit. The fs and log options follow the same shape as runInstall, plus a fileExists and chmod for the scaffold step.