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

@pi-kit/permissions

v0.5.0

Published

Allow/ask/deny guardrail extension for the Pi coding agent. No third-party runtime dependencies.

Readme

@pi-kit/permissions

An allow / ask / deny guardrail for the Pi coding agent's tools, built-in and MCP. No third-party runtime dependencies, no build step, small enough to read before you install it. It guards against agent mistakes; it is not a sandbox (see Limitations).

Install

pi install npm:@pi-kit/permissions

Restart Pi. With no configuration, the defaults apply.

What it does

Every tool call resolves to one outcome:

  • allow — the call runs.
  • ask — you choose Allow once, Allow for this session, Allow commands starting with "…" for this session (shell commands only), Deny, or Deny with message…, which asks for a note and passes it to the model with the block reason (an empty note is a plain Deny). With no UI (pi -p), ask becomes headlessAsk, which defaults to deny.
  • deny — the call is blocked and the model is told which rule fired.

Rules match on four dimensions:

| Dimension | Matches | Pattern syntax | |---|---|---| | bash | the command of bash and powershell | anchored; * matches anything, including spaces and / | | paths | path inputs of the tools in paths.appliesTo | anchored; * stays within a segment, ** crosses; ~ expands; relative patterns resolve against cwd; checked against the path as written and its absolute form | | tools | the tool name | exact, or * matches any characters | | outsideCwd | any path outside cwd, for the tools in paths.appliesTo | a single allow / ask / deny |

Configuration

JSON, one file per scope. Every key is optional.

| Scope | Path | |---|---| | Global | ~/.pi/agent/extensions/pi-kit-permissions.json (honours PI_CODING_AGENT_DIR) | | Project | <cwd>/.pi/extensions/pi-kit-permissions.json, loaded only when the project is trusted |

Defaults

{
  "defaultMode": "allow",
  "headlessAsk": "deny",
  "outsideCwd": "ask",
  "tools": {},
  "bash": {
    "deny": ["rm -rf *", "git push --force*", "git reset --hard*"],
    "ask": ["npm publish*", "git push*"],
    "allow": []
  },
  "paths": {
    "appliesTo": ["write", "edit"],
    "deny": [".env", ".env.local", ".env.*.local", "**/.env", "**/.env.local"],
    "ask": [
      ".github/**",
      ".git/**",
      ".pi/**",
      ".husky/**",
      ".vscode/**",
      ".npmrc",
      "~/.bashrc",
      "~/.bash_profile",
      "~/.bash_login",
      "~/.profile",
      "~/.zshenv",
      "~/.zshrc",
      "~/.zprofile",
      "~/.zlogin",
      "~/.gitconfig",
      "~/.config/git/config",
      "~/.npmrc"
    ],
    "allow": []
  }
}

