pi-dev-flow 0.90.0 → 0.90.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/playbook.md CHANGED
@@ -1,62 +1,69 @@
1
- # The playbook — `.dev-flow/project.md`
1
+ # The playbook: `.dev-flow/project.md`
2
2
 
3
- The operator-owned file that says how *your* project is tested, run, versioned and guarded. Written once per repo with `flow init`, edited by you.
3
+ Your playbook says how *your* project is tested, run, versioned and guarded. `flow init` writes it,
4
+ and after that it's yours to edit. The agent can't change the main copy. It can only edit the
5
+ playbook inside a docs or patch flow, so every change is reviewed like any other.
4
6
 
5
7
  ## Quickstart
6
8
 
7
- 1. `/flow init`. dev-flow reads the repo and prints what it found, then one numbered question per knob. Each question shows what was detected (`detected:`), the answer that keeps it (`accept: merge=squash`), and why it matters. Nothing is written yet.
8
- 2. Answer in chat. Saying "keep these" is enough for every question that has an `accept` line.
9
- 3. The agent applies all your answers in one call, `flow init --answers merge=squash versionFile=VERSION check.lint="npm run lint" …`. That shows a summary and a diff and writes nothing.
10
- 4. You confirm. The agent re-runs the same call with `--confirmed --track`, which validates and writes the playbook, then commits it.
11
- 5. Anything detection can't know goes in later through `flow init --write-file <path>` with the whole file: checklist items, standing guidance, guard rules. You can also run `flow init --answers key=value` for a single knob at any time.
9
+ 1. Run `/flow init`. dev-flow reads the repo, prints what it found, then asks one numbered question
10
+ per setting. Each question shows what was `detected:`, the answer that keeps it (`accept:`), and
11
+ `why:` it matters. Nothing is written yet.
12
+ 2. Answer in chat. "Keep these" answers every question that has an `accept` line.
13
+ 3. The agent applies your answers in one call (`flow init --answers merge=squash test="npm test" …`)
14
+ and shows you a summary and a diff.
15
+ 4. You confirm. The agent writes the playbook and commits it (`--confirmed --track`).
16
+ 5. Add anything detection can't know later: checklist items, guidance, guard rules. Edit the file
17
+ yourself or ask the agent.
18
+
19
+ In a TUI, a single dialog offers to accept everything detected. Decline it to go through the
20
+ questions in chat.
21
+
22
+ **What detection reads** (files and git only; it never runs your commands):
23
+ - language manifests, the package manager and its scripts;
24
+ - lint, typecheck and format scripts, Makefile / justfile / Taskfile targets;
25
+ - CI workflows and publish steps (npm, crates, container images);
26
+ - Dockerfile and compose files;
27
+ - `.env` files and `secrets/` folders, which become suggested guard rules;
28
+ - the version file, existing tags, the changelog, the merge style in your history;
29
+ - CLAUDE.md, AGENTS.md and CONTRIBUTING.md, named so their rules can be proposed but never copied
30
+ silently.
31
+
32
+ Anything detection can't find is asked about, never guessed.
33
+
34
+ **Typical playbooks**, to start small and grow:
12
35
 
13
- In a TUI, one dialog shows the summary with every detected value already accepted ("Accept the detected setup?"), followed by a commit offer. Decline it to answer the questions in chat first.
14
-
15
- **What detection reads** (deterministic, files and git only, never runs your commands):
16
- - the language manifest (package.json, Cargo.toml, go.mod, pyproject/requirements), the package manager and its scripts (`npm run build`, never `npm build`)
17
- - lint, typecheck and format scripts, ruff and mypy config → extra `flow-check` blocks
18
- - Makefile, justfile and Taskfile targets when no manifest decides
19
- - CI workflows (the commands they run, which your checks should match) and publish steps (npm, crates, container image) → a suggested `artifact` check
20
- - Dockerfile and compose files → suggested `preflight` and `dev`
21
- - `.env` and `secrets/` on disk → drafted `protect`/`forbid` guard rules; an `.env.example` → a reminder that `setup` must copy it
22
- - the version manifest, existing tags (the `versionTag` convention), the changelog, the merge style seen in history, monorepo workspaces
23
- - CLAUDE.md, AGENTS.md and CONTRIBUTING.md (named, so their rules can be proposed as guidance; never copied silently)
36
+ | Project | `## implement` | `## pre-release` / `## release` |
37
+ |---|---|---|
38
+ | npm library | `test`, `build`, lint/typecheck checks | `versionFile = package.json`, `artifact = npm view --prefer-online <name>@{version} version`, `merge = …` |
39
+ | Go / Rust CLI | `test`, `build`, vet/clippy checks | `versionFile = VERSION`, `merge = …` |
40
+ | web service | `setup` (install + copy `.env`), `test`, `run`, a `health` check, `(ui)` checklist items | `versionFile`, `merge = …` |
41
+ | Docker app | `dev = docker compose up -d --build`, a `health` check | `preflight = docker build .`, `artifact = docker buildx imagetools inspect <image>:{version}` |
24
42
 
25
- Anything detection can't find is left out and asked about, never invented. No health check, no version file, no merge style is ever guessed.
43
+ ## How the file is organized
26
44
 
