pi-dev-flow 0.52.3 → 0.53.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 +15 -0
- package/docs/gates.md +2 -2
- package/docs/playbook.md +3 -1
- package/extensions/dev-flow.ts +73 -23
- package/package.json +1 -1
- package/skills/dev-flow/SKILL.md +16 -10
- package/src/core.ts +119 -22
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.53.0] - 2026-10-22
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **The release gate now proves the changelog instead of asking for it.** The stage told the agent to keep manifest, changelog and tag in step, but the machine checked almost none of that, and the gap showed up in the wild: a project shipped `v0.14.0` with **no changelog entry at all** while `flow check`, verify, release and `release-done` (artifact probe and all) stayed green. Four holes closed at the gate (#97): a versioned release never had to **touch** the changelog — the proof existed and was wired only to `--no-version`, so a merge commit could inherit whatever `CHANGELOG.md` main already carried; "mentions the version" was a substring test, so prose, a link reference or an older entry naming the number all passed without an entry existing (and `## [1.2.0-beta]` could stand in for the `1.2.0` release); an unversioned release could satisfy its rule by editing some unrelated older section instead of putting its line under `Unreleased`; and "folded" only meant `Unreleased` was empty, so **deleting** the pending entries passed where moving them was required. Now the gate wants a heading that names the version, an entry this branch actually prepared, and every line that was pending before the release still present inside that entry — compared on normalized lines, so re-indenting a fold is free while rewording or dropping one is refused by quoting the line that vanished.
|
|
12
|
+
- **The forge release page now says what the changelog says.** `release-done` published the **tag annotation** first and fell back to the changelog entry, which meant any `git tag -a` body shipped instead of the entry, and nothing ever checked what the release page ended up holding. The changelog entry for the version is now the body of record, the annotation stands in only when the changelog has no entry for that version, and the gate **reads the stored body back** and refuses a mismatch (normalized first — the forge reflows markdown — with the missing body's own text quoted so `gh release edit` is one copy-paste away).
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **`flow release --no-fold-check`** — the operator's escape from the line-level fold proofs, for the case where a pending entry is deliberately rewritten rather than moved. Same convention as `--no-release-create` and `--no-artifact-check`: one flow, granted in chat, and the gate output carries the note that the proofs were skipped. The entry-heading and touched proofs are not escapable.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **A baseline that cannot be resolved is an advisory, not a refusal.** The fold comparison needs to know what was pending before the release: it reads the changelog at the **newest tag** (what actually shipped), falling back to the branch's merge base. A rebased or squash-merged branch — or a clone that has not fetched the tag — used to be the shape where a git-topology accident would block a legal release, so when no baseline resolves the two git-dependent proofs are skipped **out loud** (`Warning: no tag or merge base to compare against…`) while the content proofs — the heading exists, its body is not empty — always run. Changelogs that never adopted the `Unreleased` convention stay vacuously clean, as before.
|
|
21
|
+
|
|
7
22
|
## [0.52.3] - 2026-10-22
|
|
8
23
|
|
|
9
24
|
### Fixed
|
package/docs/gates.md
CHANGED
|
@@ -16,8 +16,8 @@ so it needs no `--confirmed`.
|
|
|
16
16
|
| `check` | records all tier-1 checks | — (runs every `flow-check`/test/health from project.md `## implement`) |
|
|
17
17
|
| `health` | records a check | — (runs `seedData` + the health command, retrying up to `healthWait` seconds; app must be up locally with real data) |
|
|
18
18
|
| `verify [--yolo]` | implement → pre-release | all tier-1 checks green — a check with no passing record is **run by the gate itself** (`checks ran at the gate (test)`) rather than refused and pointed at `flow check`, since entering the stage or editing the worktree is what cleared it, and a failure there prints the run output, **the feature branch holds at least one commit** (verify refuses a branch with nothing committed — the checks describe the working tree, so an uncommitted state has never been recorded — and prints `commits: N ahead of <default>, M uncommitted path(s)` with what it ran; uncommitted paths are reported, never gated), build (if configured) green, `dev` deploy (if configured) runs first so you can review the running app **and the health probe (if configured) re-runs against what it just deployed, retrying every 2s up to `healthWait` seconds** (a failing probe refuses the gate and reports how many attempts it took: the `flow check` PASS predates the deploy, and a service that needs seconds after its container starts is not a broken deploy; with no probe the output says `health: none configured`), tier-2 checklist (ui-only items excluded for non-UI features) confirmed as a set; a `--docs` feature runs none of it (`docs mode: project commands skipped`) and only asks you; **one question** — or `--confirmed`; `--yolo --confirmed` = you answered 'yolo' at Verified? — answers it and pre-confirms the rest |
|
|
19
|
-
| `release [--yolo|--no-version]` | pre-release → release | checks re-greened after the prep edits; with `versioning.file`: the manifest version parses and is **not tagged yet** (the bump must be ahead of the last release); with `release.changelog
|
|
20
|
-
| `release-done` | records the release (the stage stays `release`) | **no question — the Release? answer covered the publication**; verify approval; the version published is the one `release` **stamped** from the manifest it validated (a main checkout still behind cannot republish the previous version), and it must not be older than the newest matching tag **on origin** (tag lists come from `git ls-remote`, so an unfetched clone does not decide what exists; when an origin exists but cannot be asked (offline, no ssh agent) **both release gates refuse** rather than answering with local tags); with `versioning.file`: that tag exists, is reachable from the default branch **and is on origin** (a local-only tag is not a release); with `release.artifact`: the published-artifact check runs (`{version}`/`{tag}` placeholders — the line it prints names the version it verified; skip once with `--no-artifact-check`, operator-instructed only) · creates the forge release from the tag, its body the tag's annotation
|
|
19
|
+
| `release [--yolo|--no-version|--no-fold-check]` | pre-release → release | checks re-greened after the prep edits; with `versioning.file`: the manifest version parses and is **not tagged yet** (the bump must be ahead of the last release); with `release.changelog` the gate **proves the entry mechanically** (#97): a **heading names the version** (prose that mentions it, or a `1.2.0-beta` section when releasing `1.2.0`, is not an entry), **this branch touched the file** (an inherited changelog is not release prep), **every entry that was pending before the release survives inside the new section** — compared on normalized lines, so re-indenting a fold is free while rewording or deleting one is refused by naming the line — and **nothing is left under `Unreleased`**. The pending baseline is the newest tag's changelog (what actually shipped), else the branch's merge base; when neither resolves, the two git-dependent proofs are skipped **with a printed advisory** rather than refusing a legal release for a topology reason, and the content proofs (the heading, its body) always run; tier-2 `## pre-release` checklist confirmed; the manifest version it validates is **stamped as the release's version of record** (`release-done` publishes that, whatever the checkouts say later); **one question** (Release?) — or `--confirmed`; `--no-version` (your call at Release?) ships this flow as **merge + changelog** — the bump/tag requirements and the tag checks at `release-done` are skipped for it, but the branch must still add its **own line under `Unreleased`** (editing an older section releases nothing) and it rides there until the next versioned release folds it (default: versioned); `--no-fold-check` is the operator-granted escape from the line-level fold proofs — one flow, stamped in the gate output, the heading and touched proofs stay |
|
|
20
|
+
| `release-done` | records the release (the stage stays `release`) | **no question — the Release? answer covered the publication**; verify approval; the version published is the one `release` **stamped** from the manifest it validated (a main checkout still behind cannot republish the previous version), and it must not be older than the newest matching tag **on origin** (tag lists come from `git ls-remote`, so an unfetched clone does not decide what exists; when an origin exists but cannot be asked (offline, no ssh agent) **both release gates refuse** rather than answering with local tags); with `versioning.file`: that tag exists, is reachable from the default branch **and is on origin** (a local-only tag is not a release); with `release.artifact`: the published-artifact check runs (`{version}`/`{tag}` placeholders — the line it prints names the version it verified; skip once with `--no-artifact-check`, operator-instructed only) · creates the forge release from the tag, its body **the `release.changelog` entry for that version** — the changelog is the source of truth, and the tag's annotation stands in only when the changelog has no entry for the version, else nothing (and it says why — a body that is really a shell error is dropped, never shipped) — `gh` for GitHub, `glab` for GitLab) and then **proves the release exists**: it asks the forge (`gh release view <tag>` / `glab release view <tag>`) and refuses when nothing is there, because #51, #60 and #63 were three ways of ending `release recorded as complete` with nothing published — and when the changelog was the body it **reads the stored body back** and refuses a mismatch, so the release page and the changelog cannot drift (#97; normalized before comparing, skipped with a printed note on another forge). Skipping is deliberate and loud — `--no-release-create`, `release.releases = false` or `forge = self` each print that no forge release was created, and the view check is skipped for them |
|
|
21
21
|
| `finish [--yolo] [slug]` | release → done (removes worktree + branch, deletes `.dev-flow/<slug>/`, and deletes `origin/<branch>` **only** when its merged state is verified — ancestor of the default branch or a merged PR/MR via `gh`/`glab`; unverifiable branches stay with a note) | a release is recorded (`release-done` ran), the main checkout is clean **and** pushed to `origin/<default>`, and the worktree has no uncommitted changes; **one question** (Finish? — mentions unmerged-looking squash-merge commits, and warns when the forge release create failed at `release-done` and no retry succeeded) — or `--confirmed`; to abandon an unreleased feature use `abort` |
|
|
22
22
|
| `reflect ["<note>"]` | — | `reflect "<note>"` queues a suggestion in `reflections.md` (never gates; gate flags such as `--confirmed` are ignored, they never become part of the note). Bare `reflect` prints the full **session-reflection protocol** for the agent (from the `/flow reflect` bar it additionally wakes the model, so the protocol executes immediately): review the whole session log, re-check every open item against the current playbook and **newer dev-flow versions** (`npm view pi-dev-flow version` vs the running version — dev-flow ships from npm; recommend `pi install npm:pi-dev-flow` + `/reload`, the operator performs updates), dedupe new findings against the open ones, then report playbook vs plugin items to the operator and ask whether to fix now — plugin items: search upstream issues first (`gh issue list --repo <upstream> --state all --search …`; an author-addressed match is reported back, no match → `gh issue create` with a detailed description and a suggested fix), playbook items: `flow doctor` routes each to the docs flow that implements it |
|
|
23
23
|
| `roadmap [add "<feature>" \| pick <n> <slug> \| done <n> \| tidy]` | — | manages `.dev-flow/roadmap.md`, the gitignored backlog of future features (`- [ ]` checklist): bare prints the numbered open items, `add` appends one, `pick <n> <slug>` stamps open item n with `(slug)` so `flow start <slug>` can take it — **`finish` checks the stamped item off when that feature ships**; `done <n>` checks off by hand (items shipped outside a flow), `tidy` drops the checked lines. Never gates; the open count is surfaced in `status` and session context |
|
package/docs/playbook.md
CHANGED
|
@@ -90,7 +90,9 @@ your `deny` rules do not have a back door through the read-only list.
|
|
|
90
90
|
`## pre-release` prose is where rules like “follow semver: minor for user-facing features, patch
|
|
91
91
|
otherwise; confirm the number before tagging” live — the agent sees them at stage entry, and
|
|
92
92
|
`flow release` / `flow release-done` hard-check the manifest side (bumped past the last tag, then
|
|
93
|
-
manifest↔tag agreement)
|
|
93
|
+
manifest↔tag agreement) and the changelog side (a heading for the version, an entry this branch
|
|
94
|
+
prepared, and every entry that was pending before the release folded into it — see
|
|
95
|
+
[gates.md](gates.md)). `## global` holds
|
|
94
96
|
`defaultBranch`, `branchPattern`, `worktreeDir`, `mainHook`, `mockupGlobs`, `bashTimeout = require`
|
|
95
97
|
(default: every shell call must state its own timeout) `| inject`, `release.review`,
|
|
96
98
|
`release.changelog` (default `CHANGELOG.md`; set it empty to opt out), `release.releases` and `release.artifact = <cmd>` (verify the published artifact — image registry probe etc. — before release-done completes); the implement stage takes `setup`/`test`/`build`/`run`/`seedData`/`health`/
|
package/extensions/dev-flow.ts
CHANGED
|
@@ -32,6 +32,9 @@ import {
|
|
|
32
32
|
appendRoadmapItem,
|
|
33
33
|
bashFlowGuard,
|
|
34
34
|
changelogEntry,
|
|
35
|
+
normalizeReleaseBody,
|
|
36
|
+
pendingEntryLines,
|
|
37
|
+
pickReleaseNotes,
|
|
35
38
|
checklistHash,
|
|
36
39
|
checklistPending,
|
|
37
40
|
checkoutTarget,
|
|
@@ -159,7 +162,7 @@ async function releaseTags(root: string): Promise<string[] | null> {
|
|
|
159
162
|
}
|
|
160
163
|
|
|
161
164
|
const GATE_HELP =
|
|
162
|
-
"help [--json] | init [--force|--draft|--write <text>] | reflect [<note>] | roadmap [add <text>|pick <n> <slug>|done <n>|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui] [--force] [--patch|--docs --confirmed] | use <slug> | test | check | health | approve [--yolo] | verify [--yolo] | release [--yolo|--no-version] | release-done [--no-artifact-check|--no-release-create] | finish [--yolo] [slug] | abort [slug] | version — reflect <note> queues a suggestion in reflections.md (gate flags like --confirmed are ignored there); bare reflect prints the full session-reflection protocol (review the session log, re-check open items against shipped fixes and newer dev-flow versions, dedupe and report new findings, put the fix decision to the operator); roadmap manages .dev-flow/roadmap.md, the gitignored backlog of future features (bare lists open items; add appends one; pick <n> <slug> stamps open item <n> with the slug a later flow start uses — flow finish checks it off when that feature ships; done <n> checks off by hand; tidy drops done items); bare doctor reviews structure, git consistency and open reflections (routes each fix to a flow; it never writes); doctor <note> prints an investigation brief for a fresh observation; state gates take [slug] and --confirmed (the operator already answered in chat); --patch/--docs likewise need --confirmed (the operator granted the mode); --yolo on any state gate (approve/verify/release/finish) = the operator said \"yolo\" at that checkpoint: it answers that question and pre-confirms every later one (needs --confirmed; checks and guardrails stay); release --no-version = this flow ships merge + changelog only — no bump, tag or forge release; the entry rides under Unreleased until the next versioned release folds it (default: versioned)";
|
|
165
|
+
"help [--json] | init [--force|--draft|--write <text>] | reflect [<note>] | roadmap [add <text>|pick <n> <slug>|done <n>|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui] [--force] [--patch|--docs --confirmed] | use <slug> | test | check | health | approve [--yolo] | verify [--yolo] | release [--yolo|--no-version|--no-fold-check] | release-done [--no-artifact-check|--no-release-create] | finish [--yolo] [slug] | abort [slug] | version — reflect <note> queues a suggestion in reflections.md (gate flags like --confirmed are ignored there); bare reflect prints the full session-reflection protocol (review the session log, re-check open items against shipped fixes and newer dev-flow versions, dedupe and report new findings, put the fix decision to the operator); roadmap manages .dev-flow/roadmap.md, the gitignored backlog of future features (bare lists open items; add appends one; pick <n> <slug> stamps open item <n> with the slug a later flow start uses — flow finish checks it off when that feature ships; done <n> checks off by hand; tidy drops done items); bare doctor reviews structure, git consistency and open reflections (routes each fix to a flow; it never writes); doctor <note> prints an investigation brief for a fresh observation; state gates take [slug] and --confirmed (the operator already answered in chat); --patch/--docs likewise need --confirmed (the operator granted the mode); --yolo on any state gate (approve/verify/release/finish) = the operator said \"yolo\" at that checkpoint: it answers that question and pre-confirms every later one (needs --confirmed; checks and guardrails stay); release --no-fold-check = operator-granted escape from the changelog fold proofs (the entries pending before the release are not line-checked; the entry heading and the 'this branch touched the changelog' proofs stay); release --no-version = this flow ships merge + changelog only — no bump, tag or forge release; the entry rides under Unreleased until the next versioned release folds it (default: versioned)";
|
|
163
166
|
const featDir = (root: string, slug: string) => path.join(dfDir(root), slug);
|
|
164
167
|
const stateFile = (root: string, slug: string) => path.join(featDir(root, slug), "state.json");
|
|
165
168
|
const claimFile = (root: string, slug: string) => path.join(featDir(root, slug), "claim.json");
|
|
@@ -902,19 +905,36 @@ ${mdDigest(draftRefresh)}`))
|
|
|
902
905
|
cfg.release.changelog && existsSync(path.join(wtCwd, cfg.release.changelog))
|
|
903
906
|
? { file: cfg.release.changelog, content: readFileSync(path.join(wtCwd, cfg.release.changelog), "utf8") }
|
|
904
907
|
: null;
|
|
905
|
-
//
|
|
906
|
-
//
|
|
907
|
-
//
|
|
908
|
-
let changelogChanged =
|
|
908
|
+
// The changelog's baseline is what was pending before this release. The newest tag wins over the
|
|
909
|
+
// merge base: it is what actually shipped, and a rebase or squash merge can leave the merge base
|
|
910
|
+
// unreachable — a git-topology accident must not refuse a legal release (#97).
|
|
911
|
+
let changelogChanged: boolean | null = null;
|
|
912
|
+
const changelogBase: { pending: string[]; source: "tag" | "merge-base" | "none" } = { pending: [], source: "none" };
|
|
909
913
|
if (changelog) {
|
|
914
|
+
const p = sq(cfg.release.changelog!);
|
|
910
915
|
const mb = await sh(`git merge-base origin/${sq(cfg.defaultBranch)} HEAD 2>/dev/null || git merge-base ${sq(cfg.defaultBranch)} HEAD 2>/dev/null || true`, wtCwd);
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
916
|
+
const mbRef = mb.ok ? mb.out.trim() : "";
|
|
917
|
+
// proof the branch touched the changelog: local refs only, so the check stays offline-safe
|
|
918
|
+
if (mbRef) {
|
|
919
|
+
const changes = await sh(`git diff --name-only ${sq(mbRef)} -- ${p} 2>/dev/null; git ls-files --others --exclude-standard -- ${p}`, wtCwd);
|
|
914
920
|
changelogChanged = changes.out.split("\n").some((l) => l.trim());
|
|
915
921
|
}
|
|
922
|
+
const newest = !state!.noVersion && cfg.versioning.file ? newestTaggedVersion(cfg.versioning.pattern, remoteTags) : null;
|
|
923
|
+
// tag first, merge base as the understudy: `releaseTags` asks origin, so a clone that has not
|
|
924
|
+
// fetched the tag yet must still get a baseline instead of losing the fold proof
|
|
925
|
+
const bases: { ref: string; source: "tag" | "merge-base" }[] = [];
|
|
926
|
+
if (newest) bases.push({ ref: cfg.versioning.pattern.replace("{version}", newest), source: "tag" });
|
|
927
|
+
if (mbRef) bases.push({ ref: mbRef, source: "merge-base" });
|
|
928
|
+
for (const b of bases) {
|
|
929
|
+
const base = await sh(`git show ${sq(b.ref)}:${p} 2>/dev/null || true`, wtCwd);
|
|
930
|
+
if (base.out.trim()) {
|
|
931
|
+
changelogBase.pending = pendingEntryLines(base.out);
|
|
932
|
+
changelogBase.source = b.source;
|
|
933
|
+
break;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
916
936
|
}
|
|
917
|
-
const prep = { manifestVersion: manifestVer, remoteTags, changelog, changelogChanged };
|
|
937
|
+
const prep = { manifestVersion: manifestVer, remoteTags, changelog, changelogChanged, changelogBase, noFoldCheck: flag("no-fold-check") };
|
|
918
938
|
// tier-2 pre-release confirmation is recorded by this very command, so it is excluded here
|
|
919
939
|
const preGate = preReleaseGate({ ...state!, confirmations: { ...state!.confirmations, "pre-release": { hash: checklistHash(items), at: now() } } }, cfg, prep);
|
|
920
940
|
if (preGate.length) return { text: `release gate FAILED:\n- ${preGate.join("\n- ")}`, isError: true };
|
|
@@ -927,11 +947,19 @@ ${mdDigest(draftRefresh)}`))
|
|
|
927
947
|
state!.confirmations = { ...state!.confirmations, "pre-release": { hash: checklistHash(items), at: now() } };
|
|
928
948
|
state!.approvals["pre-release"] = now();
|
|
929
949
|
state!.stage = "release";
|
|
950
|
+
// a skipped proof is never silent: the gate says which one and why (#97)
|
|
951
|
+
const foldNote = !changelog
|
|
952
|
+
? ""
|
|
953
|
+
: flag("no-fold-check")
|
|
954
|
+
? " Warning: the changelog fold proofs were skipped (--no-fold-check) — check that the entry carries what was pending."
|
|
955
|
+
: changelogBase.source === "none"
|
|
956
|
+
? " Warning: no tag or merge base to compare against, so the changelog fold was not proven — check the entry by hand."
|
|
957
|
+
: "";
|
|
930
958
|
// the version of record is fixed here, from the manifest this gate validated: release-done must not
|
|
931
959
|
// re-read a checkout that may still be behind (#52)
|
|
932
960
|
if (!state!.noVersion && manifestVer) state!.releaseVersion = manifestVer;
|
|
933
961
|
writeState(root, state!);
|
|
934
|
-
return { text: `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}.` : ""}\n${nextHint(state!, cfg)}` };
|
|
962
|
+
return { text: `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}.` : ""}${foldNote}\n${nextHint(state!, cfg)}` };
|
|
935
963
|
}
|
|
936
964
|
|
|
937
965
|
case "release-done": {
|
|
@@ -986,6 +1014,8 @@ ${mdDigest(draftRefresh)}`))
|
|
|
986
1014
|
// no checkpoint here — the operator's Release? answer covered the whole publication; everything left is objective checks
|
|
987
1015
|
const releasesWanted = !!manifestVer && !flag("no-release-create") && cfg.release.releases !== false;
|
|
988
1016
|
let ghNote = "";
|
|
1017
|
+
let bodyOfRecord: string | null = null; // the changelog entry the forge body must match (#97)
|
|
1018
|
+
let bodyNote = "";
|
|
989
1019
|
const forgeName = cfg.forge || detectForge((await sh("git remote get-url origin", root)).out);
|
|
990
1020
|
if (manifestVer && flag("no-release-create")) ghNote = "Forge release skipped (--no-release-create).";
|
|
991
1021
|
else if (manifestVer && !releasesWanted) ghNote = "no forge release created (release.releases = false — the playbook says publication is manual; a stale key is how a repo ends up with tags and an empty Releases page #85).";
|
|
@@ -996,22 +1026,25 @@ ${mdDigest(draftRefresh)}`))
|
|
|
996
1026
|
const forge = forgeName;
|
|
997
1027
|
if (forge === "self") ghNote = "Forge release skipped (forge=self — publication stays manual).";
|
|
998
1028
|
else {
|
|
999
|
-
//
|
|
1000
|
-
//
|
|
1029
|
+
// the body is the changelog entry for this version (#97); the tag annotation only stands in
|
|
1030
|
+
// when the changelog has no entry for it — and never the output of a failed command, which
|
|
1031
|
+
// is how a shell error became a release body (#51)
|
|
1001
1032
|
const notesRes = await sh(tagNotesCommand(tag), root);
|
|
1002
|
-
|
|
1003
|
-
let
|
|
1004
|
-
if (
|
|
1005
|
-
else if (looksLikeShellError(notes)) {
|
|
1006
|
-
notesNote = "no release notes (the tag command returned a shell error, not a body). ";
|
|
1007
|
-
notes = "";
|
|
1008
|
-
}
|
|
1009
|
-
if (!notes && !notesNote && cfg.release.changelog) {
|
|
1033
|
+
const annotation = notesRes.ok ? notesRes.out.trim() : "";
|
|
1034
|
+
let changelogText: string | null = null;
|
|
1035
|
+
if (cfg.release.changelog) {
|
|
1010
1036
|
const cl = path.join(gateCwd(root, state!), cfg.release.changelog);
|
|
1011
|
-
if (existsSync(cl))
|
|
1012
|
-
if (notes) notesNote = `notes from ${cfg.release.changelog}. `;
|
|
1037
|
+
if (existsSync(cl)) changelogText = readFileSync(cl, "utf8");
|
|
1013
1038
|
}
|
|
1014
|
-
|
|
1039
|
+
const picked = pickReleaseNotes({ changelog: changelogText, version: manifestVer, annotation });
|
|
1040
|
+
const notes = picked.notes;
|
|
1041
|
+
if (picked.source === "changelog") bodyOfRecord = notes;
|
|
1042
|
+
let notesNote = "";
|
|
1043
|
+
if (picked.source === "changelog") notesNote = `notes from ${cfg.release.changelog}. `;
|
|
1044
|
+
else if (picked.source === "annotation") notesNote = `notes from the ${tag} tag annotation — ${cfg.release.changelog ?? "no changelog"} has no ${manifestVer} entry, so the release page does not read like the changelog. `;
|
|
1045
|
+
else if (!notesRes.ok) notesNote = `no release notes (the tag command failed: ${tail(notesRes.out)}). `;
|
|
1046
|
+
else if (annotation && looksLikeShellError(annotation)) notesNote = "no release notes (the tag command returned a shell error, not a body). ";
|
|
1047
|
+
else notesNote = `no release notes (tag ${tag} carries no annotation${cfg.release.changelog ? ` and ${cfg.release.changelog} has no ${manifestVer} entry` : ""} — tag with git tag -a). `;
|
|
1015
1048
|
const cmd = forge === "gitlab"
|
|
1016
1049
|
? `glab release create ${sq(tag)} --name ${sq(tag)}${notes ? ` --notes ${sq(notes)}` : ""}`
|
|
1017
1050
|
: `gh release create ${sq(tag)} --title ${sq(tag)}${notes ? ` --notes ${sq(notes)}` : ""}`;
|
|
@@ -1036,6 +1069,22 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1036
1069
|
}
|
|
1037
1070
|
delete state!.forgeReleaseSkipped; // the forge has it, whatever the create call reported
|
|
1038
1071
|
ghNote += `${ghNote ? " " : ""}Release ${expectedTag} verified on ${forgeName}.`;
|
|
1072
|
+
// #97: the changelog entry is the release body — prove the forge kept it. gh normalizes the
|
|
1073
|
+
// markdown it stored, so the comparison normalizes too; on another forge say it was skipped
|
|
1074
|
+
// rather than guess at a JSON shape nobody pinned.
|
|
1075
|
+
if (bodyOfRecord !== null) {
|
|
1076
|
+
if (forgeName !== "github") bodyNote = `Release body proof skipped (forge=${forgeName}).`;
|
|
1077
|
+
else {
|
|
1078
|
+
const got = await sh(`gh release view ${sq(expectedTag)} --json body --jq .body`, root);
|
|
1079
|
+
if (!got.ok) bodyNote = `warning: could not read back the ${expectedTag} release body — compare it with ${cfg.release.changelog} by hand.`;
|
|
1080
|
+
else if (normalizeReleaseBody(got.out) !== normalizeReleaseBody(bodyOfRecord))
|
|
1081
|
+
return {
|
|
1082
|
+
text: `release gate FAILED:\n- the ${expectedTag} release body is not the ${cfg.release.changelog} entry for ${manifestVer} — publish the entry as the body: gh release edit ${expectedTag} --title ${expectedTag} --notes-file <(the entry)\n forge body starts: ${tail(normalizeReleaseBody(got.out), 4)}\n changelog entry starts: ${tail(normalizeReleaseBody(bodyOfRecord), 4)}`,
|
|
1083
|
+
isError: true,
|
|
1084
|
+
};
|
|
1085
|
+
else bodyNote = `Release ${expectedTag} body matches ${cfg.release.changelog}.`;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1039
1088
|
}
|
|
1040
1089
|
state!.approvals.release = now();
|
|
1041
1090
|
const tailNote = [
|
|
@@ -1043,6 +1092,7 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1043
1092
|
behind ? `warning: this session runs dev-flow ${behind}, not the build in the checkout — /reload before trusting what it printed.` : "",
|
|
1044
1093
|
openNote,
|
|
1045
1094
|
ghNote,
|
|
1095
|
+
bodyNote,
|
|
1046
1096
|
artNote,
|
|
1047
1097
|
].filter(Boolean).join(" ");
|
|
1048
1098
|
writeState(root, state!);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.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": [
|
package/skills/dev-flow/SKILL.md
CHANGED
|
@@ -236,17 +236,21 @@ invent one mid-release. Sequence:
|
|
|
236
236
|
3. Update the changelog and bump the manifest to the exact version you will
|
|
237
237
|
tag — manifest, changelog and tag must agree; commit the prep on the feature
|
|
238
238
|
branch. A versioned release **folds the `Unreleased` section** (entries
|
|
239
|
-
`--no-version` flows left there) under the new version heading
|
|
240
|
-
refuses while
|
|
239
|
+
`--no-version` flows left there) under the new version heading: the gate
|
|
240
|
+
refuses while entries remain, refuses a fold that **drops or rewrites** one
|
|
241
|
+
(move the lines as they are and reword afterwards in a follow-up), and
|
|
242
|
+
refuses a changelog this branch never touched. `--no-fold-check` skips only
|
|
243
|
+
the line proofs, on the operator's word.
|
|
241
244
|
4. `flow check` — the prep edits invalidated the implement checks; the release
|
|
242
245
|
gate demands them green again.
|
|
243
246
|
5. State what the PR will contain, present version and changelog entry,
|
|
244
247
|
**stop** — **Release?** → `flow release --confirmed`. The gate re-checks
|
|
245
|
-
tier-1, requires the manifest **ahead of the last tag
|
|
246
|
-
mention
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
changelog
|
|
248
|
+
tier-1, requires the manifest **ahead of the last tag**, a changelog
|
|
249
|
+
**heading** naming that version (a mention in prose is not an entry) and that
|
|
250
|
+
this branch prepared the entry. Operator ships this flow **without
|
|
251
|
+
version/tag** → `flow release --no-version --confirmed` — no bump, but the
|
|
252
|
+
changelog entry under `Unreleased` is still required: the gate proves the
|
|
253
|
+
branch **added a line there**, not that it edited some older section.
|
|
250
254
|
|
|
251
255
|
## Stage: release
|
|
252
256
|
|
|
@@ -275,9 +279,11 @@ the worktree unless noted:
|
|
|
275
279
|
the newest matching tag on origin (lists come from `git ls-remote`, so an
|
|
276
280
|
unfetched clone never decides what is tagged). It creates the forge release
|
|
277
281
|
— `gh` for GitHub, `glab` for GitLab, nothing for `forge = self`, advisory
|
|
278
|
-
note if a CLI or remote is missing; body = the
|
|
279
|
-
|
|
280
|
-
|
|
282
|
+
note if a CLI or remote is missing; body = the `release.changelog` entry for
|
|
283
|
+
that version — the changelog is what the release page must read like — else
|
|
284
|
+
the tag's annotation, else nothing with the reason printed (annotate with
|
|
285
|
+
`git tag -a`), and it reads the stored body back and refuses a mismatch
|
|
286
|
+
(#97) — and records the release;
|
|
281
287
|
`flow finish` closes the feature out. Skipping the forge release
|
|
282
288
|
(`--no-release-create`, once, or `release.releases = false`, always) and
|
|
283
289
|
the artifact check (`--no-artifact-check`, once) are operator calls only —
|
package/src/core.ts
CHANGED
|
@@ -230,17 +230,93 @@ export interface ReleasePrep {
|
|
|
230
230
|
remoteTags: string[];
|
|
231
231
|
/** Changelog file + content when release.changelog names a file that exists, else null. */
|
|
232
232
|
changelog: { file: string; content: string } | null;
|
|
233
|
-
/** True when the branch changed the changelog vs its
|
|
234
|
-
*
|
|
235
|
-
|
|
233
|
+
/** True when the branch changed the changelog vs its base — the proof a release prepared its own
|
|
234
|
+
* entry. null when no base resolves at all (a rebased or squash-merged branch): the proof is
|
|
235
|
+
* skipped with an advisory instead of refusing a legal release for a git-topology reason (#97). */
|
|
236
|
+
changelogChanged: boolean | null;
|
|
237
|
+
/** What the changelog held under Unreleased **before** this release, and where that came from: the
|
|
238
|
+
* newest tag (what actually shipped) or the branch's merge base; "none" = unprovable. */
|
|
239
|
+
changelogBase?: { pending: string[]; source: "tag" | "merge-base" | "none" };
|
|
240
|
+
/** Operator-granted escape from the line-level fold proofs (`flow release --no-fold-check`). */
|
|
241
|
+
noFoldCheck?: boolean;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** One changelog line as the fold proofs compare it: indentation, bullet style and whitespace runs are
|
|
245
|
+
* markdown jitter and do not count; a reworded or deleted line does (#97). */
|
|
246
|
+
export function normalizeEntryLine(line: string): string {
|
|
247
|
+
return line.trim().replace(/^[-*+]\s+/, "").replace(/\s+/g, " ");
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** The lines under the changelog's Unreleased heading (verbatim). Matches `## Unreleased` and
|
|
251
|
+
* `## [Unreleased]`; deeper `###` sub-headings stay inside the section; the next h1/h2 ends it. */
|
|
252
|
+
export function unreleasedBody(content: string): string[] {
|
|
253
|
+
const out: string[] = [];
|
|
254
|
+
let inside = false;
|
|
255
|
+
for (const line of content.split("\n")) {
|
|
256
|
+
if (/^#{1,2}\s/.test(line)) {
|
|
257
|
+
if (inside) break; // section ended
|
|
258
|
+
inside = /^#{2,3}\s*\[?Unreleased\]?\s*$/.test(line);
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
if (inside) out.push(line);
|
|
262
|
+
}
|
|
263
|
+
return out;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function entryLines(text: string): string[] {
|
|
267
|
+
// a section's sub-headings (`### Fixed`) are structure, not entries
|
|
268
|
+
return text
|
|
269
|
+
.split("\n")
|
|
270
|
+
.filter((l) => l.trim() && !/^#{1,6}\s/.test(l))
|
|
271
|
+
.map(normalizeEntryLine)
|
|
272
|
+
.filter(Boolean);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** The pending Unreleased entries, normalized: what a versioned release must carry into its own entry,
|
|
276
|
+
* and what an unversioned one must have added (#97). */
|
|
277
|
+
export function pendingEntryLines(content: string): string[] {
|
|
278
|
+
return entryLines(unreleasedBody(content).join("\n"));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** Pending lines the new version's entry does not carry — folded means moved, not deleted (#97). */
|
|
282
|
+
export function missingFoldedLines(basePending: string[], entryBody: string): string[] {
|
|
283
|
+
const have = new Set(entryLines(entryBody));
|
|
284
|
+
return basePending.filter((l) => !have.has(l));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** A release body as the forge stores it: trailing whitespace and outer blank lines are markdown
|
|
288
|
+
* normalization, not a different body (#97). */
|
|
289
|
+
export function normalizeReleaseBody(text: string): string {
|
|
290
|
+
return text
|
|
291
|
+
.replace(/\r\n/g, "\n")
|
|
292
|
+
.split("\n")
|
|
293
|
+
.map((l) => l.replace(/\s+$/, ""))
|
|
294
|
+
.join("\n")
|
|
295
|
+
.trim();
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* The body of a versioned forge release: the changelog entry for that version is the source of truth,
|
|
300
|
+
* so the release page and the changelog cannot drift apart (#97). The tag annotation is only a
|
|
301
|
+
* stand-in when the changelog has no entry for the version — and a shell complaint never becomes a
|
|
302
|
+
* release body (#51).
|
|
303
|
+
*/
|
|
304
|
+
export function pickReleaseNotes(src: { changelog: string | null; version: string | null; annotation: string }): { notes: string; source: "changelog" | "annotation" | "none" } {
|
|
305
|
+
const entry = src.changelog !== null && src.version ? changelogEntry(src.changelog, src.version) : "";
|
|
306
|
+
if (entry) return { notes: entry, source: "changelog" };
|
|
307
|
+
const ann = src.annotation.trim();
|
|
308
|
+
if (ann && !looksLikeShellError(ann)) return { notes: ann, source: "annotation" };
|
|
309
|
+
return { notes: "", source: "none" };
|
|
236
310
|
}
|
|
237
311
|
|
|
238
312
|
/**
|
|
239
313
|
* Gate: pre-release → release ("Release?"). Machine-proves the parts of release prep that can be
|
|
240
|
-
* proven — checks re-greened after the prep edits, manifest bumped past the last tag,
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
314
|
+
* proven — checks re-greened after the prep edits, manifest bumped past the last tag, and the
|
|
315
|
+
* changelog: a heading for the version being tagged, an entry this branch actually prepared, the
|
|
316
|
+
* entries that were pending before the release folded into it (not dropped), and nothing left under
|
|
317
|
+
* Unreleased. An unversioned (--no-version) flow skips the version rules but still owes a new entry
|
|
318
|
+
* under Unreleased. The git-dependent proofs (touched, folded) skip with an advisory when no base
|
|
319
|
+
* resolves; the content proofs always run (#97). Review/docs quality stays tier-2.
|
|
244
320
|
*/
|
|
245
321
|
export function preReleaseGate(state: FlowState, cfg: Config, prep: ReleasePrep): string[] {
|
|
246
322
|
const errs: string[] = [];
|
|
@@ -253,7 +329,22 @@ export function preReleaseGate(state: FlowState, cfg: Config, prep: ReleasePrep)
|
|
|
253
329
|
// but the merge still owes a changelog line under Unreleased, folded by the next versioned release
|
|
254
330
|
if (cfg.release.changelog) {
|
|
255
331
|
if (!prep.changelog) errs.push(`release.changelog "${cfg.release.changelog}" does not exist — an unversioned release must record its entry there (under Unreleased)`);
|
|
256
|
-
else
|
|
332
|
+
else {
|
|
333
|
+
if (prep.changelogChanged === false) errs.push(`${prep.changelog.file} is unchanged on this branch — an unversioned release must add its entry (under Unreleased)`);
|
|
334
|
+
// an unversioned release must leave a trail someone can find later: the section is where it lives,
|
|
335
|
+
// and a project with no changelog convention at all opts out with release.changelog = ""
|
|
336
|
+
if (!/^#{2,3}\s*\[?Unreleased\]?\s*$/m.test(prep.changelog.content)) {
|
|
337
|
+
errs.push(`${prep.changelog.file} has no Unreleased heading — an unversioned release records its entry there (add the heading, or set release.changelog = "" if this project keeps no changelog)`);
|
|
338
|
+
} else {
|
|
339
|
+
const pending = pendingEntryLines(prep.changelog.content);
|
|
340
|
+
if (!pending.length) errs.push(`${prep.changelog.file} has no entry under its Unreleased heading — an unversioned release rides there until the next versioned release folds it`);
|
|
341
|
+
else if (prep.changelogBase && prep.changelogBase.source !== "none" && !prep.noFoldCheck) {
|
|
342
|
+
const base = prep.changelogBase;
|
|
343
|
+
if (pending.every((l) => base.pending.includes(l)))
|
|
344
|
+
errs.push(`${prep.changelog.file}'s Unreleased section gained nothing on this branch (vs the ${base.source}) — add this release's own entry under the Unreleased heading, or skip the fold proofs with --no-fold-check`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
257
348
|
}
|
|
258
349
|
} else {
|
|
259
350
|
if (cfg.versioning.file) {
|
|
@@ -264,8 +355,19 @@ export function preReleaseGate(state: FlowState, cfg: Config, prep: ReleasePrep)
|
|
|
264
355
|
if (cfg.release.changelog) {
|
|
265
356
|
if (!prep.changelog) errs.push(`release.changelog "${cfg.release.changelog}" does not exist — prepare the changelog`);
|
|
266
357
|
else {
|
|
267
|
-
|
|
268
|
-
|
|
358
|
+
const entry = prep.manifestVersion ? changelogEntry(prep.changelog.content, prep.manifestVersion) : "";
|
|
359
|
+
if (prep.manifestVersion && !entry)
|
|
360
|
+
errs.push(`${prep.changelog.file} has no entry heading for version ${prep.manifestVersion} — add the heading (a mention in prose or a link is not an entry)`);
|
|
361
|
+
// the touched and fold proofs are about the release's own entry: a project with no version to
|
|
362
|
+
// tag has no entry to prepare, so it keeps the old contract (nothing pending under Unreleased)
|
|
363
|
+
if (prep.manifestVersion && prep.changelogChanged === false)
|
|
364
|
+
errs.push(`${prep.changelog.file} is unchanged on this branch — a release must prepare its entry in this branch, not inherit one`);
|
|
365
|
+
const base = prep.changelogBase;
|
|
366
|
+
if (entry && base && base.source !== "none" && !prep.noFoldCheck) {
|
|
367
|
+
const dropped = missingFoldedLines(base.pending, entry);
|
|
368
|
+
if (dropped.length)
|
|
369
|
+
errs.push(`${prep.changelog.file} drops ${dropped.length} Unreleased entr${dropped.length === 1 ? "y" : "ies"} from the ${base.source} under the ${prep.manifestVersion ?? "new"} heading — folding means moving them in as they are (reword afterwards, or skip with --no-fold-check):\n ${dropped.slice(0, 5).join("\n ")}${dropped.length > 5 ? `\n …(${dropped.length - 5} more)` : ""}`);
|
|
370
|
+
}
|
|
269
371
|
if (unreleasedPending(prep.changelog.content))
|
|
270
372
|
errs.push(`${prep.changelog.file} still has entries under Unreleased — fold them under the v${prep.manifestVersion ?? "new"} heading before releasing (they were left by --no-version flows)`);
|
|
271
373
|
}
|
|
@@ -279,16 +381,7 @@ export function preReleaseGate(state: FlowState, cfg: Config, prep: ReleasePrep)
|
|
|
279
381
|
* `## Unreleased` / `## [Unreleased]`; deeper `###` sub-headings stay inside the section, the
|
|
280
382
|
* next h1/h2 ends it; no section = nothing pending (the convention is opt-in). */
|
|
281
383
|
export function unreleasedPending(content: string): boolean {
|
|
282
|
-
|
|
283
|
-
for (const line of content.split("\n")) {
|
|
284
|
-
if (/^#{1,2}\s/.test(line)) {
|
|
285
|
-
if (inside) return false; // section ended without entries
|
|
286
|
-
inside = /^#{2,3}\s*\[?Unreleased\]?\s*$/.test(line);
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
if (inside && line.trim()) return true;
|
|
290
|
-
}
|
|
291
|
-
return false;
|
|
384
|
+
return unreleasedBody(content).some((l) => l.trim());
|
|
292
385
|
}
|
|
293
386
|
|
|
294
387
|
export function checklistHash(items: ChecklistItem[]): string {
|
|
@@ -434,7 +527,11 @@ export function looksLikeShellError(text: string): boolean {
|
|
|
434
527
|
export function changelogEntry(content: string, version: string): string {
|
|
435
528
|
const lines = content.split("\n");
|
|
436
529
|
const level = (l: string) => (l.match(/^#+/)?.[0].length ?? 99);
|
|
437
|
-
|
|
530
|
+
// the version must be what the heading names, not merely something it contains: `## [1.2.0]`,
|
|
531
|
+
// `## 1.2.0 - 2026-01-01` and `## [v1.2.0]` count, `## [1.2.0-beta]` and a sentence naming the
|
|
532
|
+
// version do not — the forge release body is taken from this section, so it must be the right one (#97)
|
|
533
|
+
const heading = new RegExp(`^#{1,3}\\s*\\[?v?${version.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\w.\\-])`);
|
|
534
|
+
const i = lines.findIndex((l) => level(l) <= 3 && heading.test(l));
|
|
438
535
|
if (i === -1) return "";
|
|
439
536
|
const base = level(lines[i]);
|
|
440
537
|
const out: string[] = [];
|
|
@@ -1218,7 +1315,7 @@ export function nextHint(state: FlowState, cfg: Config): string {
|
|
|
1218
1315
|
if (state.docs) return `implement in the worktree ${state.worktree} — docs mode runs no project command (no build, no dev deploy, no health probe); tick the tier-2 checklist with the operator, then ask them Verified? in chat and run flow verify --confirmed when they answer`;
|
|
1219
1316
|
return `implement in the worktree ${state.worktree}, add tests, run flow check (tier-1 checks, incl. health with seeded data); tick the tier-2 checklist with the operator, then ask them Verified? in chat and run flow verify --confirmed when they answer`;
|
|
1220
1317
|
case "pre-release":
|
|
1221
|
-
return `${cfg.release.review} → fix must-have/should-have → update docs${cfg.release.changelog ? ` → prepare ${cfg.release.changelog}` : ""}${cfg.versioning.file ? ` → bump version in ${cfg.versioning.file}` : ""}, re-run flow check, then show the operator the PR summary, version and changelog, ask Release? and run flow release`;
|
|
1318
|
+
return `${cfg.release.review} → fix must-have/should-have → update docs${cfg.release.changelog ? ` → prepare ${cfg.release.changelog} (a heading for the new version, carrying every pending Unreleased line over as it stands)` : ""}${cfg.versioning.file ? ` → bump version in ${cfg.versioning.file}` : ""}, re-run flow check, then show the operator the PR summary, version and changelog, ask Release? and run flow release`;
|
|
1222
1319
|
case "release":
|
|
1223
1320
|
return state.approvals.release
|
|
1224
1321
|
? "release recorded — commit and push the release chores in the main checkout (prefix the commit with DEV_FLOW_ALLOW_MAIN=1 — the installed pre-commit hook otherwise blocks main commits), ask the operator Finish? and run flow finish (removes worktree, branch and .dev-flow/" + state.slug + "/)"
|