pi-dev-flow 0.96.1 → 0.98.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 +32 -0
- package/docs/concurrency.md +5 -3
- package/docs/gates.md +33 -18
- package/docs/guardrails.md +12 -4
- package/docs/playbook.md +8 -3
- package/docs/reflections.md +6 -2
- package/extensions/dev-flow.ts +50 -30
- package/package.json +1 -1
- package/skills/dev-flow/SKILL.md +3 -3
- package/skills/dev-flow/references/finish.md +21 -15
- package/skills/dev-flow/references/pre-release.md +8 -7
- package/skills/dev-flow/references/release.md +2 -2
- package/skills/dev-flow/references/start.md +2 -0
- package/src/core.ts +82 -6
- package/src/projectmd.ts +24 -2
- package/src/runtime/base.ts +1 -1
- package/src/runtime/checks.ts +12 -2
- package/src/runtime/gates.ts +47 -5
- package/src/runtime/grants.ts +31 -3
- package/src/runtime/reflect.ts +49 -1
- package/src/runtime/ship.ts +72 -44
package/src/runtime/ship.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
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 { foldCallError, 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, releaseCallQuestion, releaseCallProof, cmpRelease, versionCore, resolvedDevEnv, reviewOwed, localDefaultAhead, failTail, operatorDirt } from "../core.ts";
|
|
4
|
+
import { foldCallError, nonBehaviourPath, 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, releaseCallQuestion, releaseCallProof, cmpRelease, versionCore, 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
7
|
import { manifestAt, recordReleaseCall, 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
|
+
import { applyReflectFindings, closeLinkedReflections } from "./reflect.ts";
|
|
11
11
|
import { gatePublishes, prBodyOwed, publishRelease } from "./publish.ts";
|
|
12
12
|
|
|
13
13
|
/** The release call, asked with Verified? only for a flow approved before Approve? carried it — null when the
|
|
14
14
|
* playbook decides, the flow has no manifest to version, or the call is on record (the usual case). */
|
|
15
15
|
function versionQuestion(root: string, state: FlowState, cfg: Config): { ask: string; flags: string } | null {
|
|
16
|
+
// gh#299: a call the agent proposed at Approve? is shown here, where the operator answers anyway
|
|
17
|
+
if (state.versionChoice && state.versionProposed)
|
|
18
|
+
return { ask: `the release call is ${describeVersionChoice(state.versionChoice, state.versionFrom)} — the agent's proposal at Approve?, not your word: keep it, or say patch, minor or major (or merge unreleased)`, flags: "--version=patch|minor|major or --no-version to change it" };
|
|
16
19
|
if (!cfg.versioning.file || playbookVersionChoice(cfg) || state.versionChoice) return null;
|
|
17
20
|
return releaseCallQuestion(manifestAt(gateCwd(root, state), cfg.versioning.file), cfg.versioning.file, state.docs);
|
|
18
21
|
}
|
|
@@ -194,6 +197,8 @@ export async function gateVerify(o: GateCtx): Promise<RunResult> {
|
|
|
194
197
|
const was = state!.versionChoice;
|
|
195
198
|
const choice = verArg.choice ?? state!.versionChoice ?? playbookVersionChoice(cfg);
|
|
196
199
|
if (choice) recordReleaseCall(root, state!, cfg, choice);
|
|
200
|
+
// the operator answered a Verified? that showed the proposed call (or changed it): it is their word now (gh#299)
|
|
201
|
+
if (askPending || flag("confirmed")) delete state!.versionProposed;
|
|
197
202
|
const choiceNote = choice ? `\nrelease call: ${describeVersionChoice(choice, state!.versionFrom)}${was && was !== choice ? ` (changed from ${describeVersionChoice(was)})` : ""}` : "";
|
|
198
203
|
const before = state!.stage;
|
|
199
204
|
state!.stage = "pre-release";
|
|
@@ -374,22 +379,17 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
374
379
|
// truly behind, not merely different: a session whose loaded build is NEWER than the checkout's manifest
|
|
375
380
|
// has every proof the checkout would run, and asking about it would be noise.
|
|
376
381
|
const stale = !!behind && !!selfBuild.version && cmpVersions(behind, selfBuild.version) < 0;
|
|
377
|
-
let staleAsk = "";
|
|
378
382
|
let staleNote = "";
|
|
379
383
|
if (stale) {
|
|
380
384
|
const clPath = path.join(selfBuild.dir, "CHANGELOG.md");
|
|
381
385
|
const missing = existsSync(clPath) && selfBuild.version ? changelogVersionsBetween(readFileSync(clPath, "utf8"), behind, selfBuild.version) : [];
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
(missing.length
|
|
385
|
-
? `Shipped since ${behind}: ${missing.slice(0, 8).join(", ")}${missing.length > 8 ? ` …(${missing.length} total)` : ""} — see ${clPath}. `
|
|
386
|
-
: `What shipped between them is not readable from the checkout's CHANGELOG.md — read it before deciding. `) +
|
|
387
|
-
`Update (/reload, then re-run flow release on the current build) or proceed with the old release?`;
|
|
388
|
-
staleNote = `released under dev-flow ${behind} (${selfBuild.label} ${selfBuild.version ?? "?"}) — the operator was asked update-or-proceed and chose to proceed; proofs newer than ${behind} did not run`;
|
|
386
|
+
// advisory, never a question: the operator chose the build when they loaded the session, and /reload is theirs
|
|
387
|
+
staleNote = `released under dev-flow ${behind} (${selfBuild.label} ships ${selfBuild.version ?? "?"}) — proofs newer than ${behind} did not run${missing.length ? ` (shipped since: ${missing.slice(0, 8).join(", ")}${missing.length > 8 ? ` …(${missing.length} total)` : ""})` : ""}; /reload picks up the newer build for the next flow`;
|
|
389
388
|
}
|
|
390
389
|
// #162: Verified? was answered over one tree; commits after it ship under that word unless someone says
|
|
391
390
|
// so. A warning, never a refusal — doc-only moves after verify are normal; the operator decides.
|
|
392
391
|
let postVerify = "";
|
|
392
|
+
let quietAfterVerify = "";
|
|
393
393
|
let unverifiedChange = false;
|
|
394
394
|
if (state!.verifiedHead) {
|
|
395
395
|
// gh#180: upstream work merged in after the verdict was approved on its own branch — only the branch's
|
|
@@ -398,19 +398,38 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
398
398
|
const upstream = (await sh(`git rev-parse --verify -q ${sq(`refs/remotes/origin/${d}`)}`, wtCwd)).ok ? `origin/${d}` : (await sh(`git rev-parse --verify -q ${sq(`refs/heads/${d}`)}`, wtCwd)).ok ? d : "";
|
|
399
399
|
const range = `${sq(state!.verifiedHead)}..HEAD${upstream ? ` --not ${sq(upstream)}` : ""}`;
|
|
400
400
|
// one record per commit: "<sha> <subject>" then the files it touched (\x1e starts a record)
|
|
401
|
-
const since = await sh(`git log --no-decorate --name-only --format=%x1e%h%x20%s ${upstream ? "--no-merges " : ""}${range}`, wtCwd);
|
|
402
|
-
const
|
|
403
|
-
? since.out.split("\x1e").map((rec) => rec.split("\n").map((l) => l.trim()).filter(Boolean)).filter((r) => r.length).map(([
|
|
401
|
+
const since = await sh(`git log --no-decorate --name-only --format=%x1e%H%x20%h%x20%s ${upstream ? "--no-merges " : ""}${range}`, wtCwd);
|
|
402
|
+
const listed = since.ok
|
|
403
|
+
? since.out.split("\x1e").map((rec) => rec.split("\n").map((l) => l.trim()).filter(Boolean)).filter((r) => r.length).map(([head, ...files]) => ({ full: head.split(" ")[0], line: head.split(" ").slice(1).join(" "), files }))
|
|
404
404
|
: [];
|
|
405
405
|
const all = upstream ? await sh(`git rev-list --count ${sq(state!.verifiedHead)}..HEAD`, wtCwd) : null;
|
|
406
|
-
const mergedIn = all?.ok ? Math.max(0, Number.parseInt(all.out.trim(), 10) -
|
|
406
|
+
const mergedIn = all?.ok ? Math.max(0, Number.parseInt(all.out.trim(), 10) - listed.length) : 0;
|
|
407
407
|
// gh#187: the release-prep commit (the bump, the changelog entry, whatever else the bump rewrites — an
|
|
408
408
|
// image tag in a compose file) lands after Verified? by design and no container verdict could cover
|
|
409
409
|
// it. It is the commit that touches the version file, or one that touches nothing but prep files.
|
|
410
410
|
const prepSet = prepFiles(cfg);
|
|
411
|
+
// gh#298: a rebase replays the verified commits under new ids — same content, so not news. When the verified
|
|
412
|
+
// head is no longer an ancestor, a commit whose patch (prep files left out, where a rebase conflict usually
|
|
413
|
+
// lands) matches one the operator verified rides under the word; changed content still asks.
|
|
414
|
+
const rewritten = upstream && !(await sh(`git merge-base --is-ancestor ${sq(state!.verifiedHead)} HEAD`, wtCwd)).ok;
|
|
415
|
+
const replayed = new Set<string>();
|
|
416
|
+
if (rewritten) {
|
|
417
|
+
const notPrep = [...prepSet].map((f) => sq(`:(exclude)${f}`)).join(" ");
|
|
418
|
+
const pids = async (r: string) => {
|
|
419
|
+
const out = await sh(`git log -p --no-merges --format='commit %H' ${r} -- . ${notPrep} | git patch-id --stable`, wtCwd);
|
|
420
|
+
return out.ok ? out.out.split("\n").map((l) => l.trim().split(/\s+/)).filter((x) => x.length === 2) : [];
|
|
421
|
+
};
|
|
422
|
+
const seen = new Set((await pids(`${sq(state!.verifiedHead)} --not ${sq(upstream)}`)).map(([pid]) => pid));
|
|
423
|
+
for (const [pid, sha] of await pids(range)) if (seen.has(pid)) replayed.add(sha);
|
|
424
|
+
}
|
|
425
|
+
const commits = listed.filter((c) => !replayed.has(c.full));
|
|
426
|
+
const replayNote = replayed.size ? `${replayed.size} commit(s) a rebase replayed with the patch the operator verified ride under it` : "";
|
|
411
427
|
const isPrep = (c: { files: string[] }) => (!!cfg.versioning.file && c.files.includes(cfg.versioning.file)) || (c.files.length > 0 && c.files.every((f) => prepSet.has(f)));
|
|
412
428
|
const prep = commits.filter(isPrep);
|
|
413
|
-
|
|
429
|
+
// docs and tests ship no behaviour the operator's look could have caught: they ride under the verdict, named
|
|
430
|
+
const quiet = commits.filter((c) => !isPrep(c) && c.files.length > 0 && c.files.every(nonBehaviourPath));
|
|
431
|
+
const changed = commits.filter((c) => !isPrep(c) && !quiet.includes(c));
|
|
432
|
+
quietAfterVerify = [quiet.length ? `${quiet.length} docs/test-only commit(s) after Verified? (${quiet.map((c) => c.line.split(" ")[0]).join(", ")}) ride under it` : "", replayNote].filter(Boolean).join("; ");
|
|
414
433
|
// changed code shipping under an earlier word is friction the closing reflection should look at
|
|
415
434
|
unverifiedChange = changed.length > 0;
|
|
416
435
|
if (changed.length)
|
|
@@ -430,9 +449,7 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
430
449
|
? "the playbook sets yolo = until-release: a yolo given earlier never answers Release? — ask it"
|
|
431
450
|
: postVerify
|
|
432
451
|
? "a yolo given earlier does not cover commits that landed after Verified? — ask Release? with them named"
|
|
433
|
-
:
|
|
434
|
-
? "a yolo given earlier does not choose to release under an older dev-flow build — ask Release? with the update-or-proceed question"
|
|
435
|
-
: "";
|
|
452
|
+
: "";
|
|
436
453
|
// gh#206: a yolo held back only by the playbook's until-release knob carries nothing new for the operator
|
|
437
454
|
// to weigh — it just means "Release? is asked like on any flow". Their chat answer (a plain --confirmed)
|
|
438
455
|
// stands on the first call, as it does on a flow without yolo; asking first made them repeat a word already
|
|
@@ -444,8 +461,8 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
444
461
|
// this session after that point lets the flag stand, and only a true replay is asked first.
|
|
445
462
|
const vm = state!.verifiedAtMessage;
|
|
446
463
|
const spokeSinceVerify = !!vm && vm.key === sess.key && typeof sess.operatorMessages === "number" && sess.operatorMessages > vm.users;
|
|
447
|
-
const untilReleaseOnly = cfg.release.yolo === "until-release" && !postVerify
|
|
448
|
-
const mustAskFirst =
|
|
464
|
+
const untilReleaseOnly = cfg.release.yolo === "until-release" && !postVerify;
|
|
465
|
+
const mustAskFirst = !!holdWhy && !(untilReleaseOnly && (!flag("yolo") || spokeSinceVerify));
|
|
449
466
|
const confirmed = flag("confirmed") && !(mustAskFirst && !ui.hasUI && state!.pendingAsk !== "Release?");
|
|
450
467
|
const yoloHeld = confirmed ? "" : holdWhy;
|
|
451
468
|
// gh#198: release.ask = on-change — Release? answers itself when it would only re-confirm Verified?: the call
|
|
@@ -461,23 +478,23 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
461
478
|
? `the release call changes (${state!.versionChoice ?? "none"} → ${relArg.choice}) — changing it is the operator's word`
|
|
462
479
|
: postVerify
|
|
463
480
|
? "commits beyond release prep landed after Verified?"
|
|
464
|
-
:
|
|
465
|
-
? "the session build is behind the checkout"
|
|
466
|
-
: cfg.release.yolo === "until-release"
|
|
467
|
-
? "the playbook sets yolo = until-release"
|
|
468
|
-
: choice === "next" && newest && manifestVer && majorBump(newest, manifestVer)
|
|
481
|
+
: choice === "next" && newest && manifestVer && majorBump(newest, manifestVer)
|
|
469
482
|
? `${newest} → ${manifestVer} is a major bump — the playbook's versioned call does not choose that`
|
|
470
483
|
: "";
|
|
471
484
|
const auto = onChange && !askWhy;
|
|
472
|
-
let audit = confirmed ? " (confirmed by operator instruction)" : auto ? ` (auto-answered: release.ask = on-change — ${describeVersionChoice(choice ?? "next", state!.versionFrom)} is the call on record, and only release prep landed since Verified?)` : state!.yolo ? " (yolo: pre-confirmed)" : "";
|
|
485
|
+
let audit = confirmed ? " (confirmed by operator instruction)" : auto ? ` (auto-answered: release.ask = on-change — ${describeVersionChoice(choice ?? "next", state!.versionFrom)} is the call on record, and only release prep${quietAfterVerify ? ", docs or tests" : ""} landed since Verified?)` : state!.yolo ? " (yolo: pre-confirmed)" : "";
|
|
473
486
|
const askPending = !auto && !confirmed && (!state!.yolo || !!yoloHeld);
|
|
474
487
|
if (askPending) {
|
|
475
488
|
markPendingAsk(root, state!, "Release?");
|
|
476
489
|
if (!ui.hasUI) {
|
|
477
490
|
const callAsk = cfg.versioning.file && !choice ? " — also ask the release call: a patch, minor or major release, or merge unreleased (no bump, no tag)?" : "";
|
|
478
|
-
|
|
491
|
+
// gh#288: changed code after Verified? is one question, not two — a re-verify after a Release? answer spent it
|
|
492
|
+
const oneQuestion = unverifiedChange && cfg.release.ask !== "always" && !callAsk
|
|
493
|
+
? "ask ONE question, not both: if these commits change behaviour, run flow verify now and ask Verified? over the new deploy — Release? then answers itself (release.ask = on-change); only if they do not, ask 'Release?' with them named and "
|
|
494
|
+
: "";
|
|
495
|
+
return { text: needsOperator(`ready to publish${yoloHeld ? ` (${yoloHeld})` : ""}${askWhy ? ` (asked: ${askWhy})` : ""}${postVerify ? ` — ${postVerify}` : ""}${callAsk}`, "Release?", `${oneQuestion}re-run with --confirmed once the operator answered 'Release?' in chat${callAsk ? " (add --version=patch|minor|major or --no-version for their release call)" : ""}`), isError: true };
|
|
479
496
|
}
|
|
480
|
-
const ok = await ui.confirm("Enter release", `Release ${state!.slug}${manifestVer ? ` v${manifestVer}` : ""}${noVersion ? " (unversioned — merge + changelog entry only: no bump, no tag for this flow)" : ""}? Publishing starts: PR, merge${noVersion ? "" : ", tag"} — release-done afterwards needs no further answer.${
|
|
497
|
+
const ok = await ui.confirm("Enter release", `Release ${state!.slug}${manifestVer ? ` v${manifestVer}` : ""}${noVersion ? " (unversioned — merge + changelog entry only: no bump, no tag for this flow)" : ""}? Publishing starts: PR, merge${noVersion ? "" : ", tag"} — release-done afterwards needs no further answer.${staleNote ? `\n\n${staleNote}` : ""}${postVerify ? `\n\n${postVerify}` : ""}${yoloHeld ? `\n\n(${yoloHeld})` : ""}`);
|
|
481
498
|
if (!ok) {
|
|
482
499
|
delete state!.pendingAsk;
|
|
483
500
|
writeState(root, state!);
|
|
@@ -511,7 +528,7 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
511
528
|
if (selfPublish) state!.publish = {};
|
|
512
529
|
else delete state!.publish;
|
|
513
530
|
writeState(root, state!);
|
|
514
|
-
const approved = `release approved${audit}${state!.noVersion ? " — unversioned: no bump or tag; your changelog entry rides under Unreleased until the next versioned release folds it" : ""} — entering release stage.${manifestVer ? ` Version ${manifestVer}.` : ""}${checksNote}${foldNote}${staleNote ? ` ${staleNote}.` : ""}${postVerify ? ` Warning: ${postVerify}.` : ""}\n${describeBranchState(branchProof, cfg.defaultBranch)}`;
|
|
531
|
+
const approved = `release approved${audit}${state!.noVersion ? " — unversioned: no bump or tag; your changelog entry rides under Unreleased until the next versioned release folds it" : ""} — entering release stage.${manifestVer ? ` Version ${manifestVer}.` : ""}${checksNote}${foldNote}${staleNote ? ` ${staleNote}.` : ""}${postVerify ? ` Warning: ${postVerify}.` : ""}${quietAfterVerify ? ` ${quietAfterVerify}.` : ""}\n${describeBranchState(branchProof, cfg.defaultBranch)}`;
|
|
515
532
|
if (selfPublish) return publishAndRecord(o, state!, approved);
|
|
516
533
|
return { text: `${approved}\n${AGENT_MARK}next: ${nextHint(state!, cfg)}` };
|
|
517
534
|
}
|
|
@@ -717,7 +734,7 @@ export async function gateReleaseDone(o: GateCtx): Promise<RunResult> {
|
|
|
717
734
|
const tailNote = [
|
|
718
735
|
// a session that shipped from behind: the code it runs is not the code the checkout just released
|
|
719
736
|
state!.staleBuild
|
|
720
|
-
? `stale build
|
|
737
|
+
? `stale build noted at the release gate: this session ran dev-flow ${state!.staleBuild} — proofs newer than it did not run.`
|
|
721
738
|
: skew.behind
|
|
722
739
|
// #117: the pair (session vs what the disk ships) makes the warning actionable where it prints;
|
|
723
740
|
// a second registered copy is what made the skew confusing on the report — name it too
|
|
@@ -745,15 +762,6 @@ export async function gateFinish(o: GateCtx): Promise<RunResult> {
|
|
|
745
762
|
// gh#205: release-stage items (a post-merge build, a deploy check from the default branch) are work done after
|
|
746
763
|
// the merge. A separate release-done names them while the worktree still stands; folded into finish, one
|
|
747
764
|
// call recorded the release and removed everything, so an unversioned flow never saw them. Stop once here.
|
|
748
|
-
const cur = readState(o.root, state.slug) ?? state;
|
|
749
|
-
if (checklistPending(o.cfg, cur, "release")) {
|
|
750
|
-
markPendingAsk(o.root, cur, "Finish?");
|
|
751
|
-
const items = applicableItems(o.cfg, cur, "release").map((i) => `"${i.text}"`).join(" | ");
|
|
752
|
-
return {
|
|
753
|
-
text: `${recorded}\n\n${needsOperator(`release recorded — nothing was removed yet: the release-stage checklist (## release in .dev-flow/project.md) is still open: ${items}`, "Finish?", `do each release-stage item now (they run after the merge, from ${o.cfg.defaultBranch} — not the worktree), tell the operator what each showed, then ask Finish? and run flow finish --confirmed when they answer`)}`,
|
|
754
|
-
isError: true,
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
765
|
const fin = await gateFinishCore(o);
|
|
758
766
|
return { ...fin, text: `${recorded}\n\n${fin.text}` };
|
|
759
767
|
}
|
|
@@ -853,6 +861,17 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
|
|
|
853
861
|
// yolo works uniformly at every gate: at Finish? nothing later remains to pre-confirm, the flag just answers this one
|
|
854
862
|
const yoloWord = takeYoloWord(state!);
|
|
855
863
|
if (yoloWord) return { text: yoloWord, isError: true };
|
|
864
|
+
// gh#205: release-stage items are work done after the merge, from the main checkout — stop once so it is done
|
|
865
|
+
// while the worktree still stands. It is work, not a question: the next finish goes on (finish = always asks).
|
|
866
|
+
const relItems = applicableItems(cfg, state!, "release");
|
|
867
|
+
if (checklistPending(cfg, state!, "release") && cfg.release.finish !== "always") {
|
|
868
|
+
state!.confirmations = { ...state!.confirmations, release: { hash: checklistHash(relItems), at: now() } };
|
|
869
|
+
writeState(root, state!);
|
|
870
|
+
return {
|
|
871
|
+
text: `release-stage work — the release is recorded and nothing was removed yet: the release-stage checklist (## release in .dev-flow/project.md) is work to do now, from ${cfg.defaultBranch} (the main checkout, not the worktree): ${relItems.map((i) => `"${i.text}"`).join(" | ")}\n${AGENT_MARK}next: do each item, then run flow finish again — no question to ask; say in your report what each showed`,
|
|
872
|
+
isError: true,
|
|
873
|
+
};
|
|
874
|
+
}
|
|
856
875
|
// The closing reflection runs here, before anything is removed: the worker reads this session's
|
|
857
876
|
// transcripts and .dev-flow/<slug>/tmp, and finish is about to drop that folder and the binding — a
|
|
858
877
|
// reflection asked for after finish has nothing bound to run against. Only the operator's explicit
|
|
@@ -872,6 +891,7 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
|
|
|
872
891
|
writeState(root, state!);
|
|
873
892
|
}
|
|
874
893
|
const quietNote = quiet && fold ? " closing reflection skipped: a fold flow (it fixes reflections, it does not review for new ones)." : quiet ? " closing reflection skipped: no refusals, guard blocks or unverified changes this flow (playbook reflect = always runs it anyway)." : "";
|
|
894
|
+
let appliedLines: string[] = [];
|
|
875
895
|
if (!state!.reflectedAt && !skipReflect) {
|
|
876
896
|
const skipHint = "or — only on the operator's explicit word — flow finish --no-reflect --confirmed";
|
|
877
897
|
if (!o.hooks.reflect) return { text: `finish: no reflection recorded for ${state!.slug} and no reflect worker available here — run flow_stage(op: "reflect") first, ${skipHint}`, isError: true };
|
|
@@ -887,12 +907,20 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
|
|
|
887
907
|
const cur = readState(root, state!.slug) ?? state!; // the worker stamped reflectedAt on disk
|
|
888
908
|
if (!r.recorded)
|
|
889
909
|
return { text: `finish: the closing reflection did not report — nothing was removed.\n\n${r.text}\n\nNext: re-run flow finish to retry, or review inline (bare flow reflect prints the protocol) and then flow_stage(op: "reflect"), ${skipHint}.`, isError: true };
|
|
890
|
-
|
|
910
|
+
// the reviewer's own fold/drop recommendation is applied, and reported with how to undo it: the operator
|
|
911
|
+
// answered "fold as suggested" to nearly every list. finish = always, or rows that did not parse, still ask.
|
|
912
|
+
if (r.report && cfg.release.finish !== "always") {
|
|
913
|
+
appliedLines = await applyReflectFindings(root, sess, r.report);
|
|
914
|
+
Object.assign(state!, readState(root, state!.slug) ?? cur);
|
|
915
|
+
state!.reflectApplied = true;
|
|
916
|
+
writeState(root, state!);
|
|
917
|
+
} else if (!r.findings) {
|
|
891
918
|
markPendingAsk(root, cur, "Finish?");
|
|
892
919
|
return { text: needsOperator(`the closing reflection found nothing new to fold — nothing was removed yet; on your word the worktree, branch and .dev-flow/${state!.slug}/ go.\n\n${r.text}`, "Finish?", "ask the operator Finish? and run flow finish --confirmed when they answer"), isError: true };
|
|
920
|
+
} else {
|
|
921
|
+
markPendingAsk(root, cur, "Fold or drop?");
|
|
922
|
+
return { text: needsOperator(`the closing reflection has findings — nothing was removed yet; your fold/drop answer also finishes the feature.\n\n${r.text}`, "Fold or drop?", `the fold/drop answer is the Finish? answer: apply it, then run flow finish --confirmed without asking again — the worktree, branch and .dev-flow/${state!.slug}/ go on that run`), isError: true };
|
|
893
923
|
}
|
|
894
|
-
markPendingAsk(root, cur, "Fold or drop?");
|
|
895
|
-
return { text: needsOperator(`the closing reflection has findings — nothing was removed yet; your fold/drop answer also finishes the feature.\n\n${r.text}`, "Fold or drop?", `the fold/drop answer is the Finish? answer: apply it, then run flow finish --confirmed without asking again — the worktree, branch and .dev-flow/${state!.slug}/ go on that run`), isError: true };
|
|
896
924
|
}
|
|
897
925
|
const reflectSkipNote = skipReflect && !state!.reflectedAt ? ` Reflection skipped on the operator's word — nothing re-checked this session or the open reflections.` : "";
|
|
898
926
|
// Finish? answers itself on a clean flow (release.finish = on-change, the default): the release is recorded,
|
|
@@ -900,7 +928,7 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
|
|
|
900
928
|
// the question had no decision left in it. Anything open (a reflection that ran, release-stage items, a
|
|
901
929
|
// forge release that failed, a skipped reflection) still asks.
|
|
902
930
|
const openReleaseItems = checklistPending(cfg, state!, "release");
|
|
903
|
-
const autoFinish = cfg.release.finish !== "always" && !flag("confirmed") && !state!.yolo && !!state!.reflectQuiet && !openReleaseItems && !forgeSkipNote && !skipReflect;
|
|
931
|
+
const autoFinish = cfg.release.finish !== "always" && !flag("confirmed") && !state!.yolo && (!!state!.reflectQuiet || !!state!.reflectApplied) && !openReleaseItems && !forgeSkipNote && !skipReflect;
|
|
904
932
|
const autoNote = autoFinish ? " Finish? answered itself (finish = on-change): the release is recorded, nothing was skipped and nothing is open." : "";
|
|
905
933
|
const askPending = !flag("confirmed") && !state!.yolo && !autoFinish;
|
|
906
934
|
if (askPending) {
|
|
@@ -965,5 +993,5 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
|
|
|
965
993
|
// finish is the moment between flows: name the fix / tidy suggestion when a rule fires, nothing otherwise
|
|
966
994
|
const nudge = reflectionNudges(readReflectionsText(root), now().slice(0, 10), { between: true });
|
|
967
995
|
const nudgeNote = [nudge.fix, nudge.tidy].filter(Boolean).map((n) => ` ${n} — offer it to the operator.`).join("");
|
|
968
|
-
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.` };
|
|
996
|
+
return { text: `feature ${state!.slug} done — ${closeNote}${remoteNote}; .dev-flow/${state!.slug}/ removed.${devDownNote}${roadmapNote}${reflNote}${forgeSkipNote}${reflectSkipNote}${quietNote}${releaseChecksNote}${autoNote}${syncNote}${nudgeNote}${appliedLines.length ? `\n${appliedLines.join("\n")}\n` : ""} Re-read flow status before reporting open flows — a sibling feature may have finished while this session ran.` };
|
|
969
997
|
}
|