@janvitos/pi-plan-build 0.1.25 → 0.1.27

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
@@ -19,13 +19,13 @@ A global [Pi coding agent](https://github.com/badlogic/pi-mono) extension that a
19
19
  - **Switch to Build and implement here**
20
20
  - **Start fresh and implement**
21
21
  - **Stay in Plan mode**
22
- - Staying in Plan mode produces a durable acknowledgement and stops the run until the user responds.
22
+ - Staying in Plan mode—or pressing Escape in the approval dialog—produces a durable acknowledgement and stops the run until the user responds.
23
23
  - Mode state survives reloads, resumes, and forks.
24
24
  - When Pi recreates the custom editor, the latest 100 user prompts from the active session branch are restored for Up/Down history navigation.
25
25
 
26
26
  ## Requirements
27
27
 
28
- - Pi `0.84.1` or newer
28
+ - Pi `0.84.2` or newer
29
29
  - Node.js `22.6` or newer for the test command
30
30
  - TUI or RPC UI support for interactive questions and approval dialogs
31
31
 
@@ -62,7 +62,7 @@ Do not install more than one npm, Git, or local copy at the same time; duplicate
62
62
  | `/plan` | Select Plan mode |
63
63
  | `/build` | Select Build mode |
64
64
  | `pi --plan` | Start a new session in Plan mode |
65
- | `/build-fresh` | Confirm a pending clean-session implementation |
65
+ | `/build-fresh` | Start a pending clean-session implementation manually |
66
66
 
67
67
  The agent may also enter Plan mode with `plan_enter` when planning or investigation is safer than immediate execution.
68
68
 
@@ -71,16 +71,16 @@ The agent may also enter Plan mode with `plan_enter` when planning or investigat
71
71
  When planning is complete, `plan_exit` displays the entire persisted plan and asks whether to:
72
72
 
73
73
  1. implement in the current session;
74
- 2. prepare a clean linked implementation session; or
74
+ 2. start a clean linked implementation session; or
75
75
  3. stay in Plan mode.
76
76
 
77
- Selecting **Start fresh and implement** stops the current run and pre-fills `/build-fresh`. Press Enter to confirm. Pi only exposes session creation to user-invoked command contexts, so this confirmation is required. The command creates a linked child session, copies the approved plan to its canonical plan file, switches it to Build, and starts implementation without transferring the planning conversation.
77
+ Selecting **Start fresh and implement** stops the current run and automatically dispatches `/build-fresh`. Pi 0.84.2 or newer is required for extension command dispatch from an injected user message. The command creates a linked child session, copies the approved plan to its canonical plan file, switches it to Build, and starts implementation without transferring the planning conversation.
78
78
 
79
- Selecting **Stay in Plan mode** displays:
79
+ Selecting **Stay in Plan mode**, or pressing Escape while the approval dialog is open, displays:
80
80
 
81
81
  > Staying in Plan mode. Let me know when you’re ready to revise or implement the plan.
82
82
 
83
- The agent then stops and waits for the next user message.
83
+ Both actions leave Plan mode active, stop the agent, and wait for the next user message.
84
84
 
85
85
  ## Plan-mode permissions
86
86
 
package/index.ts CHANGED
@@ -29,6 +29,7 @@ import {
29
29
  makePlanPath,
30
30
  nextMode,
31
31
  nextThinkingLevel,
32
+ normalizePlanExitChoice,
32
33
  PLAN_EXIT_APPROVE_CHOICE,
33
34
  PLAN_EXIT_FRESH_CHOICE,
34
35
  PLAN_EXIT_STAY_ACKNOWLEDGEMENT,
@@ -289,19 +290,22 @@ export default function planBuildModes(pi: ExtensionAPI): void {
289
290
  if (!plan.trim()) throw new Error("Cannot request plan approval because the plan file is empty");
290
291
  pi.appendEntry(PLAN_REVIEW_ENTRY_TYPE, { plan, planPath });
291
292
  const displayPath = shorten(planPath, ctx.cwd);
292
- const choice = await ctx.ui.select(
293
+ const selection = normalizePlanExitChoice(await ctx.ui.select(
293
294
  `Build Agent: Plan at ${displayPath} is complete. What would you like to do?`,
294
295
  [PLAN_EXIT_APPROVE_CHOICE, PLAN_EXIT_FRESH_CHOICE, PLAN_EXIT_STAY_CHOICE],
295
- );
296
- const decision = classifyPlanExitChoice(choice);
296
+ ));
297
+ const decision = classifyPlanExitChoice(selection.choice);
297
298
  if (decision === "stay") {
298
299
  freshImplementationPlan = undefined;
299
300
  pi.appendEntry(MODE_NOTICE_ENTRY_TYPE, { message: PLAN_EXIT_STAY_ACKNOWLEDGEMENT });
300
- return buildPlanExitStayResult(planPath, choice === undefined);
301
+ return buildPlanExitStayResult(planPath, selection.cancelled);
301
302
  }
302
303
  if (decision === "implement-fresh") {
303
304
  freshImplementationPlan = plan;
304
- ctx.ui.setEditorText("/build-fresh");
305
+ pi.sendUserMessage("/build-fresh", {
306
+ deliverAs: "followUp",
307
+ expandPromptTemplates: true,
308
+ });
305
309
  return buildPlanExitFreshResult(planPath);
306
310
  }
307
311
  freshImplementationPlan = undefined;
@@ -323,7 +327,7 @@ export default function planBuildModes(pi: ExtensionAPI): void {
323
327
  const details = result.details as { approved?: boolean; action?: string } | undefined;
324
328
  if (details?.action === "implement-fresh" && !context.isError) {
325
329
  return new Text(
326
- theme.fg("success", "Clean-session implementation selected — press Enter to run /build-fresh."),
330
+ theme.fg("success", "Clean-session implementation selected — starting automatically."),
327
331
  0,
328
332
  0,
329
333
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janvitos/pi-plan-build",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "description": "Plan safely, approve explicitly, then implement here or in a clean session.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "prepublishOnly": "npm test"
34
34
  },
35
35
  "peerDependencies": {
36
- "@earendil-works/pi-coding-agent": "*",
36
+ "@earendil-works/pi-coding-agent": ">=0.84.2",
37
37
  "@earendil-works/pi-tui": "*",
38
38
  "typebox": "*"
39
39
  },
package/utils.ts CHANGED
@@ -139,7 +139,19 @@ export const PLAN_EXIT_STAY_ACKNOWLEDGEMENT =
139
139
 
140
140
  export type PlanExitDecision = "implement-here" | "implement-fresh" | "stay";
141
141
 
142
- export function classifyPlanExitChoice(choice: string | undefined): PlanExitDecision {
142
+ export interface NormalizedPlanExitChoice {
143
+ choice: string;
144
+ cancelled: boolean;
145
+ }
146
+
147
+ export function normalizePlanExitChoice(choice: string | undefined): NormalizedPlanExitChoice {
148
+ return {
149
+ choice: choice ?? PLAN_EXIT_STAY_CHOICE,
150
+ cancelled: choice === undefined,
151
+ };
152
+ }
153
+
154
+ export function classifyPlanExitChoice(choice: string): PlanExitDecision {
143
155
  if (choice === PLAN_EXIT_APPROVE_CHOICE) return "implement-here";
144
156
  if (choice === PLAN_EXIT_FRESH_CHOICE) return "implement-fresh";
145
157
  return "stay";
@@ -154,7 +166,7 @@ export function buildPlanExitFreshResult(planPath: string) {
154
166
  content: [
155
167
  {
156
168
  type: "text" as const,
157
- text: "The user selected clean-session implementation. Stop now; the /build-fresh command has been prepared for the user to submit.",
169
+ text: "The user selected clean-session implementation. Stop now; /build-fresh is starting automatically.",
158
170
  },
159
171
  ],
160
172
  details: { approved: true, action: "implement-fresh" as const, mode: "plan" as const, planPath },