Plan-first workflow for Pi using revdiff for interactive markdown plan review.
This extension adds a lightweight state machine to Pi:
idle→ normal Pi behaviorplanning→ the agent can explore, but may only write/edit markdown plan filesexecuting→ after plan approval, full tools are restored and checklist progress is tracked
The review loop is simple:
- Start plan mode with
/plan - Let the agent explore and write a markdown plan
- The agent calls
plan_submit("PLAN.md") revdiffopens for review- If you quit with no annotations, the plan is approved
- If you annotate lines, the feedback goes back to the agent for revision
- Once approved, execution starts and checklist progress is tracked via
[DONE:n]
- Node.js 20+ recommended
- Pi coding agent
- revdiff available in
PATH- macOS/Homebrew example:
brew install umputun/apps/revdiff
- macOS/Homebrew example:
- A terminal environment where Pi can launch TUI tools
pi install pi-revdiff-planThen verify:
pi listgit clone <this-repo>
cd pi-revdiff-plan
pi install .pipi --plan/plan
# agent explores codebase and writes PLAN.md
# agent calls plan_submit("PLAN.md")
# revdiff opens for review
# annotate and quit, or quit clean to approve
After approval, the extension restores the previously active tool set and tracks progress using checklist items parsed from the approved markdown file.
Toggles plan mode when safe:
idle→planningplanning→idle- during
executing, it does not abort silently; it warns you to use/plan-abort
Cancels the current execution phase and returns to idle mode.
Shows:
- current phase
- current plan file, if any
- checklist progress
- remaining unchecked steps
Starts Pi with plan mode enabled.
Example:
pi --planThe agent is prompted to create a markdown plan with sections like:
- Context
- Approach
- Files to modify
- Steps
- Verification
Checklist items should be standard markdown task items, for example:
- [ ] Add parser tests
- [ ] Refactor state restoration
- [ ] Update READMEDuring execution, the extension tracks completion when the agent emits markers like:
[DONE:0]
[DONE:1]
These markers should appear on their own lines.
This project currently uses a minimal validation flow through npm scripts:
npm run typecheck
npm run build
npm run test
npm run lint
npm run validatetypecheck— run TypeScript with--noEmitbuild— compile project todist/test— build and run Node test suiteslint— currently aliases the type-safe validation baselinevalidate— run typecheck and tests together
Make sure revdiff is installed and available in PATH.
You can verify with:
command -v revdiffYou can also point to a custom binary path with REVDIFF_BIN.
The extension only allows plan files that:
- are inside the current working directory
- end with
.mdor.mdx - exist and are not empty
Examples of rejected paths:
../PLAN.md/absolute/path/outside/repo.mdplan.txt
That is expected. During planning, write and edit are restricted to markdown files only. Approve the plan first to restore full tool access.
Checklist progress only updates in executing mode and depends on [DONE:n] markers matching the zero-based checklist index.
The extension restores plan state from Pi session history. If the approved plan file was deleted or moved, restore falls back to idle.
Recommended repository improvements:
- CI to run type checking and tests on pushes and pull requests
- automated release/versioning flow for publishing
If those files exist in your fork, check .github/workflows/.
index.ts # extension entrypoint
src/constants.ts # shared constants
src/parsing.ts # checklist parsing and path validation
src/prompts.ts # agent prompt helpers
src/review.ts # revdiff launch/review flow
src/state.ts # persistence and restore helpers
src/commands.ts # slash commands and flag registration
.pi/extensions/rtk.ts # optional RTK bash rewrite helper
test/*.test.ts # automated tests
MIT