pi-dev-flow 0.89.0 → 0.90.1
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 +22 -0
- package/README.md +89 -225
- package/docs/concurrency.md +54 -48
- package/docs/development.md +48 -54
- package/docs/gates.md +187 -25
- package/docs/guardrails.md +112 -30
- package/docs/headless.md +32 -44
- package/docs/playbook.md +215 -275
- package/docs/reflections.md +73 -0
- package/extensions/dev-flow.ts +3 -2
- package/package.json +1 -1
- package/skills/dev-flow/references/implement.md +3 -1
- package/skills/dev-flow/references/reflect.md +4 -1
- package/skills/dev-flow/references/start.md +4 -1
- package/src/core.ts +85 -36
- package/src/projectmd.ts +18 -5
- package/src/runtime/gates.ts +10 -4
- package/src/runtime/grants.ts +13 -3
- package/src/runtime/reflect.ts +29 -17
- package/src/runtime/ship.ts +23 -6
package/src/runtime/reflect.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** dev-flow runtime — Reflections and the upstream issue fold. Moved out of extensions/dev-flow.ts as is (exports added). */
|
|
2
2
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { appendReflection, doneItemCount, githubSlug, pluginVersion, guessReflectSections, reflectItems, reflectMove, reflectDone, reflectLegacyPluginCount, reflectionNudges, pluginIssueRecipe, reflectionLine, reflectionsTidy, openChecklistItems, type ReflectTarget, type ReflectItem, type ReflectSection } from "../core.ts";
|
|
4
|
+
import { appendReflection, doneItemCount, githubSlug, pluginVersion, guessReflectSections, reflectItems, reflectMove, reflectDone, reflectRow, reflectLegacyPluginCount, reflectionNudges, pluginIssueRecipe, reflectionLine, reflectionsTidy, openChecklistItems, type ReflectTarget, type ReflectItem, type ReflectSection } from "../core.ts";
|
|
5
5
|
import { dedupeReflections, linkedTag, parseGhIssues, similarNote, type FoldResult, type GhIssue } from "../fold.ts";
|
|
6
6
|
import { dfDir, now, originUrl, readReflections, readReflectionsText, sh } from "./base.ts";
|
|
7
7
|
import { type RunResult, type Session } from "./checks.ts";
|
|
@@ -70,13 +70,13 @@ export async function foldView(root: string, items: ReflectItem[]): Promise<Fold
|
|
|
70
70
|
/** The fold block shared by flow doctor and flow reflect list: header, one row per unmatched
|
|
71
71
|
* issue with its route, then the unmerged near-miss hints. Local rows carry their ⟷ gh#N tag
|
|
72
72
|
* at the call site — the fold lists upstream items, it never re-numbers the local queue. */
|
|
73
|
-
export function foldRows(fold: FoldView, selfRepo: boolean): string[] {
|
|
73
|
+
export function foldRows(fold: FoldView, selfRepo: boolean, items: readonly ReflectItem[] = []): string[] {
|
|
74
74
|
if (fold.state === "absent") return [];
|
|
75
75
|
if (fold.state === "skipped") return [`upstream issues: skipped (${fold.why})`];
|
|
76
76
|
if (!fold.open) return [];
|
|
77
77
|
const rows = [`upstream on ${fold.slug} — ${fold.open} open issue(s) on GitHub (canonical there — close on GitHub, never here; this is a fold, not a copy):`];
|
|
78
78
|
for (const i of fold.result.upstreamOnly) rows.push(` gh#${i.number} ${i.title} → ${selfRepo ? "fix in a flow here (patch flow if small)" : "fix in a flow here, or close won't-fix on GitHub"}`);
|
|
79
|
-
for (const s of fold.result.similar) rows.push(` ${similarNote(s, s.item + 1)}`);
|
|
79
|
+
for (const s of fold.result.similar) rows.push(` ${similarNote(s, items[s.item]?.n ?? s.item + 1)}`);
|
|
80
80
|
return rows;
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -88,16 +88,16 @@ export async function reflectList(root: string): Promise<RunResult> {
|
|
|
88
88
|
const fold = await foldView(root, items);
|
|
89
89
|
const local = items.length
|
|
90
90
|
? [
|
|
91
|
-
`reflections — ${items.length} open:`,
|
|
91
|
+
`reflections — ${items.length} open (numbers are row numbers: checking one off leaves the others as they are; tidy and move renumber):`,
|
|
92
92
|
...items.map((it, i) => {
|
|
93
93
|
const link = fold.state === "ok" ? fold.result.linked.find((l) => l.item === i) : undefined;
|
|
94
|
-
return ` ${
|
|
94
|
+
return ` ${it.n}. [${it.section}] ${it.line.replace(/^- \[ \] /, "")}${link ? linkedTag(link.issue) : ""}`;
|
|
95
95
|
}),
|
|
96
96
|
]
|
|
97
97
|
: fold.state === "absent" || fold.state === "skipped"
|
|
98
98
|
? ["reflections: nothing open"]
|
|
99
99
|
: ["reflections: nothing open locally"];
|
|
100
|
-
return { text: [...local, ...legacyPluginRows(readReflectionsText(root), isSelfRepo(root)), ...foldRows(fold, isSelfRepo(root))].join("\n") };
|
|
100
|
+
return { text: [...local, ...legacyPluginRows(readReflectionsText(root), isSelfRepo(root)), ...foldRows(fold, isSelfRepo(root), items)].join("\n") };
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
/** Open rows still under the legacy `## plugin` heading: they belong on GitHub, not in a project's queue. */
|
|
@@ -121,30 +121,42 @@ export function reflectMoveNote(root: string, args: string[], forced: ReflectTar
|
|
|
121
121
|
const n = Number(args[0]);
|
|
122
122
|
const text = readReflectionsText(root);
|
|
123
123
|
const items = reflectItems(text);
|
|
124
|
-
|
|
125
|
-
if (
|
|
124
|
+
const it = items.find((x) => x.n === n);
|
|
125
|
+
if (!it) return { text: `move: ${noOpenRow(text, n, items)}`, isError: true };
|
|
126
|
+
if (it.section === section) return { text: `reflect: item ${n} is already under ## ${section}` };
|
|
126
127
|
// the same note open under both headings (an old --both filing): the move merges it, it does not copy it
|
|
127
|
-
const twin = items.some((
|
|
128
|
+
const twin = items.some((x) => x !== it && x.section === section && x.body === it.body);
|
|
128
129
|
const next = reflectMove(text, n, section);
|
|
129
|
-
if (next === null) return { text: `move:
|
|
130
|
+
if (next === null) return { text: `move: ${noOpenRow(text, n, items)}`, isError: true };
|
|
130
131
|
writeFileSync(path.join(dfDir(root), "reflections.md"), next);
|
|
131
|
-
const note =
|
|
132
|
-
return { text: twin ? `reflect: item ${n} was already recorded under ## ${section} — the duplicate is gone (${note})` : `reflect: item ${n} re-filed under ## ${section} — ${note}` };
|
|
132
|
+
const note = it.line.replace(/^- \[ \] /, "");
|
|
133
|
+
return { text: `${twin ? `reflect: item ${n} was already recorded under ## ${section} — the duplicate is gone (${note})` : `reflect: item ${n} re-filed under ## ${section} — ${note}`}\n${RENUMBERED}` };
|
|
133
134
|
}
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
const RENUMBERED = "the row numbers changed — run flow reflect list before the next done or move";
|
|
137
|
+
|
|
138
|
+
/** Why `<n>` names no open row (gh#197): a row already checked off says which note it holds, so a batch that
|
|
139
|
+
* drifted shows the mismatch instead of closing the wrong line. */
|
|
140
|
+
function noOpenRow(text: string, n: number, items: readonly ReflectItem[]): string {
|
|
141
|
+
const row = Number.isInteger(n) && n > 0 ? reflectRow(text, n) : null;
|
|
142
|
+
if (row && !row.open) return `item ${n} is already checked off (${row.line.replace(/^-\s*\[[xX]\]\s*/, "")}) — flow reflect list shows the open ones`;
|
|
143
|
+
return items.length ? `no open item ${n} — open: ${items.map((i) => i.n).join(", ")} (flow reflect list numbers them)` : "nothing open in reflections.md";
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** `flow reflect done <n> [what fixed it]` — check a folded/fixed item off, so doctor stops re-reporting it (#165).
|
|
147
|
+
* `<n>` is the stable row number (gh#197): closing one leaves every other number where `list` printed it. */
|
|
136
148
|
export function reflectDoneNote(root: string, sess: Session, args: string[]): RunResult {
|
|
137
149
|
const text = readReflectionsText(root);
|
|
138
150
|
const items = reflectItems(text);
|
|
139
151
|
const n = Number(args[0]);
|
|
140
|
-
|
|
141
|
-
|
|
152
|
+
const it = items.find((x) => x.n === n);
|
|
153
|
+
if (!it) return { text: `done: ${noOpenRow(text, n, items)}`, isError: true };
|
|
142
154
|
const stamp = [now().slice(0, 10), sess.slug].filter(Boolean).join(" ");
|
|
143
155
|
const what = args.slice(1).join(" ").trim();
|
|
144
156
|
const next = reflectDone(text, n, what ? `${stamp} — ${what}` : stamp)!;
|
|
145
157
|
writeFileSync(path.join(dfDir(root), "reflections.md"), next);
|
|
146
158
|
const { tidy } = reflectionNudges(next, now().slice(0, 10));
|
|
147
|
-
return { text: `reflect: item ${n} checked off — ${
|
|
159
|
+
return { text: `reflect: item ${n} checked off — ${it.body}${what ? ` — fixed: ${what}` : ""}` + (tidy ? `\n${tidy}` : "") };
|
|
148
160
|
}
|
|
149
161
|
|
|
150
162
|
/** `flow reflect tidy` — drop the closed (`- [x]`) items; the `— fixed:` note already recorded the outcome. */
|
|
@@ -156,5 +168,5 @@ export function reflectTidy(root: string): RunResult {
|
|
|
156
168
|
const open = openChecklistItems(text).length;
|
|
157
169
|
if (!closed) return { text: `reflections: nothing to tidy (${open} open, 0 closed)` };
|
|
158
170
|
writeFileSync(file, reflectionsTidy(text));
|
|
159
|
-
return { text: `reflections: dropped ${closed} closed item(s) — ${open} open` };
|
|
171
|
+
return { text: `reflections: dropped ${closed} closed item(s) — ${open} open; ${RENUMBERED}` };
|
|
160
172
|
}
|
package/src/runtime/ship.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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, versionArg, playbookVersionChoice, describeVersionChoice, majorBump, bumpVersion, isBumpKind } from "../core.ts";
|
|
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, versionArg, playbookVersionChoice, describeVersionChoice, majorBump, bumpVersion, isBumpKind, resolvedDevEnv } from "../core.ts";
|
|
5
5
|
import type { Config, FlowState } from "../core.ts";
|
|
6
6
|
import { AGENT_MARK } from "../present.ts";
|
|
7
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";
|
|
@@ -70,11 +70,14 @@ export async function gateVerify(o: GateCtx): Promise<RunResult> {
|
|
|
70
70
|
// deploy to dev before asking — the operator reviews the running dev app, not a promise
|
|
71
71
|
const probe = healthProbe(cfg);
|
|
72
72
|
if (cfg.commands.dev) {
|
|
73
|
-
const
|
|
73
|
+
const env = devEnv(root, state!, cfg);
|
|
74
|
+
const res = await sh(cfg.commands.dev, gateCwd(root, state!), undefined, env);
|
|
74
75
|
state!.checks.dev = { ok: res.ok, at: now() };
|
|
75
76
|
writeState(root, state!);
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
// gh#204: the command prints as the playbook wrote it — say what its $DEV_FLOW_* and compose project resolved to
|
|
78
|
+
const resolved = resolvedDevEnv(cfg.commands.dev, env);
|
|
79
|
+
if (!res.ok) return { text: `dev deploy FAILED (${cfg.commands.dev})${resolved ? ` — ${resolved}` : ""}:\n${tail(res.out)}`, isError: true };
|
|
80
|
+
did.push(`dev ran (${cfg.commands.dev})${devPortOf(state!, cfg) !== undefined ? ` on port ${devPortOf(state!, cfg)}` : ""}${resolved ? ` — ${resolved}` : ""}`);
|
|
78
81
|
// the deploy is what must be proven, not just run: a container that came back unhealthy, or
|
|
79
82
|
// still serves the previous build, must not pass on a health PASS recorded before it was
|
|
80
83
|
// recreated. What "the expected version" means is the project's business — the probe runs in
|
|
@@ -618,8 +621,20 @@ export async function gateFinish(o: GateCtx): Promise<RunResult> {
|
|
|
618
621
|
if (err || !state || state.approvals.release || state.stage !== "release" || !state.approvals["pre-release"]) return gateFinishCore(o);
|
|
619
622
|
const rec = await gateReleaseDone({ ...o, rest: o.rest.filter((a) => a !== "--confirmed" && a !== "--yolo") });
|
|
620
623
|
if (rec.isError) return rec;
|
|
621
|
-
const fin = await gateFinishCore(o);
|
|
622
624
|
const recorded = rec.text.split("\n").filter((l) => !l.startsWith(AGENT_MARK)).join("\n");
|
|
625
|
+
// gh#205: release-stage items (a post-merge build, a deploy check from the default branch) are work done after
|
|
626
|
+
// the merge. A separate release-done names them while the worktree still stands; folded into finish, one
|
|
627
|
+
// call recorded the release and removed everything, so an unversioned flow never saw them. Stop once here.
|
|
628
|
+
const cur = readState(o.root, state.slug) ?? state;
|
|
629
|
+
if (checklistPending(o.cfg, cur, "release")) {
|
|
630
|
+
markPendingAsk(o.root, cur, "Finish?");
|
|
631
|
+
const items = applicableItems(o.cfg, cur, "release").map((i) => `"${i.text}"`).join(" | ");
|
|
632
|
+
return {
|
|
633
|
+
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`)}`,
|
|
634
|
+
isError: true,
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
const fin = await gateFinishCore(o);
|
|
623
638
|
return { ...fin, text: `${recorded}\n\n${fin.text}` };
|
|
624
639
|
}
|
|
625
640
|
|
|
@@ -724,7 +739,9 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
|
|
|
724
739
|
if (askPending) {
|
|
725
740
|
markPendingAsk(root, state!, "Finish?");
|
|
726
741
|
if (!ui.hasUI) {
|
|
727
|
-
|
|
742
|
+
// the Finish? answer is what closes the release-stage items: name them in the question it asks
|
|
743
|
+
const openRelease = checklistPending(cfg, state!, "release") ? ` Release-stage checklist to close with this answer: ${applicableItems(cfg, state!, "release").map((i) => `"${i.text}"`).join(" | ")}.` : "";
|
|
744
|
+
return { text: needsOperator(`cleanup removes the worktree, branch and feature folder.${openRelease}${quietNote}${forgeSkipNote}`, "Finish?", "ask the operator Finish? in chat, then re-run with --confirmed"), isError: true };
|
|
728
745
|
}
|
|
729
746
|
const ok = await ui.confirm("Finish feature", `Finish ${state!.slug}?${unmergedNote}${forgeSkipNote} Removes worktree, branch ${state!.branch || "-"} and .dev-flow/${state!.slug}/.`);
|
|
730
747
|
if (!ok) {
|