pi-dev-flow 0.86.2 → 0.87.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,24 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.87.0] - 2026-11-09
8
+
9
+ **Fewer false alarms, more reflections where they matter, and a way to drop a roadmap item.**
10
+
11
+ ### Fixed
12
+ - **The "don't ask the operator to type commands" note stops firing on plain reports.** After a final reply, dev-flow checks whether the agent handed you a flow command to type and, if so, adds a hidden correction. In recent sessions every one of these corrections was wrong. The agent was only reporting what it had run, for example "`bun run build`, `docker compose up -d --no-deps`" or "`flow check`: PASS". Three things caused it: any `--flag` counted as a dev-flow flag, words inside inline code such as `bun run` counted as instructions to you, and stage workers hosted by pi-web were not recognised as workers. Now only dev-flow's own gate flags count, the check reads only the words outside code, each clause is judged separately, reflection report rows are skipped, and pi-web workers are excluded.
13
+ - **The closing reflection now runs on flows that had real friction.** Finish skips the reflection when a flow went smoothly, but it judged that too narrowly. A refusal made before `flow start` was dropped, because no feature existed yet to count it against. Code changes committed after you answered Verified? also didn't count. Both now count: the pre-start refusal goes to the feature that `start` creates, and a post-Verified? commit that touches more than the version bump and changelog counts when you answer Release?.
14
+
15
+ ### Added
16
+ - **`flow roadmap drop <n>`** (alias `remove`) deletes an open roadmap item and its brief. Before this, the only way to remove an idea you no longer wanted was `done`, which recorded it as shipped.
17
+
18
+ ## [0.86.3] - 2026-11-09
19
+
20
+ **dev-flow talks to you in outcomes, not internals.**
21
+
22
+ ### Changed
23
+ - **Chat reports are shorter and plainer.** Messages to you often walked through module names, function names and code paths you didn't need. The always-on rules now tell the agent to lead with what changed or is wrong and why it matters, in a few plain lines, and to name a file or function only when you have to act on it. The plan direction, Verified?, Release? and finish findings each got the same nudge. The full technical detail is still in plan.md, the commits and the diff, and the agent gives it in full when you ask.
24
+
7
25
  ## [0.86.2] - 2026-11-09
8
26
 
9
27
  **Stale stage chips in pi-web clear themselves after a dropped connection.**
