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-lab/permissions

v1.0.0

Published

Permission system extension for pi coding agent

Downloads

877

Readme

@pi-lab/permissions

A permission system extension for pi coding agent. Intercepts tool calls and enforces allow / deny / ask rules defined in a JSON config file.

Install

pi install npm:@pi-lab/permissions

Configuration

Rules are configured in pi settings and merged into a single list:

  • ~/.pi/agent/settings.json — global
  • .pi/settings.json — project

Example settings.json:

{
  "permissions": {
    "rules": [
      {
        "message": "Block rm -rf",
        "priority": 10,
        "match": { "tool": "bash", "params": { "command": "rm\\s+-rf" } },
        "action": "deny"
      },
      {
        "match": { "tool": "bash", "params": { "command": "sudo" } },
        "action": "ask"
      },
      {
        "message": "Only allow reading files inside the project",
        "priority": 10,
        "match": { "tool": "read", "paths": ["~/projects/my-app/**"] },
        "action": "allow"
      },
      {
        "message": "read is restricted to allowed paths only",
        "match": { "tool": "read" },
        "action": "deny"
      }
    ]
  }
}

Rule fields

| Field | Type | Required | Description | | ----------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | match.tool | string | ✓ | Tool name, or "*" to match all tools | | match.params | object | — | Param name → regex pattern. All conditions must match. | | match.paths | string[] | — | Path patterns the tool's path argument must fall within. Supports glob (**, *) and plain directory prefixes. Supports ~ expansion. Pairs with a higher-priority allow rule to form a whitelist. | | match.pathParam | string | — | Which input key holds the path. Defaults to "path". | | action | string | ✓ | allow, deny, or ask | | priority | number | — | Defaults to 0. Higher values are evaluated first. | | message | string | — | Reason returned to the LLM when a call is blocked. |

Matching order

  1. Rules sorted by priority descending
  2. Same priority: deny > ask > allow

No match defaults to allow.

ask mode

A dialog prompts the user with four options:

  • Allow — allow this call once
  • Allow always — allow identical calls for the rest of the session (not persisted)
  • Deny — deny this call once
  • Deny always — deny identical calls for the rest of the session (not persisted)

Events

The extension broadcasts observational events on pi.events. Listeners cannot change permission decisions, cache behavior, or blocked responses.

Event names

  • permissions:deny — emitted whenever a tool call is blocked
  • permissions:ask — emitted immediately before a real user prompt is shown
  • permissions:user_select — emitted after the prompt resolves

Payloads

All payloads include the matched rule serialized with configured patterns only. Raw tool input is never broadcast.

type SerializedPermissionRule = {
  action: "allow" | "deny" | "ask";
  message?: string;
  priority?: number;
  match: {
    tool: string;
    params?: Record<string, string>;
    paths?: string[];
    pathParam?: string;
  };
};

type PermissionsDenyEvent = {
  toolCallId: string;
  toolName: string;
  reason: string;
  source: "rule" | "cache" | "user" | "no_ui";
  rule: SerializedPermissionRule;
};

type PermissionsAskEvent = {
  toolCallId: string;
  toolName: string;
  rule: SerializedPermissionRule;
  options: ["Allow", "Allow always", "Deny", "Deny always"];
};

type PermissionsUserSelectEvent = {
  toolCallId: string;
  toolName: string;
  selection: "Allow" | "Allow always" | "Deny" | "Deny always" | null;
  decision: "allow" | "deny";
  cached: boolean;
  rule: SerializedPermissionRule;
};

Privacy guarantee

Event payloads never include event.input or derived raw argument values such as shell commands, file paths, or file contents. The params and paths fields contain only the configured rule patterns.

Example listener

pi.events.on("permissions:deny", (event) => {
  console.log(event);
});