27
- **Typical playbooks.** These are minimal; add to them as the project teaches you:
45
+ Sections follow the stages (`## global`, `## plan`, `## implement`, `## pre-release`, `## release`).
46
+ Inside each one, content has three tiers:
28
47
 
29
- | Project | `## implement` | `## pre-release` / `## release` |
30
- |---|---|---|
31
- | library (npm) | `test`, `build`, `flow-check lint` / `typecheck` | `versionFile = package.json`, `artifact = npm view --prefer-online <name>@{version} version`, `merge = …` |
32
- | CLI (go/rust) | `test`, `build`, `flow-check vet` / `clippy` | `versionFile = VERSION`, `releases = true`, `merge = …` |
33
- | web service | `setup` (install + copy `.env`), `test`, `run`, `flow-check health`, `(ui)` checklist items | `versionFile`, `merge = …` |
34
- | Docker app | `dev = docker compose up -d --build`, `flow-check health` | `preflight = docker build .`, `artifact = docker buildx imagetools inspect <image>:{version}` |
35
-
36
- The rest of this page is the reference.
37
-
38
- `.dev-flow/` ignores itself — its own `.dev-flow/.gitignore` is `*` with the single exception
39
- `!project.md`, so no state, plan or worktree path is ever tracked by accident. Tracking the playbook
40
- in a repo that ignores the folder is a deliberate one-off:
41
- `git add -f .dev-flow/project.md && DEV_FLOW_ALLOW_MAIN=1 git commit -m "track project.md"` — the
42
- env prefix is for dev-flow's `pre-commit` hook, which allows a main commit whose only change is the
43
- playbook.
44
-
45
- It is **committed to git**; you edit it (the agent is blocked from writing the main-checkout copy
46
- and may edit it only inside a docs/patch flow's worktree, or apply it through `flow init --write`
47
- on your word, which validates). Content is organized per stage
48
- (`## plan`, `## implement`, `## pre-release`, `## release`…) in **three tiers** — tier 1 splits into
49
- executable checks and hard safety rules:
50
-
51
- | Tier | Notation | Enforcement |
48
+ | Tier | Written as | What happens |
52
49
  |---|---|---|
53
- | 1 — executable | ` ```flow` (`key = value`) config blocks; ` ```flow-check <name>` command blocks | gates run every check, record pass/fail against a worktree fingerprint, a changed tree makes them stale — hard |
54
- | 1 — guard | ` ```flow-guard ` (`deny`/`confirm`/`protect`/`forbid`) rules in `## global` | enforced on every bash command and every edit/write path, at every stage — hard block or operator confirmation |
55
- | 1 — worker setup | ` ```flow-worker ` lines in `## global` (e.g. `export APP_TEST_PASSWORD="$(cat /path/to/.secrets/test-password)"`) | copied into every `flow_stage` worker's brief as a setup block to run before any project check, so a check that needs a variable or file the worktree lacks still runs there; a reviewer that could not run a check must say so (`checks not run:`) instead of passing |
56
- | 2 — checklist | `- [ ] item` lines (`- [ ] (ui) item` = only for `--ui` features; `- [ ] (versioned) item` = only when the flow ships a version — it stands down on `--no-version`; on a `--docs` flow the `## implement` items stand down, since nothing is built or deployed, except those tagged `- [ ] (docs) item`; an open count names its items and the section they sit under) | gate confirms cover them as a set (hashed: changing the items asks again); `(ui)` items never appear for non-UI features, `(versioned)` items never for an unversioned flow (a deploy proof of the tagged image, say) |
57
- | 3 — prose | any other text | injected to the agent when its stage begins — advisory |
50
+ | 1. checks | a ` ```flow ` block of `key = value` lines, and ` ```flow-check <name> ` command blocks | gates run them and record pass/fail. **Hard.** |
51
+ | 1. guard rules | a ` ```flow-guard ` block in `## global` | checked on every command and edit. **Hard.** |
52
+ | 1. worker setup | a ` ```flow-worker ` block in `## global` | runs first in every `flow_stage` worker (for example, exporting a test password) |
53
+ | 2. checklist | `- [ ] item` lines | you confirm them as a set at the gate |
54
+ | 3. prose | any other text | shown to the agent when the stage starts. Advisory. |
55
+
56
+ **Checklist tags:**
57
+ - `- [ ] (ui) …` applies only to `--ui` features.
58
+ - `- [ ] (versioned) …` applies only when the flow ships a version.
59
+ - `- [ ] (docs) …` is kept on a `--docs` flow. Other `## implement` items are skipped there, since a
60
+ docs flow builds nothing.
58
61
 
59
- Example `## implement` section:
62
+ If you change the items, you're asked again.
63
+
64
+ **Prose:** your `## implement` prose replaces dev-flow's built-in "senior discipline" guidance.
65
+
66
+ Example:
60
67
 
61
68
  ````markdown
62
69
  ## implement
@@ -73,246 +80,182 @@ node scripts/check-overflow.mjs
73
80
  Prefer feature flags for risky paths.
74
81
  ````
75
82
 
