npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vahor/pi-hooks

v0.0.11

Published

Run shell commands on pi lifecycle events.

Readme

@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:

| Location | Scope | |----------|-------| | ~/.pi/agent/hooks.json | Global hooks | | .pi/hooks.json | Project 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:

| Field | Type | Required | Default | Description | |-------|------|----------|---------|-------------| | command | string | Yes | – | Shell command to run | | cwd | string | No | project root | Working directory (relative) | | timeout | number | No | 30000 | Timeout in milliseconds | | print | boolean | No | true | Render command output in pi | | context | boolean | No | false | Add command output to the agent context | | interactive | boolean | No | false | Suspend 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.

| Hook | Description | |------|-------------| | session_start | Session initialized and ready | | session_before_switch | Before switching to a different session | | session_before_fork | Before forking the session | | session_before_compact | Before compacting session context | | session_compact | Session context compacted | | session_before_tree | Before generating the session tree | | session_tree | Session tree generated | | session_shutdown | Session is shutting down | | before_agent_start | Before the agent starts processing | | agent_start | Agent has started | | agent_end | Agent has finished | | turn_start | A new turn begins | | turn_end | The current turn ends | | message_start | A message (user or assistant) begins | | message_update | A message is updated in place | | message_end | A message is complete | | tool_execution_start | A tool execution begins | | tool_execution_update | Tool execution output is updated | | tool_execution_end | Tool execution finishes | | context | Context is provided to the model | | before_provider_request | Before sending a request to the model provider | | after_provider_response | After receiving a response from the model provider | | model_select | A model is selected | | thinking_level_select | Thinking level is selected | | tool_call | Assistant requests a tool call | | tool_result | Tool result is received | | input | User submits input | | resources_discover | Resources are discovered |