pi-dev-flow 0.94.2 → 0.95.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.
@@ -1,12 +1,13 @@
1
1
  /** dev-flow runtime — The gates that ship: verify, release, release-done, finish. Moved out of extensions/dev-flow.ts as is (exports added). */
2
2
  import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
3
  import path from "node:path";
4
- import { applicableItems, changelogVersionsBetween, normalizeReleaseBody, pendingEntryLines, pickReleaseNotes, checklistHash, checklistPending, cmpVersions, freshenChecks, healthProbe, mergeShapeProof, preReleaseGate, reflectionNudges, conflictMarkerLines, isReleaseOnly, looksLikeShellError, needsOperator, newestTaggedVersion, nextHint, releaseGate, parseVersion, roadmapDoneForSlug, sq, tagNotesCommand, verifyGate, versionTagGate, servedBuildMatches, prepFiles, versionArg, playbookVersionChoice, describeVersionChoice, majorBump, bumpVersion, isBumpKind, resolvedDevEnv, reviewOwed, localDefaultAhead, failTail } from "../core.ts";
4
+ import { skipsChecks, applicableItems, changelogVersionsBetween, normalizeReleaseBody, pendingEntryLines, pickReleaseNotes, checklistHash, checklistPending, cmpVersions, freshenChecks, healthProbe, mergeShapeProof, preReleaseGate, reflectionNudges, conflictMarkerLines, isReleaseOnly, looksLikeShellError, needsOperator, newestTaggedVersion, nextHint, releaseGate, parseVersion, roadmapDoneForSlug, sq, tagNotesCommand, verifyGate, versionTagGate, servedBuildMatches, prepFiles, versionArg, playbookVersionChoice, describeVersionChoice, majorBump, bumpVersion, isBumpKind, resolvedDevEnv, reviewOwed, localDefaultAhead, failTail, operatorDirt } from "../core.ts";
5
5
  import type { Config, FlowState } from "../core.ts";
6
6
  import { AGENT_MARK } from "../present.ts";
7
- import { buildSkew, copyWarning, currentBranch, featDir, flagValue, forgeMergeStyle, forgeOf, gateCwd, mergeBase, needState, now, originUrl, readReflectionsText, readRoadmap, readState, releaseTags, roadmapFile, sh, tail, worktreeAbs, writeState } from "./base.ts";
7
+ import { refreshDocsCode, buildSkew, copyWarning, currentBranch, featDir, flagValue, forgeMergeStyle, forgeOf, gateCwd, mergeBase, needState, now, originUrl, readReflectionsText, readRoadmap, readState, releaseTags, roadmapFile, sh, tail, worktreeAbs, writeState } from "./base.ts";
8
8
  import { type RunResult, ago, releaseDevSlot, keepThroughPrep, branchState, catchUp, describeBranchState, devEnv, devPortOf, devSlotCheck, healthRerunsAfterDeploy, pendingChecks, probeHealth, readDevPorts, runChecks, slotKey, triedNote, unreleasedOnMain, worktreeFingerprint, writeDevPorts } from "./checks.ts";
9
9
  import { type GateCtx, markPendingAsk } from "./gates.ts";
10
+ import { closeLinkedReflections } from "./reflect.ts";
10
11
  import { gatePublishes, prBodyOwed, publishRelease } from "./publish.ts";
11
12
 
