# Source audit: plan

Decision: OMP-port-backlog, fail-closed locally. Real plan mode belongs to OMP interactive/session runtime; `miloc-pi` must port or thin-wrap that behavior before enabling a plan plugin.

Current local state:

- `extensions/plan/index.ts` registers legacy `planMode`, `/plan`, and `/todos`.
- `planMode`, `/plan`, and `/todos` return `isError=true` or a fail-closed widget status instead of mutating local plan state.
- The extension no longer registers `tool_call` or `before_agent_start` hooks.
- The extension is disabled by default through `package.json#pi.extensions`.

OMP source evidence:

- `/tmp/oh-my-pi-review/packages/coding-agent/src/modes/interactive-mode.ts` owns plan mode toggling, enter/exit, approval menu, model/tool restoration, status updates, compact/execute choices, and `/plan` command handling.
- `/tmp/oh-my-pi-review/packages/coding-agent/src/plan-mode/state.ts` defines `PlanModeState` with `enabled`, `planFilePath`, optional workflow and reentry state.
- `/tmp/oh-my-pi-review/packages/coding-agent/src/plan-mode/approved-plan.ts` validates plan titles, resolves approved plan filenames, and renames approved local plan artifacts.
- `/tmp/oh-my-pi-review/packages/coding-agent/src/tools/plan-mode-guard.ts` enforces that plan mode may only write to the active plan file.
- `/tmp/oh-my-pi-review/packages/coding-agent/src/prompts/system/plan-mode-active.md` defines the model-facing read-only plan workflow and requires `resolve({ action: "apply", extra: { title } })` for approval.
- `/tmp/oh-my-pi-review/packages/coding-agent/src/prompts/system/plan-mode-approved.md` and `/tmp/oh-my-pi-review/packages/coding-agent/src/prompts/system/plan-mode-compact-instructions.md` define approved-plan execution prompts.
- `/tmp/oh-my-pi-review/packages/coding-agent/src/prompts/tools/resolve.md` documents the plan approval metadata path through `extra.title`.
- `/tmp/oh-my-pi-review/packages/coding-agent/src/slash-commands/builtin-registry.ts` registers native `/plan` and passes inline prompt args into `handlePlanModeCommand`.

Implementation boundary:

- Do not keep the old `tool_call` write gate as product behavior.
- Do not call this extension product-ready until plan file lifecycle, OMP write guard, hidden `resolve` approval, tool/model/context restoration, status-line state, and session resume behavior are either ported from OMP or intentionally out of scope with a documented API.
- `planMode` may remain only as a temporary compatibility alias after the primary OMP plan mode surface is implemented.

License note: OMP files are source evidence for the future port. No OMP implementation code was copied in the fail-closed slice.
