pi-dev-flow 0.95.2 → 0.96.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 +19 -0
- package/docs/gates.md +22 -8
- package/docs/playbook.md +1 -1
- package/docs/reflections.md +1 -1
- package/package.json +1 -1
- package/skills/dev-flow/SKILL.md +1 -1
- package/skills/dev-flow/references/finish.md +3 -1
- package/skills/dev-flow/references/implement.md +5 -7
- package/skills/dev-flow/references/plan.md +8 -2
- package/skills/dev-flow/references/pre-release.md +14 -7
- package/skills/dev-flow/references/reflect.md +6 -3
- package/src/core.ts +93 -27
- package/src/projectmd.ts +1 -1
- package/src/runtime/base.ts +20 -2
- package/src/runtime/gates.ts +53 -5
- package/src/runtime/publish.ts +60 -18
- package/src/runtime/ship.ts +56 -63
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,25 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.96.1] - 2026-11-23
|
|
8
|
+
|
|
9
|
+
**A fold flow (started with `--reflections`) always merges unreleased with no release call, and finishes without the closing reflection.**
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- **A fold flow merges unreleased and skips the closing reflection.** A flow started with `--reflections` (the start `flow reflect plan` prints) fixes reflection notes. On a versioned project it now always merges unreleased: Approve? asks no release call, the entry goes under Unreleased, and `--version=<kind>` or `flow bump <kind>` is refused. `flow finish` no longer runs the closing reflection on it, whatever the friction or `reflect = always`, so a clean fold flow's Finish? answers itself. `flow doctor` and the "fix the open reflections now?" nudge point at `flow reflect plan` instead of a bare `flow start … --docs|--patch`, so every fold flow is linked to the notes it closes.
|
|
13
|
+
|
|
14
|
+
## [0.96.0] - 2026-11-23
|
|
15
|
+
|
|
16
|
+
**The release call is a kind of bump (patch, minor, major or unreleased) made at Approve?, changeable until the tag; the tag takes the number the merge commit's version file carries. Also: lettuce-style versions order and bump by their x.y.z part, and a tag-push run no longer counts as the merge commit's CI.**
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- **The release call is a kind of bump, made at Approve?, and no number is fixed before the tag.** On a versioned project, Approve? now also asks *patch, minor or major, or merge unreleased?* (`flow approve --confirmed --version=<kind>` or `--no-version`). An Approve? answer without the call is refused and nothing is kept. No later gate asks it again. The operator can change it at any point until the tag: `flow bump <patch|minor|major|none> --confirmed`, or `--version` / `--no-version` on a confirmed `verify` or `release` call, including a resumed publish. An exact number (`--version=1.2.0`) is no longer accepted, because the number is always counted from the newest tag. A flow approved by an older dev-flow, with no call on record, is still asked at Verified?.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
- **`flow release` no longer tags a number the merged tree doesn't carry.** Release? used to fix the version it saw at that moment. If another flow released first, the publish step stopped on a conflict and the agent re-bumped the branch, as told. The gate then tagged the old number anyway, on a merge commit whose version file said otherwise. CI refused to publish it, and every re-run pushed the stale tag again. Now no number is fixed at Release?. Before the merge, the gate checks the branch's version against the newest tag and names the number to re-bump to (alongside the conflict, when there is one). At the tag, it reads the version file at the merge commit and checks it against the call once more. A tag of the same name already on another commit stops the release instead of being taken as done.
|
|
23
|
+
- **Release-gate version checks read the x.y.z part.** A version such as `v0.49.1-letta_0.34.68` broke the bump arithmetic (the call went unchecked) and the newest-tag ordering (the suffix decided which tag was newest). Versions now order and bump by their x.y.z core, with any prefix or suffix kept by the project.
|
|
24
|
+
- **A failed run started by a tag push no longer counts as the merge commit's CI.** That run is the release's publish job, not a check on the merge. A refused tag used to block the next tag attempt as "merge commit checks failed".
|
|
25
|
+
|
|
7
26
|
## [0.95.2] - 2026-11-20
|
|
8
27
|
|
|
9
28
|
**`flow release` stops waiting on a check that GitHub left stuck at "in progress" after its job finished.**
|
package/docs/gates.md
CHANGED
|
@@ -53,7 +53,7 @@ the session. It also takes over a feature another session holds. Nothing binds a
|
|
|
53
53
|
|
|
54
54
|
## approve: Approve?
|
|
55
55
|
|
|
56
|
-
`flow approve [--yolo]`
|
|
56
|
+
`flow approve [--yolo] [--version=patch|minor|major | --no-version]`
|
|
57
57
|
|
|
58
58
|
- `plan/plan.md` must exist with exactly that name.
|
|
59
59
|
- For a `--ui` feature, every screenshot under `plan/` must be embedded in plan.md, every
|
|
@@ -62,6 +62,16 @@ the session. It also takes over a feature another session holds. Nothing binds a
|
|
|
62
62
|
- On yes, it creates the worktree and the `feat/<slug>` branch, then runs `setup` there. If setup
|
|
63
63
|
fails, the next `approve` retries it.
|
|
64
64
|
|
|
65
|
+
**The release call rides on Approve?** On a versioned project with `version = ask` (the default),
|
|
66
|
+
the question also asks: *patch, minor or major release, or merge unreleased?* Your answer is recorded
|
|
67
|
+
with `--version=<kind>` or `--no-version`; an Approve? answer without it is refused and nothing is
|
|
68
|
+
kept. Only the kind of step is recorded, never a number: the number is counted from the newest tag
|
|
69
|
+
when the release runs, so a flow that released first moves yours along instead of colliding with it.
|
|
70
|
+
No later gate asks the call again. You can change it at any point until the tag is cut: say so,
|
|
71
|
+
and the agent runs `flow bump <patch|minor|major|none> --confirmed`, or passes
|
|
72
|
+
`--version=<kind>` / `--no-version` on a confirmed `verify` or `release` call. A fold flow — one started with `--reflections`, as `flow reflect plan` prints it — is never asked the call: on a versioned project it always merges unreleased, and `--version=<kind>` or `flow bump <kind>` is refused. A flow approved by an
|
|
73
|
+
older dev-flow, with no call on record, is asked at Verified? instead.
|
|
74
|
+
|
|
65
75
|
## test, check, health
|
|
66
76
|
|
|
67
77
|
- `flow test` runs the `test` command and records the result.
|
|
@@ -94,10 +104,6 @@ It refuses if:
|
|
|
94
104
|
- a check, the build or the post-deploy health probe fails;
|
|
95
105
|
- `servedBuild` is set and the running app isn't serving this commit.
|
|
96
106
|
|
|
97
|
-
**The release call rides on Verified?** On a versioned project with `version = ask` (the default),
|
|
98
|
-
the question also asks: *patch, minor or major release, or merge unreleased?* Your answer is recorded
|
|
99
|
-
with `--version=…` or `--no-version`.
|
|
100
|
-
|
|
101
107
|
With `--confirmed`, it never rewrites history. If main moved since the review deploy, re-run
|
|
102
108
|
`flow verify`. It also doesn't build or deploy a second time: when the tree is the one it deployed for
|
|
103
109
|
your review, it only checks that the app still answers. If the tree changed, or the app stopped
|
|
@@ -117,12 +123,14 @@ probes on the current tree and asks Verified? again. A standing yolo never answe
|
|
|
117
123
|
|
|
118
124
|
## release: Release?
|
|
119
125
|
|
|
120
|
-
`flow release [--yolo] [--version=<
|
|
126
|
+
`flow release [--yolo] [--version=<kind> | --no-version] [--no-fold-check] [--no-marker-check]`
|
|
121
127
|
|
|
122
128
|
Proves the branch is ready to ship:
|
|
123
129
|
|
|
124
130
|
- **The version** matches your release call. Patch, minor or major is counted from the newest tag
|
|
125
|
-
at release time, so if a parallel flow shipped first, yours moves to the next number.
|
|
131
|
+
at release time, so if a parallel flow shipped first, yours moves to the next number. Versions
|
|
132
|
+
that carry more than x.y.z (a `v` prefix, a suffix such as `-letta_0.34.68`) are ordered and
|
|
133
|
+
bumped by their x.y.z part.
|
|
126
134
|
- **The version is new**: the manifest's version isn't tagged yet.
|
|
127
135
|
- **The changelog** has a heading for this version, this branch edited it, every entry that was
|
|
128
136
|
pending under `Unreleased` is kept in the new section, and `Unreleased` is now empty.
|
|
@@ -163,12 +171,18 @@ On GitHub, the same `flow release` call then publishes. Your Release? answer is
|
|
|
163
171
|
(`.github/pull_request_template.md`), the gate refuses until `pr-body.md` exists, before
|
|
164
172
|
Release? is asked, so the template's sections are filled before the merge.
|
|
165
173
|
2. Checks the branch merges cleanly into the default branch. On a conflict it names the files and pushes nothing.
|
|
174
|
+
It also checks the version again against the newest tag: if another release landed since Release?, it
|
|
175
|
+
names the number to re-bump to (with the conflict, when there is one) and merges nothing until the branch
|
|
176
|
+
carries it.
|
|
166
177
|
3. Waits for the PR's CI, up to 30 minutes. A repo with no CI is given a minute for checks to show up. A check pending for 5 minutes has its Actions job asked directly: GitHub can leave a check run `in_progress` after its job finished, and the job's result is used then.
|
|
167
178
|
4. Merges in the playbook's `merge` style.
|
|
168
179
|
5. Waits for the merge commit's own CI to go green, because the tag publishes from that commit. If it's red, the
|
|
169
180
|
gate stops without tagging. If no CI runs on that commit, it tags after a minute. `tagWait = none` under
|
|
170
181
|
`## release` skips this wait.
|
|
171
|
-
6. Creates an annotated tag on the PR's merge commit and pushes it (versioned flows).
|
|
182
|
+
6. Creates an annotated tag on the PR's merge commit and pushes it (versioned flows). The tag is the version
|
|
183
|
+
file **at that merge commit**, checked against your call one last time. No number is fixed earlier, so a
|
|
184
|
+
re-bump after a merge of the default branch is what gets tagged. A tag of the same name on another commit
|
|
185
|
+
stops it. A failed run that a tag push started does not count as the merge commit's CI.
|
|
172
186
|
7. Records the release (below).
|
|
173
187
|
|
|
174
188
|
Each step first asks GitHub whether it's already done, so a re-run picks up where it stopped, and a
|
package/docs/playbook.md
CHANGED
|
@@ -171,7 +171,7 @@ These go under `## pre-release` or `## release`. Either section works.
|
|
|
171
171
|
| `versionTag` | `v{version}` | tag format |
|
|
172
172
|
| `changelog` | `CHANGELOG.md` | set it empty (`changelog =` or `changelog = ""`) to opt out |
|
|
173
173
|
| `merge` | *(asked)* | how a PR lands: `squash`, `merge`, `rebase` or `any`. See below. |
|
|
174
|
-
| `version` | `ask` | who makes the release call: `ask` (you, at
|
|
174
|
+
| `version` | `ask` | who makes the release call: `ask` (you, at Approve? — the kind of bump, changeable until the tag), or `versioned` / `unversioned` for every flow |
|
|
175
175
|
| `ask` | `on-change` | `on-change`: Release? answers itself when only release prep changed. `always`: ask every time. |
|
|
176
176
|
| `finish` | `on-change` | `on-change`: Finish? answers itself when nothing is open (see [gates](gates.md#finish-finish)). `always`: ask every time. |
|
|
177
177
|
| `publish` | `gate` | `gate`: on GitHub, `flow release` pushes, opens the PR, waits for CI, merges and tags itself. `manual`: the agent runs those steps. Other forges are always manual. |
|
package/docs/reflections.md
CHANGED
|
@@ -50,7 +50,7 @@ The review is skipped when the flow ran into no friction: no guard block, no gat
|
|
|
50
50
|
process reason (wrong stage, a missing plan, a proof that doesn't hold), no gate refusing twice in a
|
|
51
51
|
row, no code change after Verified?, and no `--note`. A failing test or build is not friction by
|
|
52
52
|
itself: finding it is what the checks are for. Set `reflect = always` in the playbook's `## release` section to run it every time. Only
|
|
53
|
-
your explicit `--no-reflect` skips it; *yolo* doesn't.
|
|
53
|
+
your explicit `--no-reflect` skips it; *yolo* doesn't. A fold flow (started with `--reflections`) never runs it: it fixes notes, it doesn't review for new ones.
|
|
54
54
|
|
|
55
55
|
## Nudges
|
|
56
56
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.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
|
@@ -42,7 +42,7 @@ criteria hold. Call it with an args array — `["start", "dark-mode"]`,
|
|
|
42
42
|
internal identifiers; give depth when asked.
|
|
43
43
|
- **yolo** at a checkpoint → that gate with `--yolo --confirmed`; run the
|
|
44
44
|
remaining gates back to back without asking, honoring guidance attached to
|
|
45
|
-
the word ("yolo, patch bump"
|
|
45
|
+
the word ("yolo, patch bump" → `--version=patch`, "yolo, no tag" → `--no-version`). Checks,
|
|
46
46
|
guard rules and any `NEEDS-OPERATOR` still apply.
|
|
47
47
|
- **One session = one feature** (flow + branch + worktree). `flow start <slug>`
|
|
48
48
|
binds a new one, `flow use <slug>` takes one over; nothing auto-binds, and an
|
|
@@ -8,7 +8,9 @@ unbinds the session — so anything that needs them runs first.
|
|
|
8
8
|
1. **`flow finish [--note="<friction the operator mentioned>"]`**
|
|
9
9
|
- Published by hand and not recorded yet → it runs the release record
|
|
10
10
|
first (no question).
|
|
11
|
-
- **Closing reflection** —
|
|
11
|
+
- **Closing reflection** — skipped on a fold flow (started with
|
|
12
|
+
`--reflections`: it fixes reflections, it doesn't review for new ones).
|
|
13
|
+
Otherwise, while none is recorded, a read-only worker
|
|
12
14
|
reviews this session's transcript and every worker transcript, dedupes
|
|
13
15
|
against `.dev-flow/reflections.md` and upstream issues, and returns
|
|
14
16
|
numbered findings, each **docs** / **code** / **plugin** with a **fold**
|
|
@@ -49,13 +49,11 @@ note). Other sessions' worktrees are theirs.
|
|
|
49
49
|
— say what changed for the user and how to see it, not which modules
|
|
50
50
|
changed.
|
|
51
51
|
Report opening: **🔨 implement · `<slug>`** (the gate's stage line).
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
3. Answer → `flow verify --confirmed` (yolo → `--yolo --confirmed`), plus
|
|
58
|
-
`--version=patch|minor|major` (or `--version=<exact>`) or `--no-version`. It does not
|
|
52
|
+
- The release call was made at Approve? and is not asked again. Only a flow
|
|
53
|
+
approved by an older dev-flow, with no call on record, gets it asked here.
|
|
54
|
+
If the operator changes it now, pass `--version=<kind>` / `--no-version`
|
|
55
|
+
with the answer.
|
|
56
|
+
3. Answer → `flow verify --confirmed` (yolo → `--yolo --confirmed`). It does not
|
|
59
57
|
deploy again when the tree is the one it deployed for review — it only
|
|
60
58
|
probes that the app still answers. If the
|
|
61
59
|
default branch moved since the review deploy it refuses: run `flow verify`
|
|
@@ -52,8 +52,14 @@ No code edits before approval. Reads are always allowed.
|
|
|
52
52
|
verify the state in the DOM and move on.
|
|
53
53
|
5. **Ask Approve? and stop.** Report opening: **📝 plan · `<slug>`** (the
|
|
54
54
|
gate's stage line). A `--patch` / `--docs` flow: name the mode and the
|
|
55
|
-
one-line change in the question — the answer grants the mode.
|
|
56
|
-
|
|
55
|
+
one-line change in the question — the answer grants the mode. Versioned project with playbook `version = ask`
|
|
56
|
+
(the default): the same question asks the **release call** — a patch, minor or major release (propose one by
|
|
57
|
+
the playbook's versioning rule) or merge unreleased. Only the kind is recorded, never a number: the gate counts
|
|
58
|
+
it from the newest tag when the release runs. Answer → `flow approve --confirmed --version=patch|minor|major` or
|
|
59
|
+
`--no-version` (yolo → add `--yolo`); without the call the gate refuses and keeps nothing.
|
|
60
|
+
The call is not asked again. The operator can change it at any later point until the tag: `flow bump
|
|
61
|
+
<patch|minor|major|none> --confirmed`, or `--version=<kind>` / `--no-version` on a confirmed verify or release call.
|
|
62
|
+
A fold flow — one started with `--reflections`, as `flow reflect plan` prints it — carries no call: on a versioned project it always merges unreleased, and `--version=<kind>` or `flow bump <kind>` is refused.
|
|
57
63
|
|
|
58
64
|
Approval creates the worktree and branch and runs `commands.setup` there; a
|
|
59
65
|
failing setup fails the gate and the next approve retries it. `(ui)` playbook
|
|
@@ -19,11 +19,17 @@ and settle the scheme with the operator; never invent one.
|
|
|
19
19
|
`flow release` refuses while that re-verify is unanswered.
|
|
20
20
|
2. **Docs**: update them to match the change.
|
|
21
21
|
3. **Changelog + bump** — manifest, changelog heading and tag must agree;
|
|
22
|
-
commit the prep on the feature branch. The release call
|
|
23
|
-
|
|
24
|
-
names the number — another flow that released first moves it
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
commit the prep on the feature branch. The release call made at Approve?
|
|
23
|
+
decides which: its kind of step, counted from the newest tag (the gate
|
|
24
|
+
names the number — another flow that released first moves it, and the
|
|
25
|
+
gate re-checks it before the merge and again at the tag), or *merge
|
|
26
|
+
unreleased* — no bump, the line goes under `Unreleased`. A project whose
|
|
27
|
+
versions carry more than x.y.z (a `v` prefix, a suffix) keeps those parts;
|
|
28
|
+
the call governs the x.y.z.
|
|
29
|
+
- **Another release landed first** (`flow release` stops: conflict, or "must
|
|
30
|
+
be <x.y.z>") → merge the default branch in, set the version file and its
|
|
31
|
+
changelog heading to the number the gate names, commit, re-run. Never
|
|
32
|
+
tag by hand around it: the gate tags the merged tree's own version.
|
|
27
33
|
- **The changelog writer reviews the branch, not its commit list**: read
|
|
28
34
|
`git log <default>..HEAD` *and* `git diff <default>...HEAD`, then write
|
|
29
35
|
what the branch delivers in the reader's terms (what was broken, what
|
|
@@ -65,8 +71,9 @@ and settle the scheme with the operator; never invent one.
|
|
|
65
71
|
as `--yolo`: the operator's answer is `flow release --confirmed`.
|
|
66
72
|
- Operator ships **without a version** → `flow release --no-version
|
|
67
73
|
--confirmed`: no bump or tag, but the branch must add its line under
|
|
68
|
-
`Unreleased`. A changed call is `--version=<
|
|
69
|
-
`--confirmed
|
|
74
|
+
`Unreleased`. A changed call is `--version=<kind>` / `--no-version` with
|
|
75
|
+
`--confirmed` (or `flow bump <kind> --confirmed`), on their word — taken
|
|
76
|
+
on any call until the tag, a resumed publish included.
|
|
70
77
|
|
|
71
78
|
The gate runs any tier-1 check that is stale, requires the manifest ahead of the last tag and a
|
|
72
79
|
changelog **heading** for that version written on this branch.
|
|
@@ -8,8 +8,8 @@ friction only, never the same issue twice. `.dev-flow/reflections.md` holds
|
|
|
8
8
|
|
|
9
9
|
| Command | Files under | Fixed by |
|
|
10
10
|
| --- | --- | --- |
|
|
11
|
-
| `flow reflect --playbook "<note>"` | `## playbook` (fix lives in `project.md`) | a docs flow: `
|
|
12
|
-
| `flow reflect --code "<note>"` | `## code` (this project's code, maybe the playbook) | a patch flow: `
|
|
11
|
+
| `flow reflect --playbook "<note>"` | `## playbook` (fix lives in `project.md`) | a docs fold flow: the `--reflections` start `flow reflect plan` prints |
|
|
12
|
+
| `flow reflect --code "<note>"` | `## code` (this project's code, maybe the playbook) | a patch fold flow: the `--reflections` start `flow reflect plan` prints (normal when bigger) |
|
|
13
13
|
| `flow reflect --plugin "<note>"` | nothing — prints the upstream recipe | a GitHub issue, filed only on the operator's word |
|
|
14
14
|
|
|
15
15
|
- `--plugin`: search first (`gh issue list --repo <dev-flow repo> --state all
|
|
@@ -46,7 +46,10 @@ rows it fixes: `flow start fix-<topic> --patch --reflections=r3,r7`. Fix them
|
|
|
46
46
|
on the branch, and run `flow reflect defer <id> "<why>"` for any linked row
|
|
47
47
|
the flow won't fix. `finish` closes the others as fixed by the flow, so never
|
|
48
48
|
check linked rows off by hand. Rows not linked to a flow are closed with
|
|
49
|
-
`flow reflect done <id> "<what>"`. Never edit `reflections.md`.
|
|
49
|
+
`flow reflect done <id> "<what>"`. Never edit `reflections.md`. A fold flow
|
|
50
|
+
always merges unreleased on a versioned project (no release call at
|
|
51
|
+
Approve?, the entry goes under Unreleased) and finishes without a closing
|
|
52
|
+
reflection.
|
|
50
53
|
|
|
51
54
|
**GitHub issues** fold into `flow doctor` / `reflect list` when the repo has a
|
|
52
55
|
GitHub remote: a local row an open issue covers shows `⟷ gh#NNN` (check it off
|
package/src/core.ts
CHANGED
|
@@ -49,15 +49,15 @@ export interface FlowState {
|
|
|
49
49
|
yolo?: boolean; // operator said "yolo" at any gate question: that one answered, every later one pre-confirmed; checks and guardrails stay
|
|
50
50
|
setupAt?: string; // commands.setup exited 0 in this worktree — a reused worktree reruns it only when unset (#49)
|
|
51
51
|
publish?: { pr?: number; merged?: string; tag?: string }; // set when the release gate publishes itself (GitHub): what it has done so far — every step re-probes the forge, this only feeds the hint and the result
|
|
52
|
-
releaseVersion?: string; // the
|
|
52
|
+
releaseVersion?: string; // the version that was tagged — read from the merge commit (or the branch head) when the tag is cut, never pinned earlier; release-done publishes this, not whatever a checkout says later (#52)
|
|
53
53
|
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)
|
|
54
54
|
staleBuild?: string; // release ran under an older dev-flow than the checkout by operator choice ("<loaded> (checkout <disk>)"); release-done repeats the acknowledgement
|
|
55
55
|
pendingAsk?: string; // the checkpoint word a gate asked for and has not been given ("Approve?", "Verified?", …) — presentation only (💬 in the footer), it never gates
|
|
56
56
|
/** when flow verify at pre-release asked Verified? over review fixes; cleared by the answer — flow release refuses while it is set */
|
|
57
57
|
reverifyAsked?: string;
|
|
58
58
|
releaseOnly?: boolean; // verify found nothing on the branch but unreleased work on main: this flow only cuts the version (#161)
|
|
59
|
-
versionChoice?: string; // the operator's release call, recorded with
|
|
60
|
-
versionFrom?: string; // the manifest version when the call was recorded —
|
|
59
|
+
versionChoice?: string; // the operator's release call, recorded with Approve?: patch | minor | major (a decision, never a number: counted from the newest tag at release, so a parallel flow taking the number moves it), "next" (playbook version = versioned: any bump past the last tag) or "unreleased"; any gate call before the tag can change it
|
|
60
|
+
versionFrom?: string; // the manifest version when the call was recorded — only for the hint's "as things stand" number; the gate counts from the newest tag
|
|
61
61
|
/** the session and its operator-message count when Verified? moved this flow to pre-release (gh#254): under
|
|
62
62
|
* yolo = until-release, a message after it is the operator's own Release? word, not a replayed plan-stage yolo */
|
|
63
63
|
verifiedAtMessage?: { key: string; users: number };
|
|
@@ -537,18 +537,37 @@ export function pickReleaseNotes(src: { changelog: string | null; version: strin
|
|
|
537
537
|
return { notes: "", source: "none" };
|
|
538
538
|
}
|
|
539
539
|
|
|
540
|
-
/**
|
|
541
|
-
* the
|
|
542
|
-
*
|
|
543
|
-
|
|
540
|
+
/** The operator's release call — a decision about the bump, never a number: a bump kind (`patch|minor|major`),
|
|
541
|
+
* `next` (the playbook says versioned: any bump past the last tag) or `unreleased` (merge + changelog only).
|
|
542
|
+
* Made at Approve? and changeable on any later gate call until the tag is cut. The number it means is counted
|
|
543
|
+
* from the newest tag whenever the gate needs it, so a flow that released first moves this one along instead
|
|
544
|
+
* of colliding with it (a pinned number was tagged onto a tree whose manifest said otherwise). */
|
|
544
545
|
export type BumpKind = "patch" | "minor" | "major";
|
|
545
546
|
export const isBumpKind = (c: string | null | undefined): c is BumpKind => c === "patch" || c === "minor" || c === "major";
|
|
546
547
|
|
|
547
|
-
/**
|
|
548
|
+
/** The x.y.z a version carries, wherever it sits: `v0.49.1-letta_0.34.68` → [0, 49, 1]. Null when there is none. */
|
|
549
|
+
export function versionCore(v: string | null | undefined): [number, number, number] | null {
|
|
550
|
+
const m = v?.match(/(\d+)\.(\d+)\.(\d+)/);
|
|
551
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/** Release order: the x.y.z core first (a `v` prefix or a project suffix such as `-letta_0.34.68` must not reorder
|
|
555
|
+
* releases), what follows the core only to break a tie. */
|
|
556
|
+
export function cmpRelease(a: string, b: string): number {
|
|
557
|
+
const ca = versionCore(a);
|
|
558
|
+
const cb = versionCore(b);
|
|
559
|
+
if (!ca || !cb) return cmpVersions(a, b);
|
|
560
|
+
for (let i = 0; i < 3; i++) if (ca[i] !== cb[i]) return ca[i] - cb[i];
|
|
561
|
+
// same core: what follows it decides (lettuce's -letta_0.34.68 over -letta_0.34.67); a prefix never does
|
|
562
|
+
const rest = (v: string) => v.slice(v.search(/\d+\.\d+\.\d+/)).replace(/^\d+\.\d+\.\d+/, "");
|
|
563
|
+
return cmpVersions(rest(a), rest(b));
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/** `from`'s x.y.z bumped by one `kind` step — the bare core, any prefix or suffix dropped — or null when `from` has none. */
|
|
548
567
|
export function bumpVersion(from: string | null | undefined, kind: BumpKind): string | null {
|
|
549
|
-
const
|
|
550
|
-
if (!
|
|
551
|
-
const [maj, min, pat] =
|
|
568
|
+
const c = versionCore(from);
|
|
569
|
+
if (!c) return null;
|
|
570
|
+
const [maj, min, pat] = c;
|
|
552
571
|
return kind === "major" ? `${maj + 1}.0.0` : kind === "minor" ? `${maj}.${min + 1}.0` : `${maj}.${min}.${pat + 1}`;
|
|
553
572
|
}
|
|
554
573
|
|
|
@@ -558,8 +577,9 @@ export const playbookVersionChoice = (cfg: Config): string | undefined =>
|
|
|
558
577
|
|
|
559
578
|
/** `to` raises the major version over `from` (1.x → 2.0, and 0.x → 1.0). */
|
|
560
579
|
export function majorBump(from: string, to: string): boolean {
|
|
561
|
-
const
|
|
562
|
-
|
|
580
|
+
const a = versionCore(from);
|
|
581
|
+
const b = versionCore(to);
|
|
582
|
+
return !!a && !!b && b[0] > a[0];
|
|
563
583
|
}
|
|
564
584
|
|
|
565
585
|
/** A recorded call in the operator's words. */
|
|
@@ -572,12 +592,54 @@ export const describeVersionChoice = (c: string, from?: string | null): string =
|
|
|
572
592
|
? `a ${c} release${bumpVersion(from, c) ? ` (${from} → ${bumpVersion(from, c)})` : ""}`
|
|
573
593
|
: `release ${c}`;
|
|
574
594
|
|
|
575
|
-
/** Does the version flag pair on a
|
|
595
|
+
/** Does the version flag pair on a gate call parse? Returns the call it makes, null for none, or an error. */
|
|
576
596
|
export function versionArg(value: string | null, noVersion: boolean): { choice: string | null } | { error: string } {
|
|
577
|
-
if (value !== null && noVersion) return { error: "--version=<
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
597
|
+
if (value !== null && noVersion) return { error: "--version=<kind> and --no-version contradict each other — pass the one the operator chose" };
|
|
598
|
+
const v = value?.trim() ?? null;
|
|
599
|
+
if (v !== null && !isBumpKind(v)) {
|
|
600
|
+
const exact = versionCore(v) ? ` — the number is not chosen up front: it is counted from the newest tag when the release runs, so pass the kind of step ${v} would be` : "";
|
|
601
|
+
return { error: `--version=${value} is not a release call — pass what the operator chose: patch, minor or major (or --no-version to merge unreleased)${exact}` };
|
|
602
|
+
}
|
|
603
|
+
return { choice: v !== null ? v : noVersion ? "unreleased" : null };
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/** The question that collects the release call (asked with Approve?); `now` is the manifest's current version. */
|
|
607
|
+
export function releaseCallQuestion(now: string | null, file: string, docs?: boolean): { ask: string; flags: string } {
|
|
608
|
+
const kinds = (["patch", "minor", "major"] as const).map((k) => `${k}${bumpVersion(now, k) ? ` (→ ${bumpVersion(now, k)} as things stand)` : ""}`).join(", ");
|
|
609
|
+
return {
|
|
610
|
+
ask: `also ask the release call: a ${kinds} release — propose one by the playbook's versioning rule${now ? ` (${file} is at ${now})` : ""} — or merge unreleased (no bump, no tag)${docs ? "; a docs flow usually merges unreleased" : ""}. Only the kind of step is recorded: the number is counted from the newest tag at release, and the operator can change the call on any gate call before the tag`,
|
|
611
|
+
flags: "--version=patch|minor|major or --no-version (merge unreleased)",
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/** A fold flow — one started with `--reflections`, fixing reflection rows — always merges unreleased: the fix rides
|
|
616
|
+
* under Unreleased until the next versioned release. Null when `choice` is allowed. */
|
|
617
|
+
export function foldCallError(state: FlowState, choice: string | null | undefined): string | null {
|
|
618
|
+
if (!state.reflections?.length || !choice || choice === "unreleased") return null;
|
|
619
|
+
return `a fold flow (linked reflections ${state.reflections.map((r) => `r${r.id}`).join(", ")}) always merges unreleased — the fix rides under Unreleased until the next versioned release`;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/** Does `manifest` carry the operator's release call? `newest` is the newest tagged release, `base` the manifest the
|
|
623
|
+
* branch started from. Null when it does; otherwise what to fix, with the number the call means today. */
|
|
624
|
+
export function releaseCallProof(choice: string, manifest: string | null, newest: string | null, base: string | null, file: string): { error: string; want?: string } | null {
|
|
625
|
+
if (choice === "unreleased") {
|
|
626
|
+
if (manifest && base && base !== manifest) return { error: `the release call is to merge unreleased, but the branch bumps ${file} ${base} → ${manifest} — revert the bump (the entry goes under Unreleased), or change the call (--version=<kind>) on the operator's word` };
|
|
627
|
+
return null;
|
|
628
|
+
}
|
|
629
|
+
if (isBumpKind(choice)) {
|
|
630
|
+
const from = newest ?? base;
|
|
631
|
+
const want = bumpVersion(from, choice);
|
|
632
|
+
if (!want) return null; // nothing to count from: the generic proofs (a version past the last tag) still run
|
|
633
|
+
const have = versionCore(manifest);
|
|
634
|
+
if (!have || have.join(".") !== want) {
|
|
635
|
+
const extra = manifest && manifest.replace(/\d+\.\d+\.\d+/, "") ? " (its x.y.z part — keep the project's own prefix and suffix)" : "";
|
|
636
|
+
return { error: `the release call is a ${choice} release: ${file} must be ${want}${extra} — ${choice} past ${newest ? `the newest tag, ${newest}` : from} — it says ${manifest ?? "no version"}`, want };
|
|
637
|
+
}
|
|
638
|
+
return null;
|
|
639
|
+
}
|
|
640
|
+
if (choice === "next" && manifest && newest && cmpRelease(manifest, newest) <= 0)
|
|
641
|
+
return { error: `${file} says ${manifest}, which is not past the newest tag ${newest} — bump it past ${newest}` };
|
|
642
|
+
return null;
|
|
581
643
|
}
|
|
582
644
|
|
|
583
645
|
/**
|
|
@@ -883,7 +945,7 @@ export function newestTaggedVersion(pattern: string, tags: string[]): string | n
|
|
|
883
945
|
let best: string | null = null;
|
|
884
946
|
for (const t of tags) {
|
|
885
947
|
const m = t.match(re);
|
|
886
|
-
if (m && (best === null ||
|
|
948
|
+
if (m && (best === null || cmpRelease(m[1], best) > 0)) best = m[1];
|
|
887
949
|
}
|
|
888
950
|
return best;
|
|
889
951
|
}
|
|
@@ -2227,8 +2289,8 @@ export interface ReflectionRoute {
|
|
|
2227
2289
|
route: string;
|
|
2228
2290
|
}
|
|
2229
2291
|
|
|
2230
|
-
const DOCS_ROUTE = "docs flow (flow
|
|
2231
|
-
const CODE_ROUTE = "patch flow (flow
|
|
2292
|
+
const DOCS_ROUTE = "docs flow (flow reflect plan prints its --reflections start) — project.md edits only pass its worktree";
|
|
2293
|
+
const CODE_ROUTE = "patch flow (flow reflect plan prints its --reflections start), normal flow when bigger";
|
|
2232
2294
|
|
|
2233
2295
|
export function reflectionRoutes(items: ReflectItem[], selfRepo: boolean): ReflectionRoute[] {
|
|
2234
2296
|
return items.map((it) => {
|
|
@@ -2399,8 +2461,8 @@ export function reflectionNudges(text: string, today: string, opts: { recurred?:
|
|
|
2399
2461
|
if (code && opts.between) why.push("between flows");
|
|
2400
2462
|
let fix: string | null = null;
|
|
2401
2463
|
if (open.length && why.length) {
|
|
2402
|
-
const split = [docs ? `${docs} playbook item(s) → one docs flow
|
|
2403
|
-
fix = `⚑ fix the open reflections now? (${why.join(", ")}) — ${split}; flow reflect plan groups them into flows`;
|
|
2464
|
+
const split = [docs ? `${docs} playbook item(s) → one docs flow` : "", code ? `${code} code item(s) → patch flow(s)` : ""].filter(Boolean).join("; ");
|
|
2465
|
+
fix = `⚑ fix the open reflections now? (${why.join(", ")}) — ${split}; flow reflect plan groups them into flows and prints each start command`;
|
|
2404
2466
|
}
|
|
2405
2467
|
const closedLines = text.split("\n").filter(isDoneItem);
|
|
2406
2468
|
const closed = closedLines.length;
|
|
@@ -2597,11 +2659,15 @@ export function nextHint(state: FlowState, cfg: Config): string {
|
|
|
2597
2659
|
return `${base} — linked reflections ${open.map((r) => `r${r.id}`).join(", ")}: fix each on this branch (finish closes them as fixed), or flow reflect defer <id> "<why>" for one it will not fix`;
|
|
2598
2660
|
}
|
|
2599
2661
|
|
|
2662
|
+
/** The release call still to be asked with Approve? — "" when the playbook makes it or it is on record. */
|
|
2663
|
+
const callAsk = (state: FlowState, cfg: Config): string =>
|
|
2664
|
+
cfg.versioning.file && !playbookVersionChoice(cfg) && !state.versionChoice ? " together with the release call (patch, minor or major — the kind of step, not a number — or merge unreleased)" : "";
|
|
2665
|
+
|
|
2600
2666
|
function stageHint(state: FlowState, cfg: Config): string {
|
|
2601
2667
|
switch (state.stage) {
|
|
2602
2668
|
case "plan":
|
|
2603
|
-
if (state.patch || state.docs) return `${state.patch ? "patch" : "docs"} (proposed — the Approve? answer grants the mode): describe the change in one line, ask Approve? in chat naming the mode, then flow approve --confirmed — no plan file${state.docs ? ", no tier-1 checks" : ""}`;
|
|
2604
|
-
return `clarify the direction in chat, write .dev-flow/${state.slug}/plan/plan.md${state.ui ? ` and render mockups to plan/mockups/ (${cfg.mockupGlobs.join(", ")}) with headless chromium, embedded in plan.md` : ""}, then ask Approve
|
|
2669
|
+
if (state.patch || state.docs) return `${state.patch ? "patch" : "docs"} (proposed — the Approve? answer grants the mode): describe the change in one line, ask Approve? in chat naming the mode${callAsk(state, cfg)}, then flow approve --confirmed${callAsk(state, cfg) ? " --version=<kind>|--no-version" : ""} — no plan file${state.docs ? ", no tier-1 checks" : ""}`;
|
|
2670
|
+
return `clarify the direction in chat, write .dev-flow/${state.slug}/plan/plan.md${state.ui ? ` and render mockups to plan/mockups/ (${cfg.mockupGlobs.join(", ")}) with headless chromium, embedded in plan.md` : ""}, then ask Approve?${callAsk(state, cfg)} and run flow approve --confirmed${callAsk(state, cfg) ? " --version=<kind>|--no-version" : ""} on the answer`;
|
|
2605
2671
|
case "implement":
|
|
2606
2672
|
if (state.docs) {
|
|
2607
2673
|
const open = openItemsNote(cfg, state, "implement");
|
|
@@ -2611,7 +2677,7 @@ function stageHint(state: FlowState, cfg: Config): string {
|
|
|
2611
2677
|
const rv = reviewOwed(state, cfg) ? `; then the review — ${cfg.release.review}, fix what it finds and record it (flow review done "<verdict>"; a flow_stage review worker records itself)` : "";
|
|
2612
2678
|
return `build and test in ${state.worktree}, commit as you go, flow check${rv}; then flow verify (deploys for review), look yourself, keep the app running, ask Verified? and run flow verify --confirmed on the answer`;
|
|
2613
2679
|
case "pre-release": {
|
|
2614
|
-
//
|
|
2680
|
+
// the release call (made with Approve?, changeable until the tag) decides which prep this is
|
|
2615
2681
|
const vc = state.versionChoice;
|
|
2616
2682
|
// gh#233: flow release refuses until the review is on record — the hint says how it gets there
|
|
2617
2683
|
const rv = reviewOwed(state, cfg) ? `${cfg.release.review} (then record it: flow review done "<verdict>")` : cfg.release.review && state.review ? "review on record" : "";
|
|
@@ -2622,7 +2688,7 @@ function stageHint(state: FlowState, cfg: Config): string {
|
|
|
2622
2688
|
const gateAsks = `${auto} — the gate asks Release? when it needs the operator's word (NEEDS-OPERATOR Release?): ask it then, never before the call`;
|
|
2623
2689
|
if (vc === "unreleased")
|
|
2624
2690
|
return `${review}fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs${cfg.release.changelog && !state.docs ? `, add this flow's line under Unreleased in ${cfg.release.changelog} (the call is merge unreleased: no bump)` : ""}; show the PR summary, then run flow release${gateAsks}`;
|
|
2625
|
-
const prep = [cfg.release.changelog ? `prepare ${cfg.release.changelog} (fold Unreleased lines verbatim)` : "", cfg.versioning.file ? `bump version in ${cfg.versioning.file}${isBumpKind(vc) ? `
|
|
2691
|
+
const prep = [cfg.release.changelog ? `prepare ${cfg.release.changelog} (fold Unreleased lines verbatim)` : "", cfg.versioning.file ? `bump version in ${cfg.versioning.file}${isBumpKind(vc) ? ` one ${vc} step past the newest tag (${bumpVersion(state.versionFrom, vc) ?? `the next ${vc}`} as of approval — a flow that released since moves it; flow release names the number)` : ""}` : ""].filter(Boolean).join(" and ");
|
|
2626
2692
|
if (vc && prep) return `${review}fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs, ${prep}; show the PR summary, version and changelog, then run flow release${gateAsks}`;
|
|
2627
2693
|
if (state.docs && prep) return `${review}fix must/should; a docs flow usually ships unversioned — ask the operator (flow release --no-version on their word); versioned instead: ${prep}; then run flow release${gateAsks}`;
|
|
2628
2694
|
return `${review}fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs${prep ? `, ${prep}` : ""}; show the PR summary, version and changelog, then run flow release${gateAsks}`;
|
package/src/projectmd.ts
CHANGED
|
@@ -68,7 +68,7 @@ const KEYMAP: Record<string, Record<string, string>> = {
|
|
|
68
68
|
merge: "release.merge", // how a merged branch lands: squash | merge | rebase | any
|
|
69
69
|
yolo: "release.yolo", // how far a standing yolo reaches: all (default) | until-release (gh#176)
|
|
70
70
|
reflect: "release.reflect", // when finish runs the closing reflection: on-friction (default) | always
|
|
71
|
-
version: "release.version", // who
|
|
71
|
+
version: "release.version", // who makes the release call: ask (with Approve?, default) | versioned | unversioned (gh#198)
|
|
72
72
|
ask: "release.ask", // when Release? is asked: on-change (default) | always (gh#198)
|
|
73
73
|
finish: "release.finish", // when Finish? is asked: on-change (default, a clean flow closes itself) | always
|
|
74
74
|
publish: "release.publish", // who runs push, PR, merge and tag after Release?: gate (default on GitHub) | manual
|
package/src/runtime/base.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, renameS
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
6
|
import { compact, SettingsManager, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
-
import { isDocPath, checklistPending, claimBlocks, classifyMergeHistory, cmpVersions, detectForge, extractSkillCore, featureBranchPrefix, healthRetry, parseMergeStyle, parseLsRemoteTags, pluginVersion, reflectItems, sessionRunsOlderBuild, listFiles, shouldSelfCompact, sq, featureTmpDir, featureTmpEnv, staleScratch, mainCheckoutRoot, type ReflectItem, type Config, type FeatureRef, type FlowState, type SessionClaim, ensureReflectIds } from "../core.ts";
|
|
7
|
+
import { isDocPath, parseVersion, checklistPending, claimBlocks, classifyMergeHistory, cmpVersions, detectForge, extractSkillCore, featureBranchPrefix, healthRetry, parseMergeStyle, parseLsRemoteTags, pluginVersion, reflectItems, sessionRunsOlderBuild, listFiles, shouldSelfCompact, sq, featureTmpDir, featureTmpEnv, staleScratch, mainCheckoutRoot, type ReflectItem, type Config, type FeatureRef, type FlowState, type SessionClaim, ensureReflectIds } from "../core.ts";
|
|
8
8
|
import { loadProject, parseProjectMd, setPlaybookKey } from "../projectmd.ts";
|
|
9
9
|
import { bashTimeout } from "../timeouts.ts";
|
|
10
10
|
import { type RunResult, type Session } from "./checks.ts";
|
|
@@ -236,7 +236,7 @@ export async function releaseTags(root: string): Promise<string[] | null> {
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
export const GATE_HELP =
|
|
239
|
-
"help [--json] | init [--force|--draft|--write <text>|--write-file <path>|--answers key=value…|--answers-file <path>] [--confirmed] [--track] | reflect [<note> [--evidence=<file:line>]|list|plan|tidy|move <id> --playbook|--code|done <id>[,<id>…] [<what>]|reopen <id> [<why>]|defer <id> <why>|--same <id> [<evidence>]] | roadmap [add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>[,<n>…]|drop <n>[,<n>…]|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui|--patch|--docs] [--reflections=r<id>,…] [--no-ui --confirmed] [--force] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | review [done <verdict>|--skip] | approve [--yolo] | verify [--yolo] [--port=<n>|--replace] [--version=<
|
|
239
|
+
"help [--json] | init [--force|--draft|--write <text>|--write-file <path>|--answers key=value…|--answers-file <path>] [--confirmed] [--track] | reflect [<note> [--evidence=<file:line>]|list|plan|tidy|move <id> --playbook|--code|done <id>[,<id>…] [<what>]|reopen <id> [<why>]|defer <id> <why>|--same <id> [<evidence>]] | roadmap [add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>[,<n>…]|drop <n>[,<n>…]|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui|--patch|--docs] [--reflections=r<id>,…] [--no-ui --confirmed] [--force] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | review [done <verdict>|--skip] | approve [--yolo] [--version=patch|minor|major|--no-version] | bump <patch|minor|major|none> [slug] | verify [--yolo] [--port=<n>|--replace] [--version=<kind>|--no-version] | release [--yolo|--version=<kind>|--no-version|--no-fold-check|--no-marker-check] | finish [--yolo] [--no-reflect] [--note=<text>] [--no-artifact-check|--no-release-create] [slug] | abort [slug] [--purge] | version [--check-upstream] — state gates take [slug] and --confirmed (the operator already answered in chat); without it the agent's call returns NEEDS-OPERATOR with the question to ask in chat (it never opens a dialog), and the /flow slash command asks in a dialog — verify without --confirmed rebases a branch that is behind the default branch and deploys for review; --port=<n> / --replace answer its Dev port? question when another flow holds the stack — --ui on start is the agent's call whenever screens change (it only adds the mockup gate); --patch/--docs are proposed at start and granted by the Approve? answer; --no-ui (clearing ui on a plan-stage feature) and --merge=<style> are operator-granted (--confirmed); start refuses until the playbook has a merge policy and writes the answer into project.md — --yolo (with --confirmed) answers that checkpoint and pre-confirms every later one; checks and guardrails stay — approve --confirmed carries the operator's release call on a versioned project: --version=patch|minor|major (the kind of step — the number is counted from the newest tag when the release runs) or --no-version (merge unreleased), asked with Approve?; it is never asked again, and the operator changes it on any later gate call (verify/release take the same flags) or with bump <kind> --confirmed, until the tag is cut — on GitHub release then publishes itself (push, PR, CI wait, merge in the playbook style, annotated tag) and records the release; a 'publish stopped' or 'publish waiting' result is resumed by re-running flow release; publish = manual in the playbook (or another forge) leaves those steps to the agent, and finish records the release (--no-artifact-check / --no-release-create skip a proof on the operator's word) — release --no-version ships merge + changelog only (no bump, tag or forge release); --no-fold-check skips the changelog fold line proofs on the operator's word; --no-marker-check lets a branch add conflict-marker-shaped lines on purpose — finish runs the closing reflection worker first (before removing anything) and stops for the operator's fold/drop; the re-run with --confirmed cleans up; --no-reflect --confirmed skips it on the operator's explicit word (yolo never does), --note= hands the worker the operator's friction notes — release names a session running an older dev-flow build than the disk ships and asks update (/reload) or proceed — recorded, never a block — reflect <note> queues a project suggestion in reflections.md (--playbook = docs-flow fix, --code = patch-flow fix); --plugin never writes — dev-flow feedback goes upstream and it prints the GitHub issue recipe; bare reflect prints the session-reflection protocol (bound: run flow_stage op reflect); list prints open items by id (r<n>: never renumbered), plan groups them into flows with the start command, move <id> re-files one, done <id> checks a fixed one off, reopen <id> brings back one closed by mistake (from the archive too), --same <id> counts a recurrence on its row, defer <id> <why> leaves a row linked to the bound flow open, tidy moves closed ones to reflections-archive.md — start --reflections=<ids> links rows to the flow and finish closes them as fixed by it — roadmap manages .dev-flow/roadmap.md: pick <n> <slug> (or add --slug=) stamps an item for flow start, which seeds the new plan from its brief; finish checks it off; drop <n> removes an item nobody wants any more (done would record it as shipped); <n> is the row number list prints — done leaves the others in place, drop and tidy renumber — a new feature asked for mid-flow is parked there, never as a hand-made .dev-flow/<slug>/; start <slug> --confirmed adopts such a ghost dir — review records the review flow verify requires before it asks Verified? (and flow release before it ships): done <verdict> after the playbook's review step ran inline (a flow_stage review worker records itself); --skip (--confirmed, the operator's Skip review? answer) ships without one; bare review shows what is on record — doctor reviews structure, git consistency and open reflections (never writes); doctor <note> prints an investigation brief — abort unbinds and keeps the worktree; abort --purge (--confirmed, the operator's Purge? answer) removes the worktree, branch and feature folder of a dropped feature, never anything on origin — version prints the build the disk ships and any other dev-flow copies in this process (--check-upstream asks the registry)";
|
|
240
240
|
export const featDir = (root: string, slug: string) => path.join(dfDir(root), slug);
|
|
241
241
|
export const stateFile = (root: string, slug: string) => path.join(featDir(root, slug), "state.json");
|
|
242
242
|
export const claimFile = (root: string, slug: string) => path.join(featDir(root, slug), "claim.json");
|
|
@@ -528,6 +528,24 @@ export async function refreshDocsCode(root: string, state: FlowState, cfg: Confi
|
|
|
528
528
|
|
|
529
529
|
/** Where feature commands run: the feature worktree once it exists (that is where the
|
|
530
530
|
* code under test lives), else the main checkout. Keeps gates off the main branch. */
|
|
531
|
+
/** The version `file` under `dir` says, or null when it is missing or unparsable. */
|
|
532
|
+
export function manifestAt(dir: string, file: string): string | null {
|
|
533
|
+
const f = path.join(dir, file);
|
|
534
|
+
return existsSync(f) ? parseVersion(file, readFileSync(f, "utf8")) : null;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/** Records the operator's release call — a kind of step, never a number. `versionFrom` (the manifest it was made
|
|
538
|
+
* over) only feeds the hint's "as things stand" number; the gates count from the newest tag. The caller writes state. */
|
|
539
|
+
export function recordReleaseCall(root: string, state: FlowState, cfg: Config, choice: string): void {
|
|
540
|
+
if (choice !== state.versionChoice || !state.versionFrom) {
|
|
541
|
+
const from = cfg.versioning.file ? manifestAt(gateCwd(root, state), cfg.versioning.file) : null;
|
|
542
|
+
if (from) state.versionFrom = from;
|
|
543
|
+
}
|
|
544
|
+
state.versionChoice = choice;
|
|
545
|
+
if (choice === "unreleased") state.noVersion = true;
|
|
546
|
+
else delete state.noVersion;
|
|
547
|
+
}
|
|
548
|
+
|
|
531
549
|
export function gateCwd(root: string, state: FlowState): string {
|
|
532
550
|
const wt = worktreeAbs(root, state);
|
|
533
551
|
return wt && existsSync(wt) ? wt : root;
|
package/src/runtime/gates.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/** dev-flow runtime — The gate runner and the gates that do not ship anything. Moved out of extensions/dev-flow.ts as is (exports added). */
|
|
2
2
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { skipsChecks, approveGate, applicableItems, appendRoadmapItem, checklistHash, claimBlocks, doneItemCount, detectForge, gateHelpJson, healthProbe, parseMergeStyle, investigationBrief, pluginVersion, reflectProtocol, reflectUnfiledCount, reflectionNudges, reflectionRoutes, listFiles, needsOperator, newState, nextHint, openChecklistItems, releaseGate, roadmapDone, roadmapDrop, roadmapOpenCount, roadmapOpenRows, roadmapBriefFor, roadmapPick, roadmapTidy, statusJson, subst, sq, featureTmpDir, foreignWorktreeLinks, validSlug, verifyGate, STAGE_EMOJI, type ReflectTarget, type Config, type FlowState, parseRowIds, DF_GITIGNORE } from "../core.ts";
|
|
4
|
+
import { foldCallError, skipsChecks, approveGate, versionArg, playbookVersionChoice, releaseCallQuestion, describeVersionChoice, applicableItems, appendRoadmapItem, checklistHash, claimBlocks, doneItemCount, detectForge, gateHelpJson, healthProbe, parseMergeStyle, investigationBrief, pluginVersion, reflectProtocol, reflectUnfiledCount, reflectionNudges, reflectionRoutes, listFiles, needsOperator, newState, nextHint, openChecklistItems, releaseGate, roadmapDone, roadmapDrop, roadmapOpenCount, roadmapOpenRows, roadmapBriefFor, roadmapPick, roadmapTidy, statusJson, subst, sq, featureTmpDir, foreignWorktreeLinks, validSlug, verifyGate, STAGE_EMOJI, type ReflectTarget, type Config, type FlowState, parseRowIds, DF_GITIGNORE } from "../core.ts";
|
|
5
5
|
import { applyAnswers, buildDraft, doctorFindings, ghostFeatureDirs, ghostInfo, lineDiff, loadProject, mdDigest, parseAnswers, parseProjectMd } from "../projectmd.ts";
|
|
6
6
|
import { linkedTag } from "../fold.ts";
|
|
7
7
|
import { detectProject } from "../detect.ts";
|
|
8
8
|
import { AGENT_MARK } from "../present.ts";
|
|
9
|
-
import { GATE_HELP, SELF_BUILD, refreshDocsCode, type Ui, buildSkew, copyWarning, currentBranch, dfDir, featDir, featureEnv, flagValue, gateCwd, gitConsistency, initiated, loadedVersion, mergeHistoryEvidence, needState, now, originUrl, publishedVersion, readClaim, readReflections, readReflectionsText, readRoadmap, readState, roadmapFile, sh, stateFile, tail, unfinishedStates, writePlaybookMergePolicy, writeState } from "./base.ts";
|
|
9
|
+
import { GATE_HELP, SELF_BUILD, refreshDocsCode, type Ui, manifestAt, recordReleaseCall, buildSkew, copyWarning, currentBranch, dfDir, featDir, featureEnv, flagValue, gateCwd, gitConsistency, initiated, loadedVersion, mergeHistoryEvidence, needState, now, originUrl, publishedVersion, readClaim, readReflections, readReflectionsText, readRoadmap, readState, roadmapFile, sh, stateFile, tail, unfinishedStates, writePlaybookMergePolicy, writeState } from "./base.ts";
|
|
10
10
|
import { type RunResult, type Session, ago, behindNote, releaseDevSlot, pendingChecks, probeHealth, readDevPorts, runChecks, stampChecks, triedNote } from "./checks.ts";
|
|
11
11
|
import { GIT_TRACK_NOTE, isSelfRepo, renderQuestions, setupQuestions, tagPatternEvidence } from "./setup.ts";
|
|
12
12
|
import { foldRows, foldView, legacyPluginRows, pluginUpstream, reflectDeferNote, reflectDoneNote, reflectList, reflectMoveNote, reflectNote, reflectPlanNote, reflectReopenNote, reflectSameNote, reflectTidy } from "./reflect.ts";
|
|
@@ -81,6 +81,9 @@ export async function runFlow(args: string[], root: string, ui: Ui, sess: Sessio
|
|
|
81
81
|
case "approve":
|
|
82
82
|
return gateApprove(o);
|
|
83
83
|
|
|
84
|
+
case "bump":
|
|
85
|
+
return gateBump(o);
|
|
86
|
+
|
|
84
87
|
case "test":
|
|
85
88
|
return gateTest(o);
|
|
86
89
|
|
|
@@ -409,8 +412,13 @@ export async function gateStart(o: GateCtx): Promise<RunResult> {
|
|
|
409
412
|
const state = newState(slugArg, flag("ui"), flag("patch"), flag("docs"), loadedVersion() ?? undefined);
|
|
410
413
|
if (linked.length) {
|
|
411
414
|
state.reflections = linked;
|
|
415
|
+
// a fold flow fixes rows: on a versioned project it always merges unreleased, so no release call is asked
|
|
416
|
+
if (cfg.versioning.file) {
|
|
417
|
+
state.versionChoice = "unreleased";
|
|
418
|
+
state.noVersion = true;
|
|
419
|
+
}
|
|
412
420
|
const rows = readReflections(root).filter((i) => linked.some((l) => l.id === i.n));
|
|
413
|
-
notes.push(`linked reflections (finish closes each as fixed by this flow; one it does not fix: flow reflect defer <id> "<why>"):\n${rows.map((i) => ` r${i.n}. ${i.line.replace(/^- \[ \] /, "").replace(/^\[r\d+\]\s*/, "")}`).join("\n")}`);
|
|
421
|
+
notes.push(`linked reflections (finish closes each as fixed by this flow; one it does not fix: flow reflect defer <id> "<why>"):\n${rows.map((i) => ` r${i.n}. ${i.line.replace(/^- \[ \] /, "").replace(/^\[r\d+\]\s*/, "")}`).join("\n")}\nfold flow: it merges unreleased (entry under Unreleased, no bump, no tag — no release call is asked) and finishes without a closing reflection`);
|
|
414
422
|
}
|
|
415
423
|
const planDir = path.join(featDir(root, slugArg), "plan");
|
|
416
424
|
if (ghost) notes.push(gi!.plan ? `adopted ghost .dev-flow/${slugArg}/ — its plan/ (${listFiles(planDir).join(", ") || "empty"}) is this feature's draft` : `adopted ghost .dev-flow/${slugArg}/ — kept ${gi!.entries.join(", ") || "nothing (it was empty)"}`);
|
|
@@ -445,7 +453,20 @@ export async function gateApprove(o: GateCtx): Promise<RunResult> {
|
|
|
445
453
|
const errs = approveGate(state!, cfg, planFiles, existsSync(planMd) ? readFileSync(planMd, "utf8") : undefined, foreignWorktreeLinks(dfDir(root), state!.slug, mockupHtml));
|
|
446
454
|
if (errs.length) return { text: `plan gate FAILED:\n- ${errs.join("\n- ")}`, isError: true };
|
|
447
455
|
const planItems = applicableItems(cfg, state!, "plan");
|
|
456
|
+
// the release call is made here, with the plan: only the kind of step is recorded, never a number
|
|
457
|
+
const relArg = versionArg(flagValue(o.rest, "version"), flag("no-version"));
|
|
458
|
+
if ("error" in relArg) return { text: `plan gate FAILED:\n- ${relArg.error}`, isError: true };
|
|
459
|
+
const foldErr = foldCallError(state!, relArg.choice);
|
|
460
|
+
if (foldErr) return { text: `plan gate FAILED:\n- ${foldErr}`, isError: true };
|
|
461
|
+
const call = relArg.choice ?? state!.versionChoice ?? playbookVersionChoice(cfg);
|
|
462
|
+
const callQ = cfg.versioning.file && !call ? releaseCallQuestion(manifestAt(root, cfg.versioning.file), cfg.versioning.file, state!.docs) : null;
|
|
463
|
+
if (relArg.choice && relArg.choice !== "unreleased" && !cfg.versioning.file) return { text: "plan gate FAILED:\n- --version needs a version file to bump: the playbook sets none (versionFile under ## release)", isError: true };
|
|
448
464
|
let audit = flag("confirmed") ? " (confirmed by operator instruction)" : "";
|
|
465
|
+
// the /flow dialog is yes/no: a call it cannot carry comes on the command line, before anything is asked
|
|
466
|
+
if (!flag("confirmed") && ui.hasUI && callQ) return { text: `plan gate FAILED:\n- the release call rides on Approve? — run /flow approve ${callQ.flags}`, isError: true };
|
|
467
|
+
// an answer to Approve? without the call answers half the question: ask the call, keep nothing
|
|
468
|
+
if (flag("confirmed") && callQ)
|
|
469
|
+
return { text: needsOperator(`Approve? on this versioned project carries the release call, and none was passed — ${callQ.ask}`, "Approve?", `ask the operator the release call, then re-run flow approve --confirmed ${callQ.flags}`), isError: true };
|
|
449
470
|
const askPending = !flag("confirmed");
|
|
450
471
|
if (askPending) {
|
|
451
472
|
markPendingAsk(root, state!, "Approve?");
|
|
@@ -456,7 +477,7 @@ export async function gateApprove(o: GateCtx): Promise<RunResult> {
|
|
|
456
477
|
: state!.docs
|
|
457
478
|
? "this is proposed as a docs flow — no written plan and no build checks; your answer grants that"
|
|
458
479
|
: "the plan is waiting for your approval";
|
|
459
|
-
return { text: needsOperator(what
|
|
480
|
+
return { text: needsOperator(`${what}${callQ ? ` — ${callQ.ask}` : ""}`, "Approve?", `${state!.patch || state!.docs ? "say the mode and the one-line change when you ask; " : ""}re-run with --confirmed${callQ ? ` ${callQ.flags}` : ""} once the operator answered in chat`), isError: true };
|
|
460
481
|
}
|
|
461
482
|
const ok = await ui.confirm("Approve plan", `Approve ${state!.slug}${state!.ui ? " (UI)" : ""}${state!.patch ? " (patch)" : state!.docs ? " (docs)" : ""}? Creates the worktree.${flag("yolo") ? " YOLO: all later gate questions (Verified?/Release?/Finish?) are pre-confirmed — checks and guardrails stay in place." : ""}`);
|
|
462
483
|
if (!ok) {
|
|
@@ -495,9 +516,36 @@ export async function gateApprove(o: GateCtx): Promise<RunResult> {
|
|
|
495
516
|
state!.worktree = wtRel;
|
|
496
517
|
state!.stage = "implement";
|
|
497
518
|
state!.approvals.plan = now();
|
|
519
|
+
if (call) recordReleaseCall(root, state!, cfg, call);
|
|
498
520
|
delete state!.pendingAsk;
|
|
499
521
|
writeState(root, state!);
|
|
500
|
-
return { text: `plan approved${audit}${state!.yolo ? " — yolo: later gate questions pre-confirmed" : ""}; worktree ${wtRel} on branch ${branch}.${setupNote}\n${AGENT_MARK}next: ${nextHint(state!, cfg)}` };
|
|
522
|
+
return { text: `plan approved${audit}${state!.yolo ? " — yolo: later gate questions pre-confirmed" : ""}; worktree ${wtRel} on branch ${branch}.${call ? `\nrelease call: ${describeVersionChoice(call, state!.versionFrom)} — the number is counted from the newest tag at release; the operator can change the call on any gate call (or flow bump <kind>) until the tag` : ""}${setupNote}\n${AGENT_MARK}next: ${nextHint(state!, cfg)}` };
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/** `flow bump <patch|minor|major|none> [slug]`: the operator changes the release call at any stage before the tag.
|
|
526
|
+
* Only the kind of step is recorded; the number is counted from the newest tag when the release runs. */
|
|
527
|
+
export async function gateBump(o: GateCtx): Promise<RunResult> {
|
|
528
|
+
const { root, cfg, flag, sess } = o;
|
|
529
|
+
const words = o.rest.filter((a) => !a.startsWith("--"));
|
|
530
|
+
const [kind, slug] = words;
|
|
531
|
+
const usage = "usage: flow bump <patch|minor|major|none> [slug] --confirmed — none merges unreleased (no bump, no tag)";
|
|
532
|
+
if (!kind) return { text: usage, isError: true };
|
|
533
|
+
const arg = kind === "none" || kind === "unreleased" ? versionArg(null, true) : versionArg(kind, false);
|
|
534
|
+
if ("error" in arg) return { text: `bump FAILED:\n- ${arg.error}\n${usage}`, isError: true };
|
|
535
|
+
const { state, err } = needState(root, sess, slug);
|
|
536
|
+
if (err) return err;
|
|
537
|
+
const choice = arg.choice!;
|
|
538
|
+
const foldErr = foldCallError(state!, choice);
|
|
539
|
+
if (foldErr) return { text: `bump FAILED:\n- ${foldErr}`, isError: true };
|
|
540
|
+
if (!cfg.versioning.file && choice !== "unreleased") return { text: "bump FAILED:\n- the playbook sets no version file (versionFile under ## release), so there is nothing to bump — set one first", isError: true };
|
|
541
|
+
if (state!.publish?.tag || state!.approvals.release) return { text: `bump FAILED:\n- ${state!.publish?.tag ?? "the release"} is already ${state!.publish?.tag ? "tagged" : "recorded"} — the call cannot change after the tag`, isError: true };
|
|
542
|
+
const was = state!.versionChoice;
|
|
543
|
+
if (was === choice) return { text: `release call unchanged: ${describeVersionChoice(choice, state!.versionFrom)}` };
|
|
544
|
+
if (!flag("confirmed")) return { text: needsOperator(`change the release call from ${was ? describeVersionChoice(was) : "none"} to ${describeVersionChoice(choice)}`, "Release call?", `this is the operator's word — on it, re-run flow bump ${kind}${slug ? ` ${slug}` : ""} --confirmed`), isError: true };
|
|
545
|
+
recordReleaseCall(root, state!, cfg, choice);
|
|
546
|
+
writeState(root, state!);
|
|
547
|
+
const prep = state!.stage === "pre-release" || state!.stage === "release" ? ` — redo the release prep to match (${choice === "unreleased" ? "revert any bump; the entry goes under Unreleased" : "the version file and its changelog heading"}); flow release names the number` : "";
|
|
548
|
+
return { text: `release call changed (confirmed by operator instruction): ${was ? describeVersionChoice(was) : "none"} → ${describeVersionChoice(choice, state!.versionFrom)}${prep}` };
|
|
501
549
|
}
|
|
502
550
|
|
|
503
551
|
export async function gateStatus(o: GateCtx): Promise<RunResult> {
|
package/src/runtime/publish.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* the forge whether it is already done, so a re-run resumes and a step done by hand is accepted. */
|
|
5
5
|
import { existsSync, readFileSync } from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
|
-
import { pickReleaseNotes, prepOnlyChange, sq } from "../core.ts";
|
|
7
|
+
import { newestTaggedVersion, parseVersion, pickReleaseNotes, prepOnlyChange, releaseCallProof, sq } from "../core.ts";
|
|
8
8
|
import type { Config, FlowState } from "../core.ts";
|
|
9
9
|
import { featDir, gateCwd, mergeBase, releaseTags, sh, tail, writeState } from "./base.ts";
|
|
10
10
|
|
|
@@ -18,7 +18,7 @@ export const publishWait = {
|
|
|
18
18
|
clock: () => Date.now(),
|
|
19
19
|
checks: (pr: number, cwd: string): Promise<PrCheck[] | null> => prChecks(pr, cwd),
|
|
20
20
|
/** the CI runs a commit started — the merge commit, before it is tagged (gh#271) */
|
|
21
|
-
commitChecks: (sha: string, cwd: string): Promise<PrCheck[] | null> => commitRuns(sha, cwd),
|
|
21
|
+
commitChecks: (sha: string, cwd: string, branch?: string): Promise<PrCheck[] | null> => commitRuns(sha, cwd, branch),
|
|
22
22
|
/** gh#275: a check pending this long has its Actions job asked directly — GitHub can leave a check run
|
|
23
23
|
* `in_progress` for good after its job concluded */
|
|
24
24
|
staleMs: 5 * 60_000,
|
|
@@ -39,12 +39,14 @@ async function actionsConclusion(link: string, cwd: string): Promise<string | nu
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/** Workflow runs of one commit as checks; [] when none started, null when gh cannot say. */
|
|
42
|
-
async function commitRuns(sha: string, cwd: string): Promise<PrCheck[] | null> {
|
|
43
|
-
const r = await sh(`gh run list --commit ${sha} --limit 50 --json status,conclusion,name,url`, cwd, 60_000);
|
|
42
|
+
async function commitRuns(sha: string, cwd: string, branch?: string): Promise<PrCheck[] | null> {
|
|
43
|
+
const r = await sh(`gh run list --commit ${sha} --limit 50 --json status,conclusion,name,url,headBranch`, cwd, 60_000);
|
|
44
44
|
if (!r.ok) return null;
|
|
45
|
-
const rows = jsonArray<{ status?: string; conclusion?: string; name?: string; url?: string }>(r.out);
|
|
45
|
+
const rows = jsonArray<{ status?: string; conclusion?: string; name?: string; url?: string; headBranch?: string }>(r.out);
|
|
46
46
|
if (rows === null) return r.out.trim() ? null : [];
|
|
47
|
-
|
|
47
|
+
// the merge commit's own CI ran on the default branch: a run a tag push started on the same commit is the
|
|
48
|
+
// release's publish job, not a check on the merge — a refused tag's red run must not hold the next tag back
|
|
49
|
+
return rows.filter((x) => !branch || !x.headBranch || x.headBranch === branch).map((x) => ({ name: x.name ?? "run", bucket: checkBucket({ status: (x.status ?? "").toUpperCase(), conclusion: (x.conclusion ?? "").toUpperCase() }), link: x.url ?? "" }));
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
export interface PrCheck { name: string; bucket: string; link: string }
|
|
@@ -108,8 +110,8 @@ export const awaitPrChecks = (pr: number, cwd: string): Promise<CiVerdict> =>
|
|
|
108
110
|
});
|
|
109
111
|
|
|
110
112
|
/** gh#271: wait (bounded) for the CI the merge commit started — a tag publishes from it, so it is cut on green only. */
|
|
111
|
-
export const awaitCommitChecks = (sha: string, cwd: string): Promise<CiVerdict> =>
|
|
112
|
-
awaitChecks(() => publishWait.commitChecks(sha, cwd), cwd, { who: `merge commit ${sha.slice(0, 9)}`, read: `gh run list --commit ${sha}`, none: "no CI ran on the merge commit", green: "merge-commit CI green" });
|
|
113
|
+
export const awaitCommitChecks = (sha: string, cwd: string, branch?: string): Promise<CiVerdict> =>
|
|
114
|
+
awaitChecks(() => publishWait.commitChecks(sha, cwd, branch), cwd, { who: `merge commit ${sha.slice(0, 9)}`, read: `gh run list --commit ${sha}`, none: "no CI ran on the merge commit", green: "merge-commit CI green" });
|
|
113
115
|
|
|
114
116
|
async function awaitChecks(read: () => Promise<PrCheck[] | null>, cwd: string, l: { who: string; read: string; none: string; green: string; stuck?: string }): Promise<CiVerdict> {
|
|
115
117
|
const start = publishWait.clock();
|
|
@@ -203,13 +205,30 @@ async function prBody(root: string, cwd: string, cfg: Config, state: FlowState):
|
|
|
203
205
|
const authored = prBodyFile(root, state.slug);
|
|
204
206
|
if (existsSync(authored)) return readFileSync(authored, "utf8").trim();
|
|
205
207
|
const file = cfg.release.changelog ? path.join(cwd, cfg.release.changelog) : "";
|
|
206
|
-
const entry = pickReleaseNotes({ changelog: file && existsSync(file) ? readFileSync(file, "utf8") : null, version: state.releaseVersion ?? null, annotation: "" }).notes;
|
|
208
|
+
const entry = pickReleaseNotes({ changelog: file && existsSync(file) ? readFileSync(file, "utf8") : null, version: state.releaseVersion ?? (cfg.versioning.file ? await versionAt("HEAD", cfg.versioning.file, cwd) : null), annotation: "" }).notes;
|
|
207
209
|
if (entry) return entry;
|
|
208
210
|
const base = await mergeBase(cwd, cfg.defaultBranch);
|
|
209
211
|
const log = await sh(`git log -n 30 --format='- %s' ${base ? `${sq(base)}..HEAD` : "HEAD"}`, cwd);
|
|
210
212
|
return log.ok ? log.out.trim() : "";
|
|
211
213
|
}
|
|
212
214
|
|
|
215
|
+
/** The version `file` says at `ref`, or null when it is not there. */
|
|
216
|
+
async function versionAt(ref: string, file: string, cwd: string): Promise<string | null> {
|
|
217
|
+
const r = await sh(`git show ${sq(`${ref}:${file}`)} 2>/dev/null`, cwd);
|
|
218
|
+
return r.ok && r.out.trim() ? parseVersion(file, r.out) : null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** The release call against the version `file` says at `ref` — what the tag would be — counted from the newest
|
|
222
|
+
* tag. Null when it holds (or there is no call to prove); `version` is what `ref` carries. */
|
|
223
|
+
async function callAt(ref: string, base: string | null, state: FlowState, cfg: Config, tags: string[], cwd: string): Promise<{ version: string | null; bad: { error: string; want?: string } | null }> {
|
|
224
|
+
const file = cfg.versioning.file!;
|
|
225
|
+
const version = await versionAt(ref, file, cwd);
|
|
226
|
+
const newest = newestTaggedVersion(cfg.versioning.pattern, tags);
|
|
227
|
+
const baseVer = base ? await versionAt(base, file, cwd) : null;
|
|
228
|
+
const bad = state.versionChoice ? releaseCallProof(state.versionChoice, version, newest ? cfg.versioning.pattern.replace("{version}", newest) : null, baseVer, file) : null;
|
|
229
|
+
return { version, bad };
|
|
230
|
+
}
|
|
231
|
+
|
|
213
232
|
export type PublishResult = { ok: true; log: string } | { ok: false; text: string };
|
|
214
233
|
|
|
215
234
|
/** gh#259: the files a merge of `HEAD` into `origin/<default>` would conflict in, from a fresh fetch — [] when it
|
|
@@ -254,9 +273,17 @@ export async function publishRelease(root: string, state: FlowState, cfg: Config
|
|
|
254
273
|
else {
|
|
255
274
|
// gh#259: a conflict with the default branch is known before the push — never spend the CI wait to learn it
|
|
256
275
|
const d = cfg.defaultBranch;
|
|
257
|
-
const resolve = `merge origin/${d} into ${br} in the worktree (git merge origin/${d}), resolve the conflicts — keep both sides' changelog lines; a version file takes the bump past the newest release — and commit`;
|
|
258
276
|
const conflicts = await mergeConflicts(wt, d);
|
|
277
|
+
// the call, proven on what would merge: a flow that released since Release? moves the number, and the branch
|
|
278
|
+
// must say so before anything is pushed — never a tag that disagrees with the version file it lands on
|
|
279
|
+
const versioned = !state.noVersion && !!cfg.versioning.file;
|
|
280
|
+
const tagsNow = versioned ? await releaseTags(root) : [];
|
|
281
|
+
if (tagsNow === null) return stop("cannot list tags on origin", "check the network and git credentials");
|
|
282
|
+
const atHead = versioned ? await callAt("HEAD", await mergeBase(wt, d), state, cfg, tagsNow, wt) : null;
|
|
283
|
+
const want = atHead?.bad?.want ? ` and set ${cfg.versioning.file} to ${atHead.bad.want} (the release call, ${state.versionChoice}, counted from the newest tag)${cfg.release.changelog ? ` with its ${cfg.release.changelog} heading` : ""}` : "";
|
|
284
|
+
const resolve = `merge origin/${d} into ${br} in the worktree (git merge origin/${d}), resolve the conflicts — keep both sides' changelog lines${want || (versioned ? "; the version file stays one step of the release call past the newest tag" : "")} — and commit`;
|
|
259
285
|
if (conflicts?.length) return stop(`${br} conflicts with origin/${d} in ${conflicts.join(", ")} — the merge would be refused after the CI wait, so nothing was pushed`, resolve);
|
|
286
|
+
if (atHead?.bad) return stop(`${atHead.bad.error} — nothing was merged`, atHead.bad.want ? `set ${cfg.versioning.file} to ${atHead.bad.want}${cfg.release.changelog ? ` and its ${cfg.release.changelog} heading` : ""} on ${br} (merge origin/${d} first if it moved) and commit` : "fix the version on the branch and commit");
|
|
260
287
|
const remote = await sh(`git ls-remote origin ${sq(`refs/heads/${br}`)}`, wt, 60_000);
|
|
261
288
|
if (!remote.ok) return stop(`cannot reach origin:\n${tail(remote.out, 5)}`, "check the network and git credentials");
|
|
262
289
|
if (remote.out.split(/\s/)[0] === head) steps.push("branch already on origin");
|
|
@@ -315,25 +342,40 @@ export async function publishRelease(root: string, state: FlowState, cfg: Config
|
|
|
315
342
|
state.publish = { ...state.publish, pr: merged.number, merged: oid };
|
|
316
343
|
writeState(root, state);
|
|
317
344
|
await sh(`git fetch -q origin ${sq(cfg.defaultBranch)}`, root, 5 * 60_000);
|
|
318
|
-
if (state.
|
|
319
|
-
const tag = cfg.versioning.pattern.replace("{version}", state.releaseVersion);
|
|
345
|
+
if (!state.noVersion && cfg.versioning.file) {
|
|
320
346
|
const tags = await releaseTags(root);
|
|
321
347
|
if (tags === null) return stop("cannot list tags on origin", "check the network and git credentials");
|
|
322
|
-
|
|
323
|
-
|
|
348
|
+
// the version of record is the merged tree's own: read now, never pinned at Release? (a merge of the default
|
|
349
|
+
// branch after it may have re-bumped), and held to the release call once more before anything is tagged
|
|
350
|
+
if (!oid) return stop(`PR #${merged.number} shows no merge commit to tag`, "tag what shipped yourself (git tag -a <tag>) and push it");
|
|
351
|
+
if (!(await sh(`git cat-file -e ${sq(`${oid}^{commit}`)}`, root)).ok) return stop(`the merge commit ${oid.slice(0, 9)} of PR #${merged.number} is not in this clone after a fetch`, `git fetch origin ${cfg.defaultBranch}`);
|
|
352
|
+
const atMerge = await callAt(oid, `${oid}^1`, state, cfg, tags, root);
|
|
353
|
+
if (!atMerge.version) return stop(`${cfg.versioning.file} has no parsable version at the merge commit ${oid.slice(0, 9)} — the tag was not cut`, "fix it forward on the default branch, then tag by hand");
|
|
354
|
+
const tag = cfg.versioning.pattern.replace("{version}", atMerge.version);
|
|
355
|
+
if (tags.includes(tag)) {
|
|
356
|
+
// a resume finds its own tag on the merge commit; the same name on another commit is another flow's release
|
|
357
|
+
const at = await sh(`git ls-remote origin ${sq(`refs/tags/${tag}`)} ${sq(`refs/tags/${tag}^{}`)}`, root, 60_000);
|
|
358
|
+
const rows = at.out.split("\n").map((l) => l.split(/\s+/)).filter((r) => r.length >= 2);
|
|
359
|
+
const sha = (rows.find((r) => r[1].endsWith("^{}")) ?? rows[0])?.[0] ?? "";
|
|
360
|
+
if (at.ok && sha && sha !== oid) return stop(`merged, but the tag was not cut: ${tag} is already on origin at ${sha.slice(0, 9)}, not on the merge commit ${oid.slice(0, 9)} — another release took that number`, "tell the operator; fix the version forward in a new flow");
|
|
361
|
+
state.releaseVersion = atMerge.version;
|
|
362
|
+
steps.push(`tag ${tag} already on origin`);
|
|
363
|
+
} else {
|
|
364
|
+
if (atMerge.bad) return stop(`merged, but the tag was not cut: ${atMerge.bad.error} (at the merge commit ${oid.slice(0, 9)})`, "tell the operator — a release landed since this branch was checked; fix the version forward in a new flow, or tag by hand on their word");
|
|
365
|
+
state.releaseVersion = atMerge.version;
|
|
324
366
|
// gh#271: the tag publishes from the merge commit — wait for that commit's own CI before cutting it, so a
|
|
325
367
|
// playbook rule "test green on the merge commit before the tag" is something this gate can honour
|
|
326
368
|
if (oid && cfg.release.tagWait !== "none") {
|
|
327
|
-
const ci = await awaitCommitChecks(oid, root);
|
|
369
|
+
const ci = await awaitCommitChecks(oid, root, cfg.defaultBranch);
|
|
328
370
|
if (!("why" in ci)) steps.push(ci.note);
|
|
329
371
|
else if (ci.state === "running") return { ok: false, text: `publish waiting — ${ci.why}; the tag waits for it${steps.length ? `\ndone so far: ${steps.join(" · ")}` : ""}\n↪ next: re-run flow release to keep waiting — do not end the turn on a promise to watch` };
|
|
330
372
|
else if (ci.state === "red")
|
|
331
373
|
return stop(`${ci.why} — merged, but the tag was not cut: it would publish a red build`, `tell the operator. A flaky job: re-run it (gh run rerun --failed <run>), then re-run flow release, which tags on green. A real failure is fixed forward in a new flow, and the tag goes on the fix by the operator's word (or tagWait = none under ## release for a project whose tag publishes nothing)`);
|
|
332
374
|
else return stop(ci.why, "check gh auth status, or tag the merge commit yourself once its CI is green");
|
|
333
375
|
}
|
|
334
|
-
|
|
335
|
-
if (
|
|
336
|
-
if (!
|
|
376
|
+
const local = await sh(`git rev-parse -q --verify ${sq(`refs/tags/${tag}^{commit}`)}`, root);
|
|
377
|
+
if (local.ok && local.out.trim() !== oid) return stop(`a local tag ${tag} points at ${local.out.trim().slice(0, 9)}, not the merge commit ${oid.slice(0, 9)}`, `git tag -d ${tag} if it is a leftover`);
|
|
378
|
+
if (!local.ok) {
|
|
337
379
|
// the merge commit by sha, not origin/<default>: a parallel flow that landed after it stays out of the tag
|
|
338
380
|
const mk = await sh(`git tag -a ${sq(tag)} -m ${sq(tag)} ${sq(oid)}`, root);
|
|
339
381
|
if (!mk.ok) return stop(`creating tag ${tag} failed:\n${tail(mk.out, 5)}`, "fix what git reports");
|
package/src/runtime/ship.ts
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
/** dev-flow runtime — The gates that ship: verify, release, release-done, finish. Moved out of extensions/dev-flow.ts as is (exports added). */
|
|
2
2
|
import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { skipsChecks, applicableItems, changelogVersionsBetween, normalizeReleaseBody, pendingEntryLines, pickReleaseNotes, checklistHash, checklistPending, cmpVersions, freshenChecks, healthProbe, mergeShapeProof, preReleaseGate, reflectionNudges, conflictMarkerLines, isReleaseOnly, looksLikeShellError, needsOperator, newestTaggedVersion, nextHint, releaseGate, parseVersion, roadmapDoneForSlug, sq, tagNotesCommand, verifyGate, versionTagGate, servedBuildMatches, prepFiles, versionArg, playbookVersionChoice, describeVersionChoice, majorBump,
|
|
4
|
+
import { foldCallError, skipsChecks, applicableItems, changelogVersionsBetween, normalizeReleaseBody, pendingEntryLines, pickReleaseNotes, checklistHash, checklistPending, cmpVersions, freshenChecks, healthProbe, mergeShapeProof, preReleaseGate, reflectionNudges, conflictMarkerLines, isReleaseOnly, looksLikeShellError, needsOperator, newestTaggedVersion, nextHint, releaseGate, parseVersion, roadmapDoneForSlug, sq, tagNotesCommand, verifyGate, versionTagGate, servedBuildMatches, prepFiles, versionArg, playbookVersionChoice, describeVersionChoice, majorBump, releaseCallQuestion, releaseCallProof, cmpRelease, versionCore, resolvedDevEnv, reviewOwed, localDefaultAhead, failTail, operatorDirt } from "../core.ts";
|
|
5
5
|
import type { Config, FlowState } from "../core.ts";
|
|
6
6
|
import { AGENT_MARK } from "../present.ts";
|
|
7
|
-
import { refreshDocsCode, buildSkew, copyWarning, currentBranch, featDir, flagValue, forgeMergeStyle, forgeOf, gateCwd, mergeBase, needState, now, originUrl, readReflectionsText, readRoadmap, readState, releaseTags, roadmapFile, sh, tail, worktreeAbs, writeState } from "./base.ts";
|
|
7
|
+
import { manifestAt, recordReleaseCall, refreshDocsCode, buildSkew, copyWarning, currentBranch, featDir, flagValue, forgeMergeStyle, forgeOf, gateCwd, mergeBase, needState, now, originUrl, readReflectionsText, readRoadmap, readState, releaseTags, roadmapFile, sh, tail, worktreeAbs, writeState } from "./base.ts";
|
|
8
8
|
import { type RunResult, ago, releaseDevSlot, keepThroughPrep, branchState, catchUp, describeBranchState, devEnv, devPortOf, devSlotCheck, healthRerunsAfterDeploy, pendingChecks, probeHealth, readDevPorts, runChecks, slotKey, triedNote, unreleasedOnMain, worktreeFingerprint, writeDevPorts } from "./checks.ts";
|
|
9
9
|
import { type GateCtx, markPendingAsk } from "./gates.ts";
|
|
10
10
|
import { closeLinkedReflections } from "./reflect.ts";
|
|
11
11
|
import { gatePublishes, prBodyOwed, publishRelease } from "./publish.ts";
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
13
|
+
/** The release call, asked with Verified? only for a flow approved before Approve? carried it — null when the
|
|
14
|
+
* playbook decides, the flow has no manifest to version, or the call is on record (the usual case). */
|
|
15
15
|
function versionQuestion(root: string, state: FlowState, cfg: Config): { ask: string; flags: string } | null {
|
|
16
16
|
if (!cfg.versioning.file || playbookVersionChoice(cfg) || state.versionChoice) return null;
|
|
17
|
-
|
|
18
|
-
const now = existsSync(file) ? parseVersion(cfg.versioning.file, readFileSync(file, "utf8")) : null;
|
|
19
|
-
const kinds = (["patch", "minor", "major"] as const).map((k) => `${k}${bumpVersion(now, k) ? ` (→ ${bumpVersion(now, k)})` : ""}`).join(", ");
|
|
20
|
-
return {
|
|
21
|
-
ask: `also ask the release call: a ${kinds} release — propose one by the playbook's versioning rule${now ? ` (${cfg.versioning.file} is at ${now})` : ""} — or merge unreleased (no bump, no tag)${state.docs ? "; a docs flow usually merges unreleased" : ""}`,
|
|
22
|
-
flags: "--version=patch|minor|major (or the exact version they named) or --no-version (merge unreleased)",
|
|
23
|
-
};
|
|
17
|
+
return releaseCallQuestion(manifestAt(gateCwd(root, state), cfg.versioning.file), cfg.versioning.file, state.docs);
|
|
24
18
|
}
|
|
25
19
|
|
|
26
20
|
export async function gateVerify(o: GateCtx): Promise<RunResult> {
|
|
@@ -28,9 +22,11 @@ export async function gateVerify(o: GateCtx): Promise<RunResult> {
|
|
|
28
22
|
const { state, err } = needState(root, sess, slugArg);
|
|
29
23
|
if (err) return err;
|
|
30
24
|
const items = applicableItems(cfg, state!, "implement");
|
|
31
|
-
//
|
|
25
|
+
// the release call is made at Approve?; a --version/--no-version on the Verified? answer changes it (or makes it, for an older flow)
|
|
32
26
|
const verArg = versionArg(flagValue(o.rest, "version"), flag("no-version"));
|
|
33
27
|
if ("error" in verArg) return { text: `verify gate FAILED:\n- ${verArg.error}`, isError: true };
|
|
28
|
+
const foldErr = foldCallError(state!, verArg.choice);
|
|
29
|
+
if (foldErr) return { text: `verify gate FAILED:\n- ${foldErr}`, isError: true };
|
|
34
30
|
// the operator reviews the tree that ships: catch up with the default branch before anything runs
|
|
35
31
|
const caught = state!.stage === "implement" ? await catchUp(root, state!, cfg, flag("confirmed")) : { note: "" };
|
|
36
32
|
if ("text" in caught) return caught;
|
|
@@ -194,19 +190,11 @@ export async function gateVerify(o: GateCtx): Promise<RunResult> {
|
|
|
194
190
|
const vHead = await sh("git rev-parse HEAD", gateCwd(root, state!));
|
|
195
191
|
if (vHead.ok && vHead.out.trim()) state!.verifiedHead = vHead.out.trim();
|
|
196
192
|
else delete state!.verifiedHead;
|
|
197
|
-
//
|
|
193
|
+
// the call made at Approve? stands; a --version/--no-version on this confirmed call is the operator changing it
|
|
194
|
+
const was = state!.versionChoice;
|
|
198
195
|
const choice = verArg.choice ?? state!.versionChoice ?? playbookVersionChoice(cfg);
|
|
199
|
-
if (choice)
|
|
200
|
-
|
|
201
|
-
const mf = cfg.versioning.file ? path.join(gateCwd(root, state!), cfg.versioning.file) : "";
|
|
202
|
-
const from = mf && existsSync(mf) ? parseVersion(cfg.versioning.file!, readFileSync(mf, "utf8")) : null;
|
|
203
|
-
if (from) state!.versionFrom = from;
|
|
204
|
-
}
|
|
205
|
-
state!.versionChoice = choice;
|
|
206
|
-
if (choice === "unreleased") state!.noVersion = true;
|
|
207
|
-
else delete state!.noVersion;
|
|
208
|
-
}
|
|
209
|
-
const choiceNote = choice ? `\nrelease call: ${describeVersionChoice(choice, state!.versionFrom)}` : "";
|
|
196
|
+
if (choice) recordReleaseCall(root, state!, cfg, choice);
|
|
197
|
+
const choiceNote = choice ? `\nrelease call: ${describeVersionChoice(choice, state!.versionFrom)}${was && was !== choice ? ` (changed from ${describeVersionChoice(was)})` : ""}` : "";
|
|
210
198
|
const before = state!.stage;
|
|
211
199
|
state!.stage = "pre-release";
|
|
212
200
|
// gh#254: what the operator says after this point is said over a tree they verified — the release gate reads it
|
|
@@ -236,17 +224,30 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
236
224
|
if (err) return err;
|
|
237
225
|
// Release? was answered on an earlier call: this one resumes publishing where it stopped (CI still running,
|
|
238
226
|
// a red check fixed, a PR merged by hand) — nothing is asked again
|
|
227
|
+
// --version=<kind> / --no-version change the call made at Approve? (the operator changed their mind) — on any
|
|
228
|
+
// call before the tag, a resumed publish included
|
|
229
|
+
const relArg = versionArg(flagValue(o.rest, "version"), flag("no-version"));
|
|
230
|
+
if ("error" in relArg) return { text: `release gate FAILED:\n- ${relArg.error}`, isError: true };
|
|
231
|
+
const foldErr = foldCallError(state!, relArg.choice);
|
|
232
|
+
if (foldErr) return { text: `release gate FAILED:\n- ${foldErr}`, isError: true };
|
|
239
233
|
if (state!.stage === "release" && state!.approvals["pre-release"]) {
|
|
240
234
|
if (state!.approvals.release) return { text: `release already recorded.\n${AGENT_MARK}next: ${nextHint(state!, cfg)}` };
|
|
235
|
+
let callNote = "";
|
|
236
|
+
if (relArg.choice && relArg.choice !== state!.versionChoice) {
|
|
237
|
+
if (state!.publish?.tag) return { text: `release gate FAILED:\n- ${state!.publish.tag} is already tagged — the release call cannot change after the tag`, isError: true };
|
|
238
|
+
if (!flag("confirmed")) return { text: needsOperator(`change the release call from ${state!.versionChoice ? describeVersionChoice(state!.versionChoice) : "none"} to ${describeVersionChoice(relArg.choice)}`, "Release call?", `this is the operator's word — on it, re-run flow release --confirmed ${relArg.choice === "unreleased" ? "--no-version" : `--version=${relArg.choice}`}`), isError: true };
|
|
239
|
+
if ((relArg.choice === "unreleased") !== !!state!.noVersion && state!.publish?.merged)
|
|
240
|
+
return { text: `release gate FAILED:\n- PR #${state!.publish.pr} already merged ${state!.noVersion ? "unversioned" : "with a version bump"} — switching between versioned and unreleased after the merge is a new flow's work`, isError: true };
|
|
241
|
+
recordReleaseCall(root, state!, cfg, relArg.choice);
|
|
242
|
+
writeState(root, state!);
|
|
243
|
+
callNote = `release call changed (confirmed by operator instruction): ${describeVersionChoice(relArg.choice)}`;
|
|
244
|
+
}
|
|
241
245
|
if (await gatePublishes(cfg, forgeOf(cfg, await originUrl(root)), root)) {
|
|
242
246
|
if (!state!.publish) state!.publish = {};
|
|
243
|
-
return publishAndRecord(o, state!,
|
|
247
|
+
return publishAndRecord(o, state!, callNote);
|
|
244
248
|
}
|
|
249
|
+
if (callNote) return { text: `${callNote}\n${AGENT_MARK}next: ${nextHint(state!, cfg)}` };
|
|
245
250
|
}
|
|
246
|
-
// operator's word at Release?: this flow ships without a version bump or tag — recorded only once Release? is answered.
|
|
247
|
-
// gh#198: --version=<v> / --no-version here re-make the call recorded with Verified? (the operator changed their mind)
|
|
248
|
-
const relArg = versionArg(flagValue(o.rest, "version"), flag("no-version"));
|
|
249
|
-
if ("error" in relArg) return { text: `release gate FAILED:\n- ${relArg.error}`, isError: true };
|
|
250
251
|
const choice = relArg.choice ?? state!.versionChoice ?? playbookVersionChoice(cfg);
|
|
251
252
|
const noVersion = choice === "unreleased" || (!relArg.choice && !!state!.noVersion);
|
|
252
253
|
// (versioned) items stand down on an unversioned flow — the set confirmed here is the one that applies to it
|
|
@@ -326,32 +327,18 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
326
327
|
const staleNow = new Set(freshenChecks(state!, fpRelease));
|
|
327
328
|
if (staleNow.size || keptThroughPrep.length) writeState(root, state!);
|
|
328
329
|
const owedWhy = (n: string) => (staleNow.has(n) ? "the tree changed since it passed" : failedBefore.has(n) ? "its last run failed" : "no run on record");
|
|
329
|
-
//
|
|
330
|
-
//
|
|
331
|
-
//
|
|
332
|
-
const tagOf = (v: string) => cfg.versioning.pattern.replace("{version}", v);
|
|
330
|
+
// the branch must carry the call the operator made — the kind of step, counted from the newest tag now, so a
|
|
331
|
+
// flow that released first moves this one along. It runs before the generic proofs: when a parallel flow
|
|
332
|
+
// released first, "already tagged" alone would send the agent round a loop.
|
|
333
333
|
const newest = cfg.versioning.file && !noVersion ? newestTaggedVersion(cfg.versioning.pattern, remoteTags) : null;
|
|
334
|
-
if (cfg.versioning.file && choice
|
|
335
|
-
const re = "ask the operator, then re-run with --version=<their call> or --no-version and --confirmed on their answer";
|
|
334
|
+
if (cfg.versioning.file && choice) {
|
|
336
335
|
let baseVer: string | null = null;
|
|
337
336
|
if (markerBase) {
|
|
338
337
|
const was = await sh(`git show ${sq(`${markerBase}:${cfg.versioning.file}`)} 2>/dev/null`, wtCwd);
|
|
339
338
|
baseVer = was.ok && was.out.trim() ? parseVersion(cfg.versioning.file, was.out) : null;
|
|
340
339
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const from = newest ?? baseVer ?? state!.versionFrom ?? null;
|
|
344
|
-
const want = bumpVersion(from, choice);
|
|
345
|
-
const moved = from && state!.versionFrom && from !== state!.versionFrom ? ` — ${tagOf(from)} was released since Verified? (the call was counted from ${state!.versionFrom} then)` : "";
|
|
346
|
-
if (want && manifestVer !== want)
|
|
347
|
-
return { text: `release gate FAILED:\n- the operator's call is a ${choice} release: bump ${cfg.versioning.file} to ${want} (${choice} past ${from})${moved}, and head its changelog entry ${want} — it says ${manifestVer ?? "no version"}`, isError: true };
|
|
348
|
-
} else if (choice !== "unreleased") {
|
|
349
|
-
if (remoteTags.includes(tagOf(choice)))
|
|
350
|
-
return { text: `release gate FAILED:\n- ${choice}, the operator's call at Verified?, is taken: ${tagOf(choice)} was released since (another flow got there first) — ${re}; propose the same kind of step past ${newest ?? choice}, never pick the number yourself`, isError: true };
|
|
351
|
-
if (manifestVer && manifestVer !== choice)
|
|
352
|
-
return { text: `release gate FAILED:\n- the operator's release call is ${choice}, but ${cfg.versioning.file} says ${manifestVer} — bump it to ${choice}, or, if the call changed, ${re}`, isError: true };
|
|
353
|
-
} else if (manifestVer && baseVer && baseVer !== manifestVer)
|
|
354
|
-
return { text: `release gate FAILED:\n- the operator's call is to merge unreleased, but the branch bumps ${cfg.versioning.file} ${baseVer} → ${manifestVer} — revert the bump (the entry goes under Unreleased), or, if the call changed, ${re}`, isError: true };
|
|
340
|
+
const bad = releaseCallProof(choice, manifestVer, newest ? cfg.versioning.pattern.replace("{version}", newest) : null, baseVer, cfg.versioning.file);
|
|
341
|
+
if (bad) return { text: `release gate FAILED:\n- ${bad.error}${bad.want && cfg.release.changelog ? `, and head its ${cfg.release.changelog} entry with that version` : ""}`, isError: true };
|
|
355
342
|
}
|
|
356
343
|
// tier-2 pre-release confirmation is recorded by this very command, so it is excluded here
|
|
357
344
|
// The checks this gate needs green are run by the gate, as verify does (#84) — after the cheap proofs, so a
|
|
@@ -471,7 +458,7 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
471
458
|
: cfg.versioning.file && !choice
|
|
472
459
|
? "no release call on record — ask it with Release?: patch, minor, major, or merge unreleased"
|
|
473
460
|
: relArg.choice && relArg.choice !== state!.versionChoice
|
|
474
|
-
? `the release call
|
|
461
|
+
? `the release call changes (${state!.versionChoice ?? "none"} → ${relArg.choice}) — changing it is the operator's word`
|
|
475
462
|
: postVerify
|
|
476
463
|
? "commits beyond release prep landed after Verified?"
|
|
477
464
|
: stale
|
|
@@ -482,13 +469,13 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
482
469
|
? `${newest} → ${manifestVer} is a major bump — the playbook's versioned call does not choose that`
|
|
483
470
|
: "";
|
|
484
471
|
const auto = onChange && !askWhy;
|
|
485
|
-
let audit = confirmed ? " (confirmed by operator instruction)" : auto ? ` (auto-answered: release.ask = on-change — ${describeVersionChoice(choice ?? "next", state!.versionFrom)}
|
|
472
|
+
let audit = confirmed ? " (confirmed by operator instruction)" : auto ? ` (auto-answered: release.ask = on-change — ${describeVersionChoice(choice ?? "next", state!.versionFrom)} is the call on record, and only release prep landed since Verified?)` : state!.yolo ? " (yolo: pre-confirmed)" : "";
|
|
486
473
|
const askPending = !auto && !confirmed && (!state!.yolo || !!yoloHeld);
|
|
487
474
|
if (askPending) {
|
|
488
475
|
markPendingAsk(root, state!, "Release?");
|
|
489
476
|
if (!ui.hasUI) {
|
|
490
477
|
const callAsk = cfg.versioning.file && !choice ? " — also ask the release call: a patch, minor or major release, or merge unreleased (no bump, no tag)?" : "";
|
|
491
|
-
return { text: needsOperator(`ready to publish${yoloHeld ? ` (${yoloHeld})` : ""}${askWhy ? ` (asked: ${askWhy})` : ""}${stale ? ` — also: ${staleAsk}` : ""}${postVerify ? ` — ${postVerify}` : ""}${callAsk}`, "Release?", `re-run with --confirmed once the operator answered 'Release?' in chat${stale ? " (and the stale-build question)" : ""}${callAsk ? " (add --version=patch|minor|major
|
|
478
|
+
return { text: needsOperator(`ready to publish${yoloHeld ? ` (${yoloHeld})` : ""}${askWhy ? ` (asked: ${askWhy})` : ""}${stale ? ` — also: ${staleAsk}` : ""}${postVerify ? ` — ${postVerify}` : ""}${callAsk}`, "Release?", `re-run with --confirmed once the operator answered 'Release?' in chat${stale ? " (and the stale-build question)" : ""}${callAsk ? " (add --version=patch|minor|major or --no-version for their release call)" : ""}`), isError: true };
|
|
492
479
|
}
|
|
493
480
|
const ok = await ui.confirm("Enter release", `Release ${state!.slug}${manifestVer ? ` v${manifestVer}` : ""}${noVersion ? " (unversioned — merge + changelog entry only: no bump, no tag for this flow)" : ""}? Publishing starts: PR, merge${noVersion ? "" : ", tag"} — release-done afterwards needs no further answer.${staleAsk ? `\n\n${staleAsk}` : ""}${postVerify ? `\n\n${postVerify}` : ""}${yoloHeld ? `\n\n(${yoloHeld})` : ""}`);
|
|
494
481
|
if (!ok) {
|
|
@@ -498,9 +485,9 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
498
485
|
}
|
|
499
486
|
audit = " (confirmed in dialog)";
|
|
500
487
|
}
|
|
488
|
+
if (choice) recordReleaseCall(root, state!, cfg, choice);
|
|
501
489
|
if (noVersion) state!.noVersion = true;
|
|
502
490
|
else delete state!.noVersion;
|
|
503
|
-
if (choice) state!.versionChoice = choice;
|
|
504
491
|
if (unverifiedChange) state!.friction = (state!.friction ?? 0) + 1;
|
|
505
492
|
state!.confirmations = { ...state!.confirmations, "pre-release": { hash: checklistHash(items), at: now() } };
|
|
506
493
|
state!.approvals["pre-release"] = now();
|
|
@@ -513,9 +500,9 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
513
500
|
: changelogBase.source === "none"
|
|
514
501
|
? " Warning: no tag or merge base to compare against, so the changelog fold was not proven — check the entry by hand."
|
|
515
502
|
: "";
|
|
516
|
-
// the version of record is
|
|
517
|
-
// re-
|
|
518
|
-
|
|
503
|
+
// no number is pinned here: the version of record is read when the tag is cut, from the tree that merged
|
|
504
|
+
// (a merge of the default branch after this point may re-bump it), and checked against the call again
|
|
505
|
+
delete state!.releaseVersion;
|
|
519
506
|
if (stale) state!.staleBuild = `${behind} (${selfBuild.label} ${selfBuild.version ?? "?"})`;
|
|
520
507
|
delete state!.pendingAsk;
|
|
521
508
|
// on GitHub the gate runs the release stage itself: the Release? answer (or its self-answer) is what authorizes
|
|
@@ -594,9 +581,13 @@ export async function gateReleaseDone(o: GateCtx): Promise<RunResult> {
|
|
|
594
581
|
const { state, err } = needState(root, sess, slugArg);
|
|
595
582
|
if (err) return err;
|
|
596
583
|
const errs = releaseGate(state!);
|
|
597
|
-
// the version of record is what
|
|
598
|
-
|
|
599
|
-
|
|
584
|
+
// the version of record is what shipped (#52) — never a re-read of a main checkout that may be behind: what the
|
|
585
|
+
// gate tagged, else the merge commit's own version file, else the feature branch's head (a hand-run publish)
|
|
586
|
+
const shippedAt = state!.publish?.merged || (state!.branch && (await sh(`git rev-parse -q --verify ${sq(`refs/heads/${state!.branch}`)}`, root)).ok ? state!.branch : "");
|
|
587
|
+
const shipped = !state!.releaseVersion && cfg.versioning.file && !state!.noVersion && shippedAt ? await sh(`git show ${sq(`${shippedAt}:${cfg.versioning.file}`)} 2>/dev/null`, root) : null;
|
|
588
|
+
const manifestVer: string | null = state!.releaseVersion ?? (shipped?.ok && shipped.out.trim() ? parseVersion(cfg.versioning.file!, shipped.out) : null);
|
|
589
|
+
if (manifestVer && !state!.noVersion) state!.releaseVersion = manifestVer;
|
|
590
|
+
if (cfg.versioning.file && !state!.noVersion && !manifestVer) errs.push(`no version to record: ${cfg.versioning.file} has none at ${shippedAt || "the feature branch"} — fix the playbook, or ship this flow unversioned`);
|
|
600
591
|
const expectedTag = manifestVer ? cfg.versioning.pattern.replace("{version}", manifestVer) : null;
|
|
601
592
|
const origin = await originUrl(root);
|
|
602
593
|
const hasOrigin = origin !== null;
|
|
@@ -615,7 +606,7 @@ export async function gateReleaseDone(o: GateCtx): Promise<RunResult> {
|
|
|
615
606
|
// never publish behind what the forge already has — that is how a stale manifest republished
|
|
616
607
|
// the previous version and its artifact probe passed (#52)
|
|
617
608
|
const newest = newestTaggedVersion(cfg.versioning.pattern, tags);
|
|
618
|
-
if (newest &&
|
|
609
|
+
if (newest && cmpRelease(newest, manifestVer) > 0) errs.push(`${cfg.versioning.pattern.replace("{version}", newest)} is already tagged — refusing to release ${expectedTag} behind it`);
|
|
619
610
|
if (!verrs.length) {
|
|
620
611
|
const reach = await sh(`git merge-base --is-ancestor ${sq(expectedTag)} origin/${cfg.defaultBranch} 2>/dev/null || git merge-base --is-ancestor ${sq(expectedTag)} ${cfg.defaultBranch}`, root);
|
|
621
612
|
if (!reach.ok) errs.push(`tag ${expectedTag} is not reachable from ${cfg.defaultBranch} — tag what actually shipped on ${cfg.defaultBranch}`);
|
|
@@ -866,19 +857,21 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
|
|
|
866
857
|
// transcripts and .dev-flow/<slug>/tmp, and finish is about to drop that folder and the binding — a
|
|
867
858
|
// reflection asked for after finish has nothing bound to run against. Only the operator's explicit
|
|
868
859
|
// --no-reflect skips it; yolo never does (it answers checkpoints, it does not waive the review).
|
|
869
|
-
|
|
860
|
+
// a fold flow fixes reflections; it does not review for new ones — it never runs the closing reflection
|
|
861
|
+
const fold = !!state!.reflections?.length;
|
|
862
|
+
const skipReflect = flag("no-reflect") && !fold;
|
|
870
863
|
if (skipReflect && !flag("confirmed")) return { text: "--no-reflect is the operator's word — ask them whether to skip the closing reflection, then re-run with --no-reflect --confirmed", isError: true };
|
|
871
864
|
// a flow that never hit a refusal, a guard block or a change shipped after Verified?, with no friction note
|
|
872
865
|
// from the operator, has nothing
|
|
873
866
|
// for the reflection worker to find — skip the worker run unless the playbook says reflect = always
|
|
874
867
|
const note = flagValue(o.rest, "note") ?? "";
|
|
875
|
-
const quiet = !state!.reflectedAt && !skipReflect && cfg.release.reflect !== "always" && !(state!.friction ?? 0) && !note.trim();
|
|
868
|
+
const quiet = !state!.reflectedAt && !skipReflect && (fold || (cfg.release.reflect !== "always" && !(state!.friction ?? 0) && !note.trim()));
|
|
876
869
|
if (quiet) {
|
|
877
870
|
state!.reflectedAt = now();
|
|
878
871
|
state!.reflectQuiet = true;
|
|
879
872
|
writeState(root, state!);
|
|
880
873
|
}
|
|
881
|
-
const quietNote = quiet ? " closing reflection skipped: no refusals, guard blocks or unverified changes this flow (playbook reflect = always runs it anyway)." : "";
|
|
874
|
+
const quietNote = quiet && fold ? " closing reflection skipped: a fold flow (it fixes reflections, it does not review for new ones)." : quiet ? " closing reflection skipped: no refusals, guard blocks or unverified changes this flow (playbook reflect = always runs it anyway)." : "";
|
|
882
875
|
if (!state!.reflectedAt && !skipReflect) {
|
|
883
876
|
const skipHint = "or — only on the operator's explicit word — flow finish --no-reflect --confirmed";
|
|
884
877
|
if (!o.hooks.reflect) return { text: `finish: no reflection recorded for ${state!.slug} and no reflect worker available here — run flow_stage(op: "reflect") first, ${skipHint}`, isError: true };
|