pi-dev-flow 0.54.0 → 0.55.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 +13 -0
- package/README.md +3 -1
- package/docs/gates.md +4 -4
- package/docs/headless.md +5 -2
- package/extensions/dev-flow.ts +108 -15
- package/package.json +1 -1
- package/skills/dev-flow/SKILL.md +8 -3
- package/src/core.ts +25 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.55.1] - 2026-10-22
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **The guard no longer mistakes an unattributed command for a stage violation.** pi can register dev-flow twice in one process (the documented two-sources hazard — a project pointer beside the installed package), and *every* copy evaluates every guard hook: the copy that never served the flow call judges with an empty in-memory binding, and whenever a second unfinished feature exists — which kills the single-feature auto-bind that used to mask it — `git merge`/`push` to the default branch was refused with *'requires stage release'* while the bound feature sat at release the whole time (it blocked the v0.55.0 release's own chore git, live). The on-disk claim is now a binding: an unfinished feature whose `claim.json` carries this session's key attributes the call regardless of how many features are unfinished, so a second copy judges from disk instead of guessing. When attribution truly fails, the refusal says so — *not attributed to a bound feature (session key, which dev-flow, what to do)* — instead of lying about the stage. `flow version`, `status` and `start` also name every dev-flow copy registered in the process, and the README's two-sources warning says which copy to remove.
|
|
12
|
+
- **`flow finish` fast-forwards a main checkout that trails origin.** Close-out used to probe only `origin/<default>` (tag there, HEAD an ancestor), so a local main left behind by the release — exactly what a guard misattribution produces — passed silently and rotted. Now, once the checkout is clean and proven pushed, `finish` fast-forwards local `<default>` to `origin/<default>` with its own git (never a merge: a diverged or not-checked-out main prints the operator's exact `git pull --ff-only` command instead of touching it).
|
|
13
|
+
|
|
14
|
+
## [0.55.0] - 2026-10-22
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- **A stale session build is a question at `flow release`, not a stop.** Gates execute the dev-flow build the session loaded at start, and the checkout moves past it with every release — and shipping from behind had already cost releases: 0.53.0 and 0.53.1 were both published under 0.52.2 code (so #97's changelog proofs never fired and the release pages took tag annotations), and the 0.54.0 release itself ran under loaded 0.53.0, so its own new proofs (merge shape, artifact freshness) never fired in-session. The old answer was prose — *stop and ask the operator to `/reload` before publishing* — a refusal with no gate behind it, and a refusal is the wrong shape: publishing under an older gate is a legitimate operator choice (hotfix, offline reload), exactly the emergency the relaxed modes exist for. Now, when the loaded build is **behind** the checkout's, `flow release` prints both builds, lists the changelog versions that shipped between them (the proofs that will not run this release), and folds *update (`/reload`, then re-run) or proceed with the old release?* into the Release? question — still exactly one checkpoint. The decision is stamped into the release (`staleBuild`) and `release-done` repeats the acknowledgement in place of its bare after-the-fact warning, which stays as the backstop for headless runs; a session build **ahead** of the checkout's manifest is asked nothing, because no proof is missing there. `DEV_FLOW_LOADED_VERSION` lets the smoke suite stand in for an old session — the override can only ever make a gate more cautious, never lift a proof.
|
|
19
|
+
|
|
7
20
|
## [0.54.0] - 2026-10-22
|
|
8
21
|
|
|
9
22
|
### Added
|
package/README.md
CHANGED
|
@@ -52,7 +52,9 @@ pi install ./pi-dev-flow # or a local checkout
|
|
|
52
52
|
Later releases arrive with `pi update --extensions` (an npm install reconciles to the newest version);
|
|
53
53
|
then `/reload` — a running session keeps the code it loaded at startup. Two sources at once (a project
|
|
54
54
|
`git:` pin beside the global `npm:` package) load two copies — pi dedupes extensions by path, not by
|
|
55
|
-
package — so keep the one you actually update from
|
|
55
|
+
package — so keep the one you actually update from: `flow version` lists every dev-flow copy
|
|
56
|
+
registered in the process, and the on-disk session claim keeps the guard of a copy that never served
|
|
57
|
+
a flow call attributing your commands correctly.
|
|
56
58
|
|
|
57
59
|
Then, once per project repo, `/flow init`. It reads the repo (default branch and forge from git,
|
|
58
60
|
package manager, test/build/run conventions, version manifest) and writes **`.dev-flow/project.md`
|
package/docs/gates.md
CHANGED
|
@@ -10,15 +10,15 @@ so it needs no `--confirmed`.
|
|
|
10
10
|
| Gate | Advances | Refuses unless |
|
|
11
11
|
|---|---|---|
|
|
12
12
|
| `start <slug> [--ui] [--patch|--docs --confirmed] [--merge=squash\|merge\|rebase\|any] [--check-upstream]` | → plan | slug is new (binds the session); relaxed modes are operator-granted in chat, anchored by `--confirmed`: `--patch` = chore release, no plan document, every gate unchanged; `--docs` = docs-only, no plan document and no tier-1 checks (worktree and release intact). Start prints the dev-flow build and stamps it into the feature state (`flow status` shows `flow=<ver>`), warns when **this session runs an older build than the checkout** (`--check-upstream` also asks npm for the published one), prints the playbook gaps `flow doctor` would report — and **refuses while the playbook has no `merge` policy**: it names the question (squash / merge / rebase / any), the style its own history suggests, and the re-run `--merge=<style> --confirmed`, which writes the answer into `## release` (single-line insert, validated, `.bak` kept, committed as a playbook chore only when the playbook is the only dirty path) and never asks again |
|
|
13
|
-
| `use <slug>` | — (binds this session to a feature) | slug unfinished |
|
|
13
|
+
| `use <slug>` | — (binds this session to a feature) | slug unfinished — the binding is persisted to disk as a claim (`flow version` lists every dev-flow copy registered in the process, and a copy whose in-memory bindings never saw the bind attributes commands from the claim, so a two-sources setup does not misjudge your git) |
|
|
14
14
|
| `approve [--yolo]` | plan → implement (creates worktree + branch) | `plan/*.md` exists; if `--ui`, rendered mockup screenshots (per `mockupGlobs`, default `*.png`) exist under `plan/` — headless chromium renders embedded in plan.md; **one question** — or `--confirmed` after you answered in chat; **yolo** (your chat answer at **any** checkpoint question) → run that gate with `--yolo --confirmed` (`approve`/`verify`/`release`/`finish`): that question is answered and every later one (Verified?/Release?/Finish?) is pre-confirmed — the agent then runs the remaining gates back to back, honoring guidance attached to the yolo word (e.g. "yolo, create a patch version release") — checks and guardrails stay fully enforced. `commands.setup` runs in the worktree and is retried until it succeeds once (a worktree left behind by a failed setup is set up on the next `approve`, never silently reused); a `--docs` feature runs no project command at all and says `setup skipped (docs mode)` |
|
|
15
15
|
| `test` | records a check | — (runs the `test` command/check, records pass/fail) |
|
|
16
16
|
| `check` | records all tier-1 checks | — (runs every `flow-check`/test/health from project.md `## implement`); a `--docs` feature runs none of them and says `docs mode: project commands skipped` — a docs flow builds nothing, so a fresh checkout must not read as a failed deploy (#96) |
|
|
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|--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; **with a `merge` policy** it also proves the merge that shipped matches it — branch ancestry plus what the forge says (`gh pr view` / `glab api`), so a squash under `merge = merge` (or a merge commit under `merge = squash`) refuses the release record, while a shape it cannot see prints an advisory instead (#97's split: an invisible topology never blocks a legal release) |
|
|
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 commits with the playbook's `merge` policy in mind, and warns when the forge release create failed at `release-done` and no retry succeeded) — or `--confirmed`; under `merge = merge`, commits that never reached the default branch are a **policy violation**: `yolo` does not answer it, only your explicit answer does; to abandon an unreleased feature use `abort` |
|
|
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; **stale session build** (loaded build behind the checkout): the gate prints both builds, lists what shipped between them (those proofs will not run this release) and folds *update (/reload, then re-run) or proceed with the old release?* into the Release? question — the operator's word, recorded in the release output, **never a block**: publishing under an older gate is a legitimate choice (hotfix, offline reload) |
|
|
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; **with a `merge` policy** it also proves the merge that shipped matches it — branch ancestry plus what the forge says (`gh pr view` / `glab api`), so a squash under `merge = merge` (or a merge commit under `merge = squash`) refuses the release record, while a shape it cannot see prints an advisory instead (#97's split: an invisible topology never blocks a legal release); when the release went out on a stale build the operator acknowledged at the release gate, it prints that acknowledgement in place of the after-the-fact version-skew warning |
|
|
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; when the clean checkout trails `origin/<default>` the gate **fast-forwards local main** as it closes out (never a merge — anything that cannot fast-forward prints the operator's exact `git pull --ff-only` command); **one question** (Finish? — mentions unmerged-looking commits with the playbook's `merge` policy in mind, and warns when the forge release create failed at `release-done` and no retry succeeded) — or `--confirmed`; under `merge = merge`, commits that never reached the default branch are a **policy violation**: `yolo` does not answer it, only your explicit answer does; 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 |
|
|
24
24
|
| `doctor ["<issue note>"]` | — | read-only findings: playbook drift, dead commands/scripts, untracked playbook, ghost feature dirs, orphan worktrees/branches — **plus a review of every open reflection, each routed to the flow that should fix it** (playbook item → docs flow; plugin item → upstream issue, or a patch/normal flow inside the dev-flow repo). It writes nothing and asks nothing, safe for agents and CI at any stage; the agent investigates, you confirm, the routed flow implements. `doctor "<note>"` prints an investigation brief and a fix route for a fresh observation |
|
package/docs/headless.md
CHANGED
|
@@ -38,5 +38,8 @@ The contract a headless driver (a session with no UI) relies on:
|
|
|
38
38
|
- **Edits invalidate checks.** Any worktree write clears recorded checks and the tier-2
|
|
39
39
|
confirmation — re-run `flow check` before `verify` after the last edit.
|
|
40
40
|
- **Version skew.** Gates execute the dev-flow build the session loaded at start; `flow version`
|
|
41
|
-
reports when the checkout has moved ahead of it
|
|
42
|
-
|
|
41
|
+
reports when the checkout has moved ahead of it. `flow release` turns the skew into a question —
|
|
42
|
+
update (`/reload`, then re-run) or proceed with the old release — never a block: publishing under
|
|
43
|
+
an older gate is a legitimate choice. The operator's proceed is stamped into the release and
|
|
44
|
+
`release-done` repeats the acknowledgement (its after-the-fact warning stays for a release that
|
|
45
|
+
went out without the question being answered).
|
package/extensions/dev-flow.ts
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
appendRoadmapItem,
|
|
33
33
|
bashFlowGuard,
|
|
34
34
|
changelogEntry,
|
|
35
|
+
changelogVersionsBetween,
|
|
35
36
|
normalizeReleaseBody,
|
|
36
37
|
pendingEntryLines,
|
|
37
38
|
pickReleaseNotes,
|
|
@@ -113,8 +114,47 @@ import { detectProject } from "../src/detect.ts";
|
|
|
113
114
|
|
|
114
115
|
const execAsync = promisify(exec);
|
|
115
116
|
|
|
116
|
-
/** The dev-flow build this session actually loaded — see sessionRunsOlderBuild.
|
|
117
|
-
|
|
117
|
+
/** The dev-flow build this session actually loaded — see sessionRunsOlderBuild. Read at call time, and
|
|
118
|
+
* DEV_FLOW_LOADED_VERSION can stand in for it (the smoke suite runs gates in-process and needs to
|
|
119
|
+
* pretend it is an old session): the override can only ever make a gate more cautious — it never
|
|
120
|
+
* lifts a proof, it turns a release into a warn-and-ask. */
|
|
121
|
+
function loadedVersion(): string | null {
|
|
122
|
+
return process.env.DEV_FLOW_LOADED_VERSION?.trim() || pluginVersion(import.meta.dirname).version;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** This build's own identity, read once (the guard hot path must not re-walk the fs per call). */
|
|
126
|
+
const SELF_BUILD = pluginVersion(import.meta.dirname);
|
|
127
|
+
|
|
128
|
+
/** Cross-copy registry: one process can register dev-flow more than once (the documented
|
|
129
|
+
* two-sources-at-once hazard: a project dogfood pointer plus an installed copy), and EVERY copy
|
|
130
|
+
* evaluates every guard hook. The flow-tool binding belongs to whichever copy served the call,
|
|
131
|
+
* so the other copy judges from a missing binding — claims on disk (see boundFeature) keep its
|
|
132
|
+
* verdict honest, and these entries let `flow version`, `status` and `start` name the duplicate
|
|
133
|
+
* instead of leaving a misattribution a mystery. Same-process only: it is a globalThis list. */
|
|
134
|
+
interface CopyEntry {
|
|
135
|
+
dir: string;
|
|
136
|
+
version: string | null;
|
|
137
|
+
pid: number;
|
|
138
|
+
at: string;
|
|
139
|
+
}
|
|
140
|
+
const COPIES: CopyEntry[] = ((globalThis as { __piDevFlowCopies?: CopyEntry[] }).__piDevFlowCopies ??= []);
|
|
141
|
+
function registerCopy(): void {
|
|
142
|
+
const mine = COPIES.find((r) => r.dir === SELF_BUILD.dir && r.pid === process.pid);
|
|
143
|
+
if (mine) Object.assign(mine, { version: loadedVersion(), at: new Date().toISOString() });
|
|
144
|
+
else COPIES.push({ dir: SELF_BUILD.dir, version: loadedVersion(), pid: process.pid, at: new Date().toISOString() });
|
|
145
|
+
}
|
|
146
|
+
function otherCopies(): CopyEntry[] {
|
|
147
|
+
return COPIES.filter((r) => r.pid === process.pid && r.dir !== SELF_BUILD.dir);
|
|
148
|
+
}
|
|
149
|
+
function copyWarning(): string | null {
|
|
150
|
+
const dup = otherCopies();
|
|
151
|
+
return dup.length
|
|
152
|
+
? `warning: ${dup.length} other dev-flow cop${dup.length === 1 ? "y" : "ies"} registered in this process: ${dup.map((d) => `${d.dir} (${d.version ?? "?"})`).join(", ")} — every copy evaluates the guard hooks, so keep only one source you intend (README: two sources at once)`
|
|
153
|
+
: null;
|
|
154
|
+
}
|
|
155
|
+
/** Test seam: the smoke suite cannot load a second copy of this module, so it plants registry
|
|
156
|
+
* entries and asserts the warnings the real duplicate would print. */
|
|
157
|
+
export const testSeams = { copies: COPIES };
|
|
118
158
|
|
|
119
159
|
interface Ui {
|
|
120
160
|
hasUI: boolean;
|
|
@@ -241,7 +281,7 @@ async function releaseTags(root: string): Promise<string[] | null> {
|
|
|
241
281
|
}
|
|
242
282
|
|
|
243
283
|
const GATE_HELP =
|
|
244
|
-
"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] [--merge=squash|merge|rebase|any] [--check-upstream] | 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 [--check-upstream] — start preflights the playbook before creating anything: it prints playbook gaps and warns when the session runs an older dev-flow build, and it refuses until a merge policy is set (ask the operator squash / merge / rebase / any in chat, then re-run with --merge=<style> --confirmed — the answer is written into project.md and enforced from then on: gh/glab merges that contradict it are blocked, and release-done proves what actually landed); version prints the loaded build (--check-upstream also asks the registry for the published one) — 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)";
|
|
284
|
+
"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] [--merge=squash|merge|rebase|any] [--check-upstream] | 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 [--check-upstream] — start preflights the playbook before creating anything: it prints playbook gaps and warns when the session runs an older dev-flow build, and it refuses until a merge policy is set (ask the operator squash / merge / rebase / any in chat, then re-run with --merge=<style> --confirmed — the answer is written into project.md and enforced from then on: gh/glab merges that contradict it are blocked, and release-done proves what actually landed); version prints the loaded build and names any other dev-flow copies registered in the same process (--check-upstream also asks the registry for the published one) — 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); when the session runs an older dev-flow build than the checkout, release names both builds, lists what the running code can no longer prove, and asks the operator update (/reload) or proceed with the old release — an operator decision recorded in state and repeated by release-done, never a block";
|
|
245
285
|
const featDir = (root: string, slug: string) => path.join(dfDir(root), slug);
|
|
246
286
|
const stateFile = (root: string, slug: string) => path.join(featDir(root, slug), "state.json");
|
|
247
287
|
const claimFile = (root: string, slug: string) => path.join(featDir(root, slug), "claim.json");
|
|
@@ -315,6 +355,12 @@ function boundFeature(root: string, key: string): FlowState | null {
|
|
|
315
355
|
if (s && s.stage !== "done") return s;
|
|
316
356
|
}
|
|
317
357
|
const un = unfinishedStates(root);
|
|
358
|
+
// the claim is the persisted binding: bind() already stamps the session key into claim.json, so
|
|
359
|
+
// trust the disk after the in-memory map — a second registered dev-flow copy (both copies
|
|
360
|
+
// evaluate the guard hooks) or a re-instantiated module then attributes the session's own
|
|
361
|
+
// feature from disk instead of misjudging with stage null
|
|
362
|
+
const mine = un.find((s) => readClaim(root, s.slug)?.key === key);
|
|
363
|
+
if (mine) return mine;
|
|
318
364
|
if (un.length !== 1) return null;
|
|
319
365
|
const claim = readClaim(root, un[0].slug);
|
|
320
366
|
// shortcut: liveness is pid-only — pid reuse can read "live" and force an explicit flow use; friction only, never a wrong commit.
|
|
@@ -561,7 +607,7 @@ function reflectNote(root: string, sess: Session, note: string[]): RunResult {
|
|
|
561
607
|
async function runFlow(args: string[], root: string, ui: Ui, sess: Session): Promise<RunResult> {
|
|
562
608
|
const [sub = "status", ...rest] = args;
|
|
563
609
|
// help and version are questions about the plugin, not the repo: answerable with no .dev-flow/ at all
|
|
564
|
-
if (sub === "help" || sub === "--help" || sub === "-h") return { text: rest.includes("--json") ? gateHelpJson(GATE_HELP,
|
|
610
|
+
if (sub === "help" || sub === "--help" || sub === "-h") return { text: rest.includes("--json") ? gateHelpJson(GATE_HELP, loadedVersion()) : `usage: flow <sub> — ${GATE_HELP}` };
|
|
565
611
|
if (!existsSync(dfDir(root)) && sub !== "init" && sub !== "version") return { text: "no .dev-flow/ in this repo — run flow init first", isError: true };
|
|
566
612
|
const cfg = loadProject(dfDir(root)).cfg;
|
|
567
613
|
const flag = (name: string) => rest.includes(`--${name}`);
|
|
@@ -715,8 +761,10 @@ ${mdDigest(draftRefresh)}`))
|
|
|
715
761
|
// --- preflight: is this session running the current build, and is the playbook complete? ---
|
|
716
762
|
const notes: string[] = [];
|
|
717
763
|
const self = pluginVersion(import.meta.dirname);
|
|
718
|
-
const behind = sessionRunsOlderBuild(
|
|
764
|
+
const behind = sessionRunsOlderBuild(loadedVersion(), self.version);
|
|
719
765
|
if (behind) notes.push(`warning: this session runs dev-flow ${behind}, the checkout has ${self.version} — /reload before trusting what a gate prints`);
|
|
766
|
+
const dupStart = copyWarning();
|
|
767
|
+
if (dupStart) notes.push(dupStart);
|
|
720
768
|
if (flag("check-upstream")) {
|
|
721
769
|
const pub = await sh("npm view pi-dev-flow version", root);
|
|
722
770
|
const newest = pub.ok ? pub.out.trim().split("\n").pop() : "";
|
|
@@ -765,7 +813,7 @@ ${mdDigest(draftRefresh)}`))
|
|
|
765
813
|
const { md } = loadProject(df);
|
|
766
814
|
// cheap fs probes only (no git subprocesses) — status is a glance, `flow doctor` is the full list
|
|
767
815
|
const findings = md ? doctorFindings(root, cfg, md) : [];
|
|
768
|
-
const warn = findings.length ? [`⚠ doctor: ${findings.length} finding(s) — run flow doctor`] : [];
|
|
816
|
+
const warn = [...(findings.length ? [`⚠ doctor: ${findings.length} finding(s) — run flow doctor`] : []), ...(copyWarning() ? [copyWarning()!] : [])];
|
|
769
817
|
// the backlog nudge belongs to the no-features answer too — that is when a pick is most useful
|
|
770
818
|
const rmap = roadmapOpenCount(readRoadmap(root));
|
|
771
819
|
const rmapLine = rmap ? [`◇ ${rmap} roadmap item(s) open — flow roadmap`] : [];
|
|
@@ -869,15 +917,16 @@ ${mdDigest(draftRefresh)}`))
|
|
|
869
917
|
case "version": {
|
|
870
918
|
// the plugin's own version — separate from the project's versioning.file version the release gates use
|
|
871
919
|
const self = pluginVersion(import.meta.dirname);
|
|
872
|
-
const behind = sessionRunsOlderBuild(
|
|
920
|
+
const behind = sessionRunsOlderBuild(loadedVersion(), self.version);
|
|
873
921
|
const head = self.version ? `dev-flow ${self.version} (pi-dev-flow at ${self.dir})` : `dev-flow version unknown — no pi-dev-flow package.json above ${self.dir}`;
|
|
922
|
+
const dupNote = copyWarning();
|
|
874
923
|
// --check-upstream is the one that asks the registry; plain flow version stays offline and instant
|
|
875
924
|
if (flag("check-upstream")) {
|
|
876
925
|
const pub = await sh("npm view pi-dev-flow version", root);
|
|
877
926
|
const newest = pub.ok ? pub.out.trim().split("\n").pop() : "";
|
|
878
927
|
return { text: newest ? `${head} — published: ${newest}${self.version && newest !== self.version ? " (update available)" : ""}` : `${head} — could not read the published version (offline?)` };
|
|
879
928
|
}
|
|
880
|
-
return { text: behind ? `${head} — but this session runs ${behind}; /reload to run ${self.version}` : head };
|
|
929
|
+
return { text: `${behind ? `${head} — but this session runs ${behind}; /reload to run ${self.version}` : head}${dupNote ? `\n${dupNote}` : ""}` };
|
|
881
930
|
}
|
|
882
931
|
|
|
883
932
|
case "approve": {
|
|
@@ -1101,10 +1150,32 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1101
1150
|
// tier-2 pre-release confirmation is recorded by this very command, so it is excluded here
|
|
1102
1151
|
const preGate = preReleaseGate({ ...state!, confirmations: { ...state!.confirmations, "pre-release": { hash: checklistHash(items), at: now() } } }, cfg, prep);
|
|
1103
1152
|
if (preGate.length) return { text: `release gate FAILED:\n- ${preGate.join("\n- ")}`, isError: true };
|
|
1153
|
+
// a stale session build is the operator's decision, never a block: publishing under an older gate is a
|
|
1154
|
+
// legitimate choice (hotfix, offline reload), and refusing would close exactly the emergency the relaxed
|
|
1155
|
+
// modes exist for. The gate names both builds, lists what the running code is missing, and folds the
|
|
1156
|
+
// update-or-proceed question into the Release? checkpoint — the operator's word, recorded in state.
|
|
1157
|
+
const selfBuild = pluginVersion(import.meta.dirname);
|
|
1158
|
+
const behind = sessionRunsOlderBuild(loadedVersion(), selfBuild.version);
|
|
1159
|
+
// truly behind, not merely different: a session whose loaded build is NEWER than the checkout's manifest
|
|
1160
|
+
// has every proof the checkout would run, and asking about it would be noise.
|
|
1161
|
+
const stale = !!behind && !!selfBuild.version && cmpVersions(behind, selfBuild.version) < 0;
|
|
1162
|
+
let staleAsk = "";
|
|
1163
|
+
let staleNote = "";
|
|
1164
|
+
if (stale) {
|
|
1165
|
+
const clPath = path.join(selfBuild.dir, "CHANGELOG.md");
|
|
1166
|
+
const missing = existsSync(clPath) && selfBuild.version ? changelogVersionsBetween(readFileSync(clPath, "utf8"), behind, selfBuild.version) : [];
|
|
1167
|
+
staleAsk =
|
|
1168
|
+
` This session runs dev-flow ${behind}, the checkout ships ${selfBuild.version ?? "?"} — gate proofs shipped between the two will NOT run. ` +
|
|
1169
|
+
(missing.length
|
|
1170
|
+
? `Shipped since ${behind}: ${missing.slice(0, 8).join(", ")}${missing.length > 8 ? ` …(${missing.length} total)` : ""} — see ${clPath}. `
|
|
1171
|
+
: `What shipped between them is not readable from the checkout's CHANGELOG.md — read it before deciding. `) +
|
|
1172
|
+
`Update (/reload, then re-run flow release on the current build) or proceed with the old release?`;
|
|
1173
|
+
staleNote = `released under dev-flow ${behind} (checkout ${selfBuild.version ?? "?"}) by operator choice — proofs newer than ${behind} did not run`;
|
|
1174
|
+
}
|
|
1104
1175
|
const audit = flag("confirmed") ? " (confirmed by operator instruction)" : state!.yolo ? " (yolo: pre-confirmed)" : "";
|
|
1105
1176
|
if (!flag("confirmed") && !state!.yolo) {
|
|
1106
|
-
if (!ui.hasUI) return { text: needsOperator(
|
|
1107
|
-
const ok = await ui.confirm("Enter release", `Release ${state!.slug}${manifestVer ? ` v${manifestVer}` : ""}${state!.noVersion ? " (unversioned — merge + changelog entry only: no bump, no tag for this flow)" : ""}? Publishing starts: PR, merge${state!.noVersion ? "" : ", tag"} — release-done afterwards needs no further answer
|
|
1177
|
+
if (!ui.hasUI) return { text: needsOperator(`release confirmation needs the operator: confirm interactively, or re-run with --confirmed once the operator answered 'Release?' in chat${stale ? ` — the operator must also answer the stale-build question: ${staleAsk}` : ""}`, "Release?"), isError: true };
|
|
1178
|
+
const ok = await ui.confirm("Enter release", `Release ${state!.slug}${manifestVer ? ` v${manifestVer}` : ""}${state!.noVersion ? " (unversioned — merge + changelog entry only: no bump, no tag for this flow)" : ""}? Publishing starts: PR, merge${state!.noVersion ? "" : ", tag"} — release-done afterwards needs no further answer.${staleAsk ? `\n\n${staleAsk}` : ""}`);
|
|
1108
1179
|
if (!ok) return { text: "release declined — keep preparing in pre-release" };
|
|
1109
1180
|
}
|
|
1110
1181
|
state!.confirmations = { ...state!.confirmations, "pre-release": { hash: checklistHash(items), at: now() } };
|
|
@@ -1121,8 +1192,9 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1121
1192
|
// the version of record is fixed here, from the manifest this gate validated: release-done must not
|
|
1122
1193
|
// re-read a checkout that may still be behind (#52)
|
|
1123
1194
|
if (!state!.noVersion && manifestVer) state!.releaseVersion = manifestVer;
|
|
1195
|
+
if (stale) state!.staleBuild = `${behind} (checkout ${selfBuild.version ?? "?"})`;
|
|
1124
1196
|
writeState(root, state!);
|
|
1125
|
-
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)}` };
|
|
1197
|
+
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}${staleNote ? ` ${staleNote}.` : ""}\n${nextHint(state!, cfg)}` };
|
|
1126
1198
|
}
|
|
1127
1199
|
|
|
1128
1200
|
case "release-done": {
|
|
@@ -1233,7 +1305,7 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1233
1305
|
ghNote = gr.ok ? `${forge} release ${tag} created. ${notesNote}`.trim() : `${forge} release skipped: ${tail(gr.out)}`;
|
|
1234
1306
|
}
|
|
1235
1307
|
}
|
|
1236
|
-
const behind = sessionRunsOlderBuild(
|
|
1308
|
+
const behind = sessionRunsOlderBuild(loadedVersion(), pluginVersion(import.meta.dirname).version);
|
|
1237
1309
|
const openRelease = checklistPending(cfg, state!, "release");
|
|
1238
1310
|
// release-stage items have no gate of their own: the operator's Finish? answer is what closes them, so
|
|
1239
1311
|
// name them at the last objective gate — on the way out too, or the refusal hides half the story
|
|
@@ -1267,7 +1339,11 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1267
1339
|
state!.approvals.release = now();
|
|
1268
1340
|
const tailNote = [
|
|
1269
1341
|
// a session that shipped from behind: the code it runs is not the code the checkout just released
|
|
1270
|
-
|
|
1342
|
+
state!.staleBuild
|
|
1343
|
+
? `stale build acknowledged at release gate: this session ran dev-flow ${state!.staleBuild} — proofs newer than it did not run.`
|
|
1344
|
+
: behind
|
|
1345
|
+
? `warning: this session runs dev-flow ${behind}, not the build in the checkout — /reload before trusting what it printed.`
|
|
1346
|
+
: "",
|
|
1271
1347
|
mergeNote,
|
|
1272
1348
|
openNote,
|
|
1273
1349
|
ghNote,
|
|
@@ -1291,6 +1367,22 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1291
1367
|
const pushed = await sh(`git merge-base --is-ancestor HEAD ${sq(`origin/${cfg.defaultBranch}`)}`, root);
|
|
1292
1368
|
if (!pushed.ok) return { text: `HEAD is not on origin/${cfg.defaultBranch} — push the release (git push origin ${cfg.defaultBranch}) before finish`, isError: true };
|
|
1293
1369
|
}
|
|
1370
|
+
// close-out also syncs the main checkout: a released flow must never leave local
|
|
1371
|
+
// <default> trailing origin — the push check above proved nothing local-only remains, so a
|
|
1372
|
+
// differing sha means local trails and the fast-forward is safe. never a merge: a diverged
|
|
1373
|
+
// or not-checked-out main prints the operator's exact command instead of touching anything
|
|
1374
|
+
let syncNote = "";
|
|
1375
|
+
if (hasOriginF) {
|
|
1376
|
+
const headSha = await sh("git rev-parse HEAD", root);
|
|
1377
|
+
const originSha = await sh(`git rev-parse ${sq(`origin/${cfg.defaultBranch}`)}`, root);
|
|
1378
|
+
if (headSha.ok && originSha.ok && headSha.out.trim() !== originSha.out.trim()) {
|
|
1379
|
+
const onDefault = (await currentBranch(root)) === cfg.defaultBranch;
|
|
1380
|
+
const ff = onDefault ? await sh(`git merge --ff-only ${sq(`origin/${cfg.defaultBranch}`)}`, root) : { ok: false, out: "" };
|
|
1381
|
+
syncNote = ff.ok
|
|
1382
|
+
? ` local ${cfg.defaultBranch} fast-forwarded to origin/${cfg.defaultBranch}.`
|
|
1383
|
+
: ` local ${cfg.defaultBranch} trails origin/${cfg.defaultBranch} and did not fast-forward cleanly — sync by hand: git -C ${sq(root)} pull --ff-only`;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1294
1386
|
// the cleanup part of closing out: drop the worktree and branch the release consumed
|
|
1295
1387
|
const wt = worktreeAbs(root, state!);
|
|
1296
1388
|
let closeNote: string;
|
|
@@ -1380,7 +1472,7 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1380
1472
|
roadmapNote = ` roadmap: ${r.count} item(s) marked done.`;
|
|
1381
1473
|
}
|
|
1382
1474
|
}
|
|
1383
|
-
return { text: `feature ${state!.slug} done — ${closeNote}${remoteNote}; .dev-flow/${state!.slug}/ removed.${roadmapNote}${forgeSkipNote}` };
|
|
1475
|
+
return { text: `feature ${state!.slug} done — ${closeNote}${remoteNote}; .dev-flow/${state!.slug}/ removed.${roadmapNote}${forgeSkipNote}${syncNote}` };
|
|
1384
1476
|
}
|
|
1385
1477
|
|
|
1386
1478
|
case "use": {
|
|
@@ -1469,6 +1561,7 @@ async function askOperator(ctx: ExtensionContext, what: string, why: string): Pr
|
|
|
1469
1561
|
}
|
|
1470
1562
|
|
|
1471
1563
|
export default function devFlow(pi: ExtensionAPI) {
|
|
1564
|
+
registerCopy(); // which copy of dev-flow this is — see COPIES
|
|
1472
1565
|
/** Parse "flow <sub> [slug] [--flags]" args shared by command and tool. */
|
|
1473
1566
|
const parse = (input: unknown): string[] => {
|
|
1474
1567
|
if (Array.isArray(input)) return input.map(String);
|
|
@@ -1718,7 +1811,7 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
1718
1811
|
const dirty = await sh(`git -C ${sq(gitDir)} status --porcelain`, ctx.cwd);
|
|
1719
1812
|
playbookChore = dirty.ok && playbookOnlyChange(dirty.out);
|
|
1720
1813
|
}
|
|
1721
|
-
const reason = bashFlowGuard({ command: g.seg, branch, stage: bound?.stage ?? null, defaultBranch: cfg.defaultBranch, pushRefs, playbookChore, dir: gitDir });
|
|
1814
|
+
const reason = bashFlowGuard({ command: g.seg, branch, stage: bound?.stage ?? null, defaultBranch: cfg.defaultBranch, pushRefs, playbookChore, dir: gitDir, attribution: bound ? undefined : `not attributed to a bound feature (session ${key}; dev-flow ${loadedVersion() ?? "?"} at ${SELF_BUILD.dir}) — run flow use <slug> here if a binding is missing` });
|
|
1722
1815
|
if (reason) return { block: true, reason };
|
|
1723
1816
|
// Branch discipline: feature branches live in their worktree — never checked out or created (-b) in the main checkout
|
|
1724
1817
|
const target = checkoutTarget(g.seg);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.1",
|
|
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
|
@@ -299,9 +299,14 @@ the worktree unless noted:
|
|
|
299
299
|
`flow finish` closes the feature out. Skipping the forge release
|
|
300
300
|
(`--no-release-create`, once, or `release.releases = false`, always) and
|
|
301
301
|
the artifact check (`--no-artifact-check`, once) are operator calls only —
|
|
302
|
-
act when told, never on your own. If
|
|
303
|
-
|
|
304
|
-
|
|
302
|
+
act when told, never on your own. If this session runs an older build than
|
|
303
|
+
the checkout, **the release gate asks instead of blocking**: it prints both
|
|
304
|
+
builds, lists what shipped between them (those proofs will not run), and
|
|
305
|
+
puts the choice to the operator — **update (`/reload` and re-run) or
|
|
306
|
+
proceed with the old release?** Publishing under an older gate is a
|
|
307
|
+
legitimate choice (hotfix, offline reload); the answer is recorded in the
|
|
308
|
+
release output and `release-done` repeats the acknowledgement as the
|
|
309
|
+
backstop for headless runs.
|
|
305
310
|
Release-stage checklist items have no gate of their own: `release-done`
|
|
306
311
|
lists the open ones and the Finish? answer closes them.
|
|
307
312
|
|
package/src/core.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface FlowState {
|
|
|
40
40
|
setupAt?: string; // commands.setup exited 0 in this worktree — a reused worktree reruns it only when unset (#49)
|
|
41
41
|
releaseVersion?: string; // the manifest version the release gate approved — release-done publishes this, not whatever a checkout says later (#52)
|
|
42
42
|
forgeReleaseSkipped?: string; // a gh/glab release create that failed: release-done says so, finish names it so the missing forge release cannot slip past (#63)
|
|
43
|
+
staleBuild?: string; // release ran under an older dev-flow than the checkout by operator choice ("<loaded> (checkout <disk>)"); release-done repeats the acknowledgement
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/** Tier-2 item: operator prose; uiOnly items ("(ui)" in project.md) apply only to --ui features. */
|
|
@@ -460,6 +461,22 @@ export function sessionRunsOlderBuild(loaded: string | null, disk: string | null
|
|
|
460
461
|
return loaded && disk && loaded !== disk ? loaded : "";
|
|
461
462
|
}
|
|
462
463
|
|
|
464
|
+
/** The changelog's version headings strictly between `from` (exclusive) and `to` (inclusive), newest
|
|
465
|
+
* first — what a session running `from` is missing against a checkout on `to`, i.e. the gate proofs
|
|
466
|
+
* that will not run. Only `## [0.54.0]` / `## 0.54.0` headings with a parseable numeric-dot version
|
|
467
|
+
* count; everything else (Unreleased, prose, `v` prefixes) is skipped, and so are unparseable bounds. */
|
|
468
|
+
export function changelogVersionsBetween(changelog: string, from: string, to: string): string[] {
|
|
469
|
+
const versioned = (v: string) => /^\d+\.\d+\.\d+/.test(v);
|
|
470
|
+
if (!versioned(from) || !versioned(to)) return [];
|
|
471
|
+
const found: string[] = [];
|
|
472
|
+
for (const m of changelog.matchAll(/^##\s+\[?([^\]\s]+)\]?/gm)) {
|
|
473
|
+
const v = m[1];
|
|
474
|
+
if (!versioned(v) || found.includes(v)) continue;
|
|
475
|
+
if (cmpVersions(v, from) > 0 && cmpVersions(v, to) <= 0) found.push(v);
|
|
476
|
+
}
|
|
477
|
+
return found.sort((a, b) => cmpVersions(b, a));
|
|
478
|
+
}
|
|
479
|
+
|
|
463
480
|
/** Owner/slug from any GitHub repo reference — "owner/repo", "github.com/owner/repo", git+https or scp-style git@github.com:owner/repo.git; "" when it is not GitHub. */
|
|
464
481
|
export function githubSlug(ref: string): string {
|
|
465
482
|
const m = ref.match(/github\.com[/:]([\w.-]+\/[\w.-]+?)(?:\.git)?(?:\/|$)/) ?? /^[\w.-]+\/[\w.-]+$/.exec(ref);
|
|
@@ -674,6 +691,7 @@ export interface GuardCtx {
|
|
|
674
691
|
pushRefs?: PushRef[]; // caller-resolved push targets (bare names disambiguated tag vs branch); omit = guard parses raw command
|
|
675
692
|
playbookChore?: boolean; // the only change in this checkout is the playbook — tracking it is setup, not feature work (#53)
|
|
676
693
|
dir?: string; // absolute directory this segment runs in; named in the refusal so a wrong verdict is diagnosable
|
|
694
|
+
attribution?: string; // why the call could not be attributed to a bound feature; appended to the stage refusals when stage is null, so a misattribution names itself instead of lying about the stage
|
|
677
695
|
}
|
|
678
696
|
|
|
679
697
|
const unquote = (s: string): string => s.replace(/^(['"])(.*)\1$/, "$2");
|
|
@@ -912,15 +930,19 @@ export function bashFlowGuard(o: GuardCtx): string | null {
|
|
|
912
930
|
// a cd earlier in the command picks the directory this verdict is about — name it, or a misjudged segment
|
|
913
931
|
// reads as "the rule is broken" instead of "the guard looked in the wrong place".
|
|
914
932
|
const judgedIn = o.dir ? ` — judged in ${o.dir}; a cd or git -C earlier in the command picks the directory` : "";
|
|
915
|
-
|
|
933
|
+
// an unattributed refusal must admit it is guessing: "requires stage release" reads as a verdict on
|
|
934
|
+
// the feature when the real finding is "I never found your feature" (a second registered dev-flow
|
|
935
|
+
// copy judging with no bindings of its own — see boundFeature's claim path)
|
|
936
|
+
const attr = o.stage === null && o.attribution ? ` — ${o.attribution}` : "";
|
|
937
|
+
if (git("commit") && onMain && o.stage !== "release" && !playbookCommit) return `direct commits to ${o.defaultBranch} are forbidden — work in the feature worktree (tracking the playbook is legal: git add -f .dev-flow/project.md && DEV_FLOW_ALLOW_MAIN=1 git commit)${judgedIn}${attr}`;
|
|
916
938
|
if (git("push")) {
|
|
917
939
|
// ref-aware: only pushes that WRITE the default branch need stage release — tags and other branches pass.
|
|
918
940
|
// unresolved bare names arrive pre-resolved by the caller (tag vs branch); no parse info → conservative onMain.
|
|
919
941
|
const refs = o.pushRefs ?? parsePushRefs(gitInvocation(c).pushes);
|
|
920
942
|
const writesDefault = refs.some((r) => (r.kind === "branch" && (r.name === o.defaultBranch || r.name === "*")) || (r.kind === "current" && onMain));
|
|
921
|
-
if (writesDefault && o.stage !== "release") return `pushing to ${o.defaultBranch} requires stage "release" (verified feature)`;
|
|
943
|
+
if (writesDefault && o.stage !== "release") return `pushing to ${o.defaultBranch} requires stage "release" (verified feature)${attr}`;
|
|
922
944
|
}
|
|
923
|
-
if (git("merge") && onMain && o.stage !== "release") return `merging into ${o.defaultBranch} requires stage "release"`;
|
|
945
|
+
if (git("merge") && onMain && o.stage !== "release") return `merging into ${o.defaultBranch} requires stage "release"${attr}`;
|
|
924
946
|
return null;
|
|
925
947
|
}
|
|
926
948
|
|