Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pi-switch

One-command switch between your default pi package set and everything-on, for the pi coding agent.

/sw        toggle: default ⇄ everything-on (auto /reload, no restart)
/sw save   store the current package state as your default

简体中文文档

Why

Every installed pi package adds its tool schemas, skills, and prompt guidelines to every new conversation. On my machine the fixed baseline cost looked like this:

State Context baseline per conversation
All packages on (incl. pi-subagents) ~13.6K tokens
pi-subagents off (default set) ~6.9K tokens

Heavy packages like pi-subagents are invaluable occasionally — and pure overhead the rest of the time. pi config toggles resources one checkbox at a time; pi-switch makes it a single keystroke.

Install

From GitHub:

pi install git:github.com/new595/pi-switch

Or from a local clone:

pi install /absolute/path/to/pi-switch

After installing, set up your default once:

  1. Configure your packages the lean way you like (e.g. disable pi-subagents in pi config, or just keep the defaults).
  2. Run /sw save — this writes the snapshot ~/.pi/agent/sw-default.json.

From then on /sw flips between that snapshot and everything-on. The switch persists: whichever state you leave is what every new session starts with.

How it works

  • The snapshot is just the packages array of ~/.pi/agent/settings.json, stored verbatim.
  • /sw compares the current packages against the snapshot by state: a package counts as "on" when written as a plain string or with a filter key omitted, and "off" only when a resource type is an empty filter []. Every other filter list (including pi's expanded per-file exclusions) is a distinct state of its own, so the toggle direction is always correct. If pi rewrote your config or you hand-tuned filters, the first /sw returns you to the saved default; the next one toggles to everything-on.
  • Direction rule: current config == snapshot → switch to everything-on; anything else → switch back to default (one-key home).
  • Packages missing from the snapshot are kept as-is instead of being dropped.

Complex-task reminder

When package resources are restricted, pi-switch adds one short model-side instruction to the system prompt—no tool schemas, skills, extra UI, or extra model turn. It asks the model to check with you before tool use only for clearly complex work that could materially benefit from disabled capabilities; ordinary Q&A and small edits proceed normally. If you choose full mode, run /sw until it reports everything on (use /sw save first if prompted), then say continue; the model cannot run slash commands itself. When everything is enabled, pi-switch injects nothing.

Notes & limitations

  • Only global settings (~/.pi/agent/settings.json) is managed; project-level .pi/settings.json is untouched.
  • Run /sw save again after installing or removing packages, so the snapshot stays complete.
  • Zero dependencies, zero configuration files beyond the snapshot.

Testing

node scripts/test-sw.mjs

Runs the extension in a sandboxed temp home against synthetic settings and covers snapshot handling, both switch directions, filter fingerprints, invalid input, new-package preservation, and the complex-task reminder guard.

License

MIT

About

Too many extensions and skills slowing down every conversation? Define your lean default set and toggle it with a single /sw — no more wasted tokens.快速关闭一些已经安装的插件和skill,让你的pi轻装上阵,只需输入/sw 即可。

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages