pi-dev-flow 0.91.1 → 0.92.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,44 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.92.1] - 2026-11-14
8
+
9
+ **Stage workers are told your guard rules, a docs flow's worker runs no project checks, and `flow reflect done` closes a batch.**
10
+
11
+ ### Changed
12
+ - **`flow reflect done` closes several notes at once (gh#220).** A fold that fixed nine notes checked them off by patching `reflections.md` with a script, because nothing pointed the session at the command. `flow reflect done 3,4,7 "<what fixed them>"` now closes a batch, and one bad number closes none. `flow reflect list` tells the agent to use it instead of editing the file.
13
+
14
+ ### Fixed
15
+ - **Worker briefs carry your guard rules (gh#214).** A `flow_stage` worker has no operator, so a command your `confirm` rule matches can never be granted. A review worker chained a read-only check with a `docker compose down`; the guard refused the whole call and the check was silently dropped. Every worker brief now lists the playbook's `deny`, `confirm`, `protect` and `forbid` rules, says not to try or work around them, says to run each probe as its own call, and has the worker report a blocked check under `checks not run:`.
16
+ - **A docs flow's worker is no longer told to run project checks (gh#211).** On a `--docs` flow the gates skip the project's commands and no setup runs in the worktree, but the review brief still listed the test and health commands. The worker installed every dependency to run checks its own gate had skipped. The brief now says there are none to run.
17
+
18
+ ## [0.92.0] - 2026-11-14
19
+
20
+ **The gates stop repeating work and asking empty questions, and on GitHub `flow release` publishes the release itself.**
21
+
22
+ ### Changed
23
+ - **Verified? no longer builds and deploys twice.** `flow verify` deploys the app for your review, and the `--confirmed` run after your answer used to build and deploy it all over again. That doubled the wait and could fail after you had already said yes. Now, when the tree is the one that was deployed for review, the confirmed run only checks that the app still answers. If the tree changed or the app stopped answering, it deploys again as before.
24
+ - **`flow release` runs the checks it needs.** After a commit at pre-release the release gate used to refuse with "run flow check" and wait for a second call. It now runs stale or missing checks itself, the way `flow verify` does, after the quick proofs (version, changelog, clean tree) so a wrong version is refused before a slow suite starts.
25
+ - **A version bump no longer re-runs the whole suite.** Checks that passed before a commit holding only release prep (the version file, the changelog, `package-lock.json`) stay green, and the release result says they were kept. Set `recheck = always` under `## release` to re-run them every time.
26
+ - **The closing reflection runs only on flows that had real friction.** Any gate error counted as friction, including a `flow check` that found a failing test, so nearly every flow ran the reflection worker at finish. A red test, build or deploy now counts only when the same gate refuses twice in a row. Guard blocks, self-granted answers and process refusals (wrong stage, missing plan, a proof that doesn't hold) count as before.
27
+ - **A patch or docs flow asks one question before work starts, not two.** `--patch` and `--docs` needed your OK at start, and then Approve? came right after. Nothing those modes relax can happen before you approve, so the agent now proposes the mode on the start call and the Approve? question names it ("this is proposed as a patch flow — no written plan"). Your Approve? answer grants it. Dropping the mockup gate (`--no-ui`) and writing the merge policy still need their own answer.
28
+ - **Finish? answers itself on a clean flow.** When the release is recorded, the flow had no friction, no `## release` checklist item is open and nothing was skipped, `flow finish` closes the feature in one call and says so. It still asks when a reflection ran, an item is open or a forge release failed. Set `finish = always` under `## release` to be asked every time.
29
+ - **`flow release` publishes the release itself on GitHub.** After Release? the agent used to push the branch, open the PR, watch CI, merge and tag by hand, and most of the release reference was a list of mistakes made in those steps. The gate now does it in the same call: it pushes, opens the PR with the changelog entry as its body, waits for the PR's CI (up to 30 minutes), merges in the playbook's style, tags the PR's merge commit and records the release. Each step first asks GitHub whether it is already done, so re-running `flow release` resumes after a red check, a long CI run, or a PR you merged yourself. Set `publish = manual` under `## release` to keep the agent running these steps; GitLab and self-hosted forges work as before.
30
+ - **`release-done` is no longer part of what the agent is told.** `flow release` (GitHub) or `flow finish` (manual publishing) records the release. `/flow release-done` stays as your manual override.
31
+ - **Fewer plan rounds for obvious work.** The plan stage confirmed a direction in chat before writing the plan, even with nothing to clarify. The agent now does that only when there are open questions or more than one sound approach.
32
+
33
+ ### Added
34
+ - **After-merge checks (gh#210).** A `flow-check` block under `## release` runs from the main checkout when `flow finish` closes the feature, before anything is removed. A post-merge build or deploy check is now proven by the gate instead of listed as an open item you wave through. A red check stops finish and removes nothing.
35
+ - **`flow abort --purge` cleans up a dropped feature.** After approval, `flow abort` keeps the worktree, branch and state, and removing them was left to you with hand-typed git commands. `flow abort <slug> --purge` asks **Purge?**, lists what would be lost (commits not on main, uncommitted files, the plan), and on your answer removes the worktree, the local branch and the feature folder. It never deletes anything on origin.
36
+ - **`flow check` says when the branch fell behind (gh#209).** It reports how many commits behind the default branch the feature is and which files a rebase would conflict in, so a conflict is found during implement and not inside `flow verify`'s rebase.
37
+ - **Every gate names a stale session build (gh#218).** A session running an older dev-flow than the installed one heard about it only from `start` and `status`. Every gate result now carries the warning for the agent.
38
+
39
+ ### Fixed
40
+ - **`yolo = until-release` holds against a replayed `--confirmed` (gh#219).** `flow release --yolo --confirmed` published on a yolo given earlier even with `yolo = until-release`, as long as the gate had never asked. Where a question must be put (a held yolo, or a stale build), a `--confirmed` given before the gate asked no longer counts: the gate asks Release? first.
41
+ - **A stale build is no longer recorded as your choice when nobody asked (gh#217).** Under a standing yolo the release went ahead on an older build and the result said "by operator choice". The gate now asks update-or-proceed first, and the record says you were asked.
42
+ - **Reading tags is allowed before release (gh#221).** `git tag --sort=-creatordate` was blocked as tagging, so an agent working out the next version ran the query in another clone where the guard couldn't see it. The guard now blocks only calls that create a tag (a tag name, or `-a`/`-s`/`-m`/`-f`), and the refusal says that reads are allowed.
43
+ - **A reflection worker that dies no longer leaves finish with an empty result (gh#216).** If the closing reflection worker failed before it started, `flow finish --confirmed` returned nothing, and the session stayed marked as "a worker is already running". Finish now reports the failure, removes nothing, and can be re-run.
44
+
7
45
  ## [0.91.1] - 2026-11-11
8
46
 
9
47
  **A revised plan reads as one clean plan, without the dropped options from earlier rounds.**
package/README.md CHANGED
@@ -53,9 +53,9 @@ a test"*. It becomes the feature `session-renewal`:
53
53
  └────────┬────────┘
54
54
  Release? · usually answers itself when only release prep changed
55
55
  ┌────────▼────────┐
56
- │ release │ PR → merge → tag → release notes
56
+ │ release │ PR → CI → merge → tag → release notes, run by the gate
57
57
  └────────┬────────┘
58
- Finish?
58
+ Finish? · answers itself when nothing is left open
59
59
  ┌────────▼────────┐
60
60
  │ done │ worktree, branch and feature folder removed
61
61
  └─────────────────┘
@@ -66,7 +66,7 @@ a test"*. It becomes the feature `session-renewal`:
66
66
  | **plan** | reads the code, asks questions, writes `plan/plan.md` | **Approve?** — build it |
67
67
  | **implement** | works on `feat/<slug>`, commits in small steps, gets the checks green | **Verified?** — you tried it; also pick patch / minor / major, or merge unreleased |
68
68
  | **pre-release** | reviews, fixes, updates docs and changelog, bumps the version | **Release?** — only asked if something beyond release prep changed |
69
- | **release** | opens the PR, merges, tags, publishes release notes | **Finish?** — clean up |
69
+ | **release** | nothing on GitHub: the gate opens the PR, waits for CI, merges, tags and publishes release notes | **Finish?** — only asked if something is still open |
70
70
 
71
71
  ### Your answers
72
72
 
@@ -76,8 +76,8 @@ a test"*. It becomes the feature `session-renewal`:
76
76
  - **merge unreleased**: merge with a changelog entry, but no version bump or tag. The next release
77
77
  picks it up.
78
78
 
79
- For small work the agent may suggest a lighter **mode**: `--patch` for a quick fix with no written
80
- plan, or `--docs` for docs-only changes with no build checks.
79
+ For small work the agent may propose a lighter **mode**: `--patch` for a quick fix with no written
80
+ plan, or `--docs` for docs-only changes with no build checks. Your Approve? answer grants it.
81
81
 
82
82
  You never need to type `flow` commands. `/flow …` is there as a manual override when a session gets
83
83
  stuck. See the [gate reference](https://github.com/dmarchevsky/pi-dev-flow/blob/main/docs/gates.md).
@@ -31,6 +31,7 @@ pi -e . run /flow status # try the working tree against any repo
31
31
  - `checks`: dev deploy, health, tier-1 checks.
32
32
  - `gates`: the runner and the non-shipping gates.
33
33
  - `ship`: verify, release, release-done, finish.
34
+ - `publish`: the release stage run by the gate (push, PR, CI wait, merge, tag).
34
35
  - `setup`, `reflect`, `workers`.
35
36
  - `src/core.ts`, `src/projectmd.ts`, `src/present.ts`, …: pure logic, unit-tested without Pi.
36
37
  `present.ts` splits each gate result into your view and the agent's text.
@@ -59,7 +60,7 @@ runs `npm ci && npm test`, and runs `npm publish --provenance`. Nothing publishe
59
60
  and the workflow file name, so re-register after renaming either one.
60
61
  - **`--provenance` needs a public repo.** If the repo ever goes private, drop the flag.
61
62
  - **If the job fails,** fix the cause and re-run the same job. The tag already points at the right
62
- commit. `flow release-done` refuses to close the flow until `npm view pi-dev-flow@<version>`
63
+ commit. The release record refuses to close the flow until `npm view pi-dev-flow@<version>`
63
64
  succeeds.
64
65
 
65
66
  The README is also the package page on npm and [pi.dev](https://pi.dev/packages/pi-dev-flow). Its doc
package/docs/gates.md CHANGED
@@ -20,9 +20,8 @@ its own.
20
20
  | `use <slug>` | binds this session | the feature is unfinished |
21
21
  | `approve` | plan → implement | `plan/plan.md` exists (plus embedded mockups for `--ui`) and you said yes |
22
22
  | `verify` | implement → pre-release | the branch has commits, checks are green, the deploy is healthy, and you said yes |
23
- | `release` | pre-release → release | the version and changelog are right, nothing is uncommitted, and you said yes (or it answered itself) |
24
- | `release-done` | records the release | the tag is on origin, the artifact is published, and the forge release exists |
25
- | `finish` | release → done | the release is recorded, main is clean and pushed, and you said yes |
23
+ | `release` | pre-release → release, then publishes | the version and changelog are right, nothing is uncommitted, and you said yes (or it answered itself) |
24
+ | `finish` | release → done | the release is published and recorded, main is clean and pushed, and you said yes (or it answered itself) |
26
25
 
27
26
  Tools that never gate: `test`, `check`, `health`, `status`, `abort`, `doctor`, `reflect`, `roadmap`,
28
27
  `help`, `version`.
@@ -36,7 +35,8 @@ Creates the feature, binds this session to it, and renames the session after the
36
35
  - `--ui` means the plan gate requires rendered mockups. The agent turns it on by itself when screens
37
36
  change (it only adds a check); turning it off (`--no-ui` at plan, or aborting a ui feature) needs
38
37
  your OK. `--patch` (a small fix, no written plan) and `--docs` (docs only, no build checks) are
39
- lighter modes and need your OK in chat, after which the agent adds `--confirmed`.
38
+ lighter modes the agent proposes at start. Your Approve? answer grants the mode: the question
39
+ names it, and nothing the mode relaxes can happen before you approve.
40
40
  - **The playbook needs a `merge` policy.** If it has none, start asks which style to use (squash,
41
41
  merge, rebase or any), suggests one from your git history, and writes your answer into
42
42
  `## release`.
@@ -65,7 +65,8 @@ the session. It also takes over a feature another session holds. Nothing binds a
65
65
  ## test, check, health
66
66
 
67
67
  - `flow test` runs the `test` command and records the result.
68
- - `flow check` runs every tier-1 check from `## implement`.
68
+ - `flow check` runs every tier-1 check from `## implement`. If the branch fell behind main, it says
69
+ by how many commits and which files a rebase would conflict in.
69
70
  - `flow health` runs `seedData` and then the health probe, retrying for up to `healthWait` seconds.
70
71
 
71
72
  Each record carries a fingerprint of the worktree. When the tree changes, the record goes stale and
@@ -97,7 +98,9 @@ the question also asks: *patch, minor or major release, or merge unreleased?* Yo
97
98
  with `--version=…` or `--no-version`.
98
99
 
99
100
  With `--confirmed`, it never rewrites history. If main moved since the review deploy, re-run
100
- `flow verify`.
101
+ `flow verify`. It also doesn't build or deploy a second time: when the tree is the one it deployed for
102
+ your review, it only checks that the app still answers. If the tree changed, or the app stopped
103
+ answering, it deploys again.
101
104
 
102
105
  **At pre-release, `verify` is the re-verify:** after review fixes, it re-runs the build, deploy and
103
106
  probes on the current tree and asks Verified? again. A standing yolo never answers this.
@@ -115,11 +118,16 @@ Proves the branch is ready to ship:
115
118
  pending under `Unreleased` is kept in the new section, and `Unreleased` is now empty.
116
119
  - **Merge unreleased** (`--no-version`): no bump, but the branch adds its own line under
117
120
  `Unreleased`. Docs flows are exempt.
118
- - The checks are green again after the prep edits, and `release.preflight` passes if set.
121
+ - The checks are green. The gate runs any that are stale or missing itself. Checks that passed
122
+ before a commit holding only release prep (version file, changelog) stay green without a re-run;
123
+ set `recheck = always` in `## release` to re-run them anyway. `release.preflight` passes if set.
119
124
  - There are no leftover conflict markers (`<<<<<<<`) and no uncommitted files in the worktree.
120
125
 
121
126
  **Release? often answers itself** (`ask = on-change`, the default). That happens when your call is
122
- on record and only release prep (bump, changelog) changed since Verified?. It still asks when:
127
+ on record and only release prep (bump, changelog) changed since Verified?. A `--confirmed` given before the gate asked doesn't count where a question must be put (a held yolo,
128
+ or a stale build): the gate asks first.
129
+
130
+ It still asks when:
123
131
  - code changed after Verified?;
124
132
  - the session runs an old build (proceeding is allowed, and it says what you'd miss);
125
133
  - the playbook sets `yolo = until-release`;
@@ -130,10 +138,27 @@ Set `ask = always` in `## release` to be asked every time.
130
138
  Escape hatches, used only on your word: `--no-fold-check` skips the line-level changelog check, and
131
139
  `--no-marker-check` allows intentional conflict-marker lines.
132
140
 
133
- ## release-done
141
+ ### Publishing
142
+
143
+ On GitHub, the same `flow release` call then publishes. Your Release? answer is what authorizes it:
144
+
145
+ 1. Pushes the branch and opens the PR, with the changelog entry as the body.
146
+ 2. Waits for the PR's CI, up to 30 minutes. A repo with no CI is given a minute for checks to show up.
147
+ 3. Merges in the playbook's `merge` style.
148
+ 4. Creates an annotated tag on the PR's merge commit and pushes it (versioned flows).
149
+ 5. Records the release (below).
150
+
151
+ Each step first asks GitHub whether it's already done, so a re-run picks up where it stopped, and a
152
+ step you did by hand (merging a PR that needed your review, for example) is accepted. The gate stops
153
+ with `publish waiting` when CI is still running, and with `publish stopped` when a check is red, the
154
+ forge refuses the merge, or `gh` can't answer. In both cases, `flow release` again resumes.
134
155
 
135
- Records the release. It asks no question, because your Release? answer covered it. `finish` runs it
136
- for you if the agent didn't.
156
+ Set `publish = manual` in `## release` to have the agent run these steps instead. That is also what
157
+ happens on GitLab, on a self-hosted forge, and without `gh`.
158
+
159
+ ### The release record
160
+
161
+ Asks no question, because your Release? answer covered it. On the manual path, `finish` runs it.
137
162
 
138
163
  - The tag exists, is reachable from main, and is **on origin**. If origin can't be reached, it
139
164
  refuses rather than trust local tags.
@@ -147,14 +172,19 @@ for you if the agent didn't.
147
172
  Skip flags (on your word): `--no-artifact-check`, `--no-release-create`. You can also set
148
173
  `release.releases = false` or `forge = self` to skip creating the forge release.
149
174
 
175
+ `/flow release-done` runs the record by itself. It's a manual override; the agent has no reason to
176
+ call it.
177
+
150
178
  ## finish: Finish?
151
179
 
152
180
  `flow finish [--yolo] [--no-reflect] [--note=<text>] [slug]`
153
181
 
154
- 1. Records the release if `release-done` never ran. If the `## release` checklist still has open
182
+ 1. Records the release if `flow release` didn't already (manual publishing). If the `## release` checklist still has open
155
183
  items, it stops and lists them.
156
- 2. Runs the **closing reflection** (see [reflections](reflections.md)) and waits for your fold/drop.
157
- 3. On `--confirmed`, cleans up: removes the worktree, the branch and `.dev-flow/<slug>/`. It deletes
184
+ 2. Runs the after-merge checks (`flow-check` blocks under `## release`) from the main checkout. A red
185
+ one stops finish and removes nothing.
186
+ 3. Runs the **closing reflection** (see [reflections](reflections.md)) and waits for your fold/drop.
187
+ 4. Cleans up, on `--confirmed` or when Finish? answers itself: removes the worktree, the branch and `.dev-flow/<slug>/`. It deletes
158
188
  the remote branch only once it's proven merged. If local main is just behind origin, it
159
189
  fast-forwards it.
160
190
 
@@ -162,6 +192,11 @@ It refuses until the release is recorded, the main checkout is clean and pushed,
162
192
  no uncommitted changes. Under `merge = merge`, commits missing from main are a policy violation that
163
193
  yolo can't answer.
164
194
 
195
+ **Finish? answers itself on a clean flow** (`finish = on-change`, the default): the release is
196
+ recorded, the flow had no friction so no reflection ran, no `## release` checklist item is open, and
197
+ no forge release was skipped. It still asks when any of those is open, and always with
198
+ `finish = always` in `## release`.
199
+
165
200
  To drop an unreleased feature, use `flow abort` instead.
166
201
 
167
202
  ## reflect, roadmap, doctor
@@ -177,7 +212,11 @@ To drop an unreleased feature, use `flow abort` instead.
177
212
  ## status, abort, help, version
178
213
 
179
214
  - `flow status [slug]` shows where every feature stands. `--json` gives machine output.
180
- - `flow abort [slug]` drops a feature.
215
+ - `flow abort [slug]` drops a feature. Before approval, that removes it. After approval, it unbinds
216
+ the session and keeps the worktree, branch and state so nothing is lost.
217
+ - `flow abort [slug] --purge` removes what an aborted feature left: the worktree (uncommitted files
218
+ included), the local branch and `.dev-flow/<slug>/`. It asks **Purge?** first and lists what would
219
+ be lost. It never touches origin; a remote branch or open PR is named for you to remove.
181
220
  - `flow help` (`--json`) prints the gate contract.
182
221
  - `flow version [--check-upstream]` prints which dev-flow copy this session runs and whether the
183
222
  checkout is newer.
@@ -190,6 +229,7 @@ Answering **yolo** at any checkpoint runs that gate with `--yolo --confirmed`. T
190
229
  question and pre-confirms the rest, so the agent runs the remaining gates back to back, following
191
230
  any wishes you added ("yolo, patch bump"). Every check and guard still applies. Yolo never answers:
192
231
  - the re-verify at pre-release;
193
- - Release? when code changed after Verified?, or when the playbook sets `yolo = until-release`;
232
+ - Release? when code changed after Verified?, when the playbook sets `yolo = until-release`, or
233
+ when the session runs an older build than the install;
194
234
  - a `merge = merge` policy violation at finish;
195
235
  - skipping the closing reflection.
@@ -15,8 +15,8 @@ playbook, dev-flow stays silent.
15
15
  - A `pre-commit` hook covers commits made outside Pi.
16
16
 
17
17
  **Shipping waits for `flow release`.** Before the release stage, tagging, merging the PR
18
- (`gh pr merge`, `glab mr merge`) and creating a forge release are refused. Reads like `git tag -l`
19
- and opening the PR are fine.
18
+ (`gh pr merge`, `glab mr merge`) and creating a forge release are refused. Reads like `git tag -l` or
19
+ `git tag --sort=-creatordate` and opening the PR are fine.
20
20
 
21
21
  **No code before an approved plan.** During plan, the agent can only write in its own
22
22
  `.dev-flow/<slug>/` folder.
@@ -39,6 +39,8 @@ and opening the PR are fine.
39
39
  **Gates can't be faked.**
40
40
  - The agent can't write, move or delete `state.json`, `claim.json`, a feature folder or `.dev-flow/`
41
41
  itself, through either edit tools or bash.
42
+ - A dropped feature is removed by the gate, on your word: `flow abort <slug> --purge` asks Purge?
43
+ and lists what would be lost.
42
44
  - The playbook is yours. The agent can only edit it inside a docs or patch flow's worktree, and every
43
45
  sanctioned overwrite keeps a `project.md.bak`.
44
46
  - Every check result is tied to a fingerprint of the worktree. Any change, even through `sed -i` or a
package/docs/headless.md CHANGED
@@ -16,8 +16,10 @@ except the `pre-commit` hook.
16
16
  on that marker, show the question to a human word for word, and when they answer, re-run the same
17
17
  gate with `--confirmed`. A `flow-guard` `confirm` rule with no UI refuses with the same marker.
18
18
  - **`--confirmed` runs on trust.** dev-flow can't verify that a human answered. If your
19
- orchestrator adds `--confirmed` on its own guess, dev-flow can't catch it. `--patch` and `--docs`
20
- grants work the same way.
19
+ orchestrator adds `--confirmed` on its own guess, dev-flow can't catch it. A `--patch` or
20
+ `--docs` mode is granted by the Approve? answer, so it runs on the same trust.
21
+ - **Not every question is asked.** Release? and Finish? often answer themselves (`ask` and `finish`
22
+ default to `on-change`), so a driver must not wait for all four checkpoints.
21
23
  - **Machine-readable output.** `flow status --json` gives the bound slug and, per feature: stage,
22
24
  modes, branch, worktree, checks and next hint. `flow help --json` gives the gate contract:
23
25
  questions and flag names. `status`, `help`, `version`, `doctor` and `roadmap` (list) are safe at any
@@ -26,11 +28,13 @@ except the `pre-commit` hook.
26
28
  reconnects either rejoins its session or rebinds with `flow use <slug>`. Nothing binds
27
29
  automatically. Parallel features need parallel sessions.
28
30
  - **Long gates need long timeouts.** `approve` runs `setup`. `verify` runs the build and the `dev`
29
- deploy (killed after 15 minutes), then retries the health probe. Give the driver minutes, not
31
+ deploy (killed after 15 minutes), then retries the health probe. On GitHub, `release` waits for
32
+ the PR's CI (up to 30 minutes) and then for the publish CI the tag started (up to 15). It returns
33
+ `publish waiting` when the budget runs out; call it again. Give the driver minutes, not
30
34
  seconds. Gates print progress while they run.
31
35
  - **Edits make checks stale.** Each check result is tied to a worktree fingerprint, and
32
- `verify` / `release` re-run stale ones. Running `flow check` after the last edit is still the tidy
33
- order.
36
+ `verify` / `release` re-run stale ones themselves. A commit that holds only release prep (version
37
+ file, changelog) doesn't make them stale.
34
38
  - **Version skew.** Gates run the dev-flow build the session loaded at start. `flow version` says
35
39
  when the checkout is newer. `flow release` asks whether to `/reload` or proceed with the old build,
36
40
  and never blocks on it.
package/docs/playbook.md CHANGED
@@ -59,6 +59,12 @@ Inside each one, content has three tiers:
59
59
  - `- [ ] (docs) …` is kept on a `--docs` flow. Other `## implement` items are skipped there, since a
60
60
  docs flow builds nothing.
61
61
 
62
+ **After-merge checks.** A ` ```flow-check <name> ` block under `## release` runs from the main
63
+ checkout when `flow finish` closes the feature, after the release is recorded and before anything is
64
+ removed. Use it for steps that only make sense after the merge, like a build from main or a deploy
65
+ check. If one fails, finish stops and removes nothing. A `- [ ]` item under `## release` stays a
66
+ question for you instead: it closes with your Finish? answer.
67
+
62
68
  If you change the items, you're asked again.
63
69
 
64
70
  **Prose:** your `## implement` prose replaces dev-flow's built-in "senior discipline" guidance.
@@ -141,6 +147,8 @@ forbid docker/secrets :: secret storage
141
147
 
142
148
  Tips:
143
149
  - Text after ` :: ` is the reason, shown when the rule fires.
150
+ - `flow_stage` workers get these rules in their brief. A worker has no one to ask, so `confirm` and
151
+ `protect` are refusals for it, and the reason you write is what it reads.
144
152
  - An invalid regex makes the playbook invalid, and `flow init` refuses it.
145
153
  - Match the **verb** you mean, not a flag. `\bgit\b[^\n]*--force` also blocks
146
154
  `git filter-branch --force`.
@@ -165,7 +173,10 @@ These go under `## pre-release` or `## release`. Either section works.
165
173
  | `merge` | *(asked)* | how a PR lands: `squash`, `merge`, `rebase` or `any`. See below. |
166
174
  | `version` | `ask` | who makes the release call: `ask` (you, at Verified?), or `versioned` / `unversioned` for every flow |
167
175
  | `ask` | `on-change` | `on-change`: Release? answers itself when only release prep changed. `always`: ask every time. |
168
- | `yolo` | `all` | `until-release`: a yolo given earlier never answers Release? |
176
+ | `finish` | `on-change` | `on-change`: Finish? answers itself when nothing is open (see [gates](gates.md#finish-finish)). `always`: ask every time. |
177
+ | `publish` | `gate` | `gate`: on GitHub, `flow release` pushes, opens the PR, waits for CI, merges and tags itself. `manual`: the agent runs those steps. Other forges are always manual. |
178
+ | `recheck` | `prep-skip` | `prep-skip`: checks stay green across a commit that holds only the version bump and changelog. `always`: re-run them. |
179
+ | `yolo` | `all` | `until-release`: a yolo given earlier never answers Release?. The gate asks, and only your answer to that question releases. |
169
180
  | `reflect` | `on-friction` | `always`: run the closing reflection on every finish |
170
181
  | `review` | `/flow-review` | the review step at pre-release |
171
182
  | `preflight` | — | runs in the worktree at `flow release` before anything ships, for example `docker build .` |
@@ -194,8 +205,9 @@ So dev-flow asks.
194
205
  - **`flow init` and `flow start` ask** if it isn't set, with evidence from your history.
195
206
  - **The guard enforces it.** `gh pr merge <n> --squash` under `merge = merge` is blocked, and a merge
196
207
  with no style flag asks you. Put the PR number *before* the flag.
197
- - **Merge only once CI is green** (`gh pr checks <n> --watch`). Local checks can't run CI-only jobs.
198
- - **`release-done` proves** that what landed matches the policy. When it can't tell, it prints a note
208
+ - **Merge only once CI is green.** On GitHub the release gate waits for the PR's checks and merges
209
+ in this style itself. Local checks can't run CI-only jobs.
210
+ - **The release record proves** that what landed matches the policy. When it can't tell, it prints a note
199
211
  instead of refusing.
200
212
 
201
213
  dev-flow can't stop someone clicking the merge button in the web UI. Use your forge's
@@ -26,7 +26,7 @@ dev-flow repo, filed only when you say so.
26
26
  | `flow reflect "<note>"` | guesses the section from the wording and says why |
27
27
  | `flow reflect list` | numbers the open notes |
28
28
  | `flow reflect move <n> --code` | moves a note to the other section |
29
- | `flow reflect done <n> "<what>"` | checks a note off as fixed |
29
+ | `flow reflect done <n> "<what>"` | checks a note off as fixed. `done 3,4,7 "<what>"` closes several at once; one bad number closes none. |
30
30
  | `flow reflect tidy` | removes the checked-off notes |
31
31
 
32
32
  `flow status` and `flow doctor` show how many notes are open.
@@ -41,8 +41,10 @@ suggestion to **fold** (keep) or **drop** it.
41
41
  You answer per item, for example `fold 1,3 drop 2`. Folding records a note, or files the issue for a
42
42
  plugin finding. Dropping records nothing.
43
43
 
44
- The review is skipped when the flow ran into no friction: no gate refusal, no guard block, no code change
45
- after Verified?, and no `--note`. Set `reflect = always` in the playbook's `## release` section to run it every time. Only
44
+ The review is skipped when the flow ran into no friction: no guard block, no gate refusing for a
45
+ process reason (wrong stage, a missing plan, a proof that doesn't hold), no gate refusing twice in a
46
+ row, no code change after Verified?, and no `--note`. A failing test or build is not friction by
47
+ itself: finding it is what the checks are for. Set `reflect = always` in the playbook's `## release` section to run it every time. Only
46
48
  your explicit `--no-reflect` skips it; *yolo* doesn't.
47
49
 
48
50
  ## Nudges
@@ -34,7 +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
+ import { grantCheck, grantRecord, isFriction, newGrantLedger, operatorMessageCount, type RefusalStreak } from "../src/runtime/grants.ts";
38
38
  import { PIWEB_SUBAGENT, WORKER_TOOLS, piwebLiveClaim, piwebStamp, piwebWorkerMeta, reflectSeams, sessionHeaders, stageWorkerSpawn, workerName, workerSessions, workerTiming, writeTranscriptDigests } from "../src/runtime/workers.ts";
39
39
  export { compactionTakeover } from "../src/runtime/base.ts";
40
40
  export { reflectSeams, stageWorkerSpawn, workerTiming } from "../src/runtime/workers.ts";
@@ -142,6 +142,8 @@ export default function devFlow(pi: ExtensionAPI) {
142
142
 
143
143
  /** Which gate asked for the operator's word, and when features started — per session (gh#190). */
144
144
  const grantLedger = newGrantLedger();
145
+ /** Gates that refused in a row, per session — what turns a failing check into friction (see isFriction). */
146
+ const refusalStreak: RefusalStreak = new Map();
145
147
 
146
148
  /** A flow_stage worker: registered in this module's set, or — for a worker pi-web hosts, whose extension
147
149
  * instance never saw the registration — stamped with pi-web's subagent entry. */
@@ -242,8 +244,8 @@ export default function devFlow(pi: ExtensionAPI) {
242
244
  if (!res.isError) maybeCompactNow(ctx, root);
243
245
  // two readers: the model gets every instruction, the operator's row renders the view (renderResult) —
244
246
  // facts, the stage line and the question waiting on them, never a command to type
245
- // a refusal (not a question for the operator) is friction the closing reflection should look at
246
- if (res.isError && (!res.text.startsWith(NEEDS_OPERATOR) || selfGrant) && initiated(root)) noteFriction(root, sessionKey(ctx));
247
+ // a refusal (not a question for the operator, not a red check doing its job) is friction the closing reflection should look at
248
+ if (isFriction(params.args, sessionKey(ctx), res, !!selfGrant, refusalStreak) && initiated(root)) noteFriction(root, sessionKey(ctx));
247
249
  // a start that bound a feature takes over the refusals this session hit before it existed
248
250
  else if (!res.isError && params.args[0] === "start" && initiated(root)) noteFriction(root, sessionKey(ctx), 0);
249
251
  const { agent, view } = await presentRun(params.args, root, sessionKey(ctx), res);
@@ -310,7 +312,9 @@ export default function devFlow(pi: ExtensionAPI) {
310
312
  let lineage: { id?: string; file?: string; dir?: string } = {};
311
313
  try { lineage = { id: ctx.sessionManager.getSessionId(), file: ctx.sessionManager.getSessionFile() ?? undefined, dir: ctx.sessionManager.getSessionDir() ?? undefined }; } catch { /* unbacked driver: the worker is unlinked */ }
312
314
  const selfRepo = isSelfRepo(root);
313
- const brief =
315
+ // gh#216: the brief is built before the worker's try/finally — a throw here used to leave this session
316
+ // marked as running a worker forever and hand the caller nothing
317
+ const briefOf = async (): Promise<string> =>
314
318
  wop === "reflect"
315
319
  ? await (async () => {
316
320
  const items = readReflections(root);
@@ -340,10 +344,19 @@ export default function devFlow(pi: ExtensionAPI) {
340
344
  defaultBranch: cfg.defaultBranch,
341
345
  commits: await git(`git log --oneline ${sq(cfg.defaultBranch)}..HEAD`),
342
346
  status: await git("git status --short"),
343
- checks: cfg.checkList.map((c) => ({ name: c.name, command: c.cmd })),
347
+ checks: st.docs ? [] : cfg.checkList.map((c) => ({ name: c.name, command: c.cmd })),
344
348
  preamble: cfg.workerPreamble,
349
+ docs: !!st.docs,
350
+ guard: cfg.guard,
345
351
  note: String(params.note ?? ""),
346
352
  });
353
+ let brief: string;
354
+ try {
355
+ brief = await briefOf();
356
+ } catch (e) {
357
+ runningWorkers.delete(key);
358
+ return err(`the ${wop} worker could not be briefed: ${e instanceof Error ? e.message : String(e)} — nothing ran; re-run, or do it inline`);
359
+ }
347
360
  // pi-web visibility needs both halves of the lineage: the id the Agents menu links the child
348
361
  // to, the file the parentSession header points at — without either the worker stays unlinked.
349
362
  const subagent = !lineage.id || !lineage.file ? undefined : { parentId: lineage.id, parentFile: lineage.file, toolCallId: id, profile: `flow-${wop}`, description: name, task: brief };
@@ -541,6 +554,7 @@ export default function devFlow(pi: ExtensionAPI) {
541
554
  pi.on("session_shutdown", async (_event, ctx) => {
542
555
  WEB_CHIP_KEYS.delete(sessionKey(ctx)); // the session's UI is gone; a long-lived server must not keep its slot
543
556
  hollowStreak.delete(sessionKey(ctx));
557
+ refusalStreak.delete(sessionKey(ctx));
544
558
  if (!guardsAreMine()) return;
545
559
  const root = await flowRoot(ctx.cwd);
546
560
  if (!existsSync(dfDir(root))) return;
@@ -772,7 +786,7 @@ export default function devFlow(pi: ExtensionAPI) {
772
786
  const co = checkoutInvocation(g.seg);
773
787
  if (!co) continue;
774
788
  const homeWt = worktrees.find((w) => gitDir === w || gitDir.startsWith(w + path.sep));
775
- if (co.creates && homeWt) return { block: true, reason: `a feature worktree stays on its own branch — not creating ${co.target} in ${homeWt}; an unrelated fix is its own flow (flow start <slug> --patch --confirmed)` };
789
+ if (co.creates && homeWt) return { block: true, reason: `a feature worktree stays on its own branch — not creating ${co.target} in ${homeWt}; an unrelated fix is its own flow (flow start <slug> --patch)` };
776
790
  // Branch discipline: feature branches live in their worktree — never checked out or created (-b) in the main checkout
777
791
  if (!homeWt && co.target.startsWith(featureBranchPrefix(cfg)))
778
792
  return { block: true, reason: `branch ${co.target} belongs to a feature worktree, not the main checkout — flow use <slug> and run git inside ${featureBranchPrefix(cfg)}…'s worktree` };
@@ -870,7 +884,7 @@ export default function devFlow(pi: ExtensionAPI) {
870
884
  return { message: { customType: "dev-flow-context", display: false, content: `${core}${sameAsLast(key, content, `[dev-flow] no flow bound — unchanged since the last [dev-flow] note (playbook map is ${path.join(SKILL_DIR, "SKILL.md")}).`)}` } };
871
885
  }
872
886
  const guidance: string[] = [];
873
- if (state.yolo) guidance.push("YOLO mode: the operator pre-confirmed every gate question from here on (Verified?/Release?/Finish?) — run the remaining gates (verify → release → release-done → finish) back to back without stopping to ask; guidance the operator attached to the yolo word (e.g. patch bump, no tag) is a binding directive for the chain; checks and guardrails stay fully enforced.");
887
+ if (state.yolo) guidance.push("YOLO mode: the operator pre-confirmed every gate question from here on (Verified?/Release?/Finish?) — run the remaining gates (verify → release → finish) back to back without stopping to ask; guidance the operator attached to the yolo word (e.g. patch bump, no tag) is a binding directive for the chain; checks and guardrails stay fully enforced.");
874
888
  // The one playbook file this stage needs, named outright: the model reads it instead of
875
889
  // guessing what a stage asks of it, and it pays for itself the first time a gate is refused.
876
890
  const ref = stageReference(state.stage);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.91.1",
3
+ "version": "0.92.1",
4
4
  "description": "Enforced feature workflow for Pi: plan → implement → pre-release → release, gated checkpoints, self-improvement reflections, one git worktree per feature, changelog + publish as part of the release",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -6,16 +6,17 @@
6
6
  unbinds the session — so anything that needs them runs first.
7
7
 
8
8
  1. **`flow finish [--note="<friction the operator mentioned>"]`**
9
- - Release published but not recorded → it runs the release record first
10
- (no question).
9
+ - Published by hand and not recorded yet → it runs the release record
10
+ first (no question).
11
11
  - **Closing reflection** — while none is recorded, a read-only worker
12
12
  reviews this session's transcript and every worker transcript, dedupes
13
13
  against `.dev-flow/reflections.md` and upstream issues, and returns
14
14
  numbered findings, each **docs** / **code** / **plugin** with a **fold**
15
15
  or **drop** recommendation. Finish then stops.
16
- - A flow with **no friction** (no refusal, no guard block, no `--note`)
17
- skips the worker, unless the playbook says `reflect = always`.
18
- - Worker failed → nothing is removed: re-run, or review inline (bare `flow
16
+ - A flow with **no friction** (no guard block, no process refusal, no gate
17
+ stuck twice in a row, no `--note`) skips the worker, unless the playbook
18
+ says `reflect = always`. A red test or build is not friction.
19
+ - Worker failed or died → the gate says so and nothing is removed: re-run, or review inline (bare `flow
19
20
  reflect` prints the protocol). Only the operator's explicit word skips
20
21
  it: `flow finish --no-reflect --confirmed` — yolo never does.
21
22
  2. **Findings → ask fold or drop** per item — one plain line each — with
@@ -28,6 +29,12 @@ unbinds the session — so anything that needs them runs first.
28
29
  items the reviewer found fixed → propose checking them off.
29
30
  4. **`flow finish --confirmed`** without asking again. Nothing found → ask
30
31
  **Finish?** first.
32
+ - **A clean flow needs no question**: no friction, no open release-stage
33
+ item, nothing skipped → the first `flow finish` closes the feature and
34
+ says Finish? answered itself (`finish = always` in the playbook asks
35
+ every time). Report it; do not ask afterwards.
36
+ - A red after-merge check (`flow-check` under `## release`, run from the
37
+ main checkout) stops finish with its output: fix, re-run.
31
38
  5. Offer the printed suggestions (`⚑ fix the open reflections now?`, `↻ N
32
39
  closed reflection(s)`) in one line each; never start a fix flow without
33
40
  the operator's word.
@@ -16,7 +16,9 @@ note). Other sessions' worktrees are theirs.
16
16
  `.dev-flow/<slug>/tmp/`, removed at finish) — never a hard-coded `/tmp/...`.
17
17
  4. `flow check` runs every tier-1 check (test, health with seeded data, named
18
18
  `flow-check` blocks) and records them against the worktree; any later edit
19
- makes them stale, and verify reruns stale ones itself.
19
+ makes them stale, and verify reruns stale ones itself. It also says when
20
+ the branch fell behind the default branch and which files a rebase would
21
+ conflict in — resolve those now (`git rebase`), not inside verify.
20
22
  5. UI feature → a real browser visual pass, not just a typecheck.
21
23
  6. Walk the **tier-2 checklist** (`- [ ]` items) with the operator honestly —
22
24
  it cannot be scripted.
@@ -45,7 +47,9 @@ note). Other sessions' worktrees are theirs.
45
47
  unreleased. Record the kind, not a number, unless the operator names one:
46
48
  the gate counts it from the newest tag, so a parallel release moves it.
47
49
  3. Answer → `flow verify --confirmed` (yolo → `--yolo --confirmed`), plus
48
- `--version=patch|minor|major` (or `--version=<exact>`) or `--no-version`. If the
50
+ `--version=patch|minor|major` (or `--version=<exact>`) or `--no-version`. It does not
51
+ deploy again when the tree is the one it deployed for review — it only
52
+ probes that the app still answers. If the
49
53
  default branch moved since the review deploy it refuses: run `flow verify`
50
54
  again first. Fixes → iterate and re-verify; that loop is free.
51
55
 
@@ -5,10 +5,13 @@
5
5
  No code edits before approval. Reads are always allowed.
6
6
 
7
7
  1. **Research** the code the plan needs.
8
- 2. **Clarify before drafting**: give your direction in chat — the problem in
9
- one sentence, the fix in a few plain lines, open unknowns, the mode you
10
- propose and why — and ask your questions. File-by-file detail belongs in
11
- plan.md, not chat. Draft only after the direction is confirmed.
8
+ 2. **Clarify before drafting — when there is something to clarify**: open
9
+ questions, or more than one sound approach → give your direction in chat
10
+ (the problem in one sentence, the fix in a few plain lines, the unknowns)
11
+ and ask. Draft after the direction is confirmed. Nothing open and one
12
+ obvious approach → skip this round: write plan.md and go to Approve?,
13
+ which is the operator's chance to redirect. File-by-file detail belongs
14
+ in plan.md, not chat.
12
15
  3. **Write `.dev-flow/<slug>/plan/plan.md`** — problem, approach, files to
13
16
  touch, test strategy, risks. Reviewable, not exhaustive.
14
17
  - Create it as soon as the direction is confirmed and keep it current: chat
@@ -48,7 +51,8 @@ No code edits before approval. Reads are always allowed.
48
51
  state; caption planned behavior as planned; if a shot fights you twice,
49
52
  verify the state in the DOM and move on.
50
53
  5. **Ask Approve? and stop.** Report opening: **📝 plan · `<slug>`** (the
51
- gate's stage line). Answer → `flow approve --confirmed` (yolo → `flow
54
+ gate's stage line). A `--patch` / `--docs` flow: name the mode and the
55
+ one-line change in the question — the answer grants the mode. Answer → `flow approve --confirmed` (yolo → `flow
52
56
  approve --yolo --confirmed`).
53
57
 
54
58
  Approval creates the worktree and branch and runs `commands.setup` there; a
@@ -35,7 +35,8 @@ and settle the scheme with the operator; never invent one.
35
35
  dropped or rewritten pending line, leftovers under `Unreleased`, and a
36
36
  changelog this branch never touched. `--no-fold-check` only on the
37
37
  operator's word.
38
- 4. `flow check` — the prep made the earlier checks stale.
38
+ 4. No `flow check` is owed after the prep commit: the gate keeps green checks across a commit that
39
+ holds only the bump and changelog, and runs any stale check itself.
39
40
  5. **Run `flow release`.** By default (`ask = on-change`) it answers
40
41
  Release? itself when the release call is on record and only the prep
41
42
  landed since Verified? — say in a few lines what the PR delivers (the
@@ -48,13 +49,15 @@ and settle the scheme with the operator; never invent one.
48
49
  **🔍 pre-release · `<slug>`** (the gate's stage line; the version field
49
50
  reads `pending` until decided — never invent a bump or a no-version
50
51
  decision). Answer → `flow release --confirmed`.
51
- - Standing yolo → run `flow release` without asking. It still returns
52
- `NEEDS-OPERATOR Release?` when commits landed after Verified? or the
53
- playbook says `yolo = until-release` — then ask.
52
+ - Standing yolo → run `flow release` bare, without asking. It still returns
53
+ `NEEDS-OPERATOR Release?` when commits landed after Verified?, the
54
+ playbook says `yolo = until-release`, or the session build is stale —
55
+ then ask. A `--confirmed` passed before the gate asked is not an answer
56
+ there: the gate asks first.
54
57
  - Operator ships **without a version** → `flow release --no-version
55
58
  --confirmed`: no bump or tag, but the branch must add its line under
56
59
  `Unreleased`. A changed call is `--version=<v>` / `--no-version` with
57
60
  `--confirmed`, on their word.
58
61
 
59
- The gate re-checks tier-1, requires the manifest ahead of the last tag and a
62
+ The gate runs any tier-1 check that is stale, requires the manifest ahead of the last tag and a
60
63
  changelog **heading** for that version written on this branch.