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

@michalkvasnicak/pi-hooks

v0.1.0

Published

Configurable hooks for Pi: block or nudge tool calls and run repository checks before the agent finishes.

Readme

@michalkvasnicak/pi-hooks

Configurable hooks for Pi: block or nudge tool calls and run repository checks before the agent finishes.

  • Block tool calls or add guidance to their results using glob-based rules.
  • Run commands or TypeScript scripts before the agent finishes, with automatic retries on failure.
  • Skip checks when their configured input files haven't changed.

Development

pnpm install
pnpm check
pi --extension ./src/index.ts

The package manifest points Pi package discovery at src/index.ts.

Repository checks

The extension reads .pi/pi-hooks.json first, then .pi-hooks.json from the current repository root. The config is validated against the Zod schema in src/config.ts; config.schema.json documents the JSON format.

{
  "$schema": "./config.schema.json",
  "hooks": {
    "tool_call": {
      "rules": [
        { "match": { "tool": "bash", "arguments": { "command": "*rm -rf*" } }, "action": "block", "reason": "Destructive shell commands are not allowed." },
        { "match": { "tool": "read", "arguments": { "path": "**/.env*" } }, "action": "nudge", "text": "Avoid reading secrets; use documented configuration instead." }
      ]
    },
    "agent_before_settle": {
      "failFast": true,
      "maxRetries": 5,
      "checks": [
        { "name": "Lint", "type": "command", "command": "pnpm lint" },
        { "type": "script", "path": ".pi-hooks/check.ts" }
      ]
    }
  }
}

Tool-call rules

Rules match tool names and string arguments using glob patterns. All patterns in a rule must match.

  • block prevents the call and tells the agent why.
  • nudge lets the call run and adds guidance to its result.

Rules run in order. The first matching block stops the call; blocked calls receive no nudges.

Checks before finishing

  • Commands run in the repository root. A non-zero exit code fails the check.
  • Scripts use repository-relative paths and default-export an async function receiving { cwd, event }. Throw an error or return a non-empty string to fail. Script edits are picked up on the next run.

Failures go back to the agent so it can fix them. maxRetries limits retries (default: 5). failFast stops at the first failure (default: true); set it to false to run all checks.

Skip unchanged checks

Add inputs with repository-relative glob patterns to run a check only when matching files change or are deleted. Checks without inputs always run. The cache lasts until the extension restarts.