pi-dev-flow 0.90.0 → 0.91.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.
@@ -0,0 +1,73 @@
1
+ # Reflections: the agent's notes to you
2
+
3
+ When something costs the agent a step, it writes the problem down instead of quietly working
4
+ around it. Examples: a playbook command that no longer exists, a guard that blocked the wrong thing,
5
+ or a gate that forced a detour. That is how your playbook stays in sync with your project.
6
+
7
+ Reflections are advisory. They never block a gate, and nothing is fixed without your word.
8
+
9
+ ## Where notes go
10
+
11
+ `.dev-flow/reflections.md` is your project's queue. It has two sections:
12
+
13
+ | Section | The fix lives in | Fixed by |
14
+ |---|---|---|
15
+ | `## playbook` | `.dev-flow/project.md` | a docs flow |
16
+ | `## code` | your project's code | a patch flow |
17
+
18
+ **Feedback about dev-flow itself never goes into your project.** It becomes a GitHub issue on the
19
+ dev-flow repo, filed only when you say so.
20
+
21
+ | Command | Does |
22
+ |---|---|
23
+ | `flow reflect --playbook "<note>"` | adds a playbook note |
24
+ | `flow reflect --code "<note>"` | adds a code note |
25
+ | `flow reflect --plugin "<note>"` | prints how to file a dev-flow issue (search first, then `gh issue create`); writes nothing |
26
+ | `flow reflect "<note>"` | guesses the section from the wording and says why |
27
+ | `flow reflect list` | numbers the open notes |
28
+ | `flow reflect move <n> --code` | moves a note to the other section |
29
+ | `flow reflect done <n> "<what>"` | checks a note off as fixed |
30
+ | `flow reflect tidy` | removes the checked-off notes |
31
+
32
+ `flow status` and `flow doctor` show how many notes are open.
33
+
34
+ ## The closing review at finish
35
+
36
+ Before `flow finish` removes anything, a fresh read-only reviewer reads the whole session: the main
37
+ transcript and every worker's. It checks the findings against the open notes and the upstream
38
+ issues, then gives you a numbered list. Each finding is marked docs, code or plugin, with a
39
+ suggestion to **fold** (keep) or **drop** it.
40
+
41
+ You answer per item, for example `fold 1,3 drop 2`. Folding records a note, or files the issue for a
42
+ plugin finding. Dropping records nothing.
43
+
44
+ The review is skipped when the flow ran into no friction: no gate refusal, no guard block, no code change
45
+ after Verified?, and no `--note`. Set `reflect = always` in the playbook's `## release` section to run it every time. Only
46
+ your explicit `--no-reflect` skips it; *yolo* doesn't.
47
+
48
+ ## Nudges
49
+
50
+ The agent suggests working through the notes only at good moments: at finish, between flows, or in
51
+ `flow doctor`, and never in the middle of a feature.
52
+
53
+ - **"Fix the open reflections now?"** appears when a note came up again this session, a note is 14
54
+ days old, three playbook notes could share one docs flow, or a code note is waiting while you're
55
+ between flows.
56
+ - **"Tidy?"** appears once 5 notes are closed, closed notes outnumber open ones, or a closed note is
57
+ a month old.
58
+
59
+ To fix them, ask the agent to go through them, usually with `flow doctor`. It sends each note to the
60
+ flow that should fix it: playbook notes to a docs flow, code notes to a patch flow.
61
+
62
+ ## GitHub issues alongside
63
+
64
+ If the repo has a GitHub remote, `flow doctor` and `flow reflect list` also show open GitHub issues
65
+ next to your notes:
66
+
67
+ - a note that an open issue already covers is marked `⟷ gh#120`;
68
+ - the other issues are listed below as upstream rows;
69
+ - a possible duplicate is flagged (`~ gh#NNN may duplicate`), never merged automatically.
70
+
71
+ This view is display-only. Issues are closed on GitHub and notes are checked off in the file. If
72
+ `gh` is missing or fails, you get one line saying so. Set `DEV_FLOW_NO_ISSUES=1` to turn the view
73
+ off.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.90.0",
3
+ "version": "0.91.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": [
@@ -27,7 +27,9 @@ note). Other sessions' worktrees are theirs.
27
27
  behind (a conflict aborts and hands it to you), runs build, the `dev`
