pi-dev-flow 0.76.0 โ†’ 0.76.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.76.1] - 2026-11-03
8
+
9
+ **pi-web workers read Running while they run.** Since 0.75.0 a `flow_stage` worker's Agents-menu row read *Interrupted* for its whole run, and its label repeated the slug.
10
+
11
+ ### Fixed
12
+ - While a `flow_stage` worker runs, its pi-web Agents row now reads running. pi-web shows a persisted `running` as interrupted unless it can confirm the run is alive in-process, so the worker now registers itself in pi-web's live run map for the run and leaves it only after its result entry is written. Plain pi is unchanged. Stop/steer from the Agents menu still answer "not running"; the driving session's Stop aborts the worker.
13
+ - Worker labels read `<glyph> <slug> <what>`: a `label` that repeats the slug is trimmed (`๐Ÿ” flow-list-widget ยท flow-list-widget review` โ†’ `๐Ÿ” flow-list-widget review`), and with no label the op names the run.
14
+
7
15
  ## [0.76.0] - 2026-11-03
8
16
 
9
17
  **The status bar now lists the flows.** In pi-web the footer was text โ€” nothing to click, and no way to see what was in flight without asking the agent.
@@ -207,7 +207,7 @@ function copyWarning(): string | null {
207
207
  }
208
208
  /** Test seam: the smoke suite cannot load a second copy of this module, so it plants registry
209
209
  * entries and asserts the warnings the real duplicate would print. */
210
- export const testSeams = { copies: COPIES, skillCore: { value: undefined as string | null | undefined }, piweb: { meta: piwebWorkerMeta, stamp: piwebStamp } };
210
+ export const testSeams = { copies: COPIES, skillCore: { value: undefined as string | null | undefined }, piweb: { meta: piwebWorkerMeta, stamp: piwebStamp, liveClaim: piwebLiveClaim, workerName } };
211
211
 