76
- `healthWait` (default 30) is the seconds the post-deploy probe may keep retrying, every 2s — a service
77
- whose readiness lags its container start needs a wait, not a poll loop hand-written into the playbook.
78
- `healthWait = 0` restores the single shot.
83
+ ## Implement settings
84
+
85
+ | Key | What it does |
86
+ |---|---|
87
+ | `setup` | runs once in a fresh worktree at `approve`, for example `cp .env.example .env && npm ci`. A failure fails the gate. |
88
+ | `test` | your test command |
89
+ | `build` | runs at `verify` |
90
+ | `run` | how the agent starts the app to try it. dev-flow never runs it itself. |
91
+ | `dev` | the dev deploy `verify` runs before asking you. It must start in the background and exit, like `docker compose up -d`. |
92
+ | `seedData` | runs before the health probe |
93
+ | `health` | the health probe. After a deploy, `verify` re-runs it and refuses if it fails. |
94
+ | `healthWait` | seconds the probe keeps retrying, every 2s (default 30; `0` = try once) |
95
+ | `servedBuild` | prints the commit the running app serves. `verify` checks it's this branch's HEAD. |
96
+
97
+ The health probe runs in the worktree, so it can compare the app's build stamp with
98
+ `git rev-parse HEAD`. Without a probe, `verify` says `health: none configured` and `flow doctor`
99
+ flags it.
79
100
 
80
- **Dev port and parallel flows.** Two flows on one machine share one dev stack unless you say otherwise:
101
+ ### Dev port and parallel flows
102
+
103
+ By default, two flows on one machine share one dev stack. To let them run side by side:
81
104
 
82
105
  ```flow
83
- port = 8090 # the default dev port — exported to dev/health/servedBuild as $DEV_FLOW_PORT
84
- parallelDev = yes # can two instances run side by side? (no = only replace or wait are offered)
85
- instanceMem = 2G # what one instance needs — checked against available RAM
86
- instanceDisk = 5G # …and against free disk
106
+ port = 8090 # default dev port, exported as $DEV_FLOW_PORT
107
+ parallelDev = yes # can two instances run side by side? (no = replace or wait only)
108
+ instanceMem = 2G # what one instance needs, checked against free RAM
109
+ instanceDisk = 5G # ...and against free disk
87
110
  dev = BFF_PORT=$DEV_FLOW_PORT COMPOSE_PROJECT_NAME=app$DEV_FLOW_SUFFIX docker compose up -d
88
111
  devDown = COMPOSE_PROJECT_NAME=app$DEV_FLOW_SUFFIX docker compose down
89
- servedBuild = curl -fsS http://127.0.0.1:$DEV_FLOW_PORT/version # must print the served commit
112
+ servedBuild = curl -fsS http://127.0.0.1:$DEV_FLOW_PORT/version
90
113
  ```
91
114
 
