Files
bot/docs/cli/hooks.md
zeekayandHanzo Dev 84e4069c2c docs name the state dir and config file the bot reads: ~/.bot/bot.json
The docs said ~/.hanzo-bot/hanzo-bot.json (and ~/.hanzo-bot-<profile>, hanzo-bot.plugin.json), which nothing reads: src/config/paths.ts resolves ~/.bot, bot.json and ~/.bot-<profile>, and plugins ship bot.plugin.json. Every such path in docs/ now names what the code opens.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-24 21:12:09 -07:00

6.1 KiB
Raw Permalink Blame History

summary, read_when, title
summary read_when title
CLI reference for `hanzo-bot hooks` (agent hooks)
You want to manage agent hooks
You want to install or update hooks
hooks

hanzo-bot hooks

Manage agent hooks (event-driven automations for commands like /new, /reset, and gateway startup).

Related:

List All Hooks

hanzo-bot hooks list

List all discovered hooks from workspace, managed, and bundled directories.

Options:

  • --eligible: Show only eligible hooks (requirements met)
  • --json: Output as JSON
  • -v, --verbose: Show detailed information including missing requirements

Example output:

Hooks (4/4 ready)

Ready:
  🚀 boot-md ✓ - Run BOOT.md on gateway startup
  📎 bootstrap-extra-files ✓ - Inject extra workspace bootstrap files during agent bootstrap
  📝 command-logger ✓ - Log all command events to a centralized audit file
  💾 session-memory ✓ - Save session context to memory when /new command is issued

Example (verbose):

hanzo-bot hooks list --verbose

Shows missing requirements for ineligible hooks.

Example (JSON):

hanzo-bot hooks list --json

Returns structured JSON for programmatic use.

Get Hook Information

hanzo-bot hooks info <name>

Show detailed information about a specific hook.

Arguments:

  • <name>: Hook name (e.g., session-memory)

Options:

  • --json: Output as JSON

Example:

hanzo-bot hooks info session-memory

Output:

💾 session-memory ✓ Ready

Save session context to memory when /new command is issued

Details:
  Source: hanzo-bot-bundled
  Path: /path/to/hanzo-bot/hooks/bundled/session-memory/HOOK.md
  Handler: /path/to/hanzo-bot/hooks/bundled/session-memory/handler.ts
  Homepage: https://docs.hanzo-bot.ai/automation/hooks#session-memory
  Events: command:new

Requirements:
  Config: ✓ workspace.dir

Check Hooks Eligibility

hanzo-bot hooks check

Show summary of hook eligibility status (how many are ready vs. not ready).

Options:

  • --json: Output as JSON

Example output:

Hooks Status

Total hooks: 4
Ready: 4
Not ready: 0

Enable a Hook

hanzo-bot hooks enable <name>

Enable a specific hook by adding it to your config (~/.bot/config.json).

Note: Hooks managed by plugins show plugin:<id> in hanzo-bot hooks list and can’t be enabled/disabled here. Enable/disable the plugin instead.

Arguments:

  • <name>: Hook name (e.g., session-memory)

Example:

hanzo-bot hooks enable session-memory

Output:

✓ Enabled hook: 💾 session-memory

What it does:

  • Checks if hook exists and is eligible
  • Updates hooks.internal.entries.<name>.enabled = true in your config
  • Saves config to disk

After enabling:

  • Restart the gateway so hooks reload (menu bar app restart on macOS, or restart your gateway process in dev).

Disable a Hook

hanzo-bot hooks disable <name>

Disable a specific hook by updating your config.

Arguments:

  • <name>: Hook name (e.g., command-logger)

Example:

hanzo-bot hooks disable command-logger

Output:

⏸ Disabled hook: 📝 command-logger

After disabling:

  • Restart the gateway so hooks reload

Install Hooks

hanzo-bot hooks install <path-or-spec>
hanzo-bot hooks install <npm-spec> --pin

Install a hook pack from a local folder/archive or npm.

Npm specs are registry-only (package name + optional version/tag). Git/URL/file specs are rejected. Dependency installs run with --ignore-scripts for safety.

What it does:

  • Copies the hook pack into ~/.bot/hooks/<id>
  • Enables the installed hooks in hooks.internal.entries.*
  • Records the install under hooks.internal.installs

Options:

  • -l, --link: Link a local directory instead of copying (adds it to hooks.internal.load.extraDirs)
  • --pin: Record npm installs as exact resolved name@version in hooks.internal.installs

Supported archives: .zip, .tgz, .tar.gz, .tar

Examples:

# Local directory
hanzo-bot hooks install ./my-hook-pack

# Local archive
hanzo-bot hooks install ./my-hook-pack.zip

# NPM package
hanzo-bot hooks install @hanzo/bot-my-hook-pack

# Link a local directory without copying
hanzo-bot hooks install -l ./my-hook-pack

Update Hooks

hanzo-bot hooks update <id>
hanzo-bot hooks update --all

Update installed hook packs (npm installs only).

Options:

  • --all: Update all tracked hook packs
  • --dry-run: Show what would change without writing

When a stored integrity hash exists and the fetched artifact hash changes, HanzoBot prints a warning and asks for confirmation before proceeding. Use global --yes to bypass prompts in CI/non-interactive runs.

Bundled Hooks

session-memory

Saves session context to memory when you issue /new.

Enable:

hanzo-bot hooks enable session-memory

Output: ~/.bot/workspace/memory/YYYY-MM-DD-slug.md

See: session-memory documentation

bootstrap-extra-files

Injects additional bootstrap files (for example monorepo-local AGENTS.md / TOOLS.md) during agent:bootstrap.

Enable:

hanzo-bot hooks enable bootstrap-extra-files

See: bootstrap-extra-files documentation

command-logger

Logs all command events to a centralized audit file.

Enable:

hanzo-bot hooks enable command-logger

Output: ~/.bot/logs/commands.log

View logs:

# Recent commands
tail -n 20 ~/.bot/logs/commands.log

# Pretty-print
cat ~/.bot/logs/commands.log | jq .

# Filter by action
grep '"action":"new"' ~/.bot/logs/commands.log | jq .

See: command-logger documentation

boot-md

Runs BOOT.md when the gateway starts (after channels start).

Events: gateway:startup

Enable:

hanzo-bot hooks enable boot-md

See: boot-md documentation