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-mpc

v1.0.0

Published

MPC (Mental Preview & Correction) extension for pi coding agent — rehearse and verify before any code is written

Readme

pi-mpc

MPC — Mental Preview & Correction for pi coding agent

A pi extension that forces the LLM to fully rehearse a task before touching a single file. It explores the codebase, dry-runs every change, hunts for type errors and broken imports, backtracks to fix them, and only then surfaces a structured Verified Plan for you to approve — or discard.


Why MPC?

Normal agents interleave thinking and writing. They guess, edit, re-guess, and leave a trail of partial fixes behind. MPC introduces a mandatory rehearse → verify loop:

explore → dryrun → issues → (backtrack →) verified → execute

All tool calls before execute are read-only. Nothing is written until the plan passes verification and you say go.


Phases

| # | Phase | What happens | Tools | |---|-------|-------------|-------| | 1 | explore | Read files, grep patterns, identify everything that needs to change | read-only | | 2 | dryrun | Narrate each edit step-by-step; predict the result of every change | read-only | | 3 | issues | Actively check for type errors, broken imports, failing tests, wrong assumptions | read-only | | 4 | backtrack | Fix identified issues, revise the plan (up to 2 rounds) | read-only | | 5 | verified | Output a structured final plan with Assumptions, Steps, Risks, and Confidence | read-only | | 6 | execute | User confirms → execute the verified plan with full tool access | full |

Automatic phase transitions

Each phase ends when the LLM emits a phase marker; the extension detects it and advances automatically:

| Marker | Transition | |--------|-----------| | EXPLORATION COMPLETE: … | → dryrun | | DRY RUN COMPLETE: … | → issues | | NO ISSUES FOUND | → verified (skips backtrack) | | ISSUE N: … | → backtrack (or force → verified after max retries) | | REVISED PLAN: … | → verified |


Install

pi install npm:pi-mpc

Or add to your project settings (.pi/settings.json) so teammates get it automatically:

{
  "packages": ["npm:pi-mpc"]
}

Commands

| Command | Description | |---------|-------------| | /mpc | Toggle MPC mode on / off | | /mpc-next | Manually advance to the next phase (fallback when the LLM misses a marker) | | /mpc-resume | Resume the most recent in-progress plan from disk | | /mpc-status | Show current phase and plan file path |

Shortcut: Ctrl + Alt + M — toggle MPC mode


Typical workflow

1.  /mpc                      ← enable MPC
2.  Refactor UserService to support async interfaces
     │
     ├─ [explore]   reads files, maps dependencies
     ├─ [dryrun]    narrates every edit, traces types
     ├─ [issues]    finds a missing export in utils.ts → ISSUE 1
     ├─ [backtrack] revises plan to add the export
     └─ [verified]  outputs structured plan + confidence rating
     │
3.  ❯  Execute the plan   ← you pick one
       Refine further
       Abort

Safety — read-only phases

During phases 1–4, edit and write are unavailable. bash calls are intercepted and must match a safe-command allowlist (cat, grep, git status, ls, etc.). Destructive patterns are blocked:

  • File writes (>, >>, tee, truncate)
  • File mutations (rm, mv, cp, mkdir)
  • Package installs (npm install, pip install, brew install, …)
  • Git writes (commit, push, merge, rebase, …)
  • System ops (sudo, kill, reboot, …)

Any blocked command returns an error explaining why, with a hint to use /mpc-next or /mpc to abort.


Plan persistence

Every MPC session is saved to disk automatically:

<project>/.pi/mpc/<timestamp>-<task-slug>.md

The file is human-readable Markdown (with phase outputs) plus a machine-readable JSON block at the bottom. Use /mpc-resume in any new session to pick up where you left off — the LLM skips completed phases and continues from the breakpoint.


Verified Plan format

When the LLM reaches phase 5 it outputs a structured plan:

## Verified Plan

### Summary
One paragraph: what this does and why.

### Assumptions Verified
- [assumption]: [how it was verified]

### Steps
1. **[File / Action]**: [what and why]
2. …

### Potential Risks
- [remaining unknowns or caveats]

### Confidence
HIGH / MEDIUM / LOW: [reason]

Mode comparison

| Feature | Normal agent | Plan mode | MPC | |---------|-------------|-----------|-----| | Trigger | direct chat | /plan · Ctrl+Alt+P | /mpc · Ctrl+Alt+M | | Workflow | think → act (interleaved) | explore → plan → execute | explore → dryrun → issues → (backtrack) → verified → execute | | Phases | none | 2 | up to 6, auto-advancing | | Tool lock | full always | read-only during explore | read-only until execute | | Issue detection | ✗ | ✗ | ✓ dedicated phase | | Auto-backtrack | ✗ | ✗ | ✓ up to 2 rounds | | Plan format | none | numbered list | structured (Assumptions / Risks / Confidence) | | Plan persisted | ✗ | session only | ✓ .pi/mpc/*.md, cross-session resume | | Confirm before execute | — | Execute / Stay / Refine | Execute / Refine / Abort | | Best for | quick edits | medium complexity | high-risk · multi-file · unfamiliar codebases |


File structure

mpc/
├── index.ts      # entry point: commands, events, state machine
├── phases.ts     # phase labels + per-phase LLM prompts
├── persist.ts    # plan persistence (.pi/mpc/*.md read/write)
└── utils.ts      # types, marker detection, text helpers

Package this for npm

To publish as an npm package so others can pi install npm:pi-mpc:

package.json

{
  "name": "pi-mpc",
  "version": "1.0.0",
  "description": "MPC (Mental Preview & Correction) extension for pi coding agent",
  "type": "module",
  "license": "MIT",
  "keywords": ["pi-package", "pi-extension", "mpc", "plan-mode", "coding-agent"],
  "pi": {
    "extensions": ["./index.ts"]
  },
  "files": [
    "index.ts",
    "phases.ts",
    "persist.ts",
    "utils.ts",
    "README.md"
  ],
  "peerDependencies": {
    "@mariozechner/pi-coding-agent": "*",
    "@mariozechner/pi-tui": "*"
  }
}

Then:

npm publish --access public

Consumers install with:

pi install npm:pi-mpc

Contributing

Issues and PRs welcome at github.com/ShawnRong/pi-mpc.


License

MIT