pi-dev-flow 0.69.0 → 0.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.70.0] - 2026-10-31
8
+
9
+ - **A flow's workers are one family in the picker.** Every `flow_stage` worker is now stamped as a child of the session that delegated it: its header carries `parentSession` → the driver's session file, and its transcript lands in the driver's own session bucket. `pi --resume` therefore nests the whole family under the driver in its default **Current Folder** scope, Threaded sort, with no scope switch — and because the worker's name carries its outcome (`✓ 🔍 · PASS · stamp attack`, `✗ 🔨 #3 · hard-cut`), the tree reads without opening a single row. One layout boundary: with a configured session directory that is not the checkout's default, the folder scope filters by each session's own cwd, so workers — whose cwd is the worktree — sit one Tab away under **All**, still threaded.
10
+ - **The family has a text view for hosts without a tree.** The settled card and `flow_stage { op: "status" }` list every worker this session spawned: picker name, message count, last-write time (local wall-clock), transcript path, newest first, older ones folded behind one counted line. The run the card or status is reporting on is left out — it is the section above it — and the section appears only inside a flow. A host with no file-backed session gets the flow's own `transcripts.log` instead, labelled as the coarser source it is. Reading a bucket costs ~15 ms per MB of its history, so a polled live view re-reads at most once per two seconds while the settled card and an idle status always read fresh.
11
+
7
12
  ## [0.69.0] - 2026-10-30
8
13
 
9
14
  - **Workers, so the conversation that talks to you stays lean.** `flow_stage` now delegates to disposable worker sessions with a fresh context, and the skill makes delegation the default for non-trivial implement work: the driver keeps the claim, the gates and the checkpoints, and receives one bounded stage report. A **verify worker** (`op: "verify"`) is an independent, check-only checker of the implement work — and its PASS is now a hard precondition of `flow verify`: the stamp belongs to the exact tree it read (worktree *and* the plan dir it judged against), so any edit anywhere — including a mid-stage plan amendment — drops it like a tier-1 record; a fresh FAIL deletes a contradicted PASS; a reviewer that moves the tree through bash anyway (file, HEAD, branch pointer or plan) voids its own verdict and gets snapshotted. A **reflect worker** (`op: "reflect"`) reviews the finished flow — driver transcript plus every worker transcript, durably indexed in `stage-sessions/transcripts.log` — returning tagged findings to route through Fold?/Fix?/Drop?.
package/README.md CHANGED
@@ -244,6 +244,6 @@ shipped feature checks off the item it was picked from.
244
244
  | [docs/gates.md](docs/gates.md) | every gate and flag, what makes each refuse |
245
245
  | [docs/guardrails.md](docs/guardrails.md) | everything enforced, and the deliberate limits |
246
246
  | [docs/concurrency.md](docs/concurrency.md) | several agents, one repo: bindings, claims, attribution |
247
- | [docs/stage-agent.md](docs/stage-agent.md) | `flow_stage`: run a heavy stage in a disposable worker session |
247
+ | [docs/stage-agent.md](docs/stage-agent.md) | `flow_stage`: run a heavy stage in a disposable worker session — nested under the driver in pi's picker |
248
248
  | [docs/headless.md](docs/headless.md) | driving a session from a bot/UI/queue: `NEEDS-OPERATOR`, `--json` surfaces |
249
249
  | [docs/development.md](docs/development.md) | hacking on dev-flow itself: tests, self-hosting, `/reload` |
@@ -95,8 +95,19 @@ driver's transcript wherever the host renders streamed tool updates (the TUI
95
95
  does; expansion adds the fuller stream, the report and the transcript path).
96
96
  Around it, three mirrors:
97
97
 
