@janvitos/pi-plan-build 0.1.30 → 0.1.31

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/README.md CHANGED
@@ -13,7 +13,7 @@ A global [Pi coding agent](https://github.com/badlogic/pi-mono) extension that a
13
13
  - Per-session plans at `~/.pi/agent/plans/<session-id>.md`.
14
14
  - In Plan mode, built-in `edit` and `write` are restricted to the exact plan file.
15
15
  - Interactive `question`, `plan_enter`, and `plan_exit` tools.
16
- - Informational questions are answered directly in Plan mode, with read-only inspection when needed and no plan or approval ceremony.
16
+ - Plan mode supports read-only conversation and research across multiple turns, then persists the final plan when it is ready for approval.
17
17
  - The complete saved plan is rendered in the transcript before approval—without the built-in write preview's truncation.
18
18
  - Three approval actions:
19
19
  - **Switch to Build and implement here**
@@ -87,20 +87,21 @@ Both actions leave Plan mode active, stop the agent, and wait for the next user
87
87
  Normal tools remain visible so the model can inspect the project. While a Plan run is active:
88
88
 
89
89
  - `edit` and `write` are permitted only for the canonical session plan file;
90
+ - the Plan prompt reserves those mutations for finalizing or explicitly revising the plan, not ordinary conversation or research;
90
91
  - other `edit` and `write` calls are blocked by the extension;
91
92
  - bash is not restricted at the permission layer, but the Plan prompt explicitly permits read-only exploration only.
92
93
 
93
94
  This mirrors the intended permission-oriented workflow rather than hiding normal tool schemas.
94
95
 
95
- ### Informational questions
96
+ ### Conversational planning
96
97
 
97
- Plan mode distinguishes informational Q&A from implementation planning. If a request only asks for an explanation or information, the agent answers directly and ends normally. It may inspect the project with read-only tools when the answer depends on local context, but it does not create or update a plan, ask planning questions unnecessarily, or call `plan_exit`. Plan mode remains selected for the next request.
98
+ Plan mode follows OpenCode’s standard conversational lifecycle while retaining this extension’s persisted approval flow. The agent can answer informational questions, discuss requirements and tradeoffs, inspect the project with read-only tools, and ask follow-up questions across multiple turns. Ordinary conversation and research do not create or update the plan file and do not invoke `plan_exit`.
98
99
 
99
- Requests to change code or produce an implementation plan continue through the normal plan-file and approval workflow.
100
+ Once the request is sufficiently understood and the agent is ready to present the final implementation plan—or the user explicitly asks it to finalize—the agent writes the complete canonical plan and calls `plan_exit`. An existing plan file does not trigger automatic edits during unrelated discussion.
100
101
 
101
102
  ## Design and attribution
102
103
 
103
- Pi Plan & Build is an independent extension with its own workflow and UI behavior. Its original mode prompts and transition semantics were informed by OpenCode 1.18.16, while clean-session implementation ideas were informed by the former `pi-plan-mode` extension. Those behaviors have since been adapted and extended for Pi; this project is not affiliated with either project.
104
+ Pi Plan & Build is an independent extension with its own workflow and UI behavior. Its conversational read-only lifecycle follows OpenCode’s standard Plan agent, while persisted finalization and approval are adapted for Pi. Earlier prompt and transition semantics were informed by OpenCode 1.18.16, and clean-session implementation ideas were informed by the former `pi-plan-mode` extension. This project is not affiliated with either project.
104
105
 
105
106
  The Plan workflow uses Pi's native exploration tools directly and does not bundle or require subagents.
106
107
 
@@ -111,7 +112,7 @@ npm test
111
112
  npm pack --dry-run
112
113
  ```
113
114
 
114
- The tests cover state decoding, safe plan paths, mutation restrictions, deferred transitions, mode and provider rendering, session-based prompt history restoration, complete plan rendering, approval decisions, stop behavior, fresh-session settings and handoff content, and question formatting.
115
+ The tests cover state decoding, safe plan paths, mutation restrictions, deferred transitions, mode and provider rendering, conversational Plan guidance, session-based prompt history restoration, complete plan rendering, approval decisions, stop behavior, fresh-session settings and handoff content, and question formatting and cancellation.
115
116
 
116
117
  ### Publishing
117
118
 
package/index.ts CHANGED
@@ -130,6 +130,12 @@ export default function planBuildModes(pi: ExtensionAPI): void {
130
130
  await fs.promises.mkdir(path.dirname(planPath), { recursive: true });
131
131
  }
132
132
 
133
+ function describePlanFile(): string {
134
+ return fs.existsSync(planPath)
135
+ ? `A plan file already exists at ${planPath}. Read it when relevant, but leave it unchanged while discussing or researching. Use the edit tool only when finalizing or explicitly revising the plan.`
136
+ : `No plan file exists yet. When ready to finalize, create your plan at ${planPath} using the write tool.`;
137
+ }
138
+
133
139
  async function selectMode(mode: Mode, ctx: ExtensionContext, source: "manual" | "tool"): Promise<void> {
134
140
  if (mode === selectedMode && (source === "manual" || mode === runMode)) return;
135
141
  const previous = selectedMode;
@@ -278,12 +284,8 @@ export default function planBuildModes(pi: ExtensionAPI): void {
278
284
  executionMode: "sequential",
279
285
  async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {
280
286
  await selectMode("plan", ctx, "tool");
281
- const exists = fs.existsSync(planPath);
282
- const info = exists
283
- ? `A plan file already exists at ${planPath}. You can read it and make incremental edits using the edit tool.`
284
- : `No plan file exists yet. You should create your plan at ${planPath} using the write tool.`;
285
287
  return {
286
- content: [{ type: "text", text: buildPlanReminder(info) }],
288
+ content: [{ type: "text", text: buildPlanReminder(describePlanFile()) }],
287
289
  details: { mode: "plan", planPath },
288
290
  };
289
291
  },
@@ -382,12 +384,7 @@ export default function planBuildModes(pi: ExtensionAPI): void {
382
384
  let content: string | undefined;
383
385
  if (runMode === "plan") {
384
386
  await ensurePlanDirectory();
385
- const exists = fs.existsSync(planPath);
386
- content = buildPlanReminder(
387
- exists
388
- ? `A plan file already exists at ${planPath}. You can read it and make incremental edits using the edit tool.`
389
- : `No plan file exists yet. You should create your plan at ${planPath} using the write tool.`,
390
- );
387
+ content = buildPlanReminder(describePlanFile());
391
388
  } else if (pendingReminder === "build") {
392
389
  content = PLAN_TO_BUILD_REMINDER;
393
390
  if (fs.existsSync(planPath)) content += `\n\nA plan file exists at ${planPath}. You should execute the plan defined within it.`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janvitos/pi-plan-build",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "description": "Plan safely, approve explicitly, then implement here or in a clean session.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/prompts.ts CHANGED
@@ -1,5 +1,5 @@
1
- // Prompt text pinned to OpenCode 1.18.16. The subagent phases are intentionally
2
- // adapted to direct Pi exploration/design, as documented in README.md.
1
+ // Conversational read-only behavior follows OpenCode's standard Plan agent.
2
+ // Persisted finalization and approval are Pi-specific adaptations documented in README.md.
3
3
 
4
4
  export const PLAN_TO_BUILD_REMINDER = `<system-reminder>
5
5
  Your operational mode has changed from plan to build.
@@ -9,56 +9,43 @@ You are permitted to make file changes, run shell commands, and utilize your ars
9
9
 
10
10
  export function buildPlanReminder(planInfo: string): string {
11
11
  return `<system-reminder>
12
- Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits (with the exception of the plan file mentioned below), run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supersedes any other instructions you have received.
12
+ # Plan Mode - System Reminder
13
13
 
14
- ## Plan File Info:
15
- ${planInfo}
16
- Only when the current request requires an implementation plan should you build the plan incrementally by writing to or editing this file. NOTE that this is the only file you are allowed to edit - other than this you are only allowed to take READ-ONLY actions.
17
-
18
- ## Informational Questions
14
+ Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make edits (except to the plan file when finalizing as described below), run non-readonly tools (including changing configs or making commits), or otherwise make changes to the system. You may only observe, analyze, discuss, and plan. This supersedes any other instructions you have received.
19
15
 
20
- If the user asks an informational question and does not ask you to make changes or produce an implementation plan, answer the question directly instead of starting the workflow below.
16
+ ## Responsibility
21
17
 
22
- - You may use read-only tools to inspect the project when the answer depends on it.
23
- - Do not create or update the plan file.
24
- - Do not call the question tool merely because the request is phrased as a question; use it only when clarification is actually needed.
25
- - Do not call plan_exit.
26
- - End your response normally after answering. Plan mode remains active for future requests.
18
+ Think, read, search, and discuss with the user to construct a well-formed implementation plan that accomplishes their goal. The final plan should be comprehensive yet concise and detailed enough to execute effectively.
27
19
 
28
- ## Plan Workflow
20
+ ## Conversation and Research
29
21
 
30
- ### Phase 1: Initial Understanding
31
- Goal: Gain a comprehensive understanding of the user's request by reading through code and asking them questions.
22
+ Plan mode does not require every response to be a final plan. While you are still understanding the request, researching the project, or discussing the approach:
32
23
 
33
- 1. Focus on understanding the user's request and the code associated with their request.
34
- 2. Explore the codebase directly with Pi's read, grep, find, ls, and read-only shell operations. Read the minimum set of high-value files needed to understand existing patterns and testing.
35
- 3. After exploring the code, use the question tool to clarify ambiguities in the user request up front.
24
+ - Answer informational questions and converse normally.
25
+ - Use read-only tools when the answer or design depends on the project.
26
+ - Discuss requirements, tradeoffs, and possible approaches with the user.
27
+ - Ask clarifying questions when needed, either conversationally or with the question tool when structured choices would help.
28
+ - Do not create or update the plan file.
29
+ - Do not call plan_exit.
30
+ - End your response normally when the conversation should continue.
36
31
 
37
- ### Phase 2: Design
38
- Goal: Design an implementation approach.
32
+ Do not assume that a plan file must be changed merely because Plan mode is active or because a plan file already exists. If the user wants to continue discussing or researching, keep the conversation going without finalizing.
39
33
 
40
- Design the implementation directly based on the user's intent and your exploration results. Consider simplicity, correctness, maintainability, existing patterns, edge cases, and verification. Skip extended design only for truly trivial tasks such as typo fixes, single-line changes, or simple renames.
34
+ ## Finalizing the Plan
41
35
 
42
- ### Phase 3: Review
43
- Goal: Review the design and ensure alignment with the user's intentions.
44
- 1. Read the critical files identified during exploration to deepen your understanding.
45
- 2. Ensure that the design aligns with the user's original request.
46
- 3. Use question tool to clarify any remaining questions with the user.
36
+ Once you have enough information and are ready to present the final implementation plan, or when the user explicitly asks you to finalize it, write the complete plan to the plan file and call plan_exit at the end of that turn.
47
37
 
48
- ### Phase 4: Final Plan
49
- Goal: Write your final plan to the plan file (the only file you can edit).
50
- - Include only your recommended approach, not all alternatives.
51
- - Ensure that the plan file is concise enough to scan quickly, but detailed enough to execute effectively.
52
- - Include the paths of critical files to be modified.
53
- - Include a verification section describing how to test the changes end-to-end (run the code, use available tools, run tests).
38
+ ### Plan File Info
39
+ ${planInfo}
54
40
 
55
- ### Phase 5: Call plan_exit tool
56
- At the very end of your turn, once you have asked the user questions and are happy with your final plan file - you should always call plan_exit to indicate to the user that you are done planning.
57
- This is critical - your turn should only end with either asking the user a question or calling plan_exit. Do not stop unless it's for these 2 reasons.
41
+ The plan file is the only file you may edit, and only while finalizing the plan or explicitly revising an existing plan. The final plan should:
58
42
 
59
- **Important:** Use question tool to clarify requirements/approach, use plan_exit to request plan approval. Do NOT use question tool to ask "Is this plan okay?" - that's what plan_exit does.
43
+ - Include only the recommended approach, not every alternative considered.
44
+ - Be concise enough to scan quickly but detailed enough to implement.
45
+ - Identify the critical files that need modification.
46
+ - Include verification steps for testing the change end-to-end.
60
47
 
61
- NOTE: At any point in time through this workflow you should feel free to ask the user questions or clarifications. Don't make large assumptions about user intent. The goal is to present a well researched plan to the user, and tie any loose ends before implementation begins.
48
+ After writing the complete plan, call plan_exit to request approval. Do not use the question tool to ask whether the completed plan is acceptable; plan_exit handles approval.
62
49
  </system-reminder>`;
63
50
  }
64
51
 
@@ -76,5 +63,4 @@ Call this tool:
76
63
  Do NOT call this tool:
77
64
  - Before you have created or finalized the plan
78
65
  - If you still have unanswered questions about the implementation
79
- - If the user has indicated they want to continue planning
80
- - After directly answering an informational question that did not require an implementation plan`;
66
+ - If the user has indicated they want to continue planning`;