pi-dev-flow 0.87.0 → 0.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +8 -5
- package/docs/gates.md +4 -4
- package/docs/playbook.md +6 -0
- package/extensions/dev-flow.ts +10 -2
- package/package.json +1 -1
- package/skills/dev-flow/SKILL.md +2 -1
- package/skills/dev-flow/references/implement.md +7 -1
- package/skills/dev-flow/references/pre-release.md +23 -7
- package/skills/dev-flow/references/release.md +4 -2
- package/src/core.ts +56 -4
- package/src/present.ts +2 -2
- package/src/projectmd.ts +20 -0
- package/src/runtime/base.ts +1 -1
- package/src/runtime/gates.ts +23 -8
- package/src/runtime/grants.ts +65 -0
- package/src/runtime/ship.ts +184 -27
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,24 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.89.0] - 2026-11-09
|
|
8
|
+
|
|
9
|
+
**The release call is made with Verified?, and Release? answers itself when nothing but the release prep changed.**
|
|
10
|
+
|
|
11
|
+
- The versioned-or-unreleased call is now made with Verified? instead of at Release? (gh#198). On a versioned project the Verified? question also asks "a patch, minor or major release, or merge unreleased?", and `flow verify --confirmed --version=patch|minor|major` (or an exact version) / `--no-version` records the answer, so pre-release prepares the right bump (or the Unreleased line) the first time. A playbook can make the call for every flow with `version = versioned | unversioned`. A patch/minor/major call is counted from the newest tag at release time, so when another flow ships the number first the gate names the next one instead of looping between "already tagged" and "not the chosen version". The release gate refuses a bump that doesn't match the call, an exact version another flow already took (with a request to ask the operator again), and a bump on a flow that merges unreleased.
|
|
12
|
+
- Release? now answers itself by default (`ask = on-change` in `## release`) when the call is on record and nothing but release prep landed after Verified?. It still asks, and says why, when code changed after Verified?, no call is recorded, the session build is stale, `yolo = until-release` is set, or a playbook-made versioned call turns out to be a major bump. Set `ask = always` to have Release? asked on every flow, as before.
|
|
13
|
+
|
|
14
|
+
## [0.88.0] - 2026-11-09
|
|
15
|
+
|
|
16
|
+
**Recording a release waits for its CI, review fixes can be re-verified, and `--confirmed` needs your actual word.**
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- **A feature folder that lost its state file is no longer a dead end (gh#178).** If `.dev-flow/<slug>/` survived without `state.json` and had no `plan/`, the two commands sent you in a circle. `flow start` said "already exists, flow use it", and `flow use` said "no unfinished feature". Both now say the folder is a ghost and list what's in it. `flow start <slug> --confirmed` adopts it and keeps its files. A leftover `worktree/` is the one exception: a new start would collide with it, so `flow start` refuses and names the cleanup to run first.
|
|
20
|
+
- **`--confirmed` needs an actual operator message (gh#190).** `--confirmed` means "the operator answered in chat", but nothing checked that, so the agent could grant an operator-only option to itself. Two sessions showed it. In one, a `flow start --ui` refusal came straight back with `--confirmed`. In the other, a plain `flow start` was switched to `--ui --confirmed` without asking. The flow tool now counts your messages in the session and refuses two things. First, a `--confirmed` re-run of a gate that asked for your word, when you haven't sent a message since it asked. Second, turning on `--ui`, `--patch` or `--docs` for a feature this session started, when you haven't sent a message since the start. It doesn't judge what you said: one message after the question is enough. The refusal counts as friction for the closing reflection.
|
|
21
|
+
- **Review fixes can be verified before release (gh#187).** The pre-release review often turns up fixes that change behaviour, but `flow verify` refused at pre-release. Those fixes shipped under a Verified? you had given over the earlier build, and nothing could re-ask it. At pre-release, `flow verify` now redeploys the current tree and asks Verified? again. Your answer moves the verdict to that tree, and the flow stays in pre-release. A yolo given earlier doesn't answer this question, because it was given before the fixes existed.
|
|
22
|
+
- **The "commits after Verified?" warning no longer counts the release-prep commit.** The version bump and changelog entry always land after Verified?, so the warning fired on every versioned release. That made a real unverified fix look the same as routine release prep. The warning now leaves out a commit that touches the version file, or that touches only the version file and changelog. That includes bump commits that also rewrite an image tag elsewhere. The warning still names those commits, as "release prep … not counted". The same rule decides whether the closing reflection treats a post-Verified? commit as friction.
|
|
23
|
+
- **Recording a release waits for the publish CI instead of failing on it (gh#179).** The tag push is what starts the CI that publishes the artifact, so the artifact check in `flow release-done` (and in `flow finish`, which runs the same proofs) used to fail right after the tag with "not found". The agent then had to watch the CI run by hand and re-run the gate. On GitHub, a missing artifact now makes the gate look for the CI runs that the tag started. If one is still running, the gate waits for it, up to 15 minutes plus a minute's grace for a registry that lags the run, and then checks again. If a run failed, the refusal names it with its URL. If the run is still going when the wait ends, the refusal points at it. If the tag started no run at all, the gate says so after a minute. Without GitHub, or without `gh`, the check behaves as before.
|
|
24
|
+
|
|
7
25
|
## [0.87.0] - 2026-11-09
|
|
8
26
|
|
|
9
27
|
**Fewer false alarms, more reflections where they matter, and a way to drop a roadmap item.**
|
package/README.md
CHANGED
|
@@ -103,6 +103,7 @@ walking five stages with a gate between each:
|
|
|
103
103
|
│ pre-release │ review, docs, changelog entry, version bump
|
|
104
104
|
└────────┬────────┘
|
|
105
105
|
Release? · refuses unless the version passes the last tag and the changelog agrees
|
|
106
|
+
(answers itself when only that prep changed since Verified?)
|
|
106
107
|
┌────────▼────────┐
|
|
107
108
|
│ release │ PR → merge → annotated tag → release notes
|
|
108
109
|
└────────┬────────┘
|
|
@@ -115,12 +116,12 @@ walking five stages with a gate between each:
|
|
|
115
116
|
| Stage | What the agent does | It asks you |
|
|
116
117
|
|---|---|---|
|
|
117
118
|
| **plan** | reads the code, asks its clarifying questions, writes the spec to `.dev-flow/session-renewal/plan/plan.md` | **Approve?** — the plan is right, build it |
|
|
118
|
-
| **implement** | works in a fresh worktree on `feat/session-renewal`, commits in small steps, runs your `test` command to green, walks the manual checks with you | **Verified?** — after you used it running |
|
|
119
|
-
| **pre-release** | review and fixes, docs, changelog,
|
|
119
|
+
| **implement** | works in a fresh worktree on `feat/session-renewal`, commits in small steps, runs your `test` command to green, walks the manual checks with you | **Verified?** — after you used it running; with it, the release call: a patch, minor or major release, or merge unreleased |
|
|
120
|
+
| **pre-release** | review and fixes, docs, changelog, the bump you chose, checks re-run; shows the PR summary and the version it tags | **Release?** — only when something beyond that prep changed since Verified? (set `ask = always` under `## release` to be asked every time) |
|
|
120
121
|
| **release** | PR → merge → annotated tag → release notes; only here may git touch main | **Finish?** — clean up, we're done |
|
|
121
122
|
| **done** | removes the worktree, branch and `.dev-flow/session-renewal/` | — |
|
|
122
123
|
|
|
123
|
-
|
|
124
|
+
Three or four answers from you; everything between them was the agent's problem and your playbook's gates. If
|
|
124
125
|
the feature grows mid-flight it is folded into this one (the plan gains an `Added mid-stage:` line and
|
|
125
126
|
checks re-run); a *different* problem waits for the next flow — one feature, one plan, one PR.
|
|
126
127
|
|
|
@@ -131,8 +132,10 @@ Your answers at a checkpoint:
|
|
|
131
132
|
back with every check still enforced. Attach your wishes to the word: *"yolo, patch bump"*,
|
|
132
133
|
*"yolo, no tag"*. Release? is asked anyway when commits landed after Verified?, or always when
|
|
133
134
|
the playbook sets `yolo = until-release` under `## release`.
|
|
134
|
-
- **
|
|
135
|
-
versioned release folds your `Unreleased` entry under its
|
|
135
|
+
- **merge unreleased** (the release call at Verified?, or a change of mind at Release?) — merge and
|
|
136
|
+
changelog land, no bump or tag; the next versioned release folds your `Unreleased` entry under its
|
|
137
|
+
heading. A patch/minor/major call is turned into a number when the release runs, so a parallel flow
|
|
138
|
+
that ships first just moves yours to the next one.
|
|
136
139
|
|
|
137
140
|
Two things you grant rather than run: a **mode** when the agent proposes one (`normal` is the
|
|
138
141
|
default; `--patch` for a small change you intend to ship now, `--docs` for docs-only work — both skip
|
package/docs/gates.md
CHANGED
|
@@ -11,15 +11,15 @@ so it needs no `--confirmed`. The agent's own `flow` call never opens a dialog (
|
|
|
11
11
|
|
|
12
12
|
| Gate | Advances | Refuses unless |
|
|
13
13
|
|---|---|---|
|
|
14
|
-
| `start <slug> [--ui|--patch|--docs --confirmed] [--merge=squash\|merge\|rebase\|any] [--check-upstream]` | → plan | slug is new (binds the session); `--ui` and the relaxed modes are operator-granted in chat, anchored by `--confirmed` (`--ui` = the plan gate demands rendered mockups; on an existing feature still at plan, `start <slug> --ui --confirmed` from its bound session switches the flag on instead of refusing); `--patch` = chore release, no plan document, every gate unchanged; `--docs` = docs-only, no plan document and no tier-1 checks (worktree and release intact). Start prints the dev-flow build and stamps it into the feature state (`flow status` shows `flow=<ver>`), warns when **this session runs an older build than the checkout** (`--check-upstream` also asks npm for the published one), prints the playbook gaps `flow doctor` would report — and **refuses while the playbook has no `merge` policy**: it names the question (squash / merge / rebase / any), the style its own history suggests, and the re-run `--merge=<style> --confirmed`, which writes the answer into `## release` (single-line insert, validated, `.bak` kept, committed as a playbook chore only when the playbook is the only dirty path) and never asks again |
|
|
14
|
+
| `start <slug> [--ui|--patch|--docs --confirmed] [--merge=squash\|merge\|rebase\|any] [--check-upstream]` | → plan | slug is new (binds the session); a `.dev-flow/<slug>/` left without `state.json` is a **ghost** it names with its contents and adopts on `--confirmed`, keeping the files (a `plan/` becomes the draft) — except a leftover `worktree/`, which it refuses with the cleanup to run first (gh#178); `use <slug>` on a ghost says the same instead of "no unfinished feature"; `--ui` and the relaxed modes are operator-granted in chat, anchored by `--confirmed` (`--ui` = the plan gate demands rendered mockups; on an existing feature still at plan, `start <slug> --ui --confirmed` from its bound session switches the flag on instead of refusing); `--patch` = chore release, no plan document, every gate unchanged; `--docs` = docs-only, no plan document and no tier-1 checks (worktree and release intact). Start prints the dev-flow build and stamps it into the feature state (`flow status` shows `flow=<ver>`), warns when **this session runs an older build than the checkout** (`--check-upstream` also asks npm for the published one), prints the playbook gaps `flow doctor` would report — and **refuses while the playbook has no `merge` policy**: it names the question (squash / merge / rebase / any), the style its own history suggests, and the re-run `--merge=<style> --confirmed`, which writes the answer into `## release` (single-line insert, validated, `.bak` kept, committed as a playbook chore only when the playbook is the only dirty path) and never asks again |
|
|
15
15
|
| `use <slug>` | — (binds this session to a feature) | slug unfinished — the binding is persisted to disk as a claim (`flow version` lists every dev-flow copy registered in the process, and a copy whose in-memory bindings never saw the bind attributes commands from the claim, so a two-sources setup does not misjudge your git) |
|
|
16
16
|
| `approve [--yolo]` | plan → implement (creates worktree + branch) | `plan/plan.md` exists **by name** (a separate pre-plan/direction file does not open the gate — a preliminary direction belongs inside plan.md); if `--ui`, rendered mockup screenshots (per `mockupGlobs`, default `*.png`) exist under `plan/` — headless chromium renders embedded in plan.md, and the gate opens plan.md to prove it: every image file under `plan/` must appear in an embed (``, case-insensitive) and every `mockups/<screen>.html` must carry an embedded `<screen>-<width>.` shot, and no mockup may link (href/src/@import) into another feature's `.dev-flow/<other>/worktree/`; **one question** — or `--confirmed` after you answered in chat; **yolo** (your chat answer at **any** checkpoint question) → run that gate with `--yolo --confirmed` (`approve`/`verify`/`release`/`finish`): that question is answered and every later one (Verified?/Release?/Finish?) is pre-confirmed — the agent then runs the remaining gates back to back, honoring guidance attached to the yolo word (e.g. "yolo, create a patch version release") — checks and guardrails stay fully enforced. `commands.setup` runs in the worktree and is retried until it succeeds once (a worktree left behind by a failed setup is set up on the next `approve`, never silently reused); a `--docs` feature runs no project command at all and says `setup skipped (docs mode)` |
|
|
17
17
|
| `test` | records a check | — (runs the `test` command/check, records pass/fail) |
|
|
18
18
|
| `check` | records all tier-1 checks | — (runs every `flow-check`/test/health from project.md `## implement`); a `--docs` feature runs none of them and says `docs mode: project commands skipped` — a docs flow builds nothing, so a fresh checkout must not read as a failed deploy (#96) |
|
|
19
19
|
| `health` | records a check | — (runs `seedData` + the health command, retrying up to `healthWait` seconds; app must be up locally with real data) |
|
|
20
|
-
| `verify [--yolo] [--port=<n>\|--replace]` | implement → pre-release | **without `--confirmed` it is the review deploy**: it fetches and, when the branch is behind `origin/<default>` (or local `<default>` with no remote), **rebases** it — untracked files never block, uncommitted tracked edits and conflicts refuse (the rebase is aborted, the branch untouched); when the dev port (playbook `port`, or the whole stack when none is set) was last deployed by **another live flow** it refuses with `NEEDS-OPERATOR Dev port?`, the measured RAM/disk against `instanceMem`/`instanceDisk`, and the options: run alongside on the next free port (offered only when `parallelDev` is not `no`, `dev`/`health` read `$DEV_FLOW_PORT`, and the resources fit), `--replace`, or wait — nothing is built first; then it deploys and returns `deployed for review` with the chat question. **With `--confirmed`** it never rewrites history: a default branch that moved since refuses (re-run `flow verify`). With `servedBuild` set the served commit must be the worktree's HEAD. Otherwise: all tier-1 checks green — a check with no passing record is **run by the gate itself** (`checks ran at the gate (test)`) rather than refused and pointed at `flow check`, since entering the stage or editing the worktree is what cleared it — and so is a record whose worktree fingerprint differs from the tree now (`stale record(s) rerun after a worktree change: …`): a change made through bash fires no edit-tool hook, the fingerprint is what notices the tree moved — and a failure there prints the run output, **the feature branch holds at least one commit** (verify refuses a branch with nothing committed — the checks describe the working tree, so an uncommitted state has never been recorded — except a **release-only flow** (#161): on a versioned project an empty branch over unreleased commits on the default branch (since the newest local version tag, or all of them before the first release) passes, the line says `release-only flow: N unreleased commit(s)`, and the version bump is the pre-release commit; with nothing unreleased the refusal says there is nothing to release; and prints `commits: N ahead of <default>, M uncommitted path(s)` with what it ran; uncommitted paths are reported, never gated), build (if configured) green, `dev` deploy (if configured) runs first so you can review the running app **and the health probe (if configured) re-runs against what it just deployed, retrying every 2s up to `healthWait` seconds** (a failing probe refuses the gate and reports how many attempts it took: the `flow check` PASS predates the deploy, and a service that needs seconds after its container starts is not a broken deploy; with no probe the output says `health: none configured`); with **no `dev` command but a `health` probe configured the gate live-re-probes the app before asking** (`health: live re-probe PASS` — a killed server refuses with `live probe FAILED`, because process death dirties no worktree fingerprint and a green record alone cannot prove liveness: start the app and rerun), tier-2 checklist (ui-only items excluded for non-UI features) confirmed as a set; a `--docs` feature runs none of it (`docs mode: project commands skipped`) and only asks you; **one question** — or `--confirmed`; `--yolo --confirmed` = you answered 'yolo' at Verified? — answers it and pre-confirms the rest |
|
|
21
|
-
| `release [--yolo|--no-version|--no-fold-check|--no-marker-check]` | pre-release → release | checks re-greened after the prep edits; `release.preflight` (when set) passes in the worktree — the build the tag will trigger, proven before anything ships; **the branch adds no merge-conflict marker lines** vs its merge base (#164: a hand-resolved merge that kept a `<<<<<<<`/`>>>>>>>` line is refused with `file:line`; `--no-marker-check` on the operator's word when the lines are meant); **commits after Verified?** are named in the Release? question and the approved line (#162: the operator's word covers the HEAD verify stamped — a warning, never a refusal); a **standing yolo** (given at an earlier checkpoint) does not answer Release? when such commits exist, nor ever under `yolo = until-release` in `## release` — the gate returns NEEDS-OPERATOR Release? (gh#176), while `--confirmed` (the operator's answer, a yolo said at Release? included) still passes; **the worktree holds no uncommitted paths** (gh#131: a merge ships the branch, not the working tree — an uncommitted fix at this gate is a fix that never ships; the refusal lists the paths, and the approved line prints `commits: N ahead of <default>, M uncommitted path(s)` like verify's); with `versioning.file`: the manifest version parses and is **not tagged yet** (the bump must be ahead of the last release); with `release.changelog` the gate **proves the entry mechanically** (#97): a **heading names the version** (prose that mentions it, or a `1.2.0-beta` section when releasing `1.2.0`, is not an entry), **this branch touched the file** (an inherited changelog is not release prep), **every entry that was pending before the release survives inside the new section** — compared on normalized lines, so re-indenting a fold is free while rewording or deleting one is refused by naming the line — and **nothing is left under `Unreleased`**. The proofs guard the **baseline's** pending lines — they do not freeze the wording of the entry this flow writes, so a branch that landed as several iteration commits is free to state its result as one entry (see the changelog-writer rule in the pre-release reference). The pending baseline is the newest tag's changelog (what actually shipped), else the branch's merge base; when neither resolves, the two git-dependent proofs are skipped **with a printed advisory** rather than refusing a legal release for a topology reason, and the content proofs (the heading, its body) always run; tier-2 `## pre-release` checklist confirmed; the manifest version it validates is **stamped as the release's version of record** (`release-done` publishes that, whatever the checkouts say later); **one question** (Release?) — or `--confirmed`; `--no-version` (your call at Release?) ships this flow as **merge + changelog** — the bump/tag requirements and the tag checks at `release-done` are skipped for it, but the branch must still add its **own line under `Unreleased`** (a `--docs` flow is exempt — #163: a playbook/docs change owes no user-facing entry; one it writes is welcome, not proven) (editing an older section releases nothing) and it rides there until the next versioned release folds it (default: versioned); `--no-fold-check` is the operator-granted escape from the line-level fold proofs — one flow, stamped in the gate output, the heading and touched proofs stay; **stale session build** (loaded build behind the checkout): the gate prints both builds, lists what shipped between them (those proofs will not run this release) and folds *update (/reload, then re-run) or proceed with the old release?* into the Release? question — the operator's word, recorded in the release output, **never a block**: publishing under an older gate is a legitimate choice (hotfix, offline reload) |
|
|
22
|
-
| `release-done` | records the release (the stage stays `release`) | **no question — the Release? answer covered the publication**; verify approval; the version published is the one `release` **stamped** from the manifest it validated (a main checkout still behind cannot republish the previous version), and it must not be older than the newest matching tag **on origin** (tag lists come from `git ls-remote`, so an unfetched clone does not decide what exists; when an origin exists but cannot be asked (offline, no ssh agent) **both release gates refuse** rather than answering with local tags); with `versioning.file`: that tag exists, is reachable from the default branch **and is on origin** (a local-only tag is not a release); with `release.artifact`: the published-artifact check runs (`{version}`/`{tag}` placeholders — the line it prints names the version it verified; skip once with `--no-artifact-check`, operator-instructed only) · creates the forge release from the tag, its body **the `release.changelog` entry for that version** — the changelog is the source of truth, and the tag's annotation stands in only when the changelog has no entry for the version, else nothing (and it says why — a body that is really a shell error is dropped, never shipped) — `gh` for GitHub, `glab` for GitLab) and then **proves the release exists**: it asks the forge (`gh release view <tag>` / `glab release view <tag>`) and refuses when nothing is there, because #51, #60 and #63 were three ways of ending `release recorded as complete` with nothing published — and when the changelog was the body it **reads the stored body back** and refuses a mismatch, so the release page and the changelog cannot drift (#97; normalized before comparing, skipped with a printed note on another forge). Skipping is deliberate and loud — `--no-release-create`, `release.releases = false` or `forge = self` each print that no forge release was created, and the view check is skipped for them; **with a `merge` policy** it also proves the merge that shipped matches it — branch ancestry plus what the forge says (`gh pr view` / `glab api`), so a squash under `merge = merge` (or a merge commit under `merge = squash`) refuses the release record, while a shape it cannot see prints an advisory instead (#97's split: an invisible topology never blocks a legal release); when the release went out on a stale build the operator acknowledged at the release gate, it prints that acknowledgement in place of the after-the-fact version-skew warning, and that warning prints the session vs disk version pair plus the duplicate-copy note when a second copy is registered (#117) |
|
|
20
|
+
| `verify [--yolo] [--port=<n>\|--replace] [--version=<v>\|--no-version]` | implement → pre-release | **the release call rides on Verified?** (gh#198): on a versioned project (`versionFile`) whose playbook leaves `version = ask`, the NEEDS-OPERATOR Verified? also asks *a patch, minor or major release (each with the number it makes from the manifest's current version), or merge unreleased?*, and `--confirmed --version=patch|minor|major` (or an exact `--version=<v>`) / `--confirmed --no-version` records the answer (`release call: …` in the output, the version on the stage line) so pre-release prepares the right thing; a playbook `version = versioned \| unversioned` makes the call for every flow, and a re-verify keeps the recorded call unless it is given again; **at pre-release it is the re-verify** (gh#187): after review fixes it runs the same build, deploy and probes over the current tree (no rebase), re-asks Verified? — a standing yolo never answers it — and on the answer moves the verdict (`verifiedHead`) to that tree, staying in pre-release; **without `--confirmed` it is the review deploy**: it fetches and, when the branch is behind `origin/<default>` (or local `<default>` with no remote), **rebases** it — untracked files never block, uncommitted tracked edits and conflicts refuse (the rebase is aborted, the branch untouched); when the dev port (playbook `port`, or the whole stack when none is set) was last deployed by **another live flow** it refuses with `NEEDS-OPERATOR Dev port?`, the measured RAM/disk against `instanceMem`/`instanceDisk`, and the options: run alongside on the next free port (offered only when `parallelDev` is not `no`, `dev`/`health` read `$DEV_FLOW_PORT`, and the resources fit), `--replace`, or wait — nothing is built first; then it deploys and returns `deployed for review` with the chat question. **With `--confirmed`** it never rewrites history: a default branch that moved since refuses (re-run `flow verify`). With `servedBuild` set the served commit must be the worktree's HEAD. Otherwise: all tier-1 checks green — a check with no passing record is **run by the gate itself** (`checks ran at the gate (test)`) rather than refused and pointed at `flow check`, since entering the stage or editing the worktree is what cleared it — and so is a record whose worktree fingerprint differs from the tree now (`stale record(s) rerun after a worktree change: …`): a change made through bash fires no edit-tool hook, the fingerprint is what notices the tree moved — and a failure there prints the run output, **the feature branch holds at least one commit** (verify refuses a branch with nothing committed — the checks describe the working tree, so an uncommitted state has never been recorded — except a **release-only flow** (#161): on a versioned project an empty branch over unreleased commits on the default branch (since the newest local version tag, or all of them before the first release) passes, the line says `release-only flow: N unreleased commit(s)`, and the version bump is the pre-release commit; with nothing unreleased the refusal says there is nothing to release; and prints `commits: N ahead of <default>, M uncommitted path(s)` with what it ran; uncommitted paths are reported, never gated), build (if configured) green, `dev` deploy (if configured) runs first so you can review the running app **and the health probe (if configured) re-runs against what it just deployed, retrying every 2s up to `healthWait` seconds** (a failing probe refuses the gate and reports how many attempts it took: the `flow check` PASS predates the deploy, and a service that needs seconds after its container starts is not a broken deploy; with no probe the output says `health: none configured`); with **no `dev` command but a `health` probe configured the gate live-re-probes the app before asking** (`health: live re-probe PASS` — a killed server refuses with `live probe FAILED`, because process death dirties no worktree fingerprint and a green record alone cannot prove liveness: start the app and rerun), tier-2 checklist (ui-only items excluded for non-UI features) confirmed as a set; a `--docs` feature runs none of it (`docs mode: project commands skipped`) and only asks you; **one question** — or `--confirmed`; `--yolo --confirmed` = you answered 'yolo' at Verified? — answers it and pre-confirms the rest |
|
|
21
|
+
| `release [--yolo|--version=<v>|--no-version|--no-fold-check|--no-marker-check]` | pre-release → release | **the branch carries the release call** (gh#198), checked before the generic version proofs: a patch/minor/major call is **counted from the newest tag at release time**, so when a parallel flow released the number first the refusal names the new one (`bump VERSION to 1.2.0 (minor past 1.1.0) — v1.1.0 was released since Verified?`) and the call still stands; an exact version another flow already tagged is refused as **taken**, for the operator to re-make; a manifest that does not say the version the operator chose, or a bump on a flow whose call is *merge unreleased* (the manifest differs from the merge base's), is refused — re-make the call with `--version=<v>` / `--no-version` and `--confirmed` on the operator's word; **`release.ask = on-change`** (the default; `ask = always` asks every time) answers Release? itself (`auto-answered: release.ask = on-change — …` in the approved line) when the call is on record, a Verified? tree is on record, nothing but release prep landed after it, the session build is current, the playbook does not set `yolo = until-release`, and a playbook-made versioned call is not a major bump — otherwise Release? is asked as before, naming why (`asked: …`) — a call re-made on the release command without `--confirmed` is one of those reasons, since the call is the operator's, and with no call on record it asks that too; checks re-greened after the prep edits; `release.preflight` (when set) passes in the worktree — the build the tag will trigger, proven before anything ships; **the branch adds no merge-conflict marker lines** vs its merge base (#164: a hand-resolved merge that kept a `<<<<<<<`/`>>>>>>>` line is refused with `file:line`; `--no-marker-check` on the operator's word when the lines are meant); **commits after Verified?** are named in the Release? question and the approved line (#162: the operator's word covers the HEAD verify stamped — a warning, never a refusal); a **standing yolo** (given at an earlier checkpoint) does not answer Release? when such commits exist, nor ever under `yolo = until-release` in `## release` — the gate returns NEEDS-OPERATOR Release? (gh#176), while `--confirmed` (the operator's answer, a yolo said at Release? included) still passes; **the worktree holds no uncommitted paths** (gh#131: a merge ships the branch, not the working tree — an uncommitted fix at this gate is a fix that never ships; the refusal lists the paths, and the approved line prints `commits: N ahead of <default>, M uncommitted path(s)` like verify's); with `versioning.file`: the manifest version parses and is **not tagged yet** (the bump must be ahead of the last release); with `release.changelog` the gate **proves the entry mechanically** (#97): a **heading names the version** (prose that mentions it, or a `1.2.0-beta` section when releasing `1.2.0`, is not an entry), **this branch touched the file** (an inherited changelog is not release prep), **every entry that was pending before the release survives inside the new section** — compared on normalized lines, so re-indenting a fold is free while rewording or deleting one is refused by naming the line — and **nothing is left under `Unreleased`**. The proofs guard the **baseline's** pending lines — they do not freeze the wording of the entry this flow writes, so a branch that landed as several iteration commits is free to state its result as one entry (see the changelog-writer rule in the pre-release reference). The pending baseline is the newest tag's changelog (what actually shipped), else the branch's merge base; when neither resolves, the two git-dependent proofs are skipped **with a printed advisory** rather than refusing a legal release for a topology reason, and the content proofs (the heading, its body) always run; tier-2 `## pre-release` checklist confirmed; the manifest version it validates is **stamped as the release's version of record** (`release-done` publishes that, whatever the checkouts say later); **one question** (Release?) — or `--confirmed`; `--no-version` (your call at Release?) ships this flow as **merge + changelog** — the bump/tag requirements and the tag checks at `release-done` are skipped for it, but the branch must still add its **own line under `Unreleased`** (a `--docs` flow is exempt — #163: a playbook/docs change owes no user-facing entry; one it writes is welcome, not proven) (editing an older section releases nothing) and it rides there until the next versioned release folds it (default: versioned); `--no-fold-check` is the operator-granted escape from the line-level fold proofs — one flow, stamped in the gate output, the heading and touched proofs stay; **stale session build** (loaded build behind the checkout): the gate prints both builds, lists what shipped between them (those proofs will not run this release) and folds *update (/reload, then re-run) or proceed with the old release?* into the Release? question — the operator's word, recorded in the release output, **never a block**: publishing under an older gate is a legitimate choice (hotfix, offline reload) |
|
|
22
|
+
| `release-done` | records the release (the stage stays `release`) | **no question — the Release? answer covered the publication**; verify approval; the version published is the one `release` **stamped** from the manifest it validated (a main checkout still behind cannot republish the previous version), and it must not be older than the newest matching tag **on origin** (tag lists come from `git ls-remote`, so an unfetched clone does not decide what exists; when an origin exists but cannot be asked (offline, no ssh agent) **both release gates refuse** rather than answering with local tags); with `versioning.file`: that tag exists, is reachable from the default branch **and is on origin** (a local-only tag is not a release); with `release.artifact`: the published-artifact check runs (`{version}`/`{tag}` placeholders — the line it prints names the version it verified; skip once with `--no-artifact-check`, operator-instructed only; on GitHub a miss right after the tag push **waits for the CI runs that tag started** — up to 15 min, plus a minute's grace for a registry that lags the green run — then probes again, and a refusal names a failed or still-running run with its URL, gh#179) · creates the forge release from the tag, its body **the `release.changelog` entry for that version** — the changelog is the source of truth, and the tag's annotation stands in only when the changelog has no entry for the version, else nothing (and it says why — a body that is really a shell error is dropped, never shipped) — `gh` for GitHub, `glab` for GitLab) and then **proves the release exists**: it asks the forge (`gh release view <tag>` / `glab release view <tag>`) and refuses when nothing is there, because #51, #60 and #63 were three ways of ending `release recorded as complete` with nothing published — and when the changelog was the body it **reads the stored body back** and refuses a mismatch, so the release page and the changelog cannot drift (#97; normalized before comparing, skipped with a printed note on another forge). Skipping is deliberate and loud — `--no-release-create`, `release.releases = false` or `forge = self` each print that no forge release was created, and the view check is skipped for them; **with a `merge` policy** it also proves the merge that shipped matches it — branch ancestry plus what the forge says (`gh pr view` / `glab api`), so a squash under `merge = merge` (or a merge commit under `merge = squash`) refuses the release record, while a shape it cannot see prints an advisory instead (#97's split: an invisible topology never blocks a legal release); when the release went out on a stale build the operator acknowledged at the release gate, it prints that acknowledgement in place of the after-the-fact version-skew warning, and that warning prints the session vs disk version pair plus the duplicate-copy note when a second copy is registered (#117) |
|
|
23
23
|
| `finish [--yolo] [--no-reflect] [--note=<text>] [slug]` | release → done — **records an unrecorded release first** (published but `release-done` never ran: finish runs its proofs itself — that gate asks nothing, so it is not a separate step; its refusal is finish's) — **then the closing reflection**: while no reflection is recorded for the flow, finish starts the reflect worker before it touches anything and stops for the operator's fold/drop (or Finish? when nothing was found); a flow with **no friction** (no gate refusal, no guard block, no `--note`) skips the worker unless the playbook sets `reflect = always`; the re-run with `--confirmed` does the cleanup. `--no-reflect --confirmed` skips it on the operator's explicit word (yolo never does); `--note=` hands the worker the operator's friction notes. Cleanup (removes worktree + branch, deletes `.dev-flow/<slug>/`, and deletes `origin/<branch>` **only** when its merged state is verified — ancestor of the default branch or a merged PR/MR via `gh`/`glab`; unverifiable branches stay with a note) | a release is recorded (`release-done` ran), the main checkout is clean **and** pushed to `origin/<default>`, and the worktree has no uncommitted changes (the refusal lists the paths, not just the count — gh#131); when the clean checkout trails `origin/<default>` the gate **fast-forwards local main** as it closes out (never a merge — anything that cannot fast-forward prints the operator's exact `git pull --ff-only` command); **one question** (Finish? — mentions unmerged-looking commits with the playbook's `merge` policy in mind, and warns when the forge release create failed at `release-done` and no retry succeeded) — or `--confirmed`; under `merge = merge`, commits that never reached the default branch are a **policy violation**: `yolo` does not answer it, only your explicit answer does; to abandon an unreleased feature use `abort` |
|
|
24
24
|
| `reflect ["<note>"|list|tidy|move <n> --playbook|--code|done <n> ["<what>"]]` | — | `reflect "<note>"` queues a suggestion in **this project's** `reflections.md` (never gates; gate flags such as `--confirmed` are ignored, they never become part of the note). `--playbook` (alias `--docs`) files it under `## playbook` — the fix lives only in `project.md`, a docs flow implements it; `--code` files it under `## code` — the fix touches project code, a patch flow implements it. `--plugin` **never writes**: dev-flow feedback is filed upstream, so it prints the recipe — `gh issue list --repo <dev-flow repo> --state all --search …` first, then `gh issue create` with a body ending `— reflection from <slug> <date>` (in the dev-flow repo itself plugin is code → `## code`). With no flag the wording guesses (plugin-shaped → the recipe; otherwise `## playbook`) and the echo prints why. `reflect list` numbers the open items with their section; `reflect move <n> --playbook|--code` re-files one; `reflect done <n> ["<what>"]` checks a fixed one off (`— fixed: <date> <slug> — <what>`) so doctor stops re-reporting it; a legacy `## plugin` row is flagged by list and doctor (file it upstream, check it off `— filed: gh#NNN`). `reflect tidy` drops the closed (`- [x]`) items — the preamble and open items stay verbatim and a `## section` heading left empty goes with its items. **Nudges are timed, not constant**: `⚑ fix the open reflections now?` prints when an item recurred this session, is ≥ 14 days old, ≥ 3 playbook items wait, or a code item waits while between flows — at finish, in an unbound session and in doctor, never mid-feature; `↻ N closed reflection(s)` prints at ≥ 5 closed, closed ≥ open (≥ 3), or a closed item ≥ 30 days old. Bare `reflect` prints the **session-reflection protocol** (from the `/flow reflect` bar it additionally wakes the model): bound to a flow, delegate the review to `flow_stage` op `reflect`; unbound, review inline; re-check every open item against the playbook and **newer dev-flow versions** (`npm view pi-dev-flow version`; the operator performs updates); show the operator a numbered list with a fold/drop recommendation per finding and stop; fold docs/code → `reflect --playbook|--code`, fold plugin → the upstream issue, drop → nothing recorded |
|
|
25
25
|
| `roadmap [add "<feature>" [--slug=<slug>] [--brief=<notes>\|--brief-file=<path>] \| pick <n> <slug> \| done <n> \| drop <n> \| tidy]` | — | manages `.dev-flow/roadmap.md`, the gitignored backlog of future features (`- [ ]` checklist): bare prints the numbered open items, `add` appends one (`--slug=` stamps it like pick, `--brief=`/`--brief-file=` keeps notes under it as ` > ` lines, and a bound session records `— split from <slug>` — the spin-off route for a new feature surfaced mid-flow), `pick <n> <slug>` stamps open item n with `(slug)` so `flow start <slug>` can take it (start seeds `plan/plan.md` with the item and its brief) — **`finish` checks the stamped item off when that feature ships**; `done <n>` checks off by hand (items shipped outside a flow), `drop <n>` (alias `remove`) deletes an open item and its brief that nobody wants any more — `done` would record it as shipped — `tidy` drops the checked lines. Never gates; the open count is surfaced in `status` and session context |
|
package/docs/playbook.md
CHANGED
|
@@ -171,6 +171,12 @@ gate prints `health: none configured` and `flow doctor` flags the combination. T
|
|
|
171
171
|
`merge = squash | merge | rebase | any` — how a merged PR lands on the default branch (see below) — and
|
|
172
172
|
`yolo = all | until-release`: with `until-release` a yolo given at an earlier checkpoint never answers Release?
|
|
173
173
|
(for repos whose rules want the release word given after the commits exist; default `all`) — and
|
|
174
|
+
`version = ask | versioned | unversioned` (gh#198): who makes the release call — `ask` (default) puts *a patch, minor or
|
|
175
|
+
major release, or merge unreleased?* into the Verified? question (a kind is turned into a number at release, from the
|
|
176
|
+
newest tag, so parallel flows never fight over one); the other two make it for every flow — and
|
|
177
|
+
`ask = on-change | always`: with `on-change` (default) Release? answers itself when the call is on record and nothing but
|
|
178
|
+
release prep (the bump, the changelog) changed since Verified? (a stale build, `yolo = until-release` or a major
|
|
179
|
+
bump the operator did not name still ask; `always` asks it every flow, as before 0.89) — and
|
|
174
180
|
`reflect = on-friction | always`: when `flow finish` runs the closing reflection worker. `on-friction` (default)
|
|
175
181
|
skips it for a flow that hit no gate refusal and no guard block and carries no `--note`; `always` runs it every
|
|
176
182
|
time. `## global` also takes
|
package/extensions/dev-flow.ts
CHANGED
|
@@ -34,6 +34,7 @@ import { type Session, presentRun } from "../src/runtime/checks.ts";
|
|
|
34
34
|
import { isSelfRepo } from "../src/runtime/setup.ts";
|
|
35
35
|
import { foldView, pluginUpstream } from "../src/runtime/reflect.ts";
|
|
36
36
|
import { type FlowHooks, runFlow } from "../src/runtime/gates.ts";
|
|
37
|
+
import { grantCheck, grantRecord, newGrantLedger, operatorMessageCount } from "../src/runtime/grants.ts";
|
|
37
38
|
import { PIWEB_SUBAGENT, WORKER_TOOLS, piwebLiveClaim, piwebStamp, piwebWorkerMeta, reflectSeams, sessionHeaders, stageWorkerSpawn, workerName, workerSessions, workerTiming, writeTranscriptDigests } from "../src/runtime/workers.ts";
|
|
38
39
|
export { compactionTakeover } from "../src/runtime/base.ts";
|
|
39
40
|
export { reflectSeams, stageWorkerSpawn, workerTiming } from "../src/runtime/workers.ts";
|
|
@@ -139,6 +140,9 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
139
140
|
};
|
|
140
141
|
};
|
|
141
142
|
|
|
143
|
+
/** Which gate asked for the operator's word, and when features started — per session (gh#190). */
|
|
144
|
+
const grantLedger = newGrantLedger();
|
|
145
|
+
|
|
142
146
|
/** A flow_stage worker: registered in this module's set, or — for a worker pi-web hosts, whose extension
|
|
143
147
|
* instance never saw the registration — stamped with pi-web's subagent entry. */
|
|
144
148
|
const isWorkerSession = (ctx: ExtensionContext): boolean => {
|
|
@@ -230,12 +234,16 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
230
234
|
// the agent's call never opens a dialog (#181): a dialog inside a tool call blocks the turn, so nobody
|
|
231
235
|
// can talk to the agent while it waits, and the agent cannot see who answered. Gates answer with the
|
|
232
236
|
// chat word to ask instead; the /flow slash command (a human at the keyboard) keeps its dialogs.
|
|
233
|
-
|
|
237
|
+
// gh#190: --confirmed stands for the operator's chat answer — refuse it when no operator message came after the question
|
|
238
|
+
const users = operatorMessageCount((() => { try { return ctx.sessionManager?.getBranch(); } catch { return null; } })());
|
|
239
|
+
const selfGrant = grantCheck(params.args, sessionKey(ctx), users, grantLedger);
|
|
240
|
+
const res = selfGrant ? { text: selfGrant, isError: true } : await runFlow(params.args, root, NO_DIALOGS, sessFor(ctx, root), finishReflectHook(id, ctx, root, signal, onUpdate));
|
|
241
|
+
grantRecord(params.args, sessionKey(ctx), users, res, grantLedger);
|
|
234
242
|
if (!res.isError) maybeCompactNow(ctx, root);
|
|
235
243
|
// two readers: the model gets every instruction, the operator's row renders the view (renderResult) —
|
|
236
244
|
// facts, the stage line and the question waiting on them, never a command to type
|
|
237
245
|
// a refusal (not a question for the operator) is friction the closing reflection should look at
|
|
238
|
-
if (res.isError && !res.text.startsWith(NEEDS_OPERATOR) && initiated(root)) noteFriction(root, sessionKey(ctx));
|
|
246
|
+
if (res.isError && (!res.text.startsWith(NEEDS_OPERATOR) || selfGrant) && initiated(root)) noteFriction(root, sessionKey(ctx));
|
|
239
247
|
// a start that bound a feature takes over the refusals this session hit before it existed
|
|
240
248
|
else if (!res.isError && params.args[0] === "start" && initiated(root)) noteFriction(root, sessionKey(ctx), 0);
|
|
241
249
|
const { agent, view } = await presentRun(params.args, root, sessionKey(ctx), res);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.89.0",
|
|
4
4
|
"description": "Enforced feature workflow for Pi: plan → implement → pre-release → release, gated checkpoints, self-improvement reflections, one git worktree per feature, changelog + publish as part of the release",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
package/skills/dev-flow/SKILL.md
CHANGED
|
@@ -23,7 +23,8 @@ criteria hold. Call it with an args array — `["start", "dark-mode"]`,
|
|
|
23
23
|
chat — **Approve? / Verified? / Release? / Finish?** — mentioning that
|
|
24
24
|
*yolo* is an answer, then stop. Their word (or a clear equivalent) in chat →
|
|
25
25
|
run that gate with `--confirmed`. A structured question tool is not chat;
|
|
26
|
-
never infer the answer
|
|
26
|
+
never infer the answer — the flow tool refuses a `--confirmed` with no
|
|
27
|
+
operator message since the gate asked. A gate returning `NEEDS-OPERATOR <Question?>` means:
|
|
27
28
|
ask exactly that, in chat. `/flow` is the operator's own override; mention it
|
|
28
29
|
only when the session is demonstrably stuck or wrong (and `/reload` when
|
|
29
30
|
`flow version` says this session runs an older build).
|
|
@@ -35,7 +35,13 @@ note). Other sessions' worktrees are theirs.
|
|
|
35
35
|
— say what changed for the user and how to see it, not which modules
|
|
36
36
|
changed.
|
|
37
37
|
Report opening: **🔨 implement · `<slug>`** (the gate's stage line).
|
|
38
|
-
|
|
38
|
+
- Versioned project, playbook `version = ask` (the default): the gate's
|
|
39
|
+
question also asks the **release call** — a patch, minor or major
|
|
40
|
+
release (propose one by the playbook's versioning rule) or merge
|
|
41
|
+
unreleased. Record the kind, not a number, unless the operator names one:
|
|
42
|
+
the gate counts it from the newest tag, so a parallel release moves it.
|
|
43
|
+
3. Answer → `flow verify --confirmed` (yolo → `--yolo --confirmed`), plus
|
|
44
|
+
`--version=patch|minor|major` (or `--version=<exact>`) or `--no-version`. If the
|
|
39
45
|
default branch moved since the review deploy it refuses: run `flow verify`
|
|
40
46
|
again first. Fixes → iterate and re-verify; that loop is free.
|
|
41
47
|
|
|
@@ -11,9 +11,17 @@ and settle the scheme with the operator; never invent one.
|
|
|
11
11
|
|
|
12
12
|
1. **Review**: `/flow-review` the change; fix every **Must fix** and **Should
|
|
13
13
|
fix**; `flow check` again if code changed.
|
|
14
|
+
- A fix that changes behaviour → `flow verify` again: it redeploys, then
|
|
15
|
+
ask **Verified?** over the fixed build and run `flow verify --confirmed`
|
|
16
|
+
on the answer (stays in pre-release; a standing yolo does not answer it).
|
|
17
|
+
Otherwise `flow release` warns that the fix shipped after Verified?.
|
|
14
18
|
2. **Docs**: update them to match the change.
|
|
15
19
|
3. **Changelog + bump** — manifest, changelog heading and tag must agree;
|
|
16
|
-
commit the prep on the feature branch.
|
|
20
|
+
commit the prep on the feature branch. The release call recorded with
|
|
21
|
+
Verified? decides which: its kind, counted from the newest tag (the gate
|
|
22
|
+
names the number — another flow that released first moves it), an exact
|
|
23
|
+
version (taken by another flow → ask again, never pick one), or
|
|
24
|
+
*merge unreleased* — no bump, the line goes under `Unreleased`.
|
|
17
25
|
- **The changelog writer reviews the branch, not its commit list**: read
|
|
18
26
|
`git log <default>..HEAD` *and* `git diff <default>...HEAD`, then write
|
|
19
27
|
what the branch delivers in the reader's terms (what was broken, what
|
|
@@ -28,17 +36,25 @@ and settle the scheme with the operator; never invent one.
|
|
|
28
36
|
changelog this branch never touched. `--no-fold-check` only on the
|
|
29
37
|
operator's word.
|
|
30
38
|
4. `flow check` — the prep made the earlier checks stale.
|
|
31
|
-
5. **
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
5. **Run `flow release`.** By default (`ask = on-change`) it answers
|
|
40
|
+
Release? itself when the release call is on record and only the prep
|
|
41
|
+
landed since Verified? — say in a few lines what the PR delivers (the
|
|
42
|
+
changelog entry usually is that) and the version, and carry on with the
|
|
43
|
+
release stage.
|
|
44
|
+
6. **It returned `NEEDS-OPERATOR Release?`** (it says why: code after
|
|
45
|
+
Verified?, no call on record, a stale build, `yolo = until-release`, a
|
|
46
|
+
major bump, or the playbook's `ask = always`) → **ask Release? and
|
|
47
|
+
stop**, with the same summary and the version. Report opening:
|
|
48
|
+
**🔍 pre-release · `<slug>`** (the gate's stage line; the version field
|
|
49
|
+
reads `pending` until decided — never invent a bump or a no-version
|
|
50
|
+
decision). Answer → `flow release --confirmed`.
|
|
36
51
|
- Standing yolo → run `flow release` without asking. It still returns
|
|
37
52
|
`NEEDS-OPERATOR Release?` when commits landed after Verified? or the
|
|
38
53
|
playbook says `yolo = until-release` — then ask.
|
|
39
54
|
- Operator ships **without a version** → `flow release --no-version
|
|
40
55
|
--confirmed`: no bump or tag, but the branch must add its line under
|
|
41
|
-
`Unreleased`.
|
|
56
|
+
`Unreleased`. A changed call is `--version=<v>` / `--no-version` with
|
|
57
|
+
`--confirmed`, on their word.
|
|
42
58
|
|
|
43
59
|
The gate re-checks tier-1, requires the manifest ahead of the last tag and a
|
|
44
60
|
changelog **heading** for that version written on this branch.
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
## Stage: release
|
|
4
4
|
|
|
5
5
|
Main-repo git (merge, tag, push on the default branch) is allowed only here.
|
|
6
|
-
Nothing in this stage asks the operator anything — Release? covered it
|
|
6
|
+
Nothing in this stage asks the operator anything — Release? covered it (answered
|
|
7
|
+
by the operator, or by the gate itself under `ask = on-change`). Report
|
|
7
8
|
each step with the gate's stage line, **🚀 release · `<slug>`**; no `Done:` /
|
|
8
9
|
`Next steps:` block.
|
|
9
10
|
|
|
@@ -19,7 +20,8 @@ each step with the gate's stage line, **🚀 release · `<slug>`**; no `Done:` /
|
|
|
19
20
|
`git push origin v<ver>`. Never `--follow-tags`.
|
|
20
21
|
- CI builds from the tag? `release.preflight` proves that build at
|
|
21
22
|
`flow release`; `release.artifact` makes the record step verify the
|
|
22
|
-
published artifact.
|
|
23
|
+
published artifact. On GitHub it waits for the publish CI the tag
|
|
24
|
+
started (up to 15 min) — no hand-run `gh run watch` before it.
|
|
23
25
|
- `--no-version` flow: no bump, no tag — publish the merge only.
|
|
24
26
|
3. **Hand over to finish.** Once merged and tagged, the playbook continues in
|
|
25
27
|
[finish.md](finish.md): `flow finish` records the release itself first
|
package/src/core.ts
CHANGED
|
@@ -48,6 +48,8 @@ export interface FlowState {
|
|
|
48
48
|
staleBuild?: string; // release ran under an older dev-flow than the checkout by operator choice ("<loaded> (checkout <disk>)"); release-done repeats the acknowledgement
|
|
49
49
|
pendingAsk?: string; // the checkpoint word a gate asked for and has not been given ("Approve?", "Verified?", …) — presentation only (💬 in the footer), it never gates
|
|
50
50
|
releaseOnly?: boolean; // verify found nothing on the branch but unreleased work on main: this flow only cuts the version (#161)
|
|
51
|
+
versionChoice?: string; // the operator's release call, recorded with Verified? (gh#198): patch | minor | major (counted from the newest tag at release, so a parallel flow taking the number moves it), an exact version, "next" (playbook version = versioned: any bump past the last tag) or "unreleased"
|
|
52
|
+
versionFrom?: string; // the manifest version when the call was recorded — what a patch/minor/major call was counted from at Verified?
|
|
51
53
|
verifiedHead?: string; // HEAD the operator's Verified? was given over — release names commits after it, so the word is not recorded as the verdict for a tree nobody looked at (#162)
|
|
52
54
|
reflectedAt?: string; // a reflect worker reported for this flow — finish runs one first while this is unset (only --no-reflect --confirmed skips it)
|
|
53
55
|
devPort?: number; // the port the operator chose for this flow's dev deploy when the default was held by another flow — finish stops it (devDown)
|
|
@@ -119,7 +121,7 @@ export interface Config {
|
|
|
119
121
|
/** Bytes one dev instance needs (playbook `instanceMem` / `instanceDisk`, e.g. 2G) — the side-by-side feasibility check. */
|
|
120
122
|
instanceMem?: number;
|
|
121
123
|
instanceDisk?: number;
|
|
122
|
-
release: { review: string; changelog?: string; releases?: boolean; artifact?: string; preflight?: string; merge?: MergeStyle | "any"; /** `until-release`: a standing yolo never answers Release? (gh#176) */ yolo?: "all" | "until-release"; /** `always`: finish runs the closing reflection even on a flow with no friction */ reflect?: "always" | "on-friction" };
|
|
124
|
+
release: { review: string; changelog?: string; releases?: boolean; artifact?: string; preflight?: string; merge?: MergeStyle | "any"; /** `until-release`: a standing yolo never answers Release? (gh#176) */ yolo?: "all" | "until-release"; /** `always`: finish runs the closing reflection even on a flow with no friction */ reflect?: "always" | "on-friction"; /** who decides versioned vs unreleased: asked with Verified? (`ask`, default) or fixed by the playbook (gh#198) */ version?: "ask" | "versioned" | "unversioned"; /** `on-change` (default): Release? answers itself when nothing but release prep changed since Verified? and the version choice is on record; `always` asks it every time (gh#198) */ ask?: "always" | "on-change" };
|
|
123
125
|
mainHook: boolean; // flow init installs a pre-commit hook blocking main commits
|
|
124
126
|
/** `inject` (default): the class default timeout is armed silently on every shell call.
|
|
125
127
|
* `require`: a shell call without its own visible timeout is refused (costs a turn per miss). */
|
|
@@ -372,7 +374,8 @@ export const isReleaseOnly = (cfg: Config, branch?: BranchState | null): boolean
|
|
|
372
374
|
* committed the operator is asked to approve state no gate has ever seen. */
|
|
373
375
|
export function verifyGate(state: FlowState, cfg: Config, branch?: BranchState | null): string[] {
|
|
374
376
|
const errs: string[] = [];
|
|
375
|
-
|
|
377
|
+
// pre-release: a re-verify after review fixes (gh#187) — the same proofs, over the tree that will ship
|
|
378
|
+
if (state.stage !== "implement" && state.stage !== "pre-release") errs.push(`stage is "${state.stage}", verify only applies to "implement" (or "pre-release", to re-ask Verified? after review fixes)`);
|
|
376
379
|
// a release-only flow (#161) proves main's committed tree here; its version bump is the pre-release commit
|
|
377
380
|
if (branch && branch.commitsAhead === 0 && !isReleaseOnly(cfg, branch))
|
|
378
381
|
errs.push(
|
|
@@ -496,6 +499,49 @@ export function pickReleaseNotes(src: { changelog: string | null; version: strin
|
|
|
496
499
|
return { notes: "", source: "none" };
|
|
497
500
|
}
|
|
498
501
|
|
|
502
|
+
/** gh#198 — the operator's release call: a bump kind (`patch|minor|major`, turned into a number at release from
|
|
503
|
+
* the newest tag), an exact version (`1.2.0`, a pre-release suffix allowed), `next` (the playbook says
|
|
504
|
+
* versioned: any bump past the last tag) or `unreleased` (merge + changelog only). */
|
|
505
|
+
export const VERSION_ARG_RE = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;
|
|
506
|
+
export type BumpKind = "patch" | "minor" | "major";
|
|
507
|
+
export const isBumpKind = (c: string | null | undefined): c is BumpKind => c === "patch" || c === "minor" || c === "major";
|
|
508
|
+
|
|
509
|
+
/** `from` bumped by one `kind` step (a pre-release suffix is dropped), or null when `from` is not x.y.z. */
|
|
510
|
+
export function bumpVersion(from: string | null | undefined, kind: BumpKind): string | null {
|
|
511
|
+
const m = from?.match(/^(\d+)\.(\d+)\.(\d+)/);
|
|
512
|
+
if (!m) return null;
|
|
513
|
+
const [maj, min, pat] = [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
514
|
+
return kind === "major" ? `${maj + 1}.0.0` : kind === "minor" ? `${maj}.${min + 1}.0` : `${maj}.${min}.${pat + 1}`;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/** The call a playbook makes for every flow (`release.version`), or undefined when the operator is asked. */
|
|
518
|
+
export const playbookVersionChoice = (cfg: Config): string | undefined =>
|
|
519
|
+
cfg.release.version === "versioned" ? "next" : cfg.release.version === "unversioned" ? "unreleased" : undefined;
|
|
520
|
+
|
|
521
|
+
/** `to` raises the major version over `from` (1.x → 2.0, and 0.x → 1.0). */
|
|
522
|
+
export function majorBump(from: string, to: string): boolean {
|
|
523
|
+
const maj = (v: string) => Number.parseInt(v.split(".")[0] ?? "", 10);
|
|
524
|
+
return Number.isFinite(maj(from)) && Number.isFinite(maj(to)) && maj(to) > maj(from);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/** A recorded call in the operator's words. */
|
|
528
|
+
export const describeVersionChoice = (c: string, from?: string | null): string =>
|
|
529
|
+
c === "unreleased"
|
|
530
|
+
? "merge unreleased (no bump, no tag)"
|
|
531
|
+
: c === "next"
|
|
532
|
+
? "a versioned release (playbook: version = versioned)"
|
|
533
|
+
: isBumpKind(c)
|
|
534
|
+
? `a ${c} release${bumpVersion(from, c) ? ` (${from} → ${bumpVersion(from, c)})` : ""}`
|
|
535
|
+
: `release ${c}`;
|
|
536
|
+
|
|
537
|
+
/** Does the version flag pair on a verify/release call parse? Returns the call it makes, null for none, or an error. */
|
|
538
|
+
export function versionArg(value: string | null, noVersion: boolean): { choice: string | null } | { error: string } {
|
|
539
|
+
if (value !== null && noVersion) return { error: "--version=<v> and --no-version contradict each other — pass the one the operator chose" };
|
|
540
|
+
if (value !== null && !isBumpKind(value.trim()) && !VERSION_ARG_RE.test(value.trim()))
|
|
541
|
+
return { error: `--version=${value} is not a release call — pass what the operator chose: patch, minor, major, or an exact version such as 1.4.0` };
|
|
542
|
+
return { choice: value !== null ? value.trim() : noVersion ? "unreleased" : null };
|
|
543
|
+
}
|
|
544
|
+
|
|
499
545
|
/**
|
|
500
546
|
* Gate: pre-release → release ("Release?"). Machine-proves the parts of release prep that can be
|
|
501
547
|
* proven — checks re-greened after the prep edits, manifest bumped past the last tag, and the
|
|
@@ -2189,9 +2235,15 @@ export function nextHint(state: FlowState, cfg: Config): string {
|
|
|
2189
2235
|
if (state.docs) return `edit in ${state.worktree} (docs mode: no project commands), tick the tier-2 checklist with the operator, ask Verified?, then flow verify --confirmed`;
|
|
2190
2236
|
return `build and test in ${state.worktree}, commit as you go, flow check; then flow verify (deploys for review), look yourself, keep the app running, ask Verified? and run flow verify --confirmed on the answer`;
|
|
2191
2237
|
case "pre-release": {
|
|
2192
|
-
|
|
2238
|
+
// gh#198: the release call made with Verified? decides which prep this is
|
|
2239
|
+
const vc = state.versionChoice;
|
|
2240
|
+
const auto = cfg.release.ask !== "always" ? " (release.ask = on-change: it asks Release? only when something beyond the prep changed)" : "";
|
|
2241
|
+
if (vc === "unreleased")
|
|
2242
|
+
return `${cfg.release.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)` : ""}, flow check; show the PR summary, then run flow release${auto || " and ask Release?"}`;
|
|
2243
|
+
const prep = [cfg.release.changelog ? `prepare ${cfg.release.changelog} (fold Unreleased lines verbatim)` : "", cfg.versioning.file ? `bump version in ${cfg.versioning.file}${isBumpKind(vc) ? ` to ${bumpVersion(state.versionFrom, vc) ?? `the next ${vc}`} (a ${vc} release, the operator's call — the gate counts it from the newest tag, so a flow that released first moves the number)` : vc && vc !== "next" ? ` to ${vc} (the operator's call)` : ""}` : ""].filter(Boolean).join(" and ");
|
|
2244
|
+
if (vc && prep) return `${cfg.release.review}, fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs, ${prep}, flow check; show the PR summary, version and changelog, then run flow release${auto || " and ask Release?"}`;
|
|
2193
2245
|
if (state.docs && prep) return `${cfg.release.review}, fix must/should; a docs flow usually ships unversioned — ask the operator (flow release --no-version on their word); versioned instead: ${prep}; then ask Release? and run flow release`;
|
|
2194
|
-
return `${cfg.release.review}, fix must/should, update docs${prep ? `, ${prep}` : ""}, flow check; show the PR summary, version and changelog, ask Release? and run flow release`;
|
|
2246
|
+
return `${cfg.release.review}, fix must/should${state.docs ? "" : " (a fix that changes behaviour: flow verify redeploys and re-asks Verified? over it)"}, update docs${prep ? `, ${prep}` : ""}, flow check; show the PR summary, version and changelog, ask Release? and run flow release`;
|
|
2195
2247
|
}
|
|
2196
2248
|
case "release":
|
|
2197
2249
|
if (state.approvals.release) return `release recorded — commit and push any release chores in the main checkout (DEV_FLOW_ALLOW_MAIN=1 for the pre-commit hook), then flow finish (closing reflection first; its fold/drop answer is Finish?)`;
|
package/src/present.ts
CHANGED
|
@@ -117,7 +117,7 @@ export function stageLine(state: FlowState, cfg: Config, f: StageFacts = {}): st
|
|
|
117
117
|
else if (items) fields.push("tier-2 `confirmed` ✓");
|
|
118
118
|
}
|
|
119
119
|
if (stage === "pre-release" || stage === "release") {
|
|
120
|
-
const version = state.noVersion ? "version `no-version` ✓" : state.releaseVersion ? `version \`${state.releaseVersion}\` ✓` : f.manifest ? `version \`${f.manifest}\` ~` : "version `pending` ?";
|
|
120
|
+
const version = state.noVersion ? "version `no-version` ✓" : state.releaseVersion ? `version \`${state.releaseVersion}\` ✓` : state.versionChoice && state.versionChoice !== "next" && state.versionChoice !== "unreleased" ? `version \`${state.versionChoice}\` ✓` : f.manifest ? `version \`${f.manifest}\` ~` : "version `pending` ?";
|
|
121
121
|
fields.push(version);
|
|
122
122
|
const merge = cfg.release.merge;
|
|
123
123
|
fields.push(merge ? `merge \`${merge}\` ✓playbook` : "merge `unset` ?");
|
|
@@ -207,7 +207,7 @@ export function agentText(text: string, v: GateView): string {
|
|
|
207
207
|
|
|
208
208
|
/** Flags only dev-flow's gates take. A generic CLI flag (`docker compose up -d --no-deps`, `gh pr merge --merge`)
|
|
209
209
|
* in a report of what the agent ran is not a dev-flow command handed to the operator. */
|
|
210
|
-
const GATE_FLAGS = "confirmed|ui|patch|docs|yolo|replace|port|no-version|no-fold-check|no-marker-check|no-artifact-check|no-release-create|no-reflect|check-upstream|answers|answers-file|write-file|brief|brief-file|playbook|note";
|
|
210
|
+
const GATE_FLAGS = "version=|confirmed|ui|patch|docs|yolo|replace|port|no-version|no-fold-check|no-marker-check|no-artifact-check|no-release-create|no-reflect|check-upstream|answers|answers-file|write-file|brief|brief-file|playbook|note";
|
|
211
211
|
const ASK_COMMAND_RE = new RegExp(`(?:^|[\\s\`'"(*_])/?flow (?:${FLOW_VERBS})\\b|(?:^|[\\s\`])--(?:${GATE_FLAGS})\\b|\\bflow_stage\\b|(?:^|[\\s\`])/flow\\b`);
|
|
212
212
|
/** An imperative addressed to the operator: the verb opens a clause (or follows please/then/just), or a "you can" form. */
|
|
213
213
|
const ASK_VERB_RE = /(?:^|[:;,.!?(—–]\s*|\b(?:please|then|just|now|simply|and)\s+)(?:run|type|enter|use|try|send|invoke)\b|\byou (?:can|could|may|should|need to|might)\b|\bplease\b/i;
|
package/src/projectmd.ts
CHANGED
|
@@ -64,6 +64,8 @@ const KEYMAP: Record<string, Record<string, string>> = {
|
|
|
64
64
|
merge: "release.merge", // how a merged branch lands: squash | merge | rebase | any
|
|
65
65
|
yolo: "release.yolo", // how far a standing yolo reaches: all (default) | until-release (gh#176)
|
|
66
66
|
reflect: "release.reflect", // when finish runs the closing reflection: on-friction (default) | always
|
|
67
|
+
version: "release.version", // who decides versioned vs unreleased: ask (with Verified?, default) | versioned | unversioned (gh#198)
|
|
68
|
+
ask: "release.ask", // when Release? is asked: on-change (default) | always (gh#198)
|
|
67
69
|
},
|
|
68
70
|
};
|
|
69
71
|
// pre-release owns release preparation; the release keys are accepted under both sections so
|
|
@@ -178,6 +180,14 @@ export function parseProjectMd(text: string): ParsedMd {
|
|
|
178
180
|
p.warn.push(`${where}: reflect = "${m[2]}" — expected always or on-friction, keeping on-friction`);
|
|
179
181
|
return;
|
|
180
182
|
}
|
|
183
|
+
if (mapped === "release.version" && !/^(ask|versioned|unversioned)$/.test(m[2].trim())) {
|
|
184
|
+
p.warn.push(`${where}: version = "${m[2]}" — expected ask, versioned or unversioned, keeping ask`);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (mapped === "release.ask" && !/^(always|on-change)$/.test(m[2].trim())) {
|
|
188
|
+
p.warn.push(`${where}: ask = "${m[2]}" — expected on-change or always, keeping on-change`);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
181
191
|
p.flow[stage as MdStage][mapped] = m[2];
|
|
182
192
|
}
|
|
183
193
|
}
|
|
@@ -464,6 +474,16 @@ export function ghostFeatureDirs(root: string): string[] {
|
|
|
464
474
|
.map((d) => `.dev-flow/${d.name}`);
|
|
465
475
|
}
|
|
466
476
|
|
|
477
|
+
/** A feature dir that survived without its state.json (gh#178): what is in it, and whether a stray
|
|
478
|
+
* worktree/ blocks adopting it (a git worktree a new start would collide with). Null when the dir is
|
|
479
|
+
* absent or a flow owns it. */
|
|
480
|
+
export function ghostInfo(root: string, slug: string): { entries: string[]; plan: boolean; worktree: boolean } | null {
|
|
481
|
+
const dir = path.join(root, ".dev-flow", slug);
|
|
482
|
+
if (!existsSync(dir) || existsSync(path.join(dir, "state.json"))) return null;
|
|
483
|
+
const entries = readdirSync(dir, { withFileTypes: true }).map((d) => (d.isDirectory() ? `${d.name}/` : d.name)).sort();
|
|
484
|
+
return { entries, plan: existsSync(path.join(dir, "plan")), worktree: existsSync(path.join(dir, "worktree")) };
|
|
485
|
+
}
|
|
486
|
+
|
|
467
487
|
/**
|
|
468
488
|
* Doctor: cheap file-level probes only — NEVER runs user commands.
|
|
469
489
|
* Findings are advisory strings for `flow init` (fixer) and the status flag.
|
package/src/runtime/base.ts
CHANGED
|
@@ -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>|list|tidy|move <n> --playbook|--code|done <n> [<what>]] | roadmap [add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>|drop <n>|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui|--patch|--docs --confirmed] [--force] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | approve [--yolo] | verify [--yolo] [--port=<n>|--replace] | release [--yolo|--no-version|--no-fold-check|--no-marker-check] | release-done [--no-artifact-check|--no-release-create] | finish [--yolo] [--no-reflect] [--note=<text>] [slug] | abort [slug] | 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/--patch/--docs and --merge=<style> on start 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 — 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 numbers open items, move <n> re-files one, done <n> checks a fixed one off, tidy drops closed ones — 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) — 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 — doctor reviews structure, git consistency and open reflections (never writes); doctor <note> prints an investigation brief — version prints the build the disk ships and any other dev-flow copies in this process (--check-upstream asks the registry)";
|
|
239
|
+
"help [--json] | init [--force|--draft|--write <text>|--write-file <path>|--answers key=value…|--answers-file <path>] [--confirmed] [--track] | reflect [<note>|list|tidy|move <n> --playbook|--code|done <n> [<what>]] | roadmap [add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>|drop <n>|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui|--patch|--docs --confirmed] [--force] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | approve [--yolo] | verify [--yolo] [--port=<n>|--replace] [--version=<v>|--no-version] | release [--yolo|--version=<v>|--no-version|--no-fold-check|--no-marker-check] | release-done [--no-artifact-check|--no-release-create] | finish [--yolo] [--no-reflect] [--note=<text>] [slug] | abort [slug] | 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/--patch/--docs and --merge=<style> on start 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 — verify --confirmed carries the operator's release call: --version=<v> (ship that version) or --no-version (merge unreleased), asked with Verified?; release takes the same flags when the call changed — 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 numbers open items, move <n> re-files one, done <n> checks a fixed one off, tidy drops closed ones — 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) — 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 — doctor reviews structure, git consistency and open reflections (never writes); doctor <note> prints an investigation brief — 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");
|
package/src/runtime/gates.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { 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, roadmapBriefFor, roadmapPick, roadmapTidy, statusJson, subst, sq, featureTmpDir, foreignWorktreeLinks, validSlug, verifyGate, STAGE_EMOJI, type ReflectTarget, type Config, type FlowState } from "../core.ts";
|
|
5
|
-
import { applyAnswers, buildDraft, doctorFindings, ghostFeatureDirs, lineDiff, loadProject, mdDigest, parseAnswers, parseProjectMd } from "../projectmd.ts";
|
|
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";
|
|
@@ -278,10 +278,20 @@ export async function gateStart(o: GateCtx): Promise<RunResult> {
|
|
|
278
278
|
if (!slugArg || !validSlug(slugArg)) return { text: "usage: flow start <slug> [--ui] [--patch|--docs] [--merge=squash|merge|rebase|any] (slug: lowercase, dashes); --ui/--patch/--docs are operator-granted — ask the operator in chat, then add --confirmed", isError: true };
|
|
279
279
|
// a ghost (plan/ but no state.json — typically a spin-off someone wrote by hand) is adopted, never a dead end:
|
|
280
280
|
// "already exists, flow use it" sent the agent to use, which found no state, and doctor offered to delete it
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
281
|
+
// gh#178: any feature dir without state.json is a ghost, not only one with a plan/ — a tmp/ or mockups
|
|
282
|
+
// left behind used to read as "already exists, flow use it", and flow use then found nothing
|
|
283
|
+
const gi = ghostInfo(root, slugArg);
|
|
284
|
+
if (gi?.worktree)
|
|
285
|
+
return { text: `.dev-flow/${slugArg}/ has a worktree/ but no state.json — a flow that lost its state; nothing can resume it, and a new start would collide with that worktree. Remove it first (git worktree remove --force .dev-flow/${slugArg}/worktree, or git worktree prune when git no longer lists it — after checking it holds nothing the operator wants), then flow start ${slugArg} --confirmed adopts the rest (${gi.entries.filter((e) => e !== "worktree/").join(", ") || "nothing else"})`, isError: true };
|
|
286
|
+
const ghost = !!gi;
|
|
287
|
+
if (gi && !flag("confirmed")) {
|
|
288
|
+
const files = gi.plan ? listFiles(path.join(featDir(root, slugArg), "plan")) : [];
|
|
289
|
+
return {
|
|
290
|
+
text: gi.plan
|
|
291
|
+
? `.dev-flow/${slugArg}/ is a ghost — plan/ (${files.join(", ") || "empty"}) but no state.json, so no flow owns it. Adopt it as this feature's draft plan: flow start ${slugArg} --confirmed (the operator agrees in chat), or delete the dir to start clean`
|
|
292
|
+
: `.dev-flow/${slugArg}/ is a ghost — ${gi.entries.join(", ") || "empty"} but no state.json, so no flow owns it. Start ${slugArg} over it, keeping those files: flow start ${slugArg} --confirmed (the operator agrees in chat), or delete the dir to start clean`,
|
|
293
|
+
isError: true,
|
|
294
|
+
};
|
|
285
295
|
}
|
|
286
296
|
if (existsSync(featDir(root, slugArg)) && !ghost) {
|
|
287
297
|
// --ui on the plan-stage feature this session drives: the operator asked for mockups after the start,
|
|
@@ -350,7 +360,7 @@ export async function gateStart(o: GateCtx): Promise<RunResult> {
|
|
|
350
360
|
// the stamp is what ran, not what the disk claims (that mismatch is the warning above).
|
|
351
361
|
const state = newState(slugArg, flag("ui"), flag("patch"), flag("docs"), loadedVersion() ?? undefined);
|
|
352
362
|
const planDir = path.join(featDir(root, slugArg), "plan");
|
|
353
|
-
if (ghost) notes.push(`adopted ghost .dev-flow/${slugArg}/ — its plan/ (${listFiles(planDir).join(", ") || "empty"}) is this feature's draft`);
|
|
363
|
+
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)"}`);
|
|
354
364
|
mkdirSync(planDir, { recursive: true });
|
|
355
365
|
// a roadmap item stamped for this slug carries its brief into the plan: the spin-off's context outlives the session that split it
|
|
356
366
|
const picked = roadmapBriefFor(readRoadmap(root), slugArg);
|
|
@@ -681,8 +691,13 @@ export async function gateUse(o: GateCtx): Promise<RunResult> {
|
|
|
681
691
|
if (!slugArg) return { text: "usage: flow use <slug>", isError: true };
|
|
682
692
|
const st = readState(root, slugArg);
|
|
683
693
|
if (!st) {
|
|
684
|
-
const
|
|
685
|
-
return {
|
|
694
|
+
const gi = ghostInfo(root, slugArg);
|
|
695
|
+
return {
|
|
696
|
+
text: gi
|
|
697
|
+
? `.dev-flow/${slugArg}/ exists but has no state.json (a ghost: ${gi.entries.join(", ") || "empty"}) — there is nothing to resume. ${gi.worktree ? `Its worktree/ must go first (flow start ${slugArg} names the cleanup)` : `flow start ${slugArg} --confirmed adopts it as a new feature${gi.plan ? ", its plan/ as the draft" : ", keeping its files"}`}`
|
|
698
|
+
: `no unfinished feature ${slugArg}`,
|
|
699
|
+
isError: true,
|
|
700
|
+
};
|
|
686
701
|
}
|
|
687
702
|
const prior = readClaim(root, slugArg);
|
|
688
703
|
const takeover = claimBlocks(prior, sess.key) ? ` — taken over from live session (pid ${prior!.pid})` : "";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/** dev-flow runtime — `--confirmed` means "the operator said it in chat" (gh#190). The gates cannot read the
|
|
2
|
+
* chat, so on its own the flag is the agent's word: a refused `start --ui` came straight back with
|
|
3
|
+
* `--confirmed`, and a plain start was upgraded to `--ui --confirmed` with nobody asked. The flow tool can
|
|
4
|
+
* count the operator's messages in the session, which is enough to refuse the two shapes seen:
|
|
5
|
+
*
|
|
6
|
+
* A. a gate asked for the operator's word (NEEDS-OPERATOR, or an "operator-granted" refusal) and the same
|
|
7
|
+
* gate is re-run with --confirmed before any operator message arrived;
|
|
8
|
+
* B. a feature started in this session gets a mode flag (--ui/--patch/--docs) granted with --confirmed
|
|
9
|
+
* before any operator message arrived after the start.
|
|
10
|
+
*
|
|
11
|
+
* It never decides what the operator meant — one message after the question is all it asks for. A
|
|
12
|
+
* session it cannot read (no session manager) is not checked. Pure module: no pi imports. */
|
|
13
|
+
import { NEEDS_OPERATOR } from "../core.ts";
|
|
14
|
+
|
|
15
|
+
/** Operator messages in a session branch, or null when the branch cannot be read. */
|
|
16
|
+
export function operatorMessageCount(entries: readonly unknown[] | null | undefined): number | null {
|
|
17
|
+
if (!Array.isArray(entries)) return null;
|
|
18
|
+
let n = 0;
|
|
19
|
+
for (const e of entries) {
|
|
20
|
+
// SAFETY: narrow structural view of the SessionEntry union; only a user message is counted
|
|
21
|
+
const m = e as { type?: string; message?: { role?: string } };
|
|
22
|
+
if (m.type === "message" && m.message?.role === "user") n++;
|
|
23
|
+
}
|
|
24
|
+
return n;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface GrantLedger {
|
|
28
|
+
/** per session: the gate that last asked for the operator's word, and the operator-message count then */
|
|
29
|
+
asked: Map<string, { sub: string; users: number }>;
|
|
30
|
+
/** per session + slug: the operator-message count when start created the feature */
|
|
31
|
+
started: Map<string, number>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const newGrantLedger = (): GrantLedger => ({ asked: new Map(), started: new Map() });
|
|
35
|
+
|
|
36
|
+
const ASKS_FOR_WORD = /operator-granted|operator's (?:explicit )?word|the operator must grant/;
|
|
37
|
+
const MODE_FLAGS = ["--ui", "--patch", "--docs"];
|
|
38
|
+
const slugOf = (args: readonly string[]) => args.slice(1).find((a) => !a.startsWith("--")) ?? "";
|
|
39
|
+
|
|
40
|
+
/** The refusal for a `--confirmed` no operator message stands behind, or null when the call may run. */
|
|
41
|
+
export function grantCheck(args: readonly string[], key: string, users: number | null, ledger: GrantLedger): string | null {
|
|
42
|
+
if (users === null || !args.includes("--confirmed")) return null;
|
|
43
|
+
const sub = args[0] ?? "";
|
|
44
|
+
const asked = ledger.asked.get(key);
|
|
45
|
+
if (asked && asked.sub === sub && users <= asked.users)
|
|
46
|
+
return `${NEEDS_OPERATOR} no operator message since flow ${sub} asked for their word — --confirmed records the operator's answer in chat, it is not yours to give: ask in chat, stop, and re-run with --confirmed once they reply (gh#190)`;
|
|
47
|
+
if (sub === "start" && args.some((a) => MODE_FLAGS.includes(a))) {
|
|
48
|
+
const at = ledger.started.get(`${key}\u0000${slugOf(args)}`);
|
|
49
|
+
if (at !== undefined && users <= at)
|
|
50
|
+
return `${NEEDS_OPERATOR} ${args.filter((a) => MODE_FLAGS.includes(a)).join(" ")} on ${slugOf(args)} is operator-granted, and the operator has said nothing since it started — ask them in chat whether to turn it on, stop, and re-run with --confirmed once they reply (gh#190)`;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Note what a flow call's result means for later grants. */
|
|
56
|
+
export function grantRecord(args: readonly string[], key: string, users: number | null, res: { text: string; isError?: boolean }, ledger: GrantLedger): void {
|
|
57
|
+
if (users === null) return;
|
|
58
|
+
const sub = args[0] ?? "";
|
|
59
|
+
if (res.isError && (res.text.startsWith(NEEDS_OPERATOR) || ASKS_FOR_WORD.test(res.text))) {
|
|
60
|
+
ledger.asked.set(key, { sub, users });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (!res.isError && ledger.asked.get(key)?.sub === sub) ledger.asked.delete(key);
|
|
64
|
+
if (!res.isError && sub === "start" && /\bstarted at stage\b/.test(res.text)) ledger.started.set(`${key}\u0000${slugOf(args)}`, users);
|
|
65
|
+
}
|
package/src/runtime/ship.ts
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
/** dev-flow runtime — The gates that ship: verify, release, release-done, finish. Moved out of extensions/dev-flow.ts as is (exports added). */
|
|
2
2
|
import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { applicableItems, changelogVersionsBetween, normalizeReleaseBody, pendingEntryLines, pickReleaseNotes, checklistHash, checklistPending, cmpVersions, freshenChecks, healthProbe, mergeShapeProof, preReleaseGate, reflectionNudges, conflictMarkerLines, isReleaseOnly, looksLikeShellError, needsOperator, newestTaggedVersion, nextHint, releaseGate, parseVersion, roadmapDoneForSlug, sq, tagNotesCommand, verifyGate, versionTagGate, servedBuildMatches } from "../core.ts";
|
|
4
|
+
import { applicableItems, changelogVersionsBetween, normalizeReleaseBody, pendingEntryLines, pickReleaseNotes, checklistHash, checklistPending, cmpVersions, freshenChecks, healthProbe, mergeShapeProof, preReleaseGate, reflectionNudges, conflictMarkerLines, isReleaseOnly, looksLikeShellError, needsOperator, newestTaggedVersion, nextHint, releaseGate, parseVersion, roadmapDoneForSlug, sq, tagNotesCommand, verifyGate, versionTagGate, servedBuildMatches, versionArg, playbookVersionChoice, describeVersionChoice, majorBump, bumpVersion, isBumpKind } from "../core.ts";
|
|
5
|
+
import type { Config, FlowState } from "../core.ts";
|
|
5
6
|
import { AGENT_MARK } from "../present.ts";
|
|
6
7
|
import { buildSkew, copyWarning, currentBranch, featDir, flagValue, forgeMergeStyle, forgeOf, gateCwd, mergeBase, needState, now, originUrl, readReflectionsText, readRoadmap, readState, releaseTags, roadmapFile, sh, tail, worktreeAbs, writeState } from "./base.ts";
|
|
7
8
|
import { type RunResult, branchState, catchUp, describeBranchState, devEnv, devPortOf, devSlotCheck, healthRerunsAfterDeploy, pendingChecks, probeHealth, readDevPorts, runChecks, slotKey, triedNote, unreleasedOnMain, worktreeFingerprint, writeDevPorts } from "./checks.ts";
|
|
8
9
|
import { type GateCtx, markPendingAsk } from "./gates.ts";
|
|
9
10
|
|
|
11
|
+
/** gh#198: the version question asked with Verified? — null when it is not the operator's to answer here
|
|
12
|
+
* (no manifest to version, the playbook decides, or an earlier Verified? already recorded the call). */
|
|
13
|
+
function versionQuestion(root: string, state: FlowState, cfg: Config): { ask: string; flags: string } | null {
|
|
14
|
+
if (!cfg.versioning.file || playbookVersionChoice(cfg) || state.versionChoice) return null;
|
|
15
|
+
const file = path.join(gateCwd(root, state), cfg.versioning.file);
|
|
16
|
+
const now = existsSync(file) ? parseVersion(cfg.versioning.file, readFileSync(file, "utf8")) : null;
|
|
17
|
+
const kinds = (["patch", "minor", "major"] as const).map((k) => `${k}${bumpVersion(now, k) ? ` (→ ${bumpVersion(now, k)})` : ""}`).join(", ");
|
|
18
|
+
return {
|
|
19
|
+
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" : ""}`,
|
|
20
|
+
flags: "--version=patch|minor|major (or the exact version they named) or --no-version (merge unreleased)",
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
10
24
|
export async function gateVerify(o: GateCtx): Promise<RunResult> {
|
|
11
25
|
const { root, ui, sess, cfg, flag, slugArg, takeYoloWord } = o;
|
|
12
26
|
const { state, err } = needState(root, sess, slugArg);
|
|
13
27
|
if (err) return err;
|
|
14
28
|
const items = applicableItems(cfg, state!, "implement");
|
|
29
|
+
// gh#198: the release call (versioned vs unreleased) rides on the Verified? answer — the prep that follows depends on it
|
|
30
|
+
const verArg = versionArg(flagValue(o.rest, "version"), flag("no-version"));
|
|
31
|
+
if ("error" in verArg) return { text: `verify gate FAILED:\n- ${verArg.error}`, isError: true };
|
|
15
32
|
// the operator reviews the tree that ships: catch up with the default branch before anything runs
|
|
16
33
|
const caught = state!.stage === "implement" ? await catchUp(root, state!, cfg, flag("confirmed")) : { note: "" };
|
|
17
34
|
if ("text" in caught) return caught;
|
|
@@ -94,11 +111,14 @@ export async function gateVerify(o: GateCtx): Promise<RunResult> {
|
|
|
94
111
|
writeDevPorts(root, { ...readDevPorts(root), [slotKey(devPortOf(state!, cfg))]: { slug: state!.slug, head, at: now() } });
|
|
95
112
|
}
|
|
96
113
|
const ran = [branchLine, ...did].join("; ");
|
|
97
|
-
// yolo is the operator's word at Verified? — answers this question and pre-confirms the later ones
|
|
114
|
+
// yolo is the operator's word at Verified? — answers this question and pre-confirms the later ones.
|
|
115
|
+
// A re-verify at pre-release (gh#187) exists to put the new tree in front of the operator: a yolo given
|
|
116
|
+
// before those commits existed never answers it.
|
|
117
|
+
const reverify = state!.stage === "pre-release";
|
|
98
118
|
const yoloWord = takeYoloWord(state!);
|
|
99
119
|
if (yoloWord) return { text: yoloWord, isError: true };
|
|
100
|
-
let audit = flag("confirmed") ? " (confirmed by operator instruction)" : state!.yolo ? " (yolo: pre-confirmed)" : "";
|
|
101
|
-
const askPending = !flag("confirmed") && !state!.yolo;
|
|
120
|
+
let audit = flag("confirmed") ? " (confirmed by operator instruction)" : state!.yolo && !reverify ? " (yolo: pre-confirmed)" : "";
|
|
121
|
+
const askPending = !flag("confirmed") && (!state!.yolo || reverify);
|
|
102
122
|
if (askPending) {
|
|
103
123
|
markPendingAsk(root, state!, "Verified?"); // pending however it is asked — a chat question or a dialog
|
|
104
124
|
// the agent's call never opens a dialog (#181): this is the review deploy — the app is up for the
|
|
@@ -106,13 +126,14 @@ export async function gateVerify(o: GateCtx): Promise<RunResult> {
|
|
|
106
126
|
if (!ui.hasUI) {
|
|
107
127
|
const port = devPortOf(state!, cfg);
|
|
108
128
|
const what = state!.docs ? "ready for review" : cfg.commands.dev ? `deployed for review${port !== undefined ? ` on port ${port}` : ""}` : "live app re-probed for review";
|
|
109
|
-
|
|
129
|
+
const vq = versionQuestion(root, state!, cfg);
|
|
130
|
+
return { text: `${needsOperator(`${what}${reverify ? ` — a re-verify over the review fixes since ${state!.verifiedHead?.slice(0, 7) ?? "the last Verified?"}` : ""} — the app stays up until you answer${vq ? ` — ${vq.ask}` : ""}`, "Verified?", `look at the change in the running app yourself first (the playbook's self-check), then ask the operator Verified? in chat and run flow verify --confirmed${vq ? ` ${vq.flags}` : ""} once they answer. Keep it running until they answer.`)}\n${ran}` };
|
|
110
131
|
}
|
|
111
132
|
const ok = await ui.confirm("Operator verification", `Verified? All checks green${cfg.commands.dev && !state!.docs ? `; dev deploy is up for review (${cfg.commands.dev})` : ""} \u2014 does it work?`);
|
|
112
133
|
if (!ok) {
|
|
113
134
|
delete state!.pendingAsk;
|
|
114
135
|
writeState(root, state!);
|
|
115
|
-
return { text:
|
|
136
|
+
return { text: `verification declined — stay in ${reverify ? "pre-release" : "implement"} and fix what failed` };
|
|
116
137
|
}
|
|
117
138
|
audit = " (confirmed in dialog)";
|
|
118
139
|
}
|
|
@@ -126,18 +147,38 @@ export async function gateVerify(o: GateCtx): Promise<RunResult> {
|
|
|
126
147
|
const vHead = await sh("git rev-parse HEAD", gateCwd(root, state!));
|
|
127
148
|
if (vHead.ok && vHead.out.trim()) state!.verifiedHead = vHead.out.trim();
|
|
128
149
|
else delete state!.verifiedHead;
|
|
150
|
+
// gh#198: the operator's call, else the playbook's, else whatever an earlier Verified? recorded
|
|
151
|
+
const choice = verArg.choice ?? state!.versionChoice ?? playbookVersionChoice(cfg);
|
|
152
|
+
if (choice) {
|
|
153
|
+
if (choice !== state!.versionChoice || !state!.versionFrom) {
|
|
154
|
+
const mf = cfg.versioning.file ? path.join(gateCwd(root, state!), cfg.versioning.file) : "";
|
|
155
|
+
const from = mf && existsSync(mf) ? parseVersion(cfg.versioning.file!, readFileSync(mf, "utf8")) : null;
|
|
156
|
+
if (from) state!.versionFrom = from;
|
|
157
|
+
}
|
|
158
|
+
state!.versionChoice = choice;
|
|
159
|
+
if (choice === "unreleased") state!.noVersion = true;
|
|
160
|
+
else delete state!.noVersion;
|
|
161
|
+
}
|
|
162
|
+
const choiceNote = choice ? `\nrelease call: ${describeVersionChoice(choice, state!.versionFrom)}` : "";
|
|
163
|
+
const before = state!.stage;
|
|
129
164
|
state!.stage = "pre-release";
|
|
130
165
|
delete state!.pendingAsk;
|
|
131
166
|
writeState(root, state!);
|
|
132
|
-
|
|
167
|
+
if (before === "pre-release")
|
|
168
|
+
return { text: `re-verified${audit} over ${state!.verifiedHead?.slice(0, 7) ?? "the current tree"} — the Verified? word now covers the review fixes; still in pre-release.${choiceNote}\n${ran}\n${AGENT_MARK}next: ${nextHint(state!, cfg)}` };
|
|
169
|
+
return { text: `verified${audit} — entering pre-release stage.${choiceNote}\n${ran}\n${AGENT_MARK}next: ${nextHint(state!, cfg)}` };
|
|
133
170
|
}
|
|
134
171
|
|
|
135
172
|
export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
136
173
|
const { root, ui, sess, cfg, flag, slugArg, takeYoloWord } = o;
|
|
137
174
|
const { state, err } = needState(root, sess, slugArg);
|
|
138
175
|
if (err) return err;
|
|
139
|
-
// operator's word at Release?: this flow ships without a version bump or tag — recorded only once Release? is answered
|
|
140
|
-
|
|
176
|
+
// operator's word at Release?: this flow ships without a version bump or tag — recorded only once Release? is answered.
|
|
177
|
+
// gh#198: --version=<v> / --no-version here re-make the call recorded with Verified? (the operator changed their mind)
|
|
178
|
+
const relArg = versionArg(flagValue(o.rest, "version"), flag("no-version"));
|
|
179
|
+
if ("error" in relArg) return { text: `release gate FAILED:\n- ${relArg.error}`, isError: true };
|
|
180
|
+
const choice = relArg.choice ?? state!.versionChoice ?? playbookVersionChoice(cfg);
|
|
181
|
+
const noVersion = choice === "unreleased" || (!relArg.choice && !!state!.noVersion);
|
|
141
182
|
// (versioned) items stand down on an unversioned flow — the set confirmed here is the one that applies to it
|
|
142
183
|
const items = applicableItems(cfg, { ...state!, noVersion }, "pre-release");
|
|
143
184
|
// yolo is the operator's word at Release? — pre-confirms Finish?; publishing guardrails stay enforced
|
|
@@ -199,6 +240,33 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
199
240
|
const prep = { manifestVersion: manifestVer, remoteTags, changelog, changelogChanged, changelogBase, noFoldCheck: flag("no-fold-check"), conflictMarkers, noMarkerCheck: flag("no-marker-check") };
|
|
200
241
|
// same freshness rule as verify: a green predating a worktree write may not stand for the tree this gate blesses
|
|
201
242
|
if (freshenChecks(state!, await worktreeFingerprint(wtCwd)).length) writeState(root, state!);
|
|
243
|
+
// gh#198: the branch must carry the call the operator made — a bump they did not choose, or a bump on a flow
|
|
244
|
+
// they said merges unreleased, is prep that contradicts the word Release? would stand on. It runs before the
|
|
245
|
+
// generic proofs: when a parallel flow released first, "already tagged" alone would send the agent round a loop.
|
|
246
|
+
const tagOf = (v: string) => cfg.versioning.pattern.replace("{version}", v);
|
|
247
|
+
const newest = cfg.versioning.file && !noVersion ? newestTaggedVersion(cfg.versioning.pattern, remoteTags) : null;
|
|
248
|
+
if (cfg.versioning.file && choice && choice !== "next") {
|
|
249
|
+
const re = "ask the operator, then re-run with --version=<their call> or --no-version and --confirmed on their answer";
|
|
250
|
+
let baseVer: string | null = null;
|
|
251
|
+
if (markerBase) {
|
|
252
|
+
const was = await sh(`git show ${sq(`${markerBase}:${cfg.versioning.file}`)} 2>/dev/null`, wtCwd);
|
|
253
|
+
baseVer = was.ok && was.out.trim() ? parseVersion(cfg.versioning.file, was.out) : null;
|
|
254
|
+
}
|
|
255
|
+
if (isBumpKind(choice)) {
|
|
256
|
+
// counted from what actually shipped last, so a flow that took the number first moves this one along
|
|
257
|
+
const from = newest ?? baseVer ?? state!.versionFrom ?? null;
|
|
258
|
+
const want = bumpVersion(from, choice);
|
|
259
|
+
const moved = from && state!.versionFrom && from !== state!.versionFrom ? ` — ${tagOf(from)} was released since Verified? (the call was counted from ${state!.versionFrom} then)` : "";
|
|
260
|
+
if (want && manifestVer !== want)
|
|
261
|
+
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 };
|
|
262
|
+
} else if (choice !== "unreleased") {
|
|
263
|
+
if (remoteTags.includes(tagOf(choice)))
|
|
264
|
+
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 };
|
|
265
|
+
if (manifestVer && manifestVer !== choice)
|
|
266
|
+
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 };
|
|
267
|
+
} else if (manifestVer && baseVer && baseVer !== manifestVer)
|
|
268
|
+
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 };
|
|
269
|
+
}
|
|
202
270
|
// tier-2 pre-release confirmation is recorded by this very command, so it is excluded here
|
|
203
271
|
const preGate = preReleaseGate({ ...state!, noVersion, confirmations: { ...state!.confirmations, "pre-release": { hash: checklistHash(items), at: now() } } }, cfg, prep);
|
|
204
272
|
if (preGate.length) return { text: `release gate FAILED:\n- ${preGate.join("\n- ")}`, isError: true };
|
|
@@ -238,22 +306,25 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
238
306
|
// own commits are news to the operator; the merged-in ones are a count, not a list to wade through
|
|
239
307
|
const d = cfg.defaultBranch;
|
|
240
308
|
const upstream = (await sh(`git rev-parse --verify -q ${sq(`refs/remotes/origin/${d}`)}`, wtCwd)).ok ? `origin/${d}` : (await sh(`git rev-parse --verify -q ${sq(`refs/heads/${d}`)}`, wtCwd)).ok ? d : "";
|
|
241
|
-
const
|
|
242
|
-
|
|
309
|
+
const range = `${sq(state!.verifiedHead)}..HEAD${upstream ? ` --not ${sq(upstream)}` : ""}`;
|
|
310
|
+
// one record per commit: "<sha> <subject>" then the files it touched (\x1e starts a record)
|
|
311
|
+
const since = await sh(`git log --no-decorate --name-only --format=%x1e%h%x20%s ${upstream ? "--no-merges " : ""}${range}`, wtCwd);
|
|
312
|
+
const commits = since.ok
|
|
313
|
+
? since.out.split("\x1e").map((rec) => rec.split("\n").map((l) => l.trim()).filter(Boolean)).filter((r) => r.length).map(([line, ...files]) => ({ line, files }))
|
|
314
|
+
: [];
|
|
243
315
|
const all = upstream ? await sh(`git rev-list --count ${sq(state!.verifiedHead)}..HEAD`, wtCwd) : null;
|
|
244
316
|
const mergedIn = all?.ok ? Math.max(0, Number.parseInt(all.out.trim(), 10) - commits.length) : 0;
|
|
245
|
-
//
|
|
317
|
+
// gh#187: the release-prep commit (the bump, the changelog entry, whatever else the bump rewrites — an
|
|
318
|
+
// image tag in a compose file) lands after Verified? by design and no container verdict could cover
|
|
319
|
+
// it. It is the commit that touches the version file, or one that touches nothing but prep files.
|
|
246
320
|
const prepFiles = new Set([cfg.versioning.file, cfg.release.changelog, cfg.versioning.file === "package.json" ? "package-lock.json" : ""].filter(Boolean) as string[]);
|
|
247
|
-
const
|
|
248
|
-
const
|
|
249
|
-
|
|
321
|
+
const isPrep = (c: { files: string[] }) => (!!cfg.versioning.file && c.files.includes(cfg.versioning.file)) || (c.files.length > 0 && c.files.every((f) => prepFiles.has(f)));
|
|
322
|
+
const prep = commits.filter(isPrep);
|
|
323
|
+
const changed = commits.filter((c) => !isPrep(c));
|
|
250
324
|
// changed code shipping under an earlier word is friction the closing reflection should look at
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
if (commits.length && !prepOnly)
|
|
256
|
-
postVerify = `${commits.length} commit(s) landed after the operator's Verified? (given over ${state!.verifiedHead.slice(0, 7)}): ${commits.slice(0, 6).join(" | ")}${commits.length > 6 ? ` …(${commits.length - 6} more)` : ""}${mergedIn ? ` (+${mergedIn} merged in from ${upstream}, not listed)` : ""} — the verify verdict does not cover them: if behaviour changed, have the operator check the current build before Release?, and either way say in the PR body which commit the verdict was given over`;
|
|
325
|
+
unverifiedChange = changed.length > 0;
|
|
326
|
+
if (changed.length)
|
|
327
|
+
postVerify = `${changed.length} commit(s) landed after the operator's Verified? (given over ${state!.verifiedHead.slice(0, 7)}): ${changed.slice(0, 6).map((c) => c.line).join(" | ")}${changed.length > 6 ? ` …(${changed.length - 6} more)` : ""}${prep.length ? ` (release prep ${prep.map((c) => c.line.split(" ")[0]).join(", ")} not counted)` : ""}${mergedIn ? ` (+${mergedIn} merged in from ${upstream}, not listed)` : ""} — the verify verdict does not cover them: if behaviour changed, re-run flow verify (at pre-release it redeploys and re-asks Verified? over the current tree) before Release?, and either way say in the PR body which commit the verdict was given over`;
|
|
257
328
|
}
|
|
258
329
|
// a standing yolo (given at an earlier checkpoint) stops short of Release? when the playbook says so, or
|
|
259
330
|
// when commits landed after Verified? — the word was given before those commits existed (gh#176).
|
|
@@ -265,12 +336,34 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
265
336
|
: postVerify
|
|
266
337
|
? "a yolo given earlier does not cover commits that landed after Verified? — ask Release? with them named"
|
|
267
338
|
: "";
|
|
268
|
-
|
|
269
|
-
|
|
339
|
+
// gh#198: release.ask = on-change — Release? answers itself when it would only re-confirm Verified?: the call
|
|
340
|
+
// is on record, nothing but release prep landed since, and no other question (stale build, a major bump) is open
|
|
341
|
+
const onChange = cfg.release.ask !== "always" && !flag("confirmed") && !state!.yolo;
|
|
342
|
+
const askWhy = !onChange
|
|
343
|
+
? ""
|
|
344
|
+
: !state!.verifiedHead
|
|
345
|
+
? "no Verified? tree on record to compare against"
|
|
346
|
+
: cfg.versioning.file && !choice
|
|
347
|
+
? "no release call on record — ask it with Release?: patch, minor, major, or merge unreleased"
|
|
348
|
+
: relArg.choice && relArg.choice !== state!.versionChoice
|
|
349
|
+
? `the release call changed since Verified? (${state!.versionChoice ?? "none"} → ${relArg.choice}) — the operator makes that call`
|
|
350
|
+
: postVerify
|
|
351
|
+
? "commits beyond release prep landed after Verified?"
|
|
352
|
+
: stale
|
|
353
|
+
? "the session build is behind the checkout"
|
|
354
|
+
: cfg.release.yolo === "until-release"
|
|
355
|
+
? "the playbook sets yolo = until-release"
|
|
356
|
+
: choice === "next" && newest && manifestVer && majorBump(newest, manifestVer)
|
|
357
|
+
? `${newest} → ${manifestVer} is a major bump — the playbook's versioned call does not choose that`
|
|
358
|
+
: "";
|
|
359
|
+
const auto = onChange && !askWhy;
|
|
360
|
+
let audit = flag("confirmed") ? " (confirmed by operator instruction)" : auto ? ` (auto-answered: release.ask = on-change — ${describeVersionChoice(choice ?? "next", state!.versionFrom)} was the call at Verified?, and only release prep landed since)` : state!.yolo ? " (yolo: pre-confirmed)" : "";
|
|
361
|
+
const askPending = !auto && !flag("confirmed") && (!state!.yolo || !!yoloHeld);
|
|
270
362
|
if (askPending) {
|
|
271
363
|
markPendingAsk(root, state!, "Release?");
|
|
272
364
|
if (!ui.hasUI) {
|
|
273
|
-
|
|
365
|
+
const callAsk = cfg.versioning.file && !choice ? " — also ask the release call: a patch, minor or major release, or merge unreleased (no bump, no tag)?" : "";
|
|
366
|
+
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, an exact version, or --no-version for their release call)" : ""}`), isError: true };
|
|
274
367
|
}
|
|
275
368
|
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})` : ""}`);
|
|
276
369
|
if (!ok) {
|
|
@@ -281,6 +374,8 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
281
374
|
audit = " (confirmed in dialog)";
|
|
282
375
|
}
|
|
283
376
|
if (noVersion) state!.noVersion = true;
|
|
377
|
+
else delete state!.noVersion;
|
|
378
|
+
if (choice) state!.versionChoice = choice;
|
|
284
379
|
if (unverifiedChange) state!.friction = (state!.friction ?? 0) + 1;
|
|
285
380
|
state!.confirmations = { ...state!.confirmations, "pre-release": { hash: checklistHash(items), at: now() } };
|
|
286
381
|
state!.approvals["pre-release"] = now();
|
|
@@ -302,6 +397,66 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
|
|
|
302
397
|
return { text: `release approved${audit}${state!.noVersion ? " — unversioned: no bump or tag; your changelog entry rides under Unreleased until the next versioned release folds it" : ""} — entering release stage.${manifestVer ? ` Version ${manifestVer}.` : ""}${foldNote}${staleNote ? ` ${staleNote}.` : ""}${postVerify ? ` Warning: ${postVerify}.` : ""}\n${describeBranchState(branchProof, cfg.defaultBranch)}\n${AGENT_MARK}next: ${nextHint(state!, cfg)}` };
|
|
303
398
|
}
|
|
304
399
|
|
|
400
|
+
/** How long release-done waits on the publish CI a tag push started; a seam so tests run in milliseconds. */
|
|
401
|
+
export const artifactWait = {
|
|
402
|
+
budgetMs: 15 * 60_000,
|
|
403
|
+
pollMs: 20_000,
|
|
404
|
+
/** a tag pushed seconds ago may not have a run yet: look this long before deciding there is none */
|
|
405
|
+
appearMs: 60_000,
|
|
406
|
+
sleep: (ms: number) => new Promise<void>((r) => setTimeout(r, ms)),
|
|
407
|
+
clock: () => Date.now(),
|
|
408
|
+
runs: (tag: string, root: string): Promise<TagRun[] | null> => tagRuns(tag, root),
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
export interface TagRun { status: string; conclusion: string; url: string; workflowName: string }
|
|
412
|
+
|
|
413
|
+
/** The workflow runs a tag push started (GitHub names the tag as the run's branch); null when gh cannot say. */
|
|
414
|
+
async function tagRuns(tag: string, root: string): Promise<TagRun[] | null> {
|
|
415
|
+
const r = await sh(`gh run list --branch ${sq(tag)} --event push --limit 20 --json status,conclusion,url,workflowName`, root, 30_000);
|
|
416
|
+
if (!r.ok) return null;
|
|
417
|
+
try {
|
|
418
|
+
const rows = JSON.parse(r.out) as TagRun[];
|
|
419
|
+
return Array.isArray(rows) ? rows : null;
|
|
420
|
+
} catch {
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/** Probe the release artifact; when it is missing and the tag's CI is still running, wait for that CI
|
|
426
|
+
* (bounded) and probe again. `waited` says what the wait saw, for the gate's note or its refusal. */
|
|
427
|
+
export async function awaitArtifact(cmd: string, tag: string, root: string): Promise<{ ok: boolean; out: string; waited: string }> {
|
|
428
|
+
const start = artifactWait.clock();
|
|
429
|
+
const mins = () => `${Math.max(1, Math.round((artifactWait.clock() - start) / 60_000))} min`;
|
|
430
|
+
let greenAt: number | null = null; // a registry can answer "not found" for a minute after the run that pushed to it went green
|
|
431
|
+
for (let round = 0; ; round++) {
|
|
432
|
+
const art = await sh(cmd, root);
|
|
433
|
+
if (art.ok) return { ...art, waited: round ? `after waiting ${mins()} for the publish CI ${tag} started` : "" };
|
|
434
|
+
const runs = await artifactWait.runs(tag, root);
|
|
435
|
+
if (runs === null) return { ...art, waited: "" }; // gh cannot say: the plain probe result stands
|
|
436
|
+
const elapsed = artifactWait.clock() - start;
|
|
437
|
+
const pending = runs.filter((r) => r.status !== "completed");
|
|
438
|
+
if (!runs.length && elapsed >= artifactWait.appearMs)
|
|
439
|
+
return { ...art, waited: `no CI run was started by ${tag} — publish by hand, or check that the publish workflow triggers on tags` };
|
|
440
|
+
if (runs.length && !pending.length) {
|
|
441
|
+
const failed = runs.filter((r) => r.conclusion !== "success" && r.conclusion !== "skipped" && r.conclusion !== "neutral");
|
|
442
|
+
if (!failed.length && greenAt === null) greenAt = artifactWait.clock();
|
|
443
|
+
if (!failed.length && artifactWait.clock() - (greenAt ?? 0) < artifactWait.appearMs) {
|
|
444
|
+
await artifactWait.sleep(artifactWait.pollMs);
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
return {
|
|
448
|
+
...art,
|
|
449
|
+
waited: failed.length
|
|
450
|
+
? `the CI ${tag} started did not pass — ${failed.map((r) => `${r.workflowName}: ${r.conclusion || "?"} (${r.url})`).join(", ")}; fix and re-publish, then re-run release-done`
|
|
451
|
+
: `every CI run ${tag} started finished green, yet the artifact is missing — check where the publish workflow pushes`,
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
if (elapsed >= artifactWait.budgetMs)
|
|
455
|
+
return { ...art, waited: `the publish CI is still running after ${mins()} (${pending.map((r) => `${r.workflowName}: ${r.url}`).join(", ")}) — re-run release-done once it finishes` };
|
|
456
|
+
await artifactWait.sleep(artifactWait.pollMs);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
305
460
|
export async function gateReleaseDone(o: GateCtx): Promise<RunResult> {
|
|
306
461
|
const { root, sess, cfg, flag, slugArg } = o;
|
|
307
462
|
const { state, err } = needState(root, sess, slugArg);
|
|
@@ -339,9 +494,11 @@ export async function gateReleaseDone(o: GateCtx): Promise<RunResult> {
|
|
|
339
494
|
if (flag("no-artifact-check")) artNote = "Artifact check skipped (--no-artifact-check).";
|
|
340
495
|
else {
|
|
341
496
|
const cmd = cfg.release.artifact.replaceAll("{version}", manifestVer!).replaceAll("{tag}", expectedTag);
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
497
|
+
// the tag push is what starts the publish CI: a miss right after it is usually "not yet" — only a
|
|
498
|
+
// tag that is really on the forge has a run worth waiting for (gh#179)
|
|
499
|
+
const art = forgeName === "github" && !errs.length ? await awaitArtifact(cmd, expectedTag, root) : { ...(await sh(cmd, root)), waited: "" };
|
|
500
|
+
if (art.ok) artNote = `Artifact verified for ${manifestVer}${art.waited ? ` ${art.waited}` : ""}.`;
|
|
501
|
+
else errs.push(`artifact not published — release.artifact check failed (${cmd}):\n${tail(art.out)}${art.waited ? `\n${art.waited}` : ""}`);
|
|
345
502
|
}
|
|
346
503
|
}
|
|
347
504
|
// merge policy: did what actually landed agree with what the playbook says? A measured contradiction
|