pi-better-harness 0.21.0 → 0.22.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/README.md CHANGED
@@ -64,14 +64,20 @@ need interactive confirmation. Full policy: [pi-better-sandbox](https://github.c
64
64
 
65
65
  ## Minimal Tool Output
66
66
 
67
- The bundled harness also provides `/tool-output minimal`, `/tool-output normal`,
68
- and `/tool-output` (toggle). Minimal mode folds each tool call into a single-line
69
- header, including running calls. Long headers are truncated to the terminal
70
- width; result bodies, images, boxes, and tool spacers are hidden. Built-in,
71
- extension, and MCP calls are included. Execution, sandboxing, and agent-facing
72
- payloads are unchanged. Ctrl+O reveals the original tool blocks; Ctrl+O again
73
- folds them. `/tool-output normal` restores ordinary rendering. Error result
74
- bodies are also hidden in minimal mode and remain available when expanded.
67
+ The bundled harness provides **Tool output: Normal / Minimal** in
68
+ `/harness-settings`. `/tool-output minimal`, `/tool-output normal`, and
69
+ `/tool-output` (toggle) remain compatibility shortcuts to the same preference.
70
+ Minimal mode folds each tool call into a single-line header, including running
71
+ calls. Muted tool names and quieter inline command/path context distinguish
72
+ activity from conversation text; running and failed calls retain visible state
73
+ markers. Long headers are truncated to the terminal width; result bodies,
74
+ images, boxes, and tool spacers are hidden. Built-in, extension, and MCP calls
75
+ are included. Execution, sandboxing, and agent-facing payloads are unchanged.
76
+ In newer Pi fullscreen mode, click a folded row to expand its original details,
77
+ then click the expanded call/result to collapse it. Regular terminals keep mouse
78
+ input for terminal selection and scrollback; Ctrl+O expands tools in all modes.
79
+ `/tool-output normal` restores ordinary rendering. Error result bodies are also
80
+ hidden in minimal mode and remain available when expanded.
75
81
 
76
82
  Normal mode is the default. The preference is saved in the current session,
77
83
  including resume/reload. This is a version-sensitive internal TUI adapter,
@@ -94,7 +100,9 @@ packages without duplicating their configuration. `/sandbox`, `/subagents
94
100
  settings`, and `/goal settings` remain available in standalone installations.
95
101
  Packages without a settings screen are not listed. Pi's `/settings` is unchanged.
96
102
 
97
- The hub also owns **Completions while busy**, shared by Subagents and Background
103
+ The hub includes **Tool output** when the bundled renderer extension is loaded.
104
+ Changes apply immediately to the current session and do not save a global
105
+ default. The hub also owns **Completions while busy**, shared by Subagents and Background
98
106
  Tasks. Choose **Wait until idle** (the default) or **Steer active run**. Changes
99
107
  apply immediately and autosave to the current session branch, including across
100
108
  reloads. Press **Ctrl+S** to save the current choice as your default for future
@@ -4,12 +4,15 @@ import { createRequire } from "node:module";
4
4
  import { dirname, join } from "node:path";
5
5
  import { pathToFileURL } from "node:url";
6
6
  import { stripVTControlCharacters } from "node:util";
7
+ import type { Theme } from "@earendil-works/pi-coding-agent";
7
8
 
8
9
  interface ToolComponent {
9
10
  toolName: string;
10
11
  args: unknown;
11
12
  callRendererComponent?: Component;
12
13
  expanded: boolean;
14
+ isPartial?: boolean;
15
+ result?: { isError?: boolean };
13
16
  showImages: boolean;
14
17
  resultRendererComponent?: unknown;
15
18
  ui: { requestRender(): void };
@@ -19,7 +22,10 @@ interface ToolComponent {
19
22
  }
20
23
 
21
24
  type Method = (this: ToolComponent, ...args: unknown[]) => unknown;
25
+ interface ToolMouseEvent { type: string; button: string; y: number; shift?: boolean; alt?: boolean; ctrl?: boolean }
26
+ type MouseHandler = (this: ToolComponent, event: ToolMouseEvent) => unknown;
22
27
  interface ToolPrototype {
28
+ handleMouse?: MouseHandler;
23
29
  updateDisplay: Method;
24
30
  getResultRenderer: Method;
25
31
  getTextOutput: Method;
@@ -42,7 +48,7 @@ export interface MinimalOutputHook {
42
48
  const HOOK = Symbol.for("pi-better-harness.minimal-output-hook");
43
49
  const emptyResult = () => ({ render: () => [] as string[], invalidate() {} });
44
50
 
45
- function compactCall(component: ToolComponent, width: number): string[] {
51
+ function compactCall(component: ToolComponent, width: number, theme?: Theme): string[] {
46
52
  if (width <= 0) return [];
47
53
  // Render the call alone at a wider width so terminal wrapping becomes truncation.
48
54
  const header = component.callRendererComponent?.render(Math.max(4096, width + 1))
@@ -50,10 +56,24 @@ function compactCall(component: ToolComponent, width: number): string[] {
50
56
  .find((line) => line.length > 0);
51
57
  let text = header;
52
58
  if (!text) {
53
- const args = JSON.stringify(component.args);
54
- text = `${component.toolName}${args && args !== "{}" ? ` ${args}` : ""}`;
59
+ const args = component.args as Record<string, unknown> | undefined;
60
+ const hint = args?.command ?? args?.path ?? args?.pattern;
61
+ const detail = typeof hint === "string" ? hint.replace(/\r?\n/g, " ") : JSON.stringify(component.args);
62
+ text = `${component.toolName}${detail && detail !== "{}" ? ` ${detail}` : ""}`;
55
63
  }
56
- return [truncateToWidth(text, width)];
64
+ const failed = component.result?.isError === true;
65
+ const running = !component.result || component.isPartial;
66
+ const detail = text.startsWith(`${component.toolName} `) ? text.slice(component.toolName.length).trimStart()
67
+ : text === component.toolName ? "" : text;
68
+ const label = component.toolName === "bash" ? "Shell"
69
+ : component.toolName.replace(/_/g, " ").replace(/^./, letter => letter.toUpperCase());
70
+ const marker = failed ? "!" : running ? "~" : ">";
71
+ const suffix = failed ? " (failed)" : running ? " (running)" : "";
72
+ const title = `${marker} ${label}`;
73
+ const styled = theme
74
+ ? `${theme.fg(failed ? "error" : "muted", title)}${detail ? ` ${theme.fg("dim", detail)}` : ""}${theme.fg(failed ? "error" : "muted", suffix)}`
75
+ : `${title}${detail ? ` ${detail}` : ""}${suffix}`;
76
+ return [truncateToWidth(styled, width)];
57
77
  }
58
78
 
59
79
  function hostRequire(): NodeRequire {
@@ -104,7 +124,7 @@ function sdkEntry(require: ReturnType<typeof createRequire>): string {
104
124
  }
105
125
 
106
126
  /** Internal TUI adapter: no tools are replaced and no result content is changed. */
107
- export function installMinimalOutputHook(prototype: ToolPrototype): MinimalOutputHook {
127
+ export function installMinimalOutputHook(prototype: ToolPrototype, getTheme?: () => Theme): MinimalOutputHook {
108
128
  for (const name of ["updateDisplay", "getResultRenderer", "getTextOutput", "setExpanded", "invalidate", "render"] as const) {
109
129
  if (typeof prototype[name] !== "function") {
110
130
  throw new Error(`Pi's tool display API is incompatible: missing ${name}. Normal output remains enabled.`);
@@ -117,6 +137,7 @@ export function installMinimalOutputHook(prototype: ToolPrototype): MinimalOutpu
117
137
  getResultRenderer: prototype.getResultRenderer,
118
138
  getTextOutput: prototype.getTextOutput,
119
139
  render: prototype.render,
140
+ ...(typeof prototype.handleMouse === "function" ? { handleMouse: prototype.handleMouse } : {}),
120
141
  };
121
142
  const seen = new WeakSet<ToolComponent>();
122
143
  const components = new Set<WeakRef<ToolComponent>>();
@@ -133,10 +154,11 @@ export function installMinimalOutputHook(prototype: ToolPrototype): MinimalOutpu
133
154
  }
134
155
  },
135
156
  restore() {
136
- for (const name of Object.keys(originals) as Array<keyof typeof originals>) {
157
+ for (const name of ["updateDisplay", "getResultRenderer", "getTextOutput", "render"] as const) {
137
158
  // Do not remove another extension's subsequently installed wrapper.
138
159
  if (prototype[name] === wrappers[name]) Object.assign(prototype, { [name]: originals[name] });
139
160
  }
161
+ if (originals.handleMouse && prototype.handleMouse === mouseWrapper) prototype.handleMouse = originals.handleMouse;
140
162
  delete prototype[HOOK];
141
163
  components.clear();
142
164
  },
@@ -164,9 +186,19 @@ export function installMinimalOutputHook(prototype: ToolPrototype): MinimalOutpu
164
186
  return current.enabled && !this.expanded ? "" : originals.getTextOutput.apply(this, args);
165
187
  },
166
188
  render(this: ToolComponent, width: number): string[] {
167
- return current.enabled && !this.expanded ? compactCall(this, width) : originals.render.call(this, width);
189
+ return current.enabled && !this.expanded ? compactCall(this, width, getTheme?.()) : originals.render.call(this, width);
168
190
  },
169
191
  };
192
+ const mouseWrapper: MouseHandler = function(event) {
193
+ if (current.enabled && !this.expanded) {
194
+ if (event.type !== "click" || event.button !== "left" || event.y !== 0 || event.shift || event.alt || event.ctrl) return undefined;
195
+ this.setExpanded(true);
196
+ this.ui.requestRender();
197
+ return { handled: true, render: true };
198
+ }
199
+ return originals.handleMouse?.call(this, event);
200
+ };
201
+ if (originals.handleMouse) prototype.handleMouse = mouseWrapper;
170
202
  Object.assign(prototype, wrappers);
171
203
  prototype[HOOK] = state;
172
204
  }
@@ -1,5 +1,6 @@
1
1
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
2
  import { installMinimalOutputHook, loadToolPrototype, type MinimalOutputHook } from "./hook.ts";
3
+ import type { SettingsControl } from "../settings/registry.ts";
3
4
 
4
5
  const ENTRY = "pi-better-harness-tool-output";
5
6
 
@@ -24,7 +25,7 @@ export default function minimalOutputExtension(pi: ExtensionAPI): void {
24
25
  }
25
26
  if (hook) return true;
26
27
  try {
27
- hook = installMinimalOutputHook(await loadToolPrototype());
28
+ hook = installMinimalOutputHook(await loadToolPrototype(), () => ctx.ui.theme);
28
29
  return true;
29
30
  } catch (error) {
30
31
  ctx.ui.notify(`Minimal tool output is unavailable: ${error instanceof Error ? error.message : String(error)}`, "warning");
@@ -32,13 +33,13 @@ export default function minimalOutputExtension(pi: ExtensionAPI): void {
32
33
  }
33
34
  }
34
35
 
35
- pi.on("session_start", async (_event, ctx) => {
36
+ async function restore(ctx: ExtensionContext): Promise<void> {
36
37
  if (ctx.mode !== "tui") return;
37
38
  enabled = false;
38
39
  for (const entry of ctx.sessionManager.getBranch()) {
39
40
  if (entry.type === "custom" && entry.customType === ENTRY) {
40
- const data = entry.data as { enabled?: unknown } | undefined;
41
- if (typeof data?.enabled === "boolean") enabled = data.enabled;
41
+ const data = entry.data as { version?: unknown; enabled?: unknown } | undefined;
42
+ if (data?.version === 1 && typeof data.enabled === "boolean") enabled = data.enabled;
42
43
  }
43
44
  }
44
45
  // Observe transcript components from startup, so the toggle also redraws existing rows.
@@ -47,9 +48,35 @@ export default function minimalOutputExtension(pi: ExtensionAPI): void {
47
48
  hook!.setEnabled(enabled);
48
49
  } else enabled = false;
49
50
  status(ctx);
50
- });
51
+ }
52
+
53
+ async function change(value: string, ctx: ExtensionContext): Promise<void> {
54
+ if (value !== "Normal" && value !== "Minimal") throw new Error("Invalid tool output mode.");
55
+ if (!await ensureHook(ctx)) throw new Error("Tool output settings are unavailable in this Pi runtime.");
56
+ const data = { version: 1, enabled: value === "Minimal" };
57
+ try { pi.appendEntry(ENTRY, data); }
58
+ catch (error) { data.version = 0; data.enabled = enabled; throw error; }
59
+ enabled = data.enabled;
60
+ if (enabled) collapseTools(ctx);
61
+ hook!.setEnabled(enabled);
62
+ status(ctx);
63
+ }
64
+
65
+ const setting: SettingsControl = {
66
+ id: "tool-output", label: "Tool output", values: ["Normal", "Minimal"],
67
+ get: () => enabled ? "Minimal" : "Normal", change,
68
+ };
69
+ const register = () => pi.events.emit("harness-settings:register", setting);
70
+ let stopSettings: (() => void) | undefined;
71
+ const subscribe = () => { stopSettings ??= pi.events.on("harness-settings:request", register); };
72
+ subscribe();
73
+ register();
74
+ pi.on("session_start", async (_event, ctx) => { subscribe(); await restore(ctx); register(); });
75
+ pi.on("session_tree", async (_event, ctx) => { await restore(ctx); });
51
76
 
52
77
  pi.on("session_shutdown", () => {
78
+ stopSettings?.();
79
+ stopSettings = undefined;
53
80
  hook?.dispose();
54
81
  hook = undefined;
55
82
  enabled = false;
@@ -71,12 +98,8 @@ export default function minimalOutputExtension(pi: ExtensionAPI): void {
71
98
  ctx.ui.notify("Usage: /tool-output [minimal|normal]", "warning");
72
99
  return;
73
100
  }
74
- if (!await ensureHook(ctx)) return;
75
- enabled = mode ? mode === "minimal" : !enabled;
76
- if (enabled) collapseTools(ctx);
77
- hook!.setEnabled(enabled);
78
- pi.appendEntry(ENTRY, { version: 1, enabled });
79
- status(ctx);
101
+ try { await change((mode ? mode === "minimal" : !enabled) ? "Minimal" : "Normal", ctx); }
102
+ catch (error) { ctx.ui.notify(error instanceof Error ? error.message : String(error), "warning"); return; }
80
103
  ctx.ui.notify(enabled
81
104
  ? "Minimal tool output on. Compact call headers remain visible. Ctrl+O reveals results."
82
105
  : "Normal tool output restored.", "info");
@@ -30,7 +30,7 @@ export default function harnessSettingsExtension(pi: ExtensionAPI): void {
30
30
  get: readSettings,
31
31
  change: mode => changeCallbackSetting(pi, ctx, mode),
32
32
  save: () => saveCallbackDefault(readSettings().mode),
33
- });
33
+ }, registry.controls());
34
34
  } catch (error) {
35
35
  ctx.ui.notify(`Settings unavailable: ${error instanceof Error ? error.message : String(error)}`, "error");
36
36
  return;
@@ -1,6 +1,6 @@
1
1
  import type { Theme } from "@earendil-works/pi-coding-agent";
2
2
  import { Container, SettingsList, Text, getKeybindings, setKeybindings, KeybindingsManager, TUI_KEYBINDINGS, matchesKey, type SettingItem } from "@earendil-works/pi-tui";
3
- import type { SettingsLink } from "./registry.ts";
3
+ import type { SettingsControl, SettingsLink } from "./registry.ts";
4
4
 
5
5
  export interface CallbackSettingsControl {
6
6
  get(): { mode: "hold" | "steer"; source: "session" | "default" };
@@ -11,7 +11,7 @@ export interface CallbackSettingsControl {
11
11
  const CALLBACK_SETTING_ID = "callbacks:while-busy";
12
12
  const callbackLabel = (mode: "hold" | "steer") => mode === "steer" ? "Steer active run" : "Wait until idle";
13
13
 
14
- export async function chooseHarnessSetting(ctx: any, links: SettingsLink[], selected?: string, callbacks?: CallbackSettingsControl): Promise<string | undefined> {
14
+ export async function chooseHarnessSetting(ctx: any, links: SettingsLink[], selected?: string, callbacks?: CallbackSettingsControl, controls: SettingsControl[] = []): Promise<string | undefined> {
15
15
  return ctx.ui.custom((tui: any, theme: Theme, _kb: unknown, done: (id?: string) => void) => {
16
16
  let callbackMode = callbacks?.get().mode ?? "hold";
17
17
  const callbackSetting: SettingItem | undefined = callbacks ? {
@@ -23,9 +23,11 @@ export async function chooseHarnessSetting(ctx: any, links: SettingsLink[], sele
23
23
  } : undefined;
24
24
  const items: SettingItem[] = [
25
25
  ...(callbackSetting ? [callbackSetting] : []),
26
+ ...controls.map(control => ({ id: `setting:${control.id}`, label: control.label, currentValue: control.get(), description: "Session setting", values: control.values })),
26
27
  ...links.map(link => ({ id: `link:${link.id}`, label: link.label, currentValue: link.command, description: "Open package settings", values: [link.command] })),
27
28
  ];
28
29
  const feedback = new Text("", 0, 0);
30
+ let changing = false;
29
31
  const report = (message: string, error = false) => {
30
32
  feedback.setText(theme.fg(error ? "error" : "muted", message));
31
33
  tui.requestRender?.();
@@ -35,6 +37,20 @@ export async function chooseHarnessSetting(ctx: any, links: SettingsLink[], sele
35
37
  value: (text, active) => active ? theme.inverse(text) : theme.fg("muted", text),
36
38
  description: text => theme.fg("muted", text), cursor: "> ", hint: text => theme.fg("dim", text),
37
39
  }, (id, value) => {
40
+ const control = controls.find(item => `setting:${item.id}` === id);
41
+ if (control) {
42
+ const previous = control.get();
43
+ changing = true;
44
+ report("Saving session setting...");
45
+ Promise.resolve().then(() => control.change(value, ctx)).then(() => {
46
+ list.updateValue(id, control.get());
47
+ report("Session setting saved.");
48
+ }).catch(error => {
49
+ list.updateValue(id, previous);
50
+ report(error instanceof Error ? error.message : String(error), true);
51
+ }).finally(() => { changing = false; tui.requestRender?.(); });
52
+ return;
53
+ }
38
54
  if (id !== CALLBACK_SETTING_ID || !callbacks || !callbackSetting) { done(id); return; }
39
55
  try {
40
56
  const nextMode = value === "Steer active run" ? "steer" : "hold";
@@ -67,6 +83,7 @@ export async function chooseHarnessSetting(ctx: any, links: SettingsLink[], sele
67
83
  render: (width: number) => page.render(width),
68
84
  invalidate: () => page.invalidate(),
69
85
  handleInput(data: string) {
86
+ if (changing) return;
70
87
  if (callbacks && matchesKey(data, "ctrl+s")) {
71
88
  try { callbacks.save(); report("Callback default saved."); }
72
89
  catch (error) { report(error instanceof Error ? error.message : String(error), true); }
@@ -7,21 +7,38 @@ export interface SettingsLink {
7
7
  open(ctx: ExtensionCommandContext): Promise<void> | void;
8
8
  }
9
9
 
10
+ export interface SettingsControl {
11
+ id: string;
12
+ label: string;
13
+ values: string[];
14
+ get(): string;
15
+ change(value: string, ctx: ExtensionCommandContext): Promise<void> | void;
16
+ }
17
+
10
18
  export function createSettingsRegistry(pi: ExtensionAPI) {
11
19
  const links = new Map<string, SettingsLink>();
20
+ const controls = new Map<string, SettingsControl>();
12
21
  const conflicts = new Set<string>();
13
22
  const stop = pi.events.on("harness-settings:register", (candidate: unknown) => {
14
- const link = candidate as Partial<SettingsLink> | null;
15
- if (!link || !/^[a-z][a-z0-9-]*$/.test(link.id ?? "") || typeof link.label !== "string" ||
16
- typeof link.command !== "string" || !link.command.startsWith("/") || typeof link.open !== "function") return;
23
+ const link = candidate as Partial<SettingsLink & SettingsControl> | null;
24
+ if (!link || !/^[a-z][a-z0-9-]*$/.test(link.id ?? "") || typeof link.label !== "string") return;
25
+ const control = Array.isArray(link.values) && link.values.length > 1 && link.values.every(value => typeof value === "string")
26
+ && typeof link.get === "function" && typeof link.change === "function";
27
+ if (!control && (typeof link.command !== "string" || !link.command.startsWith("/") || typeof link.open !== "function")) return;
17
28
  if (conflicts.has(link.id!)) return;
18
29
  const prior = links.get(link.id!);
19
- if (prior && prior.open !== link.open) { links.delete(link.id!); conflicts.add(link.id!); return; }
20
- links.set(link.id!, link as SettingsLink);
30
+ const priorControl = controls.get(link.id!);
31
+ if ((prior && (control || prior.open !== link.open)) ||
32
+ (priorControl && (!control || priorControl.change !== link.change || priorControl.get !== link.get))) {
33
+ links.delete(link.id!); controls.delete(link.id!); conflicts.add(link.id!); return;
34
+ }
35
+ if (control) controls.set(link.id!, link as SettingsControl);
36
+ else links.set(link.id!, link as SettingsLink);
21
37
  });
22
38
  return {
23
- refresh() { links.clear(); conflicts.clear(); pi.events.emit("harness-settings:request", undefined); },
39
+ refresh() { links.clear(); controls.clear(); conflicts.clear(); pi.events.emit("harness-settings:request", undefined); },
24
40
  list() { return [...links.values()].sort((a, b) => a.label.localeCompare(b.label)); },
25
- dispose() { stop(); links.clear(); conflicts.clear(); },
41
+ controls() { return [...controls.values()].sort((a, b) => a.label.localeCompare(b.label)); },
42
+ dispose() { stop(); links.clear(); controls.clear(); conflicts.clear(); },
26
43
  };
27
- }
44
+ }
@@ -45,13 +45,15 @@ For any workflow using the shared task-plan contract (including `resolve-issues`
45
45
  "event": "unit-validated",
46
46
  "revision": 12,
47
47
  "changes": [
48
- { "id": "1201", "set": { "stage": "done", "status": "succeeded", "worker": null, "headSha": "abc123" } },
48
+ { "id": "1201", "set": { "stage": "done", "status": "in-flight", "worker": null, "headSha": "abc123" } },
49
49
  { "id": "C1", "set": { "status": "combining" } }
50
50
  ],
51
51
  "profiling": { "outcome": "succeeded", "wallMs": 540000 }
52
52
  } }
53
53
  ```
54
54
 
55
+ Each issue row shows where it is between code and delivery: `●` while it is being built, `◐ implemented` once `stage` is `done` with a `headSha`, `◑ review passed` while `reviewedHead` equals `headSha`, and `✓` only at `status: succeeded`, when the change has landed on the target branch by a merged PR or a direct push. Only `✓` rows count as complete.
56
+
55
57
  `changes` addresses units, components, and fleet stages by id (a change without an id sets run-level fields); all changes in one call are one transition. For a scope change, a change with `target` `unit` or `component` and an `add` row appends a new row; existing rows cannot be removed or renamed. The tool checks ids, dependencies (including cycles), worker slots, and status/stage values against the shared issue-resolution contract (a fleet status of `n/a` is saved as `not-applicable`), refuses a stale `revision`, appends an optional `decision`, then saves the plan atomically with `planRevision + 1` and a new `updatedAt`, and appends one profiling event with the same revision to the log the run already uses (`profiling/run.jsonl` or `profiling.jsonl`). A rejected update changes nothing. The event is appended before the plan is renamed into place, so a crash between the two can leave the log one revision ahead; the next update notices, reuses that revision, and marks its event with `logAheadRevision`.
56
58
 
57
59
  The binding records the active workflow's name, which is shown in the plan view. A different workflow cannot read or update that binding; a new invocation or ownership release invalidates it. The skill name is not an allowlist: explicit binding opts a workflow into the shared schema and transition rules, while path confinement to `.resolve-issues/rush/<run-id>/task-plan.json`, run identity, size limits, and revision checks still apply. Workflows using other schemas or storage locations retain their own planning and must not bind incompatible state.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-better-plan",
3
- "version": "0.5.4",
3
+ "version": "0.6.0",
4
4
  "description": "Structured execution plans with persistent progress for Pi.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -5,7 +5,9 @@ export interface PlanRenderTheme {
5
5
  fg(color: string, value: string): string;
6
6
  }
7
7
 
8
- export type DisplayStatus = "completed" | "in_progress" | "pending" | "blocked" | "failed" | "skipped" | "unknown";
8
+ // `implemented` and `reviewed` are in-progress states a workflow row can show between
9
+ // "code done" and "delivered"; native plans never use them.
10
+ export type DisplayStatus = "completed" | "in_progress" | "implemented" | "reviewed" | "pending" | "blocked" | "failed" | "skipped" | "unknown";
9
11
  export interface PlanRow {
10
12
  label: string;
11
13
  title: string;
@@ -24,6 +26,8 @@ export function statusStyle(status: DisplayStatus): { glyph: string; color: stri
24
26
  switch (status) {
25
27
  case "completed": return { glyph: "✓", color: "success", label: "" };
26
28
  case "in_progress": return { glyph: "●", color: "accent", label: "active" };
29
+ case "implemented": return { glyph: "◐", color: "accent", label: "implemented" };
30
+ case "reviewed": return { glyph: "◑", color: "success", label: "review passed" };
27
31
  case "blocked": return { glyph: "!", color: "warning", label: "blocked" };
28
32
  case "failed": return { glyph: "×", color: "error", label: "failed" };
29
33
  case "skipped": return { glyph: "—", color: "dim", label: "skipped" };
@@ -45,7 +49,8 @@ export function renderPlanPresentation(
45
49
  const count = (status: DisplayStatus) => plan.rows.filter((row) => row.status === status).length;
46
50
  const summary = [`${count("completed")}/${plan.rows.length} complete`];
47
51
  for (const [status, label] of [
48
- ["in_progress", "in progress"], ["blocked", "blocked"], ["failed", "failed"],
52
+ ["in_progress", "in progress"], ["implemented", "implemented"], ["reviewed", "review passed"],
53
+ ["blocked", "blocked"], ["failed", "failed"],
49
54
  ["skipped", "skipped"], ["unknown", "unknown"],
50
55
  ] as const) {
51
56
  if (count(status)) summary.push(`${count(status)} ${label}`);
@@ -67,7 +72,7 @@ export function renderPlanPresentation(
67
72
  theme.fg(style.color, style.glyph) + " " + theme.fg("dim", label) +
68
73
  " ".repeat(Math.max(0, labelWidth - visibleWidth(label)) + 2);
69
74
  const titleColor = row.status === "blocked" ? "warning" : row.status === "failed" ? "error" :
70
- row.status === "in_progress" ? "text" : "muted";
75
+ row.status === "in_progress" || row.status === "implemented" || row.status === "reviewed" ? "text" : "muted";
71
76
  const badge = planText(row.statusLabel ?? style.label);
72
77
  const available = size - visibleWidth(prefix);
73
78
  // At narrow widths use an inline status so it survives title truncation.
@@ -16,6 +16,9 @@ interface RushUnit {
16
16
  dependsOn: string[];
17
17
  worker?: string | number | undefined;
18
18
  note?: string | undefined;
19
+ headSha?: string | undefined;
20
+ reviewedHead?: string | undefined;
21
+ delivery?: string | undefined;
19
22
  }
20
23
 
21
24
  export interface RushPlan {
@@ -78,6 +81,9 @@ export function projectRushPlan(data: unknown, runId: string): RushPlan {
78
81
  dependsOn: Array.isArray(unit.dependsOn) ? unit.dependsOn.filter((id): id is string => typeof id === "string") : [],
79
82
  worker: typeof unit.worker === "string" || typeof unit.worker === "number" ? unit.worker : undefined,
80
83
  note: typeof unit.note === "string" ? unit.note : undefined,
84
+ headSha: typeof unit.headSha === "string" && unit.headSha ? unit.headSha : undefined,
85
+ reviewedHead: typeof unit.reviewedHead === "string" && unit.reviewedHead ? unit.reviewedHead : undefined,
86
+ delivery: typeof unit.delivery === "string" && unit.delivery ? unit.delivery : undefined,
81
87
  };
82
88
  });
83
89
  const fleet: RushPlan["fleet"] = {};
@@ -133,6 +139,15 @@ function workflowStatus(status: string): DisplayStatus {
133
139
  }
134
140
  }
135
141
 
142
+ // A unit is delivered (completed) only at `status: succeeded`, whether its change landed by a
143
+ // merged PR or a direct push. Between code done and delivery, a unit with a HEAD shows
144
+ // whether that HEAD passed review; without one it shows plain in-progress, as before.
145
+ function unitStatus(unit: RushUnit): DisplayStatus {
146
+ const status = workflowStatus(unit.status);
147
+ if (status !== "in_progress" || unit.stage !== "done" || !unit.headSha) return status;
148
+ return unit.reviewedHead === unit.headSha ? "reviewed" : "implemented";
149
+ }
150
+
136
151
  function presentRushPlan(plan: RushPlan, owner: string): PlanPresentation {
137
152
  // The warehouse canary only applies to data work; hide it otherwise.
138
153
  const stages = ["explore", "implement", "review", "ci", ...(plan.warehouseCanaryRequired ? ["canary"] : [])];
@@ -147,8 +162,8 @@ function presentRushPlan(plan: RushPlan, owner: string): PlanPresentation {
147
162
  return {
148
163
  metadata,
149
164
  rows: plan.issues.map((unit) => {
150
- const status = workflowStatus(unit.status);
151
- const details = [`${unit.stage} · ${unit.status}${unit.worker !== undefined ? ` · worker ${unit.worker}` : ""}`];
165
+ const status = unitStatus(unit);
166
+ const details = [`${unit.stage} · ${unit.status}${unit.delivery ? ` · ${unit.delivery}` : ""}${unit.worker !== undefined ? ` · worker ${unit.worker}` : ""}`];
152
167
  if (unit.dependsOn.length) details.push(`after: ${unit.dependsOn.map((id) => `#${id}`).join(", ")}`);
153
168
  if (unit.note) details.push(unit.note);
154
169
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-better-harness",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "Pi extension bundle for a write sandbox, subagents, background tasks, SSH, goals, and structured plans.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -55,7 +55,7 @@
55
55
  "dependencies": {
56
56
  "pi-better-background-tasks": "0.7.0",
57
57
  "pi-better-goal": "0.8.1",
58
- "pi-better-plan": "0.5.4",
58
+ "pi-better-plan": "0.6.0",
59
59
  "pi-better-sandbox": "0.11.0",
60
60
  "pi-better-ssh": "0.1.2",
61
61
  "pi-better-subagents": "0.15.0",