98
- - a worker is a real pi session in pi's standard session directory, named by
99
- role glyph, ordinal and purpose — `⏳ 🔨 #2 · wire ops` while it runs, renamed
98
+ - a worker is a real pi session, **stamped as this session's child**: its header
99
+ carries `parentSession` → the driver's session file, and its transcript lands in
100
+ the driver's own session bucket — so `pi --resume` nests it under the driver in
101
+ its default **Current Folder** scope, in the Threaded sort, with no scope switch
102
+ (pi #1108 built that link for exactly this: extensions may stamp it on sessions
103
+ they create on a user's behalf). One layout exception: if you point pi at a
104
+ configured session directory (settings `sessionDir`, or `--session-dir`) that is
105
+ not the default for the folder you started it in, that scope filters by each
106
+ session's own cwd and a worker's cwd is its worktree — the family is still
107
+ threaded, one Tab away under **All**, and dev-flow's text view below lists it in
108
+ either layout. On a host with no file-backed session the stamp
109
+ is skipped and the worker keeps pi's default location, unlinked. Named by role
110
+ glyph, ordinal and purpose — `⏳ 🔨 #2 · wire ops` while it runs, renamed
100
111
  at the end with its outcome: `✓ 🔨 #2 · 3 commits · wire ops`, a verify `✓ 🔍 ·
101
112
  PASS · stamp attack`, a cut-off worker `✗ 🔨 #3 · hard-cut`; the verdict never
102
113
  depends on opening the row (a `label` on the call supplies the purpose; with
@@ -113,6 +124,31 @@ Around it, three mirrors:
113
124
  `flow_stage { op: "status" }` prints the same tail plus elapsed time, budget,
114
125
  the worktree state and recent commits, on any host, no model call.
115
126
 
127
+ ### The family, on a host with no tree
128
+
129
+ The parent link makes pi's own picker the lineage view. Where a host has no tree
130
+ (or you want the answer in text), the settled card and
131
+ `flow_stage { op: "status" }` list the family instead: one line per worker this
132
+ session spawned — its picker name (so the outcome is right there), message count,
133
+ last-write time, transcript path, newest first, older ones folded behind one
134
+ counted line. The worker the card or status is reporting on is left out — it is the
135
+ section above it — and the section appears only inside a flow, because an unbound
136
+ session has never spawned one:
137
+
138
+ ```
139
+ workers this session spawned:
140
+ ✓ 🔍 · PASS · stamp attack · 7 msgs · 2026-10-30 12:04 · ~/.pi/agent/sessions/…/w2.jsonl
141
+ ✗ 🔨 #1 · hard-cut · 31 msgs · 2026-10-30 11:02 · ~/.pi/agent/sessions/…/w1.jsonl
142
+ ```
143
+
144
+ It is read back from pi's session listing, not from a dev-flow index, so renames,
145
+ deletions and workers an earlier session already delegated all read correctly for
146
+ free. A host that gives dev-flow no session file to be a parent of falls back to
147
+ the lines the flow's own `transcripts.log` already holds — coarser (no message
148
+ count, no rename), still the same answer. Reading a bucket costs about 15 ms per
149
+ MB of its history, so the polled live view re-reads at most once every two seconds
150
+ while the settled card and an idle status always read fresh.
151
+
116
152
  Lifecycle is also on the bus: `dev-flow:worker-started` / `-completed` /
117
153
  `-failed` events (slug, op, elapsed, usage) let other extensions react without
118
154
  touching dev-flow. `pi export <file>` turns any finished transcript into
@@ -135,8 +171,14 @@ file to read before deciding what to keep.
135
171
 
136
172
  ## Transcripts
137
173
 
138
- Session JSONL lives where pi keeps sessions (standard dir, discoverable by the
139
- picker and `pi export`); snapshots and the `transcripts.log` index live under
174
+ Session JSONL lives in the **driver's own session bucket** (the directory pi already
175
+ uses for this session), which is what lets pi's picker show a flow's workers as one
176
+ nested family; `pi export` and the picker find them there. Two consequences worth
177
+ knowing: a worker's header `cwd` is still the worktree, so after `flow finish`
178
+ removes that worktree the row points at a directory that is gone (browsing and
179
+ `pi export` still work — resuming it would not); and the bucket is shared with the
180
+ driver's own history, so worker transcripts are only ever deleted by path, never
181
+ by clearing a folder. Snapshots and the `transcripts.log` index live under
140
182
  `.dev-flow/<slug>/stage-sessions/` (gitignored, like all flow-owned state).
141
183
 
142
184
  ## Deliberate limits (v2)
@@ -26,7 +26,7 @@ import path from "node:path";
26
26
  import { promisify } from "node:util";
27
27
  import { Type } from "@earendil-works/pi-ai";
28
28
  import { Container, Text } from "@earendil-works/pi-tui";