Under the defaults, read /etc/hosts is allowed (read is not in appliesTo), write /etc/hosts asks, and write .env.example is allowed (the deny patterns are deliberately narrow). Writes under .git/ (hooks run as code) and .pi/ (project extensions and this package's own project config) ask. Writes under .husky/ and .vscode/, to .npmrc, and to shell, git and npm config in your home folder also ask, including through shell redirects and tee.

Keys

| Key | Values | Meaning | |---|---|---| | defaultMode | allow ask deny | Outcome when no rule matches | | headlessAsk | allow deny | What ask becomes with no UI | | outsideCwd | allow ask deny | Outcome for a path outside cwd; allow disables the check | | tools, bash | { deny, ask, allow } | Pattern lists | | paths | { appliesTo, deny, ask, allow } | appliesTo names the tools these rules and outsideCwd cover |

Combining scopes

Defaults, then global, then the trusted project file.

  • Rule lists add up. No scope can remove an inherited rule.
  • The global file overwrites scalars. defaultMode, headlessAsk, outsideCwd, and paths.appliesTo take the global value when it sets them.
  • A project can only tighten. Its scalars apply only when stricter than the inherited value (deny > ask > allow), and its paths.appliesTo adds tools rather than replacing the list. A looser value is ignored and named in the footer banner. Its allow rules still apply.
  • To relax a global rule, edit the global file.

A file that fails to parse or validate contributes no rules, is named in a footer banner, and forces defaultMode: ask and headlessAsk: deny for the session. Fix it and start a new session.

Precedence

  1. Within a dimension, lists are checked deny → ask → allow; the first match wins. Specificity is ignored: deny: ["git *"] beats allow: ["git status"].
  2. Across dimensions, the most restrictive result wins: deny > ask > allow. No match anywhere yields defaultMode.
  3. Compound commands (split on unquoted &&, ||, ;, |, &, newline): deny and ask also match each piece; allow matches only the whole command. A piece can make the outcome stricter, never looser. Deny and ask also match each piece after collapsing whitespace and stripping leading VAR= assignments and the wrappers timeout, time, nice, nohup, stdbuf, command, builtin, noglob, env, sudo, doas. allow does not: allow: ["npm test"] does not cover timeout 30 npm test. Flag values after a wrapper are not skipped, so sudo -u root rm -rf x is not caught. For rm, deny and ask also match a normalized form: short flags in any cluster or order and the long forms --recursive and --force (-fr, -Rf, -r -f, --recursive --force) read as rm -rf. Abbreviated long options such as --recur are not recognised.
  4. Shell path targets: redirect targets and the file arguments of cat, head, tail, sed and tee are checked against paths.deny and paths.ask as the tool they imitate (> and tee = write, sed -i = edit, the rest = read), and only when that tool is in appliesTo. These checks can only make the outcome stricter. Path allow and outsideCwd do not apply to them.

| Situation | Outcome | |---|---| | bash.allow matches, defaultMode: deny | allow | | tools.allow: ["write"], write /etc/hosts, outsideCwd: ask | ask | | bash.deny matches one piece of a && b, bash.allow the other | deny | | bash.allow: ["ls"], defaultMode: deny, command ls && curl x | deny | | echo K=v >> .env under the defaults | deny |

These rows are executed by test/decide.test.ts.

Session approvals

Allow for this session remembers the exact request (tool, command, paths as written). For a tool with no command or path, such as an MCP tool, that is the tool name alone, so the approval covers every later call to that tool, whatever its arguments. For bash and powershell, Allow commands starting with "…" remembers a prefix instead: the command name plus a subcommand-like second word, so git push origin main offers git push. A prefix covers that prefix followed by any arguments, but only when the command contains none of ; & | < > $ ` ( ) { } \, a newline or a carriage return; anything else prompts as usual.

Approvals are saved in the Pi session file and restored on reload and resume of that session, in the same directory; deleting the session deletes them. Allow once and Deny are not saved. If saving fails, the approval still applies, with a warning. Approvals are consulted only after the rules return ask, so they never override a deny.

Status command

/permissions shows the settings in force, then each configuration layer (built-in defaults, the global file, the project file) with its own rules and the file's path and status: loaded, not found, invalid (ignored) or untrusted (not read). It also lists the requests allowed for this session and any config problems. It reflects the configuration loaded at session start, appears in the chat, and is not sent to the model.

Recipes

Gate reads too:

{ "paths": { "appliesTo": ["read", "write", "edit", "ls", "grep", "find"] } }

Protect secrets outside the repo:

{ "paths": { "appliesTo": ["read", "write", "edit"], "deny": ["~/.ssh/**", "~/.aws/**"] } }

Ask before git and network operations:

{ "bash": { "ask": ["git push*", "git rebase*", "curl *", "wget *", "npm install*"] } }

Ask before the tools of one MCP server, matched by name prefix, and block its delete tools:

{ "tools": { "deny": ["mcp__github__delete_*"], "ask": ["mcp__github__*"] } }
  • Rules match the name Pi registers a tool under, mcp__<server>__<tool>, built from the server's configured name and the tool name the server offers. In both, every character other than letters, digits and _ becomes _, so server dev-radius is written mcp__dev_radius__*. /mcp lists the tool name the server offers, not the registered name.
  • The pattern matches a name prefix, not a server: mcp__github__* also matches the tools of a server whose name starts with github__, such as github__prod.
  • Pi shortens a registered name longer than 64 characters and adds a hash suffix, so a mcp__<server>__* rule can miss the tools of a server whose name is about 50 characters or longer.

Ask by default, allowing only these exact commands:

{
  "defaultMode": "ask",
  "bash": { "allow": ["ls", "git status", "git diff", "git log", "pnpm test"] }
}

Prefer complete commands in allow. A trailing * also matches chained commands: ls* allows ls && curl https://example.com/script | sh unless a deny or ask rule matches.

Limitations

This is a guardrail against agent mistakes, not a security boundary. For enforcement, run Pi in a container or an OS sandbox.

  • Not caught: forms whose only purpose is evasion — bash -c, eval, $(...), backticks, $VAR, /bin/rm, xargs, find -exec.
  • Not parsed: text inside subshells; $HOME in paths; a relative path after cd (it still resolves against cwd); cp/mv destinations; heredoc bodies, which are scanned like commands and can over-match; symlinks.
  • MCP resources: Pi's resource tools read_mcp_resource, list_mcp_resources and list_mcp_resource_templates reach every server and are not covered by mcp__* or a mcp__<server>__* rule; deny them by exact name to block resources from all servers.
  • RPC clients receive ask as an extension UI request and must answer it; an unanswered request leaves the tool call waiting (cancel = deny).

Supported versions

Node 22.19 or newer. Pi: no minimum version; recent Pi releases are tested weekly — latest results.

Dependencies

@pi-kit/shared, pinned to an exact version, and nothing third-party. @earendil-works/pi-coding-agent and typebox are optional peers that Pi supplies; scanner alerts on them belong to the Pi host.

More from pi-kit

Part of pi-kit, extensions that bring the most useful features shared by Claude Code and Codex to the Pi coding agent.

| Package | What it does | |---|---| | @pi-kit/rewind | Rewind code and conversation to an earlier prompt |

Licence

MIT