pi-dev-flow 0.94.0 → 0.94.3

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,27 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.94.3] - 2026-11-19
8
+
9
+ **Fold or drop? shows the findings you're answering about: a short list, folds grouped by plugin, playbook and code, then the drops.**
10
+
11
+ ### Fixed
12
+ - **Fold or drop? lists the findings you're answering about (gh#260).** The closing reflection suggested "fold 2", but your view didn't show what 2 was. A finding that quoted a flow command (such as "`flow finish` removed nothing") lost its headline line, because the view hides command text. Finish now starts with a short list: one line per finding, with folds grouped by plugin, playbook and code, and drops after them. The header shows the suggested `fold … · drop …` answer. Only the agent sees each finding's full route, duplicate and reason.
13
+
14
+ ## [0.94.2] - 2026-11-19
15
+
16
+ **Publishes 0.94.1's fix: you're asked Release? once. 0.94.1 never reached npm because a flaky test failed its publish run.**
17
+
18
+ ### Fixed
19
+ - **A malformed session pid always reads as dead.** `pidAlive("123")` was meant to treat a malformed pid as dead, but `process.kill` turned it into pid 123. On a machine where a process with that pid existed, the claim read as alive, and that failed the 0.94.1 publish run. `pidAlive` now treats anything but a positive integer as dead without checking for the process.
20
+
21
+ ## [0.94.1] - 2026-11-19
22
+
23
+ **You're asked Release? once: the gate asks it, never the agent ahead of the call, and your answer after Verified? stands even when the agent carries a yolo onto it.**
24
+
25
+ ### Fixed
26
+ - **You're asked Release? once (gh#254, gh#253).** The pre-release hint told the agent to ask Release? in chat and then run `flow release`. The gate never saw that question, so when it needed your word (`yolo = until-release`, commits after Verified?, a stale build) it asked again, and you answered twice. A PR-body refusal could also land after your answer. The hint now says to run `flow release` first and ask only when it returns `NEEDS-OPERATOR Release?`. Under `yolo = until-release` the injected yolo note no longer claims Release? is pre-confirmed, and says to run `flow release` without `--yolo`. When the agent still adds `--yolo` to your answer, the gate accepts it if you've sent a message since Verified?. A yolo replayed with nothing said since is still asked first (gh#219).
27
+
7
28
  ## [0.94.0] - 2026-11-19
8
29
 
9
30
  **The review runs before Verified?, so you're asked Verified? once; an unanswered re-verify holds the release; your Release? word stands on the first call under `yolo = until-release`; and `flow roadmap done` closes the items you named.**
@@ -120,6 +120,7 @@ export default function devFlow(pi: ExtensionAPI) {
120
120
  return {
121
121
  key,
122
122
  slug: bindings.get(key) ?? null,
123
+ operatorMessages: operatorMessageCount((() => { try { return ctx.sessionManager?.getBranch(); } catch { return null; } })()),
123
124
  bind: (slug) => {
124
125
  const prev = bindings.get(key);
125
126
  bindings.set(key, slug);
@@ -480,7 +481,7 @@ export default function devFlow(pi: ExtensionAPI) {
480
481
  const recurred = reflected?.open.filter((x) => x.status === "recurred").length ?? 0;
481
482
  const nudges = reflectionNudges(readReflectionsText(root), now().slice(0, 10), { recurred });
482
483
  parts.push(
483
- "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. " +
484
+ "Next: show the operator the fold/drop list above as it stands — suggested folds grouped by plugin, playbook and code, then the drops, one short line each — and ask for one answer (the suggested 'fold … drop …' line is fine) — then STOP until they answer. " +
484
485
  `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.`,
485
486
  );
486
487
  if (nudges.fix) parts.push(`${nudges.fix} — offer it after the fold/drop answer.`);
@@ -907,7 +908,11 @@ export default function devFlow(pi: ExtensionAPI) {
907
908
  return { message: { customType: "dev-flow-context", display: false, content: `${core}${sameAsLast(key, content, `[dev-flow] no flow bound — unchanged since the last [dev-flow] note (playbook map is ${path.join(SKILL_DIR, "SKILL.md")}).`)}` } };
908
909
  }
909
910
  const guidance: string[] = [];
910
- if (state.yolo) guidance.push("YOLO mode: the operator pre-confirmed every gate question from here on (Verified?/Release?/Finish?) — run the remaining gates (verify → release → finish) back to back without stopping to ask; guidance the operator attached to the yolo word (e.g. patch bump, no tag) is a binding directive for the chain; checks and guardrails stay fully enforced.");
911
+ // gh#254: under yolo = until-release the standing word does not answer Release? — saying it did sent the agent
912
+ // to carry it onto the call as --yolo --confirmed, which the gate reads as a replay and asks again
913
+ if (state.yolo && cfg.release.yolo === "until-release")
914
+ guidance.push("YOLO mode (until-release): the operator pre-confirmed Verified? and Finish? — run verify and finish without stopping to ask; Release? is NOT pre-confirmed (the playbook sets yolo = until-release). Run flow release bare — never with --yolo — and when it returns NEEDS-OPERATOR Release?, ask Release? in chat, stop, and on their answer re-run flow release --confirmed (plus --version=… / --no-version if they named the call). Guidance the operator attached to the yolo word (e.g. patch bump, no tag) is a binding directive for the chain; checks and guardrails stay fully enforced.");
915
+ else if (state.yolo) guidance.push("YOLO mode: the operator pre-confirmed every gate question from here on (Verified?/Release?/Finish?) — run the remaining gates (verify → release → finish) back to back without stopping to ask; guidance the operator attached to the yolo word (e.g. patch bump, no tag) is a binding directive for the chain; checks and guardrails stay fully enforced.");
911
916
  // The one playbook file this stage needs, named outright: the model reads it instead of
912
917
  // guessing what a stage asks of it, and it pays for itself the first time a gate is refused.
913
918
  const ref = stageReference(state.stage);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.94.0",
3
+ "version": "0.94.3",
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": [
@@ -43,7 +43,9 @@ and settle the scheme with the operator; never invent one.
43
43
  refuses without it.
44
44
  5. No `flow check` is owed after the prep commit: the gate keeps green checks across a commit that
45
45
  holds only the bump and changelog, and runs any stale check itself.
46
- 6. **Run `flow release`.** By default (`ask = on-change`) it answers
46
+ 6. **Run `flow release` before asking anything.** Never ask Release? in
47
+ chat ahead of the call: the gate did not see that question, and when it
48
+ needs the word it asks again, so the operator answers twice. By default (`ask = on-change`) it answers
47
49
  Release? itself when the release call is on record and only the prep
48
50
  landed since Verified? — say in a few lines what the PR delivers (the
49
51
  changelog entry usually is that) and the version, and carry on with the
@@ -59,7 +61,8 @@ and settle the scheme with the operator; never invent one.
59
61
  `NEEDS-OPERATOR Release?` when commits landed after Verified?, the
60
62
  playbook says `yolo = until-release`, or the session build is stale —
61
63
  then ask. A `--confirmed` passed before the gate asked is not an answer
62
- there: the gate asks first.
64
+ there: the gate asks first. Never carry the standing yolo onto the call
65
+ as `--yolo`: the operator's answer is `flow release --confirmed`.
63
66
  - Operator ships **without a version** → `flow release --no-version
64
67
  --confirmed`: no bump or tag, but the branch must add its line under
65
68
  `Unreleased`. A changed call is `--version=<v>` / `--no-version` with
package/src/core.ts CHANGED
@@ -58,6 +58,9 @@ export interface FlowState {
58
58
  releaseOnly?: boolean; // verify found nothing on the branch but unreleased work on main: this flow only cuts the version (#161)
59
59
  versionChoice?: string; // the operator's release call, recorded with Verified? (gh#198): patch | minor | major (counted from the newest tag at release, so a parallel flow taking the number moves it), an exact version, "next" (playbook version = versioned: any bump past the last tag) or "unreleased"
60
60
  versionFrom?: string; // the manifest version when the call was recorded — what a patch/minor/major call was counted from at Verified?
61
+ /** the session and its operator-message count when Verified? moved this flow to pre-release (gh#254): under
62
+ * yolo = until-release, a message after it is the operator's own Release? word, not a replayed plan-stage yolo */
63
+ verifiedAtMessage?: { key: string; users: number };
61
64
  verifiedHead?: string; // HEAD the operator's Verified? was given over — release names commits after it, so the word is not recorded as the verdict for a tree nobody looked at (#162)
62
65
  reflectedAt?: string; // a reflect worker reported for this flow — finish runs one first while this is unset (only --no-reflect --confirmed skips it)
63
66
  devPort?: number; // the port the operator chose for this flow's dev deploy when the default was held by another flow — finish stops it (devDown)
@@ -1758,6 +1761,8 @@ export interface SessionClaim {
1758
1761
 
1759
1762
  /** Whether a process is running (kill 0 only probes existence; EPERM means it exists, foreign-owned). */
1760
1763
  export function pidAlive(pid: number): boolean {
1764
+ // a corrupt value is dead, never probed: process.kill coerces "123" to pid 123, which may be a live process
1765
+ if (!Number.isInteger(pid) || pid <= 0) return false;
1761
1766
  try {
1762
1767
  process.kill(pid, 0);
1763
1768
  return true;
@@ -2411,12 +2416,15 @@ export function nextHint(state: FlowState, cfg: Config): string {
2411
2416
  const rv = reviewOwed(state, cfg) ? `${cfg.release.review} (then record it: flow review done "<verdict>")` : cfg.release.review && state.review ? "review on record" : "";
2412
2417
  const review = rv ? `${rv}, ` : "";
2413
2418
  const auto = cfg.release.ask !== "always" ? " (release.ask = on-change: it asks Release? only when something beyond the prep changed)" : "";
2419
+ // gh#254: the gate is the one that asks Release? — asked in chat first, the gate never saw the question and
2420
+ // put it again (a yolo or until-release hold), so the operator answered twice
2421
+ const gateAsks = `${auto} — the gate asks Release? when it needs the operator's word (NEEDS-OPERATOR Release?): ask it then, never before the call`;
2414
2422
  if (vc === "unreleased")
2415
- return `${review}fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs${cfg.release.changelog && !state.docs ? `, add this flow's line under Unreleased in ${cfg.release.changelog} (the call is merge unreleased: no bump)` : ""}; show the PR summary, then run flow release${auto || " and ask Release?"}`;
2423
+ return `${review}fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs${cfg.release.changelog && !state.docs ? `, add this flow's line under Unreleased in ${cfg.release.changelog} (the call is merge unreleased: no bump)` : ""}; show the PR summary, then run flow release${gateAsks}`;
2416
2424
  const prep = [cfg.release.changelog ? `prepare ${cfg.release.changelog} (fold Unreleased lines verbatim)` : "", cfg.versioning.file ? `bump version in ${cfg.versioning.file}${isBumpKind(vc) ? ` to ${bumpVersion(state.versionFrom, vc) ?? `the next ${vc}`} (a ${vc} release, the operator's call — the gate counts it from the newest tag, so a flow that released first moves the number)` : vc && vc !== "next" ? ` to ${vc} (the operator's call)` : ""}` : ""].filter(Boolean).join(" and ");
2417
- if (vc && prep) return `${review}fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs, ${prep}; show the PR summary, version and changelog, then run flow release${auto || " and ask Release?"}`;
2418
- if (state.docs && prep) return `${review}fix must/should; a docs flow usually ships unversioned — ask the operator (flow release --no-version on their word); versioned instead: ${prep}; then ask Release? and run flow release`;
2419
- return `${review}fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs${prep ? `, ${prep}` : ""}; show the PR summary, version and changelog, ask Release? and run flow release`;
2425
+ if (vc && prep) return `${review}fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs, ${prep}; show the PR summary, version and changelog, then run flow release${gateAsks}`;
2426
+ if (state.docs && prep) return `${review}fix must/should; a docs flow usually ships unversioned — ask the operator (flow release --no-version on their word); versioned instead: ${prep}; then run flow release${gateAsks}`;
2427
+ return `${review}fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs${prep ? `, ${prep}` : ""}; show the PR summary, version and changelog, then run flow release${gateAsks}`;
2420
2428
  }
2421
2429
  case "release":
2422
2430
  if (state.approvals.release) return `release recorded — commit and push any release chores in the main checkout (DEV_FLOW_ALLOW_MAIN=1 for the pre-commit hook), then flow finish (closing reflection first; its fold/drop answer is Finish?)`;
@@ -2957,18 +2965,52 @@ export function parseReflectReport(body: string): { findings: ReflectFinding[];
2957
2965
  return { findings, open };
2958
2966
  }
2959
2967
 
2960
- /** The numbered list the driver shows the operator: one row per finding with its route, then the
2961
- * open-item re-check. Routes follow where the fix lives — plugin is always an upstream issue
2962
- * (code in the dev-flow repo itself), never a local row. */
2968
+ /** A finding as one short operator-facing line: clipped at a word boundary, with any dev-flow command text
2969
+ * spelled as plain words. The view drops a line that names a flow command, so a finding that merely quoted
2970
+ * one (`flow finish` removed nothing) vanished from the list the operator was answering about. */
2971
+ export function shortFindingNote(note: string, max = 110): string {
2972
+ const plain = note
2973
+ .replace(/`([^`]*)`/g, "$1")
2974
+ .replace(/(^|[\s'"(*_])\/?flow (?=[a-z])/g, "$1")
2975
+ .replace(/(^|\s)--(?=[a-z])/g, "$1")
2976
+ .replace(/\bflow_stage\b/g, "worker")
2977
+ .replace(/\s+/g, " ")
2978
+ .trim();
2979
+ if (plain.length <= max) return plain;
2980
+ const cut = plain.slice(0, max);
2981
+ const at = cut.lastIndexOf(" ");
2982
+ return `${(at > max * 0.6 ? cut.slice(0, at) : cut).replace(/[\s,;:—-]+$/, "")}…`;
2983
+ }
2984
+
2985
+ /** The fold/drop list the operator answers (gh#260): a short line per finding, the suggested folds first —
2986
+ * grouped by where the fix lives (plugin, playbook, code) — then the suggested drops, so "fold 2" names
2987
+ * something they can read. The full rows (route, dup, why) follow for the agent only. Routes follow where
2988
+ * the fix lives — plugin is always an upstream issue (code in the dev-flow repo itself), never a local row. */
2963
2989
  export function renderReflectFindings(r: { findings: ReflectFinding[]; open: ReflectOpenCheck[] }, selfRepo: boolean): string[] {
2990
+ const kindOf = (f: ReflectFinding): ReflectKind => (f.kind === "plugin" && selfRepo ? "code" : f.kind);
2964
2991
  const route = (k: ReflectKind) =>
2965
- k === "docs" ? "docs flow · record: flow reflect --playbook" : k === "code" || selfRepo ? "patch flow · record: flow reflect --code" : "upstream GitHub issue · flow reflect --plugin prints the recipe (never a local row)";
2992
+ k === "docs" ? "docs flow · record: flow reflect --playbook" : k === "code" ? "patch flow · record: flow reflect --code" : "upstream GitHub issue · flow reflect --plugin prints the recipe (never a local row)";
2993
+ const KIND_LABEL: Record<ReflectKind, string> = { plugin: "plugin (an upstream dev-flow issue)", docs: "playbook (a docs flow)", code: "code (a patch flow)" };
2966
2994
  const out: string[] = [];
2967
2995
  if (r.findings.length) {
2968
- out.push(`findings (${r.findings.length}) — recommendation · kind → route:`);
2996
+ const folds = r.findings.filter((f) => f.rec === "fold");
2997
+ const drops = r.findings.filter((f) => f.rec === "drop");
2998
+ const nums = (fs: ReflectFinding[]) => fs.map((f) => f.n).join(",");
2999
+ out.push(`findings (${r.findings.length}) — suggested: ${[folds.length ? `fold ${nums(folds)}` : "", drops.length ? `drop ${nums(drops)}` : ""].filter(Boolean).join(" · ")}`);
3000
+ for (const k of ["plugin", "docs", "code"] as const) {
3001
+ const group = folds.filter((f) => kindOf(f) === k);
3002
+ if (!group.length) continue;
3003
+ out.push(`fold — ${KIND_LABEL[k]}:`);
3004
+ for (const f of group) out.push(` ${f.n}. ${shortFindingNote(f.note)}`);
3005
+ }
3006
+ if (drops.length) {
3007
+ out.push("drop:");
3008
+ for (const f of drops) out.push(` ${f.n}. ${shortFindingNote(f.note)} (${kindOf(f) === "docs" ? "playbook" : kindOf(f)})`);
3009
+ }
3010
+ out.push(`${AGENT_MARK}finding detail — recommendation · kind → route:`);
2969
3011
  for (const f of r.findings) {
2970
- out.push(` ${f.n}. [${f.rec}] ${f.kind}: ${f.note}`);
2971
- out.push(` → ${route(f.kind === "plugin" && selfRepo ? "code" : f.kind)}${f.dup && f.dup !== "none" ? ` · dup: ${f.dup}` : ""}${f.why ? ` · ${f.why}` : ""}`);
3012
+ out.push(`${AGENT_MARK}${f.n}. [${f.rec}] ${f.kind}: ${f.note}`);
3013
+ out.push(`${AGENT_MARK} → ${route(kindOf(f))}${f.dup && f.dup !== "none" ? ` · dup: ${f.dup}` : ""}${f.why ? ` · ${f.why}` : ""}`);
2972
3014
  }
2973
3015
  } else out.push("findings: none");
2974
3016
  if (r.open.length) {
@@ -471,4 +471,7 @@ export interface Session {
471
471
  bind: (slug: string | null) => void;
472
472
  /** Name the pi session after a slug (one session = one feature: the picker shows the feature). */
473
473
  rename: (slug: string) => void;
474
+ /** Operator messages in this session's branch so far, or null/undefined when it cannot be read — a gate
475
+ * compares it with the count it recorded earlier to know whether the operator spoke since (gh#254). */
476
+ operatorMessages?: number | null;
474
477
  }
@@ -207,6 +207,9 @@ export async function gateVerify(o: GateCtx): Promise<RunResult> {
207
207
  const choiceNote = choice ? `\nrelease call: ${describeVersionChoice(choice, state!.versionFrom)}` : "";
208
208
  const before = state!.stage;
209
209
  state!.stage = "pre-release";
210
+ // gh#254: what the operator says after this point is said over a tree they verified — the release gate reads it
211
+ if (typeof sess.operatorMessages === "number") state!.verifiedAtMessage = { key: sess.key, users: sess.operatorMessages };
212
+ else delete state!.verifiedAtMessage;
210
213
  delete state!.pendingAsk;
211
214
  delete state!.reverifyAsked;
212
215
  writeState(root, state!);
@@ -445,8 +448,14 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
445
448
  // stands on the first call, as it does on a flow without yolo; asking first made them repeat a word already
446
449
  // given. gh#219's shape — `--yolo --confirmed` replayed from the plan-stage word — still gets the question.
447
450
  // Commits after Verified? and a stale build carry news, so those holds always ask first.
451
+ // gh#254: the agent carried the standing yolo onto the call as `--yolo --confirmed` after the operator had
452
+ // answered Release? in chat, and the replay guard threw the fresh answer out with the replayed flag. A replay
453
+ // has no operator message behind it since Verified? moved the flow here; an answer does — so a message in
454
+ // this session after that point lets the flag stand, and only a true replay is asked first.
455
+ const vm = state!.verifiedAtMessage;
456
+ const spokeSinceVerify = !!vm && vm.key === sess.key && typeof sess.operatorMessages === "number" && sess.operatorMessages > vm.users;
448
457
  const untilReleaseOnly = cfg.release.yolo === "until-release" && !postVerify && !stale;
449
- const mustAskFirst = (!!holdWhy && !(untilReleaseOnly && !flag("yolo"))) || stale;
458
+ const mustAskFirst = (!!holdWhy && !(untilReleaseOnly && (!flag("yolo") || spokeSinceVerify))) || stale;
450
459
  const confirmed = flag("confirmed") && !(mustAskFirst && !ui.hasUI && state!.pendingAsk !== "Release?");
451
460
  const yoloHeld = confirmed ? "" : holdWhy;
452
461
  // gh#198: release.ask = on-change — Release? answers itself when it would only re-confirm Verified?: the call