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

@leo-alvarenga/pi-agent-manager

v0.18.2

Published

A package for managing agents in Pi

Downloads

948

Readme

@leo-alvarenga/pi-agent-manager

A pi-coding-agent extension providing persona-based agent switching and OpenCode-style permission guards.

Each agent combines a system prompt persona with a permission ruleset that resolves tool executions into three actions:

  • deny: Physically disables tools via pi.setActiveTools() so the model never sees them.
  • ask: Pauses execution and prompts for interactive user confirmation (once, always, or reject).
  • allow: Permits immediate tool execution without confirmation.

How It Works

  1. Tool Stripping: On startup or agent switch, the extension evaluates the active agent's ruleset. Tools matched with deny rules are filtered out entirely via pi.setActiveTools()
  2. Prompt Injection: The active agent's system prompt (and optional XML permission envelope) is prepended to the system prompt before each conversation turn
  3. Interactive Gate: When a tool configured with ask is invoked, the user is prompted to allow or deny the call. Allowing then asks whether to remember the decision ("always") for the rest of the session, which appends a runtime rule to the session state.

Built-In Agents

| Agent | Description | Default Ruleset Summary | | ------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | | planner 󱞁 | Analysis and inspection profile; cannot modify files or execute shell commands. | read, grep, glob, list, websearch, webfetch, task, todo, and all context-mode tools except ctx_execute / ctx_execute_file / ctx_batch_execute allowed; edit, bash, and context-mode exec tools denied. | | builder 󱁤 | Execution-oriented profile; unrestricted file changes and commands, but web tools are unavailable. | All tools allowed except websearch and webfetch (denied); destructive commands (rm, sudo, chmod, chown) trigger ask. |


Installation

Install via the pi package manager:

pi install npm:@leo-alvarenga/pi-agent-manager

After installation, restart pi or execute /reload within the TUI.


Commands & Keybindings

TUI Commands

| Command | Description | | ------------------------- | ---------------------------------------------------------------------------- | | /agents | Opens the interactive agent selection picker | | /agents <name> | Switches directly to the specified agent (supports tab-completion) | | /agents_help | Shows agent list, permissions, keybindings, and usage | | /agent_guard [on / off] | Toggles XML permission-envelope system prompt injection (toggles if omitted) |

Note: Selected agents persist across sessions and are restored upon restarting

Custom Keybindings

Configure shortcuts in ~/.pi/agent/keybindings.json:

{
  "piAgentManager.next": "shift+tab",
  "piAgentManager.previous": "ctrl+shift+alt+p",
  "piAgentManager.picker": "ctrl+shift+alt+a"
}

Run /reload after updating keybindings.


Permission Engine

The permission engine evaluates { permission, pattern } pairs against defined rulesets.

Evaluation Order: Rules are evaluated top-to-bottom in definition order, where the last matching rule takes precedence. If no rule matches an invoked tool, the default fallback is ask.

Permission Mappings

| Key | Mapped Pi Tools | | ----------- | -------------------------------------------------------------- | | read | read, hash_read | | grep | grep | | glob | find | | list | ls | | edit | write, edit, delete_file, hash_edit | | bash | bash, shell, run, exec | | websearch | web_search, source_check, get_search_content | | webfetch | fetch_content | | task | subagent, subagent_wait, subagent_supervisor, intercom | | question | questionnaire, ask_user_question |

Unlisted custom or MCP tools map directly to their exact tool name.


Custom Agents

Add custom agent definition files (.md) with YAML frontmatter to ~/.pi/agent/agents/:

---
name: reviewer
description: Reviews code for quality, performance, and security issues
permissions:
  "*": deny
  read: allow
  grep: allow
  glob: allow
  list: allow
  websearch: allow
icon: ★
color: success
---

You are a Code Reviewer: focus on security, performance, and maintainability.
Read freely and suggest improvements, but never edit files or run commands.

Frontmatter Schema

| Field | Required | Description | | ------------- | -------- | ---------------------------------------------------------------------------- | | description | Yes | Short summary displayed in the selection picker and help views. | | permissions | Yes | Preset name (plan, build, read), ruleset array, or full rule object. | | name | No | Unique identifier (defaults to filename without .md). | | type | No | primary (default) or subagent. | | icon | No | Display icon/glyph placed before the agent name. | | color | No | Theme color token (accent, success, warning, error, info, dim). | | hidden | No | Set to true to exclude from cycle shortcuts and the picker menu. | | steps | No | Maximum tool execution turns permitted before requesting a response summary. | | prompt | No | Overrides markdown body text as the system prompt instructions. |

Permission Definition Formats

1. Preset Strings

permissions: plan # Read/web/subagent allowed; edit and bash denied
permissions: build # Full access; destructive bash commands gated with ask
permissions: read # Inspection tools only

2. Legacy Array (Auto-converted to ruleset)

permissions: [read, web, ask]

3. Full Ruleset Object (OpenCode Compatible)

permissions:
  "*": deny
  read: allow
  grep: allow
  glob: allow
  list: allow
  websearch: allow
  bash:
    "*": deny
    "npm test*": allow
    "npm run build*": allow

Directory Layout

src/
├── index.ts              # Extension entry point, lifecycle hooks, and commands
├── constants.ts          # Key definitions, default values, and XML tags
├── agent/
│   ├── types.ts          # Agent state, configuration, and type definitions
│   ├── builtin.ts        # Default built-in agent definitions
│   ├── manager.ts        # Agent state machine and tool guard enforcement
│   └── config.ts         # User markdown agent and keybinding loaders
├── permission/
│   ├── types.ts          # Ruleset schemas, actions, and evaluation types
│   ├── evaluate.ts       # Core rule evaluation algorithms and state merging
│   ├── wildcard.ts       # Glob pattern matching engine
│   ├── mapping.ts        # Built-in tool-to-permission maps
│   └── presets.ts        # Preset profiles and legacy format converters
└── cli/
    ├── picker.ts         # Interactive TUI selection interface
    ├── help.ts           # Help renderer, permission badges, and validators
    └── logger.ts         # Wrapper for pi notification rendering