pi-dev-flow 0.96.1 → 0.98.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 CHANGED
@@ -4,6 +4,38 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.98.0] - 2026-11-29
8
+
9
+ **A `confirm` or `protect` rule asks in chat instead of a dialog that held the call for hours. Also: `flow guard` tests a playbook rule, a release call the operator never named is shown before it counts, a hand rebase keeps the Verified? word, and five smaller fixes to workers, briefs and cleanup.**
10
+
11
+ ### Changed
12
+ - **A `confirm` or `protect` rule never opens a dialog inside the agent's call** (fixes #289). The dialog held the call before the command ran, outside its own timeout: 2h53m, 14h43m and about 10 hours in three sessions while nobody was there, with nothing in the transcript to say why. A yes in it also never reached the agent, so one session asked the same question 12 times. Now the call is refused at once as `NEEDS-OPERATOR Run it?` with the rule's reason, and the agent asks you in chat. On your yes it re-runs the same command prefixed with `DEV_FLOW_CONFIRMED=1`, or repeats the same edit. The yes counts only once you have replied since the refusal, and only for that exact command or path. A worker is never granted one. Every rule a call trips is one question. A force push and a merge with no style flag are asked in chat the same way.
13
+
14
+ ### Added
15
+ - **`flow guard "<command>"` and `flow guard --path <file>`** name the playbook `flow-guard` rule a command or an edit would trip, through the same matcher the hooks use, and run nothing. A playbook no longer hand-imports `guardBash` from `src/core.ts` to test its own rules (gh#287).
16
+
17
+ ### Fixed
18
+ - **A release call you never named is shown to you before it counts.** When your Approve? answer names no kind (a bare "approve") and the agent passed `--version=<kind>` from its own proposal, the gate records it as the agent's proposal, says so, and shows it with Verified? to keep or change. Your answer there, or `flow bump <kind> --confirmed`, settles it. If a yolo skips Verified?, the pre-release hint says to ask the kind before cutting the release prep (gh#299).
19
+ - **A hand rebase no longer re-asks Release?** A rebase replays the verified commits under new ids, and the gate listed them as "landed after Verified?". It now compares diffs (`git patch-id`, with the changelog and version file left out): a replayed commit with the patch you verified rides under your Verified?, and a commit whose content changed still asks (gh#298).
20
+ - **Resuming a stopped publish no longer asks for a word already given.** The red-CI "publish stopped" message mentions "the operator's word" (for a real failure's way forward), and that wording re-armed the rule that refuses an unanswered `--confirmed`. After a flaky job was re-run green, the resume was refused and Release? asked again. A stopped or waiting publish now never counts as a question (gh#283).
21
+ - **Release? over changed code asks one question.** When code landed after Verified?, the Release? refusal now tells the agent to ask one thing: re-verify and ask Verified? if behaviour changed, since Release? then answers itself, or else ask Release? with the commits named. Asking Release? first and then re-verifying spent the answer (gh#288).
22
+ - **`flow_stage` with no `op` says what to pass.** It was refused with pi's bare `op: missing`. The schema now lets the call through, so the refusal names the field and the three ops (gh#286).
23
+ - **A worker brief gives its scratch dir as a real path.** It said `$TMPDIR`, which a worker's shell does not set, so `mkdir "$TMPDIR/x"` tried `/x`. The brief now names the feature's tmp dir and says the project playbook's scratch rule wins (gh#281).
24
+ - **A review worker no longer re-runs checks the driver already ran green.** A check that passed against the exact tree under review is marked green in the brief, with "do not re-run it". A read-only reviewer is no longer handed the health probe, since the driver owns the deploy (gh#285).
25
+ - **Empty feature folders are found and cleaned up.** A `.dev-flow/<slug>/` with no file anywhere inside was neither a feature nor a ghost, so nothing named it. `flow doctor` now lists it, and `flow init` removes it without asking once it is ten minutes old. A `plan/` with no file in it counts as empty, not as a ghost (gh#282).
26
+
27
+ ## [0.97.0] - 2026-11-23
28
+
29
+ **A standard flow asks two questions, Approve? and Verified?, and runs the rest to done. Release? answers itself over docs and test commits and a stale build. Finish files the closing reflection's own fold/drop recommendations and does release-stage items as work. Dev port? is asked only while another flow's deploy is under review.**
30
+
31
+ ### Changed
32
+ - **A standard flow asks two questions: Approve? and Verified?** The rest runs to done unless something new comes up. Measured over ~50 real flows, the operator also answered Release? most of the time, "fold as suggested" at nearly every fold/drop list, and Finish? in chat.
33
+ - **Verified? is the release word.** Release? (`ask = on-change`) now also answers itself when the only commits after Verified? are docs (`docs/`, README, CHANGELOG) or tests, and the release output names those commits. `yolo = until-release` now holds back only a standing yolo, not a Verified? the operator gave themselves. A session running an older dev-flow build is a note on the release output instead of a question. Release? is still asked for a code change after Verified?, a major bump the playbook made, and `ask = always`.
34
+ - **Finish files the closing reflection's own fold/drop recommendations** instead of asking. A fold records a note, or counts a recurrence on the row it duplicates. A drop records nothing. The output lists each one with how to undo it. A plugin finding outside the dev-flow repo is named for the operator to file upstream, never filed by the gate. `finish = always` asks fold/drop as before.
35
+ - **Release-stage checklist items are work, not a question.** The first `flow finish` stops once to list them, to be done from the main checkout. The next `flow finish` closes out, and Finish? then answers itself.
36
+ - **Dev port? is asked only while another flow's deploy is under review and running alongside is not possible.** A holder that isn't waiting on its Verified? is replaced with a note, as one past Verified? already was. A holder under review gets a second instance next to it on the next free port when `parallelDev = yes` and the measured RAM and disk fit.
37
+ - **Skill rules:** a bare "continue", "proceed", "ok" or "yes" at a pending checkpoint is its answer. Never ask before `flow start`. Never pre-ask Release? or Finish?: run the gate, which asks only when something is open.
38
+
7
39
  ## [0.96.1] - 2026-11-23
8
40
 
9
41
  **A fold flow (started with `--reflections`) always merges unreleased with no release call, and finishes without the closing reflection.**
@@ -35,9 +35,11 @@ while your feature is at plan or implement.
35
35
  A dev deploy is machine state, not branch state, so `flow verify` keeps a small registry in
36
36
  `.dev-flow/dev-ports.json` (port → slug, commit, time). `flow status` shows it.
37
37
 
38
- If the flow holding your port is already past its **Verified?** (at pre-release or release, and not
39
- re-asking it), nobody is reviewing that deploy, so verify replaces it and says so. If the holder is
40
- still being reviewed or still in implement, verify doesn't deploy. Instead it asks
38
+ If the flow holding your port isn't waiting on its **Verified?** (it's past it, still in implement,
39
+ or gone), nobody is reviewing that deploy, so verify replaces it and says so; the holder's own
40
+ verify redeploys before it asks you. If the holder is under review and the playbook says
41
+ `parallelDev = yes`, verify runs alongside on the next free port by itself, as long as a second
42
+ instance fits the measured RAM and disk. Otherwise verify doesn't deploy. Instead it asks
41
43
  **Dev port?**, showing who holds the port and how much RAM and disk are free, and offers:
42
44
 
43
45
  - **run alongside** on the next free port (`--port=<n>`). This needs `parallelDev` not set to `no`,
package/docs/gates.md CHANGED
@@ -67,7 +67,9 @@ the question also asks: *patch, minor or major release, or merge unreleased?* Yo
67
67
  with `--version=<kind>` or `--no-version`; an Approve? answer without it is refused and nothing is
68
68
  kept. Only the kind of step is recorded, never a number: the number is counted from the newest tag
69
69
  when the release runs, so a flow that released first moves yours along instead of colliding with it.
70
- No later gate asks the call again. You can change it at any point until the tag is cut: say so,
70
+ No later gate asks the call again. When your Approve? answer names no kind (a bare "approve") and the
71
+ agent passed one anyway, the gate records it as the agent's proposal: the output says so, Verified?
72
+ shows it to you to keep or change, and your answer there settles it. You can change it at any point until the tag is cut: say so,
71
73
  and the agent runs `flow bump <patch|minor|major|none> --confirmed`, or passes
72
74
  `--version=<kind>` / `--no-version` on a confirmed `verify` or `release` call. A fold flow — one started with `--reflections`, as `flow reflect plan` prints it — is never asked the call: on a versioned project it always merges unreleased, and `--version=<kind>` or `flow bump <kind>` is refused. A flow approved by an
73
75
  older dev-flow, with no call on record, is asked at Verified? instead.
@@ -90,9 +92,10 @@ Run without `--confirmed`, it deploys for your review:
90
92
 
91
93
  1. Fetches, and rebases the branch if main moved ahead. Conflicts or uncommitted tracked edits
92
94
  refuse, and the branch is left untouched.
93
- 2. Checks the dev port. If another flow that is past its Verified? holds it, verify takes it over
94
- and says so. If one still under review holds it, it asks **Dev port?**: run alongside on
95
- another port, replace that deploy, or wait. See [concurrency](concurrency.md).
95
+ 2. Checks the dev port. If the flow holding it isn't waiting on its Verified?, nobody is reviewing
96
+ that deploy, so verify takes it over and says so. If it is under review, verify runs alongside on
97
+ the next free port when `parallelDev = yes` and a second instance fits; otherwise it asks
98
+ **Dev port?**: replace that deploy, or wait. See [concurrency](concurrency.md).
96
99
  3. Runs the checks (re-running any that are stale or missing), the build, the `dev` deploy, and then
97
100
  the health probe against what it just deployed.
98
101
  4. Asks **Verified?**
@@ -146,17 +149,23 @@ Proves the branch is ready to ship:
146
149
  - **No re-verify is waiting.** When `flow verify` at pre-release asked Verified? again, the answer
147
150
  has to be recorded (`flow verify --confirmed`) before the release ships under it.
148
151
 
149
- **Release? often answers itself** (`ask = on-change`, the default). That happens when your call is
150
- on record and only release prep (bump, changelog) changed since Verified?. A `--confirmed` given before the gate asked doesn't count where a question carries news you haven't
152
+ **Release? usually answers itself** (`ask = on-change`, the default): your Verified? is the release
153
+ word. That happens when your call is on record and only release prep (bump, changelog), docs
154
+ (`docs/`, README, CHANGELOG) or tests changed since Verified?; the output names any docs/test commit
155
+ that rode under it. A hand rebase replays the verified commits under new ids: a commit whose diff
156
+ (changelog and version file left out) matches one you verified rides under your Verified? too, while
157
+ a commit whose content changed still asks. A `--confirmed` given before the gate asked doesn't count where a question carries news you haven't
151
158
  seen (commits after Verified? on a yolo flow, or a stale build): the gate asks first. A yolo held back
152
159
  only by `yolo = until-release` is asked like any flow, so your chat answer stands on the first call.
153
160
 
154
161
  It still asks when:
155
- - code changed after Verified?;
156
- - the session runs an old build (proceeding is allowed, and it says what you'd miss);
157
- - the playbook sets `yolo = until-release`;
162
+ - code changed after Verified? (a CI fix, a late review fix: news you haven't seen);
163
+ - a standing yolo reaches it and the playbook sets `yolo = until-release` (a Verified? you gave yourself is not held back);
158
164
  - it's a major bump the playbook made rather than you.
159
165
 
166
+ A session running an older dev-flow build than the install is a note on the release output, not a
167
+ question: it names both builds and what didn't run, and `/reload` picks up the newer one.
168
+
160
169
  Set `ask = always` in `## release` to be asked every time.
161
170
 
162
171
  Escape hatches, used only on your word: `--no-fold-check` skips the line-level changelog check, and
@@ -220,7 +229,10 @@ call it.
220
229
  items, it stops and lists them.
221
230
  2. Runs the after-merge checks (`flow-check` blocks under `## release`) from the main checkout. A red
222
231
  one stops finish and removes nothing.
223
- 3. Runs the **closing reflection** (see [reflections](reflections.md)) and waits for your fold/drop.
232
+ 3. Runs the **closing reflection** (see [reflections](reflections.md)) and files the reviewer's own
233
+ fold/drop recommendations: a fold becomes a note (or a recurrence on the note it duplicates), a
234
+ drop records nothing. The output lists each with how to undo it. dev-flow feedback for upstream is
235
+ named for you, never filed by the gate. `finish = always` asks fold/drop as before.
224
236
  4. Cleans up, on `--confirmed` or when Finish? answers itself: removes the worktree, the branch and `.dev-flow/<slug>/`. It deletes
225
237
  the remote branch only once it's proven merged. If local main is just behind origin, it
226
238
  fast-forwards it.
@@ -232,10 +244,11 @@ Playbook commits from `flow init --track` are only noted: they reach origin thro
232
244
  never a direct push. Under `merge = merge`, commits missing from main are a policy violation that
233
245
  yolo can't answer.
234
246
 
235
- **Finish? answers itself on a clean flow** (`finish = on-change`, the default): the release is
236
- recorded, the flow had no friction so no reflection ran, no `## release` checklist item is open, and
237
- no forge release was skipped. It still asks when any of those is open, and always with
238
- `finish = always` in `## release`.
247
+ **Finish? answers itself** (`finish = on-change`, the default) once the release is recorded, the
248
+ closing reflection was skipped or filed, and no forge release was skipped. `## release` checklist
249
+ items are work, not a question: the first `finish` stops once and lists them (run from the main
250
+ checkout), and the next `finish` closes out. It still asks when a forge release was skipped or the
251
+ reflection's report didn't parse, and always with `finish = always` in `## release`.
239
252
 
240
253
  To drop an unreleased feature, use `flow abort` instead.
241
254
 
@@ -246,8 +259,11 @@ To drop an unreleased feature, use `flow abort` instead.
246
259
  manages `.dev-flow/roadmap.md`. `pick` stamps an item for `flow start <slug>`, and `finish` checks
247
260
  it off when the feature ships.
248
261
  - `flow doctor ["<note>"]` is a read-only health report: playbook drift, dead commands, ghost
249
- folders, orphan worktrees and branches, and a review of every open reflection. It writes nothing,
250
- so it's safe at any stage and in CI.
262
+ folders, empty feature folders, orphan worktrees and branches, and a review of every open
263
+ reflection. It writes nothing, so it's safe at any stage and in CI. `flow init` removes an empty
264
+ feature folder (no file anywhere inside) without asking, once it is ten minutes old.
265
+ - `flow guard "<command>"` / `flow guard --path <file>` names the playbook `flow-guard` rule a
266
+ command or an edit would trip, or says none does. It reads only.
251
267
 
252
268
  ## status, abort, help, version
253
269
 
@@ -269,7 +285,6 @@ Answering **yolo** at any checkpoint runs that gate with `--yolo --confirmed`. T
269
285
  question and pre-confirms the rest, so the agent runs the remaining gates back to back, following
270
286
  any wishes you added ("yolo, patch bump"). Every check and guard still applies. Yolo never answers:
271
287
  - the re-verify at pre-release;
272
- - Release? when code changed after Verified?, when the playbook sets `yolo = until-release`, or
273
- when the session runs an older build than the install;
288
+ - Release? when code changed after Verified?, or when the playbook sets `yolo = until-release`;
274
289
  - a `merge = merge` policy violation at finish;
275
290
  - skipping the closing reflection.
@@ -52,10 +52,18 @@ playbook, dev-flow stays silent.
52
52
 
53
53
  **Your own rules.** The `deny` / `confirm` / `protect` / `forbid` rules in your playbook's
54
54
  `flow-guard` block run on every bash command and every edit, at every stage, before dev-flow's own
55
- checks. A block always shows the reason you wrote. See the [playbook](playbook.md).
56
-
57
- **Force pushes ask you.** `git push --force` / `-f` / `--force-with-lease` needs your OK. The
58
- refusal prints the prefix that marks it as approved: `DEV_FLOW_ALLOW_REWRITE=1`.
55
+ checks. A block always shows the reason you wrote. See the [playbook](playbook.md). To test a rule
56
+ before an agent meets it, `flow guard "<command>"` (or `flow guard --path <file>`) names the rule that
57
+ fires, with the same matcher the hooks use, and runs nothing.
58
+
59
+ **Rules that ask you never wait on a dialog.** A `confirm` or `protect` rule refuses the call at
60
+ once with your reason, and the agent asks you in chat. On your yes it re-runs the command prefixed
61
+ with `DEV_FLOW_CONFIRMED=1` (or repeats the edit). The prefix counts only after you replied, and only
62
+ for the command it was asked about. A dialog used to hold the call, outside its own timeout, for
63
+ hours while nobody was there, and a yes in it never reached the agent, so it asked again.
64
+
65
+ **Force pushes ask you.** `git push --force` / `-f` / `--force-with-lease` needs your OK, asked in
66
+ chat. The refusal prints the prefix that marks it as approved: `DEV_FLOW_ALLOW_REWRITE=1`.
59
67
 
60
68
  **Shell calls can't hang.** The model often omits a timeout, so a `gh` waiting on a prompt could
61
69
  freeze a session for hours. A shell call without a timeout gets a default for its kind:
package/docs/playbook.md CHANGED
@@ -141,12 +141,17 @@ forbid docker/secrets :: secret storage
141
141
  | Verb | Applies to | What happens |
142
142
  |---|---|---|
143
143
  | `deny` | a bash command (regex) | blocked |
144
- | `confirm` | a bash command (regex) | asks you; blocked when there's no UI to ask |
145
- | `protect` | an edit/write path | asks you; blocked when there's no UI |
144
+ | `confirm` | a bash command (regex) | refused with your reason; the agent asks you in chat, and on your yes re-runs it prefixed with `DEV_FLOW_CONFIRMED=1` |
145
+ | `protect` | an edit/write path | refused with your reason; the agent asks you in chat, and on your yes repeats the edit |
146
146
  | `forbid` | an edit/write path | blocked |
147
147
 
148
148
  Tips:
149
- - Text after ` :: ` is the reason, shown when the rule fires.
149
+ - Text after ` :: ` is the reason, shown when the rule fires. Name the safe form in it (`scope it with
150
+ --no-deps`): the agent reads it on every refusal, so it can use that form instead of asking you.
151
+ - A `confirm` or `protect` never opens a dialog. The yes counts only after you reply in chat, and it
152
+ covers that exact command or path. When a safe form always exists, prefer `deny` with the safe form
153
+ in the reason: the agent fixes the command itself and you are never asked.
154
+ - `flow guard "<command>"` or `flow guard --path <file>` shows which rule fires, without running anything.
150
155
  - `flow_stage` workers get these rules in their brief. A worker has no one to ask, so `confirm` and
151
156
  `protect` are refusals for it, and the reason you write is what it reads.
152
157
  - An invalid regex makes the playbook invalid, and `flow init` refuses it.
@@ -43,8 +43,12 @@ transcript and every worker's. It checks the findings against the open notes and
43
43
  issues, then gives you a numbered list. Each finding is marked docs, code or plugin, with a
44
44
  suggestion to **fold** (keep) or **drop** it.
45
45
 
46
- You answer per item, for example `fold 1,3 drop 2`. Folding records a note, or files the issue for a
47
- plugin finding. Dropping records nothing.
46
+ Finish files the reviewer's own recommendation for each finding, without asking: a fold records a
47
+ note (or counts a recurrence on the note it duplicates), a drop records nothing. The output lists
48
+ each one with how to undo it (`flow reflect done <id> "dropped"`, or `flow reflect --playbook|--code
49
+ "<note>"` to keep a drop). A plugin finding outside the dev-flow repo is an upstream issue, which is
50
+ public, so it's named for you to file and never filed by the gate. Set `finish = always` in
51
+ `## release` to answer fold/drop yourself, for example `fold 1,3 drop 2`.
48
52
 
49
53
  The review is skipped when the flow ran into no friction: no guard block, no gate refusing for a
50
54
  process reason (wrong stage, a missing plan, a proof that doesn't hold), no gate refusing twice in a
@@ -24,17 +24,17 @@ import path from "node:path";
24
24
  import { Type } from "typebox";
25
25
  import { compact, defineTool, isToolCallEventType, type AgentSession, type ExtensionContext } from "@earendil-works/pi-coding-agent";
26
26
  import { type ExtensionAPI, type ToolCallEvent, type ToolCallEventResult, type TurnEndEvent, type TurnEndEventResult } from "@earendil-works/pi-coding-agent";
27
- import { ALLOW_REWRITE, applicableItems, openItemsNote, bashFlowGuard, checklistPending, checkoutInvocation, claimBlocks, featureBranchPrefix, FLOW_SHELL_HINT, flowShellInvocation, forcePushInvocation, freshenChecks, gitInvocation, guardBash, guardPath, mergeStyleInvocation, parsePushRefs, playbookTamper, playbookOnlyChange, pluginVersion, reflectionNudges, buildReflectBrief, parseReflectReport, renderReflectFindings, childSessionFiles, workerSteer, workerSteerAt, recoverReflectRows, assistantTexts, WORKER_SALVAGE, WORKER_SALVAGE_MS, WORKER_NUDGE_READONLY, stageReference, needsOperator, NEEDS_OPERATOR, nextHint, roadmapOpenCount, shouldTakeOverCompaction, stageGuidance, stateTamper, statusFor, sq, featureTmpDir, compactionStateBlock, withTmpDir, widgetLines, chipLabel, writeGuard, buildWorkerBrief, clampBudgetMin, parseWorkerReport, workerTurnError, hollowStop, hollowStopNote, workerOpError, WORKER_NUDGE, WORKER_NUDGES, releaseOrderInvocation, worktreeWorkGuard, flowArgsShapeError, type WorkerOp, type FlowState, type PushRef } from "../src/core.ts";
27
+ import { ALLOW_REWRITE, OPERATOR_CONFIRMED, confirmedPrefix, guardConfirmVerdict, type GuardAsk, applicableItems, openItemsNote, bashFlowGuard, checklistPending, checkoutInvocation, claimBlocks, featureBranchPrefix, FLOW_SHELL_HINT, flowShellInvocation, forcePushInvocation, freshenChecks, gitInvocation, guardBash, guardPath, mergeStyleInvocation, parsePushRefs, playbookTamper, playbookOnlyChange, pluginVersion, reflectionNudges, buildReflectBrief, parseReflectReport, renderReflectFindings, childSessionFiles, workerSteer, workerSteerAt, recoverReflectRows, assistantTexts, WORKER_SALVAGE, WORKER_SALVAGE_MS, WORKER_NUDGE_READONLY, stageReference, needsOperator, NEEDS_OPERATOR, nextHint, roadmapOpenCount, shouldTakeOverCompaction, stageGuidance, stateTamper, statusFor, sq, featureTmpDir, compactionStateBlock, withTmpDir, widgetLines, chipLabel, writeGuard, buildWorkerBrief, clampBudgetMin, parseWorkerReport, workerTurnError, hollowStop, hollowStopNote, workerOpError, WORKER_NUDGE, WORKER_NUDGES, releaseOrderInvocation, worktreeWorkGuard, flowArgsShapeError, type WorkerOp, type FlowState, type PushRef } from "../src/core.ts";
28
28
  import { loadProject } from "../src/projectmd.ts";
29
29
  import { bashTimeout, requireTimeout, timeoutClass } from "../src/timeouts.ts";
30
30
  import { AGENT_MARK, operatorCommandAsks, operatorCommandCorrection, viewHeader, askLine, type GateView } from "../src/present.ts";
31
31
  import { Text } from "@earendil-works/pi-tui";
32
32
  import { CONTEXT_EMITTED, COPIES, GATE_HELP, SELF_BUILD, SKILL_DIR, type Ui, WEB_CHIP_KEYS, LEGACY_CHIP_KEYS, nextChipKeys, baseSeams, bindings, boundFeature, claimBlocker, claimFile, compacting, compactionTakeover, coreInjected, coreStale, currentBranch, dfDir, featDir, featureRefs, flowCompactInstructions, flowRoot, guardsAreMine, initiated, lastContext, loadedVersion, maybeCompactNow, noteFriction, now, readClaim, readReflections, readReflectionsText, readRoadmap, readState, registerCopy, releaseSession, sessionKey, sh, skillCore, unfinishedStates, worktreeAbs, writeClaim, writeState } from "../src/runtime/base.ts";
33
- import { type Session, presentRun } from "../src/runtime/checks.ts";
33
+ import { type Session, presentRun, worktreeFingerprint } 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, isFriction, newGrantLedger, operatorMessageCount, type RefusalStreak } from "../src/runtime/grants.ts";
37
+ import { grantCheck, grantRecord, isFriction, lastOperatorText, 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";
@@ -86,12 +86,6 @@ function refreshStatus(ctx: ExtensionContext, root: string): void {
86
86
  }
87
87
 
88
88
 
89
- /** A project confirm rule with no operator present is a block — a hidden confirmation is not a confirmation. */
90
- async function askOperator(ctx: ExtensionContext, what: string, why: string): Promise<string | null> {
91
- if (!ctx.hasUI) return needsOperator(`${why}: this needs an operator confirmation and no UI is available — ask them, or run it yourself outside Pi`);
92
- const ok = await ctx.ui.confirm("dev-flow project rule", `${what}\n\n${why}\n\nProceed?`);
93
- return ok ? null : `operator declined — ${why}`;
94
- }
95
89
 
96
90
  /** What a kill by dev-flow's own timeout tells the agent (and the operator reading the transcript). */
97
91
  export function timeoutKillNote(armed: { s: number; cls: string }): string {
@@ -126,6 +120,7 @@ export default function devFlow(pi: ExtensionAPI) {
126
120
  key,
127
121
  slug: bindings.get(key) ?? null,
128
122
  operatorMessages: operatorMessageCount((() => { try { return ctx.sessionManager?.getBranch(); } catch { return null; } })()),
123
+ operatorText: lastOperatorText((() => { try { return ctx.sessionManager?.getBranch(); } catch { return null; } })()),
129
124
  bind: (slug) => {
130
125
  const prev = bindings.get(key);
131
126
  bindings.set(key, slug);
@@ -148,6 +143,22 @@ export default function devFlow(pi: ExtensionAPI) {
148
143
 
149
144
  /** Which gate asked for the operator's word, and when features started — per session (gh#190). */
150
145
  const grantLedger = newGrantLedger();
146
+ /** Per session: the last guard confirm refused, so the operator's answer can be matched to it (gh#289). */
147
+ const guardAsks = new Map<string, GuardAsk>();
148
+ /** A call that trips confirm rule(s): never a dialog — run on the operator's chat answer, else refuse with the reason. */
149
+ const askOperator = (ctx: ExtensionContext, key: string, o: { target: string; what: string; whys: string[]; prefixed: boolean; edit: boolean }): string | null => {
150
+ const users = (() => {
151
+ try {
152
+ return operatorMessageCount(ctx.sessionManager?.getBranch());
153
+ } catch {
154
+ return null;
155
+ }
156
+ })();
157
+ const v = guardConfirmVerdict({ ...o, users, prev: guardAsks.get(key), worker: isWorkerSession(ctx) });
158
+ if (v.allow) return null;
159
+ if (v.record) guardAsks.set(key, v.record);
160
+ return v.reason;
161
+ };
151
162
  /** Gates that refused in a row, per session — what turns a failing check into friction (see isFriction). */
152
163
  const refusalStreak: RefusalStreak = new Map();
153
164
 
@@ -281,7 +292,7 @@ export default function devFlow(pi: ExtensionAPI) {
281
292
  /** Driver sessions with a worker running right now — one worker per session at a time. */
282
293
  const runningWorkers = new Set<string>();
283
294
 
284
- type WorkerResult = { content: { type: "text"; text: string }[]; details: { op: WorkerOp; outcome: string; verdict: string | null; commits: number; findings?: number; recorded?: boolean } | undefined; isError?: boolean };
295
+ type WorkerResult = { content: { type: "text"; text: string }[]; details: { op: WorkerOp; outcome: string; verdict: string | null; commits: number; findings?: number; recorded?: boolean; report?: ReturnType<typeof parseReflectReport> | null } | undefined; isError?: boolean };
285
296
 
286
297
  /** One fresh-session worker run for a bound flow — the body of flow_stage, shared with flow finish,
287
298
  * which runs the closing reflection itself before it removes anything (the worker reads the session
@@ -362,7 +373,14 @@ export default function devFlow(pi: ExtensionAPI) {
362
373
  defaultBranch: cfg.defaultBranch,
363
374
  commits: await git(`git log --oneline ${sq(cfg.defaultBranch)}..HEAD`),
364
375
  status: await git("git status --short"),
365
- checks: st.docs ? [] : cfg.checkList.map((c) => ({ name: c.name, command: c.cmd })),
376
+ checks: st.docs
377
+ ? []
378
+ : await (async () => {
379
+ // green only when proven against this tree: a record with no fingerprint is not proof (gh#285)
380
+ const fp = wop === "review" ? await worktreeFingerprint(work) : null;
381
+ return cfg.checkList.map((c) => ({ name: c.name, command: c.cmd, green: !!fp && !!st.checks[c.name]?.ok && st.checks[c.name]?.wt === fp }));
382
+ })(),
383
+ scratchDir: ((d) => (mkdirSync(d, { recursive: true }), d))(featureTmpDir(dfDir(root), st.slug)),
366
384
  preamble: cfg.workerPreamble,
367
385
  docs: !!st.docs,
368
386
  guard: cfg.guard,
@@ -513,7 +531,7 @@ export default function devFlow(pi: ExtensionAPI) {
513
531
  if (nudges.tidy) parts.push(`${nudges.tidy} — offer it after the fold/drop answer.`);
514
532
  if (newCommits.trim() || dirty !== statusBefore) parts.push("note: the reflect worker changed the tree — inspect the change; it was told to write nothing");
515
533
  parts.push(`transcript: ${transcript || "(unknown)"}`);
516
- return { content: [{ type: "text", text: parts.join("\n\n") }], details: { op: wop, outcome, verdict: null, commits: 0, findings: reflected?.findings.length ?? 0, recorded: report.found } };
534
+ return { content: [{ type: "text", text: parts.join("\n\n") }], details: { op: wop, outcome, verdict: null, commits: 0, findings: reflected?.findings.length ?? 0, recorded: report.found, report: rows ? reflected : null } };
517
535
  }
518
536
  parts.push(
519
537
  report.found ? `REPORT:\n${report.body.slice(0, 6000)}` : modelError ? deadModelNote : `no REPORT — last words:\n${report.body}`,
@@ -544,7 +562,7 @@ export default function devFlow(pi: ExtensionAPI) {
544
562
  const finishReflectHook = (id: string, ctx: ExtensionContext, root: string, signal?: AbortSignal, onUpdate?: (u: { content: { type: "text"; text: string }[]; details: unknown }) => void): FlowHooks => ({
545
563
  reflect: async (st, note) => {
546
564
  const r = await runStageWorker({ id, wop: "reflect", st, root, key: sessionKey(ctx), note, label: "finish reflection", signal, onUpdate, ctx });
547
- return { text: r.content.map((c) => c.text).join("\n"), recorded: !!r.details?.recorded, findings: r.details?.findings ?? 0, failed: !!r.isError };
565
+ return { text: r.content.map((c) => c.text).join("\n"), recorded: !!r.details?.recorded, findings: r.details?.findings ?? 0, failed: !!r.isError, report: r.details?.report ?? undefined };
548
566
  },
549
567
  });
550
568
 
@@ -555,7 +573,9 @@ export default function devFlow(pi: ExtensionAPI) {
555
573
  'Optional: hand a slice of work to a fresh pi session so this conversation stays lean. op "implement" (stage implement) — the worker edits and commits a slice on the feature branch; op "review" (implement or pre-release) — a fresh read-only reviewer that returns findings and a PASS/FAIL verdict (the verdict is advisory; that a review ran is recorded — run it in implement once flow check is green: flow verify requires a review on record before it asks Verified?); op "reflect" (any stage; flow finish runs it itself before cleanup) — a fresh read-only reviewer of this session\'s transcript and every worker transcript that returns classified reflection findings (docs / code / plugin) with a fold-or-drop recommendation each, for the operator to decide. The plan path, branch, commits so far and the project checks are added to the brief automatically — `note` is just the slice: what to do, operator answers and decisions the worker cannot see. The worker holds no flow tool; gates and checkpoints stay with you. Delegate an implement slice when it is in the plan, provable by flow check, needs no operator input mid-slice and is big enough (≈4+ files or heavy reading) to crowd this context; small work, small fixes, mid-debug work, operator-judged work and final integration stay inline (criteria: references/implement.md). In pi-web the worker appears in the session\'s Agents menu as a subagent (running while it works, then its final status); the opened transcript holds its report.',
556
574
  promptSnippet: 'flow_stage(op: "implement"|"review"|"reflect", note, label?) — optional fresh-session worker for a big implement slice, an independent review, or a reflection (flow finish runs the closing one itself); gates stay with you; in pi-web workers show up as subagents in the Agents menu',
557
575
  parameters: Type.Object({
558
- op: Type.String({ description: '"implement" (a worker edits + commits a slice), "review" (read-only reviewer, findings + verdict) or "reflect" (read-only reviewer of the session transcripts, reflection findings + fold/drop recommendations)' }),
576
+ // required in practice, optional in the schema: a missing op then reaches workerOpError, which says what to
577
+ // pass, instead of pi's bare "op: missing" refusal (gh#286)
578
+ op: Type.Optional(Type.String({ description: 'Required. "implement" (a worker edits + commits a slice), "review" (read-only reviewer, findings + verdict) or "reflect" (read-only reviewer of the session transcripts, reflection findings + fold/drop recommendations)' })),
559
579
  note: Type.String({ description: "The slice: what to do and anything from this conversation the worker must know (operator answers, decisions). Facts (plan path, commits, checks) are added for you." }),
560
580
  label: Type.Optional(Type.String({ description: "A few words naming this delegation, shown in the worker's session name." })),
561
581
  budgetMin: Type.Optional(Type.Number({ description: "Wall-clock budget in minutes (5-180). Default 60 implement; 30 review, +10 per 500 changed lines past 500 (up to 90); 20 reflect, +5 per 250 KB of transcript past 250 KB (up to 60). Past it the worker is interrupted." })),
@@ -730,7 +750,8 @@ export default function devFlow(pi: ExtensionAPI) {
730
750
  const pv = guardPath(abs, ctx.cwd, cfg.guard);
731
751
  if (pv.block) return { block: true, reason: pv.block };
732
752
  if (pv.confirm) {
733
- const why = await askOperator(ctx, `Editing ${path.relative(ctx.cwd, abs) || abs}`, pv.confirm);
753
+ const rel = path.relative(ctx.cwd, abs) || abs;
754
+ const why = askOperator(ctx, key, { target: `edit:${abs}`, what: `Editing ${rel}`, whys: [pv.confirm], prefixed: false, edit: true });
734
755
  if (why) return { block: true, reason: why };
735
756
  }
736
757
  // only an unbound session's main-checkout write ever reads it — ask git just then (gh#175)
@@ -748,8 +769,17 @@ export default function devFlow(pi: ExtensionAPI) {
748
769
  // and the operator's deny outranks dev-flow's own stage verdicts
749
770
  const gv = guardBash(command, cfg.guard);
750
771
  if (gv.block) return { block: true, reason: gv.block };
751
- for (const r of gv.confirms) {
752
- const why = await askOperator(ctx, command, r.why || `project rule ${r.pattern}`);
772
+ // the playbook's merge style is enforced where the decision is actually made: gh/glab merging the PR.
773
+ // An explicit contradiction is a hard block, a merge with no style flag (the forge default decides)
774
+ // is a confirmation. No policy in the playbook → no new verdicts at all.
775
+ const mv = mergeStyleInvocation(command, cfg.release.merge);
776
+ if (mv.block) return { block: true, reason: mv.block };
777
+ // every confirm this call trips is one question to the operator, not one per rule (gh#289)
778
+ const whys = [...gv.confirms.map((r) => r.why || `project rule ${r.pattern}`), ...(mv.confirm ? [mv.confirm] : [])];
779
+ if (whys.length) {
780
+ const cp = confirmedPrefix(command);
781
+ const short = cp.target.length > 160 ? `${cp.target.slice(0, 160)}…` : cp.target;
782
+ const why = askOperator(ctx, key, { target: cp.target, what: `\`${short}\``, whys, prefixed: cp.prefixed, edit: false });
753
783
  if (why) return { block: true, reason: why };
754
784
  }
755
785
  // `flow` in a shell is a 127 with no pointer, so the mistake repeated — name the call that works
@@ -758,19 +788,9 @@ export default function devFlow(pi: ExtensionAPI) {
758
788
  if (mustStateTimeout) return { block: true, reason: requireTimeout(command)! };
759
789
  // a forced push rewrites history CI and other sessions already have. dev-flow asks the operator
760
790
  // itself so a project never needs a blunt `--force` deny of its own (#82, #83)
761
- if (forcePushInvocation(command)) {
762
- const why = await askOperator(ctx, command, `a forced push rewrites a pushed branch — CI and other sessions lose these commits (with the operator's word, prefix the push with ${ALLOW_REWRITE})`);
763
- if (why) return { block: true, reason: why };
764
- }
765
- // the playbook's merge style is enforced where the decision is actually made: gh/glab merging the PR.
766
- // An explicit contradiction is a hard block, a merge with no style flag (the forge default decides)
767
- // is a confirmation. No policy in the playbook → no new verdicts at all.
768
- const mv = mergeStyleInvocation(command, cfg.release.merge);
769
- if (mv.block) return { block: true, reason: mv.block };
770
- if (mv.confirm) {
771
- const why = await askOperator(ctx, command, mv.confirm);
772
- if (why) return { block: true, reason: why };
773
- }
791
+ // no dialog here either (gh#289): the refusal names the prefix that carries the operator's word
792
+ if (forcePushInvocation(command))
793
+ return { block: true, reason: needsOperator("a forced push rewrites a pushed branch — CI and other sessions lose these commits", "Force-push?", `ask the operator in chat; on their yes, prefix the push with ${ALLOW_REWRITE}`) };
774
794
  // shipping on the forge (PR merge, release page) is release-stage work for a bound feature
775
795
  if (/\b(?:gh|glab)\b/.test(command)) {
776
796
  const ro = releaseOrderInvocation(command, boundFeature(guardRoot, key)?.stage ?? null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.96.1",
3
+ "version": "0.98.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": [
@@ -19,10 +19,10 @@ criteria hold. Call it with an args array — `["start", "dark-mode"]`,
19
19
  - **The flow tool is the only invocation.** There is no `flow` shell command —
20
20
  never bash, `npx` or a path.
21
21
  - **You run the gates; the operator says words.** Never ask the operator to
22
- type a `flow` or `/flow` command. A checkpoint is one word asked in plain
22
+ type a `flow` or `/flow` command. A checkpoint is one word asked in
23
23
  chat — **Approve? / Verified? / Release? / Finish?** — mentioning that
24
- *yolo* is an answer, then stop. Their word (or a clear equivalent) in chat →
25
- run that gate with `--confirmed`. A structured question tool is not chat;
24
+ *yolo* is an answer, then stop. Their word (or an equivalent, even "ok") in chat →
25
+ run that gate with `--confirmed`; never re-ask. A structured question tool is not chat;
26
26
  never infer the answer — the flow tool refuses a `--confirmed` with no
27
27
  operator message since the gate asked. A gate returning `NEEDS-OPERATOR <Question?>` means:
28
28
  ask exactly that, in chat. `/flow` is the operator's own override; mention it
@@ -14,29 +14,35 @@ unbinds the session — so anything that needs them runs first.
14
14
  reviews this session's transcript and every worker transcript, dedupes
15
15
  against `.dev-flow/reflections.md` and upstream issues, and returns
16
16
  numbered findings, each **docs** / **code** / **plugin** with a **fold**
17
- or **drop** recommendation. Finish then stops.
17
+ or **drop** recommendation. Finish files those recommendations itself
18
+ (a fold is a note or a recurrence on the row it duplicates; a drop
19
+ records nothing) and goes on — no fold/drop question. Relay the list it
20
+ prints, with its undo line. A plugin finding outside the dev-flow repo
21
+ is listed for the operator to file upstream on their word — never file
22
+ it yourself.
18
23
  - A flow with **no friction** (no guard block, no process refusal, no gate
19
24
  stuck twice in a row, no `--note`) skips the worker, unless the playbook
20
25
  says `reflect = always`. A red test or build is not friction.
21
26
  - Worker failed or died → the gate says so and nothing is removed: re-run, or review inline (bare `flow
22
27
  reflect` prints the protocol). Only the operator's explicit word skips
23
28
  it: `flow finish --no-reflect --confirmed` — yolo never does.
24
- 2. **Findings → ask fold or drop** per item — one plain line each — with
25
- your recommendation (`fold
26
- 1,3 drop 2` is a fine answer), and stop. That answer **is** Finish?.
27
- 3. **Apply it**: fold docs → `flow reflect --playbook "<note>"`; fold code →
28
- `flow reflect --code "<note>"`; fold plugin → `flow reflect --plugin
29
- "<note>"` prints the upstream recipe — search first, then `gh issue create`
30
- and report the URL. Plugin findings never go into `reflections.md`. Open
31
- items the reviewer found fixed → propose checking them off.
32
- 4. **`flow finish --confirmed`** without asking again. Nothing found → ask
33
- **Finish?** first.
34
- - **A clean flow needs no question**: no friction, no open release-stage
35
- item, nothing skipped → the first `flow finish` closes the feature and
36
- says Finish? answered itself (`finish = always` in the playbook asks
37
- every time). Report it; do not ask afterwards.
29
+ - `finish = always` in the playbook, or a report whose rows did not parse →
30
+ the gate asks **Fold or drop?** / **Finish?** as before: ask it, apply the
31
+ answer (`flow reflect --playbook|--code "<note>"`, `--same r<id>`,
32
+ `--plugin` prints the upstream recipe), then `flow finish --confirmed`.
33
+ 2. **Release-stage checklist items** (`- [ ]` under `## release`) are work:
34
+ the first `flow finish` stops once (`release-stage work —`, not a
35
+ question) and lists them. Do each from the main checkout, then run `flow
36
+ finish` again — no question to ask; report what each showed.
38
37
  - A red after-merge check (`flow-check` under `## release`, run from the
39
38
  main checkout) stops finish with its output: fix, re-run.
39
+ 3. **Never ask Finish? before calling the gate.** Run `flow finish` as soon
40
+ as the release is recorded; it answers Finish? itself when nothing is left
41
+ open, and returns `NEEDS-OPERATOR Finish?` only when something is (a
42
+ skipped forge release, `finish = always`). Report it; do not ask
43
+ afterwards.
44
+ 4. Open items the reviewer found fixed are listed as proposals — check them
45
+ off only on the operator's word (`flow reflect done r<id> "<where>"`).
40
46
  5. Offer the printed suggestions (`⚑ fix the open reflections now?`, `↻ N
41
47
  closed reflection(s)`) in one line each; never start a fix flow without
42
48
  the operator's word.
@@ -52,21 +52,22 @@ and settle the scheme with the operator; never invent one.
52
52
  6. **Run `flow release` before asking anything.** Never ask Release? in
53
53
  chat ahead of the call: the gate did not see that question, and when it
54
54
  needs the word it asks again, so the operator answers twice. By default (`ask = on-change`) it answers
55
- Release? itself when the release call is on record and only the prep
56
- landed since Verified? — say in a few lines what the PR delivers (the
55
+ Release? itself when the release call is on record and only the prep,
56
+ docs or tests landed since Verified? — the operator's Verified? is the
57
+ release word. Say in a few lines what the PR delivers (the
57
58
  changelog entry usually is that) and the version, and carry on with the
58
59
  release stage.
59
60
  7. **It returned `NEEDS-OPERATOR Release?`** (it says why: code after
60
- Verified?, no call on record, a stale build, `yolo = until-release`, a
61
- major bump, or the playbook's `ask = always`) → **ask Release? and
61
+ Verified?, no call on record, a standing yolo under `yolo =
62
+ until-release`, a major bump, or the playbook's `ask = always`) → **ask Release? and
62
63
  stop**, with the same summary and the version. Report opening:
63
64
  **🔍 pre-release · `<slug>`** (the gate's stage line; the version field
64
65
  reads `pending` until decided — never invent a bump or a no-version
65
66
  decision). Answer → `flow release --confirmed`.
66
67
  - Standing yolo → run `flow release` bare, without asking. It still returns
67
- `NEEDS-OPERATOR Release?` when commits landed after Verified?, the
68
- playbook says `yolo = until-release`, or the session build is stale —
69
- then ask. A `--confirmed` passed before the gate asked is not an answer
68
+ `NEEDS-OPERATOR Release?` when commits landed after Verified? or the
69
+ playbook says `yolo = until-release` — then ask. A stale session build is
70
+ a note in the output, never a question. A `--confirmed` passed before the gate asked is not an answer
70
71
  there: the gate asks first. Never carry the standing yolo onto the call
71
72
  as `--yolo`: the operator's answer is `flow release --confirmed`.
72
73
  - Operator ships **without a version** → `flow release --no-version
@@ -57,5 +57,5 @@ git (merge, tag, push on the default branch) is allowed only in this stage.
57
57
  - `release.artifact` set and CI publishes from the tag: the record step waits
58
58
  for that CI (up to 15 min) — no hand-run `gh run watch`.
59
59
  - After-merge work: `flow-check` blocks under `## release` are run by
60
- `flow finish` from the main checkout; `- [ ]` items there close with the
61
- Finish? answer.
60
+ `flow finish` from the main checkout; `- [ ]` items there are work — the
61
+ first `flow finish` stops once to list them, the next one closes out.
@@ -35,6 +35,8 @@ knobs · merge-policy state.
35
35
  adds the mockup gate, so don't ask. Turning it **off** is the operator's:
36
36
  `flow start <slug> --no-ui --confirmed` at plan, after they say so, and
37
37
  aborting a ui feature at plan asks the same.
38
+ - **Never ask before `flow start`**: starting only creates the plan stage;
39
+ the operator's first word is Approve?.
38
40
  - **A mode is a proposal, not a grant**: pass `--patch` or `--docs` on the
39
41
  start call when the work fits (no `--confirmed`, no question). The
40
42
  operator grants it with their **Approve?** answer — say the mode and why