mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-06 23:44:36 +00:00
## What
Hardens the plan-mode example extension's step-progress tracking.
Previously, completion markers were only recognized in the exact
`[DONE:n]` form inside visible text blocks, so steps frequently never
got checked off during execution.
## Changes
- **`getTextContent`** now reads `thinking` blocks as well as text
blocks, so `[DONE:n]` tags emitted during reasoning are honored.
- **Marker tolerance** (`extractDoneSteps`): accepts `[DONE: 1]`, `[DONE
1]`, `Done: n`, and prose phrasings like "Step n done / is complete /
finished" — all adjacency-anchored so negations ("Step 9 is not done")
never match.
- **Whole-plan fallback** (`allStepsComplete`): if the run's final
message says the plan is done (e.g. "All steps complete"), all remaining
steps are marked at `agent_end`.
- **Plan extraction dedup**: only the last `Plan:` section is extracted,
so a plan drafted in a thinking block no longer duplicates the steps
from the text block.
- **No more truncation**: step text is kept in full (previously cut at
50 chars); the widget truncates for display only. The execution prompt
now shows the complete step text.
- **No more dropped steps**: steps whose text starts with a backtick
(e.g. `1. \`index.ts\` — …`) are no longer skipped.
- **Widget refresh** happens on every turn instead of only when a marker
matched.
- **Plan-complete card** is delivered with `nextTurn` instead of
triggering an extra LLM turn.
## Tests
`packages/coding-agent/test/plan-mode-utils.test.ts` updated for the new
behavior (truncation, backtick steps, marker-count semantics) and
extended with coverage for the new cases (marker variants, prose
phrasings, negation safety, thinking-draft dedup, markdown titles,
whole-plan completion).
All 43 tests in `plan-mode-utils.test.ts` +
`plan-mode-extension.test.ts` pass (`npx vitest run`).
Note: the repo-wide type-check currently fails on `main` with
pre-existing `ModelCatalog`/`never` errors unrelated to this change;
this branch adds none (same count with and without the diff).
|
||
|---|---|---|
| .. | ||
| index.ts | ||
| README.md | ||
| utils.ts | ||
Plan Mode Extension
Read-only exploration mode for safe code analysis.
Features
- Built-in write tools disabled: Disables edit/write while preserving other active tools
- Bash allowlist: Only read-only bash commands are allowed
- Plan extraction: Extracts numbered steps from
Plan:sections - Progress tracking: Widget shows completion status during execution
- [DONE:n] markers: Explicit step completion tracking
- Session persistence: State survives session resume
Commands
/plan- Toggle plan mode/todos- Show current plan progressCtrl+Alt+P- Toggle plan mode (shortcut)
Usage
- Enable plan mode with
/planor--planflag - Ask the agent to analyze code and create a plan
- The agent should output a numbered plan under a
Plan:header:
Plan:
1. First step description
2. Second step description
3. Third step description
- Choose "Execute the plan" when prompted
- During execution, the agent marks steps complete with
[DONE:n]tags - Progress widget shows completion status
How It Works
Plan Mode (Read-Only)
- Built-in edit/write tools disabled
- Other active tools remain available
- Bash commands filtered through allowlist
- Agent creates a plan without making changes
Execution Mode
- Full tool access restored
- Agent executes steps in order
[DONE:n]markers track completion- Widget shows progress
Command Allowlist
Safe commands (allowed):
- File inspection:
cat,head,tail,less,more - Search:
grep,find,rg,fd - Directory:
ls,pwd,tree - Git read:
git status,git log,git diff,git branch - Package info:
npm list,npm outdated,yarn info - System info:
uname,whoami,date,uptime
Blocked commands:
- File modification:
rm,mv,cp,mkdir,touch - Git write:
git add,git commit,git push - Package install:
npm install,yarn add,pip install - System:
sudo,kill,reboot - Editors:
vim,nano,code