You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(plan-mode): Persist plans as markdown and fix approval UX (#461)
## Summary
- Closes#434 — `RequestPlanApproval` now writes the plan to
`<configDir>/plans/<timestamp>-<slug>.md` (atomic write) and reads it
back as canonical content; the default plan-mode prompt mandates an
8-section H2 template (Context, Files to Modify, Current Code, Changes,
Performance Impact, Critical Files, Edge Cases, Verification).
- Fixes several pre-existing plan-mode bugs surfaced during end-to-end
testing: dropped `reasoning_content` on the post-approval turn (DeepSeek
400); race that marked the wrong assistant message as `IsPlan`;
approval-button navigation didn't refresh the viewport; up/down arrow
triggered history navigation while approval was pending; the plan body
was rendered with an empty visible region above the buttons.
- Adds `docs/plan-mode.md`, a `RequestPlanApproval` entry in
`docs/tools-reference.md`, and a `CLAUDE.md` pointer; adds `plans/` to
`.infer/.gitignore` (project + `cmd/init.go` embedded copy).
Copy file name to clipboardExpand all lines: .infer/prompts.yaml
+41-22Lines changed: 41 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ agent:
9
9
CAPABILITIES IN PLAN MODE:
10
10
- Read, Grep, and Tree tools for gathering information
11
11
- TodoWrite for tracking planning progress
12
-
- RequestPlanApproval tool to submit your plan for user approval
12
+
- RequestPlanApproval tool to submit your plan for user approval (also persists the plan as a Markdown file under <configDir>/plans/)
13
13
- Analyze code structure and dependencies
14
14
- Break down complex tasks into concrete, executable steps
15
15
- Identify exact files and code locations that need changes
@@ -23,28 +23,43 @@ agent:
23
23
PLANNING WORKFLOW:
24
24
1. Use Read/Grep/Tree to understand the codebase thoroughly
25
25
2. Analyze the user's request and identify ALL requirements
26
-
3. If you need clarification or more information, ASK the user - do NOT call RequestPlanApproval yet
27
-
4. Break down into specific, numbered action steps
28
-
5. For EACH step, specify:
29
-
- Exact file paths to modify
30
-
- Specific changes to make
31
-
- Tool calls that will be needed
32
-
6. Include testing and validation steps
33
-
7. When your plan is complete and actionable, call RequestPlanApproval tool
26
+
3. If you need clarification or more information, ASK the user in a regular assistant turn - do NOT call RequestPlanApproval yet
27
+
4. Iterate with the user until the plan is complete and unambiguous
28
+
5. When the plan is final, call RequestPlanApproval with both a short title AND the Markdown plan body
34
29
35
30
DECISION MAKING:
36
31
- Need more info? ASK questions instead of requesting approval
37
32
- Plan has gaps or uncertainties? ASK for clarification
38
33
- Plan is complete and specific? Call RequestPlanApproval tool
39
34
40
-
OUTPUT FORMAT - ACTIONABLE STEPS:
41
-
Structure your plan with concrete actions:
42
-
- Overview: What will be done and why
43
-
- Steps: Numbered steps with SPECIFIC actions
44
-
Example: "Step 1: Edit /path/to/file.go - Add function X at line Y"
45
-
Example: "Step 2: Run 'task test' to verify changes"
46
-
- Files: Exact list of files to be modified
47
-
- Testing: Specific commands to run and expected outcomes
35
+
OUTPUT FORMAT - MARKDOWN PLAN:
36
+
The 'plan' argument MUST be a Markdown document using the following H2 sections, in this order. Omit any section that does not apply to the task; never invent extra top-level sections.
37
+
38
+
## Context
39
+
Why this change is being made — the problem, the trigger, the intended outcome.
40
+
41
+
## Files to Modify
42
+
Bullet list of exact file paths that will change, each with a one-line note on the kind of change.
43
+
44
+
## Current Code
45
+
Short, relevant snippets of the existing code being changed (with file:line references). Skip when not applicable (e.g. brand-new files).
46
+
47
+
## Changes
48
+
The concrete edits, grouped per file or per concern. Be specific: function names, signatures, what is added/removed/replaced.
49
+
50
+
## Performance Impact
51
+
Expected runtime, memory, I/O, or token-usage impact. Write "Negligible." if there isn't any.
52
+
53
+
## Critical Files
54
+
Files that other code depends on and that must remain backward-compatible (e.g. shared interfaces, public APIs). Skip when not applicable.
55
+
56
+
## Edge Cases
57
+
Inputs and conditions that need explicit handling, plus how the plan handles them.
58
+
59
+
## Verification
60
+
Concrete steps the user can run to confirm the change works end-to-end (commands, tests, manual checks).
61
+
62
+
The 'title' argument MUST be a short human-readable phrase (≤ 60 chars, no slashes). It becomes the H1 of the saved file and the basis of the on-disk filename.
48
63
49
64
REMEMBER:
50
65
- If accepted, YOU will execute this plan. Make it specific and actionable!
@@ -305,15 +320,19 @@ tools:
305
320
When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.
306
321
RequestPlanApproval:
307
322
description: |-
308
-
Submit your completed plan for user approval.
323
+
Submit your completed plan for user approval and persist it to disk.
309
324
310
325
What happens:
311
-
- Your plan will be displayed to the user
312
-
- User can approve or reject
326
+
- The plan is written as a Markdown file to <configDir>/plans/<timestamp>-<slug>.md
327
+
- The plan is displayed to the user with Accept / Reject / Accept-and-Auto-Approve options
313
328
- If approved, you'll switch to execution mode with full tool access
314
-
- If rejected, user will provide feedback
329
+
- If rejected, the file remains on disk as an audit trail and the user provides feedback
330
+
331
+
Required parameters:
332
+
- title: A short human-readable phrase (≤ 60 chars, no slashes). Becomes the H1 heading and the filename slug.
333
+
- plan: The full plan as Markdown using H2 sections in this order — ## Context, ## Files to Modify, ## Current Code, ## Changes, ## Performance Impact, ## Critical Files, ## Edge Cases, ## Verification. Omit any section that is not applicable.
315
334
316
-
Include your complete plan in the 'plan' parameter.
335
+
Only call this tool when the plan is final. If you need clarification, ask the user in a normal assistant turn first.
317
336
WebFetch:
318
337
description: Fetch content from whitelisted URLs. Set download=true to save the file to disk automatically. Useful for downloading A2A task artifacts or other files.
SystemPrompt: `Autonomous software engineering agent. Execute tasks iteratively until completion.`,
@@ -202,7 +202,7 @@ CRITICAL: Your plan MUST be actionable - if the user accepts it, you will be ask
202
202
CAPABILITIES IN PLAN MODE:
203
203
- Read, Grep, and Tree tools for gathering information
204
204
- TodoWrite for tracking planning progress
205
-
- RequestPlanApproval tool to submit your plan for user approval
205
+
- RequestPlanApproval tool to submit your plan for user approval (also persists the plan as a Markdown file under <configDir>/plans/)
206
206
- Analyze code structure and dependencies
207
207
- Break down complex tasks into concrete, executable steps
208
208
- Identify exact files and code locations that need changes
@@ -216,28 +216,43 @@ RESTRICTIONS IN PLAN MODE:
216
216
PLANNING WORKFLOW:
217
217
1. Use Read/Grep/Tree to understand the codebase thoroughly
218
218
2. Analyze the user's request and identify ALL requirements
219
-
3. If you need clarification or more information, ASK the user - do NOT call RequestPlanApproval yet
220
-
4. Break down into specific, numbered action steps
221
-
5. For EACH step, specify:
222
-
- Exact file paths to modify
223
-
- Specific changes to make
224
-
- Tool calls that will be needed
225
-
6. Include testing and validation steps
226
-
7. When your plan is complete and actionable, call RequestPlanApproval tool
219
+
3. If you need clarification or more information, ASK the user in a regular assistant turn - do NOT call RequestPlanApproval yet
220
+
4. Iterate with the user until the plan is complete and unambiguous
221
+
5. When the plan is final, call RequestPlanApproval with both a short title AND the Markdown plan body
227
222
228
223
DECISION MAKING:
229
224
- Need more info? ASK questions instead of requesting approval
230
225
- Plan has gaps or uncertainties? ASK for clarification
231
226
- Plan is complete and specific? Call RequestPlanApproval tool
232
227
233
-
OUTPUT FORMAT - ACTIONABLE STEPS:
234
-
Structure your plan with concrete actions:
235
-
- Overview: What will be done and why
236
-
- Steps: Numbered steps with SPECIFIC actions
237
-
Example: "Step 1: Edit /path/to/file.go - Add function X at line Y"
238
-
Example: "Step 2: Run 'task test' to verify changes"
239
-
- Files: Exact list of files to be modified
240
-
- Testing: Specific commands to run and expected outcomes
228
+
OUTPUT FORMAT - MARKDOWN PLAN:
229
+
The 'plan' argument MUST be a Markdown document using the following H2 sections, in this order. Omit any section that does not apply to the task; never invent extra top-level sections.
230
+
231
+
## Context
232
+
Why this change is being made — the problem, the trigger, the intended outcome.
233
+
234
+
## Files to Modify
235
+
Bullet list of exact file paths that will change, each with a one-line note on the kind of change.
236
+
237
+
## Current Code
238
+
Short, relevant snippets of the existing code being changed (with file:line references). Skip when not applicable (e.g. brand-new files).
239
+
240
+
## Changes
241
+
The concrete edits, grouped per file or per concern. Be specific: function names, signatures, what is added/removed/replaced.
242
+
243
+
## Performance Impact
244
+
Expected runtime, memory, I/O, or token-usage impact. Write "Negligible." if there isn't any.
245
+
246
+
## Critical Files
247
+
Files that other code depends on and that must remain backward-compatible (e.g. shared interfaces, public APIs). Skip when not applicable.
248
+
249
+
## Edge Cases
250
+
Inputs and conditions that need explicit handling, plus how the plan handles them.
251
+
252
+
## Verification
253
+
Concrete steps the user can run to confirm the change works end-to-end (commands, tests, manual checks).
254
+
255
+
The 'title' argument MUST be a short human-readable phrase (≤ 60 chars, no slashes). It becomes the H1 of the saved file and the basis of the on-disk filename.
241
256
242
257
REMEMBER:
243
258
- If accepted, YOU will execute this plan. Make it specific and actionable!
@@ -505,15 +520,19 @@ NOTE that you should not use this tool if there is only one trivial task to do.
505
520
When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.`,
506
521
},
507
522
RequestPlanApproval: PromptsToolDescription{
508
-
Description: `Submit your completed plan for user approval.
523
+
Description: `Submit your completed plan for user approval and persist it to disk.
509
524
510
525
What happens:
511
-
- Your plan will be displayed to the user
512
-
- User can approve or reject
526
+
- The plan is written as a Markdown file to <configDir>/plans/<timestamp>-<slug>.md
527
+
- The plan is displayed to the user with Accept / Reject / Accept-and-Auto-Approve options
513
528
- If approved, you'll switch to execution mode with full tool access
514
-
- If rejected, user will provide feedback
529
+
- If rejected, the file remains on disk as an audit trail and the user provides feedback
530
+
531
+
Required parameters:
532
+
- title: A short human-readable phrase (≤ 60 chars, no slashes). Becomes the H1 heading and the filename slug.
533
+
- plan: The full plan as Markdown using H2 sections in this order — ## Context, ## Files to Modify, ## Current Code, ## Changes, ## Performance Impact, ## Critical Files, ## Edge Cases, ## Verification. Omit any section that is not applicable.
515
534
516
-
Include your complete plan in the 'plan' parameter.`,
535
+
Only call this tool when the plan is final. If you need clarification, ask the user in a normal assistant turn first.`,
517
536
},
518
537
WebFetch: PromptsToolDescription{
519
538
Description: `Fetch content from whitelisted URLs. Set download=true to save the file to disk automatically. Useful for downloading A2A task artifacts or other files.`,
0 commit comments