pi-extension-selector

内容来源:README.md(说明文档) · 原始地址 · 查看安装指南

原始内容

Pi Extension Selector

npm license

Switch Pi extensions without leaving Pi. pi-extension-selector adds an interactive /extensions screen for enabling installed package extensions, managing local extensions, and saving reusable profiles.

Install

Install it as a standard Pi package:

pi install npm:pi-extension-selector

Restart Pi or run /reload, then open the selector:

/extensions

Use Enter or Space to toggle an extension. Press Escape to save the selection and reload Pi with the new extension set.

Features

  • Discovers extension resources from npm packages already configured in Pi.
  • Keeps non-extension package resources, such as skills and themes, loaded when an extension is disabled.
  • Supports standalone .ts/.js extensions and Pi package directories in a local extension pool.
  • Saves named profiles so different coding workflows can use different extension sets.
  • Preserves unrelated entries in ~/.pi/agent/settings.json.
  • Keeps the selector itself permanently loaded, so it cannot disable its own recovery UI.

Profiles

Pass a profile name to create or switch extension sets:

/extensions coding
/extensions review
/extensions minimal

The active profile and its enabled extensions are stored in ~/.pi/agent/extension-selector.json. Applying a profile updates Pi's package extension filters and calls Pi's native reload lifecycle, so commands, tools, event handlers, and providers are rebuilt cleanly.

Local extension pool

For extensions that are not installed as npm packages, place them under ~/.pi/agent/extension-pool:

~/.pi/agent/extension-pool/
├── permission-gate.ts
├── subagent/
│   └── index.ts
└── my-package/
    ├── package.json
    └── src/index.ts

Package directories can declare one or more entry points with the standard Pi manifest:

{
  "pi": {
    "extensions": ["./src/index.ts"]
  }
}

The pool is intentionally outside ~/.pi/agent/extensions, because Pi automatically loads everything in that directory before the selector can apply a profile. To use another location, set poolDir in ~/.pi/agent/extension-selector.json; absolute paths, ~/..., and paths relative to ~/.pi/agent are supported.

How package switching works

Pi package objects accept a resource filter for each resource type. The selector disables only extension resources:

{
  "source": "npm:example-package",
  "extensions": []
}

When the package is enabled again, its previous configuration is restored. Skills, prompts, and themes from the same package are not removed.

Development

git clone https://github.com/PanCodeInventory/pi-extension-selector.git
cd pi-extension-selector
npm install
npm test
npm run typecheck

To load the checkout directly while developing:

mkdir -p ~/.pi/agent/extensions ~/.pi/agent/extension-pool
ln -s "$PWD" ~/.pi/agent/extensions/pi-extension-selector

The project targets Pi 0.80.6 or newer and Node.js 22.19.0 or newer.

License

MIT