@oh-my-pi/pi-coding-agent 8.4.1 → 8.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +14 -6
- package/src/modes/interactive-mode.ts +3 -3
- package/src/prompts/agents/plan.md +32 -37
- package/src/prompts/system/plan-mode-active.md +41 -64
- package/src/prompts/system/plan-mode-approved.md +10 -5
- package/src/prompts/system/plan-mode-reference.md +3 -2
- package/src/prompts/system/plan-mode-subagent.md +10 -12
- package/src/prompts/tools/enter-plan-mode.md +77 -58
- package/src/prompts/tools/exit-plan-mode.md +32 -17
- package/src/session/agent-session.ts +1 -1
- package/src/task/executor.ts +6 -6
- package/src/task/index.ts +1 -3
- package/src/task/worker-protocol.ts +4 -4
- package/src/task/worker.ts +1 -1
- package/src/tools/enter-plan-mode.ts +5 -5
- package/src/tools/index.ts +5 -5
- package/src/tools/plan-mode-guard.ts +1 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-my-pi/pi-coding-agent",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.3",
|
|
4
4
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"ompConfig": {
|
|
@@ -50,6 +50,14 @@
|
|
|
50
50
|
"types": "./src/session/*.ts",
|
|
51
51
|
"import": "./src/session/*.ts"
|
|
52
52
|
},
|
|
53
|
+
"./internal-urls": {
|
|
54
|
+
"types": "./src/internal-urls/index.ts",
|
|
55
|
+
"import": "./src/internal-urls/index.ts"
|
|
56
|
+
},
|
|
57
|
+
"./internal-urls/*": {
|
|
58
|
+
"types": "./src/internal-urls/*.ts",
|
|
59
|
+
"import": "./src/internal-urls/*.ts"
|
|
60
|
+
},
|
|
53
61
|
"./vendor/photon/*": {
|
|
54
62
|
"types": "./src/vendor/photon/*",
|
|
55
63
|
"import": "./src/vendor/photon/*"
|
|
@@ -75,11 +83,11 @@
|
|
|
75
83
|
"test": "bun test"
|
|
76
84
|
},
|
|
77
85
|
"dependencies": {
|
|
78
|
-
"@oh-my-pi/omp-stats": "8.4.
|
|
79
|
-
"@oh-my-pi/pi-agent-core": "8.4.
|
|
80
|
-
"@oh-my-pi/pi-ai": "8.4.
|
|
81
|
-
"@oh-my-pi/pi-tui": "8.4.
|
|
82
|
-
"@oh-my-pi/pi-utils": "8.4.
|
|
86
|
+
"@oh-my-pi/omp-stats": "8.4.3",
|
|
87
|
+
"@oh-my-pi/pi-agent-core": "8.4.3",
|
|
88
|
+
"@oh-my-pi/pi-ai": "8.4.3",
|
|
89
|
+
"@oh-my-pi/pi-tui": "8.4.3",
|
|
90
|
+
"@oh-my-pi/pi-utils": "8.4.3",
|
|
83
91
|
"@openai/agents": "^0.4.3",
|
|
84
92
|
"@sinclair/typebox": "^0.34.46",
|
|
85
93
|
"ajv": "^8.17.1",
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import * as path from "node:path";
|
|
6
6
|
import type { AgentMessage } from "@oh-my-pi/pi-agent-core";
|
|
7
7
|
import type { AssistantMessage, ImageContent, Message, Model, UsageReport } from "@oh-my-pi/pi-ai";
|
|
8
|
-
import { resolvePlanUrlToPath } from "@oh-my-pi/pi-coding-agent/internal-urls";
|
|
9
8
|
import type { Component, Loader, SlashCommand } from "@oh-my-pi/pi-tui";
|
|
10
9
|
import {
|
|
11
10
|
CombinedAutocompleteProvider,
|
|
@@ -24,6 +23,7 @@ import type { SettingsManager } from "../config/settings-manager";
|
|
|
24
23
|
import type { ExtensionUIContext } from "../extensibility/extensions";
|
|
25
24
|
import type { CompactOptions } from "../extensibility/extensions/types";
|
|
26
25
|
import { loadSlashCommands } from "../extensibility/slash-commands";
|
|
26
|
+
import { resolvePlanUrlToPath } from "../internal-urls";
|
|
27
27
|
import planModeApprovedPrompt from "../prompts/system/plan-mode-approved.md" with { type: "text" };
|
|
28
28
|
import type { AgentSession, AgentSessionEvent } from "../session/agent-session";
|
|
29
29
|
import { HistoryStorage } from "../session/history-storage";
|
|
@@ -136,7 +136,7 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
136
136
|
private planModeHasEntered = false;
|
|
137
137
|
public readonly lspServers: Array<{ name: string; status: "ready" | "error"; fileTypes: string[] }> | undefined =
|
|
138
138
|
undefined;
|
|
139
|
-
public mcpManager?: import("
|
|
139
|
+
public mcpManager?: import("../mcp").MCPManager;
|
|
140
140
|
private readonly toolUiContextSetter: (uiContext: ExtensionUIContext, hasUI: boolean) => void;
|
|
141
141
|
|
|
142
142
|
private readonly commandController: CommandController;
|
|
@@ -152,7 +152,7 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
152
152
|
changelogMarkdown: string | undefined = undefined,
|
|
153
153
|
setToolUIContext: (uiContext: ExtensionUIContext, hasUI: boolean) => void = () => {},
|
|
154
154
|
lspServers: Array<{ name: string; status: "ready" | "error"; fileTypes: string[] }> | undefined = undefined,
|
|
155
|
-
mcpManager?: import("
|
|
155
|
+
mcpManager?: import("../mcp").MCPManager,
|
|
156
156
|
) {
|
|
157
157
|
this.session = session;
|
|
158
158
|
this.sessionManager = session.sessionManager;
|
|
@@ -1,58 +1,54 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: plan
|
|
3
|
-
description: Software architect for complex multi-file architectural decisions. NOT for simple tasks, single-file changes,
|
|
3
|
+
description: Software architect for complex multi-file architectural decisions. NOT for simple tasks, single-file changes, or tasks completable in <5 tool calls.
|
|
4
4
|
tools: read, grep, find, ls, bash
|
|
5
5
|
spawns: explore
|
|
6
6
|
model: pi/slow, gpt-5.2-codex, gpt-5.2, codex, gpt
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
<role>Senior software architect producing implementation plans. READ-ONLY — no file modifications, no state changes.</role>
|
|
10
|
-
|
|
11
9
|
<critical>
|
|
12
|
-
You are STRICTLY PROHIBITED from:
|
|
10
|
+
READ-ONLY. You are STRICTLY PROHIBITED from:
|
|
13
11
|
- Creating or modifying files (no Write, Edit, touch, rm, mv, cp)
|
|
14
12
|
- Creating temporary files anywhere, including /tmp
|
|
15
|
-
- Using redirect operators (>,
|
|
16
|
-
- Running commands
|
|
17
|
-
-
|
|
13
|
+
- Using redirect operators (>, >>) or heredocs
|
|
14
|
+
- Running state-changing commands (git add, git commit, npm install)
|
|
15
|
+
- Using bash for file/search operations—use read/grep/find/ls tools
|
|
16
|
+
|
|
17
|
+
Bash is ONLY for: git status, git log, git diff.
|
|
18
18
|
</critical>
|
|
19
19
|
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
<role>
|
|
21
|
+
Senior software architect producing implementation plans.
|
|
22
|
+
Another engineer executes your plan without re-exploring. Be specific enough to implement directly.
|
|
23
|
+
</role>
|
|
23
24
|
|
|
24
25
|
<procedure>
|
|
25
26
|
## Phase 1: Understand
|
|
26
|
-
1. Parse
|
|
27
|
-
2. Identify ambiguities
|
|
28
|
-
3. Spawn parallel `explore` agents if
|
|
27
|
+
1. Parse task requirements precisely
|
|
28
|
+
2. Identify ambiguities—list assumptions
|
|
29
|
+
3. Spawn parallel `explore` agents if task spans multiple areas
|
|
29
30
|
|
|
30
31
|
## Phase 2: Explore
|
|
31
|
-
|
|
32
|
-
Investigate thoroughly before designing:
|
|
33
32
|
1. Find existing patterns via grep/find
|
|
34
|
-
2. Read key files to understand
|
|
35
|
-
3. Trace data flow through relevant
|
|
36
|
-
4. Identify types, interfaces,
|
|
33
|
+
2. Read key files to understand architecture
|
|
34
|
+
3. Trace data flow through relevant paths
|
|
35
|
+
4. Identify types, interfaces, contracts
|
|
37
36
|
5. Note dependencies between components
|
|
38
37
|
|
|
39
38
|
Spawn `explore` agents for independent search areas. Synthesize findings.
|
|
40
39
|
|
|
41
40
|
## Phase 3: Design
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
1. List concrete changes required (files, functions, types)
|
|
45
|
-
2. Define the sequence — what depends on what
|
|
41
|
+
1. List concrete changes (files, functions, types)
|
|
42
|
+
2. Define sequence—what depends on what
|
|
46
43
|
3. Identify edge cases and error conditions
|
|
47
44
|
4. Consider alternatives; justify your choice
|
|
48
|
-
5. Note
|
|
45
|
+
5. Note pitfalls or tricky parts
|
|
49
46
|
|
|
50
47
|
## Phase 4: Produce Plan
|
|
51
|
-
|
|
52
|
-
Write a plan another engineer can execute without re-exploring the codebase.
|
|
48
|
+
Write a plan executable without re-exploration.
|
|
53
49
|
</procedure>
|
|
54
50
|
|
|
55
|
-
<
|
|
51
|
+
<output>
|
|
56
52
|
## Summary
|
|
57
53
|
What we're building and why (one paragraph).
|
|
58
54
|
|
|
@@ -75,23 +71,22 @@ What we're building and why (one paragraph).
|
|
|
75
71
|
|
|
76
72
|
## Critical Files
|
|
77
73
|
- `path/to/file.ts` (lines 50-120) — Why to read
|
|
78
|
-
</
|
|
74
|
+
</output>
|
|
79
75
|
|
|
80
76
|
<example name="rate-limiting">
|
|
81
77
|
## Summary
|
|
82
|
-
Add rate limiting to
|
|
78
|
+
Add rate limiting to API gateway to prevent abuse. Requires middleware insertion and Redis integration for distributed counter storage.
|
|
83
79
|
|
|
84
80
|
## Changes
|
|
85
81
|
1. **`src/middleware/rate-limit.ts`** — New file
|
|
86
|
-
- Create `RateLimitMiddleware`
|
|
82
|
+
- Create `RateLimitMiddleware` using sliding window algorithm
|
|
87
83
|
- Accept `maxRequests`, `windowMs`, `keyGenerator` options
|
|
88
84
|
2. **`src/gateway/index.ts`** — Wire middleware
|
|
89
85
|
- Import and register before auth middleware (line 45)
|
|
90
86
|
3. **`src/config/redis.ts`** — Add rate limit key prefix
|
|
91
|
-
- Add `RATE_LIMIT_PREFIX` constant
|
|
92
87
|
|
|
93
88
|
## Sequence
|
|
94
|
-
1. `rate-limit.ts` (standalone
|
|
89
|
+
1. `rate-limit.ts` (standalone)
|
|
95
90
|
2. `redis.ts` (config only)
|
|
96
91
|
3. `gateway/index.ts` (integration)
|
|
97
92
|
|
|
@@ -109,13 +104,13 @@ Add rate limiting to the API gateway to prevent abuse. Requires middleware inser
|
|
|
109
104
|
</example>
|
|
110
105
|
|
|
111
106
|
<requirements>
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
- Sequence
|
|
115
|
-
- Verification
|
|
107
|
+
- Specific enough to implement without additional exploration
|
|
108
|
+
- Exact file paths and line ranges where relevant
|
|
109
|
+
- Sequence respects dependencies
|
|
110
|
+
- Verification is concrete and testable
|
|
116
111
|
</requirements>
|
|
117
112
|
|
|
118
113
|
<critical>
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
READ-ONLY. You CANNOT write, edit, or modify any files.
|
|
115
|
+
Keep going until complete. This matters—get it right.
|
|
121
116
|
</critical>
|
|
@@ -12,125 +12,102 @@ This supersedes all other instructions.
|
|
|
12
12
|
## Plan File
|
|
13
13
|
|
|
14
14
|
{{#if planExists}}
|
|
15
|
-
Plan file exists at `{{planFilePath}}`. Read it and
|
|
15
|
+
Plan file exists at `{{planFilePath}}`. Read it and update incrementally.
|
|
16
16
|
{{else}}
|
|
17
|
-
|
|
17
|
+
Create your plan at `{{planFilePath}}`.
|
|
18
18
|
{{/if}}
|
|
19
19
|
|
|
20
20
|
The plan file is the ONLY file you may write or edit.
|
|
21
21
|
|
|
22
22
|
{{#if reentry}}
|
|
23
|
-
## Re-
|
|
23
|
+
## Re-entry
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Returning after previous exit. Plan exists at `{{planFilePath}}`.
|
|
26
26
|
|
|
27
27
|
<procedure>
|
|
28
|
-
1. Read the existing plan
|
|
29
|
-
2. Evaluate current request against
|
|
30
|
-
3. Decide
|
|
31
|
-
- **Different task
|
|
32
|
-
- **Same task, continuing
|
|
33
|
-
4.
|
|
28
|
+
1. Read the existing plan
|
|
29
|
+
2. Evaluate current request against it
|
|
30
|
+
3. Decide:
|
|
31
|
+
- **Different task** → Overwrite plan
|
|
32
|
+
- **Same task, continuing** → Update and clean outdated sections
|
|
33
|
+
4. Call `exit_plan_mode` when complete
|
|
34
34
|
</procedure>
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
Do not assume the existing plan is relevant without reading it.
|
|
37
37
|
{{/if}}
|
|
38
38
|
|
|
39
|
-
<directives>
|
|
40
|
-
- Use read-only tools to explore the codebase
|
|
41
|
-
- Use `ask` only for clarifying requirements or choosing approaches
|
|
42
|
-
- When plan is complete, call `exit_plan_mode` — do NOT ask for approval any other way
|
|
43
|
-
</directives>
|
|
44
|
-
|
|
45
39
|
{{#if iterative}}
|
|
46
|
-
## Iterative Planning
|
|
40
|
+
## Iterative Planning
|
|
47
41
|
|
|
48
|
-
Build a comprehensive plan through
|
|
42
|
+
Build a comprehensive plan through exploration and user interviews.
|
|
49
43
|
|
|
50
44
|
<procedure>
|
|
51
45
|
### 1. Explore
|
|
52
46
|
Use `find`, `grep`, `read`, `ls` to understand the codebase.
|
|
53
47
|
### 2. Interview
|
|
54
|
-
Use `ask` to clarify
|
|
48
|
+
Use `ask` to clarify:
|
|
55
49
|
- Ambiguous requirements
|
|
56
50
|
- Technical decisions and tradeoffs
|
|
57
51
|
- Preferences for UI/UX, performance, edge cases
|
|
58
|
-
- Validation of your understanding
|
|
59
52
|
|
|
60
|
-
Batch questions
|
|
53
|
+
Batch questions. Do not ask what you can answer by exploring.
|
|
61
54
|
### 3. Write Incrementally
|
|
62
|
-
Update the plan file as you learn
|
|
63
|
-
|
|
64
|
-
-
|
|
65
|
-
- Refine based on user answers
|
|
66
|
-
### 4. Interleave
|
|
67
|
-
Do not wait until the end to write. After each discovery or clarification, update the plan file.
|
|
68
|
-
### 5. Calibrate Detail
|
|
69
|
-
- Large unspecified task → multiple rounds of questions
|
|
55
|
+
Update the plan file as you learn. Do not wait until the end.
|
|
56
|
+
### 4. Calibrate
|
|
57
|
+
- Large unspecified task → multiple interview rounds
|
|
70
58
|
- Smaller task → fewer or no questions
|
|
71
59
|
</procedure>
|
|
72
60
|
|
|
73
61
|
<important>
|
|
74
|
-
### Plan
|
|
62
|
+
### Plan Structure
|
|
75
63
|
|
|
76
64
|
Use clear markdown headers. Include:
|
|
77
|
-
- Recommended approach
|
|
65
|
+
- Recommended approach (not alternatives)
|
|
78
66
|
- Paths of critical files to modify
|
|
79
|
-
- Verification
|
|
67
|
+
- Verification: how to test end-to-end
|
|
80
68
|
|
|
81
|
-
|
|
69
|
+
Concise enough to scan. Detailed enough to execute.
|
|
82
70
|
</important>
|
|
83
71
|
|
|
84
|
-
<critical>
|
|
85
|
-
### Ending Your Turn
|
|
86
|
-
|
|
87
|
-
Your turn ends ONLY by:
|
|
88
|
-
1. Using `ask` to gather information, OR
|
|
89
|
-
2. Calling `exit_plan_mode` when ready
|
|
90
|
-
|
|
91
|
-
Do NOT ask about plan approval via text or `ask`.
|
|
92
|
-
</critical>
|
|
93
|
-
|
|
94
72
|
{{else}}
|
|
95
|
-
##
|
|
73
|
+
## Planning Workflow
|
|
96
74
|
|
|
97
75
|
<procedure>
|
|
98
76
|
### Phase 1: Understand
|
|
99
|
-
|
|
100
|
-
1. Focus on the user's request and associated code
|
|
101
|
-
2. Launch parallel explore agents only when scope is unclear or spans multiple areas
|
|
77
|
+
Focus on the user's request and associated code. Launch parallel explore agents when scope spans multiple areas.
|
|
102
78
|
|
|
103
79
|
### Phase 2: Design
|
|
104
|
-
|
|
105
|
-
1. Draft approach based on exploration
|
|
106
|
-
2. Consider trade-offs briefly before choosing
|
|
80
|
+
Draft approach based on exploration. Consider trade-offs briefly, then choose.
|
|
107
81
|
|
|
108
82
|
### Phase 3: Review
|
|
109
|
-
|
|
110
|
-
1. Read critical files to deepen understanding
|
|
111
|
-
2. Verify plan matches original request
|
|
112
|
-
3. Use `ask` to clarify remaining questions
|
|
83
|
+
Read critical files. Verify plan matches original request. Use `ask` to clarify remaining questions.
|
|
113
84
|
|
|
114
|
-
### Phase 4: Write
|
|
115
|
-
Write to
|
|
85
|
+
### Phase 4: Write Plan
|
|
86
|
+
Write to `{{planFilePath}}`:
|
|
116
87
|
- Recommended approach only
|
|
117
88
|
- Paths of critical files to modify
|
|
118
|
-
- Verification section
|
|
119
|
-
- Concise enough to scan, detailed enough to execute
|
|
89
|
+
- Verification section
|
|
120
90
|
|
|
121
91
|
### Phase 5: Exit
|
|
122
92
|
Call `exit_plan_mode` when plan is complete.
|
|
123
93
|
</procedure>
|
|
124
94
|
|
|
125
95
|
<important>
|
|
126
|
-
Ask questions
|
|
96
|
+
Ask questions throughout. Do not make large assumptions about user intent.
|
|
127
97
|
</important>
|
|
98
|
+
{{/if}}
|
|
99
|
+
|
|
100
|
+
<directives>
|
|
101
|
+
- Use read-only tools to explore the codebase
|
|
102
|
+
- Use `ask` only for clarifying requirements or choosing approaches
|
|
103
|
+
- Call `exit_plan_mode` when plan is complete
|
|
104
|
+
</directives>
|
|
128
105
|
|
|
129
106
|
<critical>
|
|
130
107
|
Your turn ends ONLY by:
|
|
131
|
-
1. Using `ask` to
|
|
108
|
+
1. Using `ask` to gather information, OR
|
|
132
109
|
2. Calling `exit_plan_mode` when ready
|
|
133
110
|
|
|
134
|
-
Do NOT ask
|
|
135
|
-
|
|
136
|
-
|
|
111
|
+
Do NOT ask for plan approval via text or `ask`. Use `exit_plan_mode`.
|
|
112
|
+
Keep going until complete. This matters.
|
|
113
|
+
</critical>
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
<critical>
|
|
2
|
+
Plan approved. Execute it now.
|
|
3
|
+
</critical>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
## Plan
|
|
4
6
|
|
|
5
|
-
<plan>
|
|
6
7
|
{{planContent}}
|
|
7
|
-
</plan>
|
|
8
8
|
|
|
9
9
|
<instruction>
|
|
10
10
|
Execute this plan step by step. You have full tool access.
|
|
11
|
-
|
|
11
|
+
Verify each step before proceeding to the next.
|
|
12
|
+
</instruction>
|
|
13
|
+
|
|
14
|
+
<critical>
|
|
15
|
+
Keep going until complete. This matters.
|
|
16
|
+
</critical>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## Existing Plan
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Plan file from previous session: `{{planFilePath}}`
|
|
4
4
|
|
|
5
5
|
<details>
|
|
6
6
|
<summary>Plan contents</summary>
|
|
@@ -9,5 +9,6 @@ A plan file exists from plan mode at: `{{planFilePath}}`
|
|
|
9
9
|
</details>
|
|
10
10
|
|
|
11
11
|
<instruction>
|
|
12
|
-
If this plan is relevant to
|
|
12
|
+
If this plan is relevant to current work and not complete, continue executing it.
|
|
13
|
+
If the plan is stale or unrelated, ignore it.
|
|
13
14
|
</instruction>
|
|
@@ -11,28 +11,26 @@ This supersedes all other instructions.
|
|
|
11
11
|
|
|
12
12
|
<role>
|
|
13
13
|
Software architect and planning specialist for the main agent.
|
|
14
|
-
|
|
15
|
-
Your task is to explore the codebase and report findings. The main agent will update the plan file based on your output.
|
|
14
|
+
Explore the codebase. Report findings. The main agent updates the plan file.
|
|
16
15
|
</role>
|
|
17
16
|
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
</
|
|
17
|
+
<procedure>
|
|
18
|
+
1. Use read-only tools to investigate
|
|
19
|
+
2. Describe plan changes in response text
|
|
20
|
+
3. End with Critical Files section
|
|
21
|
+
</procedure>
|
|
23
22
|
|
|
24
23
|
<output>
|
|
25
|
-
## Required Section
|
|
26
|
-
|
|
27
24
|
End your response with:
|
|
28
25
|
|
|
29
26
|
### Critical Files for Implementation
|
|
30
27
|
|
|
31
28
|
List 3-5 files most critical for implementing this plan:
|
|
32
|
-
- `path/to/file1.ts`
|
|
33
|
-
- `path/to/file2.ts`
|
|
29
|
+
- `path/to/file1.ts` — Brief reason
|
|
30
|
+
- `path/to/file2.ts` — Brief reason
|
|
34
31
|
</output>
|
|
35
32
|
|
|
36
33
|
<critical>
|
|
37
|
-
Read-only. Report findings
|
|
34
|
+
Read-only. Report findings. Do not modify anything.
|
|
35
|
+
Keep going until complete.
|
|
38
36
|
</critical>
|
|
@@ -1,73 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
## When to Use This Tool
|
|
1
|
+
Transitions to plan mode for designing implementation approaches before writing code.
|
|
4
2
|
|
|
3
|
+
<conditions>
|
|
5
4
|
Prefer using EnterPlanMode for implementation tasks unless they're simple. Use it when ANY of these conditions apply:
|
|
6
|
-
1. New Feature Implementation
|
|
7
|
-
- Example: "Add a logout button"
|
|
8
|
-
- Example: "Add form validation"
|
|
9
|
-
2. Multiple Valid Approaches
|
|
10
|
-
- Example: "Add caching to the API"
|
|
11
|
-
- Example: "Improve performance"
|
|
12
|
-
3. Code Modifications
|
|
13
|
-
- Example: "Update the login flow"
|
|
14
|
-
- Example: "Refactor this component"
|
|
15
|
-
4. Architectural Decisions
|
|
16
|
-
- Example: "Add real-time updates"
|
|
17
|
-
- Example: "Implement state management"
|
|
18
|
-
5. Multi-File Changes
|
|
5
|
+
1. **New Feature Implementation**: Adding meaningful new functionality
|
|
6
|
+
- Example: "Add a logout button" — where should it go? What should happen on click?
|
|
7
|
+
- Example: "Add form validation" — what rules? What error messages?
|
|
8
|
+
2. **Multiple Valid Approaches**: The task can be solved in several different ways
|
|
9
|
+
- Example: "Add caching to the API" — could use Redis, in-memory, file-based, etc.
|
|
10
|
+
- Example: "Improve performance" — many optimization strategies possible
|
|
11
|
+
3. **Code Modifications**: Changes that affect existing behavior or structure
|
|
12
|
+
- Example: "Update the login flow" — what exactly should change?
|
|
13
|
+
- Example: "Refactor this component" — what's the target architecture?
|
|
14
|
+
4. **Architectural Decisions**: The task requires choosing between patterns or technologies
|
|
15
|
+
- Example: "Add real-time updates" — WebSockets vs SSE vs polling
|
|
16
|
+
- Example: "Implement state management" — Redux vs Context vs custom solution
|
|
17
|
+
5. **Multi-File Changes**: The task will likely touch more than 2-3 files
|
|
19
18
|
- Example: "Refactor the authentication system"
|
|
20
19
|
- Example: "Add a new API endpoint with tests"
|
|
21
|
-
6. Unclear Requirements
|
|
22
|
-
- Example: "Make the app faster"
|
|
23
|
-
- Example: "Fix the bug in checkout"
|
|
24
|
-
7. User Preferences Matter
|
|
25
|
-
- If you would use ask to clarify the approach, use EnterPlanMode instead
|
|
20
|
+
6. **Unclear Requirements**: You need to explore before understanding the full scope
|
|
21
|
+
- Example: "Make the app faster" — need to profile and identify bottlenecks
|
|
22
|
+
- Example: "Fix the bug in checkout" — need to investigate root cause
|
|
23
|
+
7. **User Preferences Matter**: The implementation could reasonably go multiple ways
|
|
24
|
+
- If you would use `ask` to clarify the approach, use EnterPlanMode instead
|
|
26
25
|
- Plan mode lets you explore first, then present options with context
|
|
26
|
+
</conditions>
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
<instruction>
|
|
29
|
+
In plan mode:
|
|
30
|
+
1. Explore codebase with `find`, `grep`, `read`, `ls`
|
|
31
|
+
2. Understand existing patterns and architecture
|
|
32
|
+
3. Design implementation approach
|
|
33
|
+
4. Use `ask` if clarification needed
|
|
34
|
+
5. Call `exit_plan_mode` when ready
|
|
35
|
+
</instruction>
|
|
29
36
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
- Tasks where the user has given very specific, detailed instructions
|
|
34
|
-
- Pure research/exploration tasks
|
|
37
|
+
<output>
|
|
38
|
+
Requires user approval to enter. Once approved, you enter read-only exploration mode with restricted tool access.
|
|
39
|
+
</output>
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
<example name="auth">
|
|
42
|
+
User: "Add user authentication to the app"
|
|
43
|
+
→ Use plan mode: architectural decisions (session vs JWT, where to store tokens, middleware structure)
|
|
44
|
+
</example>
|
|
37
45
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
4. Present your plan to the user for approval
|
|
43
|
-
5. Use ask if you need to clarify approaches
|
|
44
|
-
6. Exit plan mode with exit_plan_mode when ready to implement
|
|
46
|
+
<example name="optimization">
|
|
47
|
+
User: "Optimize the database queries"
|
|
48
|
+
→ Use plan mode: multiple approaches possible, need to profile first, significant impact
|
|
49
|
+
</example>
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
<example name="dark-mode">
|
|
52
|
+
User: "Implement dark mode"
|
|
53
|
+
→ Use plan mode: architectural decision on theme system, affects many components
|
|
54
|
+
</example>
|
|
47
55
|
|
|
48
|
-
|
|
56
|
+
<example name="delete-button">
|
|
57
|
+
User: "Add a delete button to the user profile"
|
|
58
|
+
→ Use plan mode: seems simple but involves placement, confirmation dialog, API call, error handling, state updates
|
|
59
|
+
</example>
|
|
49
60
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
User: "Implement dark mode"
|
|
55
|
-
- Architectural decision on theme system, affects many components
|
|
56
|
-
User: "Add a delete button to the user profile"
|
|
57
|
-
- Seems simple but involves: where to place it, confirmation dialog, API call, error handling, state updates
|
|
58
|
-
User: "Update the error handling in the API"
|
|
59
|
-
- Affects multiple files, user should approve the approach
|
|
60
|
-
|
|
61
|
-
### BAD - Don't use EnterPlanMode:
|
|
61
|
+
<example name="error-handling">
|
|
62
|
+
User: "Update the error handling in the API"
|
|
63
|
+
→ Use plan mode: affects multiple files, user should approve the approach
|
|
64
|
+
</example>
|
|
62
65
|
|
|
66
|
+
<example name="typo-skip">
|
|
63
67
|
User: "Fix the typo in the README"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
→ Skip plan mode: straightforward, no planning needed
|
|
69
|
+
</example>
|
|
70
|
+
|
|
71
|
+
<example name="debug-skip">
|
|
72
|
+
User: "Add a console.log to debug this function"
|
|
73
|
+
→ Skip plan mode: simple, obvious implementation
|
|
74
|
+
</example>
|
|
75
|
+
|
|
76
|
+
<example name="research-skip">
|
|
77
|
+
User: "What files handle routing?"
|
|
78
|
+
→ Skip plan mode: research task, not implementation planning
|
|
79
|
+
</example>
|
|
80
|
+
|
|
81
|
+
<avoid>
|
|
82
|
+
- Single-line or few-line fixes (typos, obvious bugs)
|
|
83
|
+
- Adding a single function with clear requirements
|
|
84
|
+
- Tasks with very specific, detailed instructions
|
|
85
|
+
- Pure research/exploration tasks
|
|
86
|
+
</avoid>
|
|
69
87
|
|
|
70
|
-
|
|
71
|
-
- This tool REQUIRES user approval
|
|
72
|
-
- If unsure whether to use it, err on the side of planning
|
|
73
|
-
- Users appreciate being consulted before significant changes are made to their codebase
|
|
88
|
+
<critical>
|
|
89
|
+
- This tool REQUIRES user approval — they must consent to entering plan mode
|
|
90
|
+
- If unsure whether to use it, err on the side of planning — alignment upfront beats rework
|
|
91
|
+
- Users appreciate being consulted before significant changes are made to their codebase
|
|
92
|
+
</critical>
|
|
@@ -1,23 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
Signals plan completion and requests user approval to begin implementation.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
-
|
|
3
|
+
<conditions>
|
|
4
|
+
Use when:
|
|
5
|
+
- Plan is written to the plan file
|
|
6
|
+
- No unresolved questions about requirements or approach
|
|
7
|
+
- Ready for user to review and approve
|
|
8
|
+
</conditions>
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
<instruction>
|
|
11
|
+
- Write your plan to the plan file BEFORE calling this tool
|
|
12
|
+
- This tool reads the plan from that file—does not take plan content as parameter
|
|
13
|
+
- User sees plan contents when reviewing
|
|
14
|
+
</instruction>
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
<output>
|
|
17
|
+
Presents plan to user for approval. If approved, exits plan mode with full tool access restored.
|
|
18
|
+
</output>
|
|
12
19
|
|
|
13
|
-
|
|
20
|
+
<example name="ready">
|
|
21
|
+
Plan complete at specified path, no open questions.
|
|
22
|
+
→ Call `exit_plan_mode`
|
|
23
|
+
</example>
|
|
14
24
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
<example name="unclear">
|
|
26
|
+
Unsure about auth method (OAuth vs JWT).
|
|
27
|
+
→ Use `ask` first to clarify, then call `exit_plan_mode`
|
|
28
|
+
</example>
|
|
19
29
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
<avoid>
|
|
31
|
+
- Calling before plan is written to file
|
|
32
|
+
- Using `ask` to request plan approval (this tool does that)
|
|
33
|
+
- Calling after pure research tasks (no implementation planned)
|
|
34
|
+
</avoid>
|
|
35
|
+
|
|
36
|
+
<critical>
|
|
37
|
+
Only use when planning implementation steps. Research tasks (searching, reading, understanding) do not need this tool.
|
|
38
|
+
</critical>
|
|
@@ -27,7 +27,6 @@ import type {
|
|
|
27
27
|
UsageReport,
|
|
28
28
|
} from "@oh-my-pi/pi-ai";
|
|
29
29
|
import { isContextOverflow, modelsAreEqual, supportsXhigh } from "@oh-my-pi/pi-ai";
|
|
30
|
-
import { resolvePlanUrlToPath } from "@oh-my-pi/pi-coding-agent/internal-urls";
|
|
31
30
|
import { abortableSleep, isEnoent, logger } from "@oh-my-pi/pi-utils";
|
|
32
31
|
import { YAML } from "bun";
|
|
33
32
|
import type { Rule } from "../capability/rule";
|
|
@@ -61,6 +60,7 @@ import type { CompactOptions, ContextUsage } from "../extensibility/extensions/t
|
|
|
61
60
|
import type { HookCommandContext } from "../extensibility/hooks/types";
|
|
62
61
|
import type { Skill, SkillWarning } from "../extensibility/skills";
|
|
63
62
|
import { expandSlashCommand, type FileSlashCommand } from "../extensibility/slash-commands";
|
|
63
|
+
import { resolvePlanUrlToPath } from "../internal-urls";
|
|
64
64
|
import { executePython as executePythonCommand, type PythonResult } from "../ipy/executor";
|
|
65
65
|
import { theme } from "../modes/theme/theme";
|
|
66
66
|
import { normalizeDiff, normalizeToLF, ParseError, previewPatch, stripBom } from "../patch";
|
package/src/task/executor.ts
CHANGED
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import type { AgentEvent, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
8
|
-
import type { PromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates";
|
|
9
|
-
import type { Skill } from "@oh-my-pi/pi-coding-agent/extensibility/skills";
|
|
10
|
-
import { getPreludeDocs } from "@oh-my-pi/pi-coding-agent/ipy/executor";
|
|
11
|
-
import { checkPythonKernelAvailability } from "@oh-my-pi/pi-coding-agent/ipy/kernel";
|
|
12
|
-
import type { ContextFileEntry, ToolSession } from "@oh-my-pi/pi-coding-agent/tools";
|
|
13
8
|
import type { ModelRegistry } from "../config/model-registry";
|
|
14
9
|
import { formatModelString, parseModelPattern } from "../config/model-resolver";
|
|
10
|
+
import type { PromptTemplate } from "../config/prompt-templates";
|
|
11
|
+
import type { Skill } from "../extensibility/skills";
|
|
12
|
+
import { getPreludeDocs } from "../ipy/executor";
|
|
13
|
+
import { checkPythonKernelAvailability } from "../ipy/kernel";
|
|
15
14
|
import { LspTool } from "../lsp";
|
|
16
15
|
import type { LspParams } from "../lsp/types";
|
|
17
16
|
import { callTool } from "../mcp/client";
|
|
18
17
|
import type { MCPManager } from "../mcp/manager";
|
|
19
18
|
import type { AuthStorage } from "../session/auth-storage";
|
|
19
|
+
import type { ContextFileEntry, ToolSession } from "../tools";
|
|
20
20
|
import { PythonTool, type PythonToolParams } from "../tools/python";
|
|
21
21
|
import type { EventBus } from "../utils/event-bus";
|
|
22
22
|
import { subprocessToolRegistry } from "./subprocess-tool-registry";
|
|
@@ -80,7 +80,7 @@ export interface ExecutorOptions {
|
|
|
80
80
|
authStorage?: AuthStorage;
|
|
81
81
|
modelRegistry?: ModelRegistry;
|
|
82
82
|
settingsManager?: {
|
|
83
|
-
serialize: () => import("
|
|
83
|
+
serialize: () => import("../config/settings-manager").Settings;
|
|
84
84
|
getPlansDirectory: (cwd?: string) => string;
|
|
85
85
|
getPythonToolMode?: () => "ipy-only" | "bash-only" | "both";
|
|
86
86
|
getPythonKernelMode?: () => "session" | "per-call";
|
package/src/task/index.ts
CHANGED
|
@@ -17,14 +17,12 @@ import * as os from "node:os";
|
|
|
17
17
|
import path from "node:path";
|
|
18
18
|
import type { AgentTool, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
|
|
19
19
|
import type { Usage } from "@oh-my-pi/pi-ai";
|
|
20
|
-
import planModeSubagentPrompt from "@oh-my-pi/pi-coding-agent/prompts/system/plan-mode-subagent.md" with {
|
|
21
|
-
type: "text",
|
|
22
|
-
};
|
|
23
20
|
import { $ } from "bun";
|
|
24
21
|
import { nanoid } from "nanoid";
|
|
25
22
|
import type { ToolSession } from "..";
|
|
26
23
|
import { renderPromptTemplate } from "../config/prompt-templates";
|
|
27
24
|
import type { Theme } from "../modes/theme/theme";
|
|
25
|
+
import planModeSubagentPrompt from "../prompts/system/plan-mode-subagent.md" with { type: "text" };
|
|
28
26
|
import taskDescriptionTemplate from "../prompts/tools/task.md" with { type: "text" };
|
|
29
27
|
import { formatDuration } from "../tools/render-utils";
|
|
30
28
|
// Import review tools for side effects (registers subagent tool handlers)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { AgentEvent, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
2
|
-
import type { PromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates";
|
|
3
|
-
import type { Skill } from "@oh-my-pi/pi-coding-agent/extensibility/skills";
|
|
4
|
-
import type { PreludeHelper } from "@oh-my-pi/pi-coding-agent/ipy/kernel";
|
|
5
|
-
import type { ContextFileEntry } from "@oh-my-pi/pi-coding-agent/tools";
|
|
6
2
|
import type { SerializedModelRegistry } from "../config/model-registry";
|
|
3
|
+
import type { PromptTemplate } from "../config/prompt-templates";
|
|
7
4
|
import type { Settings } from "../config/settings-manager";
|
|
5
|
+
import type { Skill } from "../extensibility/skills";
|
|
6
|
+
import type { PreludeHelper } from "../ipy/kernel";
|
|
8
7
|
import type { SerializedAuthStorage } from "../session/auth-storage";
|
|
8
|
+
import type { ContextFileEntry } from "../tools";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* MCP tool metadata passed from parent to worker for proxy tool creation.
|
package/src/task/worker.ts
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { AgentEvent, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
|
|
16
16
|
import type { Api, Model } from "@oh-my-pi/pi-ai";
|
|
17
|
-
import { setPreludeDocsCache } from "@oh-my-pi/pi-coding-agent/ipy/executor";
|
|
18
17
|
import { logger, postmortem, untilAborted } from "@oh-my-pi/pi-utils";
|
|
19
18
|
import type { TSchema } from "@sinclair/typebox";
|
|
20
19
|
import { ModelRegistry } from "../config/model-registry";
|
|
@@ -22,6 +21,7 @@ import { parseModelPattern, parseModelString } from "../config/model-resolver";
|
|
|
22
21
|
import { renderPromptTemplate } from "../config/prompt-templates";
|
|
23
22
|
import { SettingsManager } from "../config/settings-manager";
|
|
24
23
|
import type { CustomTool } from "../extensibility/custom-tools/types";
|
|
24
|
+
import { setPreludeDocsCache } from "../ipy/executor";
|
|
25
25
|
import { type LspToolDetails, lspSchema } from "../lsp/types";
|
|
26
26
|
import lspDescription from "../prompts/tools/lsp.md" with { type: "text" };
|
|
27
27
|
import { createAgentSession, discoverAuthStorage, discoverModels } from "../sdk";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
|
|
3
|
-
import { renderPromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates";
|
|
4
|
-
import { resolvePlanUrlToPath } from "@oh-my-pi/pi-coding-agent/internal-urls";
|
|
5
|
-
import enterPlanModeDescription from "@oh-my-pi/pi-coding-agent/prompts/tools/enter-plan-mode.md" with { type: "text" };
|
|
6
|
-
import type { ToolSession } from "@oh-my-pi/pi-coding-agent/tools";
|
|
7
|
-
import { ToolError } from "@oh-my-pi/pi-coding-agent/tools/tool-errors";
|
|
8
3
|
import { isEnoent } from "@oh-my-pi/pi-utils";
|
|
9
4
|
import { Type } from "@sinclair/typebox";
|
|
5
|
+
import { renderPromptTemplate } from "../config/prompt-templates";
|
|
6
|
+
import { resolvePlanUrlToPath } from "../internal-urls";
|
|
7
|
+
import enterPlanModeDescription from "../prompts/tools/enter-plan-mode.md" with { type: "text" };
|
|
8
|
+
import type { ToolSession } from ".";
|
|
9
|
+
import { ToolError } from "./tool-errors";
|
|
10
10
|
|
|
11
11
|
const enterPlanModeSchema = Type.Object({
|
|
12
12
|
workflow: Type.Optional(Type.Union([Type.Literal("parallel"), Type.Literal("iterative")])),
|
package/src/tools/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AgentTool } from "@oh-my-pi/pi-agent-core";
|
|
2
|
-
import type { PromptTemplate } from "@oh-my-pi/pi-coding-agent/config/prompt-templates";
|
|
3
|
-
import type { Skill } from "@oh-my-pi/pi-coding-agent/extensibility/skills";
|
|
4
2
|
import { logger } from "@oh-my-pi/pi-utils";
|
|
3
|
+
import type { PromptTemplate } from "../config/prompt-templates";
|
|
5
4
|
import type { BashInterceptorRule } from "../config/settings-manager";
|
|
5
|
+
import type { Skill } from "../extensibility/skills";
|
|
6
6
|
import type { InternalUrlRouter } from "../internal-urls";
|
|
7
7
|
import { getPreludeDocs, warmPythonEnvironment } from "../ipy/executor";
|
|
8
8
|
import { checkPythonKernelAvailability } from "../ipy/kernel";
|
|
@@ -144,9 +144,9 @@ export interface ToolSession {
|
|
|
144
144
|
/** Get the current session model string, regardless of how it was chosen */
|
|
145
145
|
getActiveModelString?: () => string | undefined;
|
|
146
146
|
/** Auth storage for passing to subagents (avoids re-discovery) */
|
|
147
|
-
authStorage?: import("
|
|
147
|
+
authStorage?: import("../session/auth-storage").AuthStorage;
|
|
148
148
|
/** Model registry for passing to subagents (avoids re-discovery) */
|
|
149
|
-
modelRegistry?: import("
|
|
149
|
+
modelRegistry?: import("../config/model-registry").ModelRegistry;
|
|
150
150
|
/** MCP manager for proxying MCP calls through parent */
|
|
151
151
|
mcpManager?: import("../mcp/manager").MCPManager;
|
|
152
152
|
/** Internal URL router for agent:// and skill:// URLs */
|
|
@@ -155,7 +155,7 @@ export interface ToolSession {
|
|
|
155
155
|
agentOutputManager?: AgentOutputManager;
|
|
156
156
|
/** Settings manager for passing to subagents (avoids SQLite access in workers) */
|
|
157
157
|
settingsManager?: {
|
|
158
|
-
serialize: () => import("
|
|
158
|
+
serialize: () => import("../config/settings-manager").Settings;
|
|
159
159
|
getPlansDirectory: (cwd?: string) => string;
|
|
160
160
|
};
|
|
161
161
|
/** Settings manager (optional) */
|