@hank-warren/pi-plan-mode 1.3.0 → 1.4.0
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 +8 -0
- package/README.md +16 -5
- package/package.json +5 -1
- package/skills/pi-plan-mode/SKILL.md +81 -0
- package/src/presentation.ts +105 -23
- package/src/prompt.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @hank-warren/pi-plan-mode
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 449f989: Ships a companion `pi-plan-mode` skill, making this a hybrid package: the system prompt stays the short enforcement surface and points at the skill for the plan-crafting craft — what decision-complete means, exploring before asking, what separates a question worth asking from one the repository already answers, and what a finished plan contains.
|
|
8
|
+
|
|
9
|
+
The footer status and the editor widget now render from one formatter, so they cannot drift, in a glyph vocabulary shared with `pi-loop`: `◆ plan · drafting`, `◆ plan · revising`, `◆ plan · ready → /plan`, `▶ plan · implementing`, each with a dim hint line in the widget. Statuslines that render extension statuses will show the new strings in place of `plan active` / `plan ready` / `plan implementing`.
|
|
10
|
+
|
|
3
11
|
## 1.3.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ The plan is written to a **durable file** that survives compaction, survives res
|
|
|
17
17
|
- Two ways to implement: continue in this conversation, or open a fresh session that reads the same file.
|
|
18
18
|
- `/plan export [path]` copies the plan anywhere, never overwriting an existing target.
|
|
19
19
|
- Hand-edit the plan file at any time; every command and both implementation paths read from disk.
|
|
20
|
+
- A companion `pi-plan-mode` **skill**, loaded on demand, carrying the plan-crafting craft the prompt only points at.
|
|
20
21
|
|
|
21
22
|
## 📦 Install
|
|
22
23
|
|
|
@@ -117,13 +118,22 @@ Detection is by tool name at runtime, re-evaluated every turn — there is no de
|
|
|
117
118
|
|
|
118
119
|
A standalone `pi-plan-mode` install loses nothing: `plan_mode_question` stays fully functional and the prompt reads exactly as it always has. It is a **legacy fallback** and is slated for removal in a future major.
|
|
119
120
|
|
|
120
|
-
##
|
|
121
|
+
## 📚 The companion skill
|
|
121
122
|
|
|
122
|
-
|
|
123
|
+
The package ships a `pi-plan-mode` skill (`skills/pi-plan-mode/SKILL.md`) alongside the extension. The system prompt is the enforcement surface and stays deliberately short; the skill is the depth layer it points at — what decision-complete actually means, why exploration comes before questions, what separates a question worth asking from one the repository already answered, and what belongs in a finished plan. One line in the planning prompt names it, and the model loads the body when it judges it needs it.
|
|
123
124
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
Skill and extension version as one artifact: a skill describing a mode the installed extension does not have is a coupling failure waiting to happen.
|
|
126
|
+
|
|
127
|
+
## 📊 Statusline and widget
|
|
128
|
+
|
|
129
|
+
The footer status and the widget above the editor render from **one formatter**, so they cannot drift, and they share a glyph vocabulary with the sibling [`pi-loop`](../pi-loop): `◆` for a state wanting a decision, `▶` for work under way.
|
|
130
|
+
|
|
131
|
+
- `◆ plan · drafting` — planning is under way.
|
|
132
|
+
- `◆ plan · revising` — feedback superseded a completed plan; the stored one is not current.
|
|
133
|
+
- `◆ plan · ready → /plan` — a completed plan is waiting for your choice.
|
|
134
|
+
- `▶ plan · implementing` — a plan file is active and guiding implementation.
|
|
135
|
+
|
|
136
|
+
The widget adds a dim second line naming what to do next.
|
|
127
137
|
|
|
128
138
|
## 🗂️ Package layout
|
|
129
139
|
|
|
@@ -135,6 +145,7 @@ packages/pi-plan-mode/
|
|
|
135
145
|
│ ├── plan-file.ts # Durable plan file read/write/delete
|
|
136
146
|
│ ├── interactive-ui.ts # Lazily loaded interactive menus
|
|
137
147
|
│ └── *.ts # Prompt, question, export, settings modules
|
|
148
|
+
├── skills/pi-plan-mode/ # Companion plan-crafting skill
|
|
138
149
|
├── test/
|
|
139
150
|
├── README.md
|
|
140
151
|
├── NOTICE.md
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hank-warren/pi-plan-mode",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Plan mode for Pi: research and design with a durable plan file that survives compaction.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -27,11 +27,15 @@
|
|
|
27
27
|
"pi": {
|
|
28
28
|
"extensions": [
|
|
29
29
|
"./index.ts"
|
|
30
|
+
],
|
|
31
|
+
"skills": [
|
|
32
|
+
"./skills/pi-plan-mode"
|
|
30
33
|
]
|
|
31
34
|
},
|
|
32
35
|
"files": [
|
|
33
36
|
"index.ts",
|
|
34
37
|
"src",
|
|
38
|
+
"skills",
|
|
35
39
|
"README.md",
|
|
36
40
|
"NOTICE.md",
|
|
37
41
|
"LICENSE",
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pi-plan-mode
|
|
3
|
+
description: Craft decision-complete implementation plans in Plan mode — explore before asking, ask questions worth answering, and write a plan another agent can execute without guessing. Use while Plan mode is active, before calling plan_mode_complete, and when deciding whether a request needs a plan at all.
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# pi-plan-mode
|
|
8
|
+
|
|
9
|
+
The extension enforces the mechanics: `edit` and `write` are blocked, the plan is written to a durable file, and `plan_mode_complete` is the only way out. It cannot enforce the thing that decides whether the plan was worth making: **whether a competent implementer could execute it without asking you anything.** That is this file.
|
|
10
|
+
|
|
11
|
+
## What "decision-complete" means
|
|
12
|
+
|
|
13
|
+
A plan is finished when every decision it depends on has been made — by discovery, by the user, or by an explicitly recorded assumption. It is not finished when it is long, well organised, or reads confidently.
|
|
14
|
+
|
|
15
|
+
The test: hand the plan to someone who was not in the conversation. Every place they would have to stop and ask "which one?" is an unresolved decision, and every one of those is a defect. That includes:
|
|
16
|
+
|
|
17
|
+
- which of two plausible approaches is being taken, and why the other was rejected;
|
|
18
|
+
- the names and shapes of anything new — files, functions, types, settings keys, tool parameters;
|
|
19
|
+
- what happens on failure, and what happens to state that already exists;
|
|
20
|
+
- how the change is verified, in the form of the commands to run and what they should print;
|
|
21
|
+
- what deliberately stays out of scope.
|
|
22
|
+
|
|
23
|
+
An unresolved decision hidden behind a confident sentence is worse than an open question, because nobody will notice it until implementation stalls.
|
|
24
|
+
|
|
25
|
+
## Phase 1: explore before asking
|
|
26
|
+
|
|
27
|
+
Read the repository first, every time. Questions are expensive — they cost the user's attention and they interrupt — so spend them only on what the code cannot tell you.
|
|
28
|
+
|
|
29
|
+
Facts the environment owns: what already exists, how the neighbours solve the same problem, what the tests cover, what conventions the repo files and `AGENTS.md` impose, what versions are pinned, what a command actually prints. **Never ask about any of them.** A question whose answer was one `rg` away tells the user you did not look, and it trains them to stop answering carefully.
|
|
30
|
+
|
|
31
|
+
Facts the environment does not own, and only the user does: product intent, priorities and tradeoffs, what "good enough" means here, which of two acceptable designs they want to live with, whether a breaking change is acceptable, deadlines and blast-radius tolerance.
|
|
32
|
+
|
|
33
|
+
Exploration also earns the right to disagree. A plan that says "this repo already does X three times, so the fourth should match" is grounded; one that invents a new pattern in a codebase that already has one is a plan the reviewer has to fight.
|
|
34
|
+
|
|
35
|
+
## Phase 2: ask questions worth answering
|
|
36
|
+
|
|
37
|
+
Use the question tool for the decisions that are genuinely the user's. Good questions share a shape:
|
|
38
|
+
|
|
39
|
+
- **The options are real and mutually exclusive.** If one option is obviously right, it is not a question — it is a decision, and you should state it and move on.
|
|
40
|
+
- **Each option says what happens if it is chosen**, not just what it is called. "Store it in the session entry (survives restart, costs a write per turn)" is a choice; "session entry" is a label.
|
|
41
|
+
- **The recommendation comes first and is marked**, so a user who trusts you can answer in one keystroke and one who does not has the alternatives in front of them.
|
|
42
|
+
- **The question is answerable without reading the codebase.** If answering it requires knowing what a function currently does, that is your job, not theirs.
|
|
43
|
+
|
|
44
|
+
Batch decisions that belong to one choice into one call rather than dripping them out over several turns, and stop asking as soon as the remaining ambiguity is low-impact. When the user declines to answer, do not silently pick: state the default you are taking, mark it as an assumption in the plan, and keep the alternative visible.
|
|
45
|
+
|
|
46
|
+
A high-impact ambiguity is a reason to keep planning, never a reason to write a plan that hedges. A plan with two branches in it is two plans and nobody's decision.
|
|
47
|
+
|
|
48
|
+
## Phase 3: write the plan
|
|
49
|
+
|
|
50
|
+
The plan is read by a human deciding whether to approve it and by an agent executing it. Both want the same thing: grouped, behaviour-level changes with the reasoning attached.
|
|
51
|
+
|
|
52
|
+
Structure that works:
|
|
53
|
+
|
|
54
|
+
- **Title and a short summary** — what changes and why, in a few sentences.
|
|
55
|
+
- **The approach**, including the alternatives considered and why they lost. This is the part that survives contact with the implementation; the file list is not.
|
|
56
|
+
- **Behaviour, interface, and data changes** — what a caller or user sees differently, and what the new names and shapes are.
|
|
57
|
+
- **Edge cases and failure modes**, including what happens to existing state and how the change behaves on a host that has the old version.
|
|
58
|
+
- **Verification** — the commands to run and what they should print, plus the manual checks that no command covers.
|
|
59
|
+
- **Assumptions and defaults chosen** — every place you decided rather than asked, stated plainly so it can be corrected.
|
|
60
|
+
|
|
61
|
+
What to leave out: file-by-file or symbol-by-symbol inventories, restatements of the conversation, and speculative future work. A plan is a decision record, not a diff written in prose.
|
|
62
|
+
|
|
63
|
+
Prefer specifics over adjectives. "Add a `groundRules?: string[]` to the persisted state, normalized on read, dropped when empty" is a plan; "improve state handling" is a mood.
|
|
64
|
+
|
|
65
|
+
## Ending a turn, and ending the mode
|
|
66
|
+
|
|
67
|
+
Every planning turn ends in exactly one of two ways: a question, or `plan_mode_complete` called alone as the final action with the whole plan. Never end with prose announcing that a plan is coming — that costs a whole turn and produces nothing.
|
|
68
|
+
|
|
69
|
+
On revision, the next `plan_mode_complete` carries a **complete replacement**, not a delta. If you cannot write a complete replacement yet, keep planning and ask instead.
|
|
70
|
+
|
|
71
|
+
Once the plan is completed the user chooses what happens from the `/plan` menu: implement here, implement in a fresh session that reads the same file, export it, or discard it. The file is the source of truth from then on — it survives compaction, and the user may have hand-edited it, so re-read it before implementing rather than working from memory of what you wrote.
|
|
72
|
+
|
|
73
|
+
## When a plan is the wrong tool
|
|
74
|
+
|
|
75
|
+
Plan mode is for work whose *shape* is uncertain. It is overhead when it is not:
|
|
76
|
+
|
|
77
|
+
- **A single obvious change** — make it. A plan for a one-line fix costs more than the fix.
|
|
78
|
+
- **Pure investigation with no change in view** — investigate in the conversation. Plan mode blocks the tools that would let you experiment, and there is nothing to decide yet.
|
|
79
|
+
- **Work whose difficulty is execution, not design** ("run this migration on 40 hosts") → the interesting part is a runbook and a rollout order, not a design decision.
|
|
80
|
+
|
|
81
|
+
Say so in one line and offer the alternative rather than producing a plan nobody needed.
|
package/src/presentation.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
1
2
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
3
|
import { readPlanFile } from "./plan-file.js";
|
|
3
4
|
import type { PlanModeState } from "./state.js";
|
|
@@ -5,25 +6,111 @@ import type { PlanModeState } from "./state.js";
|
|
|
5
6
|
const STATUS_KEY = "plan-mode";
|
|
6
7
|
const PLAN_WIDGET_KEY = "plan-mode-plan";
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* The one thing both surfaces render.
|
|
11
|
+
*
|
|
12
|
+
* The footer and the widget say the same thing in two sizes, so they are
|
|
13
|
+
* formatted once. When each formatted its own they drifted — the sibling
|
|
14
|
+
* pi-loop shipped a loop that read as "waiting" in the footer and "running"
|
|
15
|
+
* above the editor for exactly that reason, and this is the same shape of
|
|
16
|
+
* bug waiting to happen with "ready" and "implementing".
|
|
17
|
+
*
|
|
18
|
+
* The glyphs are the family vocabulary shared with pi-loop by convention
|
|
19
|
+
* rather than by import: `◆` planning or ready, `▶` implementing. Six
|
|
20
|
+
* characters do not justify a shared package; a user reading a footer
|
|
21
|
+
* justifies the consistency.
|
|
22
|
+
*/
|
|
23
|
+
export type PlanModePhase = "drafting" | "revising" | "ready" | "implementing";
|
|
24
|
+
|
|
25
|
+
export interface PlanModeView {
|
|
26
|
+
phase: PlanModePhase;
|
|
27
|
+
/** The footer line: plain text with a glyph, no colour. */
|
|
28
|
+
footer: string;
|
|
29
|
+
/** The widget's headline, rendered bold and themed. */
|
|
30
|
+
headline: string;
|
|
31
|
+
/** The dim second line: what to do next. */
|
|
32
|
+
hint: string;
|
|
33
|
+
/** Accent while the plan wants a decision; normal once it is being built. */
|
|
34
|
+
tone: "accent" | "normal";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function planModeView(state: PlanModeState): PlanModeView | undefined {
|
|
38
|
+
if (state.enabled) {
|
|
39
|
+
if (state.awaitingAction) {
|
|
40
|
+
return {
|
|
41
|
+
phase: "ready",
|
|
42
|
+
footer: "◆ plan · ready → /plan",
|
|
43
|
+
headline: "◆ plan · proposed plan ready",
|
|
44
|
+
hint: "/plan to implement, export, or exit — or type feedback to revise.",
|
|
45
|
+
tone: "accent",
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// A stored plan with no pending action means feedback superseded it: the
|
|
49
|
+
// plan on disk is no longer what is being offered, and saying "drafting"
|
|
50
|
+
// would hide that a completed plan is being replaced.
|
|
51
|
+
if (state.planPath) {
|
|
52
|
+
return {
|
|
53
|
+
phase: "revising",
|
|
54
|
+
footer: "◆ plan · revising",
|
|
55
|
+
headline: "◆ plan · revising the proposed plan",
|
|
56
|
+
hint: "The stored plan is superseded until the next plan_mode_complete.",
|
|
57
|
+
tone: "accent",
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
phase: "drafting",
|
|
62
|
+
footer: "◆ plan · drafting",
|
|
63
|
+
headline: "◆ plan · drafting",
|
|
64
|
+
hint: "Explore and ask; finish with plan_mode_complete when decision-ready.",
|
|
65
|
+
tone: "accent",
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (state.planPath) {
|
|
69
|
+
return {
|
|
70
|
+
phase: "implementing",
|
|
71
|
+
footer: "▶ plan · implementing",
|
|
72
|
+
headline: "▶ plan · implementing",
|
|
73
|
+
hint: "/plan to show, replace, or clear the active plan.",
|
|
74
|
+
tone: "normal",
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The slice of Pi's theme this widget uses. Structural rather than imported so
|
|
82
|
+
* the renderer keeps working against a host whose theme carries neither
|
|
83
|
+
* helper: both are optional, and an absent one degrades to plain text.
|
|
84
|
+
*/
|
|
85
|
+
interface WidgetTheme {
|
|
86
|
+
bold?: (text: string) => string;
|
|
87
|
+
fg?: (color: string, text: string) => string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
type WidgetFactory = Parameters<ExtensionContext["ui"]["setWidget"]>[1];
|
|
91
|
+
|
|
8
92
|
export function updatePlanModeUi(ctx: ExtensionContext, state: PlanModeState) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"Proposed plan ready",
|
|
13
|
-
"Use /plan to implement, export, or exit — or type feedback to revise.",
|
|
14
|
-
]);
|
|
15
|
-
} else if (state.enabled) {
|
|
16
|
-
ctx.ui.setWidget(PLAN_WIDGET_KEY, [
|
|
17
|
-
"Plan mode: planning",
|
|
18
|
-
"Finish with plan_mode_complete when decision-ready.",
|
|
19
|
-
]);
|
|
20
|
-
} else if (state.planPath) {
|
|
21
|
-
ctx.ui.setWidget(PLAN_WIDGET_KEY, [
|
|
22
|
-
"Implementation plan active",
|
|
23
|
-
"Use /plan to show, replace, or clear it.",
|
|
24
|
-
]);
|
|
25
|
-
} else {
|
|
93
|
+
const view = planModeView(state);
|
|
94
|
+
ctx.ui.setStatus(STATUS_KEY, view?.footer);
|
|
95
|
+
if (!view) {
|
|
26
96
|
ctx.ui.setWidget(PLAN_WIDGET_KEY, undefined);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const render = (_tui: unknown, rawTheme: unknown) => {
|
|
101
|
+
const theme = (rawTheme ?? {}) as WidgetTheme;
|
|
102
|
+
const bold = theme.bold ?? ((text: string) => text);
|
|
103
|
+
const headline =
|
|
104
|
+
view.tone === "accent"
|
|
105
|
+
? (theme.fg?.("accent", bold(view.headline)) ?? bold(view.headline))
|
|
106
|
+
: bold(view.headline);
|
|
107
|
+
const hint = theme.fg?.("dim", ` ${view.hint}`) ?? ` ${view.hint}`;
|
|
108
|
+
return new Text(`${headline}\n${hint}`);
|
|
109
|
+
};
|
|
110
|
+
ctx.ui.setWidget(PLAN_WIDGET_KEY, render as WidgetFactory);
|
|
111
|
+
} catch {
|
|
112
|
+
// Presentation only: a host without the component form of setWidget (or a
|
|
113
|
+
// render failure) must never take Plan mode's state transitions with it.
|
|
27
114
|
}
|
|
28
115
|
}
|
|
29
116
|
|
|
@@ -79,6 +166,7 @@ export function showPlanModePlan(
|
|
|
79
166
|
}
|
|
80
167
|
}
|
|
81
168
|
|
|
169
|
+
/** The sentence form, for menus, notifications, and non-TUI modes. */
|
|
82
170
|
export function planModeStatusText(state: PlanModeState) {
|
|
83
171
|
if (state.enabled) {
|
|
84
172
|
if (state.awaitingAction) return "Plan mode is active and a proposed plan is ready.";
|
|
@@ -90,9 +178,3 @@ export function planModeStatusText(state: PlanModeState) {
|
|
|
90
178
|
if (state.planPath) return "An implementation plan is active.";
|
|
91
179
|
return "Plan mode is off.";
|
|
92
180
|
}
|
|
93
|
-
|
|
94
|
-
function formatStatus(state: PlanModeState) {
|
|
95
|
-
if (state.enabled) return state.awaitingAction ? "plan ready" : "plan active";
|
|
96
|
-
if (state.planPath) return "plan implementing";
|
|
97
|
-
return undefined;
|
|
98
|
-
}
|
package/src/prompt.ts
CHANGED
|
@@ -51,6 +51,7 @@ You are in Plan Mode, a collaboration mode for producing a decision-complete imp
|
|
|
51
51
|
|
|
52
52
|
## Mode rules
|
|
53
53
|
|
|
54
|
+
- Read the pi-plan-mode skill before planning if it is available: it carries the plan-crafting craft — decision-completeness, exploring before asking, question quality, and what a finished plan contains.
|
|
54
55
|
- Stay in Plan Mode until a developer or extension explicitly exits it.
|
|
55
56
|
- Treat requests to implement as requests to plan the implementation; do not edit files or carry out the plan.
|
|
56
57
|
- Do not use todo/checklist tooling to track execution progress in Plan Mode; Plan Mode is conversational planning, and the plan itself belongs in plan_mode_complete.
|