package/docs/gates.md CHANGED
@@ -22,7 +22,7 @@ so it needs no `--confirmed`. The agent's own `flow` call never opens a dialog (
22
22
  | `release-done` | records the release (the stage stays `release`) | **no question — the Release? answer covered the publication**; verify approval; the version published is the one `release` **stamped** from the manifest it validated (a main checkout still behind cannot republish the previous version), and it must not be older than the newest matching tag **on origin** (tag lists come from `git ls-remote`, so an unfetched clone does not decide what exists; when an origin exists but cannot be asked (offline, no ssh agent) **both release gates refuse** rather than answering with local tags); with `versioning.file`: that tag exists, is reachable from the default branch **and is on origin** (a local-only tag is not a release); with `release.artifact`: the published-artifact check runs (`{version}`/`{tag}` placeholders — the line it prints names the version it verified; skip once with `--no-artifact-check`, operator-instructed only) · creates the forge release from the tag, its body **the `release.changelog` entry for that version** — the changelog is the source of truth, and the tag's annotation stands in only when the changelog has no entry for the version, else nothing (and it says why — a body that is really a shell error is dropped, never shipped) — `gh` for GitHub, `glab` for GitLab) and then **proves the release exists**: it asks the forge (`gh release view <tag>` / `glab release view <tag>`) and refuses when nothing is there, because #51, #60 and #63 were three ways of ending `release recorded as complete` with nothing published — and when the changelog was the body it **reads the stored body back** and refuses a mismatch, so the release page and the changelog cannot drift (#97; normalized before comparing, skipped with a printed note on another forge). Skipping is deliberate and loud — `--no-release-create`, `release.releases = false` or `forge = self` each print that no forge release was created, and the view check is skipped for them; **with a `merge` policy** it also proves the merge that shipped matches it — branch ancestry plus what the forge says (`gh pr view` / `glab api`), so a squash under `merge = merge` (or a merge commit under `merge = squash`) refuses the release record, while a shape it cannot see prints an advisory instead (#97's split: an invisible topology never blocks a legal release); when the release went out on a stale build the operator acknowledged at the release gate, it prints that acknowledgement in place of the after-the-fact version-skew warning, and that warning prints the session vs disk version pair plus the duplicate-copy note when a second copy is registered (#117) |
23
23
  | `finish [--yolo] [--no-reflect] [--note=<text>] [slug]` | release → done — **records an unrecorded release first** (published but `release-done` never ran: finish runs its proofs itself — that gate asks nothing, so it is not a separate step; its refusal is finish's) — **then the closing reflection**: while no reflection is recorded for the flow, finish starts the reflect worker before it touches anything and stops for the operator's fold/drop (or Finish? when nothing was found); a flow with **no friction** (no gate refusal, no guard block, no `--note`) skips the worker unless the playbook sets `reflect = always`; the re-run with `--confirmed` does the cleanup. `--no-reflect --confirmed` skips it on the operator's explicit word (yolo never does); `--note=` hands the worker the operator's friction notes. Cleanup (removes worktree + branch, deletes `.dev-flow/<slug>/`, and deletes `origin/<branch>` **only** when its merged state is verified — ancestor of the default branch or a merged PR/MR via `gh`/`glab`; unverifiable branches stay with a note) | a release is recorded (`release-done` ran), the main checkout is clean **and** pushed to `origin/<default>`, and the worktree has no uncommitted changes (the refusal lists the paths, not just the count — gh#131); when the clean checkout trails `origin/<default>` the gate **fast-forwards local main** as it closes out (never a merge — anything that cannot fast-forward prints the operator's exact `git pull --ff-only` command); **one question** (Finish? — mentions unmerged-looking commits with the playbook's `merge` policy in mind, and warns when the forge release create failed at `release-done` and no retry succeeded) — or `--confirmed`; under `merge = merge`, commits that never reached the default branch are a **policy violation**: `yolo` does not answer it, only your explicit answer does; to abandon an unreleased feature use `abort` |
24
24
  | `reflect ["<note>"|list|tidy|move <n> --playbook|--code|done <n> ["<what>"]]` | — | `reflect "<note>"` queues a suggestion in **this project's** `reflections.md` (never gates; gate flags such as `--confirmed` are ignored, they never become part of the note). `--playbook` (alias `--docs`) files it under `## playbook` — the fix lives only in `project.md`, a docs flow implements it; `--code` files it under `## code` — the fix touches project code, a patch flow implements it. `--plugin` **never writes**: dev-flow feedback is filed upstream, so it prints the recipe — `gh issue list --repo <dev-flow repo> --state all --search …` first, then `gh issue create` with a body ending `— reflection from <slug> <date>` (in the dev-flow repo itself plugin is code → `## code`). With no flag the wording guesses (plugin-shaped → the recipe; otherwise `## playbook`) and the echo prints why. `reflect list` numbers the open items with their section; `reflect move <n> --playbook|--code` re-files one; `reflect done <n> ["<what>"]` checks a fixed one off (`— fixed: <date> <slug> — <what>`) so doctor stops re-reporting it; a legacy `## plugin` row is flagged by list and doctor (file it upstream, check it off `— filed: gh#NNN`). `reflect tidy` drops the closed (`- [x]`) items — the preamble and open items stay verbatim and a `## section` heading left empty goes with its items. **Nudges are timed, not constant**: `⚑ fix the open reflections now?` prints when an item recurred this session, is ≥ 14 days old, ≥ 3 playbook items wait, or a code item waits while between flows — at finish, in an unbound session and in doctor, never mid-feature; `↻ N closed reflection(s)` prints at ≥ 5 closed, closed ≥ open (≥ 3), or a closed item ≥ 30 days old. Bare `reflect` prints the **session-reflection protocol** (from the `/flow reflect` bar it additionally wakes the model): bound to a flow, delegate the review to `flow_stage` op `reflect`; unbound, review inline; re-check every open item against the playbook and **newer dev-flow versions** (`npm view pi-dev-flow version`; the operator performs updates); show the operator a numbered list with a fold/drop recommendation per finding and stop; fold docs/code → `reflect --playbook|--code`, fold plugin → the upstream issue, drop → nothing recorded |
25
- | `roadmap [add "<feature>" [--slug=<slug>] [--brief=<notes>\|--brief-file=<path>] \| pick <n> <slug> \| done <n> \| tidy]` | — | manages `.dev-flow/roadmap.md`, the gitignored backlog of future features (`- [ ]` checklist): bare prints the numbered open items, `add` appends one (`--slug=` stamps it like pick, `--brief=`/`--brief-file=` keeps notes under it as ` > ` lines, and a bound session records `— split from <slug>` — the spin-off route for a new feature surfaced mid-flow), `pick <n> <slug>` stamps open item n with `(slug)` so `flow start <slug>` can take it (start seeds `plan/plan.md` with the item and its brief) — **`finish` checks the stamped item off when that feature ships**; `done <n>` checks off by hand (items shipped outside a flow), `tidy` drops the checked lines. Never gates; the open count is surfaced in `status` and session context |
25
+ | `roadmap [add "<feature>" [--slug=<slug>] [--brief=<notes>\|--brief-file=<path>] \| pick <n> <slug> \| done <n> \| drop <n> \| tidy]` | — | manages `.dev-flow/roadmap.md`, the gitignored backlog of future features (`- [ ]` checklist): bare prints the numbered open items, `add` appends one (`--slug=` stamps it like pick, `--brief=`/`--brief-file=` keeps notes under it as ` > ` lines, and a bound session records `— split from <slug>` — the spin-off route for a new feature surfaced mid-flow), `pick <n> <slug>` stamps open item n with `(slug)` so `flow start <slug>` can take it (start seeds `plan/plan.md` with the item and its brief) — **`finish` checks the stamped item off when that feature ships**; `done <n>` checks off by hand (items shipped outside a flow), `drop <n>` (alias `remove`) deletes an open item and its brief that nobody wants any more — `done` would record it as shipped — `tidy` drops the checked lines. Never gates; the open count is surfaced in `status` and session context |
26
26
  | `doctor ["<issue note>"]` | — | read-only findings: playbook drift, dead commands/scripts, untracked playbook, ghost feature dirs, orphan worktrees/branches — the state of an **aborted** feature is never a finding (its worktree cleanup is by design — gh#138) — **plus a review of every open reflection, each routed to the flow that should fix it** (playbook item → docs flow; plugin item → upstream issue, or a patch/normal flow inside the dev-flow repo) — every item is labelled from the `## section` it is filed under (the file is the record, so the table cannot disagree with it) and items sitting outside both sections are named rather than silently bucketed. It writes nothing and asks nothing, safe for agents and CI at any stage; the agent investigates, you confirm, the routed flow implements. `doctor "<note>"` prints an investigation brief and a fix route for a fresh observation, including the section it would be filed under and why |
27
27
  | `status [slug]` / `abort [slug]` | — | — |
28
28
  | `help` (`--help`, `-h`) | — | — (prints the gate help — answerable in any repo, at any stage, with no `.dev-flow/`) |
package/docs/playbook.md CHANGED
@@ -296,8 +296,9 @@ recorded / main-state / unmerged / reflections at 🏁.
296
296
 
297
297
  **The checkpoint** closes exactly one message per stage (the operator's verb stays a plain-chat word
298
298
  — a structured-question tool is not chat). Event title, then the labels **`Done:`** and
299
- **`Next steps:`** standing alone on their own lines. `Done:` names the review surface — paths, SHAs,
300
- counts, not vibes. `Next steps:` lists the operator's verbs in italics (the recommended one
299
+ **`Next steps:`** standing alone on their own lines. `Done:` says what now works, in plain words and
300
+ counts, not vibes; a path or SHA only when the operator needs it. Internals (modules, code paths)
301
+ stay out of chat unless asked. `Next steps:` lists the operator's verbs in italics (the recommended one
301
302
  ***bold italic***, and no line needs a "(recommended)" tag when the styling carries it) and **never
302
303
  gate commands** (the agent runs those): recommended first, then alternatives, then *yolo* last with
303
304
  what it pre-confirms, then the plain closing line "or say what to do differently". Example:
@@ -139,6 +139,21 @@ export default function devFlow(pi: ExtensionAPI) {
139
139
  };
140
140
  };
141
141
 
142
+ /** A flow_stage worker: registered in this module's set, or — for a worker pi-web hosts, whose extension
143
+ * instance never saw the registration — stamped with pi-web's subagent entry. */
144
+ const isWorkerSession = (ctx: ExtensionContext): boolean => {
145
+ try {
146
+ if (workerSessions.has(ctx.sessionManager.getSessionId())) return true;
147
+ // SAFETY: narrow structural view of the SessionEntry union; only the custom entry's type is read
148
+ return (ctx.sessionManager?.getBranch() ?? []).some((e) => {
149
+ const ce = e as unknown as { type: string; customType?: string };
150
+ return ce.type === "custom" && ce.customType === PIWEB_SUBAGENT.meta;
151
+ });
152
+ } catch {
153
+ return false;
154
+ }
155
+ };
156
+
142
157
  /** Restore this session's binding from its branch history (survives resume/fork). */
143
158
  const rebuildSession = (ctx: ExtensionContext, root: string) => {
144
159
  let slug: string | null = null;
@@ -221,6 +236,8 @@ export default function devFlow(pi: ExtensionAPI) {
221
236
  // facts, the stage line and the question waiting on them, never a command to type
222
237
  // a refusal (not a question for the operator) is friction the closing reflection should look at
223
238
  if (res.isError && !res.text.startsWith(NEEDS_OPERATOR) && initiated(root)) noteFriction(root, sessionKey(ctx));
239
+ // a start that bound a feature takes over the refusals this session hit before it existed
240
+ else if (!res.isError && params.args[0] === "start" && initiated(root)) noteFriction(root, sessionKey(ctx), 0);
224
241
  const { agent, view } = await presentRun(params.args, root, sessionKey(ctx), res);
225
242
  return { content: [{ type: "text", text: agent }], details: { view }, isError: res.isError };
226
243
  },
@@ -761,11 +778,7 @@ export default function devFlow(pi: ExtensionAPI) {
761
778
  const commandAskCorrection = (event: TurnEndEvent, ctx: ExtensionContext, root: string): TurnEndEventResult | undefined => {
762
779
  const e = event as { outcome?: string; toolResults?: unknown[]; message?: { role?: string; content?: unknown }; entries?: unknown[] };
763
780
  if (!initiated(root) || e.outcome !== "completed" || (e.toolResults?.length ?? 0) > 0 || e.message?.role !== "assistant") return undefined;
764
- try {
765
- if (workerSessions.has(ctx.sessionManager.getSessionId())) return undefined;
766
- } catch {
767
- /* not a worker */
768
- }
781
+ if (isWorkerSession(ctx)) return undefined;
769
782
  const parts = Array.isArray(e.message.content) ? (e.message.content as { type?: string; text?: string }[]) : [];
770
783
  const text = parts.filter((p) => p.type === "text" && typeof p.text === "string").map((p) => p.text).join("\n");
771
784
  const hits = operatorCommandAsks(text);
@@ -790,11 +803,7 @@ export default function devFlow(pi: ExtensionAPI) {
790
803
  return undefined;
791
804
  }
792
805
  if (!initiated(root) || !boundFeature(root, key)) return undefined;
793
- try {
794
- if (workerSessions.has(ctx.sessionManager.getSessionId())) return undefined;
795
- } catch {
796
- /* not a worker */
797
- }
806
+ if (isWorkerSession(ctx)) return undefined;
798
807
  const streak = (hollowStreak.get(key) ?? 0) + 1;
799
808
  hollowStreak.set(key, streak);
800
809
  const resume = streak === 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.86.2",
3
+ "version": "0.87.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": [
@@ -30,11 +30,16 @@ criteria hold. Call it with an args array — `["start", "dark-mode"]`,
30
30
  - **Stage reports** — open every report with the **stage line the gate
31
31
  returned** (`stage line for your report`), pasted as is — the gate builds it
32
32
  from state. A checkpoint message then has an event title and, on their own
33
- lines, **`Done:`** (paths, SHAs, counts) and **`Next steps:`** — the
34
- operator's options as italic verbs, the recommended one ***bold italic***
33
+ lines, **`Done:`** (outcomes; a path or SHA only when useful) and
34
+ **`Next steps:`** — the operator's options as italic verbs, the recommended one ***bold italic***
35
35
  first, *yolo* last with what it pre-confirms, then the line
36
36
  "or say what to do differently". Plain markdown, never fenced, never a gate
37
37
  command.
38
+ - **Talk outcomes, not internals.** Chat is for the operator: what changed or
39
+ is wrong, why it matters, in plain words and a few lines. Name a file or
40
+ function only when they must act on it — no code-path walkthroughs or
41
+ internal identifiers. Depth lives in plan.md, commits and the diff; give it
42
+ in full when asked.
38
43
  - **yolo** at a checkpoint → that gate with `--yolo --confirmed`; run the
39
44
  remaining gates back to back without asking, honoring guidance attached to
40
45
  the word ("yolo, patch bump", "yolo, no tag" → `--no-version`). Checks,
@@ -18,7 +18,8 @@ unbinds the session — so anything that needs them runs first.
18
18
  - Worker failed → nothing is removed: re-run, or review inline (bare `flow
19
19
  reflect` prints the protocol). Only the operator's explicit word skips
20
20
  it: `flow finish --no-reflect --confirmed` — yolo never does.
21
- 2. **Findings → ask fold or drop** per item, with your recommendation (`fold
21
+ 2. **Findings → ask fold or drop** per item — one plain line each — with
22
+ your recommendation (`fold
22
23
  1,3 drop 2` is a fine answer), and stop. That answer **is** Finish?.
23
24
  3. **Apply it**: fold docs → `flow reflect --playbook "<note>"`; fold code →
24
25
  `flow reflect --code "<note>"`; fold plugin → `flow reflect --plugin
@@ -31,7 +31,9 @@ note). Other sessions' worktrees are theirs.
31
31
  RAM/disk: ask, then re-run with `--port=<n>` or `--replace`.
32
32
  - The health probe retries every 2s up to `healthWait` (default 30s); a
33
33
  service that needs a moment is not a broken deploy.
34
- 2. Look at the change yourself, **keep the app running**, ask **Verified?**.
34
+ 2. Look at the change yourself, **keep the app running**, ask **Verified?**
35
+ — say what changed for the user and how to see it, not which modules
36
+ changed.
35
37
  Report opening: **🔨 implement · `<slug>`** (the gate's stage line).
36
38
  3. Answer → `flow verify --confirmed` (yolo → `--yolo --confirmed`). If the
37
39
  default branch moved since the review deploy it refuses: run `flow verify`
@@ -5,9 +5,10 @@
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 — findings, shape
9
- of the fix, open unknowns, the mode you propose and why — and ask your
10
- questions. Draft only after the direction is confirmed.
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.
11
12
  3. **Write `.dev-flow/<slug>/plan/plan.md`** — problem, approach, files to
12
13
  touch, test strategy, risks. Reviewable, not exhaustive.
13
14
  - Create it as soon as the direction is confirmed and keep it current: chat
@@ -28,8 +28,8 @@ and settle the scheme with the operator; never invent one.
28
28
  changelog this branch never touched. `--no-fold-check` only on the
29
29
  operator's word.
30
30
  4. `flow check` — the prep made the earlier checks stale.
31
- 5. **Ask Release? and stop.** Show what the PR contains, the version and the
32
- changelog entry. Report opening: **🔍 pre-release · `<slug>`** (the gate's
31
+ 5. **Ask Release? and stop.** Say in a few lines what the PR delivers (the
32
+ changelog entry usually is that), plus the version. Report opening: **🔍 pre-release · `<slug>`** (the gate's
33
33
  stage line; the version field reads `pending` until decided — never
34
34
  invent a bump or a no-version decision). Answer → `flow release
35
35
  --confirmed`.
@@ -51,4 +51,5 @@ never gating.
51
51
  from the brief. A hand-made `.dev-flow/<slug>/plan/` is a ghost; `flow start
52
52
  <slug> --confirmed` adopts it.
53
53
  - Shipped outside a flow: `flow roadmap done <n>`; `flow roadmap tidy` drops
54
- checked lines.
54
+ checked lines. Not wanted any more (never built): `flow roadmap drop <n>` —
55
+ `done` would claim it shipped.
package/src/core.ts CHANGED
@@ -51,7 +51,7 @@ export interface FlowState {
51
51
  verifiedHead?: string; // HEAD the operator's Verified? was given over — release names commits after it, so the word is not recorded as the verdict for a tree nobody looked at (#162)
52
52
  reflectedAt?: string; // a reflect worker reported for this flow — finish runs one first while this is unset (only --no-reflect --confirmed skips it)
53
53
  devPort?: number; // the port the operator chose for this flow's dev deploy when the default was held by another flow — finish stops it (devDown)
54
- friction?: number; // gate refusals and guard blocks this feature hit — finish skips the closing reflection at 0 (playbook reflect = on-friction)
54
+ friction?: number; // gate refusals, guard blocks and post-Verified? code changes this feature hit — finish skips the closing reflection at 0 (playbook reflect = on-friction)
55
55
  aborted?: string; // flow abort on a feature whose worktree exists: the state is a deliberate abandoned-feature record (gh#138) — the doctor's git-consistency sweep must never flag its hand-removed worktree as drift
56
56
  }
57
57
 
@@ -2083,6 +2083,23 @@ export function roadmapDone(text: string, n: number, stamp: string): string | nu
2083
2083
  return hit ? out.join("\n") : null;
2084
2084
  }
2085
2085
 
2086
+ /** Remove the nth open item (1-based, open items only) and its brief — an idea the operator no longer
2087
+ * wants, which `done` would record as shipped. Returns null when n is out of range. */
2088
+ export function roadmapDrop(text: string, n: number): { text: string; item: string } | null {
2089
+ let seen = 0;
2090
+ let item: string | null = null;
2091
+ let dropping = false;
2092
+ const out = text.split("\n").filter((l) => {
2093
+ if (isBriefLine(l)) return !dropping;
2094
+ dropping = false;
2095
+ if (!isOpenItem(l) || ++seen !== n) return true;
2096
+ item = l.trim().slice(6);
2097
+ dropping = true;
2098
+ return false;
2099
+ });
2100
+ return item === null ? null : { text: out.join("\n"), item };
2101
+ }
2102
+
2086
2103
  /** Check every open item stamped `(slug)` by a pick — flow finish closes the backlog item a picked feature ships.
2087
2104
  * shortcut: "(slug)" matches as substring — item prose literally containing "(fin)" closes when fin ships; only pick-minted stamps are meant to match. */
2088
2105
  export function roadmapDoneForSlug(text: string, slug: string, stamp: string): { text: string; count: number } {
package/src/present.ts CHANGED
@@ -205,15 +205,27 @@ export function agentText(text: string, v: GateView): string {
205
205
  return v.stageLine ? `${text}\n${AGENT_MARK}stage line for your report (paste as is): ${v.stageLine}` : text;
206
206
  }
207
207
 
208
+ /** Flags only dev-flow's gates take. A generic CLI flag (`docker compose up -d --no-deps`, `gh pr merge --merge`)
209
+ * in a report of what the agent ran is not a dev-flow command handed to the operator. */
210
+ const GATE_FLAGS = "confirmed|ui|patch|docs|yolo|replace|port|no-version|no-fold-check|no-marker-check|no-artifact-check|no-release-create|no-reflect|check-upstream|answers|answers-file|write-file|brief|brief-file|playbook|note";
211
+ const ASK_COMMAND_RE = new RegExp(`(?:^|[\\s\`'"(*_])/?flow (?:${FLOW_VERBS})\\b|(?:^|[\\s\`])--(?:${GATE_FLAGS})\\b|\\bflow_stage\\b|(?:^|[\\s\`])/flow\\b`);
212
+ /** An imperative addressed to the operator: the verb opens a clause (or follows please/then/just), or a "you can" form. */
213
+ const ASK_VERB_RE = /(?:^|[:;,.!?(—–]\s*|\b(?:please|then|just|now|simply|and)\s+)(?:run|type|enter|use|try|send|invoke)\b|\byou (?:can|could|may|should|need to|might)\b|\bplease\b/i;
214
+
208
215
  /** Sentences in an assistant message that hand the operator a dev-flow command to type. */
209
216
  export function operatorCommandAsks(message: string): string[] {
210
217
  const hits: string[] = [];
211
218
  // fenced code is command output being shown, not a request
212
219
  const prose = message.replace(/```[\s\S]*?```/g, "");
213
- for (const sentence of prose.split(/(?<=[.!?])\s+|\n+/)) {
214
- if (!commandish(sentence)) continue;
215
- // addressed to the operator: an imperative or a "you can / please" form around the command
216
- if (/\b(you (can|could|may|should|need to|might)|please|type|run|enter|use|try|send|invoke)\b/i.test(sentence) && !/\bI('ll| will| am going to| ran|'m running| run)\b/.test(sentence)) hits.push(sentence.trim());
220
+ // a clause is the unit: "`flow verify` holds — you can use the QA agent" names a command and asks something else
221
+ for (const sentence of prose.split(/(?<=[.!?])\s+|\n+|\s[—–]\s|;\s/)) {
222
+ if (!ASK_COMMAND_RE.test(sentence)) continue;
223
+ // a reflection's report row (`F1 | fold | plugin | …`) describes a past session, it asks nothing
224
+ if (/^\s*[FO]\d+\s*\|/.test(sentence)) continue;
225
+ // the verb is read outside inline code (`bun run build` is a command named, not "run" said to the operator),
226
+ // with list bullets and emphasis markers dropped so a bullet's first word still opens its clause
227
+ const words = sentence.replace(/`[^`]*`/g, " ").replace(/^[\s>*_#-]*(?:\d+[.)]\s*)?/, "").replace(/[*_]+/g, "");
228
+ if (ASK_VERB_RE.test(words) && !/\bI('ll| will| am going to| ran|'m running| run)\b/.test(words)) hits.push(sentence.trim());
217
229
  }
218
230
  return hits;
219
231
  }
@@ -236,7 +236,7 @@ export async function releaseTags(root: string): Promise<string[] | null> {
236
236
  }
237
237
 
238
238
  export const GATE_HELP =
239
- "help [--json] | init [--force|--draft|--write <text>|--write-file <path>|--answers key=value…|--answers-file <path>] [--confirmed] [--track] | reflect [<note>|list|tidy|move <n> --playbook|--code|done <n> [<what>]] | roadmap [add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui|--patch|--docs --confirmed] [--force] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | approve [--yolo] | verify [--yolo] [--port=<n>|--replace] | release [--yolo|--no-version|--no-fold-check|--no-marker-check] | release-done [--no-artifact-check|--no-release-create] | finish [--yolo] [--no-reflect] [--note=<text>] [slug] | abort [slug] | version [--check-upstream] — state gates take [slug] and --confirmed (the operator already answered in chat); without it the agent's call returns NEEDS-OPERATOR with the question to ask in chat (it never opens a dialog), and the /flow slash command asks in a dialog — verify without --confirmed rebases a branch that is behind the default branch and deploys for review; --port=<n> / --replace answer its Dev port? question when another flow holds the stack — --ui/--patch/--docs and --merge=<style> on start are operator-granted (--confirmed); start refuses until the playbook has a merge policy and writes the answer into project.md — --yolo (with --confirmed) answers that checkpoint and pre-confirms every later one; checks and guardrails stay — release --no-version ships merge + changelog only (no bump, tag or forge release); --no-fold-check skips the changelog fold line proofs on the operator's word; --no-marker-check lets a branch add conflict-marker-shaped lines on purpose — finish runs the closing reflection worker first (before removing anything) and stops for the operator's fold/drop; the re-run with --confirmed cleans up; --no-reflect --confirmed skips it on the operator's explicit word (yolo never does), --note= hands the worker the operator's friction notes — release names a session running an older dev-flow build than the disk ships and asks update (/reload) or proceed — recorded, never a block — reflect <note> queues a project suggestion in reflections.md (--playbook = docs-flow fix, --code = patch-flow fix); --plugin never writes — dev-flow feedback goes upstream and it prints the GitHub issue recipe; bare reflect prints the session-reflection protocol (bound: run flow_stage op reflect); list numbers open items, move <n> re-files one, done <n> checks a fixed one off, tidy drops closed ones — roadmap manages .dev-flow/roadmap.md: pick <n> <slug> (or add --slug=) stamps an item for flow start, which seeds the new plan from its brief; finish checks it off — a new feature asked for mid-flow is parked there, never as a hand-made .dev-flow/<slug>/; start <slug> --confirmed adopts such a ghost dir — doctor reviews structure, git consistency and open reflections (never writes); doctor <note> prints an investigation brief — version prints the build the disk ships and any other dev-flow copies in this process (--check-upstream asks the registry)";
239
+ "help [--json] | init [--force|--draft|--write <text>|--write-file <path>|--answers key=value…|--answers-file <path>] [--confirmed] [--track] | reflect [<note>|list|tidy|move <n> --playbook|--code|done <n> [<what>]] | roadmap [add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>|drop <n>|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui|--patch|--docs --confirmed] [--force] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | approve [--yolo] | verify [--yolo] [--port=<n>|--replace] | release [--yolo|--no-version|--no-fold-check|--no-marker-check] | release-done [--no-artifact-check|--no-release-create] | finish [--yolo] [--no-reflect] [--note=<text>] [slug] | abort [slug] | version [--check-upstream] — state gates take [slug] and --confirmed (the operator already answered in chat); without it the agent's call returns NEEDS-OPERATOR with the question to ask in chat (it never opens a dialog), and the /flow slash command asks in a dialog — verify without --confirmed rebases a branch that is behind the default branch and deploys for review; --port=<n> / --replace answer its Dev port? question when another flow holds the stack — --ui/--patch/--docs and --merge=<style> on start are operator-granted (--confirmed); start refuses until the playbook has a merge policy and writes the answer into project.md — --yolo (with --confirmed) answers that checkpoint and pre-confirms every later one; checks and guardrails stay — release --no-version ships merge + changelog only (no bump, tag or forge release); --no-fold-check skips the changelog fold line proofs on the operator's word; --no-marker-check lets a branch add conflict-marker-shaped lines on purpose — finish runs the closing reflection worker first (before removing anything) and stops for the operator's fold/drop; the re-run with --confirmed cleans up; --no-reflect --confirmed skips it on the operator's explicit word (yolo never does), --note= hands the worker the operator's friction notes — release names a session running an older dev-flow build than the disk ships and asks update (/reload) or proceed — recorded, never a block — reflect <note> queues a project suggestion in reflections.md (--playbook = docs-flow fix, --code = patch-flow fix); --plugin never writes — dev-flow feedback goes upstream and it prints the GitHub issue recipe; bare reflect prints the session-reflection protocol (bound: run flow_stage op reflect); list numbers open items, move <n> re-files one, done <n> checks a fixed one off, tidy drops closed ones — roadmap manages .dev-flow/roadmap.md: pick <n> <slug> (or add --slug=) stamps an item for flow start, which seeds the new plan from its brief; finish checks it off; drop <n> removes an item nobody wants any more (done would record it as shipped) — a new feature asked for mid-flow is parked there, never as a hand-made .dev-flow/<slug>/; start <slug> --confirmed adopts such a ghost dir — doctor reviews structure, git consistency and open reflections (never writes); doctor <note> prints an investigation brief — version prints the build the disk ships and any other dev-flow copies in this process (--check-upstream asks the registry)";
240
240
  export const featDir = (root: string, slug: string) => path.join(dfDir(root), slug);
241
241
  export const stateFile = (root: string, slug: string) => path.join(featDir(root, slug), "state.json");
242
242
  export const claimFile = (root: string, slug: string) => path.join(featDir(root, slug), "claim.json");
@@ -253,12 +253,23 @@ export function writeState(root: string, state: FlowState): void {
253
253
  atomicWrite(stateFile(root, state.slug), `${JSON.stringify(state, null, "\t")}\n`);
254
254
  }
255
255
 
256
- /** Count one refusal or guard block against the session's bound feature (best effort, never throws). */
257
- export function noteFriction(root: string, key: string): void {
256
+ /** Refusals a session hit before any feature was bound to it — a `flow start --ui` refused as operator-granted,
257
+ * then retried — belong to the feature that start creates next. */
258
+ const unboundFriction = new Map<string, number>();
259
+
260
+ /** Count one refusal or guard block against the session's bound feature (best effort, never throws).
261
+ * With nothing bound yet, the count waits for the feature the session starts next. */
262
+ export function noteFriction(root: string, key: string, by = 1): void {
258
263
  try {
259
264
  const st = boundFeature(root, key);
260
- if (!st) return;
261
- st.friction = (st.friction ?? 0) + 1;
265
+ if (!st) {
266
+ if (by) unboundFriction.set(key, (unboundFriction.get(key) ?? 0) + by);
267
+ return;
268
+ }
269
+ const total = by + (unboundFriction.get(key) ?? 0);
270
+ unboundFriction.delete(key);
271
+ if (!total) return;
272
+ st.friction = (st.friction ?? 0) + total;
262
273
  writeState(root, st);
263
274
  } catch {
264
275
  /* a counter must never fail the call it watches */
@@ -1,7 +1,7 @@
1
1
  /** dev-flow runtime — The gate runner and the gates that do not ship anything. Moved out of extensions/dev-flow.ts as is (exports added). */
2
2
  import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
3
  import path from "node:path";
4
- import { approveGate, applicableItems, appendRoadmapItem, checklistHash, claimBlocks, doneItemCount, detectForge, gateHelpJson, healthProbe, parseMergeStyle, investigationBrief, pluginVersion, reflectProtocol, reflectUnfiledCount, reflectionNudges, reflectionRoutes, listFiles, needsOperator, newState, nextHint, openChecklistItems, releaseGate, roadmapDone, roadmapOpenCount, roadmapBriefFor, roadmapPick, roadmapTidy, statusJson, subst, sq, featureTmpDir, foreignWorktreeLinks, validSlug, verifyGate, STAGE_EMOJI, type ReflectTarget, type Config, type FlowState } from "../core.ts";
4
+ import { approveGate, applicableItems, appendRoadmapItem, checklistHash, claimBlocks, doneItemCount, detectForge, gateHelpJson, healthProbe, parseMergeStyle, investigationBrief, pluginVersion, reflectProtocol, reflectUnfiledCount, reflectionNudges, reflectionRoutes, listFiles, needsOperator, newState, nextHint, openChecklistItems, releaseGate, roadmapDone, roadmapDrop, roadmapOpenCount, roadmapBriefFor, roadmapPick, roadmapTidy, statusJson, subst, sq, featureTmpDir, foreignWorktreeLinks, validSlug, verifyGate, STAGE_EMOJI, type ReflectTarget, type Config, type FlowState } from "../core.ts";
5
5
  import { applyAnswers, buildDraft, doctorFindings, ghostFeatureDirs, lineDiff, loadProject, mdDigest, parseAnswers, parseProjectMd } from "../projectmd.ts";
6
6
  import { linkedTag } from "../fold.ts";
7
7
  import { detectProject } from "../detect.ts";
@@ -558,13 +558,22 @@ export async function gateRoadmap(o: GateCtx): Promise<RunResult> {
558
558
  save(roadmapDone(text, idx, [new Date().toISOString().slice(0, 10), sess.slug].filter(Boolean).join(" "))!);
559
559
  return { text: `roadmap: item ${idx} marked done (${open - 1} open)` };
560
560
  }
561
+ case "drop":
562
+ case "remove":
563
+ case "delete": {
564
+ // not shipped, not wanted: gone from the backlog, so the done list never claims it was built
565
+ if (!validIdx) return { text: `drop: open item 1–${open} required — flow roadmap lists them`, isError: true };
566
+ const r = roadmapDrop(text, idx)!;
567
+ save(r.text);
568
+ return { text: `roadmap: item ${idx} dropped — "${r.item}" (${open - 1} open)` };
569
+ }
561
570
  case "tidy": {
562
571
  if (!done) return { text: `roadmap: nothing to tidy (${open} open, 0 done)` };
563
572
  save(roadmapTidy(text));
564
573
  return { text: `roadmap: dropped ${done} done item(s) — ${open} open` };
565
574
  }
566
575
  default:
567
- return { text: "usage: flow roadmap [list|add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>|tidy]", isError: true };
576
+ return { text: "usage: flow roadmap [list|add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>|drop <n>|tidy]", isError: true };
568
577
  }
569
578
  }
570
579
 
@@ -232,6 +232,7 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
232
232
  // #162: Verified? was answered over one tree; commits after it ship under that word unless someone says
233
233
  // so. A warning, never a refusal — doc-only moves after verify are normal; the operator decides.
234
234
  let postVerify = "";
235
+ let unverifiedChange = false;
235
236
  if (state!.verifiedHead) {
236
237
  // gh#180: upstream work merged in after the verdict was approved on its own branch — only the branch's
237
238
  // own commits are news to the operator; the merged-in ones are a count, not a list to wade through
@@ -245,6 +246,12 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
245
246
  const prepFiles = new Set([cfg.versioning.file, cfg.release.changelog, cfg.versioning.file === "package.json" ? "package-lock.json" : ""].filter(Boolean) as string[]);
246
247
  const touched = state!.releaseOnly && commits.length ? await sh(`git diff --name-only ${sq(state!.verifiedHead)} HEAD`, wtCwd) : null;
247
248
  const prepOnly = !!touched?.ok && touched.out.split("\n").filter((l) => l.trim()).every((f) => prepFiles.has(f.trim()));
249
+ // the branch's own commits after the verdict that touch more than the release prep (bump + changelog):
250
+ // changed code shipping under an earlier word is friction the closing reflection should look at
251
+ if (commits.length && !prepOnly) {
252
+ const files = await sh(`git log --name-only --format= --no-merges ${sq(state!.verifiedHead)}..HEAD${upstream ? ` --not ${sq(upstream)}` : ""}`, wtCwd);
253
+ unverifiedChange = files.ok && files.out.split("\n").some((f) => f.trim() && !prepFiles.has(f.trim()));
254
+ }
248
255
  if (commits.length && !prepOnly)
249
256
  postVerify = `${commits.length} commit(s) landed after the operator's Verified? (given over ${state!.verifiedHead.slice(0, 7)}): ${commits.slice(0, 6).join(" | ")}${commits.length > 6 ? ` …(${commits.length - 6} more)` : ""}${mergedIn ? ` (+${mergedIn} merged in from ${upstream}, not listed)` : ""} — the verify verdict does not cover them: if behaviour changed, have the operator check the current build before Release?, and either way say in the PR body which commit the verdict was given over`;
250
257
  }
@@ -274,6 +281,7 @@ export async function gateRelease(o: GateCtx): Promise<RunResult> {
274
281
  audit = " (confirmed in dialog)";
275
282
  }
276
283
  if (noVersion) state!.noVersion = true;
284
+ if (unverifiedChange) state!.friction = (state!.friction ?? 0) + 1;
277
285
  state!.confirmations = { ...state!.confirmations, "pre-release": { hash: checklistHash(items), at: now() } };
278
286
  state!.approvals["pre-release"] = now();
279
287
  state!.stage = "release";
@@ -530,7 +538,8 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
530
538
  // --no-reflect skips it; yolo never does (it answers checkpoints, it does not waive the review).
531
539
  const skipReflect = flag("no-reflect");
532
540
  if (skipReflect && !flag("confirmed")) return { text: "--no-reflect is the operator's word — ask them whether to skip the closing reflection, then re-run with --no-reflect --confirmed", isError: true };
533
- // a flow that never hit a refusal or a guard block, with no friction note from the operator, has nothing
541
+ // a flow that never hit a refusal, a guard block or a change shipped after Verified?, with no friction note
542
+ // from the operator, has nothing
534
543
  // for the reflection worker to find — skip the worker run unless the playbook says reflect = always
535
544
  const note = flagValue(o.rest, "note") ?? "";
536
545
  const quiet = !state!.reflectedAt && !skipReflect && cfg.release.reflect !== "always" && !(state!.friction ?? 0) && !note.trim();
@@ -538,7 +547,7 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
538
547
  state!.reflectedAt = now();
539
548
  writeState(root, state!);
540
549
  }
541
- const quietNote = quiet ? " closing reflection skipped: no refusals or guard blocks this flow (playbook reflect = always runs it anyway)." : "";
550
+ const quietNote = quiet ? " closing reflection skipped: no refusals, guard blocks or unverified changes this flow (playbook reflect = always runs it anyway)." : "";
542
551
  if (!state!.reflectedAt && !skipReflect) {
543
552
  const skipHint = "or — only on the operator's explicit word — flow finish --no-reflect --confirmed";
544
553
  if (!o.hooks.reflect) return { text: `finish: no reflection recorded for ${state!.slug} and no reflect worker available here — run flow_stage(op: "reflect") first, ${skipHint}`, isError: true };