212
212
  interface Ui {
213
213
  hasUI: boolean;
@@ -1920,7 +1920,8 @@ const WORKER_TOOLS: Record<WorkerOp, string[]> = { implement: ["read", "bash", "
1920
1920
  * readSubagentRun, fed by lib/session-reader.ts). Two placement rules the reader enforces:
1921
1921
  * the meta entry must be the file's FIRST data entry (the scanner reads header + one line and
1922
1922
  * calls anything else a fork), and a persisted `running` the host cannot prove live displays as
1923
- * `interrupted` โ€” so the final result entry is what the menu really rests on.
1923
+ * `interrupted` โ€” so while a worker runs it also claims a slot in pi-web's live run map
1924
+ * (piwebLiveClaim), and the final result entry settles the row after.
1924
1925
  * Unknown entry types are inert in plain pi, so stamping is unconditional. */
1925
1926
  const PIWEB_SUBAGENT = { meta: "pi-web:subagent", status: "pi-web:subagent-status", result: "pi-web:subagent-result" } as const;
1926
1927
 
@@ -1956,6 +1957,43 @@ function piwebStamp(target: { appendCustomEntry?(customType: string, data?: unkn
1956
1957
  try { target?.appendCustomEntry?.(customType, data); } catch { /* visibility only */ }
1957
1958
  }
1958
1959
 
1960
+ /** pi-web proves a subagent live only from its own in-process tables (rpc-manager.ts
1961
+ * subagentDisplayStatus: its session registry, or globalThis.__piSubagentRuns); anything else with
1962
+ * a persisted `running` reads `interrupted`. pi-web hosts extensions in its server process, so the
1963
+ * worker claims a slot in that map for the run โ€” pi-web's private global, used only when pi-web
1964
+ * created it (never created here: plain pi stays untouched, and a pi-web without it keeps the old
1965
+ * mid-run `interrupted`). Side effects: the driver counts as having an unsettled subagent while the
1966
+ * tool call runs (it is mid-call anyway); Stop/steer from the Agents menu still answer "not running",
1967
+ * since pi-web holds no wrapper for this child โ€” the driver's Stop aborts it. Returns an idempotent
1968
+ * release that drops the slot only if it still holds this claim (pi-web's dropSubagentRun rule). */
1969
+ function piwebLiveClaim(sm: { getSessionId?(): string; getSessionFile?(): string | undefined } | undefined, m: WorkerSubagentMeta): (status: string) => void {
1970
+ try {
1971
+ const runs = (globalThis as { __piSubagentRuns?: unknown }).__piSubagentRuns;
1972
+ const sessionId = sm?.getSessionId?.();
1973
+ if (!(runs instanceof Map) || !sessionId) return () => {};
1974
+ let settle: (run: unknown) => void = () => {};
1975
+ const run = { sessionId, sessionPath: sm?.getSessionFile?.() ?? "", parentSessionId: m.parentId, parentToolCallId: m.toolCallId, profile: m.profile, description: m.description, task: m.task, runInBackground: false, status: "running", createdAt: now() };
1976
+ const stored = { run, completion: new Promise((resolve) => { settle = resolve; }), abortRequested: false, dispatchedAt: Date.now() };
1977
+ runs.set(sessionId, stored);
1978
+ let released = false;
1979
+ return (status) => {
1980
+ if (released) return;
1981
+ released = true;
1982
+ try { if (runs.get(sessionId) === stored) runs.delete(sessionId); settle({ ...run, status, completedAt: now() }); } catch { /* visibility only */ }
1983
+ };
1984
+ } catch { return () => {}; }
1985
+ }
1986
+
1987
+ /** The worker's display name โ€” the Agents row and the session name: `<glyph> <slug> <what>`. The
1988
+ * model's label often repeats the slug ("flow-list-widget review"), so the slug and stray separators
1989
+ * are cut from it; with nothing left the op names the run. */
1990
+ function workerName(glyph: string, slug: string, op: string, label: unknown): string {
1991
+ const esc = slug.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1992
+ const what = String(label ?? "").replace(/[\r\n]+/g, " ").replace(new RegExp(esc, "gi"), " ")
1993
+ .replace(/^[\sยท:|/,-]+|[\sยท:|/,-]+$/g, "").replace(/\s{2,}/g, " ").slice(0, 40).trim();
1994
+ return `${glyph} ${slug} ${what || op}`;
1995
+ }
1996
+
1959
1997
  /** Seam that spawns a worker as a real pi session โ€” tests replace `.run`. With the driver's session
1960
1998
  * file and directory known, the worker's header links back to the driver (`parentSession`), so pi's
1961
1999
  * picker nests it under the driver, and the pi-web meta lands as the file's first data entry. */
@@ -2172,7 +2210,7 @@ export default function devFlow(pi: ExtensionAPI) {
2172
2210
  name: "flow_stage",
2173
2211
  label: "Stage worker",
2174
2212
  description:
2175
- 'Optional: hand a slice of work to a fresh pi session so this conversation stays lean. op "implement" (stage implement) โ€” the worker edits and commits a slice on the feature branch; op "review" (implement or pre-release) โ€” a fresh read-only reviewer that returns findings and a PASS/FAIL verdict (advisory: no gate depends on it). The plan path, branch, commits so far and the project checks are added to the brief automatically โ€” `note` is just the slice: what to do, operator answers and decisions the worker cannot see. The worker holds no flow tool; gates and checkpoints stay with you. Small work and small fixes are fine to do inline. In pi-web the worker appears in the session\'s Agents menu as a subagent; the row carries its final status, the opened transcript its report.',
2213
+ 'Optional: hand a slice of work to a fresh pi session so this conversation stays lean. op "implement" (stage implement) โ€” the worker edits and commits a slice on the feature branch; op "review" (implement or pre-release) โ€” a fresh read-only reviewer that returns findings and a PASS/FAIL verdict (advisory: no gate depends on it). The plan path, branch, commits so far and the project checks are added to the brief automatically โ€” `note` is just the slice: what to do, operator answers and decisions the worker cannot see. The worker holds no flow tool; gates and checkpoints stay with you. Small work and small fixes are fine to do inline. In pi-web the worker appears in the session\'s Agents menu as a subagent (running while it works, then its final status); the opened transcript holds its report.',
2176
2214
  promptSnippet: 'flow_stage(op: "implement"|"review", note, label?) โ€” optional fresh-session worker for a big implement slice, or an independent review; gates stay with you; in pi-web workers show up as subagents in the Agents menu',
2177
2215
  parameters: Type.Object({
2178
2216
  op: Type.String({ description: '"implement" (a worker edits + commits a slice) or "review" (read-only reviewer, findings + verdict)' }),
@@ -2197,9 +2235,8 @@ export default function devFlow(pi: ExtensionAPI) {
2197
2235
  runningWorkers.add(key);
2198
2236
  const cfg = loadProject(dfDir(root)).cfg;
2199
2237
  const budgetMin = clampBudgetMin(params.budgetMin, wop);
2200
- const label = String(params.label ?? "").replace(/[\r\n]+/g, " ").trim().slice(0, 40);
2201
2238
  const glyph = wop === "implement" ? "๐Ÿ”จ" : "๐Ÿ”";
2202
- const name = `${glyph} ${st.slug}${label ? ` ยท ${label}` : ""}`;
2239
+ const name = workerName(glyph, st.slug, wop, params.label);
2203
2240
  const started = Date.now();
2204
2241
  const git = async (cmd: string) => { const r = await sh(cmd, work); return r.ok ? r.out : ""; };
2205
2242
  const headBefore = (await git("git rev-parse HEAD")).trim();
@@ -2226,9 +2263,13 @@ export default function devFlow(pi: ExtensionAPI) {
2226
2263
  const timer = setTimeout(() => { timedOut = true; abortChild(); }, budgetMin * 60_000);
2227
2264
  signal?.addEventListener("abort", abortChild);
2228
2265
  let unsub: (() => void) | undefined;
2266
+ let releaseLive: (status: string) => void = () => {};
2229
2267
  try {
2230
2268
  child = await stageWorkerSpawn.run({ work, model: ctx.model, name: `โณ ${name}`, tools: WORKER_TOOLS[wop], parent: lineage.file, dir: lineage.dir, subagent });
2231
- if (subagent) piwebStamp(child.sessionManager, PIWEB_SUBAGENT.status, { version: 1, status: "running" });
2269
+ if (subagent) {
2270
+ piwebStamp(child.sessionManager, PIWEB_SUBAGENT.status, { version: 1, status: "running" });
2271
+ releaseLive = piwebLiveClaim(child.sessionManager, subagent);
2272
+ }
2232
2273
  unsub = child.subscribe((ev: unknown) => {
2233
2274
  const e = ev as { type?: string; toolName?: string };
2234
2275
  if (e.type === "tool_execution_start") {
@@ -2261,14 +2302,18 @@ export default function devFlow(pi: ExtensionAPI) {
2261
2302
  // cannot prove live displays as `interrupted`); a no-REPORT run is a failure, not a โœ“.
2262
2303
  if (subagent) {
2263
2304
  const doneAt = now();
2264
- piwebStamp(child?.sessionManager, PIWEB_SUBAGENT.result, crash
2305
+ const final = crash
2265
2306
  ? { version: 1, status: "failed", completedAt: doneAt, error: crash }
2266
2307
  : timedOut || signal?.aborted
2267
2308
  ? { version: 1, status: "aborted", completedAt: doneAt }
2268
2309
  : report.found
2269
2310
  ? { version: 1, status: "completed", completedAt: doneAt, result: report.body }
2270
- : { version: 1, status: "failed", completedAt: doneAt, error: `ended without REPORT after ${nudges} nudge(s)`, result: report.body });
2311
+ : { version: 1, status: "failed", completedAt: doneAt, error: `ended without REPORT after ${nudges} nudge(s)`, result: report.body };
2312
+ piwebStamp(child?.sessionManager, PIWEB_SUBAGENT.result, final);
2313
+ // leave the live map only once the result entry is down: the row is never neither
2314
+ releaseLive(final.status);
2271
2315
  }
2316
+ releaseLive("failed"); // idempotent guard: a throw between claim and result must not leave a live row
2272
2317
  try { if (child) workerSessions.delete(child.sessionManager.getSessionId()); } catch { /* id-less session: nothing was registered */ }
2273
2318
  try { child?.setSessionName(`${report.found && !crash && !timedOut && !signal?.aborted ? "โœ“" : "โœ—"} ${name}${report.verdict ? ` ยท ${report.verdict}` : ""}`); } catch { /* visibility only */ }
2274
2319
  const parts = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.76.0",
3
+ "version": "0.76.1",
4
4
  "description": "Enforced feature workflow for Pi: plan โ†’ implement โ†’ pre-release โ†’ release, gated checkpoints, self-improvement reflections, one git worktree per feature, changelog + publish as part of the release",
5
5
  "type": "module",
6
6
  "keywords": [