pi-dev-flow 0.73.0 → 0.74.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 +30 -0
- package/docs/guardrails.md +1 -1
- package/docs/headless.md +3 -4
- package/docs/playbook.md +5 -8
- package/extensions/dev-flow.ts +272 -340
- package/package.json +1 -1
- package/skills/dev-flow/references/implement.md +3 -4
- package/skills/dev-flow/references/pre-release.md +1 -1
- package/skills/dev-flow/references/start.md +1 -2
- package/src/core.ts +30 -73
- package/src/projectmd.ts +17 -39
- package/src/timeouts.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.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": [
|
|
@@ -23,8 +23,8 @@ feature).
|
|
|
23
23
|
2. Write tests as you go (project framework: the `test` key / `flow-check`
|
|
24
24
|
blocks).
|
|
25
25
|
3. `flow check` runs every tier-1 check (test, health, named `flow-check`
|
|
26
|
-
blocks) and records each
|
|
27
|
-
|
|
26
|
+
blocks) and records each against a fingerprint of the worktree; any later
|
|
27
|
+
worktree change makes them stale — verify reruns stale checks itself.
|
|
28
28
|
4. UI flag set? An actual browser visual pass (screenshot or the project's
|
|
29
29
|
automated pass) — not just a typecheck.
|
|
30
30
|
5. Done means **running and healthy with pre-existing data**, not "compiles":
|
|
@@ -83,8 +83,7 @@ Verify lands the feature in **pre-release**.
|
|
|
83
83
|
Mid-stage additions — do not bounce the flow, do not grow it silently:
|
|
84
84
|
**this feature grew** → stay at implement, append a `**Added mid-stage:**` line
|
|
85
85
|
to `plan.md` (what was asked and how), implement, `flow check` again — edits
|
|
86
|
-
|
|
87
|
-
addition. **Different problem** → finish this feature first, then a new flow
|
|
86
|
+
make the checks stale, so verify re-covers the addition. **Different problem** → finish this feature first, then a new flow
|
|
88
87
|
(`flow start <new-slug>` after this one ships); never fold two features into
|
|
89
88
|
one plan, PR and verify — the
|
|
90
89
|
audit trail is the point. **Heavily amended plan** → show it and have the
|
|
@@ -34,7 +34,7 @@ invent one mid-release. Sequence:
|
|
|
34
34
|
(move the lines as they are and reword afterwards in a follow-up), and
|
|
35
35
|
refuses a changelog this branch never touched. `--no-fold-check` skips only
|
|
36
36
|
the line proofs, on the operator's word.
|
|
37
|
-
4. `flow check` — the prep edits
|
|
37
|
+
4. `flow check` — the prep edits made the implement checks stale; the release
|
|
38
38
|
gate demands them green again.
|
|
39
39
|
5. State what the PR will contain, present version and changelog entry,
|
|
40
40
|
**stop** — **Release?** → `flow release --confirmed`. Checkpoint report:
|
|
@@ -67,5 +67,4 @@ Playbook ownership, in full:
|
|
|
67
67
|
rules): read freely, **never edit** — changes go through `flow init --write`
|
|
68
68
|
on the operator's word. In-life playbook updates run as a docs flow:
|
|
69
69
|
project.md is editable only inside a docs/patch flow's worktree and is
|
|
70
|
-
committed to git like any file.
|
|
71
|
-
doctor flags it.
|
|
70
|
+
committed to git like any file.
|
package/src/core.ts
CHANGED
|
@@ -9,12 +9,12 @@ import { createHash } from "node:crypto";
|
|
|
9
9
|
import os from "node:os";
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/** A feature's stage. There is no "done": flow finish deletes the feature's state outright. */
|
|
13
|
+
export type Stage = "plan" | "implement" | "pre-release" | "release";
|
|
13
14
|
|
|
14
15
|
export interface Check {
|
|
15
16
|
ok: boolean;
|
|
16
17
|
at: string;
|
|
17
|
-
note?: string;
|
|
18
18
|
/** The worktree state this check actually ran against (see checkFingerprint). A record whose
|
|
19
19
|
* fingerprint differs from the current tree at gate time was measured against code that no
|
|
20
20
|
* longer exists — green is not enough when the tree moved under it. Absent = recorded by an
|
|
@@ -101,7 +101,7 @@ export interface Config {
|
|
|
101
101
|
versioning: Versioning;
|
|
102
102
|
/** Seconds the post-deploy health probe may keep retrying before the gate gives up (0 = single shot). */
|
|
103
103
|
healthWait: number;
|
|
104
|
-
release: { review: string; changelog?: string;
|
|
104
|
+
release: { review: string; changelog?: string; releases?: boolean; artifact?: string; preflight?: string; merge?: MergeStyle | "any" };
|
|
105
105
|
mainHook: boolean; // flow init installs a pre-commit hook blocking main commits
|
|
106
106
|
/** `inject` (default): the class default timeout is armed silently on every shell call.
|
|
107
107
|
* `require`: a shell call without its own visible timeout is refused (costs a turn per miss). */
|
|
@@ -168,17 +168,11 @@ export function extractSkillCore(md: string): string | null {
|
|
|
168
168
|
return core || null;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
/** The playbook file carrying one stage's detail, relative to the skill directory.
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
implement: "references/implement.md",
|
|
177
|
-
"pre-release": "references/pre-release.md",
|
|
178
|
-
release: "references/release.md",
|
|
179
|
-
};
|
|
180
|
-
export function stageReference(stage: Stage): string | null {
|
|
181
|
-
return STAGE_REFERENCE[stage] ?? null;
|
|
171
|
+
/** The playbook file carrying one stage's detail, relative to the skill directory. The state machine
|
|
172
|
+
* has no finish stage — closing out happens inside `release`, and release.md hands over to finish.md
|
|
173
|
+
* there. The pre-flow brief is `start`. */
|
|
174
|
+
export function stageReference(stage: Stage): string {
|
|
175
|
+
return `references/${stage}.md`;
|
|
182
176
|
}
|
|
183
177
|
|
|
184
178
|
/** The project's own "running and healthy" probe — `commands.health` or a flow-check block named
|
|
@@ -568,9 +562,8 @@ export function githubSlug(ref: string): string {
|
|
|
568
562
|
return m ? m[1].replace(/\.git$/, "") : "";
|
|
569
563
|
}
|
|
570
564
|
|
|
571
|
-
/** Gate: the tag derived from the manifest version must exist among
|
|
572
|
-
export function versionTagGate(manifestVersion: string
|
|
573
|
-
if (!manifestVersion) return ["versioning.file is set but its version could not be parsed — fix versioning config"];
|
|
565
|
+
/** Gate: the tag derived from the manifest version must exist among the given tags. */
|
|
566
|
+
export function versionTagGate(manifestVersion: string, tagPattern: string, tags: string[]): string[] {
|
|
574
567
|
const expected = tagPattern.replace("{version}", manifestVersion);
|
|
575
568
|
if (tags.includes(expected)) return [];
|
|
576
569
|
return [`expected release tag "${expected}" (from manifest version ${manifestVersion}) not found; recent tags: ${tags.slice(0, 5).join(", ") || "none"}`];
|
|
@@ -655,16 +648,6 @@ export function changelogEntry(content: string, version: string): string {
|
|
|
655
648
|
return out.join("\n").trim();
|
|
656
649
|
}
|
|
657
650
|
|
|
658
|
-
/**
|
|
659
|
-
* Cleanup safety for `flow finish`. Returns { errors, unmerged }: errors hard-block;
|
|
660
|
-
* unmerged is a warning list the operator can confirm through (e.g. squash merges).
|
|
661
|
-
*/
|
|
662
|
-
export function cleanupAssess(porcelain: string, unmerged: string[]): { errors: string[]; unmerged: string[] } {
|
|
663
|
-
const errors: string[] = [];
|
|
664
|
-
if (porcelain.trim()) errors.push("worktree has uncommitted changes — commit or discard them first");
|
|
665
|
-
return { errors, unmerged: unmerged.filter(Boolean) };
|
|
666
|
-
}
|
|
667
|
-
|
|
668
651
|
/* -------------------------------------------------------------- merge policy */
|
|
669
652
|
|
|
670
653
|
/** Past tense of a style, for the wording of a refusal. */
|
|
@@ -1073,13 +1056,17 @@ export function releaseOrderInvocation(command: string, stage: Stage | null): st
|
|
|
1073
1056
|
return null;
|
|
1074
1057
|
}
|
|
1075
1058
|
|
|
1076
|
-
/**
|
|
1077
|
-
|
|
1059
|
+
/** The branch a `git checkout` / `git switch` targets, and whether it creates it (`-b/-B/-c/-C/--create/
|
|
1060
|
+
* --force-create/--orphan`), or null. Leading flags are skipped; `--` ends the branch part (paths follow). */
|
|
1061
|
+
export function checkoutInvocation(command: string): { target: string; creates: boolean } | null {
|
|
1078
1062
|
const m = command.match(/\bgit\s+(?:-C\s+\S+\s+)?(?:checkout|switch)\b([^;|&\n]*)/);
|
|
1079
1063
|
if (!m) return null;
|
|
1080
|
-
const
|
|
1064
|
+
const all = m[1].trim().split(/\s+/).filter(Boolean);
|
|
1065
|
+
const tok = all.includes("--") ? all.slice(0, all.indexOf("--")) : all;
|
|
1081
1066
|
const i = tok.findIndex((t) => /^(-[bBcC]|--create|--force-create|--orphan)$/.test(t));
|
|
1082
|
-
|
|
1067
|
+
if (i >= 0) return tok[i + 1] ? { target: unquote(tok[i + 1]), creates: true } : null;
|
|
1068
|
+
const target = tok.find((t) => !t.startsWith("-"));
|
|
1069
|
+
return target ? { target: unquote(target), creates: false } : null;
|
|
1083
1070
|
}
|
|
1084
1071
|
|
|
1085
1072
|
// ------------------------------------------------------- project safety rules
|
|
@@ -1237,7 +1224,7 @@ function compile(source: string): RegExp | null {
|
|
|
1237
1224
|
try {
|
|
1238
1225
|
regexCache.set(source, new RegExp(source));
|
|
1239
1226
|
} catch {
|
|
1240
|
-
regexCache.set(source, null); // unreachable through project.md (parse validates)
|
|
1227
|
+
regexCache.set(source, null); // unreachable through project.md (parse validates) — kept so a bad rule never throws in a hook
|
|
1241
1228
|
}
|
|
1242
1229
|
}
|
|
1243
1230
|
return regexCache.get(source)!;
|
|
@@ -1361,7 +1348,6 @@ export function writeGuard(o: { abs: string; dfDir: string; features: FeatureRef
|
|
|
1361
1348
|
// a brand-new file under a real directory resolves right, and a never-existing one is stable).
|
|
1362
1349
|
const abs = realAbs(o.abs);
|
|
1363
1350
|
const dfDir = realAbs(o.dfDir);
|
|
1364
|
-
if (abs === path.join(dfDir, "project.json")) return ".dev-flow/project.json is legacy — it is no longer read; fold its values into project.md and delete it";
|
|
1365
1351
|
if (abs === path.join(dfDir, "project.md")) return "project.md is the operator playbook — change it with flow init --write (setup) or inside a docs/patch flow's worktree";
|
|
1366
1352
|
if (abs.endsWith("state.json") && abs.includes(dfDir + path.sep)) return "state.json is dev-flow-owned — advance stages with the flow tool only";
|
|
1367
1353
|
if (abs.endsWith("claim.json") && abs.includes(dfDir + path.sep)) return "claim.json is dev-flow-owned — the live-session lock is not an edit target; take a feature over with flow use <slug>";
|
|
@@ -1370,7 +1356,6 @@ export function writeGuard(o: { abs: string; dfDir: string; features: FeatureRef
|
|
|
1370
1356
|
const owner = o.features.find((f) => within(abs, f.worktreeAbs ? realAbs(f.worktreeAbs) : null));
|
|
1371
1357
|
if (owner) {
|
|
1372
1358
|
if (owner.state.stage === "plan") return `feature ${owner.state.slug} is in plan — code is read-only until its plan is approved`;
|
|
1373
|
-
if (owner.state.stage === "done") return `feature ${owner.state.slug} is done`;
|
|
1374
1359
|
// the playbook copy inside a worktree: only operator-granted lightweight modes may change it
|
|
1375
1360
|
if (path.basename(abs) === "project.md" && abs.includes(path.join(".dev-flow", "project.md")) && !owner.state.docs && !owner.state.patch)
|
|
1376
1361
|
return `project.md changes belong to a docs or patch flow — ${owner.state.slug} is a normal feature (flow start <slug> --docs --confirmed)`;
|
|
@@ -1403,12 +1388,6 @@ export function writeGuard(o: { abs: string; dfDir: string; features: FeatureRef
|
|
|
1403
1388
|
return `unfinished features: ${o.features.map((f) => f.state.slug).join(", ")} — bind this session with flow use <slug> (or pass an explicit slug to gates)`;
|
|
1404
1389
|
}
|
|
1405
1390
|
|
|
1406
|
-
/** Branch targeted by a `git checkout`/`git switch` in the command, or null. */
|
|
1407
|
-
export function checkoutTarget(command: string): string | null {
|
|
1408
|
-
const m = command.match(/\bgit\s+(?:-C\s+\S+\s+)?(?:checkout|switch)\s+(?:-[bBc]\s+)?([^\s;|&]+)/);
|
|
1409
|
-
return m ? m[1] : null;
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
1391
|
/** Prefix feature branches match: branchPattern up to `{slug}` — used to keep feature branches out of the main checkout. */
|
|
1413
1392
|
export function featureBranchPrefix(cfg: Config): string {
|
|
1414
1393
|
return cfg.branchPattern.split("{")[0];
|
|
@@ -1437,7 +1416,7 @@ export function claimBlocks(claim: SessionClaim | null, myKey: string, alive: (p
|
|
|
1437
1416
|
}
|
|
1438
1417
|
|
|
1439
1418
|
/** Footer glyph per stage: the footer has no room for stage words and no legend of its own (README:Status bar is the legend). */
|
|
1440
|
-
export const STAGE_EMOJI: Record<Stage, string> = { plan: "📝", implement: "🔨", "pre-release": "🔍", release: "🚀"
|
|
1419
|
+
export const STAGE_EMOJI: Record<Stage, string> = { plan: "📝", implement: "🔨", "pre-release": "🔍", release: "🚀" };
|
|
1441
1420
|
|
|
1442
1421
|
export function statusCompact(state: FlowState): { text: string; failed: boolean } {
|
|
1443
1422
|
const failed = Object.values(state.checks).some((c) => !c.ok);
|
|
@@ -1453,7 +1432,7 @@ export function statusCompact(state: FlowState): { text: string; failed: boolean
|
|
|
1453
1432
|
* 💬 is the legend's "operator, your turn": an unbound session is parked on the operator by definition (an
|
|
1454
1433
|
* answer to start, or nothing to do until they say), so the pre-flow glyph is the honest one there too. */
|
|
1455
1434
|
export function statusFor(bound: FlowState | null, openCount: number): { text: string } {
|
|
1456
|
-
if (bound
|
|
1435
|
+
if (bound) {
|
|
1457
1436
|
const { text, failed } = statusCompact(bound);
|
|
1458
1437
|
return { text: failed ? `${text} ⚠️` : text };
|
|
1459
1438
|
}
|
|
@@ -1466,13 +1445,8 @@ export function openChecklistItems(text: string): string[] {
|
|
|
1466
1445
|
return text.split("\n").map((l) => l.trim()).filter((l) => l.startsWith("- [ ] "));
|
|
1467
1446
|
}
|
|
1468
1447
|
|
|
1469
|
-
/**
|
|
1470
|
-
export
|
|
1471
|
-
return openChecklistItems(text);
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
/** Closed (checked-off) reflection items — what `flow reflect tidy` drops (roadmap shares the checkbox test). */
|
|
1475
|
-
export const closedReflectionCount = (text: string) => text.split("\n").filter(isDoneItem).length;
|
|
1448
|
+
/** Checked-off (`- [x]`) items — what `flow reflect tidy` and `flow roadmap tidy` drop. */
|
|
1449
|
+
export const doneItemCount = (text: string) => text.split("\n").filter(isDoneItem).length;
|
|
1476
1450
|
|
|
1477
1451
|
/** Drop the closed (`- [x]`) reflection items: the preamble and the open lines stay verbatim
|
|
1478
1452
|
* (a line filter — no re-bucketing like appendReflection's rewrite), and a `## section` heading
|
|
@@ -1607,11 +1581,6 @@ export function guessReflectSections(note: string): ReflectGuess {
|
|
|
1607
1581
|
return { sections: ["playbook"], why: "nothing plugin-shaped in the note — if it is a dev-flow bug: flow reflect move <n> --plugin" };
|
|
1608
1582
|
}
|
|
1609
1583
|
|
|
1610
|
-
/** The section(s) a note belongs to, decided from its wording (primary home only — see guessReflectSections). */
|
|
1611
|
-
export function reflectSections(note: string): ReflectSection[] {
|
|
1612
|
-
return guessReflectSections(note).sections;
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
1584
|
/** Where a fix must be implemented: every fix runs through a flow whose gates confirm it —
|
|
1616
1585
|
* playbook-only change → docs flow; code in the dev-flow repo → patch/normal flow;
|
|
1617
1586
|
* plugin feedback in someone else's repo → upstream issue (dev-flow files nothing itself). */
|
|
@@ -1704,10 +1673,9 @@ export function reflectProtocol(items: ReflectItem[], selfRepo: boolean, facts:
|
|
|
1704
1673
|
* Rewrite reflections.md as a preamble + one section per non-empty bucket, with `line` appended to
|
|
1705
1674
|
* the end of each named section. Everything above the first item (title, comment, operator notes) is
|
|
1706
1675
|
* kept verbatim. Below the first item a `## section` heading owns the lines under it, so an existing
|
|
1707
|
-
* line never changes section
|
|
1708
|
-
*
|
|
1709
|
-
*
|
|
1710
|
-
* content untouched so the caller can say so.
|
|
1676
|
+
* line never changes section; an item under no known heading files under `## playbook` (where the
|
|
1677
|
+
* operator reads it — `flow reflect move` re-files it). A note already in a section is not written
|
|
1678
|
+
* there again — an all-duplicate call returns the content untouched so the caller can say so.
|
|
1711
1679
|
*/
|
|
1712
1680
|
export function appendReflection(text: string, sections: ReflectSection[], line: string): string {
|
|
1713
1681
|
const lines = text.split("\n");
|
|
@@ -1732,9 +1700,7 @@ export function appendReflection(text: string, sections: ReflectSection[], line:
|
|
|
1732
1700
|
continue;
|
|
1733
1701
|
}
|
|
1734
1702
|
if (!l.startsWith("- [")) continue;
|
|
1735
|
-
|
|
1736
|
-
const key: ReflectSection = section ?? (/\((plugin|doctor)\)/.test(l) || /\bto plugin\b/.test(l) ? "plugin" : "playbook");
|
|
1737
|
-
buckets[key].push(l.replace(/\((plugin|playbook|doctor)\)/, "").replace(/\s*[—-]\s*to\s+(playbook|plugin|doctor)/, "").replace(/\s{2,}/g, " ").trim());
|
|
1703
|
+
buckets[section ?? "playbook"].push(l);
|
|
1738
1704
|
}
|
|
1739
1705
|
const note = line.trim();
|
|
1740
1706
|
const body = reflectionBody(note);
|
|
@@ -1760,8 +1726,6 @@ export function appendRoadmapItem(text: string, item: string): string {
|
|
|
1760
1726
|
|
|
1761
1727
|
/** Number of open roadmap items. */
|
|
1762
1728
|
export const roadmapOpenCount = (text: string) => openChecklistItems(text).length;
|
|
1763
|
-
/** Number of done roadmap items (tidy removes them). */
|
|
1764
|
-
export const roadmapDoneCount = (text: string) => text.split("\n").filter(isDoneItem).length;
|
|
1765
1729
|
|
|
1766
1730
|
/** Stamp the nth open item (1-based, open items only) with `(slug)` — the pick→finish handshake.
|
|
1767
1731
|
* Returns null when n is out of range. Re-picking the same slug is a no-op stamp. */
|
|
@@ -1824,7 +1788,7 @@ export function shouldSelfCompact(
|
|
|
1824
1788
|
reserve = PI_RESERVE_DEFAULT,
|
|
1825
1789
|
): boolean {
|
|
1826
1790
|
if (d.compacting || d.tokens === null) return false;
|
|
1827
|
-
if (!d.stage
|
|
1791
|
+
if (!d.stage) return false;
|
|
1828
1792
|
if (d.checklistPending > 0) return false;
|
|
1829
1793
|
if (d.stage === "plan" && d.planFiles === 0) return false;
|
|
1830
1794
|
return d.tokens > d.contextWindow - reserve - COMPACT_MARGIN;
|
|
@@ -1838,18 +1802,13 @@ export function shouldTakeOverCompaction(d: { reason: "manual" | "threshold" | "
|
|
|
1838
1802
|
return d.reason === "threshold" && d.bound && !d.inFlight;
|
|
1839
1803
|
}
|
|
1840
1804
|
|
|
1841
|
-
/** reflections.md line for a forced (non-manual) pi compaction while a flow is bound — advisory, never gates. */
|
|
1842
|
-
export function compactionReflectionLine(slug: string, stage: Stage, reason: string, today: string): string {
|
|
1843
|
-
return `- [ ] pi auto-compacted (${reason}) at stage ${stage} — pace gates so work lands on disk before compaction; draft plan discussion into plan/ early — ${slug} ${today}`;
|
|
1844
|
-
}
|
|
1845
|
-
|
|
1846
|
-
/** What the agent/user should do next, per stage. */
|
|
1847
1805
|
/** The playbook's merge style spelled for a hint: "" when the project has no policy. */
|
|
1848
1806
|
function mergeHintFor(cfg: Config): string {
|
|
1849
1807
|
const m = cfg.release.merge;
|
|
1850
1808
|
return m && m !== "any" ? ` (the playbook says merge = ${m} — gh pr merge <n> --${m === "merge" ? "merge" : m}, number before the flag: a trailing one reads as the PR selector)` : "";
|
|
1851
1809
|
}
|
|
1852
1810
|
|
|
1811
|
+
/** What the agent/user should do next, per stage. */
|
|
1853
1812
|
export function nextHint(state: FlowState, cfg: Config): string {
|
|
1854
1813
|
switch (state.stage) {
|
|
1855
1814
|
case "plan":
|
|
@@ -1867,8 +1826,6 @@ export function nextHint(state: FlowState, cfg: Config): string {
|
|
|
1867
1826
|
: state.noVersion
|
|
1868
1827
|
? `publish: commit and push the branch, open the PR, merge only once CI is green (gh pr checks <n> --watch — a locally-green branch can still fail CI-only jobs)${mergeHintFor(cfg)} — unversioned release: no manifest bump, no tag, your changelog entry rides under Unreleased; then run flow release-done (no further question)`
|
|
1869
1828
|
: `publish: commit and push the branch, open the PR, merge only once CI is green (gh pr checks <n> --watch — a locally-green branch can still fail CI-only jobs)${mergeHintFor(cfg)}, create the annotated tag from the manifest version and push it, then run flow release-done (no further question)`;
|
|
1870
|
-
default:
|
|
1871
|
-
return "feature finished";
|
|
1872
1829
|
}
|
|
1873
1830
|
}
|
|
1874
1831
|
|
|
@@ -1929,7 +1886,7 @@ export function gateHelpJson(gateHelp: string, version: string | null): string {
|
|
|
1929
1886
|
);
|
|
1930
1887
|
}
|
|
1931
1888
|
|
|
1932
|
-
/** Write (or delete, on null) a dot-path value in a
|
|
1889
|
+
/** Write (or delete, on null) a dot-path value in a nested config object. */
|
|
1933
1890
|
export function applyAnswer(partial: Record<string, unknown>, key: string, value: string | boolean | null): void {
|
|
1934
1891
|
const segs = key.split(".");
|
|
1935
1892
|
const leaf = segs.pop()!;
|
package/src/projectmd.ts
CHANGED
|
@@ -35,13 +35,6 @@ const KEYMAP: Record<string, Record<string, string>> = {
|
|
|
35
35
|
forge: "forge",
|
|
36
36
|
"versioning.file": "versioning.file",
|
|
37
37
|
"versioning.pattern": "versioning.pattern",
|
|
38
|
-
"release.review": "release.review",
|
|
39
|
-
"release.changelog": "release.changelog",
|
|
40
|
-
"release.github": "release.releases",
|
|
41
|
-
"release.releases": "release.releases",
|
|
42
|
-
"release.artifact": "release.artifact",
|
|
43
|
-
"release.preflight": "release.preflight",
|
|
44
|
-
"release.merge": "release.merge",
|
|
45
38
|
},
|
|
46
39
|
plan: {},
|
|
47
40
|
implement: {
|
|
@@ -59,7 +52,6 @@ const KEYMAP: Record<string, Record<string, string>> = {
|
|
|
59
52
|
versionTag: "versioning.pattern",
|
|
60
53
|
review: "release.review",
|
|
61
54
|
changelog: "release.changelog",
|
|
62
|
-
github: "release.releases", // legacy alias for `releases` — parse warns about the rename
|
|
63
55
|
releases: "release.releases",
|
|
64
56
|
artifact: "release.artifact",
|
|
65
57
|
preflight: "release.preflight", // run in the worktree at flow release, before anything ships (e.g. docker build .)
|
|
@@ -159,7 +151,6 @@ export function parseProjectMd(text: string): ParsedMd {
|
|
|
159
151
|
const mapped = KEYMAP[stage][m[1]];
|
|
160
152
|
if (!mapped) p.warn.push(`${where}: unknown key "${m[1]}" in ## ${stage} — ignored`);
|
|
161
153
|
else {
|
|
162
|
-
if (mapped === "release.releases" && m[1].endsWith("github")) p.warn.push(`${where}: key "${m[1]}" is renamed "releases" — rename it`);
|
|
163
154
|
// the only enum-valued key: a junk mode must not silently mean "block every shell call"
|
|
164
155
|
if (m[1] === "bashTimeout" && !/^(require|inject)$/i.test(m[2].trim())) {
|
|
165
156
|
p.warn.push(`${where}: bashTimeout = "${m[2]}" — expected require or inject, keeping inject`);
|
|
@@ -217,7 +208,7 @@ export function mdToConfig(p: ParsedMd): Config {
|
|
|
217
208
|
const c: Config = structuredClone(DEFAULTS);
|
|
218
209
|
const raw: Record<string, unknown> = {};
|
|
219
210
|
for (const stage of MD_STAGES) for (const [key, val] of Object.entries(p.flow[stage])) applyAnswer(raw, key, val);
|
|
220
|
-
//
|
|
211
|
+
// playbook values arrive as strings: normalize the boolean and list keys
|
|
221
212
|
if (typeof raw.mainHook === "string") raw.mainHook = /^(yes|true)$/i.test(raw.mainHook);
|
|
222
213
|
if (typeof raw.mockupGlobs === "string") raw.mockupGlobs = String(raw.mockupGlobs).split(",").map((s) => s.trim()).filter(Boolean);
|
|
223
214
|
// flow keys were mapped to dot paths (commands.x, versioning.y, release.z) — rebuild nested
|
|
@@ -228,9 +219,11 @@ export function mdToConfig(p: ParsedMd): Config {
|
|
|
228
219
|
mergeInto(c, nested);
|
|
229
220
|
// a flow-guard block is the whole rule set; with none in project.md the DEFAULTS (empty) stand
|
|
230
221
|
if (GUARD_VERBS.some((v) => p.guard[v].length)) c.guard = structuredClone(p.guard);
|
|
222
|
+
// one check per name: an explicit flow-check block wins over the `test =` / `health =` shorthand
|
|
223
|
+
const named = new Set(p.checks.map((x) => x.name));
|
|
231
224
|
c.checkList = [
|
|
232
|
-
...(c.commands.test ? [{ name: "test", cmd: c.commands.test }] : []),
|
|
233
|
-
...(c.commands.health ? [{ name: "health", cmd: c.commands.health }] : []),
|
|
225
|
+
...(c.commands.test && !named.has("test") ? [{ name: "test", cmd: c.commands.test }] : []),
|
|
226
|
+
...(c.commands.health && !named.has("health") ? [{ name: "health", cmd: c.commands.health }] : []),
|
|
234
227
|
...p.checks.map((x) => ({ name: x.name, cmd: x.cmd })),
|
|
235
228
|
];
|
|
236
229
|
c.checklist = p.checklist;
|
|
@@ -290,7 +283,7 @@ export function setPlaybookKey(text: string, stage: MdStage, key: string, value:
|
|
|
290
283
|
return { text: lines.join("\n"), where: `## ${stage} — opened a flow block for it` };
|
|
291
284
|
}
|
|
292
285
|
|
|
293
|
-
/** Load the project config: project.md
|
|
286
|
+
/** Load the project config: project.md is the only source. */
|
|
294
287
|
export function loadProject(dfDir: string): { cfg: Config; md: ParsedMd | null } {
|
|
295
288
|
const mdFile = path.join(dfDir, "project.md");
|
|
296
289
|
let mdText: string | null = null;
|
|
@@ -330,7 +323,6 @@ export function ghostFeatureDirs(root: string): string[] {
|
|
|
330
323
|
*/
|
|
331
324
|
export function doctorFindings(root: string, cfg: Config, md: ParsedMd | null): string[] {
|
|
332
325
|
const f: string[] = [];
|
|
333
|
-
if (existsSync(path.join(root, ".dev-flow", "project.json"))) f.push(".dev-flow/project.json is no longer read — fold its values into project.md and delete it");
|
|
334
326
|
const gi = path.join(root, ".dev-flow", ".gitignore");
|
|
335
327
|
if (existsSync(gi) && !readFileSync(gi, "utf8").includes("!project.md")) f.push(".dev-flow/.gitignore still hides project.md from git — re-run flow init to heal it");
|
|
336
328
|
if (cfg.forge && !["github", "gitlab", "self"].includes(cfg.forge)) f.push(`forge "${cfg.forge}" is invalid — use github, gitlab or self`);
|
|
@@ -386,7 +378,7 @@ export function mdDigest(text: string): string {
|
|
|
386
378
|
const keys: Record<string, string> = {};
|
|
387
379
|
for (const [k, v] of Object.entries(p.flow[s] as Record<string, string>)) keys[k.split(".").pop()!] = v; // config dot-paths → display keys
|
|
388
380
|
for (const [k, v] of Object.entries(keys)) {
|
|
389
|
-
if (relStage && ["file", "pattern", "
|
|
381
|
+
if (relStage && ["file", "pattern", "artifact"].includes(k)) continue; // rendered specially below
|
|
390
382
|
bits.push(DIGEST_CMDS[k] ? `${DIGEST_CMDS[k]}: ${JSON.stringify(v)}` : `${DIGEST_WORDS[k] ?? k}: ${v}`);
|
|
391
383
|
}
|
|
392
384
|
if (s === "implement" && p.checks.length) bits.push(`named checks: ${p.checks.map((c) => c.name).join(", ")}`);
|
|
@@ -403,40 +395,26 @@ export function mdDigest(text: string): string {
|
|
|
403
395
|
return `${rows.join("\n") || "(empty)"}\n\nnothing is executed or uploaded now — gates only run later inside the flow`;
|
|
404
396
|
}
|
|
405
397
|
|
|
406
|
-
/** Draft project.md
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
const
|
|
410
|
-
const cmd = (k: string) => (fresh ? undefined : (c.commands as Record<string, string>)[k]) || det.partial.commands[k];
|
|
411
|
-
const branch = fresh ? det.partial.defaultBranch : c.defaultBranch;
|
|
412
|
-
const verFile = (fresh ? undefined : c.versioning.file) || det.partial.versioning?.file || "package.json";
|
|
398
|
+
/** Draft project.md from detection (first init, --force). Never a regeneration of an existing playbook:
|
|
399
|
+
* a draft cannot reproduce hand-written prose, checklist items and keys. */
|
|
400
|
+
export function buildDraft(det: { report: string[]; partial: { defaultBranch: string; commands: Record<string, string>; versioning?: { file: string }; forge?: string } }): string {
|
|
401
|
+
const cmd = (k: string) => det.partial.commands[k];
|
|
413
402
|
const L: string[] = [];
|
|
414
403
|
L.push("# dev-flow", "", "<!-- Operator-owned playbook. Regenerate with: flow init --draft -->", "");
|
|
415
|
-
L.push("## global", "", "```flow", `defaultBranch = ${
|
|
404
|
+
L.push("## global", "", "```flow", `defaultBranch = ${det.partial.defaultBranch}`);
|
|
416
405
|
if (det.partial.forge) L.push(`forge = ${det.partial.forge}`); // from the origin URL — confirm or correct
|
|
417
406
|
L.push("```", "");
|
|
418
|
-
L.push("## plan", "", "- [ ] rendered mockups attached for every changed screen", "", "<!-- what the plan must contain, UI expectations -->", "");
|
|
407
|
+
L.push("## plan", "", "- [ ] (ui) rendered mockups attached for every changed screen", "", "<!-- what the plan must contain, UI expectations -->", "");
|
|
419
408
|
L.push("## implement", "", "```flow");
|
|
420
409
|
for (const k of ["setup", "test", "build", "run", "seedData", "dev"]) if (cmd(k)) L.push(`${k} = ${cmd(k)}`);
|
|
421
|
-
// a hand-set wait budget is a real setting: a refresh that dropped it would silently make the probe single-shot again
|
|
422
|
-
if (!fresh && c.healthWait !== DEFAULTS.healthWait) L.push(`healthWait = ${c.healthWait}`);
|
|
423
410
|
L.push("```", "");
|
|
424
|
-
const healthCmd = cmd("health") || (fresh ? undefined : c.checkList.find((x) => x.name === "health")?.cmd);
|
|
425
411
|
// never invent a health check: a placeholder that can't pass blocks verify forever (dogfooded: curl localhost:3000 in a library repo)
|
|
426
|
-
if (
|
|
412
|
+
if (cmd("health")) L.push("```flow-check health", cmd("health"), "```", "");
|
|
427
413
|
else L.push("<!-- optional tier-1: add a flow-check 'health' block once the app exposes a health endpoint -->", "");
|
|
428
|
-
// carry every other explicit check through a refresh, or regeneration would silently drop teeth
|
|
429
|
-
for (const x of fresh ? [] : c.checkList) {
|
|
430
|
-
if (x.name === "test" || x.name === "health") continue; // implicit ones ride the flow key block / healthCmd above
|
|
431
|
-
L.push("```flow-check " + x.name, x.cmd, "```", "");
|
|
432
|
-
}
|
|
433
414
|
L.push("- [ ] app runs locally with real data; visual pass: no overflows or stray scrollbars", "", "<!-- tier-3: standing guidance for this stage -->", "");
|
|
434
|
-
L.push("## pre-release", "", "<!-- e.g. review policy, docs expectations, who picks the version -->", "", "```flow", `versionFile = ${
|
|
435
|
-
// the merge policy is never invented by detection:
|
|
436
|
-
|
|
437
|
-
L.push("## release", "");
|
|
438
|
-
if (c.release.merge) L.push("```flow", `merge = ${c.release.merge}`, "```", "");
|
|
439
|
-
else L.push("<!-- merge = squash | merge | rebase — how a merged PR lands on the default branch (`any` = no policy). flow start also asks and writes it. -->", "");
|
|
415
|
+
L.push("## pre-release", "", "<!-- e.g. review policy, docs expectations, who picks the version -->", "", "```flow", `versionFile = ${det.partial.versioning?.file || "package.json"}`, "versionTag = v{version}", "```", "");
|
|
416
|
+
// the merge policy is never invented by detection: flow start asks and writes it
|
|
417
|
+
L.push("## release", "", "<!-- merge = squash | merge | rebase — how a merged PR lands on the default branch (`any` = no policy). flow start also asks and writes it. -->", "");
|
|
440
418
|
L.push("<!-- e.g. tag policy, who publishes artifacts -->", "");
|
|
441
419
|
return L.join("\n") + "\n";
|
|
442
420
|
}
|
package/src/timeouts.ts
CHANGED
|
@@ -67,8 +67,8 @@ export function bashTimeout(command: string, explicit?: number): number {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
* `bashTimeout = require` (the default): the model must state the timeout itself,
|
|
71
|
-
* injected value never reaches the transcript — the tool call entry records the arguments the model
|
|
70
|
+
* `bashTimeout = require` (opt-in; `inject` is the default): the model must state the timeout itself,
|
|
71
|
+
* because the injected value never reaches the transcript — the tool call entry records the arguments the model
|
|
72
72
|
* emitted, and the handler mutates them afterwards. Returns the refusal, or undefined when the call
|
|
73
73
|
* already carries an explicit timeout. The refused call is not lost: the reason names the exact
|
|
74
74
|
* value the class table would have armed, so the retry is a one-token fix.
|