pi-plans 0.5.7 → 0.7.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/CONTRIBUTING.md +126 -0
- package/README.md +49 -39
- package/agents/ref-analyst.md +7 -4
- package/agents/reviewer.md +12 -3
- package/index.ts +74 -40
- package/package.json +2 -1
- package/references/pi-planning-workflow.md +45 -58
- package/references/plan-artifact-template.md +71 -60
- package/references/state-and-config.md +63 -47
- package/scripts/bench/pi-adapter/pi_plans_bench.py +33 -22
- package/scripts/bench/pi-adapter/rpc_driver.mjs +4 -4
- package/scripts/run-tests.ts +12 -1
- package/scripts/validate.ts +22 -10
- package/skills/debug-and-plan/SKILL.md +4 -4
- package/skills/plan-big/SKILL.md +5 -5
- package/skills/plan-normal/SKILL.md +5 -5
- package/skills/plan-small/SKILL.md +5 -5
- package/skills/plan-with-refs/SKILL.md +8 -8
- package/skills/planning/SKILL.md +1 -1
- package/src/ask-form.ts +4 -4
- package/src/auditor.ts +126 -0
- package/src/auto-approve.ts +1 -1
- package/src/autocomplete.ts +19 -17
- package/src/code-graph/commands.ts +2 -2
- package/src/code-graph/community.ts +1 -1
- package/src/code-graph/paths.ts +1 -1
- package/src/code-graph/watch.ts +2 -2
- package/src/compaction.ts +3 -3
- package/src/config-command.ts +154 -76
- package/src/dashboard.ts +257 -0
- package/src/exec.ts +709 -705
- package/src/global-state.ts +304 -0
- package/src/guard.ts +16 -3
- package/src/messaging.ts +44 -0
- package/src/plan.ts +421 -112
- package/src/query-hook.ts +4 -4
- package/src/refine-prompts.ts +14 -72
- package/src/refine-ui-helpers.ts +24 -5
- package/src/refine-ui-state.ts +1 -1
- package/src/refine-ui.ts +1 -1
- package/src/resume-command.ts +40 -130
- package/src/resume.ts +15 -17
- package/src/role-panels.ts +542 -0
- package/src/run-context.ts +5 -4
- package/src/run-picker.ts +98 -0
- package/src/state.ts +380 -77
- package/src/subagent.ts +32 -1
- package/src/task-tool.ts +100 -0
- package/src/tasks.ts +189 -0
- package/src/thinking-levels.ts +67 -0
- package/src/ui-language.ts +3 -54
- package/src/workflow-state.ts +78 -57
- package/tests/analyze-refs.test.ts +35 -18
- package/tests/ask-choice-pros-cons.test.ts +147 -0
- package/tests/ask-choice-schema.test.ts +0 -12
- package/tests/ask-choice.test.ts +2 -49
- package/tests/ask-form-tool.test.ts +4 -5
- package/tests/ask-form.test.ts +2 -2
- package/tests/auditor.test.ts +111 -0
- package/tests/auto-approve.test.ts +7 -10
- package/tests/autocomplete.test.ts +8 -11
- package/tests/code-graph-apply-action.test.ts +2 -2
- package/tests/code-graph-commands.test.ts +2 -2
- package/tests/code-graph-index.test.ts +2 -2
- package/tests/code-graph-loop.e2e.test.ts +1 -1
- package/tests/code-graph-mutations.test.ts +1 -1
- package/tests/code-graph-rollback.test.ts +1 -1
- package/tests/code-graph-v05.test.ts +2 -2
- package/tests/compaction.test.ts +1 -1
- package/tests/config-command.test.ts +103 -100
- package/tests/dashboard.test.ts +268 -0
- package/tests/exec-lifecycle.test.ts +181 -115
- package/tests/exec-panel-lifecycle.test.ts +106 -251
- package/tests/exec.test.ts +617 -1706
- package/tests/execute-plan.test.ts +44 -19
- package/tests/extension-load.test.ts +48 -0
- package/tests/global-state.test.ts +371 -0
- package/tests/graph-aware-file-tools.test.ts +5 -5
- package/tests/guard.test.ts +1 -1
- package/tests/multi-run.test.ts +184 -0
- package/tests/plan.test.ts +139 -62
- package/tests/plans.test.ts +7 -79
- package/tests/refine-prompts.test.ts +20 -71
- package/tests/refine-resume.test.ts +27 -22
- package/tests/refine-ui.test.ts +6 -15
- package/tests/resume-lifecycle.test.ts +37 -22
- package/tests/resume.test.ts +43 -88
- package/tests/role-panels.test.ts +391 -0
- package/tests/run-context.test.ts +1 -1
- package/tests/run-ownership.test.ts +1 -1
- package/tests/stale-ctx.test.ts +218 -0
- package/tests/state.test.ts +151 -32
- package/tests/subagent-thinking.test.ts +65 -0
- package/tests/subagent-usage.test.ts +1 -1
- package/tests/task-tool.test.ts +61 -0
- package/tests/thinking-levels.test.ts +77 -0
- package/tests/ui-language.test.ts +2 -17
- package/tests/workflow-state.test.ts +17 -99
- package/tools/analyze-refs.ts +67 -32
- package/tools/ask-choice.ts +19 -49
- package/tools/code-graph.ts +2 -2
- package/tools/execute-plan.ts +63 -33
- package/tools/graph-aware-file-tools.ts +6 -4
- package/tools/plans.ts +40 -66
- package/tools/refine.ts +101 -164
- package/agents/criticizer.md +0 -18
- package/scripts/bench/pi-adapter/__pycache__/pi_plans_bench.cpython-312.pyc +0 -0
- package/src/panel.ts +0 -473
- package/src/termination-prompt.ts +0 -73
- package/tests/goal-wait.test.ts +0 -269
- package/tests/panel-i-zero.test.ts +0 -420
- package/tests/panel.test.ts +0 -355
package/index.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* pi-plans — human-in-the-loop planning for the Pi coding agent.
|
|
3
3
|
*
|
|
4
|
-
* Researched, refined Markdown plans before any code changes. The
|
|
4
|
+
* Researched, refined Markdown plans before any code changes. The six
|
|
5
5
|
* planning skills are contributed via resources_discover; the extension
|
|
6
6
|
* provides the supporting machinery:
|
|
7
7
|
*
|
|
8
|
-
* - `plans` tool — workspace state (config, runs, ledgers) in .git/
|
|
8
|
+
* - `plans` tool — workspace state (config, runs, ledgers) in .git/pi-plans/
|
|
9
9
|
* - `ask_choice` tool — the choice-prompt contract (Other / Auto-complete rules)
|
|
10
|
-
* - `refine` tool — reviewer
|
|
10
|
+
* - `refine` tool — reviewer rounds (findings + questions) via read-only pi subagents
|
|
11
11
|
* - `execute_plan` — execution handoff into the tracked execution loop
|
|
12
12
|
* - write guard — planning runs may only write planning artifacts
|
|
13
|
-
* - execution loop —
|
|
13
|
+
* - execution loop — task-tree injection, plans_update_task tracking, dashboard, audit
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
requestPlanningCompaction,
|
|
45
45
|
restoreFromSession,
|
|
46
46
|
stopExecution,
|
|
47
|
+
toggleDashboardExpanded,
|
|
47
48
|
updateStatusWidget,
|
|
48
49
|
shouldTriggerPlanningCompaction,
|
|
49
50
|
} from "./src/exec.ts";
|
|
@@ -75,14 +76,18 @@ import { restartWatcherIfEnabled, stopGraphWatcher, disableWatcher } from "./src
|
|
|
75
76
|
import { latestPlanVersion, nextPlanVersionPath } from "./src/plan.ts";
|
|
76
77
|
import { configPiPlansCommand } from "./src/config-command.ts";
|
|
77
78
|
import { resumePlansCommand } from "./src/resume-command.ts";
|
|
78
|
-
import { getRun, loadConfig, readActive, recordDecision, resolveStateRootOrNull, setRunStatus } from "./src/state.ts";
|
|
79
|
+
import { getRun, listRuns, loadConfig, readActive, recordDecision, resolveStateRootOrNull, setRunStatus } from "./src/state.ts";
|
|
79
80
|
import { boundRunId, resolveActiveRun, restoreRunBindingFromSession } from "./src/run-context.ts";
|
|
81
|
+
import { abandonCandidates, resolveCommandRun } from "./src/run-picker.ts";
|
|
80
82
|
import { applyPlanWritten, mutateCheckpoint, planIdentityOf } from "./src/workflow-state.ts";
|
|
81
83
|
import { registerAskChoiceTool } from "./tools/ask-choice.ts";
|
|
82
84
|
import { executeCommand, registerExecutePlanTool } from "./tools/execute-plan.ts";
|
|
85
|
+
import { registerTaskStatusTool } from "./src/task-tool.ts";
|
|
86
|
+
import { flattenTaskViews, taskIsTerminal, taskProgress } from "./src/tasks.ts";
|
|
83
87
|
import { registerPlansTool } from "./tools/plans.ts";
|
|
84
88
|
import { registerRefineTool } from "./tools/refine.ts";
|
|
85
89
|
import { registerAnalyzeRefsTool } from "./tools/analyze-refs.ts";
|
|
90
|
+
import { messaging, setMessagingApi } from "./src/messaging.ts";
|
|
86
91
|
|
|
87
92
|
const baseDir = dirname(fileURLToPath(import.meta.url));
|
|
88
93
|
|
|
@@ -125,11 +130,17 @@ function hasActivePlanningWorkflow(ctx: Parameters<typeof updateStatusWidget>[0]
|
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
133
|
+
setMessagingApi(pi);
|
|
128
134
|
registerPlansTool(pi);
|
|
129
135
|
registerAskChoiceTool(pi);
|
|
130
136
|
registerRefineTool(pi, baseDir);
|
|
131
137
|
registerAnalyzeRefsTool(pi, baseDir);
|
|
132
138
|
registerExecutePlanTool(pi);
|
|
139
|
+
registerTaskStatusTool(pi);
|
|
140
|
+
pi.registerShortcut("ctrl+shift+t", {
|
|
141
|
+
description: "Expand/collapse the pi-plans task dashboard",
|
|
142
|
+
handler: (ctx) => toggleDashboardExpanded(ctx),
|
|
143
|
+
});
|
|
133
144
|
registerQueryInterviewHooks(pi, hasActivePlanningWorkflow);
|
|
134
145
|
registerCodeGraphTool(pi);
|
|
135
146
|
registerGraphAwareFileTools(pi);
|
|
@@ -176,7 +187,7 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
176
187
|
handler: async (args, ctx) => {
|
|
177
188
|
const invocation = args.trim() ? `/skill:${name} ${args.trim()}` : `/skill:${name}`;
|
|
178
189
|
try {
|
|
179
|
-
|
|
190
|
+
messaging().sendUserMessage(invocation, { expandPromptTemplates: true });
|
|
180
191
|
} catch {
|
|
181
192
|
ctx.ui.notify("Agent is busy; try again once the current turn finishes.", "error");
|
|
182
193
|
}
|
|
@@ -206,7 +217,7 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
206
217
|
if (active) {
|
|
207
218
|
const latest = latestPlanVersion(active.artifact_dir);
|
|
208
219
|
if (latest && path.resolve(ctx.cwd, rawPath) === path.resolve(ctx.cwd, latest.path)) {
|
|
209
|
-
|
|
220
|
+
messaging().appendEntry(PLANNING_PLAN_WRITTEN_CUSTOM_TYPE, {
|
|
210
221
|
runId: active.run_id,
|
|
211
222
|
planPath: latest.path,
|
|
212
223
|
});
|
|
@@ -252,14 +263,14 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
252
263
|
if (event.toolName !== "plans") return;
|
|
253
264
|
if (!consumePrePlanCompactPending(ctx)) return;
|
|
254
265
|
if (typeof ctx.compact !== "function") {
|
|
255
|
-
sendPrePlanCompactResume(
|
|
266
|
+
sendPrePlanCompactResume(ctx);
|
|
256
267
|
return;
|
|
257
268
|
}
|
|
258
269
|
let resumed = false;
|
|
259
270
|
const resumeOnce = () => {
|
|
260
271
|
if (resumed) return;
|
|
261
272
|
resumed = true;
|
|
262
|
-
sendPrePlanCompactResume(
|
|
273
|
+
sendPrePlanCompactResume(ctx);
|
|
263
274
|
};
|
|
264
275
|
ctx.compact({
|
|
265
276
|
customInstructions: PLANNING_PREPLAN_COMPACT_HINT,
|
|
@@ -311,18 +322,18 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
311
322
|
|
|
312
323
|
pi.on("session_before_compact", async (event, ctx) => {
|
|
313
324
|
noteCompactionStarted(ctx, event.customInstructions);
|
|
314
|
-
const executionResult = await handleExecutionBeforeCompact(
|
|
325
|
+
const executionResult = await handleExecutionBeforeCompact(ctx, event);
|
|
315
326
|
if (executionResult) return executionResult;
|
|
316
|
-
return handlePlanningBeforeCompact(
|
|
327
|
+
return handlePlanningBeforeCompact(ctx, event);
|
|
317
328
|
});
|
|
318
329
|
pi.on("session_compact", async (event, ctx) => {
|
|
319
|
-
await handleExecutionCompact(
|
|
320
|
-
await handlePlanningCompact(
|
|
330
|
+
await handleExecutionCompact(ctx, event);
|
|
331
|
+
await handlePlanningCompact(ctx, event);
|
|
321
332
|
noteCompactionEnded(ctx, event.customInstructions);
|
|
322
333
|
});
|
|
323
334
|
pi.on("session_compact_failed", async (event, ctx) => {
|
|
324
|
-
handleExecutionCompactFailed(
|
|
325
|
-
handlePlanningCompactFailed(
|
|
335
|
+
handleExecutionCompactFailed(ctx, event);
|
|
336
|
+
handlePlanningCompactFailed(ctx, event);
|
|
326
337
|
noteCompactionEnded(ctx, event.customInstructions);
|
|
327
338
|
});
|
|
328
339
|
|
|
@@ -330,7 +341,7 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
330
341
|
// Execution loop: inject remaining checklist each turn, track markers.
|
|
331
342
|
// -----------------------------------------------------------------------
|
|
332
343
|
pi.on("before_agent_start", async (_event, ctx) => {
|
|
333
|
-
drainExecutionFlush(
|
|
344
|
+
drainExecutionFlush(ctx);
|
|
334
345
|
const content = executionContextMessage(ctx);
|
|
335
346
|
if (!content) {
|
|
336
347
|
if (!getExecution() && shouldTriggerPlanningCompaction(ctx)) {
|
|
@@ -370,7 +381,7 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
370
381
|
// -----------------------------------------------------------------------
|
|
371
382
|
|
|
372
383
|
pi.registerCommand("init-graph", {
|
|
373
|
-
description: "Index the worktree into .git/
|
|
384
|
+
description: "Index the worktree into .git/pi-plans/code_graph.db. If a graph DB already exists, prompt to rebuild or sync changed paths via /update-graph; `--reindex` and non-interactive runs stay on the rebuild path.",
|
|
374
385
|
handler: async (args, ctx) => {
|
|
375
386
|
await initGraphCommand(args, ctx);
|
|
376
387
|
},
|
|
@@ -436,23 +447,38 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
436
447
|
description: "Show pi-plans state: config, active run, and execution progress",
|
|
437
448
|
handler: async (_args, ctx) => {
|
|
438
449
|
const lines: string[] = [];
|
|
450
|
+
// v0.6.0: list ALL runs (newest first, bound marked, cap 50) instead of
|
|
451
|
+
// only the shared active one — multi-run workdirs stay legible.
|
|
452
|
+
const runs = listRuns(ctx.cwd).slice(0, 50);
|
|
453
|
+
const bound = boundRunId(ctx.sessionManager, ctx.cwd);
|
|
454
|
+
if (runs.length === 0) {
|
|
455
|
+
lines.push("No planning runs recorded in this workdir.");
|
|
456
|
+
} else {
|
|
457
|
+
lines.push(`Runs (${runs.length} shown, newest first):`);
|
|
458
|
+
for (const run of runs) {
|
|
459
|
+
lines.push(` ${run.run_id === bound ? "★" : " "} ${run.topic} · ${run.status} · ${run.skill} · ${run.updated_at}`);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
439
462
|
const active = resolveActiveRun(ctx.sessionManager, ctx.cwd);
|
|
440
463
|
const run = active ? getRun(ctx.cwd, active.run_id) : null;
|
|
441
|
-
if (
|
|
442
|
-
lines.push(
|
|
443
|
-
} else {
|
|
444
|
-
lines.push(`Active run: ${run.run_id}`);
|
|
464
|
+
if (run) {
|
|
465
|
+
lines.push(`Session run: ${run.run_id}`);
|
|
445
466
|
lines.push(`Skill: ${run.skill} Status: ${run.status}`);
|
|
446
467
|
lines.push(`Artifacts: ${run.artifact_dir}`);
|
|
447
468
|
lines.push(`Language: ${run.language_tag ?? "(unset)"}`);
|
|
448
469
|
lines.push(`State: ${resolveStateRootOrNull(ctx.cwd) ?? "(no repo)"}`);
|
|
449
470
|
}
|
|
471
|
+
// One-time active.json deprecation note (v0.6.0 registry migration).
|
|
472
|
+
if (fs.existsSync(path.join(resolveStateRootOrNull(ctx.cwd) ?? ".git/pi-plans", "active.json"))) {
|
|
473
|
+
lines.push("Note: active.json is deprecated — the run registry now derives from runs/*/run.json; the legacy file is ignored.");
|
|
474
|
+
}
|
|
450
475
|
const execution = getExecution();
|
|
451
476
|
if (execution) {
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
477
|
+
const progress = taskProgress(execution.tasks);
|
|
478
|
+
const vcDone = execution.items.filter((item) => item.done).length;
|
|
479
|
+
lines.push(`Execution: ${execution.planPath} — tasks ${progress.done}/${progress.total} · VC ${vcDone}/${execution.items.length}`);
|
|
480
|
+
for (const task of flattenTaskViews(execution.tasks)) {
|
|
481
|
+
lines.push(` ${taskIsTerminal(task) ? (task.status === "skipped" ? "~" : "☑") : "☐"} ${task.id}`);
|
|
456
482
|
}
|
|
457
483
|
}
|
|
458
484
|
lines.push(`Auto-complete: ${autoCompleteStatus(ctx)}`);
|
|
@@ -462,7 +488,7 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
462
488
|
});
|
|
463
489
|
|
|
464
490
|
pi.registerCommand("config-pi-plans", {
|
|
465
|
-
description: "Re-ask and update pi-plans workspace config: language, artifact root, graph,
|
|
491
|
+
description: "Re-ask and update pi-plans workspace config: language, artifact root, graph, and reviewer defaults",
|
|
466
492
|
handler: async (args, ctx) => {
|
|
467
493
|
await configPiPlansCommand(args, ctx);
|
|
468
494
|
},
|
|
@@ -538,7 +564,7 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
538
564
|
`${doneIds.length}/${execution.items.length} verifier item(s) already verified; their work stays. Remaining items return to planning.`,
|
|
539
565
|
);
|
|
540
566
|
if (!ok) return;
|
|
541
|
-
await stopExecution(
|
|
567
|
+
await stopExecution(ctx, "interrupted by /update-plan");
|
|
542
568
|
}
|
|
543
569
|
|
|
544
570
|
// Return the run to planning so refinement rules and guards apply again.
|
|
@@ -586,7 +612,7 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
586
612
|
"Follow the original planning-skill contract for revisions: collect needed clarifications via ask_choice (one question at a time, recorded), apply evidence-based revisions only, then ask the next merged accept/execute question (autoComplete: false — ✓ Accept & execute now / Accept, don't execute yet / another round) and call execute_plan pointing at the new version on accept.",
|
|
587
613
|
);
|
|
588
614
|
|
|
589
|
-
await
|
|
615
|
+
await messaging().sendUserMessage(lines.join("\n"));
|
|
590
616
|
},
|
|
591
617
|
});
|
|
592
618
|
|
|
@@ -597,9 +623,9 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
597
623
|
ctx.ui.notify("No execution in progress.", "info");
|
|
598
624
|
return;
|
|
599
625
|
}
|
|
600
|
-
const ok = await ctx.ui.confirm("Stop execution?", "
|
|
626
|
+
const ok = await ctx.ui.confirm("Stop execution?", "Open tasks will be left unfinished.");
|
|
601
627
|
if (!ok) return;
|
|
602
|
-
await stopExecution(
|
|
628
|
+
await stopExecution(ctx, "stopped by user via /plans-stop");
|
|
603
629
|
ctx.ui.notify("Execution stopped.", "info");
|
|
604
630
|
},
|
|
605
631
|
});
|
|
@@ -608,31 +634,38 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
608
634
|
description:
|
|
609
635
|
"Resume the working plan in this repository: unfinished planning / reviewing / execution / implementation review, across sessions and linked worktrees, in the current session.",
|
|
610
636
|
handler: async (_args, ctx) => {
|
|
611
|
-
await resumePlansCommand(
|
|
637
|
+
await resumePlansCommand(ctx, baseDir);
|
|
612
638
|
},
|
|
613
639
|
});
|
|
614
640
|
|
|
615
641
|
pi.registerCommand("plans-abandon", {
|
|
616
642
|
description: "Abandon the active planning run (lifts the read-only guard; artifacts are kept)",
|
|
617
643
|
handler: async (_args, ctx) => {
|
|
618
|
-
|
|
619
|
-
|
|
644
|
+
// v0.6.0 (R-3): pick the run to abandon when several candidates exist;
|
|
645
|
+
// binding-first, single candidate stays direct (0.5.7 parity).
|
|
646
|
+
const chosen = await resolveCommandRun(
|
|
647
|
+
{ cwd: ctx.cwd, sessionManager: ctx.sessionManager, ui: ctx.ui },
|
|
648
|
+
{ candidates: abandonCandidates(ctx.cwd), title: "Abandon which run?" },
|
|
649
|
+
);
|
|
650
|
+
if (!chosen) {
|
|
620
651
|
ctx.ui.notify("No active planning run.", "info");
|
|
621
652
|
return;
|
|
622
653
|
}
|
|
654
|
+
const active = resolveActiveRun(ctx.sessionManager, ctx.cwd);
|
|
655
|
+
const abandoningBound = active?.run_id === chosen.run_id;
|
|
623
656
|
const ok = await ctx.ui.confirm(
|
|
624
657
|
"Abandon planning run?",
|
|
625
|
-
`${
|
|
658
|
+
`${chosen.run_id} (${chosen.topic} · ${chosen.status})\nThe read-only guard lifts; committed artifacts stay in place.`,
|
|
626
659
|
);
|
|
627
660
|
if (!ok) return;
|
|
628
661
|
// Abandon must end execution first so the planning model is restored.
|
|
629
662
|
disableAutoComplete(ctx, "run abandoned");
|
|
630
|
-
if (getExecution()) {
|
|
631
|
-
await stopExecution(
|
|
663
|
+
if (abandoningBound && getExecution()) {
|
|
664
|
+
await stopExecution(ctx, "run abandoned via /plans-abandon");
|
|
632
665
|
}
|
|
633
666
|
try {
|
|
634
|
-
setRunStatus(ctx.cwd,
|
|
635
|
-
|
|
667
|
+
setRunStatus(ctx.cwd, chosen.run_id, "abandoned");
|
|
668
|
+
ctx.ui.notify(`Run ${chosen.run_id} abandoned.`, "info");
|
|
636
669
|
} catch (error) {
|
|
637
670
|
ctx.ui.notify(`Failed: ${(error as Error).message}`, "error");
|
|
638
671
|
}
|
|
@@ -644,7 +677,7 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
644
677
|
// Session lifecycle
|
|
645
678
|
// -----------------------------------------------------------------------
|
|
646
679
|
pi.on("session_tree", async (_event, ctx) => {
|
|
647
|
-
await restoreFromSession(
|
|
680
|
+
await restoreFromSession(ctx, ctx.sessionManager.getBranch() as unknown as Parameters<typeof restoreFromSession>[1]);
|
|
648
681
|
restoreRunBindingFromSession(
|
|
649
682
|
ctx.sessionManager,
|
|
650
683
|
ctx.cwd,
|
|
@@ -652,7 +685,7 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
652
685
|
);
|
|
653
686
|
});
|
|
654
687
|
pi.on("session_start", async (_event, ctx) => {
|
|
655
|
-
await restoreFromSession(
|
|
688
|
+
await restoreFromSession(ctx, ctx.sessionManager.getBranch() as unknown as Parameters<typeof restoreFromSession>[1]);
|
|
656
689
|
restoreAutoCompleteFromSession(ctx, ctx.sessionManager.getEntries() as unknown as Parameters<typeof restoreAutoCompleteFromSession>[1]);
|
|
657
690
|
restoreRunBindingFromSession(
|
|
658
691
|
ctx.sessionManager,
|
|
@@ -661,3 +694,4 @@ export default function piPlansExtension(pi: ExtensionAPI): void {
|
|
|
661
694
|
);
|
|
662
695
|
});
|
|
663
696
|
}
|
|
697
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-plans",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Human-in-the-loop planning extension for the Pi coding agent: researched, refined Markdown plans before any code changes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"files": [
|
|
41
41
|
"README.md",
|
|
42
42
|
"LICENSE",
|
|
43
|
+
"CONTRIBUTING.md",
|
|
43
44
|
"index.ts",
|
|
44
45
|
"agents/",
|
|
45
46
|
"docs/assets",
|
|
@@ -9,17 +9,17 @@ This skill set is written for the Pi coding agent's documented behavior:
|
|
|
9
9
|
- the five skills are contributed by the pi-plans extension and loaded as Pi skills (also invokable as `/skill:<name>`);
|
|
10
10
|
- skill references and helper sources are resolved relative to the directory containing `SKILL.md`;
|
|
11
11
|
- Planning and reference analysis run with the extension tools `plans`, `ask_choice`, `refine`, `analyze_refs`, and `execute_plan`;
|
|
12
|
-
- `refine` spawns read-only Pi subagents (`pi --mode json -p --no-session --tools read,grep,find,ls`, plus `code_graph`
|
|
12
|
+
- `refine` spawns read-only Pi subagents (`pi --mode json -p --no-session --tools read,grep,find,ls`, plus `code_graph` when workspace `graph_enabled` is true) with isolated context; delegated reviewer runs show a standalone aggregate overlay titled `Reviewer` (78% × 78% top-center, ≥72 cols, no input row), stream assistant/thinking/tool events into per-lane transcripts with follow-bottom scroll, dismiss on `Esc` (close-only — the refiner child keeps running and its result still flows back as tool output), replace any retained finished overlay when a new round begins, and return conclusions to the main session as tool output; `analyze_refs` spawns one read-only subagent per downloaded reference (cwd = that ref's directory) reusing the reviewer role gates, shows the same overlay titled `Refs` in batches of at most 3 lanes, and returns structured per-reference sections for `REF_ANALYSIS.md`;
|
|
13
13
|
- when graph mode is enabled, graph-aware `read`/`edit` overrides are active for indexed source files: `read` returns a capped function digest (≤50 lines, synthetic anonymous entries folded) by default — drill in via `offset/limit` or `code_graph get-function`, and `full: true` is the only whole-file exit (small/zero-function files return full text; safety truncation matches native read); `write`/`edit` stage DB-first mutations until materialized via the `code_graph` tool's `apply` action (same planning/accepted gate as /apply-graph; refused for read-only refiner subagents via the PI_PLANS_REFINER marker; returns a per-file report with counts and a post-apply drift summary, and never changes run status); unexpected fallbacks (`not indexed` / `runtime unavailable` / `config read failed`) are marked at the top of the result while flag-off fallbacks stay unmarked;
|
|
14
|
-
- the execution loop is extension-managed: remaining
|
|
14
|
+
- the execution loop is extension-managed and task-tree driven: the current wave and remaining tasks are injected each turn, progress is reported exclusively through the `plans_update_task` tool (status + evidence / skipReason), the task dashboard tracks every task (compact widget; Ctrl+Shift+T expands the tree), and an independent completion auditor verifies the verification checks before the run completes;
|
|
15
15
|
- execution and planning compaction keep Pi's SessionManager as the history owner; during active pi-plans runs, `session_before_compact` uses a deterministic no-LLM VCC-style summary with `[Session Goal]`, `[Files And Changes]`, `[Commits]`, `[Outstanding Context]`, `[User Preferences]`, and a ranked brief transcript; Pi core owns manual `/compact`, threshold, and overflow scheduling, while pi-plans handles smart tail keep, `keep:N`, stats, and phase-specific run/plan/current-I/checklist context; in addition, creating a new planning run (`plans start-run`) proactively requests one pre-plan VCC compaction before the first planning question and resumes the planning turn with a hidden message (default on, `prePlanCompact` in `pi-vcc-config.json`);
|
|
16
16
|
|
|
17
17
|
## Planning Boundary
|
|
18
18
|
|
|
19
19
|
- Treat the user's request as a planning target, not as write authorization.
|
|
20
|
-
- Before the execution handoff, do not edit target source files, docs, configs, package metadata, generated assets, or tests outside the planning artifact directory and the pi-plans state under `.git/
|
|
21
|
-
- The normal pre-handoff writes are `.git/
|
|
22
|
-
- Downloaded references go to the workspace's configured refs root (`refs_root` in `.git/
|
|
20
|
+
- Before the execution handoff, do not edit target source files, docs, configs, package metadata, generated assets, or tests outside the planning artifact directory and the pi-plans state under `.git/pi-plans/`. The extension enforces this for `edit` and `write` while a run is active: only `.git/pi-plans/`, the run's artifact directory, `~/.cache/pi-plans/`, and the configured refs root are writable. Bash is not machine-guarded — keep it read-only by discipline (inspection, `git init`, downloads into the cache).
|
|
21
|
+
- The normal pre-handoff writes are `.git/pi-plans/` state plus planning artifacts under the configured artifact root (default `./.git/pi-plans/plans/...`).
|
|
22
|
+
- Downloaded references go to the workspace's configured refs root (`refs_root` in `.git/pi-plans/config.json`; unset → ask once via `ask_choice`, recommended `.git/pi-plans/refs/`, second `./refs/`, third `~/.cache/pi-plans/refs/`; persist with the `plans` tool, `set-refs-root`) and their paths and evidence are recorded in `REF_ANALYSIS.md`. References are not limited to GitHub repositories: papers (arXiv etc.), engineering blogs, and documentation sites are first-class, with per-medium qualified downloads (repo = clone; paper = full text — abstracts never qualify; blog/docs = full-article markdown) and one directory per reference; theoretical references count exactly as much as implementation references. plan-normal and plan-big may optionally cite 1–2 search-found references (URLs in the plan's Evidence section) without downloading them.
|
|
23
23
|
- After the user explicitly approves the execution handoff, leave this planning workflow and execute in the extension-managed loop (see Execution Handoff).
|
|
24
24
|
|
|
25
25
|
## State And Settings
|
|
@@ -30,13 +30,13 @@ Before the first planning question, read `references/state-and-config.md` and in
|
|
|
30
30
|
{ "action": "init", "workdir": "<target-workdir>" }
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
State lives under the workspace's resolved git common dir as `.git/
|
|
33
|
+
State lives under the workspace's resolved git common dir as `.git/pi-plans/` (auto-ignored, no `.gitignore` entries; the tool auto-runs `git init` when the workdir safely has no repository). The target workspace is the current working directory unless the user explicitly names another repository.
|
|
34
34
|
|
|
35
|
-
If `language.tag` is missing from `.git/
|
|
35
|
+
If `language.tag` is missing from `.git/pi-plans/config.json`, ask the language setting question (via `ask_choice`) before any product question. Persist it with `plans` (`set-language`); this question does not count against the planning-question limit.
|
|
36
36
|
|
|
37
|
-
If `artifact_root_source` is missing from `.git/
|
|
37
|
+
If `artifact_root_source` is missing from `.git/pi-plans/config.json` or is `unset`, ask the planning docs location question (via `ask_choice`) before any product question. Persist it with `plans` (`set-artifact-root`); this question does not count against the planning-question limit.
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
The reviewer role lives in the GLOBAL config (`~/.pi/pi-plans/config.json`, `PI_PLANS_GLOBAL_DIR` override — one confirmation for every workspace). If its mode is missing/invalid when a round is about to run, ask the role-setting question via `ask_choice` and persist with `plans` (`set-role`). The model + thinking level are confirmed at first use through NATIVE panels, not ask_choice: in TUI the `refine` gate itself pops a searchable model panel followed by an effort panel (Default row = no `--thinking` flag; other rows follow the chosen model's `thinkingLevelMap`) and continues the same invocation on completion; hasUI non-TUI sessions get native menus; UI-less sessions get text guidance embedding the available selectors. Esc cancels the whole gate (nothing persisted; do NOT re-ask via ask_choice — suggest `/config-pi-plans`). The `refine` tool refuses to spawn until `reviewerReady` passes (current-session, or delegated with a confirmed concrete `provider/model`). (v0.6.1: the criticizer role is gone — the reviewer emits findings AND questions in one round.)
|
|
40
40
|
|
|
41
41
|
## First-Turn Contract
|
|
42
42
|
|
|
@@ -59,7 +59,7 @@ When the recommended option depends on a web-verifiable claim, search first (web
|
|
|
59
59
|
|
|
60
60
|
Every user-facing planning or refinement question goes through the `ask_choice` tool:
|
|
61
61
|
|
|
62
|
-
- `options`: ordered options, recommended option first with `recommended: true` (exactly one), each with the
|
|
62
|
+
- `options`: ordered options, recommended option first with `recommended: true` (exactly one), each with a `description` of the form `✓ <advantage> / ✗ <drawback>` — **every option you author states both what it gains and what it costs**, in the configured language, tersely (≈8 words per half; write `—` when a side is genuinely absent). Both halves live in the single `description` string; there are no separate `pros`/`cons` fields. This rule covers every AI-written option, including the scope confirmation and the merged accept/execute handoff; only the tool-appended `Other…` / `Auto-complete` rows are exempt;
|
|
63
63
|
- do not add `Other` or `Auto-complete` yourself — the tool appends `Other…` second-last and `Auto-complete` last;
|
|
64
64
|
- pass `autoComplete: false` for the merged accept/execute question — it contains the execution approval, so Auto-complete never appears there — and for any install waiver, publishing, deployment, merge, push, credential, or external-state question. Auto-complete may choose the recommended planning or refinement option only.
|
|
65
65
|
- When the user selects Auto-complete, it remains active for the current planning run: later eligible questions use their recommended options automatically, and the extension queues one deduplicated follow-up if the model stops after an auto-completed answer. `/plans-autocomplete-stop` disables it; session restore may reactivate it only for the same active run while its status is `planning`.
|
|
@@ -74,9 +74,9 @@ Create a run only after initial read-only inspection makes the topic clear:
|
|
|
74
74
|
{ "action": "start-run", "workdir": "<target-workdir>", "topic": "<short topic>", "skill": "<skill-name>", "requestText": "<original request>" }
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
The tool creates the configured artifact directory root (default
|
|
77
|
+
The tool creates the configured artifact directory root (default `./.git/pi-plans/plans/YYYY-MM-DD-<topic>/`) and the private run state `.git/pi-plans/runs/<run-id>/`, and stores the active run pointer. Use a short lowercase slug for the topic. Keep paths stable once written.
|
|
78
78
|
|
|
79
|
-
`DECISIONS.md` records: original request; repository evidence inspected; each question, options, selected answer, and whether it came from the user or Auto-complete; assumptions still open; external sources consulted; language
|
|
79
|
+
`DECISIONS.md` records: original request; repository evidence inspected; each question, options, selected answer, and whether it came from the user or Auto-complete; assumptions still open; external sources consulted; language and reviewer settings used.
|
|
80
80
|
|
|
81
81
|
## Final Scope Confirmation
|
|
82
82
|
|
|
@@ -91,93 +91,80 @@ If the user adds requirements, resolve only the necessary follow-up questions, t
|
|
|
91
91
|
|
|
92
92
|
## Plan Artifact Requirements
|
|
93
93
|
|
|
94
|
-
Every `PLAN_vN.md` must include stable IDs that are never recycled across revisions:
|
|
94
|
+
Every `PLAN_vN.md` must include stable IDs that are never recycled across revisions: `Task-N` tasks (with deps/files/wave and one subtask level), `VC-###` verification checks, and the revision ledger. Everything else the workflow needs lives in the run state (decisions ledger, review rounds, refs), not in the plan file.
|
|
95
95
|
|
|
96
|
-
Every plan version
|
|
96
|
+
Every plan version's body is exactly two sections — `## Tasks` and `## Verification Checks` — plus the metadata header (see `references/plan-artifact-template.md` for the full microsyntax: `Task-N` ids, one subtask level, inline `deps:`/`files:`/`wave:` fields, the `### Execution Waves` subsection, and lint rules). Each verification check is a Markdown checkbox of the exact shape:
|
|
97
97
|
|
|
98
98
|
```markdown
|
|
99
|
-
- [ ] `VC-001` covers `
|
|
99
|
+
- [ ] `VC-001` covers `Task-1`; pass condition: ...; evidence: ...; metric: <threshold or reason not quantified>.
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
-
The execution loop parses `- [ ] \`VC-###\``
|
|
102
|
+
The execution loop parses `- [ ] \`VC-###\`` checks and the task tree, so keep IDs on the checkbox line and the task grammar exact; task progress flows through `plans_update_task` and the completion auditor reads these checks. Use `references/plan-artifact-template.md` when drafting.
|
|
103
103
|
|
|
104
104
|
## Refinement
|
|
105
105
|
|
|
106
|
-
After each plan version, ask one merged accept/execute question via `ask_choice` with `autoComplete: false` — it contains the execution approval, so Auto-complete never appears. Options:
|
|
106
|
+
After each plan version, ask one merged accept/execute question via `ask_choice` with `autoComplete: false` — it contains the execution approval, so Auto-complete never appears. Each of the three options below carries the usual `✓ <advantage> / ✗ <drawback>` description (executing now versus deferring versus another refine round are real trade-offs — say what each wins and costs). Options:
|
|
107
107
|
|
|
108
108
|
1. `✓ Accept PLAN_vN and execute it now` — mark the plan accepted (`plans set-status accepted`), then call the `execute_plan` tool.
|
|
109
109
|
2. `Accept PLAN_vN, don't execute yet` — mark accepted; resume later via `/plans-execute`.
|
|
110
110
|
3. `Run another round: <the level's default next refine mode>` — only while the level's default sequence is unfinished.
|
|
111
111
|
|
|
112
|
-
The recommended option follows the skill level's default sequence: while the default
|
|
112
|
+
The recommended option follows the skill level's default sequence: while the default round is unfinished it is option 3 (`plan-small` / `plan-normal`: one reviewer round; `plan-big` / `plan-with-refs`: three concurrent reviewers via `refine` with `reviewers: 3`); once the default round is complete it is option 1. Every round returns findings (`F-###`) and up to five questions (`Q-1..Q-5`) in the same output.
|
|
113
113
|
|
|
114
|
-
If the user selects
|
|
114
|
+
If the user selects another round, run the `refine` tool with the plan path and any focus. Reviewer output consolidates into `PLAN_vN_reviewer_comments.md` with findings IDs, severity, affected plan IDs, evidence, impact, recommended fix, and disposition. Revise the next plan only for findings accepted on evidence.
|
|
115
115
|
|
|
116
116
|
### Concurrent Reviewers (big plans)
|
|
117
117
|
|
|
118
118
|
A big-plan reviewer round runs three independent reviewer subagents (`reviewers: 3`); each gets its own emphasis lens but forms its own priorities. After they return, merge and dedupe their findings into one consolidated `PLAN_vN_reviewer_comments.md`, keeping each finding's source reviewer, severity, evidence, and disposition, and surface at most five high-priority comments to the user. Treat agreement between independent reviewers as stronger evidence, not as authority; every accepted finding still needs repo or reference evidence.
|
|
119
119
|
|
|
120
|
-
###
|
|
120
|
+
### Reviewer Questions
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
Merge the rounds' `Questions` sections into one deduped list and ask EVERY question with `ask_choice` (one batched `questions: [...]` form or one call per question, in the configured language, stable questionIds). Do not revise the plan until every reviewer question has a recorded answer.
|
|
123
123
|
|
|
124
124
|
### Round Lifecycle
|
|
125
125
|
|
|
126
|
-
A refinement round is complete when all reviewer
|
|
126
|
+
A refinement round is complete when all reviewer lanes have returned; each lane's output carries findings (`F-###`) and up to five questions (`Q-1..Q-5`). In the same turn: consolidate, accept or reject each finding on evidence (the user may override any disposition), revise to `PLAN_v(N+1).md` when accepted items require it (copy, edit only the new version, update the revision ledger and verifier checklist), then immediately ask the next merged accept/execute question. Never end a turn merely because a round completed.
|
|
127
127
|
|
|
128
128
|
## Execution Handoff
|
|
129
129
|
|
|
130
|
-
When the user picks `✓ Accept PLAN_vN and execute it now` in the merged question, mark the plan accepted and call the `execute_plan` tool (or the user runs `/plans-execute`). It re-confirms with the user, then the extension enters execution mode:
|
|
130
|
+
When the user picks `✓ Accept PLAN_vN and execute it now` in the merged question, mark the plan accepted and call the `execute_plan` tool (or the user runs `/plans-execute`). It re-confirms with the user (never auto-completed), then the extension enters task-tree execution mode:
|
|
131
131
|
|
|
132
|
-
- every agent turn is injected with the remaining
|
|
133
|
-
-
|
|
132
|
+
- every agent turn is injected with the current wave's open tasks, the remaining task list, verification-check summary, and execution rules (wave order, `plans_update_task` reporting with status + evidence / skipReason, subprocess polling backoff 5s -> 10s -> 20s -> 40s -> 80s then keep polling at 80s, no stopgaps, dependency and library discipline, minimum tests);
|
|
133
|
+
- task progress flows exclusively through the `plans_update_task` tool: one call per task closing it as `complete` (with evidence) or `skipped` (with skipReason); closed statuses are immutable outside the audit-authorized rollback channel; subtasks close before their parent;
|
|
134
|
+
- the task dashboard tracks the whole tree live: a compact aboveEditor widget (current task ▸, progress bar, ✓/· counts, VC pass count, wave indicator, pause state, audit-failure line) and the Ctrl+Shift+T expanded tree view (✓/▸/~/· markers, current-task anchor, VC list with audit state, width-adaptive layout);
|
|
135
|
+
- a stall watchdog pauses execution after three consecutive settled rounds without any task-status change (genuine user input or `/plans-execute` resumes without losing progress);
|
|
136
|
+
- when every task reaches a terminal state, an independent read-only completion auditor verifies each check against the worktree: failed checks roll their covered tasks (children cascade, skipped tasks reopen) back to pending and inject the audit report; the audit re-runs as tasks re-close; after three failed rounds the run pauses for the user — under auto-approve/headless it terminates as `stopped` with the audit report so pipelines never hang; checks whose covered tasks are all skipped pass as skipped-pass; checks covering no task never enter the audit;
|
|
137
|
+
- execution-phase compaction is handled only when Pi core emits manual `/compact`, threshold, or overflow events; summaries are deterministic VCC-style summaries, include session-derived plan/current-task/checklist context, use smart tail keep and `keep:N`, and never call a model;
|
|
134
138
|
- the read-only guard lifts: full write access returns;
|
|
135
|
-
- the run status moves to `executing`, then `done` when the
|
|
139
|
+
- the run status moves to `executing`, then `done` when the completion audit passes;
|
|
136
140
|
- `/plans-stop` stops execution; `/plans` shows progress.
|
|
137
141
|
|
|
138
142
|
If the user declines, stay in planning (or stop, per their choice). Never start implementation without the approved handoff.
|
|
139
143
|
|
|
140
|
-
###
|
|
144
|
+
### Continuation Between Turns
|
|
141
145
|
|
|
142
|
-
In TUI/RPC, automatic
|
|
146
|
+
In TUI/RPC, automatic continuation is evaluated only at `agent_settled`, after
|
|
143
147
|
Pi has finished natural tool continuation, retries, and compaction. The
|
|
144
|
-
extension rechecks that the same execution is active
|
|
148
|
+
extension rechecks that the same execution is active with open tasks, the
|
|
145
149
|
session is idle, and neither pending input nor compaction owns continuation.
|
|
146
150
|
Each eligible settled cycle can send at most one hidden custom message with
|
|
147
|
-
the current execution rules
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
New-plan handoffs and the `execute_plan` tool still require explicit approval.
|
|
156
|
-
Completion, stop, and session replacement invalidate the extension's wake
|
|
157
|
-
identity without clearing user or other-extension queues. Print/JSON
|
|
158
|
-
single-shot sessions keep VC tracking and completion but never auto-wake;
|
|
151
|
+
the current execution rules. Tool `turn_end` events only update usage; they
|
|
152
|
+
never prequeue continuation reminders. The stall watchdog counts settled
|
|
153
|
+
cycles without task-state change (threshold 3) and pauses instead of waking;
|
|
154
|
+
user interruption and final model errors pause too. Genuine interactive/RPC
|
|
155
|
+
user input or `/plans-execute` resumes a paused active execution without
|
|
156
|
+
losing task progress; extension input cannot unpause it. New-plan handoffs
|
|
157
|
+
and the `execute_plan` tool still require explicit approval. Print/JSON
|
|
158
|
+
single-shot sessions keep task tracking and completion but never auto-wake;
|
|
159
159
|
use RPC for persistent headless execution.
|
|
160
160
|
|
|
161
|
-
### Post-Execution Continuation
|
|
162
|
-
|
|
163
|
-
When execution completes in an interactive session, the completion message attaches a goal-running continuation block and triggers a new agent turn so the model can enter the implementation-review loop immediately. The interactive-only trigger keeps headless sessions silent (no unconsented subagent cost). The same behavior applies on both completion call sites (the normal `turn_end` completion and the `restoreFromSession` recovery path).
|
|
164
|
-
|
|
165
|
-
The agent then asks two `ask_choice` questions (each single-question, `autoComplete: false`) to configure the implementation-review loop:
|
|
166
|
-
|
|
167
|
-
1. **Termination condition** (questionId `termination-condition`, recommended first: goal wait) — options: 1. goal wait: continue until no unpassed VCs remain (auto-continue each round) 2. until no high-severity finding (hard cap 5 rounds) 3. 1 round 4. 2 rounds 5. 3 rounds.
|
|
168
|
-
2. **Reviewer count** (questionId `impl-review-reviewer-count`, `allowOther: false`, pure digit labels `1`/`2`/`3`, recommended first): "How many concurrent reviewers should each implementation-review round use?" The recommended default follows the run's skill: `plan-big` / `plan-with-refs` → 3, others → 1.
|
|
169
|
-
|
|
170
|
-
Both answers persist TOGETHER in one `plans record-checkpoint` (`transition: "implementation-review-configured"`, `terminationCondition` + `reviewerCount`). Each refinement round calls `refine` with `role: "reviewer", target: "implementation", reviewers: <configured reviewerCount>`; an omitted `reviewers` falls back to the run's configured `reviewerCount` from the checkpoint, so restarts and worktree migrations never silently revert 2/3 to 1. Each round accepts findings on evidence, applies fixes, re-runs relevant tests, and records progress. The hard cap is 5 rounds regardless of the chosen termination condition. Multi-reviewer rounds (2 or 3) consolidate like big-plan rounds: merge and dedupe findings into one `PLAN_vN_reviewer_comments.md`, keep each finding's source reviewer, severity, evidence, and disposition, and surface at most five high-priority findings. Crash recovery: if the process dies after one or both answers were recorded in `decisions.jsonl` but before the combined write, `/resume-plans` rebuilds the answered configuration from the ledger, asks only the missing question(s), and then performs the single combined write (the re-ask guard rejects duplicate configuration writes while the fields are already set).
|
|
171
|
-
- Round audit trail: `decisions.jsonl`, `subagents.jsonl`, and `pi-plans-ameliorate` entries (one at goal start, then one per round) carry `currentRound` for post-hoc verification.
|
|
172
|
-
- Headless sessions skip the prompt entirely; no `pi-plans-ameliorate` entry is appended.
|
|
173
|
-
|
|
174
161
|
`refine` records each round and lane outcome durably (successful outputs are persisted to run-state files before the tool result returns) and accepts `resumeRoundId` to resume an interrupted round lane-by-lane: completed lanes are reused from their persisted outputs and never re-run; a round id is never reused across plan versions.
|
|
175
162
|
|
|
176
163
|
## Resuming (`/resume-plans`)
|
|
177
164
|
|
|
178
|
-
After a restart or in a fresh session, `/resume-plans` (interactive only) restores the repository's working plan in the current session: the unfinished active run wins; otherwise a unique candidate resumes directly and multiple candidates get a chooser. It resumes unfinished planning (re-asks the pending question with the same `questionId`, never re-asks answered decisions), reviewing (resumes interrupted rounds via `refine resumeRoundId`, consolidates completed ones), execution (durable approval: unchanged plan digest keeps the authorization — a changed HEAD re-
|
|
165
|
+
After a restart or in a fresh session, `/resume-plans` (interactive only) restores the repository's working plan in the current session: the unfinished active run wins; otherwise a unique candidate resumes directly and multiple candidates get a chooser. It resumes unfinished planning (re-asks the pending question with the same `questionId`, never re-asks answered decisions), reviewing (resumes interrupted rounds via `refine resumeRoundId`, consolidates completed ones), and execution (durable approval: unchanged plan digest keeps the authorization — a changed HEAD re-opens previously closed tasks for re-verification; an unverifiable approval HEAD behaves the same; legacy runs without checkpoints must re-approve; v0.6.0 delegated-executor orphans require a fresh handoff approval; a legacy `implementation-review` phase maps to done — its historical acceptance stands). Linked worktrees share candidates; cross-worktree resumes confirm, copy artifacts without overwriting, reset approval and VC validity, and restart round counts. Record semantic boundaries with `plans record-checkpoint` (`plan-written`, `review-consolidated`, `completed` with evidence).
|
|
179
166
|
|
|
180
|
-
`refine`
|
|
167
|
+
`refine` reviews the plan text (the v0.6.0 `target: "implementation"` post-execution loop is gone; the independent completion auditor now gates delivery).
|
|
181
168
|
|
|
182
169
|
## Red Flags
|
|
183
170
|
|
|
@@ -186,9 +173,9 @@ Stop and return to the workflow if any of these happen:
|
|
|
186
173
|
- implementing before the approved execution handoff;
|
|
187
174
|
- running `refine` without first asking the merged accept/execute question, or before the role gates pass;
|
|
188
175
|
- ending a turn after a completed refinement round without asking the next merged accept/execute question;
|
|
189
|
-
- storing planning settings outside the target workspace's `.git/
|
|
176
|
+
- storing planning settings outside the target workspace's `.git/pi-plans/` state directory;
|
|
190
177
|
- asking multiple planning questions in one message, or asking them outside `ask_choice`;
|
|
191
178
|
- writing `PLAN_v1.md` before final scope confirmation;
|
|
192
179
|
- accepting vague answers that contradict repo or reference evidence;
|
|
193
|
-
- treating a reviewer
|
|
180
|
+
- treating a reviewer as authority instead of evidence;
|
|
194
181
|
- offering Auto-complete for execution, install, deploy, merge, push, or destructive cleanup approval.
|