29
- import { compact, createAgentSession, DefaultResourceLoader, defineTool, getAgentDir, isToolCallEventType, SettingsManager, type AgentSession, type ExtensionContext } from "@earendil-works/pi-coding-agent";
29
+ import { compact, createAgentSession, DefaultResourceLoader, defineTool, getAgentDir, isToolCallEventType, SessionManager, SettingsManager, type AgentSession, type ExtensionContext } from "@earendil-works/pi-coding-agent";
30
30
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
31
31
  import {
32
32
  ALLOW_REWRITE,
@@ -38,6 +38,8 @@ import {
38
38
  buildStageBrief,
39
39
  checkFingerprint,
40
40
  changelogVersionsBetween,
41
+ familyFoldLine,
42
+ familyHeading,
41
43
  normalizeReleaseBody,
42
44
  pendingEntryLines,
43
45
  pickReleaseNotes,
@@ -140,8 +142,13 @@ import {
140
142
  recordVerifyPass,
141
143
  renderVerifyReport,
142
144
  verifyStampMissing,
145
+ sessionPathKey,
146
+ workerFamily,
147
+ workerFamilyCount,
148
+ WORKER_FAMILY_ITEMS,
143
149
  workerOpError,
144
150
  workerTranscriptLine,
151
+ type WorkerSessionRow,
145
152
  workerName,
146
153
  sanitizeWorkerLabel,
147
154
  stateTamper,
@@ -436,14 +443,27 @@ export const compactionTakeover: { run: typeof compact } = { run: compact };
436
443
 
437
444
  /** Seam that spawns the stage worker as a disposable REAL pi session — the smoke suite replaces
438
445
  * `.run` with a stub, so the worker contract stays testable without spending a model and tests
439
- * never touch the real session directory. The real spawn uses the DEFAULT session location (the
440
- * picker and `pi export` find it for free) and names the session through an inline extension —
441
- * `setSessionName` only exists on a session's own extension API — handing back a rename channel
442
- * the driver uses for the ⏳ → ✓/✗ lifecycle. */
446
+ * never touch the real session directory. The real spawn stamps lineage: the worker's header
447
+ * carries `parentSession` → the driver's own session file, and its transcript goes into the
448
+ * driver's session bucket, so pi's picker nests it under the driver in its default Current Folder
449
+ * scope (the Threaded sort reads that link — pi #1108 wrote it for exactly this, "extensions such
450
+ * as /handoff can do the same"). Naming runs through an inline extension — `setSessionName` only
451
+ * exists on a session's own extension API — handing back a rename channel the driver uses for the
452
+ * ⏳ → ✓/✗ lifecycle. */
443
453
 
444
454
  export interface StageWorkerHandle { session: AgentSession; rename: (name: string) => void }
445
- export const stageWorkerSpawn: { run: (o: { work: string; model: unknown; name: string; tools: string[] }) => Promise<StageWorkerHandle> } = {
446
- run: async ({ work, model, name, tools }) => {
455
+
456
+ /** The worker's session manager, built exactly as the real seam builds it — split out so a test can
457
+ * drive the production composition (header link + driver's bucket) without spawning a model.
458
+ * Both or neither: `dir` is the driver's own bucket read off the live manager, so a custom
459
+ * PI_CODING_AGENT_DIR can never strand a worker in a different agent dir from its driver, and pi's
460
+ * private `--<encoded cwd>--` directory encoding is never duplicated here. */
461
+ export function workerSessionManager(work: string, parent?: string, dir?: string): SessionManager | undefined {
462
+ return parent && dir ? SessionManager.create(work, dir, { parentSession: parent }) : undefined;
463
+ }
464
+
465
+ export const stageWorkerSpawn: { run: (o: { work: string; model: unknown; name: string; tools: string[]; parent?: string; dir?: string }) => Promise<StageWorkerHandle> } = {
466
+ run: async ({ work, model, name, tools, parent, dir }) => {
447
467
  let rename: (name: string) => void = () => {};
448
468
  const loader = new DefaultResourceLoader({
449
469
  cwd: work,
@@ -458,7 +478,8 @@ export const stageWorkerSpawn: { run: (o: { work: string; model: unknown; name:
458
478
  }],
459
479
  });
460
480
  await loader.reload();
461
- const { session } = await createAgentSession({ cwd: work, model: model as never, tools, excludeTools: ["flow", "flow_stage"], resourceLoader: loader });
481
+ const sessionManager = workerSessionManager(work, parent, dir);
482
+ const { session } = await createAgentSession({ cwd: work, model: model as never, tools, excludeTools: ["flow", "flow_stage"], resourceLoader: loader, sessionManager });
462
483
  // the op's toolset decides what the worker can touch at all: an implement worker gets the coding
463
484
  // tools, a reviewer gets read + bash only (a checker with an edit tool is a second implementer).
464
485
  // excludeTools is the belt on the extension tools — a worker never holds a gate or a second flow_stage.
@@ -466,6 +487,76 @@ export const stageWorkerSpawn: { run: (o: { work: string; model: unknown; name:
466
487
  },
467
488
  };
468
489
 
490
+ /** Seam that reads the driver's session bucket the way the picker does — a stub in the smoke suite,
491
+ * because a test must not scan the operator's real session directory. `listAll(dir)`, not
492
+ * `list(cwd, dir)`: pi's `list` drops rows whose header cwd is not `cwd` whenever it is handed a
493
+ * directory that is not that cwd's default — which is precisely a stage worker (header cwd = the
494
+ * worktree, file in the driver's bucket), and precisely the layout a configured `sessionDir`
495
+ * creates. `listAll(dir)` is what the picker's Current Folder scope sees in the default layout, so
496
+ * the family list and the tree agree there; under a configured session dir the text view stays
497
+ * complete even where that scope hides the worker, which is the cheaper direction to err in. */
498
+ export const sessionRowsScan: { run: (o: { cwd: string; dir?: string }) => Promise<WorkerSessionRow[]> } = {
499
+ run: async ({ dir }) => (await SessionManager.listAll(dir)).map((s) => ({ path: s.path, parent: s.parentSessionPath, name: s.name, messageCount: s.messageCount, modified: s.modified })),
500
+ };
501
+
502
+ /** Where this session's own transcripts live, when it has any: the file the worker links to, and the
503
+ * bucket it lands in. `null` on a host with no file-backed session — lineage is then unavailable,
504
+ * which is a fact to print, never an error to raise. */
505
+ function lineageOf(ctx: ExtensionContext): { file: string | null; dir: string | null } {
506
+ try {
507
+ return { file: ctx.sessionManager.getSessionFile() ?? null, dir: ctx.sessionManager.getSessionDir() ?? null };
508
+ } catch { /* an in-memory or otherwise unbacked session says so here */ return { file: null, dir: null }; }
509
+ }
510
+
511
+ /** With no file-backed lineage to read — an unbacked host, or a driver pi never wrote a file for —
512
+ * the ledger is what the flow knows: every worker it recorded, newest first. Coarser than the
513
+ * picker's data (no message count, no rename), so the status heading names the source. */
514
+ function ledgerFamilyLines(logPath: string, exclude?: string): string[] {
515
+ try {
516
+ const drop = exclude ? sessionPathKey(exclude) : null;
517
+ const mine = parseWorkerTranscripts(readFileSync(logPath, "utf8")).filter((r) => !drop || sessionPathKey(r.path) !== drop);
518
+ const shown = mine.slice(-WORKER_FAMILY_ITEMS).reverse().map((r) => `${r.op} · ${r.at} · ${r.path}`);
519
+ return mine.length > shown.length ? [...shown, familyFoldLine(mine.length - shown.length)] : shown;
520
+ } catch { return []; }
521
+ }
522
+
523
+ /** Bucket reads are the one expensive thing the family view does: pi parses every transcript in the
524
+ * driver's bucket in full — measured here at ~15 ms per MB of bucket history (25 sessions / 10.4 MB
525
+ * ≈ 150–200 ms, 48 MB ≈ 1.3 s). A host renders a running worker by calling status repeatedly, so
526
+ * that path is allowed a slightly stale read; the places the operator draws a conclusion from — idle
527
+ * status, the settled card — always re-read. */
528
+ const BUCKET_FRESH_MS = 2000;
529
+ const bucketCache = new Map<string, { at: number; rows: Awaited<ReturnType<typeof sessionRowsScan.run>> }>();
530
+
531
+ async function bucketRows(ctx: ExtensionContext, dir: string | null, staleMs = 0) {
532
+ const key = dir ?? "(default bucket)";
533
+ const hit = bucketCache.get(key);
534
+ // staleMs = 0 is not "a zero-length window", it is "no window: read now" — which is what idle status
535
+ // and the settled card ask for, because that is where the operator draws a conclusion. With `<=` the
536
+ // condition also holds inside the caller's own millisecond, and a fast host got the previous read back
537
+ // as a fresh one (this made CI red: a status call answering "what is there now" in the same millisecond
538
+ // as the call before it printed the family that had just gone empty).
539
+ if (staleMs > 0 && hit && Date.now() - hit.at <= staleMs) return hit.rows;
540
+ const rows = await sessionRowsScan.run({ cwd: ctx.cwd, dir: dir ?? undefined });
541
+ if (bucketCache.size > 8) bucketCache.clear(); // a session drives one bucket; anything bigger is stale keys
542
+ bucketCache.set(key, { at: Date.now(), rows });
543
+ return rows;
544
+ }
545
+
546
+ /** The flow's workers as lines, newest first — `null` when this session has no file to be a parent of,
547
+ * which is when the caller reaches for `ledgerFamilyLines` instead.
548
+ * Deliberately read from the picker's own data, not from a dev-flow index: renames, deletions and
549
+ * workers an older session already delegated all read back correctly for free. `exclude` drops one
550
+ * transcript: the caller already shows that run, and meeting it again as an anonymous row under
551
+ * "other workers" reads like somebody else's work belongs to this flow. */
552
+ async function workerFamilyLines(ctx: ExtensionContext, exclude?: string, staleMs = 0): Promise<string[] | null> {
553
+ const { file, dir } = lineageOf(ctx);
554
+ if (!file) return null;
555
+ try {
556
+ return workerFamily(await bucketRows(ctx, dir, staleMs), file, { exclude });
557
+ } catch { /* visibility again: a bucket we cannot read is not a reason to lose the run's own report */ return null; }
558
+ }
559
+
469
560
  /** Test-only timer override so the smoke suite drives the soft-steer and the hard cut in ms. */
470
561
  export const stageTimingOverride: { softMs?: number; hardMs?: number } = {};
471
562
 
@@ -485,6 +576,9 @@ interface StageRun {
485
576
  slug: string;
486
577
  usage: StageUsage;
487
578
  turns: number;
579
+ /** the live worker's own session file, once spawned — a family listing leaves it out rather than
580
+ * meeting the run twice: once as the run, once as an unlabeled row under "other workers". */
581
+ transcript?: string;
488
582
  }
489
583
 
490
584
  const stageRuns = new Map<string, StageRun>();
@@ -2319,7 +2413,21 @@ export default function devFlow(pi: ExtensionAPI) {
2319
2413
  const op: WorkerOp = opRaw;
2320
2414
  if (op === "status") {
2321
2415
  const run = stageRuns.get(sessionKey(ctx));
2322
- if (!run) return { content: [{ type: "text", text: "no stage worker is running in this session" }], details: { running: false } };
2416
+ // The family is the question op:"status" gets when nothing is running — "what has this flow
2417
+ // spawned, and how did each end?". pi's picker threads the same rows into a tree; this is
2418
+ // that fact for a host with no tree, and for the moment between runs. A worker that is live
2419
+ // right now is the section above, not one of "the others" — so it is left out here. The whole
2420
+ // section is gated on a bound feature: an unbound session has never spawned a stage worker,
2421
+ // so there it would be noise paid for with a directory scan.
2422
+ const boundState = (() => { try { return initiated(ctx.cwd) ? boundFeature(ctx.cwd, sessionKey(ctx)) : null; } catch { return null; } })();
2423
+ const inFlow = !!boundState;
2424
+ const fam = inFlow ? await workerFamilyLines(ctx, run?.transcript, run ? BUCKET_FRESH_MS : 0) : null;
2425
+ // the picker's rows when we have them; the ledger when the host gave us no file to be a parent of
2426
+ const familyLines = fam ?? (boundState ? ledgerFamilyLines(path.join(featDir(ctx.cwd, boundState.slug), "stage-sessions", TRANSCRIPTS_FILE), run?.transcript) : null);
2427
+ const familySection = inFlow ? [familyHeading({ live: !!run, ledger: fam === null && !!familyLines?.length }), ...(familyLines && familyLines.length ? familyLines : ["(none yet)"])] : [];
2428
+ if (!run) {
2429
+ return { content: [{ type: "text", text: ["no stage worker is running in this session", ...familySection].join("\n") }], details: { running: false, ...(inFlow ? { workers: workerFamilyCount(familyLines) } : {}) } };
2430
+ }
2323
2431
  const elapsed = Date.now() - run.startedAt;
2324
2432
  const dirtyNow = await sh("git status --porcelain", run.work);
2325
2433
  const logNow = await sh("git log --oneline -5", run.work);
@@ -2329,8 +2437,9 @@ export default function devFlow(pi: ExtensionAPI) {
2329
2437
  stageUsageLine(run.usage, run.turns),
2330
2438
  `worktree now: ${dirtyNow.ok && dirtyNow.out.trim() ? `${dirtyNow.out.trim().split("\n").length} uncommitted path(s)` : "clean"}`,
2331
2439
  `recent commits:\n${logNow.ok && logNow.out.trim() ? logNow.out : "(none)"}`,
2440
+ ...(inFlow ? ["", ...familySection] : []),
2332
2441
  ].join("\n");
2333
- return { content: [{ type: "text", text }], details: { running: true, op: run.op, slug: run.slug, elapsedMs: elapsed, budgetMin: run.budgetMin, softFired: run.softFired, usage: run.usage, turns: run.turns } };
2442
+ return { content: [{ type: "text", text }], details: { running: true, op: run.op, slug: run.slug, elapsedMs: elapsed, budgetMin: run.budgetMin, softFired: run.softFired, usage: run.usage, turns: run.turns, workers: workerFamilyCount(familyLines) } };
2334
2443
  }
2335
2444
  if (!initiated(ctx.cwd)) return err("dev-flow is not initiated here — run flow init first");
2336
2445
  const st = boundFeature(ctx.cwd, sessionKey(ctx));
@@ -2365,6 +2474,9 @@ export default function devFlow(pi: ExtensionAPI) {
2365
2474
  const cfg = loadProject(dfDir(ctx.cwd)).cfg;
2366
2475
  const logFile = path.join(featDir(ctx.cwd, st.slug), "stage-live.log");
2367
2476
  const transcriptLog = path.join(featDir(ctx.cwd, st.slug), "stage-sessions", TRANSCRIPTS_FILE);
2477
+ // read once, used twice: the worker's header links to this file and lands in this bucket,
2478
+ // and the reflect brief names this session's own transcript to the reviewer
2479
+ const lineage = lineageOf(ctx);
2368
2480
  let child: AgentSession | undefined;
2369
2481
  let crash: string | null = null;
2370
2482
  let timedOut = false;
@@ -2400,10 +2512,8 @@ export default function devFlow(pi: ExtensionAPI) {
2400
2512
  });
2401
2513
  } else if (op === "reflect") {
2402
2514
  const transcripts = existsSync(transcriptLog) ? parseWorkerTranscripts(readFileSync(transcriptLog, "utf8")) : [];
2403
- let driverSession: string | null = null;
2404
- try { driverSession = ctx.sessionManager.getSessionFile() ?? null; } catch { /* a host without a file-backed session says so in the brief */ }
2405
2515
  brief = buildReflectBrief({
2406
- slug: st.slug, planFile, statusJson: statusJsonText, driverSession, transcripts,
2516
+ slug: st.slug, planFile, statusJson: statusJsonText, driverSession: lineage.file, transcripts,
2407
2517
  openReflections: readReflections(ctx.cwd).map((r) => r.line), note,
2408
2518
  });
2409
2519
  } else {
@@ -2426,8 +2536,9 @@ export default function devFlow(pi: ExtensionAPI) {
2426
2536
  // the worker is a REAL pi session in the default location — the pi/pi-web picker renders it
2427
2537
  // live from the append-only transcript (⏳ = resumable later; resuming a live one forks it,
2428
2538
  // browsing is read-only by construction); `pi export <file>` makes it readable HTML
2429
- const worker = await stageWorkerSpawn.run({ work, model: ctx.model, name: workerName("⏳", glyph, seq, label), tools: [...WORKER_OP_TOOLS[op]] });
2539
+ const worker = await stageWorkerSpawn.run({ work, model: ctx.model, name: workerName("⏳", glyph, seq, label), tools: [...WORKER_OP_TOOLS[op]], parent: lineage.file ?? undefined, dir: lineage.dir ?? undefined });
2430
2540
  child = worker.session;
2541
+ try { run.transcript = child.sessionManager.getSessionFile() ?? undefined; } catch { /* the family listing just won't know which row is this run */ }
2431
2542
  emit("dev-flow:worker-started", { budgetMin, startedAt: new Date().toISOString() });
2432
2543
  let lastBeat = 0;
2433
2544
  /** One live line: ledger, durable log, and the streamed card — same text on every host. */
@@ -2585,8 +2696,13 @@ export default function devFlow(pi: ExtensionAPI) {
2585
2696
  if (crash) parts.push(`worker run ended with an error: ${crash}`);
2586
2697
  if (snapshot && !verify) parts.push(`uncommitted worktree snapshotted (tracked + untracked): ${snapshot} — read it before deciding what to keep`);
2587
2698
  parts.push(check ? `tier-1 rerun after worker: ${check.text.replace(/\s+/g, " ").trim()}` : "tier-1 untouched: a check-only worker leaves the tree (and the records) as it found them — flow check / flow verify rerun what the tree still owes.");
2588
- parts.push(`worker transcript: ${transcript || "(session file unknown)"}${transcript ? `\nreadable as HTML: pi export ${transcript}` : ""}\nindexed in: ${transcriptLog}`);
2699
+ parts.push(`worker transcript: ${transcript || "(session file unknown)"}${transcript ? `\nreadable as HTML: pi export ${transcript}` : ""}\nindexed in: ${transcriptLog}${lineage.file && transcript ? `\nlineage: nested under ${lineage.file} in pi's picker (Threaded, Current Folder)` : ""}`);
2589
2700
  const failed = !!crash || timedOut || moved;
2701
+ // the family belongs on the settled card and the result only: a live frame redraws on every
2702
+ // worker tool call, and reading a session bucket is IO. This run is excluded — the card names
2703
+ // its transcript already, and repeating it as a bare row reads like a different worker.
2704
+ const famFromPicker = await workerFamilyLines(ctx, transcript || undefined);
2705
+ const fam = famFromPicker ?? ledgerFamilyLines(transcriptLog, transcript || undefined);
2590
2706
  emit(failed ? "dev-flow:worker-failed" : "dev-flow:worker-completed", {
2591
2707
  elapsedMs: Date.now() - run.startedAt, usage: run.usage, turns: run.turns, budgetMin, softFired: run.softFired, timedOut, crash,
2592
2708
  verdict: verify?.verdict ?? null, reportMissing: report?.missing ?? findings?.missing ?? false, transcript, snapshot,
@@ -2595,7 +2711,7 @@ export default function devFlow(pi: ExtensionAPI) {
2595
2711
  return {
2596
2712
  content: [{ type: "text" as const, text: parts.join("\n\n") }],
2597
2713
  details: {
2598
- op, slug: st.slug, stage: st.stage, card, cardFull: stageCardLines({ kind, slug: st.slug, elapsedMs: Date.now() - run.startedAt, budgetMin, softFired: run.softFired, tail: run.lastLines, usage: stageUsageLine(run.usage, run.turns), state: failed ? "failed" : "done", verdict: verify?.verdict ?? null, transcript }, true),
2714
+ op, slug: st.slug, stage: st.stage, card, cardFull: stageCardLines({ kind, slug: st.slug, elapsedMs: Date.now() - run.startedAt, budgetMin, softFired: run.softFired, tail: run.lastLines, usage: stageUsageLine(run.usage, run.turns), state: failed ? "failed" : "done", verdict: verify?.verdict ?? null, transcript, family: fam?.length ? fam : undefined, familyHeading: famFromPicker === null ? familyHeading({ ledger: true }) : undefined }, true),
2599
2715
  done: report?.done, files: report?.files, notes: report?.notes, blockers: report?.blockers, reportMissing: report?.missing ?? findings?.missing ?? false,
2600
2716
  verdict: verify?.verdict ?? null, stamped, clearedStamp: cleared, verdictVoided: moved, timedOut, softFired: run.softFired, budgetMin, elapsedMs: Date.now() - run.startedAt, error: crash, transcript, snapshot,
2601
2717
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.69.0",
3
+ "version": "0.70.0",
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": [
package/src/core.ts CHANGED
@@ -2322,6 +2322,10 @@ export interface StageCardView {
2322
2322
  verdict?: "pass" | "fail" | null;
2323
2323
  note?: string;
2324
2324
  transcript?: string;
2325
+ /** settled card only: the flow's other workers, already rendered by `workerFamily`. */
2326
+ family?: string[];
2327
+ /** heading for `family` when the rows came from somewhere coarser than pi's listing. */
2328
+ familyHeading?: string;
2325
2329
  }
2326
2330
 
2327
2331
  /** One frame of the worker card: header (what · where · clock against budget), the bounded live tail,
@@ -2334,9 +2338,105 @@ export function stageCardLines(v: StageCardView, expanded = false): string[] {
2334
2338
  if (v.verdict) out.push(`verdict: ${v.verdict.toUpperCase()}`);
2335
2339
  if (v.usage) out.push(v.usage);
2336
2340
  if (expanded && v.transcript) out.push(`transcript: ${v.transcript}`);
2341
+ // the family only on the settled card: listing a session directory is IO, and a live frame
2342
+ // redraws on every worker tool call — a running run must not pay for a directory read
2343
+ if (expanded && v.family?.length) out.push(v.familyHeading ?? familyHeading(), ...v.family);
2337
2344
  return out;
2338
2345
  }
2339
2346
 
2347
+ /** One worker session as pi's own session listing describes it. dev-flow keeps no lineage index
2348
+ * of its own: the `parentSession` link in a session header *is* the record, and pi's picker threads
2349
+ * on it. The extension reads pi's types and maps them onto this pi-free shape so the logic here
2350
+ * stays unit-testable. */
2351
+ export interface WorkerSessionRow {
2352
+ /** the worker's session file */
2353
+ path: string;
2354
+ /** the parent link as pi recorded it (`parentSession`); absent = not somebody's child */
2355
+ parent?: string | null;
2356
+ /** the picker display name — it carries the ⏳/✓/✗ and the outcome the driver stamps on it */
2357
+ name?: string;
2358
+ messageCount?: number;
2359
+ /** file mtime, however the host hands it over (pi gives a Date; tests give a number) */
2360
+ modified?: Date | number | string;
2361
+ }
2362
+
2363
+ /** How many workers one render lists before it folds the older ones. */
2364
+ export const WORKER_FAMILY_ITEMS = 12;
2365
+
2366
+ /** Family rendering options: `exclude` drops one transcript — the live or just-finished run, which
2367
+ * the caller already shows as its own section or its own line. */
2368
+ export interface WorkerFamilyOptions {
2369
+ exclude?: string;
2370
+ }
2371
+
2372
+ /** The heading over a family list — the one place the wording lives, so the status text and the card
2373
+ * cannot drift, and so a list that came from the ledger (no message counts, no renames) says so. */
2374
+ export function familyHeading(o: { live?: boolean; ledger?: boolean } = {}): string {
2375
+ return `${o.live ? "other workers this session spawned" : "workers this session spawned"}${o.ledger ? " (from the flow's ledger — this host has no session file to nest)" : ""}:`;
2376
+ }
2377
+
2378
+ /** The same session file written two ways is still one session (separators, trailing slash, and on
2379
+ * Windows the case of the drive letter). pi's own picker canonicalizes the same idea. */
2380
+ export function sessionPathKey(p: string): string {
2381
+ const k = path.resolve(p).replace(/[\\/]+$/, "");
2382
+ return process.platform === "win32" ? k.toLowerCase() : k;
2383
+ }
2384
+
2385
+ function sessionTime(row: WorkerSessionRow): number {
2386
+ const raw = row.modified instanceof Date ? row.modified.getTime() : typeof row.modified === "number" ? row.modified : row.modified ? Date.parse(row.modified) : 0;
2387
+ return Number.isFinite(raw) ? raw : 0;
2388
+ }
2389
+
2390
+ /**
2391
+ * The family — every stage worker this session spawned, newest first, one line each.
2392
+ *
2393
+ * A stage worker is a real pi session whose header carries `parentSession` pointing at the driver's
2394
+ * own file, so pi's picker nests it under the driver by itself (Threaded sort). This reads the same
2395
+ * fact back for every surface that has no tree: the `flow_stage` card and `op: "status"`. Nothing is
2396
+ * stored here, so a renamed worker (`✓ 🔍 · PASS · stamp attack`) reads back renamed, and workers a
2397
+ * previous session already delegated show up next to this one's.
2398
+ */
2399
+ export function workerFamily(rows: WorkerSessionRow[], driverFile: string | null | undefined, opts: WorkerFamilyOptions = {}): string[] {
2400
+ if (!driverFile) return [];
2401
+ const max = WORKER_FAMILY_ITEMS;
2402
+ const drop = opts.exclude ? sessionPathKey(opts.exclude) : null;
2403
+ const mine = rows
2404
+ .filter((r) => r.parent && sessionPathKey(r.parent) === sessionPathKey(driverFile) && (!drop || sessionPathKey(r.path) !== drop))
2405
+ .sort((a, b) => sessionTime(b) - sessionTime(a));
2406
+ const shown = mine.slice(0, max);
2407
+ const lines = shown.map((r) => {
2408
+ const at = sessionTime(r);
2409
+ return `${r.name?.trim() || "(unnamed worker)"} · ${r.messageCount ?? 0} msgs · ${at ? localStamp(at) : "time unknown"} · ${r.path}`;
2410
+ });
2411
+ if (mine.length > shown.length) lines.push(familyFoldLine(mine.length - shown.length));
2412
+ return lines;
2413
+ }
2414
+
2415
+ /** The line that stands in for the workers too old to list. It is not a worker, so anything counting
2416
+ * the list has to know it — and both sources fold the same way, so the shape lives here. */
2417
+ export function familyFoldLine(dropped: number): string {
2418
+ return `… ${dropped} earlier workers`;
2419
+ }
2420
+
2421
+ export function isFamilyFoldLine(line: string): boolean {
2422
+ return line.startsWith("… ");
2423
+ }
2424
+
2425
+ /** How many workers a rendered family list stands for: the fold line is a count, not a worker. */
2426
+ export function workerFamilyCount(lines: string[] | null | undefined): number | null {
2427
+ if (!lines) return null;
2428
+ return lines.filter((l) => !isFamilyFoldLine(l)).length;
2429
+ }
2430
+
2431
+ /** Local wall-clock `YYYY-MM-DD HH:mm` — the convention every dev-flow timestamp follows (a UTC
2432
+ * stamp next to the operator's own clock reads as a future or past session, and the family line is
2433
+ * meant to be scanned, not converted). */
2434
+ function localStamp(ms: number): string {
2435
+ const d = new Date(ms);
2436
+ const p = (n: number) => String(n).padStart(2, "0");
2437
+ return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
2438
+ }
2439
+
2340
2440
  /** What the tool accumulated from a worker's assistant usage records. */
2341
2441
  export interface StageUsage {
2342
2442
  input: number;