92
- `$DEV_FLOW_SUFFIX` is empty on the default port and `-<slug>` on any other, so a second instance gets its own
93
- compose project. The `dev ran (…)` and `dev deploy FAILED` lines print the command as written, followed by what
94
- it resolved to (`resolved: DEV_FLOW_PORT=8090, DEV_FLOW_SUFFIX="", compose project app`), so a record says
95
- which stack a deploy touched. `flow verify` records who deployed on which port in `.dev-flow/dev-ports.json`; when the
96
- port it would use belongs to another live flow it asks you first (see [concurrency](concurrency.md)).
97
- `flow finish` runs `devDown` for an instance on a non-default port. `servedBuild` turns "something answers"
98
- into "this branch answers": verify refuses when its output names no prefix of the worktree's HEAD.
115
+ `$DEV_FLOW_SUFFIX` is empty on the default port and `-<slug>` on any other, so a second instance gets
116
+ its own compose project. The deploy output shows what the variables resolved to.
117
+ `flow finish` runs `devDown` for an instance on a non-default port. See
118
+ [concurrency](concurrency.md#sharing-one-dev-stack).
119
+
120
+ ## Guard rules
99
121
 
100
- Your project's own safety rules are a `flow-guard` block in `## global` — the reason a project
101
- adopting dev-flow can delete its own guard extension:
122
+ Your project's own safety rules go in a `flow-guard` block in `## global`:
102
123
 
103
124
  ````markdown
104
125
  ## global
105
126
  ```flow-guard
106
- deny \bgit\b[^\n]*\bpush\b[^\n]*--force(?!\w) :: history stays linear — the playbook sets the merge style
107
127
  deny \bgit\b[^\n]*\bworktree\s+prune\b :: it prunes other sessions' worktrees
108
- confirm \bgit\b[^\n]*\bbranch\s+(?:-D\b|--delete\b) :: deletes a merged branch git cannot see as merged
128
+ confirm \bgit\b[^\n]*\bbranch\s+(?:-D\b|--delete\b) :: deletes a branch git can't see as merged
109
129
  confirm \bdocker\b[^\n]*\bcompose\b[^\n]*\brestart\b :: drops a permanent upstream connection
110
- protect docker/.env* :: gitignored live secrets — and any backup copied beside them
111
- forbid docker/secrets :: gitignored secret storage
130
+ protect docker/.env* :: live secrets, and any backup copied beside them
131
+ forbid docker/secrets :: secret storage
112
132
  ```
113
133
  ````
114
134
 
115
135
  | Verb | Applies to | What happens |
116
136
  |---|---|---|
117
- | `deny` | one segment of a bash command | hard block — no confirmation offered |
118
- | `confirm` | one segment of a bash command | asks the operator; **blocked when no UI is present** — a hidden confirmation is not a confirmation |
119
- | `protect` | an edit/write path | asks the operator, same no-UI rule |
120
- | `forbid` | an edit/write path | hard block |
121
-
122
- ` :: ` separates the matcher from the reason, so reasons are free text and show up verbatim when a
123
- rule fires. `deny`/`confirm` matchers are JS regex sources — an unparseable regex is a hard finding,
124
- so `flow init --write` refuses the file (an unknown verb is a warning). Anchor a matcher on the **verb**
125
- you mean, not on a flag that can appear anywhere after `git`: `\bgit\b[^\n]*--force` also refuses
126
- `git filter-branch --force` (a local rewrite) and `git show -f`, and a rule that blocks unrelated
127
- commands gets routed around. You do not need a rule for forced pushes at all — dev-flow confirms every
128
- `git push --force` / `-f` with the operator itself, and prints the one prefix that answers for it
129
- (`DEV_FLOW_ALLOW_REWRITE=1`). `protect`/`forbid` take a repo-relative path; a rule on a directory covers
130
- its subtree, including files that do not exist yet. A rule whose **last segment** globs
131
- (`protect docker/.env*`) covers the siblings in that directory whose name matches — the backup copied
132
- beside a secret is the same secret, and the commit that adds it never names the file, so no `deny` regex
133
- ever sees it. A glob anywhere else in the path warns at `flow init`: it names one literal file called
134
- `.env*` and guards nothing.
135
- The block belongs to `## global` — these rules are never stage-scoped, and one under a stage warns and
136
- applies nothing.
137
-
138
- Matching is per shell segment (the guard splits on `;`, `|`, `&&` and newlines, honouring `cd … &&` and
139
- `git -C`), and a segment whose head only reads (`grep`, `cat`, `ls`, `git log`, `jq`, …) is skipped — so
140
- `grep "git push --force" docs/` searches, it does not push. A read-only head that can still write
141
- (`find -delete`, `find -exec …`, `sort -o FILE`, `awk 'BEGIN{system(…)}'`) is judged like a writer —
142
- your `deny` rules do not have a back door through the read-only list.
143
-
144
- `## pre-release` prose is where rules like “follow semver: minor for user-facing features, patch
145
- otherwise; confirm the number before tagging” live — the agent sees them at stage entry, and
146
- `flow release` / `flow release-done` hard-check the manifest side (bumped past the last tag, then
147
- manifest↔tag agreement) and the changelog side (a heading for the version, an entry this branch
148
- prepared, and every entry that was pending before the release folded into it — see
149
- [gates.md](gates.md)).
150
- What an entry **is** stays the agent's stage convention, not a gate matter: the changelog records the
151
- net change of a branch, not its commit history — a feature that landed through several iteration
152
- commits is one entry telling the final state, and the fold proofs (which guard only lines already
153
- pending under `Unreleased`) never stand in the way of merging your own lines. Say it differently
154
- here if your project wants that (per-sprint grouping, issue numbers, a strict Keep-a-Changelog
155
- vocabulary).
156
-
157
- `## global` holds
158
- `defaultBranch`, `branchPattern`, `worktreeDir`, `mainHook`, `mockupGlobs`, `bashTimeout = inject`
159
- (default: the class timeout is armed silently on every shell call) `| require` (refuse calls that do not state one), `release.review`,
160
- `release.changelog` (default `CHANGELOG.md`; set it empty to opt out), `release.releases`, `release.preflight = <cmd>` (run in the worktree by `flow release` before anything ships — e.g. `docker build .`, so the build the tag triggers is proven first; a failure refuses the gate) and `release.artifact = <cmd>` (verify the published artifact — image registry probe etc. — before release-done completes); the implement stage takes `setup`/`test`/`build`/`run`/`seedData`/`health`/
161
- `dev`. Of those, `setup` runs once inside a freshly created worktree at `approve` (where `cp .env` +
162
- `npm install` belong — a failing setup fails the gate), and `run` is advisory: the agent starts the app
163
- with it for the running-and-healthy walk, dev-flow never runs it itself. `dev` is the dev deploy run by
164
- `flow verify` before the operator question — it must background and exit,
165
- e.g. `docker compose up -d .`; the gate names what it ran (`dev ran (<cmd>)`, or
166
- `dev: none configured`) so minutes of deploys never read as "nothing happened". After a deploy that
167
- ran, verify re-runs the health probe (`commands.health` or a `flow-check` block named `health`, with
168
- `seedData` first when set) in the worktree and refuses the gate when it fails — the pre-deploy
169
- `flow check` PASS describes a container that no longer exists. What "healthy and serving this
170
- build" means stays the project's own assertion: the probe runs with the worktree as cwd, so it can
171
- wait for readiness and compare the served build stamp with `git rev-parse HEAD`. No probe → the
172
- gate prints `health: none configured` and `flow doctor` flags the combination. The pre-release and release stages take
173
- `versionFile`/`versionTag` (defaults `v{version}`; accepted under either section) and
174
- `merge = squash | merge | rebase | any` — how a merged PR lands on the default branch (see below) — and
175
- `yolo = all | until-release`: with `until-release` a yolo given at an earlier checkpoint never answers Release?
176
- (for repos whose rules want the release word given after the commits exist; default `all`) — and
177
- `version = ask | versioned | unversioned` (gh#198): who makes the release call — `ask` (default) puts *a patch, minor or
178
- major release, or merge unreleased?* into the Verified? question (a kind is turned into a number at release, from the
179
- newest tag, so parallel flows never fight over one); the other two make it for every flow — and
180
- `ask = on-change | always`: with `on-change` (default) Release? answers itself when the call is on record and nothing but
181
- release prep (the bump, the changelog) changed since Verified? (a stale build, `yolo = until-release` or a major
182
- bump the operator did not name still ask; `always` asks it every flow, as before 0.89) — and
183
- `reflect = on-friction | always`: when `flow finish` runs the closing reflection worker. `on-friction` (default)
184
- skips it for a flow that hit no gate refusal and no guard block and carries no `--note`; `always` runs it every
185
- time. `## global` also takes
186
- `forge = github | gitlab | self` — the release machinery's target; when unset it is detected from the
187
- `origin` URL at the moment of use (GitHub gets `gh`, GitLab gets `glab`, self-hosted stays forge-neutral:
188
- no automatic release creation, merge proof by ancestry only), and `release.releases = false` skips
189
- automatic release creation entirely.
190
-
191
- ### The merge policy (`merge = squash | merge | rebase | any`)
192
-
193
- The one knob a repo can silently lack: a squash and a merge commit look identical right up until someone
194
- needs to know which one the release contains. Three things read the key:
195
-
196
- | policy | `main` gains | provable with git alone |
137
+ | `deny` | a bash command (regex) | blocked |
138
+ | `confirm` | a bash command (regex) | asks you; blocked when there's no UI to ask |
139
+ | `protect` | an edit/write path | asks you; blocked when there's no UI |
140
+ | `forbid` | an edit/write path | blocked |
141
+
142
+ Tips:
143
+ - Text after ` :: ` is the reason, shown when the rule fires.
144
+ - An invalid regex makes the playbook invalid, and `flow init` refuses it.
145
+ - Match the **verb** you mean, not a flag. `\bgit\b[^\n]*--force` also blocks
146
+ `git filter-branch --force`.
147
+ - You don't need a rule for force pushes. dev-flow already asks you about every one.
148
+ - A path rule on a directory covers everything under it, including files that don't exist yet.
149
+ - A glob only works in the **last** path segment: `docker/.env*` covers `.env` and
150
+ `.env.bak-2026`. A glob anywhere else matches nothing, and `flow init` warns about it.
151
+ - Rules are matched per shell segment (`;`, `|`, `&&`). Read-only commands like `grep`, `cat` and
152
+ `git log` are skipped, so `grep "git push --force" docs/` is just a search. Read-only commands that
153
+ can write (`find -delete`, `sort -o`) are still checked.
154
+ - Guard rules belong in `## global` only. A block under a stage is ignored with a warning.
155
+
156
+ ## Release settings
157
+
158
+ These go under `## pre-release` or `## release`. Either section works.
159
+
160
+ | Key | Default | What it does |
161
+ |---|---|---|
162
+ | `versionFile` | — | the version manifest (`package.json`, `VERSION`, …). Without it, releases are unversioned. |
163
+ | `versionTag` | `v{version}` | tag format |
164
+ | `changelog` | `CHANGELOG.md` | set it empty to opt out |
165
+ | `merge` | *(asked)* | how a PR lands: `squash`, `merge`, `rebase` or `any`. See below. |
166
+ | `version` | `ask` | who makes the release call: `ask` (you, at Verified?), or `versioned` / `unversioned` for every flow |
167
+ | `ask` | `on-change` | `on-change`: Release? answers itself when only release prep changed. `always`: ask every time. |
168
+ | `yolo` | `all` | `until-release`: a yolo given earlier never answers Release? |
169
+ | `reflect` | `on-friction` | `always`: run the closing reflection on every finish |
170
+ | `review` | `/flow-review` | the review step at pre-release |
171
+ | `preflight` | — | runs in the worktree at `flow release` before anything ships, for example `docker build .` |
172
+ | `artifact` | — | proves the release was published, for example `npm view <pkg>@{version} version` |
173
+ | `releases` | `true` | `false` skips creating a forge release |
174
+
175
+ `## pre-release` prose is a good place for your versioning rules, such as "minor for user-facing
176
+ features, patch otherwise". The gates check the mechanics: the version is bumped past the last tag,
177
+ and the changelog has the entry. See [gates](gates.md#release-release).
178
+
179
+ A changelog entry describes the branch's **net change**, not its commit history. A feature that took
180
+ several commits is one entry.
181
+
182
+ ### The merge policy
183
+
184
+ A squash and a merge commit look the same until someone needs to know which one a release contains.
185
+ So dev-flow asks.
186
+
187
+ | Policy | Main gains | Provable with git alone? |
188
+ |---|---|---|
189
+ | `merge` | a merge commit plus the branch's commits | yes |
190
+ | `squash` | one new commit | no, it asks the forge |
191
+ | `rebase` | the branch's commits with new SHAs | no, it asks the forge |
192
+ | `any` | no policy, and no asking | — |
193
+
194
+ - **`flow init` and `flow start` ask** if it isn't set, with evidence from your history.
195
+ - **The guard enforces it.** `gh pr merge <n> --squash` under `merge = merge` is blocked, and a merge
196
+ with no style flag asks you. Put the PR number *before* the flag.
197
+ - **Merge only once CI is green** (`gh pr checks <n> --watch`). Local checks can't run CI-only jobs.
198
+ - **`release-done` proves** that what landed matches the policy. When it can't tell, it prints a note
199
+ instead of refusing.
200
+
201
+ dev-flow can't stop someone clicking the merge button in the web UI. Use your forge's
202
+ merge-strategy setting for that.
203
+
204
+ ## Global settings
205
+
206
+ | Key | Default | What it does |
197
207
  |---|---|---|
198
- | `merge` | a merge commit plus the branch's own commits | **yes** — the branch is an ancestor of `origin/<default>` |
199
- | `squash` | one new commit | no — ask the forge (`gh`/`glab`) |
200
- | `rebase` | the branch's commits, replayed with new SHAs | no — same |
201
-
202
- - **`flow init` asks** with evidence from your own history (`merge history: 6 merge commit(s), 3 squash(es)
203
- — the most recent PR landed as squash`), and **`flow start` refuses until it is set**: the agent asks you
204
- in chat, re-runs with `--merge=<style> --confirmed`, and the answer is inserted as a single line under
205
- `## release` (validated before the write, `.bak` kept, committed as a playbook chore when the playbook is
206
- the only dirty path). `any` is the explicit opt-out: no policy, no asking.
207
- - **the guard enforces it where the decision is made** — `gh pr merge <n> --squash` against `merge = merge` is
208
- blocked outright, and a merge that carries no style flag (so the forge default decides) needs your
209
- confirmation; a local `git merge --squash` only ever confirms, because merging main into a branch is
210
- ordinary work. Spell the PR number **before** the flag: `gh pr merge --merge main` reads `main` as the
211
- PR selector ("no pull requests found for main") and never merges anything.
212
- - **whatever the style, merge only once CI is green** (`gh pr checks <n> --watch`): the local gate cannot run
213
- CI-only jobs — a tool the host lacks turns a locally-green branch into a red default branch (gh#134).
214
- - **`release-done` proves what actually landed** matched the policy (branch ancestry plus what the forge
215
- reports), and `flow finish` says whether commits missing from the default branch are expected (squash,
216
- rebase) or a violation (merge — where `yolo` does not answer for you). A shape dev-flow cannot see —
217
- `forge = self`, no CLI, an unfetched branch — prints an advisory instead of refusing a legal release.
218
-
219
- What it cannot do is bind a human clicking the merge button in the Web UI: only the forge's own
220
- require-a-merge-strategy setting does that, and setting it stays your step in the forge, not dev-flow's.
221
-
222
- `flow init` is the dialogue around this file (see the Quickstart above).
223
-
224
- On a **fresh repo** it prints the setup brief: the detection report, plus one question per knob, each with `detected:` / `accept:` / `why:` lines. It writes nothing.
225
-
226
- `--answers key=value …` (or `--answers-file <path>`, one pair per line, `#` for comments) applies answers as targeted edits onto the fresh draft, or onto the current file if one exists:
227
- - Keys: `forge`, `defaultBranch`, `setup`/`test`/`build`/`run`/`dev`/`health`, `versionFile`/`versionTag`/`changelog`, `releases`/`artifact`/`preflight`/`merge`, and `check.<name>` for a `flow-check` block. An empty value removes a check.
228
- - Hand-written lines survive, and a key already written under one release section stays there.
229
- - It previews the summary and the diff, and writes only with `--confirmed` (or on a dialog yes).
230
-
231
- `--write "<content>"` / `--write-file <path>` replace the whole file. The content is hard-validated, and the result shows the diff.
232
-
233
- `--track` commits the playbook as a playbook chore (`git add -f` + the main-hook prefix). `--draft` prints the draft, or the current file, without writing.
234
-
235
- On an **existing file** init is doctor mode. It reports drift, dead commands and scripts, an unparseable manifest, dual configs, and **ghost feature dirs** (a `.dev-flow/<slug>/` whose `state.json` is gone). It offers to delete ghost dirs on your confirm, and says so instead when no UI is present; to keep one as a new feature's draft, decline and run `flow start <slug> --confirmed`, which adopts it. It never runs your commands.
236
-
237
- When a hook manager sets `core.hooksPath` (husky, lefthook…), git ignores `.git/hooks`, so init prints the main-branch guard lines for you to add to that hook instead of installing one that would never run. An existing foreign `pre-commit` gets the same printout.
238
-
239
- Init prints its findings and never regenerates your file: a draft cannot reproduce your prose, checklist items and hand-set keys. `--force` is the deliberate overwrite — with your word (`--confirmed`, or one
240
- confirm dialog) and a `project.md.bak` of what was there. At any time
241
- you can just edit `.dev-flow/project.md` yourself — the next `flow init` (doctor) validates and
242
- flags problems, and `flow doctor` runs the same probes on demand without offering to change
243
- anything (findings are also printed whenever `flow init` runs without a UI, e.g. in CI). `--force`
244
- rewrites from fresh detection. Improvement
245
- ideas the agent notices along the way queue up in `.dev-flow/reflections.md` — *this project's*
246
- queue only: `## playbook` (the fix lives in your playbook → docs flow) and `## code` (the fix
247
- touches your code → patch flow). Feedback about dev-flow itself never lands there: it becomes a
248
- GitHub issue on the dev-flow repo. `flow reflect --playbook|--code "<note>"` appends a note,
249
- `flow reflect --plugin "<note>"` prints the upstream issue recipe instead (no flag guesses from the
250
- wording and prints why), `flow reflect list` numbers the open ones, `flow reflect move <n>
251
- --playbook|--code` re-files one, `flow reflect tidy` drops the closed (`- [x]`) ones, plain
252
- `flow doctor` reviews the open ones and routes each fix to the flow that implements it. At finish
253
- — run by `flow finish` itself, before it removes anything — a fresh read-only **reflect worker**
254
- (`flow_stage` op `reflect`) reviews the whole session — the
255
- driver's and every worker's transcript — and returns classified findings with a fold/drop
256
- recommendation each; the operator decides per item (fold = a queue row or an upstream issue, drop
257
- = nothing recorded). Suggestions to fix open items or tidy closed ones are timed (finish, between
258
- flows, doctor — never mid-feature) — and nothing there ever gates.
259
- Future features have their own file: `.dev-flow/roadmap.md`, a gitignored backlog `flow roadmap`
260
- manages (add / pick → `flow start` / done / tidy) — a picked item is checked off by `finish` when
261
- its feature ships, and it never gates either.
262
-
263
- ### Structured stage reports (a convention, not a gate)
264
-
265
- The gates enforce *state*; how the agent *talks* about that state is presentation. The norm lives in
266
- the skill itself — the **Stage reports** clause in `SKILL.md` ground rules, echoed by the
267
- `Stage reports:` line in every stage-context injection — so every repo using dev-flow gets the same
268
- output protocol without writing a word of playbook prose. This is the human explanation of it.
269
-
270
- **Two readers, one result.** Every `flow` tool result is split. The agent's copy keeps every
271
- instruction (what to run next, what to ask). Your copy — the tool row in the TUI — shows a header
272
- (`✅ Verification · dark-mode`, `❌ … refused`, `💬` when it waits on you), the stage line, the facts,
273
- and the one question waiting on you, phrased as a word to answer in chat. Lines the gate marks
274
- agent-only, and any clause that names a `flow` command, are left out of your copy (expand the row to see
275
- them dimmed). The test suite checks every gate it drives: no operator view names a command. If an answer
276
- still hands you a command to type, the next run gets a hidden correction.
277
-
278
- **The gate writes the stage line.** It is built from state on every gate that has a feature in scope,
279
- so it is the same every time; the agent pastes it as is (`stage line for your report`) instead of
280
- rebuilding glyphs and marks from memory.
281
-
282
- One gate message = **stage line** + event title + **`Done:`** / **`Next steps:`** blocks, all plain
283
- markdown, **never fenced** (a fenced block renders monospace with a horizontal scrollbar in web UIs;
284
- fences stay for diffs and command output).
285
-
286
- **The stage line** *is* the decision record — one copy of every fact. It opens with the statusbar's
287
- own stage glyph (the footer is the legend: 💬 pre-flow "operator, your turn" · 📝 plan · 🔨 implement
288
- · 🔍 pre-release · 🚀 release · 🏁 finish), then `slug — key value` pairs separated by `·`, with the
289
- mode glyphs after the slug as in the footer (⚡ patch · 📚 docs · 🎱 yolo). Every value carries a
290
- provenance mark:
291
-
292
- | mark | meaning |
208
+ | `defaultBranch` | `main` | |
209
+ | `forge` | detected from `origin` | `github` (uses `gh`), `gitlab` (uses `glab`) or `self` (no automatic releases; merges proven by git ancestry) |
210
+ | `branchPattern` | `feat/{slug}` | |
211
+ | `worktreeDir` | `.dev-flow/{slug}/worktree` | |
212
+ | `mainHook` | `true` | install the `pre-commit` hook that blocks main commits |
213
+ | `mockupGlobs` | `*.png` | what counts as a mockup render for `--ui` |
214
+ | `bashTimeout` | `inject` | `require`: refuse shell calls with no timeout, instead of adding one |
215
+
216
+ ## flow init in detail
217
+
218
+ - **Fresh repo:** prints the detection report and the questions. Writes nothing.
219
+ - **`--answers key=value …`** (or `--answers-file <path>`) applies answers as targeted edits. Your
220
+ hand-written lines survive. It shows a diff, and writes only with `--confirmed`. Keys include
221
+ `forge`, `defaultBranch`, `setup` / `test` / `build` / `run` / `dev` / `health`,
222
+ `versionFile` / `versionTag` / `changelog`, `releases` / `artifact` / `preflight` / `merge`, and
223
+ `check.<name>` for a check block (an empty value removes it).
224
+ - **`--write-file <path>`** (or `--write "<content>"`) replaces the whole file, after validating it.
225
+ - **`--track`** commits the playbook. **`--draft`** prints the draft without writing.
226
+ - **Existing playbook:** init becomes a doctor. It reports drift, dead commands, an unparseable
227
+ manifest and leftover feature folders, and never rewrites your file. `--force` regenerates it from
228
+ fresh detection, with your OK and a `.bak`. `flow doctor` runs the same checks without offering
229
+ changes.
230
+ - **Hook managers** (husky, lefthook): init prints the hook lines for you to add instead of installing
231
+ a hook git would ignore.
232
+
233
+ `.dev-flow/` ignores itself except for `project.md`. To track the playbook in a repo that ignores
234
+ the folder: `git add -f .dev-flow/project.md && DEV_FLOW_ALLOW_MAIN=1 git commit -m "track project.md"`.
235
+
236
+ ## How the agent reports
237
+
238
+ The gates enforce state. How the agent *talks* about it is a convention built into the skill, so
239
+ every repo gets it without writing any prose.
240
+
241
+ **Two copies of each result.** The agent's copy has every instruction. Your copy shows a header
242
+ (`✅ Verification · dark-mode`, `❌ … refused`, or `💬` when it's waiting on you), the stage line, the
243
+ facts, and the one question for you. It never shows a command for you to type.
244
+
245
+ **The stage line** is the decision record. The gate builds it from state and the agent pastes it
246
+ as is. Every value carries a mark:
247
+
248
+ | Mark | Means |
293
249
  |---|---|
294
- | `✓` | operator-decided |
295
- | `✓playbook` / `✓detected` | decided by a rule or auto-detection |
296
- | `~` | agent-assumed — vetoable; flips to `✓` when the stage's verb is given |
297
- | `?` | pending the operator's word |
298
-
299
- A decision not made reads `pending` — never left unstated, never silently invented (a version bump
300
- needs the operator's word; `no-version` too). Per-stage fields after the core (stage · slug · mode ·
301
- ui): plan status and mockups; commits `N ahead, M uncommitted`, tier-1, deploy/health, `branch@sha`;
302
- the version decision (`bump <level> → vX.Y.Z ~`) with tag/changelog/fold/review/merge-style beside
303
- it; PR/tag/artifact/forge proofs at 🚀 (stage lines only there — that stage asks nothing); release-
304
- recorded / main-state / unmerged / reflections at 🏁.
305
-
306
- **The checkpoint** closes exactly one message per stage (the operator's verb stays a plain-chat word
307
- — a structured-question tool is not chat). Event title, then the labels **`Done:`** and
308
- **`Next steps:`** standing alone on their own lines. `Done:` says what now works, in plain words and
309
- counts, not vibes; a path or SHA only when the operator needs it. Internals (modules, code paths)
310
- stay out of chat unless asked. `Next steps:` lists the operator's verbs in italics (the recommended one
311
- ***bold italic***, and no line needs a "(recommended)" tag when the styling carries it) and **never
312
- gate commands** (the agent runs those): recommended first, then alternatives, then *yolo* last with
313
- what it pre-confirms, then the plain closing line "or say what to do differently". Example:
314
-
315
- > **🔍 pre-release · `dark-mode`** — `normal` ✓playbook · ui `on` ✓ · commits `4 ahead, 0 uncommitted` · checks test ✓ build ✓ · version `0.56.0` ~ · merge `merge` ✓playbook · `feat/dark-mode@3f2c1a9`
250
+ | `✓` | you decided |
251
+ | `✓playbook` / `✓detected` | a rule or detection decided |
252
+ | `~` | the agent assumed it, and you can veto it |
253
+ | `?` | waiting on you |
254
+
255
+ **A checkpoint message** is the stage line, a title, then **Done:** (what works now, in plain
256
+ words) and **Next steps:** (your options as words to say, recommended first, yolo last):
257
+
258
+ > **🔍 pre-release · `dark-mode`** — `normal` ✓playbook · ui `on` ✓ · commits `4 ahead, 0 uncommitted` · checks test ✓ build ✓ · version `0.56.0` ~ · merge `merge` ✓playbook
316
259
  >
317
260
  > **Release prep done**
318
261
  >
@@ -320,13 +263,7 @@ what it pre-confirms, then the plain closing line "or say what to do differently
320
263
  > review 0 must / 0 should; CHANGELOG `## [0.56.0]` folded from `Unreleased`; manifest bumped
321
264
  >
322
265
  > **Next steps:**
323
- > - ***Release*** → tag `v0.56.0`, forge release — locks the `~` fields
324
- > - *No-version* → merge only, entry rides under `Unreleased`
325
- > - *Yolo* → release with these parameters, remaining gates back to back
326
- > - or say what to do differently — bump level, changelog wording
327
-
328
- Mid-stage (non-checkpoint) reports are the stage line plus a short body — no `Next steps:` block —
329
- and mid-stage scope additions amend `plan.md` with an `**Added mid-stage:**` line instead of opening
330
- a second checkpoint. Like all tier-3 prose this is advisory: gates refuse what gates refuse no matter
331
- how the report is formatted. A project can still set `prose.<stage>` for its own stage guidance —
332
- that replaces the built-in guidance text but the Stage reports rule keeps applying.
266
+ > - ***Release*** → tag `v0.56.0`, forge release
267
+ > - *No-version* → merge only, entry stays under `Unreleased`
268
+ > - *Yolo* → release with these settings, remaining gates back to back
269
+ > - or say what to do differently