pi-dev-flow 0.76.0 → 0.77.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.
@@ -20,7 +20,7 @@
20
20
  * Inactive (fully pass-through) in repos without a .dev-flow/ directory.
21
21
  */
22
22
  import { exec } from "node:child_process";
23
- import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
23
+ import { closeSync, copyFileSync, existsSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, renameSync, rmSync, writeFileSync } from "node:fs";
24
24
  import path from "node:path";
25
25
  import { promisify } from "node:util";
26
26
  import { Type } from "@earendil-works/pi-ai";
@@ -74,10 +74,19 @@ import {
74
74
  reflectMove,
75
75
  reflectProtocol,
76
76
  reflectUnfiledCount,
77
+ reflectLegacyPluginCount,
78
+ reflectionNudges,
79
+ pluginIssueRecipe,
80
+ type ReflectTarget,
81
+ buildReflectBrief,
82
+ parseReflectReport,
83
+ renderReflectFindings,
84
+ childSessionFiles,
85
+ WORKER_NUDGE_READONLY,
86
+ type SessionHeaderInfo,
77
87
  reflectionLine,
78
88
  reflectionRoutes,
79
89
  reflectionsTidy,
80
- reflectionsTidyHint,
81
90
  type ReflectItem,
82
91
  type ReflectSection,
83
92
  stageReference,
@@ -207,7 +216,7 @@ function copyWarning(): string | null {
207
216
  }
208
217
  /** Test seam: the smoke suite cannot load a second copy of this module, so it plants registry
209
218
  * 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 } };
219
+ export const testSeams = { copies: COPIES, skillCore: { value: undefined as string | null | undefined }, piweb: { meta: piwebWorkerMeta, stamp: piwebStamp, liveClaim: piwebLiveClaim, workerName } };
211
220
 
212
221
  interface Ui {
213
222
  hasUI: boolean;
@@ -357,7 +366,7 @@ async function releaseTags(root: string): Promise<string[] | null> {
357
366
  }
358
367
 
359
368
  const GATE_HELP =
360
- "help [--json] | init [--force|--draft|--write <text>] | reflect [<note>|list|tidy|move <n> --plugin|--playbook] | roadmap [add <text>|pick <n> <slug>|done <n>|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui|--patch|--docs --confirmed] [--force] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | approve [--yolo] | verify [--yolo] | release [--yolo|--no-version|--no-fold-check] | release-done [--no-artifact-check|--no-release-create] | finish [--yolo] [slug] | abort [slug] | version [--check-upstream] — state gates take [slug] and --confirmed (the operator already answered in chat); without it they ask in a dialog, or refuse with NEEDS-OPERATOR when no UI is present — --ui/--patch/--docs and --merge=<style> on start are operator-granted (--confirmed); start refuses until the playbook has a merge policy and writes the answer into project.md — --yolo (with --confirmed) answers that checkpoint and pre-confirms every later one; checks and guardrails stay — release --no-version ships merge + changelog only (no bump, tag or forge release); --no-fold-check skips the changelog fold line proofs on the operator's word — release names a session running an older dev-flow build than the disk ships and asks update (/reload) or proceed — recorded, never a block — reflect <note> queues a suggestion in reflections.md (--plugin/--playbook/--both state the section); bare reflect prints the session-reflection protocol; list numbers open items, move <n> re-files one, tidy drops closed ones — roadmap manages .dev-flow/roadmap.md: pick <n> <slug> stamps an item for flow start, finish checks it off — doctor reviews structure, git consistency and open reflections (never writes); doctor <note> prints an investigation brief — version prints the build the disk ships and any other dev-flow copies in this process (--check-upstream asks the registry)";
369
+ "help [--json] | init [--force|--draft|--write <text>] | reflect [<note>|list|tidy|move <n> --playbook|--code] | roadmap [add <text>|pick <n> <slug>|done <n>|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui|--patch|--docs --confirmed] [--force] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | approve [--yolo] | verify [--yolo] | release [--yolo|--no-version|--no-fold-check] | release-done [--no-artifact-check|--no-release-create] | finish [--yolo] [slug] | abort [slug] | version [--check-upstream] — state gates take [slug] and --confirmed (the operator already answered in chat); without it they ask in a dialog, or refuse with NEEDS-OPERATOR when no UI is present — --ui/--patch/--docs and --merge=<style> on start are operator-granted (--confirmed); start refuses until the playbook has a merge policy and writes the answer into project.md — --yolo (with --confirmed) answers that checkpoint and pre-confirms every later one; checks and guardrails stay — release --no-version ships merge + changelog only (no bump, tag or forge release); --no-fold-check skips the changelog fold line proofs on the operator's word — release names a session running an older dev-flow build than the disk ships and asks update (/reload) or proceed — recorded, never a block — reflect <note> queues a project suggestion in reflections.md (--playbook = docs-flow fix, --code = patch-flow fix); --plugin never writes — dev-flow feedback goes upstream and it prints the GitHub issue recipe; bare reflect prints the session-reflection protocol (bound: run flow_stage op reflect); list numbers open items, move <n> re-files one, tidy drops closed ones — roadmap manages .dev-flow/roadmap.md: pick <n> <slug> stamps an item for flow start, finish checks it off — doctor reviews structure, git consistency and open reflections (never writes); doctor <note> prints an investigation brief — version prints the build the disk ships and any other dev-flow copies in this process (--check-upstream asks the registry)";
361
370
  const featDir = (root: string, slug: string) => path.join(dfDir(root), slug);
362
371
  const stateFile = (root: string, slug: string) => path.join(featDir(root, slug), "state.json");
363
372
  const claimFile = (root: string, slug: string) => path.join(featDir(root, slug), "claim.json");
@@ -742,23 +751,33 @@ function setupQuestions(det: { partial: { defaultBranch: string; versioning?: {
742
751
 
743
752
  const GIT_TRACK_NOTE = 'the playbook belongs in git: git add -f .dev-flow/project.md && DEV_FLOW_ALLOW_MAIN=1 git commit -m "track project.md" (force-add: a root .gitignore may exclude .dev-flow/ entirely — tracked once, the ignore stops mattering; the env prefix is for the pre-commit hook, dev-flow itself lets a main commit whose only change is the playbook)';
744
753
 
745
- /** `flow reflect <note>` — advisory queue, operator decides. `--plugin` / `--playbook` states where
746
- * it lands (the agent knows what its own note is about); with no flag the wording guesses ONE primary
747
- * section and the echo prints the reason — a silent guess is how a dev-flow bug got buried in
748
- * `## playbook` and never routed anywhere. */
749
- function reflectNote(root: string, sess: Session, note: string[], forced: ReflectSection[] | null): RunResult {
754
+ /** The dev-flow repo plugin notes are filed against: the manifest's repository field; the dev-flow
755
+ * checkout itself falls back to its origin. */
756
+ async function pluginUpstream(root: string): Promise<string> {
757
+ return pluginVersion(import.meta.dirname).repo || (isSelfRepo(root) ? githubSlug((await originUrl(root)) ?? "") : "");
758
+ }
759
+
760
+ /** `flow reflect <note>` — this project's queue, operator decides. `--playbook` / `--code` states the
761
+ * section (the agent knows what its own note is about); `--plugin` is dev-flow feedback, which never
762
+ * lands in a project's file — it prints the upstream issue recipe instead (in the dev-flow repo itself
763
+ * plugin IS code, so it files under `## code`). With no flag the wording guesses and the echo prints why. */
764
+ async function reflectNote(root: string, sess: Session, note: string[], forced: ReflectTarget | null): Promise<RunResult> {
750
765
  const file = path.join(dfDir(root), "reflections.md");
751
766
  const text = existsSync(file) ? readFileSync(file, "utf8") : "";
752
767
  const guess = guessReflectSections(note.join(" "));
753
- const sections = forced ?? guess.sections;
754
- const line = reflectionLine(note.join(" "), sess.slug, now().slice(0, 10));
755
- const next = appendReflection(text, sections, line);
768
+ const self = isSelfRepo(root);
769
+ const target = forced ?? guess.target;
770
+ const why = forced ? "as told" : guess.why;
771
+ const date = now().slice(0, 10);
772
+ if (target === "plugin" && !self) return { text: [...pluginIssueRecipe(note.join(" "), await pluginUpstream(root), sess.slug, date), ...(forced ? [] : [`(filed as plugin: ${why} — a project note: flow reflect --playbook|--code "<note>")`])].join("\n") };
773
+ const section: ReflectSection = target === "plugin" ? "code" : target;
774
+ const line = reflectionLine(note.join(" "), sess.slug, date);
775
+ const next = appendReflection(text, [section], line);
756
776
  if (next === text) return { text: `already reflected (duplicate): ${line}` };
757
777
  writeFileSync(file, next);
758
- // queueing is exactly when the operator hears about the checked-off pile — nudge instead of letting it grow
759
- const closed = doneItemCount(next);
760
- const why = forced ? "as told" : guess.why;
761
- return { text: `reflected (${sections.join(" + ")} — ${why}): ${line}` + (closed ? `\n${reflectionsTidyHint(closed)}` : "") };
778
+ // queueing is exactly when the operator hears about the checked-off pile — nudge only once it is worth a tidy
779
+ const { tidy } = reflectionNudges(next, date);
780
+ return { text: `reflected (${section} — ${target === "plugin" ? "dev-flow repo: plugin feedback is this project's code" : why}): ${line}` + (tidy ? `\n${tidy}` : "") };
762
781
  }
763
782
 
764
783
  /** In-process TTL cache per repo slug — repeat doctor runs in one session must not re-hit the API. */
@@ -822,14 +841,27 @@ async function reflectList(root: string): Promise<RunResult> {
822
841
  : fold.state === "absent" || fold.state === "skipped"
823
842
  ? ["reflections: nothing open"]
824
843
  : ["reflections: nothing open locally"];
825
- return { text: [...local, ...foldRows(fold, isSelfRepo(root))].join("\n") };
826
- }
827
-
828
- /** `flow reflect move <n> --plugin|--playbook` — re-file an item under the other heading, so fixing a
829
- * misfile is one command instead of hand-editing markdown. */
830
- function reflectMoveNote(root: string, args: string[], forced: ReflectSection[] | null): RunResult {
831
- if (!forced || forced.length !== 1) return { text: "usage: flow reflect move <n> --plugin | --playbook", isError: true };
832
- const section = forced[0];
844
+ return { text: [...local, ...legacyPluginRows(readReflectionsText(root), isSelfRepo(root)), ...foldRows(fold, isSelfRepo(root))].join("\n") };
845
+ }
846
+
847
+ /** Open rows still under the legacy `## plugin` heading: they belong on GitHub, not in a project's queue. */
848
+ function legacyPluginRows(text: string, selfRepo: boolean): string[] {
849
+ const n = reflectLegacyPluginCount(text);
850
+ if (!n) return [];
851
+ return [
852
+ selfRepo
853
+ ? `reflections: ${n} open item(s) under the legacy ## plugin heading — in the dev-flow repo plugin is code: flow reflect move <n> --code`
854
+ : `reflections: ${n} open item(s) under the legacy ## plugin heading belong on GitHub, not here — file each upstream (flow reflect --plugin "<note>" prints the recipe), then check it off '— filed: gh#NNN'`,
855
+ ];
856
+ }
857
+
858
+ /** `flow reflect move <n> --playbook|--code` — re-file an item under the other heading, so fixing a
859
+ * misfile is one command instead of hand-editing markdown. Nothing moves INTO `## plugin`: dev-flow
860
+ * feedback is filed upstream (flow reflect --plugin prints the recipe), then the row is checked off. */
861
+ function reflectMoveNote(root: string, args: string[], forced: ReflectTarget | null): RunResult {
862
+ if (forced === "plugin") return { text: "move: plugin notes are not kept in reflections.md — file the item upstream (flow reflect --plugin \"<note>\" prints the recipe), then check the row off '— filed: gh#NNN' (in the dev-flow repo itself: move <n> --code)", isError: true };
863
+ if (!forced) return { text: "usage: flow reflect move <n> --playbook | --code", isError: true };
864
+ const section = forced;
833
865
  const n = Number(args[0]);
834
866
  const text = readReflectionsText(root);
835
867
  const items = reflectItems(text);
@@ -1374,6 +1406,8 @@ async function gateFinish(o: GateCtx): Promise<RunResult> {
1374
1406
  }
1375
1407
  // a forge release that failed at release-done is still the operator's call — but they must see it before the state vanishes (#63)
1376
1408
  const forgeSkipNote = state!.forgeReleaseSkipped ? ` WARNING: the forge release was not created (${state!.forgeReleaseSkipped}) — recreate it manually or re-run release-done before finishing.` : "";
1409
+ // the session context dies with the state: name a missing reflection — advisory, never a block (yolo too)
1410
+ const reflectSkipNote = state!.reflectedAt ? "" : ` Note: no reflection recorded for ${state!.slug} — the finish protocol runs flow_stage(op: "reflect") first and puts fold/drop to the operator.`;
1377
1411
  // the one finish question — asked after the safety checks so it can never be a wasted question
1378
1412
  // yolo works uniformly at every gate: at Finish? nothing later remains to pre-confirm, the flag just answers this one
1379
1413
  const yoloWord = takeYoloWord(state!);
@@ -1382,9 +1416,9 @@ async function gateFinish(o: GateCtx): Promise<RunResult> {
1382
1416
  if (askPending) {
1383
1417
  markPendingAsk(root, state!, "Finish?");
1384
1418
  if (!ui.hasUI) {
1385
- return { text: needsOperator(`finish needs the operator: ask them Finish? in chat, then re-run with --confirmed (or run /flow finish interactively)${forgeSkipNote}`, "Finish?"), isError: true };
1419
+ return { text: needsOperator(`finish needs the operator: ask them Finish? in chat, then re-run with --confirmed (or run /flow finish interactively)${forgeSkipNote}${reflectSkipNote}`, "Finish?"), isError: true };
1386
1420
  }
1387
- const ok = await ui.confirm("Finish feature", `Finish ${state!.slug}?${unmergedNote}${forgeSkipNote} Removes worktree, branch ${state!.branch || "-"} and .dev-flow/${state!.slug}/.`);
1421
+ const ok = await ui.confirm("Finish feature", `Finish ${state!.slug}?${unmergedNote}${forgeSkipNote}${reflectSkipNote} Removes worktree, branch ${state!.branch || "-"} and .dev-flow/${state!.slug}/.`);
1388
1422
  if (!ok) {
1389
1423
  delete state!.pendingAsk;
1390
1424
  writeState(root, state!);
@@ -1431,7 +1465,10 @@ async function gateFinish(o: GateCtx): Promise<RunResult> {
1431
1465
  roadmapNote = ` roadmap: ${r.count} item(s) marked done.`;
1432
1466
  }
1433
1467
  }
1434
- return { text: `feature ${state!.slug} done — ${closeNote}${remoteNote}; .dev-flow/${state!.slug}/ removed.${roadmapNote}${forgeSkipNote}${syncNote} Re-read flow status before reporting open flows — a sibling feature may have finished while this session ran.` };
1468
+ // finish is the moment between flows: name the fix / tidy suggestion when a rule fires, nothing otherwise
1469
+ const nudge = reflectionNudges(readReflectionsText(root), now().slice(0, 10), { between: true });
1470
+ const nudgeNote = [nudge.fix, nudge.tidy].filter(Boolean).map((n) => ` ${n} — offer it to the operator.`).join("");
1471
+ return { text: `feature ${state!.slug} done — ${closeNote}${remoteNote}; .dev-flow/${state!.slug}/ removed.${roadmapNote}${forgeSkipNote}${syncNote}${nudgeNote} Re-read flow status before reporting open flows — a sibling feature may have finished while this session ran.` };
1435
1472
  }
1436
1473
 
1437
1474
  async function gateInit(o: GateCtx): Promise<RunResult> {
@@ -1695,28 +1732,24 @@ async function gateReflect(o: GateCtx): Promise<RunResult> {
1695
1732
  // own sentence in reflections.md (#43). --plugin/--playbook/--both are reflect's own: they state
1696
1733
  // the filing instead of leaving it to a keyword guess.
1697
1734
  const words = rest.filter((a) => !a.startsWith("--"));
1698
- const forced: ReflectSection[] | null = flag("both")
1699
- ? (["playbook", "plugin"] as ReflectSection[])
1700
- : flag("plugin")
1701
- ? (["plugin"] as ReflectSection[])
1702
- : flag("playbook")
1703
- ? (["playbook"] as ReflectSection[])
1704
- : null;
1735
+ const forced: ReflectTarget | null = flag("plugin") ? "plugin" : flag("code") ? "code" : flag("playbook") || flag("docs") ? "playbook" : null;
1705
1736
  // single words are verbs (roadmap-style); a note merely starting with one stays a note
1706
1737
  if (words.length === 1 && words[0] === "tidy") return reflectTidy(root);
1707
1738
  if (words.length === 1 && words[0] === "list") return await reflectList(root);
1708
1739
  if (words[0] === "move") return reflectMoveNote(root, words.slice(1), forced);
1709
- if (words.length) return reflectNote(root, sess, words, forced);
1710
- // upstream for the update probe: the manifest's repository field; the dev-flow checkout itself falls back to its origin
1740
+ if (words.length) return await reflectNote(root, sess, words, forced);
1711
1741
  const self = pluginVersion(import.meta.dirname);
1712
- const upstream = self.repo || (isSelfRepo(root) ? githubSlug((await originUrl(root)) ?? "") : "");
1742
+ const upstream = await pluginUpstream(root);
1713
1743
  const refl = readReflections(root);
1714
1744
  const fold = await foldView(root, refl);
1745
+ const nudges = reflectionNudges(readReflectionsText(root), now().slice(0, 10), { between: !sess.slug });
1715
1746
  return {
1716
1747
  text: reflectProtocol(refl, isSelfRepo(root), {
1717
1748
  version: self.version,
1718
1749
  upstream,
1719
- closed: doneItemCount(readReflectionsText(root)),
1750
+ bound: !!sess.slug,
1751
+ fix: nudges.fix,
1752
+ tidy: nudges.tidy,
1720
1753
  ghFold: fold.state === "ok" && fold.open ? { repo: fold.slug, open: fold.open, similar: fold.result.similar.length } : undefined,
1721
1754
  }).join("\n"),
1722
1755
  };
@@ -1785,10 +1818,13 @@ async function gateDoctor(o: GateCtx): Promise<RunResult> {
1785
1818
  });
1786
1819
  }
1787
1820
  findings.push(...foldRows(fold, isSelfRepo(root)));
1788
- const unfiled = reflectUnfiledCount(readReflectionsText(root));
1789
- if (unfiled) findings.push(` reflections: ${unfiled} open item(s) sit outside ## playbook / ## plugin — flow reflect list shows them, flow reflect move <n> --plugin|--playbook files them`);
1790
- const closedRefl = doneItemCount(readReflectionsText(root));
1791
- if (closedRefl) findings.push(reflectionsTidyHint(closedRefl));
1821
+ const reflText = readReflectionsText(root);
1822
+ const unfiled = reflectUnfiledCount(reflText);
1823
+ if (unfiled) findings.push(` reflections: ${unfiled} open item(s) sit outside ## playbook / ## code — flow reflect list shows them, flow reflect move <n> --playbook|--code files them`);
1824
+ findings.push(...legacyPluginRows(reflText, isSelfRepo(root)).map((r) => ` ${r}`));
1825
+ const nudges = reflectionNudges(reflText, now().slice(0, 10), { between: !o.sess.slug });
1826
+ if (nudges.fix) findings.push(nudges.fix);
1827
+ if (nudges.tidy) findings.push(nudges.tidy);
1792
1828
  if (!rest.length) return { text: findings.length ? `doctor: ${findings.length} finding(s)\n${findings.map((f) => ` ${f}`).join("\n")}` : "doctor: no findings — playbook, flow state and git layout are consistent" };
1793
1829
  // flow doctor <note>: a fresh observation gets an investigation brief and a fix route
1794
1830
  return { text: investigationBrief(rest.filter((a) => !a.startsWith("--")).join(" "), isSelfRepo(root)).join("\n") };
@@ -1913,14 +1949,38 @@ async function gateAbort(o: GateCtx): Promise<RunResult> {
1913
1949
  const workerSessions = new Set<string>();
1914
1950
 
1915
1951
  /** Toolset per worker op: an implementer codes, a reviewer reads and runs commands only. */
1916
- const WORKER_TOOLS: Record<WorkerOp, string[]> = { implement: ["read", "bash", "edit", "write"], review: ["read", "bash"] };
1952
+ const WORKER_TOOLS: Record<WorkerOp, string[]> = { implement: ["read", "bash", "edit", "write"], review: ["read", "bash"], reflect: ["read", "bash"] };
1953
+
1954
+ /** Line 1 of every pi session file in `dir` — the header that names a worker's parent session. A
1955
+ * file is read up to its first newline only (transcripts grow large); unreadable files are skipped. */
1956
+ function sessionHeaders(dir: string | undefined): SessionHeaderInfo[] {
1957
+ if (!dir) return [];
1958
+ let names: string[];
1959
+ try { names = readdirSync(dir).filter((f) => f.endsWith(".jsonl")); } catch { return []; }
1960
+ const out: SessionHeaderInfo[] = [];
1961
+ for (const n of names) {
1962
+ const file = path.join(dir, n);
1963
+ try {
1964
+ const fd = openSync(file, "r");
1965
+ try {
1966
+ const buf = Buffer.alloc(16_384);
1967
+ const len = readSync(fd, buf, 0, buf.length, 0);
1968
+ const first = buf.subarray(0, len).toString("utf8").split("\n")[0];
1969
+ const h = JSON.parse(first) as { type?: unknown; parentSession?: unknown };
1970
+ if (h?.type === "session") out.push({ file, parentSession: typeof h.parentSession === "string" ? h.parentSession : undefined });
1971
+ } finally { closeSync(fd); }
1972
+ } catch { /* not a session file, or a header past the read window: skip */ }
1973
+ }
1974
+ return out;
1975
+ }
1917
1976
 
1918
1977
  /** What makes a worker show up in pi-web's Agents menu: pi-web classifies a subagent from the
1919
1978
  * custom entries its own runtime writes into the child's session file (pi-web lib/subagents.ts
1920
1979
  * readSubagentRun, fed by lib/session-reader.ts). Two placement rules the reader enforces:
1921
1980
  * the meta entry must be the file's FIRST data entry (the scanner reads header + one line and
1922
1981
  * 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.
1982
+ * `interrupted` — so while a worker runs it also claims a slot in pi-web's live run map
1983
+ * (piwebLiveClaim), and the final result entry settles the row after.
1924
1984
  * Unknown entry types are inert in plain pi, so stamping is unconditional. */
1925
1985
  const PIWEB_SUBAGENT = { meta: "pi-web:subagent", status: "pi-web:subagent-status", result: "pi-web:subagent-result" } as const;
1926
1986
 
@@ -1956,6 +2016,43 @@ function piwebStamp(target: { appendCustomEntry?(customType: string, data?: unkn
1956
2016
  try { target?.appendCustomEntry?.(customType, data); } catch { /* visibility only */ }
1957
2017
  }
1958
2018
 
2019
+ /** pi-web proves a subagent live only from its own in-process tables (rpc-manager.ts
2020
+ * subagentDisplayStatus: its session registry, or globalThis.__piSubagentRuns); anything else with
2021
+ * a persisted `running` reads `interrupted`. pi-web hosts extensions in its server process, so the
2022
+ * worker claims a slot in that map for the run — pi-web's private global, used only when pi-web
2023
+ * created it (never created here: plain pi stays untouched, and a pi-web without it keeps the old
2024
+ * mid-run `interrupted`). Side effects: the driver counts as having an unsettled subagent while the
2025
+ * tool call runs (it is mid-call anyway); Stop/steer from the Agents menu still answer "not running",
2026
+ * since pi-web holds no wrapper for this child — the driver's Stop aborts it. Returns an idempotent
2027
+ * release that drops the slot only if it still holds this claim (pi-web's dropSubagentRun rule). */
2028
+ function piwebLiveClaim(sm: { getSessionId?(): string; getSessionFile?(): string | undefined } | undefined, m: WorkerSubagentMeta): (status: string) => void {
2029
+ try {
2030
+ const runs = (globalThis as { __piSubagentRuns?: unknown }).__piSubagentRuns;
2031
+ const sessionId = sm?.getSessionId?.();
2032
+ if (!(runs instanceof Map) || !sessionId) return () => {};
2033
+ let settle: (run: unknown) => void = () => {};
2034
+ 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() };
2035
+ const stored = { run, completion: new Promise((resolve) => { settle = resolve; }), abortRequested: false, dispatchedAt: Date.now() };
2036
+ runs.set(sessionId, stored);
2037
+ let released = false;
2038
+ return (status) => {
2039
+ if (released) return;
2040
+ released = true;
2041
+ try { if (runs.get(sessionId) === stored) runs.delete(sessionId); settle({ ...run, status, completedAt: now() }); } catch { /* visibility only */ }
2042
+ };
2043
+ } catch { return () => {}; }
2044
+ }
2045
+
2046
+ /** The worker's display name — the Agents row and the session name: `<glyph> <slug> <what>`. The
2047
+ * model's label often repeats the slug ("flow-list-widget review"), so the slug and stray separators
2048
+ * are cut from it; with nothing left the op names the run. */
2049
+ function workerName(glyph: string, slug: string, op: string, label: unknown): string {
2050
+ const esc = slug.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2051
+ const what = String(label ?? "").replace(/[\r\n]+/g, " ").replace(new RegExp(esc, "gi"), " ")
2052
+ .replace(/^[\s·:|/,-]+|[\s·:|/,-]+$/g, "").replace(/\s{2,}/g, " ").slice(0, 40).trim();
2053
+ return `${glyph} ${slug} ${what || op}`;
2054
+ }
2055
+
1959
2056
  /** Seam that spawns a worker as a real pi session — tests replace `.run`. With the driver's session
1960
2057
  * file and directory known, the worker's header links back to the driver (`parentSession`), so pi's
1961
2058
  * picker nests it under the driver, and the pi-web meta lands as the file's first data entry. */
@@ -2172,13 +2269,13 @@ export default function devFlow(pi: ExtensionAPI) {
2172
2269
  name: "flow_stage",
2173
2270
  label: "Stage worker",
2174
2271
  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.',
2176
- 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',
2272
+ '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); op "reflect" (any stage, standard at finish) — a fresh read-only reviewer of this session\'s transcript and every worker transcript that returns classified reflection findings (docs / code / plugin) with a fold-or-drop recommendation each, for the operator to decide. 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.',
2273
+ promptSnippet: 'flow_stage(op: "implement"|"review"|"reflect", note, label?) — optional fresh-session worker for a big implement slice, an independent review, or the end-of-session reflection (finish); gates stay with you; in pi-web workers show up as subagents in the Agents menu',
2177
2274
  parameters: Type.Object({
2178
- op: Type.String({ description: '"implement" (a worker edits + commits a slice) or "review" (read-only reviewer, findings + verdict)' }),
2275
+ op: Type.String({ description: '"implement" (a worker edits + commits a slice), "review" (read-only reviewer, findings + verdict) or "reflect" (read-only reviewer of the session transcripts, reflection findings + fold/drop recommendations)' }),
2179
2276
  note: Type.String({ description: "The slice: what to do and anything from this conversation the worker must know (operator answers, decisions). Facts (plan path, commits, checks) are added for you." }),
2180
2277
  label: Type.Optional(Type.String({ description: "A few words naming this delegation, shown in the worker's session name." })),
2181
- budgetMin: Type.Optional(Type.Number({ description: "Wall-clock budget in minutes (5-180; default 60 implement, 30 review). Past it the worker is interrupted." })),
2278
+ budgetMin: Type.Optional(Type.Number({ description: "Wall-clock budget in minutes (5-180; default 60 implement, 30 review, 20 reflect). Past it the worker is interrupted." })),
2182
2279
  }),
2183
2280
  execute: async (id, params, signal, onUpdate, ctx) => {
2184
2281
  const err = (text: string) => ({ content: [{ type: "text" as const, text }], details: undefined, isError: true });
@@ -2191,29 +2288,52 @@ export default function devFlow(pi: ExtensionAPI) {
2191
2288
  const why = workerOpError(op, st.stage);
2192
2289
  if (why) return err(why);
2193
2290
  const wop = op as WorkerOp;
2194
- const work = worktreeAbs(root, st);
2291
+ // a reflection reviews transcripts, not the branch: it runs in the main checkout, where the
2292
+ // worktree may already be gone at finish time
2293
+ const work = wop === "reflect" ? root : worktreeAbs(root, st);
2195
2294
  if (!work || !existsSync(work)) return err(`feature ${st.slug} has no worktree on disk — nothing for a worker to work in`);
2196
2295
  if (runningWorkers.has(key)) return err("a worker is already running for this session — wait for it to return");
2197
2296
  runningWorkers.add(key);
2198
2297
  const cfg = loadProject(dfDir(root)).cfg;
2199
2298
  const budgetMin = clampBudgetMin(params.budgetMin, wop);
2200
- const label = String(params.label ?? "").replace(/[\r\n]+/g, " ").trim().slice(0, 40);
2201
- const glyph = wop === "implement" ? "🔨" : "🔍";
2202
- const name = `${glyph} ${st.slug}${label ? ` · ${label}` : ""}`;
2299
+ const glyph = wop === "implement" ? "🔨" : wop === "review" ? "🔍" : "🪞";
2300
+ const name = workerName(glyph, st.slug, wop, params.label);
2203
2301
  const started = Date.now();
2204
2302
  const git = async (cmd: string) => { const r = await sh(cmd, work); return r.ok ? r.out : ""; };
2205
2303
  const headBefore = (await git("git rev-parse HEAD")).trim();
2206
- const brief = buildWorkerBrief({
2207
- op: wop, slug: st.slug, workDir: work,
2208
- planFile: path.join(featDir(root, st.slug), "plan", "plan.md"),
2209
- defaultBranch: cfg.defaultBranch,
2210
- commits: await git(`git log --oneline ${sq(cfg.defaultBranch)}..HEAD`),
2211
- status: await git("git status --short"),
2212
- checks: cfg.checkList.map((c) => ({ name: c.name, command: c.cmd })),
2213
- note: String(params.note ?? ""),
2214
- });
2304
+ // the reflect worker runs in the main checkout, which may already carry the operator's edits
2305
+ const statusBefore = wop === "reflect" ? (await git("git status --short")).trim() : "";
2215
2306
  let lineage: { id?: string; file?: string; dir?: string } = {};
2216
2307
  try { lineage = { id: ctx.sessionManager.getSessionId(), file: ctx.sessionManager.getSessionFile() ?? undefined, dir: ctx.sessionManager.getSessionDir() ?? undefined }; } catch { /* unbacked driver: the worker is unlinked */ }
2308
+ const selfRepo = isSelfRepo(root);
2309
+ const brief =
2310
+ wop === "reflect"
2311
+ ? await (async () => {
2312
+ const items = readReflections(root);
2313
+ const fold = await foldView(root, items);
2314
+ return buildReflectBrief({
2315
+ slug: st.slug, root, today: now().slice(0, 10),
2316
+ driverFile: lineage.file ?? null,
2317
+ children: lineage.file ? childSessionFiles(lineage.file, sessionHeaders(lineage.dir)) : [],
2318
+ reflectionsFile: path.join(dfDir(root), "reflections.md"),
2319
+ items,
2320
+ projectMd: path.join(dfDir(root), "project.md"),
2321
+ version: pluginVersion(import.meta.dirname).version,
2322
+ upstream: await pluginUpstream(root),
2323
+ selfRepo,
2324
+ projectIssues: fold.state === "ok" && !selfRepo ? { repo: fold.slug, issues: fold.result.upstreamOnly.map((i) => ({ number: i.number, title: i.title })) } : undefined,
2325
+ note: String(params.note ?? ""),
2326
+ });
2327
+ })()
2328
+ : buildWorkerBrief({
2329
+ op: wop, slug: st.slug, workDir: work,
2330
+ planFile: path.join(featDir(root, st.slug), "plan", "plan.md"),
2331
+ defaultBranch: cfg.defaultBranch,
2332
+ commits: await git(`git log --oneline ${sq(cfg.defaultBranch)}..HEAD`),
2333
+ status: await git("git status --short"),
2334
+ checks: cfg.checkList.map((c) => ({ name: c.name, command: c.cmd })),
2335
+ note: String(params.note ?? ""),
2336
+ });
2217
2337
  // pi-web visibility needs both halves of the lineage: the id the Agents menu links the child
2218
2338
  // to, the file the parentSession header points at — without either the worker stays unlinked.
2219
2339
  const subagent = !lineage.id || !lineage.file ? undefined : { parentId: lineage.id, parentFile: lineage.file, toolCallId: id, profile: `flow-${wop}`, description: name, task: brief };
@@ -2226,9 +2346,13 @@ export default function devFlow(pi: ExtensionAPI) {
2226
2346
  const timer = setTimeout(() => { timedOut = true; abortChild(); }, budgetMin * 60_000);
2227
2347
  signal?.addEventListener("abort", abortChild);
2228
2348
  let unsub: (() => void) | undefined;
2349
+ let releaseLive: (status: string) => void = () => {};
2229
2350
  try {
2230
2351
  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" });
2352
+ if (subagent) {
2353
+ piwebStamp(child.sessionManager, PIWEB_SUBAGENT.status, { version: 1, status: "running" });
2354
+ releaseLive = piwebLiveClaim(child.sessionManager, subagent);
2355
+ }
2232
2356
  unsub = child.subscribe((ev: unknown) => {
2233
2357
  const e = ev as { type?: string; toolName?: string };
2234
2358
  if (e.type === "tool_execution_start") {
@@ -2241,7 +2365,7 @@ export default function devFlow(pi: ExtensionAPI) {
2241
2365
  // a turn that ends in prose ("now let me write D4…") ends the session: tell it to keep going
2242
2366
  while (!report.found && !timedOut && !signal?.aborted && nudges < WORKER_NUDGES) {
2243
2367
  nudges++;
2244
- await child.prompt(WORKER_NUDGE);
2368
+ await child.prompt(wop === "implement" ? WORKER_NUDGE : WORKER_NUDGE_READONLY);
2245
2369
  report = parseWorkerReport(child.getLastAssistantText() ?? "");
2246
2370
  }
2247
2371
  } catch (e) {
@@ -2261,22 +2385,48 @@ export default function devFlow(pi: ExtensionAPI) {
2261
2385
  // cannot prove live displays as `interrupted`); a no-REPORT run is a failure, not a ✓.
2262
2386
  if (subagent) {
2263
2387
  const doneAt = now();
2264
- piwebStamp(child?.sessionManager, PIWEB_SUBAGENT.result, crash
2388
+ const final = crash
2265
2389
  ? { version: 1, status: "failed", completedAt: doneAt, error: crash }
2266
2390
  : timedOut || signal?.aborted
2267
2391
  ? { version: 1, status: "aborted", completedAt: doneAt }
2268
2392
  : report.found
2269
2393
  ? { 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 });
2394
+ : { version: 1, status: "failed", completedAt: doneAt, error: `ended without REPORT after ${nudges} nudge(s)`, result: report.body };
2395
+ piwebStamp(child?.sessionManager, PIWEB_SUBAGENT.result, final);
2396
+ // leave the live map only once the result entry is down: the row is never neither
2397
+ releaseLive(final.status);
2271
2398
  }
2399
+ releaseLive("failed"); // idempotent guard: a throw between claim and result must not leave a live row
2272
2400
  try { if (child) workerSessions.delete(child.sessionManager.getSessionId()); } catch { /* id-less session: nothing was registered */ }
2273
2401
  try { child?.setSessionName(`${report.found && !crash && !timedOut && !signal?.aborted ? "✓" : "✗"} ${name}${report.verdict ? ` · ${report.verdict}` : ""}`); } catch { /* visibility only */ }
2274
- const parts = [
2275
- `${glyph} ${wop} worker ${outcome} (${Math.round((Date.now() - started) / 60_000)} min)`,
2402
+ const parts = [`${glyph} ${wop} worker ${outcome} (${Math.round((Date.now() - started) / 60_000)} min)`];
2403
+ let reflected: ReturnType<typeof parseReflectReport> | null = null;
2404
+ if (wop === "reflect") {
2405
+ reflected = report.found ? parseReflectReport(report.body) : null;
2406
+ const rows = reflected && (reflected.findings.length || reflected.open.length || /^\s*F0\b/m.test(report.body)) ? renderReflectFindings(reflected, selfRepo) : null;
2407
+ parts.push(rows ? rows.join("\n") : report.found ? `REPORT (rows did not parse — read them yourself):\n${report.body.slice(0, 6000)}` : `no REPORT — last words:\n${report.body}`);
2408
+ if (report.found) {
2409
+ // the record finish reads: a reflection ran for this flow (advisory — finish never blocks on it)
2410
+ const cur = readState(root, st.slug);
2411
+ if (cur) { cur.reflectedAt = now(); writeState(root, cur); }
2412
+ }
2413
+ const recurred = reflected?.open.filter((x) => x.status === "recurred").length ?? 0;
2414
+ const nudges = reflectionNudges(readReflectionsText(root), now().slice(0, 10), { recurred });
2415
+ parts.push(
2416
+ "Next: show the operator this numbered list with your recommendation per item and ask fold or drop for each (one answer like 'fold 1,3 drop 2' is fine) — then STOP until they answer. " +
2417
+ `Fold docs → flow reflect --playbook "<note>"; fold code → flow reflect --code "<note>"; fold plugin → ${selfRepo ? 'flow reflect --code "<note>" (this is the dev-flow repo)' : 'flow reflect --plugin "<note>" prints the upstream recipe (dedupe search, then gh issue create — the fold answer is the confirmation; never a reflections.md row)'}; drop → record nothing. Open items re-checked as fixed → propose checking them off.`,
2418
+ );
2419
+ if (nudges.fix) parts.push(`${nudges.fix} — offer it after the fold/drop answer.`);
2420
+ if (nudges.tidy) parts.push(`${nudges.tidy} — offer it after the fold/drop answer.`);
2421
+ if (newCommits.trim() || dirty !== statusBefore) parts.push("note: the reflect worker changed the tree — inspect the change; it was told to write nothing");
2422
+ parts.push(`transcript: ${transcript || "(unknown)"}`);
2423
+ return { content: [{ type: "text", text: parts.join("\n\n") }], details: { op: wop, outcome, verdict: null, commits: 0, findings: reflected?.findings.length ?? 0 } };
2424
+ }
2425
+ parts.push(
2276
2426
  report.found ? `REPORT:\n${report.body.slice(0, 6000)}` : `no REPORT — last words:\n${report.body}`,
2277
2427
  `new commits:\n${newCommits.trim() || "(none)"}`,
2278
2428
  `uncommitted: ${dirty ? `\n${dirty}` : "clean"}`,
2279
- ];
2429
+ );
2280
2430
  if (wop === "implement") {
2281
2431
  const check = await runFlow(["check"], root, uiFrom(ctx), sessFor(ctx, root));
2282
2432
  parts.push(`flow check after the worker: ${check.text.replace(/\s+/g, " ").trim().slice(0, 1500)}`);
@@ -2522,7 +2672,12 @@ export default function devFlow(pi: ExtensionAPI) {
2522
2672
  const curBr = await currentBranch(root);
2523
2673
  if (curBr && curBr !== cfg.defaultBranch) content += ` Also: main checkout is on ${curBr}, not ${cfg.defaultBranch} — surface this to the operator before starting work.`;
2524
2674
  const refl0 = readReflections(root);
2525
- if (refl0.length) content += ` Also: ${refl0.length} reflection(s) open — run flow doctor.`;
2675
+ if (refl0.length) {
2676
+ // between flows is the moment to fix them: the nudge names the docs/patch split when a rule fires
2677
+ const nudge = reflectionNudges(readReflectionsText(root), now().slice(0, 10), { between: true });
2678
+ content += ` Also: ${refl0.length} reflection(s) open — ${nudge.fix ? `${nudge.fix}; mention it to the operator` : "run flow doctor"}.`;
2679
+ if (nudge.tidy) content += ` Also: ${nudge.tidy}.`;
2680
+ }
2526
2681
  const rmap0 = roadmapOpenCount(readRoadmap(root));
2527
2682
  if (rmap0) content += ` Also: ${rmap0} roadmap item(s) open — flow roadmap lists them, flow roadmap pick <n> <slug> hands one to flow start.`;
2528
2683
  content += ` Also: the playbook map is ${path.join(SKILL_DIR, "SKILL.md")} — per-stage detail sits in references/ beside it (start: flow init, modes, ownership).`;
@@ -2539,8 +2694,12 @@ export default function devFlow(pi: ExtensionAPI) {
2539
2694
  guidance.push("Stage reports: open every report with the stage line (statusbar glyph + slug + provenance-marked decision fields); close a checkpoint with an event title and `Done:` / `Next steps:` on own lines — italic verbs, recommended first, yolo last. See Stage reports in the ground rules.");
2540
2695
  const pend = checklistPending(cfg, state, state.stage);
2541
2696
  if (pend) guidance.push(`Tier-2 checklist NOT yet confirmed (${pend} item(s)): ${applicableItems(cfg, state, state.stage).map((i) => i.text).join(" | ")}${state.stage === "release" ? " — release-stage items close with the operator's Finish? answer; no earlier gate records them" : ""}`);
2542
- const refl = readReflections(root);
2543
- if (refl.length) guidance.push(`↻ ${refl.length} reflection(s) open — mention to the operator; run flow doctor to review and route them (fold in only on request).`);
2697
+ // mid-feature is the wrong moment to divert into old reflections — they surface at the release
2698
+ // stage (finish runs the reflection), between flows, and in status/doctor
2699
+ if (state.stage === "release") {
2700
+ const refl = readReflections(root);
2701
+ if (refl.length) guidance.push(`↻ ${refl.length} reflection(s) open — the finish reflection (flow_stage op "reflect") re-checks them; fix them only on the operator's word.`);
2702
+ }
2544
2703
  const rmap = roadmapOpenCount(readRoadmap(root));
2545
2704
  if (rmap) guidance.push(`◇ ${rmap} roadmap item(s) open — flow roadmap lists them (pick only on the operator's word).`);
2546
2705
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.76.0",
3
+ "version": "0.77.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": [
@@ -91,5 +91,5 @@ session's stage injection names the file to read now, and this is the map.
91
91
  | `references/implement.md` | implement stage — worktree, commits, checks, tier-2 list, Verified? |
92
92
  | `references/pre-release.md` | pre-release — `/flow-review`, docs, changelog + bump, Release? |
93
93
  | `references/release.md` | release — PR and merge style, tag, forge release, release-done; hands over to finish |
94
- | `references/finish.md` | the close-out after `release-done` — reflect first, Finish?, worktree and branch cleanup |
95
- | `references/reflect.md` | reflections (the suggestion queue) and the roadmap backlog |
94
+ | `references/finish.md` | the close-out after `release-done` — the reflect worker and fold/drop first, Finish?, worktree and branch cleanup |
95
+ | `references/reflect.md` | reflections (this project's queue; plugin feedback → upstream issues), when to fix or tidy, and the roadmap backlog |
@@ -5,18 +5,36 @@
5
5
  ## Stage: finish
6
6
 
7
7
  **Reflect before you finish** — `flow finish` deletes `.dev-flow/<slug>/` and
8
- the session context goes with it. Run the end-of-session reflection (bare
9
- `flow reflect` protocol under *Reflect*) now and park real issues with
10
- `flow reflect`; then:
11
-
12
- - issues parked → ask **Fold? Fix? Drop?** and stop: fold = write the items
13
- into `.dev-flow/reflections.md` (your queue), fix = route them now via
14
- `flow doctor`, drop = discard them. The answer replaces **Finish?** — act
15
- on it, then run `flow finish --confirmed` without asking again;
16
- - nothing parked → ask the operator **Finish?** → `flow finish --confirmed`.
17
- Checkpoint report: stage line **🏁 finish · `<slug>`** — release recorded ·
18
- main state · unmerged count · reflections open · release-checklist open,
19
- then `Done:`/`Next steps:` per the Stage reports rule.
8
+ the session context goes with it. Run the end-of-session reflection now:
9
+
10
+ 1. `flow_stage({ op: "reflect", note })` — a fresh **read-only** reviewer reads
11
+ this session's transcript **and every `flow_stage` worker transcript**,
12
+ re-checks the open items in `.dev-flow/reflections.md`, dedupes against them
13
+ and the upstream issues, and returns numbered findings, each classified
14
+ **docs** (fix only in `project.md` → docs flow), **code** (fix in this
15
+ project's code, maybe the playbook too → patch flow) or **plugin** (dev-flow
16
+ itself → GitHub issue upstream), with a **fold** or **drop** recommendation.
17
+ `note` = anything the operator said about friction this session. If the
18
+ worker fails, run the review inline (bare `flow reflect` prints the protocol).
19
+ 2. Show the operator the list with your recommendation per item and ask
20
+ **fold or drop** for each (`fold 1,3 drop 2` is a fine answer) — then stop.
21
+ 3. Apply the answer: fold docs → `flow reflect --playbook "<note>"`; fold code →
22
+ `flow reflect --code "<note>"`; fold plugin → `flow reflect --plugin "<note>"`
23
+ prints the upstream recipe — search first, then `gh issue create` (the fold
24
+ answer is the confirmation; report the URL). **Plugin findings never become
25
+ rows in the project's `reflections.md`.** Drop → nothing is recorded. Open
26
+ items the reviewer found fixed → propose checking them off.
27
+ 4. Offer the fix / tidy suggestions the tool printed (`⚑ fix the open
28
+ reflections now?`, `↻ N closed reflection(s)`) — one line each, only when
29
+ printed; never start a fix flow without the operator's word.
30
+
31
+ The fold/drop answer replaces **Finish?** — act on it, then run
32
+ `flow finish --confirmed` without asking again. Nothing found → ask the
33
+ operator **Finish?** → `flow finish --confirmed`. A finish question with no
34
+ reflection recorded for the flow names it (advisory, never a block).
35
+ Checkpoint report: stage line **🏁 finish · `<slug>`** — release recorded ·
36
+ main state · unmerged count · reflections open · release-checklist open,
37
+ then `Done:`/`Next steps:` per the Stage reports rule.
20
38
 
21
39
  The question covers the whole cleanup and mentions any commits that look
22
40
  unmerged. `flow finish [slug]`:
@@ -62,6 +62,10 @@ asks who wrote a commit.
62
62
  no stamp, no gate waits on it. On a non-trivial feature, run one before
63
63
  Verified?. Fix what is real (inline is fine), and re-review only if the fix
64
64
  was large.
65
+ - `flow_stage({ op: "reflect", note })` — a fresh **read-only** reviewer of this
66
+ session's transcripts (driver + every worker), at any stage; its standard
67
+ moment is finish (see Stage: finish). It returns classified reflection
68
+ findings with fold/drop recommendations and writes nothing.
65
69
  - One worker at a time per session. The worker holds no flow tool, so gates
66
70
  and checkpoints stay with you. Its transcript nests under this session in
67
71
  pi's picker.