islandflow/docs/turns/2026-05-15-add-pi-plan-mode.html

55 lines
3.1 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Add Pi /plan Mode</title>
<style>
body { font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.55; margin: 2rem auto; max-width: 860px; color: #1f2520; background: #fbfaf6; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
pre { background: #ece8dd; padding: 1rem; overflow-x: auto; border-radius: 12px; }
h1, h2 { line-height: 1.15; }
.summary { background: #e4eadf; border: 1px solid #cbd8c0; border-radius: 16px; padding: 1rem 1.25rem; }
</style>
</head>
<body>
<h1>Add Pi <code>/plan</code> Mode</h1>
<section class="summary">
<h2>Summary</h2>
<p>Added a project-local Pi extension that lets users type <code>/plan</code> to activate a guarded planning mode, then <code>/plan off</code> or <code>/implement</code> to return to implementation mode.</p>
</section>
<h2>Changes Made</h2>
<ul>
<li>Created <code>.pi/extensions/plan-mode.ts</code>.</li>
<li>Registered a <code>/plan</code> command that enables plan mode.</li>
<li>Registered a <code>/implement</code> command and <code>/plan off</code> argument to disable plan mode.</li>
<li>Added tool-call guards that block <code>write</code>, <code>edit</code>, and common mutating shell commands while plan mode is active.</li>
<li>Added a turn document for this change.</li>
</ul>
<h2>Context</h2>
<p>Pi does not ship with built-in plan mode. Its documented extension system supports custom slash commands and tool-call interception, which fits this workflow without patching Pi internals.</p>
<h2>Important Implementation Details</h2>
<pre><code>/plan # enable planning guardrails
/plan off # disable planning guardrails
/implement # disable planning guardrails</code></pre>
<p>When active, plan mode appends explicit system instructions before each agent turn and blocks file mutation tools. Bash commands are screened with conservative patterns for filesystem, git, package-manager, and Docker mutations.</p>
<h2>Validation</h2>
<ul>
<li>Ran <code>NODE_PATH=/opt/homebrew/lib/node_modules bun --check .pi/extensions/plan-mode.ts</code> successfully.</li>
<li>Initial <code>bun --check .pi/extensions/plan-mode.ts</code> failed because the Pi package is installed globally, not as a repo dependency. Retried with <code>NODE_PATH</code> pointed at Homebrew global Node modules.</li>
</ul>
<h2>Issues, Limitations, and Mitigations</h2>
<ul>
<li>The bash mutation detector is intentionally conservative but cannot perfectly classify every shell command. Direct Pi <code>write</code> and <code>edit</code> calls are fully blocked.</li>
<li>The extension is project-local, so it activates automatically for Pi sessions launched in this repository. To use it everywhere, copy it to <code>~/.pi/agent/extensions/</code>.</li>
</ul>
<h2>Follow-up Work</h2>
<p>No required follow-up work. Beads issue: <code>islandflow-hio</code>.</p>
</body>
</html>