← Catalog

@vahor/pi-hooks

Run shell commands on pi lifecycle events.

Extension

Install

Install with PiG

pig install npm:@vahor/pi-hooks

Install with Pi

pi install npm:@vahor/pi-hooks
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./dist/index.js"
  ]
}

README

Written by the package's publisher, shown as published in version 0.0.11 (README.md). PiG does not review it.

@vahor/pi-hooks

npm downloads

Run shell commands in response to pi events.

pi install npm:@vahor/pi-hooks
// .pi/hooks.json
{
  "hooks": {
    "agent_end": ["bun format", "bun typecheck"],
    "session_start": [{ "command": "echo 'session start'", "print": true }]
  }
}

Config locations

Configuration is loaded from both locations and merged recursively:

LocationScope
~/.pi/agent/hooks.jsonGlobal hooks
.pi/hooks.jsonProject hooks; overrides global values

If neither file exists, the extension creates .pi/hooks.json with an empty config and a $schema field for editor validation.

Each entry can be a string (just the command) or an object:

FieldTypeRequiredDefaultDescription
commandstringYes–Shell command to run
cwdstringNoproject rootWorking directory (relative)
timeoutnumberNo30000Timeout in milliseconds
printbooleanNotrueRender command output in pi
contextbooleanNofalseAdd command output to the agent context
interactivebooleanNofalseSuspend pi's TUI and run with full terminal access. Use for commands like lazygit, vim, htop, or fzf. Output is not captured.

Command output is rendered in pi when print or context is enabled. Interactive commands restore and fully redraw pi after they exit.

Available hooks

These correspond to pi lifecycle events.

HookDescription
session_startSession initialized and ready
session_before_switchBefore switching to a different session
session_before_forkBefore forking the session
session_before_compactBefore compacting session context
session_compactSession context compacted
session_before_treeBefore generating the session tree
session_treeSession tree generated
session_shutdownSession is shutting down
before_agent_startBefore the agent starts processing
agent_startAgent has started
agent_endAgent has finished
turn_startA new turn begins
turn_endThe current turn ends
message_startA message (user or assistant) begins
message_updateA message is updated in place
message_endA message is complete
tool_execution_startA tool execution begins
tool_execution_updateTool execution output is updated
tool_execution_endTool execution finishes
contextContext is provided to the model
before_provider_requestBefore sending a request to the model provider
after_provider_responseAfter receiving a response from the model provider
model_selectA model is selected
thinking_level_selectThinking level is selected
tool_callAssistant requests a tool call
tool_resultTool result is received
inputUser submits input
resources_discoverResources are discovered