12
13
  /** gh#198: the version question asked with Verified? — null when it is not the operator's to answer here
@@ -42,6 +43,7 @@ export async function gateVerify(o: GateCtx): Promise<RunResult> {
42
43
  const fpAtGate = await worktreeFingerprint(gateCwd(root, state!));
43
44
  const staleAtGate = freshenChecks(state!, fpAtGate, (n) => n === "health" && healthRerunsAfterDeploy(cfg));
44
45
  if (staleAtGate.length) writeState(root, state!);
46
+ await refreshDocsCode(root, state!, cfg); // a docs flow whose diff reaches code owes the checks like any flow
45
47
  const pending = pendingChecks(state!, cfg);
46
48
  const gateRun = pending.length ? await runChecks(root, state!, cfg, pending) : null;
47
49
  if (gateRun?.failed) return { text: `verify gate FAILED — a check run at the gate failed:\n${gateRun.lines.join("\n")}\n${branchLine}`, isError: true };
@@ -354,7 +356,8 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
354
356
  // tier-2 pre-release confirmation is recorded by this very command, so it is excluded here
355
357
  // The checks this gate needs green are run by the gate, as verify does (#84) — after the cheap proofs, so a
356
358
  // wrong version or a missing changelog entry is refused before minutes are spent on a suite.
357
- const owed = state!.docs ? [] : cfg.checkList.filter((c) => !state!.checks[c.name]?.ok);
359
+ await refreshDocsCode(root, state!, cfg);
360
+ const owed = skipsChecks(state!) ? [] : cfg.checkList.filter((c) => !state!.checks[c.name]?.ok);
358
361
  const assumed = { ...state!.checks, ...Object.fromEntries(owed.map((c) => [c.name, { ok: true, at: now() }])) };
359
362
  const gateState = (checks: FlowState["checks"]) => ({ ...state!, checks, noVersion, confirmations: { ...state!.confirmations, "pre-release": { hash: checklistHash(items), at: now() } } });
360
363
  const cheap = preReleaseGate(gateState(assumed), cfg, prep);
@@ -772,7 +775,9 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
772
775
  return { text: `finish closes a released feature — stage is "${state!.stage}" and no release is recorded; publish it first — flow release (to abandon an unfinished feature, run flow abort)`, isError: true };
773
776
  // after this the flow state is gone: nothing may sit uncommitted or unpushed
774
777
  const dirty = await sh("git status --porcelain", root);
775
- if (dirty.ok && dirty.out.trim()) return { text: `main checkout has uncommitted changes — commit them first (finish deletes .dev-flow/${state!.slug}/):\n${tail(dirty.out)}`, isError: true };
778
+ // dev-flow's own folder is never the operator's uncommitted work — another flow's state least of all
779
+ const work = dirty.ok ? operatorDirt(dirty.out) : "";
780
+ if (work.trim()) return { text: `main checkout has uncommitted changes — commit them first (finish deletes .dev-flow/${state!.slug}/):\n${tail(work)}`, isError: true };
776
781
  const origin = await originUrl(root);
777
782
  const hasOriginF = origin !== null;
778
783
  // gh#234/gh#228: judge the local default branch, not whatever HEAD the main checkout happens to be on, and
@@ -960,8 +965,12 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
960
965
  roadmapNote = ` roadmap: ${r.count} item(s) marked done.`;
961
966
  }
962
967
  }
968
+ // the reflection rows this flow was linked to close with it — the fix and the ledger agree the moment it ships
969
+ const closedRefl = closeLinkedReflections(root, state!, state!.publish?.pr ? ` (PR #${state!.publish.pr})` : "");
970
+ const deferred = (state!.reflections ?? []).filter((r) => r.deferred);
971
+ const reflNote = closedRefl.length || deferred.length ? ` reflections: ${closedRefl.length ? `closed ${closedRefl.map((n) => `r${n}`).join(", ")} as fixed by this flow` : ""}${closedRefl.length && deferred.length ? "; " : ""}${deferred.length ? `left open ${deferred.map((r) => `r${r.id} (${r.deferred})`).join(", ")}` : ""}.` : "";
963
972
  // finish is the moment between flows: name the fix / tidy suggestion when a rule fires, nothing otherwise
964
973
  const nudge = reflectionNudges(readReflectionsText(root), now().slice(0, 10), { between: true });
965
974
  const nudgeNote = [nudge.fix, nudge.tidy].filter(Boolean).map((n) => ` ${n} — offer it to the operator.`).join("");
966
- return { text: `feature ${state!.slug} done — ${closeNote}${remoteNote}; .dev-flow/${state!.slug}/ removed.${devDownNote}${roadmapNote}${forgeSkipNote}${reflectSkipNote}${quietNote}${releaseChecksNote}${autoNote}${syncNote}${nudgeNote} Re-read flow status before reporting open flows — a sibling feature may have finished while this session ran.` };
975
+ return { text: `feature ${state!.slug} done — ${closeNote}${remoteNote}; .dev-flow/${state!.slug}/ removed.${devDownNote}${roadmapNote}${reflNote}${forgeSkipNote}${reflectSkipNote}${quietNote}${releaseChecksNote}${autoNote}${syncNote}${nudgeNote} Re-read flow status before reporting open flows — a sibling feature may have finished while this session ran.` };
967
976
  }