28
28
  deploy and the health probe against what it deployed, and returns
29
29
  `NEEDS-OPERATOR Verified?`. It never opens a dialog.
30
- - Another flow holds the dev port → `NEEDS-OPERATOR Dev port?` with free
30
+ - A flow past its Verified? holding the dev port is replaced without a
31
+ question (the result says so). One still under review →
32
+ `NEEDS-OPERATOR Dev port?` with free
31
33
  RAM/disk: ask, stop, then re-run with `--port=<n>` or `--replace` on
32
34
  their answer. "wait" means wait; a later "proceed" about the feature is
33
35
  not a yes to replacing another flow's stack.
@@ -11,6 +11,16 @@ each step with the gate's stage line, **🚀 release · `<slug>`**; no `Done:` /
11
11
  1. **PR and merge.** Commit everything, push the feature branch, open the PR.
12
12
  - **Merge only once CI is green**: `gh pr checks <n> --watch` (or your
13
13
  forge's equivalent) first — CI runs jobs the host may not.
14
+ - **Waiting on CI is your job, inside the turn.** Nothing wakes you once
15
+ the turn ends, so never end it with "I'll keep watching" or a
16
+ *wait / hold* choice: keep re-running the watch until CI settles.
17
+ - **Runs stuck in `queued`** (no job started after ~15 min, while other
18
+ runs on the repo do start) are a stuck schedule, not a slow runner:
19
+ re-trigger them — `gh run cancel <id>` then `gh run rerun <id>`, or
20
+ push a merge of the default branch when it moved — and keep watching.
21
+ - Only a red CI you can't fix, or CI still stuck after a re-trigger, ends
22
+ the turn: report it plainly ("stopped: … — say *go* to resume") and
23
+ stop.
14
24
  - Merge in the **playbook's style**, PR number before the flag:
15
25
  `gh pr merge <n> --squash` under `merge = squash`, `--merge` under
16
26
  `merge = merge`. (`gh pr merge --merge main` reads `main` as the PR.)
@@ -30,9 +30,14 @@ knobs · merge-policy state.
30
30
 
31
31
  - Check `flow status` for an active feature first. Slug: lowercase words,
32
32
  dashes.
33
+ - **`--ui` is your call, not a grant**: pass it whenever the feature changes
34
+ screens (or the project's skills require mockups for the change). It only
35
+ adds the mockup gate, so don't ask. Turning it **off** is the operator's:
36
+ `flow start <slug> --no-ui --confirmed` at plan, after they say so, and
37
+ aborting a ui feature at plan asks the same.
33
38
  - **Ask every grant in one message**, then make one call with all of them:
34
- the mode (`normal` default, or `--patch` / `--docs`), `--ui` when screens
35
- change, and the merge policy if the playbook has none —
39
+ the mode (`normal` default, or `--patch` / `--docs`) and the merge policy if
40
+ the playbook has none —
36
41
  `flow start <slug> [--ui] [--patch|--docs] [--merge=<style>] --confirmed`.
37
42
  Never grant any of them yourself. When the operator's own request already
38
43
  grants one ("start a docs flow"), that is their word: pass `--confirmed` on
@@ -41,8 +46,8 @@ knobs · merge-policy state.
41
46
  - No merge policy → the gate refuses with `NEEDS-OPERATOR Merge policy?` and a
42
47
  suggestion read off the repo's history. Ask: squash, merge, rebase or any.
43
48
  The answer is written into `## release` once.
44
- - `--ui` after a plain start, still at plan: `flow start <slug> --ui
45
- --confirmed` from the feature's own session.
49
+ - `--ui` after a plain start, still at plan: `flow start <slug> --ui` from
50
+ the feature's own session — no abort, no question.
46
51
  - Start warns when this session runs an older dev-flow build than the
47
52
  checkout (`/reload` before trusting gate output) and lists playbook gaps.
48
53
 
package/src/present.ts CHANGED
@@ -207,7 +207,7 @@ export function agentText(text: string, v: GateView): string {
207
207
 
208
208
  /** Flags only dev-flow's gates take. A generic CLI flag (`docker compose up -d --no-deps`, `gh pr merge --merge`)
209
209
  * in a report of what the agent ran is not a dev-flow command handed to the operator. */
210
- const GATE_FLAGS = "version=|confirmed|ui|patch|docs|yolo|replace|port|no-version|no-fold-check|no-marker-check|no-artifact-check|no-release-create|no-reflect|check-upstream|answers|answers-file|write-file|brief|brief-file|playbook|note";
210
+ const GATE_FLAGS = "version=|confirmed|ui|no-ui|patch|docs|yolo|replace|port|no-version|no-fold-check|no-marker-check|no-artifact-check|no-release-create|no-reflect|check-upstream|answers|answers-file|write-file|brief|brief-file|playbook|note";
211
211
  const ASK_COMMAND_RE = new RegExp(`(?:^|[\\s\`'"(*_])/?flow (?:${FLOW_VERBS})\\b|(?:^|[\\s\`])--(?:${GATE_FLAGS})\\b|\\bflow_stage\\b|(?:^|[\\s\`])/flow\\b`);
212
212
  /** An imperative addressed to the operator: the verb opens a clause (or follows please/then/just), or a "you can" form. */
213
213
  const ASK_VERB_RE = /(?:^|[:;,.!?(—–]\s*|\b(?:please|then|just|now|simply|and)\s+)(?:run|type|enter|use|try|send|invoke)\b|\byou (?:can|could|may|should|need to|might)\b|\bplease\b/i;
@@ -236,7 +236,7 @@ export async function releaseTags(root: string): Promise<string[] | null> {
236
236
  }
237
237
 
238
238
  export const GATE_HELP =
239
- "help [--json] | init [--force|--draft|--write <text>|--write-file <path>|--answers key=value…|--answers-file <path>] [--confirmed] [--track] | reflect [<note>|list|tidy|move <n> --playbook|--code|done <n> [<what>]] | roadmap [add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>|drop <n>|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui|--patch|--docs --confirmed] [--force] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | approve [--yolo] | verify [--yolo] [--port=<n>|--replace] [--version=<v>|--no-version] | release [--yolo|--version=<v>|--no-version|--no-fold-check|--no-marker-check] | release-done [--no-artifact-check|--no-release-create] | finish [--yolo] [--no-reflect] [--note=<text>] [slug] | abort [slug] | version [--check-upstream] — state gates take [slug] and --confirmed (the operator already answered in chat); without it the agent's call returns NEEDS-OPERATOR with the question to ask in chat (it never opens a dialog), and the /flow slash command asks in a dialog — verify without --confirmed rebases a branch that is behind the default branch and deploys for review; --port=<n> / --replace answer its Dev port? question when another flow holds the stack — --ui/--patch/--docs and --merge=<style> on start are operator-granted (--confirmed); start refuses until the playbook has a merge policy and writes the answer into project.md — --yolo (with --confirmed) answers that checkpoint and pre-confirms every later one; checks and guardrails stay — verify --confirmed carries the operator's release call: --version=<v> (ship that version) or --no-version (merge unreleased), asked with Verified?; release takes the same flags when the call changed — release --no-version ships merge + changelog only (no bump, tag or forge release); --no-fold-check skips the changelog fold line proofs on the operator's word; --no-marker-check lets a branch add conflict-marker-shaped lines on purpose — finish runs the closing reflection worker first (before removing anything) and stops for the operator's fold/drop; the re-run with --confirmed cleans up; --no-reflect --confirmed skips it on the operator's explicit word (yolo never does), --note= hands the worker the operator's friction notes — release names a session running an older dev-flow build than the disk ships and asks update (/reload) or proceed — recorded, never a block — reflect <note> queues a project suggestion in reflections.md (--playbook = docs-flow fix, --code = patch-flow fix); --plugin never writes — dev-flow feedback goes upstream and it prints the GitHub issue recipe; bare reflect prints the session-reflection protocol (bound: run flow_stage op reflect); list numbers open items, move <n> re-files one, done <n> checks a fixed one off, tidy drops closed ones — roadmap manages .dev-flow/roadmap.md: pick <n> <slug> (or add --slug=) stamps an item for flow start, which seeds the new plan from its brief; finish checks it off; drop <n> removes an item nobody wants any more (done would record it as shipped) — a new feature asked for mid-flow is parked there, never as a hand-made .dev-flow/<slug>/; start <slug> --confirmed adopts such a ghost dir — doctor reviews structure, git consistency and open reflections (never writes); doctor <note> prints an investigation brief — version prints the build the disk ships and any other dev-flow copies in this process (--check-upstream asks the registry)";
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] [--no-ui|--patch|--docs --confirmed] [--force] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | approve [--yolo] | verify [--yolo] [--port=<n>|--replace] [--version=<v>|--no-version] | release [--yolo|--version=<v>|--no-version|--no-fold-check|--no-marker-check] | release-done [--no-artifact-check|--no-release-create] | finish [--yolo] [--no-reflect] [--note=<text>] [slug] | abort [slug] | version [--check-upstream] — state gates take [slug] and --confirmed (the operator already answered in chat); without it the agent's call returns NEEDS-OPERATOR with the question to ask in chat (it never opens a dialog), and the /flow slash command asks in a dialog — verify without --confirmed rebases a branch that is behind the default branch and deploys for review; --port=<n> / --replace answer its Dev port? question when another flow holds the stack — --ui on start is the agent's call whenever screens change (it only adds the mockup gate); --patch/--docs, --no-ui (clearing ui on a plan-stage feature) and --merge=<style> are operator-granted (--confirmed); start refuses until the playbook has a merge policy and writes the answer into project.md — --yolo (with --confirmed) answers that checkpoint and pre-confirms every later one; checks and guardrails stay — verify --confirmed carries the operator's release call: --version=<v> (ship that version) or --no-version (merge unreleased), asked with Verified?; release takes the same flags when the call changed — release --no-version ships merge + changelog only (no bump, tag or forge release); --no-fold-check skips the changelog fold line proofs on the operator's word; --no-marker-check lets a branch add conflict-marker-shaped lines on purpose — finish runs the closing reflection worker first (before removing anything) and stops for the operator's fold/drop; the re-run with --confirmed cleans up; --no-reflect --confirmed skips it on the operator's explicit word (yolo never does), --note= hands the worker the operator's friction notes — release names a session running an older dev-flow build than the disk ships and asks update (/reload) or proceed — recorded, never a block — reflect <note> queues a project suggestion in reflections.md (--playbook = docs-flow fix, --code = patch-flow fix); --plugin never writes — dev-flow feedback goes upstream and it prints the GitHub issue recipe; bare reflect prints the session-reflection protocol (bound: run flow_stage op reflect); list numbers open items, move <n> re-files one, done <n> checks a fixed one off, tidy drops closed ones — roadmap manages .dev-flow/roadmap.md: pick <n> <slug> (or add --slug=) stamps an item for flow start, which seeds the new plan from its brief; finish checks it off; drop <n> removes an item nobody wants any more (done would record it as shipped) — a new feature asked for mid-flow is parked there, never as a hand-made .dev-flow/<slug>/; start <slug> --confirmed adopts such a ghost dir — doctor reviews structure, git consistency and open reflections (never writes); doctor <note> prints an investigation brief — version prints the build the disk ships and any other dev-flow copies in this process (--check-upstream asks the registry)";
240
240
  export const featDir = (root: string, slug: string) => path.join(dfDir(root), slug);
241
241
  export const stateFile = (root: string, slug: string) => path.join(featDir(root, slug), "state.json");
242
242
  export const claimFile = (root: string, slug: string) => path.join(featDir(root, slug), "claim.json");
@@ -253,7 +253,7 @@ 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
- /** Refusals a session hit before any feature was bound to it — a `flow start --ui` refused as operator-granted,
256
+ /** Refusals a session hit before any feature was bound to it — a `flow start --patch` refused as operator-granted,
257
257
  * then retried — belong to the feature that start creates next. */
258
258
  const unboundFriction = new Map<string, number>();
259
259
 
@@ -108,6 +108,11 @@ export async function devSlotCheck(o: GateCtx, state: FlowState): Promise<RunRes
108
108
  if (!slot || slot.slug === state.slug) return { note: "" };
109
109
  if (flag("replace")) return { note: `dev: replaced ${slot.slug}'s deploy on ${portLabel(port)} (operator's answer)` };
110
110
  const other = readState(root, slot.slug);
111
+ // the holder's review is over — it is past Verified? (pre-release or release) and not re-asking it, or it is
112
+ // gone: nobody is looking at that deploy, so taking the port asks nobody (lettuce rail-avatar-size-28 asked
113
+ // replace-or-wait over a flow that had already merged)
114
+ if (!other || ((other.stage === "pre-release" || other.stage === "release") && other.pendingAsk !== "Verified?"))
115
+ return { note: `dev: replaced ${slot.slug}'s deploy on ${portLabel(port)} — ${other ? `it is at ${other.stage}, past its Verified?` : "that flow is gone"}, so nobody was reviewing it` };
111
116
  const taken = new Set(Object.keys(reg).map(Number).filter(Number.isFinite));
112
117
  const nextPort = port !== undefined ? await nextFreePort(port, taken) : null;
113
118
  const mem = memAvailable();
@@ -281,7 +281,7 @@ export const GRANT_AFTER =
281
281
 
282
282
  export async function gateStart(o: GateCtx): Promise<RunResult> {
283
283
  const { root, sess, cfg, rest, flag, slugArg } = o;
284
- if (!slugArg || !validSlug(slugArg)) return { text: "usage: flow start <slug> [--ui] [--patch|--docs] [--merge=squash|merge|rebase|any] (slug: lowercase, dashes); --ui/--patch/--docs are operator-granted — ask the operator in chat, then add --confirmed", isError: true };
284
+ if (!slugArg || !validSlug(slugArg)) return { text: "usage: flow start <slug> [--ui] [--patch|--docs] [--merge=squash|merge|rebase|any] (slug: lowercase, dashes); --patch/--docs (and --no-ui on an existing plan-stage feature) are operator-granted — ask the operator in chat, then add --confirmed; --ui is yours to pass whenever screens change", isError: true };
285
285
  // a ghost (plan/ but no state.json — typically a spin-off someone wrote by hand) is adopted, never a dead end:
286
286
  // "already exists, flow use it" sent the agent to use, which found no state, and doctor offered to delete it
287
287
  // gh#178: any feature dir without state.json is a ghost, not only one with a plan/ — a tmp/ or mockups
@@ -300,18 +300,25 @@ export async function gateStart(o: GateCtx): Promise<RunResult> {
300
300
  };
301
301
  }
302
302
  if (existsSync(featDir(root, slugArg)) && !ghost) {
303
- // --ui on the plan-stage feature this session drives: the operator asked for mockups after the start,
304
- // so turn the mockup gate on instead of refusing — a UI feature left at ui=false skips the mockup
305
- // proof at approve and every (ui) checklist item (lettuce rail-ui-fixes shipped 20 ungated mockups)
303
+ // --ui on the plan-stage feature this session drives: turn the mockup gate on — a UI feature left at
304
+ // ui=false skips the mockup proof at approve and every (ui) checklist item (lettuce rail-ui-fixes
305
+ // shipped 20 ungated mockups). Turning it ON only adds proof, so it is the agent's call; turning it
306
+ // OFF (--no-ui) removes a gate and stays operator-granted.
306
307
  const existing = readState(root, slugArg);
307
- if (flag("ui") && existing && sess.slug === slugArg) {
308
- if (!flag("confirmed")) return { text: `--ui is operator-granted — it adds a rendered-mockup requirement to the plan gate; ${GRANT_AFTER}`, isError: true };
309
- if (existing.ui) return { text: `feature ${slugArg} already has the ui flag` };
310
- if (existing.stage !== "plan") return { text: `feature ${slugArg} is at ${existing.stage} — the ui flag can be set only at plan (the mockup gate is approve's); render the screens anyway and say so in the verify report`, isError: true };
311
- writeState(root, { ...existing, ui: true });
312
- return { text: `ui flag set on existing feature ${slugArg} (plan stage): the approve gate now requires rendered mockups under plan/mockups/ (${cfg.mockupGlobs.join(", ")}), each embedded in plan.md, and the (ui) checklist items apply` };
308
+ if ((flag("ui") || flag("no-ui")) && existing && sess.slug === slugArg) {
309
+ if (flag("ui") && flag("no-ui")) return { text: "--ui and --no-ui are exclusive", isError: true };
310
+ const on = flag("ui");
311
+ if (!on && !flag("confirmed")) return { text: `--no-ui is operator-granted — it removes the plan gate's mockup requirement; ${GRANT_AFTER}`, isError: true };
312
+ if (existing.ui === on) return { text: `feature ${slugArg} already has the ui flag ${on ? "on" : "off"}` };
313
+ if (existing.stage !== "plan") return { text: `feature ${slugArg} is at ${existing.stage} — the ui flag can be changed only at plan (the mockup gate is approve's)${on ? "; render the screens anyway and say so in the verify report" : ""}`, isError: true };
314
+ writeState(root, { ...existing, ui: on });
315
+ return {
316
+ text: on
317
+ ? `ui flag set on existing feature ${slugArg} (plan stage): the approve gate now requires rendered mockups under plan/mockups/ (${cfg.mockupGlobs.join(", ")}), each embedded in plan.md, and the (ui) checklist items apply`
318
+ : `ui flag cleared on ${slugArg} (operator's word): approve no longer requires mockups`,
319
+ };
313
320
  }
314
- return { text: `feature ${slugArg} already exists — flow use ${slugArg} to resume it${existing?.stage === "plan" ? `; to add the mockup gate at plan, run flow start ${slugArg} --ui --confirmed from the session bound to it` : ""}`, isError: true };
321
+ return { text: `feature ${slugArg} already exists — flow use ${slugArg} to resume it${existing?.stage === "plan" ? `; to add the mockup gate at plan, run flow start ${slugArg} --ui from the session bound to it` : ""}`, isError: true };
315
322
  }
316
323
  // relaxed modes are operator-granted: --confirmed anchors a literal chat grant, same convention as the gate verbs
317
324
  if (flag("patch") && flag("docs")) return { text: "--patch and --docs are exclusive — ask the operator which mode they grant", isError: true };
@@ -320,8 +327,9 @@ export async function gateStart(o: GateCtx): Promise<RunResult> {
320
327
  // the operator answers mode, mockups and merge policy in a single message
321
328
  const alsoMerge = !cfg.release.merge && flagValue(rest, "merge") === null ? `\n${AGENT_MARK}the playbook also has no merge policy — put it in the same question (squash | merge | rebase | any) and pass --merge=<style> on the same re-run` : "";
322
329
  if (mode && !flag("confirmed")) return { text: `${mode} mode is operator-granted — ${GRANT_AFTER}${alsoMerge}`, isError: true };
323
- // --ui adds the rendered-mockup gate to plan: worth it only when screens change, and the operator says so
324
- if (flag("ui") && !flag("confirmed")) return { text: `--ui is operator-granted — it adds a rendered-mockup requirement to the plan gate, so use it only when the feature changes screens; ${GRANT_AFTER}${alsoMerge}`, isError: true };
330
+ // --ui adds the rendered-mockup gate to plan: stricter, never looser, so the agent turns it on itself
331
+ // whenever screens change — no operator grant (only turning it off is theirs)
332
+ if (flag("no-ui")) return { text: "--no-ui applies to an existing plan-stage feature — a new start is ui-off unless you pass --ui", isError: true };
325
333
  // branch discipline: features branch off the default branch — starting from a stale checkout poisons the base
326
334
  const curBr = await currentBranch(root);
327
335
  if (curBr !== cfg.defaultBranch && !flag("force")) return { text: `main checkout is on ${curBr}, not ${cfg.defaultBranch} — check out ${cfg.defaultBranch} first (git checkout ${cfg.defaultBranch} && git pull) or flow use an unfinished feature; --force to override`, isError: true };
@@ -350,7 +358,7 @@ export async function gateStart(o: GateCtx): Promise<RunResult> {
350
358
  text: needsOperator(
351
359
  `how should a merged PR land on ${cfg.defaultBranch}: squash, merge (a merge commit), rebase, or any (no policy)?${ev ? ` ${ev.note}${ev.recent ? ` Detected suggestion: ${ev.recent}.` : ""}` : ""} The answer is written into the playbook once.`,
352
360
  "Merge policy?",
353
- `ask the operator — in the same message as any mode or --ui grant you propose — then re-run once with everything: flow start ${slugArg} --merge=<style> [--ui] [--patch|--docs] --confirmed`,
361
+ `ask the operator — in the same message as any mode grant you propose — then re-run once with everything: flow start ${slugArg} --merge=<style> [--ui] [--patch|--docs] --confirmed`,
354
362
  ),
355
363
  isError: true,
356
364
  };
@@ -733,6 +741,12 @@ export async function gateAbort(o: GateCtx): Promise<RunResult> {
733
741
  // as a ghost the doctor flags (a plan/ whose state.json is gone). A written plan is the
734
742
  // operator's work too — it is not dropped without their word.
735
743
  const written = listFiles(path.join(featDir(root, target), "plan"));
744
+ // a ui feature aborted at plan and restarted plain sheds its mockup gate — turning ui off is the
745
+ // operator's call, so the abort is too
746
+ if (st.ui && !written.length && !flag("confirmed")) {
747
+ const ok = ui.hasUI && (await ui.confirm("Drop ui feature?", `Abort ${target}? It has the ui flag (mockup gate); a restart without --ui drops it.`));
748
+ if (!ok) return { text: needsOperator(`aborting ${target} drops its ui flag (the mockup gate) — turning ui off is the operator's call`, "Drop ui feature?", "ask the operator, then re-run with --confirmed"), isError: true };
749
+ }
736
750
  if (written.length && !flag("confirmed")) {
737
751
  const ok = ui.hasUI && (await ui.confirm("Drop plan?", `Abort ${target}? Its plan/ (${written.join(", ")}) is deleted for good.`));
738
752
  if (!ok) return { text: needsOperator(`aborting ${target} deletes its written plan (${written.join(", ")})`, "Drop plan?", "ask the operator, then re-run with --confirmed"), isError: true };
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * A. a gate asked for the operator's word (NEEDS-OPERATOR, or an "operator-granted" refusal) and the same
7
7
  * gate is re-run with --confirmed before any operator message arrived;
8
- * B. a feature started in this session gets a mode flag (--ui/--patch/--docs) granted with --confirmed
8
+ * B. a feature started in this session gets a loosening mode flag (--patch/--docs/--no-ui) granted with --confirmed
9
9
  * before any operator message arrived after the start.
10
10
  *
11
11
  * --confirmed is not the only answer a gate takes: `Dev port?` is answered with --replace or --port=<n>
@@ -38,7 +38,8 @@ export interface GrantLedger {
38
38
  export const newGrantLedger = (): GrantLedger => ({ asked: new Map(), started: new Map() });
39
39
 
40
40
  const ASKS_FOR_WORD = /operator-granted|operator's (?:explicit )?word|the operator must grant/;
41
- const MODE_FLAGS = ["--ui", "--patch", "--docs"];
41
+ /** Mode flags that loosen a gate — --ui only tightens one, so it is not here; --no-ui (dropping it) is. */
42
+ const MODE_FLAGS = ["--no-ui", "--patch", "--docs"];
42
43
  /** Flags that carry the operator's answer to the question a gate asked — `--confirmed`, and the
43
44
  * `Dev port?` answers (gh#203). */
44
45
  export function answerFlags(args: readonly string[]): string[] {