@deathbeam/pi-plan 0.0.3 → 0.0.4
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 +2 -0
- package/index.ts +2 -8
- package/media/screenshot.png +0 -0
- package/package.json +4 -2
- package/skills/prepare-plan/SKILL.md +2 -2
- package/src/inspector.ts +65 -53
- package/src/store.ts +1 -1
package/README.md
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
Structured plans: a `plan` tool, a progress widget, and a `/plan` inspector over every plan in the project.
|
|
4
4
|
The bundled `prepare-plan` skill writes a plan, and `import-plan` migrates existing plan documents (`.plans/*.md`, Cursor, Kiro, Taskmaster).
|
|
5
5
|
|
|
6
|
+

|
|
7
|
+
|
|
6
8
|
Plans live in `.pi/plans/<id>.json` at the repository root. Add `.pi/plans/` to `.gitignore` if the first `plan create` cannot write it to `.git/info/exclude`.
|
|
7
9
|
|
|
8
10
|
## Installation
|
package/index.ts
CHANGED
|
@@ -54,7 +54,6 @@ type PlanDetails = {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
const ACTIONS = ["create", "update", "get", "list"] as const;
|
|
57
|
-
const DETAIL_HEADING = /^#{1,3}\s/m;
|
|
58
57
|
|
|
59
58
|
const PlanParams = Type.Object({
|
|
60
59
|
action: StringEnum(ACTIONS),
|
|
@@ -70,7 +69,7 @@ const PlanParams = Type.Object({
|
|
|
70
69
|
detail: Type.Optional(
|
|
71
70
|
Type.String({
|
|
72
71
|
description:
|
|
73
|
-
"create: markdown sections: current behaviour with path:line, problem, chosen design and rejected alternatives, accepted behaviour changes, out of scope, open questions.
|
|
72
|
+
"create: markdown sections: current behaviour with path:line, problem, chosen design and rejected alternatives, accepted behaviour changes, out of scope, open questions.",
|
|
74
73
|
}),
|
|
75
74
|
),
|
|
76
75
|
tasks: Type.Optional(
|
|
@@ -83,8 +82,7 @@ const PlanParams = Type.Object({
|
|
|
83
82
|
description: "Observable result, with the command to run and its expected output.",
|
|
84
83
|
}),
|
|
85
84
|
detail: Type.String({
|
|
86
|
-
description:
|
|
87
|
-
"Approach, interfaces to match, pitfalls, and a Where: line citing path:line. Headings inside use #### or lower.",
|
|
85
|
+
description: "Approach, interfaces to match, pitfalls, and a Where: line citing path:line.",
|
|
88
86
|
}),
|
|
89
87
|
dependsOn: Type.Optional(
|
|
90
88
|
Type.Array(Type.String(), { description: "Task ids this task waits on, such as t1." }),
|
|
@@ -330,10 +328,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
330
328
|
throw new Error(
|
|
331
329
|
"Every task needs a detail: the approach, the interfaces and a Where: path:line.",
|
|
332
330
|
);
|
|
333
|
-
if (DETAIL_HEADING.test(detail) || tasks.some((task) => DETAIL_HEADING.test(task.detail)))
|
|
334
|
-
throw new Error(
|
|
335
|
-
"Headings inside detail use #### or lower; # to ### belong to the plan layout.",
|
|
336
|
-
);
|
|
337
331
|
if (readPlan(root, id)) throw new Error(`Plan ${id} already exists; use get or update.`);
|
|
338
332
|
const plan: Plan = {
|
|
339
333
|
id,
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deathbeam/pi-plan",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Structured plans with a progress widget and a full-screen plan picker",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"index.ts",
|
|
21
21
|
"src",
|
|
22
22
|
"skills",
|
|
23
|
+
"media",
|
|
23
24
|
"README.md",
|
|
24
25
|
"LICENSE"
|
|
25
26
|
],
|
|
@@ -29,7 +30,8 @@
|
|
|
29
30
|
],
|
|
30
31
|
"skills": [
|
|
31
32
|
"./skills"
|
|
32
|
-
]
|
|
33
|
+
],
|
|
34
|
+
"image": "https://cdn.jsdelivr.net/npm/@deathbeam/pi-plan/media/screenshot.png"
|
|
33
35
|
},
|
|
34
36
|
"peerDependencies": {
|
|
35
37
|
"@earendil-works/pi-ai": "*",
|
|
@@ -15,7 +15,7 @@ Write the plan with the `plan` tool, action `create`. The plan is the source of
|
|
|
15
15
|
|
|
16
16
|
3. **Resolve decisions.** Find facts in the code and docs rather than asking. Ask the user only for a decision that changes the plan. Settle a blocking choice before the plan exists and record it in the plan `detail`.
|
|
17
17
|
|
|
18
|
-
4. **Write the plan detail.** Plan `detail` is markdown in sections
|
|
18
|
+
4. **Write the plan detail.** Plan `detail` is markdown in sections:
|
|
19
19
|
|
|
20
20
|
- Current behaviour, with `path:line` for each site.
|
|
21
21
|
- The problem: why that code is wrong today.
|
|
@@ -30,7 +30,7 @@ Write the plan with the `plan` tool, action `create`. The plan is the source of
|
|
|
30
30
|
|
|
31
31
|
- `title`: the deliverable or behaviour, one line.
|
|
32
32
|
- `goal`: the observable result and the command that proves it.
|
|
33
|
-
- `detail`: the approach, the interfaces it must match, the pitfalls, and a `Where:` line citing `path:line` for each file that changes.
|
|
33
|
+
- `detail`: the approach, the interfaces it must match, the pitfalls, and a `Where:` line citing `path:line` for each file that changes.
|
|
34
34
|
|
|
35
35
|
Add `dependsOn` only for a real dependency; tasks without one run at the same time, so keep their files disjoint.
|
|
36
36
|
|
package/src/inspector.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { rawKeyHint, getMarkdownTheme, type ExtensionContext, type Theme } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import {
|
|
3
|
+
Box,
|
|
3
4
|
Markdown,
|
|
5
|
+
Text,
|
|
4
6
|
type Component,
|
|
5
7
|
type Keybinding,
|
|
6
8
|
type KeybindingsManager,
|
|
@@ -8,16 +10,17 @@ import {
|
|
|
8
10
|
type TuiMouseEvent,
|
|
9
11
|
truncateToWidth,
|
|
10
12
|
visibleWidth,
|
|
11
|
-
wrapTextWithAnsi,
|
|
12
13
|
} from "@earendil-works/pi-tui";
|
|
13
14
|
import {
|
|
14
15
|
doneCount,
|
|
15
16
|
hanging,
|
|
16
17
|
nextTask,
|
|
18
|
+
noteItem,
|
|
17
19
|
planCount,
|
|
18
20
|
planStatus,
|
|
19
21
|
statusText,
|
|
20
22
|
type Plan,
|
|
23
|
+
type PlanStatus,
|
|
21
24
|
type PlanList,
|
|
22
25
|
type PlanTask,
|
|
23
26
|
} from "./store.ts";
|
|
@@ -39,8 +42,6 @@ type Focus = "list" | "detail";
|
|
|
39
42
|
|
|
40
43
|
/** Fixed rows: title, top rule, bottom rule, footer. */
|
|
41
44
|
const CHROME_ROWS = 4;
|
|
42
|
-
/** Prose past this width is hard to follow on a wide terminal; the pane leaves the rest empty. */
|
|
43
|
-
const MAX_TEXT_WIDTH = 120;
|
|
44
45
|
/** Rendered markdown by theme, then width and text; cleared by invalidate() and on a width change. */
|
|
45
46
|
const MARKDOWN_CACHE = new WeakMap<Theme, Map<string, string[]>>();
|
|
46
47
|
|
|
@@ -63,7 +64,7 @@ export function hardBreaks(text: string): string {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/** Markdown rendered at one width, cached per theme: render() runs every frame and contexts can be long. */
|
|
66
|
-
function markdown(theme: Theme, text: string, width: number
|
|
67
|
+
function markdown(theme: Theme, text: string, width: number): string[] {
|
|
67
68
|
let cache = MARKDOWN_CACHE.get(theme);
|
|
68
69
|
if (!cache) MARKDOWN_CACHE.set(theme, (cache = new Map()));
|
|
69
70
|
const key = `${width} ${text}`;
|
|
@@ -78,40 +79,47 @@ function markdown(theme: Theme, text: string, width: number, indent = 0): string
|
|
|
78
79
|
while (lines.length && !lines.at(-1)) lines.pop();
|
|
79
80
|
cache.set(key, lines);
|
|
80
81
|
}
|
|
81
|
-
return lines
|
|
82
|
+
return lines;
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
/** A section heading: the word in accent
|
|
85
|
-
function section(theme: Theme, word: string, width: number
|
|
85
|
+
/** A section heading: the word in accent on a rule to the pane edge. */
|
|
86
|
+
function section(theme: Theme, word: string, width: number): string {
|
|
86
87
|
const head = `${theme.bold(theme.fg("accent", word))} `;
|
|
87
|
-
const rule = "─".repeat(Math.max(0, width - visibleWidth(head)
|
|
88
|
-
return head + theme.fg("borderMuted", rule)
|
|
88
|
+
const rule = "─".repeat(Math.max(0, width - visibleWidth(head)));
|
|
89
|
+
return head + theme.fg("borderMuted", rule);
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
/** The
|
|
92
|
+
/** The block header: glyph, muted id, title, then the blockers still open after a dim separator. */
|
|
92
93
|
function taskLines(plan: Plan, task: PlanTask, theme: Theme, width: number, current: boolean): string[] {
|
|
93
94
|
const open = task.dependsOn.filter((id) => !plan.tasks.some((item) => item.id === id && item.status === "done"));
|
|
94
|
-
const
|
|
95
|
+
const after = open.length ? ` ${theme.fg("muted", `· after ${open.join(", ")}`)}` : "";
|
|
95
96
|
// Accent means headings and labels, so the task the reader is on is bold text instead.
|
|
96
97
|
const title = theme.fg("text", task.title);
|
|
97
|
-
const [first = "", ...rest] = hanging(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
const [first = "", ...rest] = hanging(
|
|
99
|
+
`${theme.fg("muted", task.id)} ${current ? theme.bold(title) : title}${after}`,
|
|
100
|
+
width,
|
|
101
|
+
2,
|
|
102
|
+
);
|
|
103
|
+
return [`${statusText(theme, task.status)} ${first}`, ...rest];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** A blank row, the field's accent label on a line of its own, then its value at column 0. */
|
|
107
|
+
function field(theme: Theme, label: string, value: string, width: number): string[] {
|
|
108
|
+
return ["", theme.fg("accent", label), ...markdown(theme, value, width)];
|
|
101
109
|
}
|
|
102
110
|
|
|
103
|
-
/**
|
|
104
|
-
function
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
:
|
|
110
|
-
|
|
111
|
-
return
|
|
111
|
+
/** pi-delegate's tool rows tint a job by status; a task uses the same pi background tokens. */
|
|
112
|
+
function blockBg(theme: Theme, status: PlanStatus): (text: string) => string {
|
|
113
|
+
const bg = {
|
|
114
|
+
doing: "toolPendingBg",
|
|
115
|
+
blocked: "toolErrorBg",
|
|
116
|
+
done: "toolSuccessBg",
|
|
117
|
+
todo: "userMessageBg",
|
|
118
|
+
} as const;
|
|
119
|
+
return (text) => theme.bg(bg[status], text);
|
|
112
120
|
}
|
|
113
121
|
|
|
114
|
-
/** One task
|
|
122
|
+
/** One task as a full-width block tinted by its status, like pi-delegate's transcript entries. */
|
|
115
123
|
function taskBlock(
|
|
116
124
|
plan: Plan,
|
|
117
125
|
task: PlanTask,
|
|
@@ -120,33 +128,40 @@ function taskBlock(
|
|
|
120
128
|
current: boolean,
|
|
121
129
|
expanded: boolean,
|
|
122
130
|
): string[] {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
...
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
const inner = Math.max(1, width - 2);
|
|
132
|
+
const groups = [
|
|
133
|
+
taskLines(plan, task, theme, inner, current),
|
|
134
|
+
...(!expanded && task.status === "done"
|
|
135
|
+
? []
|
|
136
|
+
: [
|
|
137
|
+
field(theme, "Goal", task.goal, inner),
|
|
138
|
+
...(task.detail ? [field(theme, "Detail", task.detail, inner)] : []),
|
|
139
|
+
...(task.notes.length ? [field(theme, "Notes", task.notes.join("\n\n"), inner)] : []),
|
|
140
|
+
]),
|
|
132
141
|
];
|
|
142
|
+
// Same padding as pi's tool-call boxes: one column each side, one row above and below.
|
|
143
|
+
const box = new Box(1, 1, blockBg(theme, task.status));
|
|
144
|
+
// field() leads each group with its blank row, so the groups stay one blank apart.
|
|
145
|
+
box.addChild(new Text(groups.flat().join("\n"), 0, 0));
|
|
146
|
+
// pi-delegate puts one blank row above each block.
|
|
147
|
+
return ["", ...box.render(width)];
|
|
133
148
|
}
|
|
134
149
|
|
|
135
|
-
/** Goal, tasks and
|
|
150
|
+
/** Goal, tasks, detail and notes as sections; the headings show where the reader is in a long plan. */
|
|
136
151
|
function taskRows(plan: Plan, theme: Theme, width: number, expanded: boolean): string[] {
|
|
137
152
|
const current = plan.tasks.find((task) => task.status === "doing") ?? nextTask(plan);
|
|
138
153
|
const blocks = plan.tasks.flatMap((task) => taskBlock(plan, task, theme, width, task === current, expanded));
|
|
139
|
-
// The next heading brings its own leading blank line, so a task's trailing one would double it.
|
|
140
|
-
if (blocks.at(-1) === "") blocks.pop();
|
|
141
154
|
return [
|
|
142
155
|
...markdown(theme, plan.goal, width),
|
|
143
156
|
"",
|
|
144
|
-
section(theme, "Tasks", width
|
|
157
|
+
section(theme, "Tasks", width),
|
|
145
158
|
...blocks,
|
|
146
159
|
"",
|
|
147
160
|
section(theme, "Detail", width),
|
|
148
161
|
...markdown(theme, plan.detail, width),
|
|
149
|
-
...plan.notes.
|
|
162
|
+
...(plan.notes.length
|
|
163
|
+
? ["", section(theme, "Notes", width), ...markdown(theme, plan.notes.flatMap(noteItem).join("\n"), width)]
|
|
164
|
+
: []),
|
|
150
165
|
].map((line) => truncateToWidth(line, width, "…", true));
|
|
151
166
|
}
|
|
152
167
|
|
|
@@ -206,7 +221,7 @@ export class PlansScreen implements Component {
|
|
|
206
221
|
private lastBody = { height: 0, total: 0 };
|
|
207
222
|
private lastIndexes: (number | undefined)[] = [];
|
|
208
223
|
private lastSidebar = 0;
|
|
209
|
-
private
|
|
224
|
+
private lastWidth = 0;
|
|
210
225
|
|
|
211
226
|
constructor(options: PlansScreenOptions) {
|
|
212
227
|
this.options = options;
|
|
@@ -254,7 +269,7 @@ export class PlansScreen implements Component {
|
|
|
254
269
|
const sidebar = sidebarRows(plans, unreadable, this.index, this.active, this.focus, theme, sidebarWidth, body);
|
|
255
270
|
this.lastIndexes = sidebar.indexes;
|
|
256
271
|
const detail = plan
|
|
257
|
-
? this.detail(plan,
|
|
272
|
+
? this.detail(plan, detailWidth, body)
|
|
258
273
|
: [row(theme.fg("muted", "No readable plans."), detailWidth)];
|
|
259
274
|
return [title, rule, ...sidebar.lines.map((line, index) => `${line} ${detail[index] ?? ""}`), rule, footer];
|
|
260
275
|
}
|
|
@@ -298,21 +313,18 @@ export class PlansScreen implements Component {
|
|
|
298
313
|
return { handled: true };
|
|
299
314
|
}
|
|
300
315
|
|
|
301
|
-
/** The right pane: the plan's
|
|
302
|
-
private detail(plan: Plan,
|
|
316
|
+
/** The right pane: the plan's header stays put over the goal, tasks and detail, with a scroll counter below. */
|
|
317
|
+
private detail(plan: Plan, width: number, body: number): string[] {
|
|
303
318
|
const { theme } = this.options;
|
|
304
|
-
if (this.
|
|
305
|
-
this.
|
|
319
|
+
if (this.lastWidth !== width) {
|
|
320
|
+
this.lastWidth = width;
|
|
306
321
|
MARKDOWN_CACHE.delete(theme);
|
|
307
322
|
}
|
|
308
323
|
const blocked = plan.tasks.some((task) => task.status === "blocked") ? " · blocked" : "";
|
|
309
|
-
const progress = theme.fg("muted",
|
|
310
|
-
const
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
];
|
|
314
|
-
const height = Math.max(0, body - header.length - 1);
|
|
315
|
-
const all = taskRows(plan, theme, textWidth, this.expanded);
|
|
324
|
+
const progress = theme.fg("muted", `· ${doneCount(plan)} of ${plan.tasks.length} done${blocked}`);
|
|
325
|
+
const header = `${statusText(theme, planStatus(plan))} ${theme.fg("accent", plan.id)} ${theme.fg("text", plan.title)} ${progress}`;
|
|
326
|
+
const height = Math.max(0, body - 2);
|
|
327
|
+
const all = taskRows(plan, theme, width, this.expanded);
|
|
316
328
|
const start = Math.min(this.top, Math.max(0, all.length - height));
|
|
317
329
|
this.top = start;
|
|
318
330
|
this.lastBody = { height, total: all.length };
|
|
@@ -323,7 +335,7 @@ export class PlansScreen implements Component {
|
|
|
323
335
|
);
|
|
324
336
|
// Right-aligned like pi-delegate's counter; every row is padded so the pane's right edge holds still.
|
|
325
337
|
const tail = " ".repeat(Math.max(0, width - visibleWidth(counter))) + counter;
|
|
326
|
-
return [
|
|
338
|
+
return [header, ...shown, ...Array(Math.max(0, height - shown.length)).fill(""), tail].map((line) =>
|
|
327
339
|
truncateToWidth(line, width, "…", true),
|
|
328
340
|
);
|
|
329
341
|
}
|
package/src/store.ts
CHANGED
|
@@ -179,7 +179,7 @@ export function taskLine(task: PlanTask): string {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
/** Notes as list items; a continuation line indents by two so it stays inside its item. */
|
|
182
|
-
function noteItem(note: string): string[] {
|
|
182
|
+
export function noteItem(note: string): string[] {
|
|
183
183
|
const [first = "", ...rest] = note.split("\n");
|
|
184
184
|
return [`- ${first}`, ...rest.map((line) => ` ${line}`)];
|
|
185
185
|
}
|