← Back to PRs

#17240: feat: add /plan directive for read-only analysis mode

by Marvae open 2026-02-15 15:22 View on GitHub →
agents stale size: M
## Summary Adds `/plan` directive for read-only analysis mode, inspired by Claude Code and Gemini CLI plan modes. **Closes #17084** ## Changes ### Directive - `/plan on` — Enable plan mode (read-only tools only) - `/plan off` — Disable plan mode (restore default tools) - `/plan` — Show current status ### Tool Profile Plan mode restricts to read-only tools: - `read`, `web_search`, `web_fetch` - `memory_search`, `memory_get` - `session_status`, `sessions_list`, `sessions_history` - `image` ### System Prompt When plan mode is active, injects guidance based on Claude Code/Gemini CLI research: - Emphasizes read-only constraint - Provides workflow: Explore → Plan → Ask - Includes "Asking Good Questions" guidance ## Testing - Added plan profile tests (5 tests) - Added directive parsing tests (invalid level, colon variant) - All existing tests pass ## Future Considerations (not in this PR) - Whether `browser` (snapshot-only) should be in plan profile - Whether subagents should inherit plan mode - System event notification on plan mode toggle ## Review Notes -[x] Local validation (pnpm build && pnpm check && pnpm test) and manally tests -[x] Focused scope (one change/theme per PR): only add /plan feature with minimal scope -[x] Clear "what" + "why" in description -[x] AI-assistance transparency (if used): Yes, implementation drafted with AI, manually reviewed and tested ![IMG_9836](https://github.com/user-attachments/assets/26f08c68-0f78-453c-b5cb-2a3ac0273fe7) <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR adds a `/plan` directive that enables read-only analysis mode, restricting tools to a read-only subset (`read`, `web_search`, `web_fetch`, `memory_search`, `memory_get`, `session_status`, `sessions_list`, `sessions_history`, `image`). When plan mode is enabled via `/plan on`, it injects custom system prompt guidance and switches the tool profile to `"plan"`, which enforces the tool restrictions. The implementation properly threads `sessionToolProfile` through the agent execution pipeline and includes comprehensive test coverage. Key changes: - Added `PlanLevel` type and normalization in `thinking.ts` - Added `extractPlanDirective()` for parsing `/plan [on|off]` directives - Added `"plan"` tool profile to `tool-policy.ts` with read-only tool allowlist - Wired `sessionToolProfile` through execution params and tool selection - Injects plan mode guidance into system prompt when active - Saves/restores previous `toolProfile` when toggling plan mode on/off - Added 7 new tests covering plan directive parsing and tool profile validation Issues found: - **Critical**: Missing `currentPlanLevel` parameter prevents `/plan` status queries from working - **Critical**: Inconsistent `previousToolProfile` handling between two code paths causes incorrect tool profile restoration in some scenarios <h3>Confidence Score: 2/5</h3> - This PR has critical bugs that will cause runtime failures - Two critical logical errors were found: (1) the `/plan` status query won't work because `currentPlanLevel` is never passed to the handler, and (2) the tool profile restoration logic is inconsistent between two code paths, which will cause incorrect behavior when toggling plan mode off in certain scenarios. Both issues need to be fixed before merging. - Pay close attention to `src/auto-reply/reply/get-reply-directives-apply.ts` and `src/auto-reply/reply/directive-handling.persist.ts` <sub>Last reviewed commit: 9e034f7</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs