pi-dev-flow 0.89.0 → 0.90.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 +15 -0
- package/docs/concurrency.md +3 -1
- package/docs/gates.md +1 -1
- package/docs/playbook.md +5 -2
- package/extensions/dev-flow.ts +3 -2
- package/package.json +1 -1
- package/skills/dev-flow/references/implement.md +3 -1
- package/skills/dev-flow/references/reflect.md +4 -1
- package/skills/dev-flow/references/start.md +4 -1
- package/src/core.ts +85 -36
- package/src/projectmd.ts +18 -5
- package/src/runtime/gates.ts +10 -4
- package/src/runtime/grants.ts +13 -3
- package/src/runtime/reflect.ts +29 -17
- package/src/runtime/ship.ts +23 -6
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.90.0] - 2026-11-10
|
|
8
|
+
|
|
9
|
+
**Operator answers are checked everywhere they are given, docs flows stop being asked for impossible checks, and stage workers get the project's setup.**
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- **Playbook setup for stage workers (gh#201).** A `flow-worker` block under `## global` in `project.md` holds the setup lines a stage worker needs before it can run your checks, for example exporting a test password read from a gitignored file. `flow_stage` copies those lines into every worker brief, so the driver no longer has to remember them. A review worker that still couldn't run a check now has to name it under `checks not run:` instead of returning a quiet PASS.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- **`--replace` and `--port=<n>` need your answer too (gh#203).** When another flow holds the dev port, `flow verify` asks *Dev port?* and takes `--replace` or `--port=<n>` as the answer. Unlike `--confirmed`, those two were accepted without any message from you, and the deploy record then said the replacement was "the operator's answer". They now bind the same way: a re-run carrying either one is refused until you have sent a message since the question.
|
|
16
|
+
- **A docs flow is no longer asked to tick checks it cannot run, and an open checklist says which items are open (gh#207).** A `--docs` flow skips build, deploy and health at implement, but the `## implement` checklist items (container tests, click-throughs) still counted as open. The stage line showed `tier-2 3 open` with no way to find them, since "tier-2" appears nowhere in `project.md`. On a docs flow, implement items now stand down unless you tag one `(docs)`. Wherever the count shows up (the verify and release refusals, the next-step hint, the stage guidance), it now lists the open items by their text and the `## <stage>` section that holds them.
|
|
17
|
+
- **`flow reflect done <n>` no longer closes the wrong item in a batch (gh#197).** The numbers counted only the open items, so after the first `done` every later number pointed one row further down than the list you were reading, and each closing note landed on the wrong item. Numbers are now row numbers that stay put when an item is checked off, so a batch of `done` calls read off one `list` closes exactly the rows it named. A number that points at a row already checked off is refused and names that row's note, and the confirmation line repeats the note and what fixed it. `move` and `tidy` still renumber, and they now say so.
|
|
18
|
+
- **Finish no longer skips the after-merge checklist (gh#205).** Items under `## release` in the playbook (for example a build and deploy check run from the default branch after the merge) were named only by `flow release-done`. An unversioned flow, or any flow that let `flow finish` record the release itself, did the recording and the cleanup in one call. The items were never shown while the worktree still stood. Now, when finish records the release and release-stage items are open, it stops before removing anything, lists them, and asks Finish?. The Finish? question also names the items its answer closes.
|
|
19
|
+
- **The deploy record names the stack it touched (gh#204).** The `dev ran (…)` line printed the playbook command as written, `$DEV_FLOW_SUFFIX` and all. On the default port that variable is empty, which is the difference between a private stack and the machine's one shared stack, and after a failed deploy the only way to find out which one was hit was to read dev-flow's source. The `dev ran` and `dev deploy FAILED` lines now add what the command resolved to: the `DEV_FLOW_*` values it reads and the compose project it lands on.
|
|
20
|
+
- **An operator-granted refusal says when a grant counts (gh#206).** A `flow start --docs` (or `--patch`, `--ui`) without `--confirmed` is refused, and since gh#190 an immediate `--confirmed` re-run is refused too, because only a message sent after the refusal counts. The agent used to learn that by burning a second call, then had to ask you to repeat a permission you had already given. The refusal now says so up front, and the playbook tells the agent to pass `--confirmed` on the first call when your request already grants the mode.
|
|
21
|
+
|
|
7
22
|
## [0.89.0] - 2026-11-09
|
|
8
23
|
|
|
9
24
|
**The release call is made with Verified?, and Release? answers itself when nothing but the release prep changed.**
|
package/docs/concurrency.md
CHANGED
|
@@ -36,7 +36,9 @@ who holds the port (stage, commit, age), the available RAM and free disk against
|
|
|
36
36
|
`instanceMem` / `instanceDisk`, and the options — run alongside on the next free port
|
|
37
37
|
(`flow verify --port=<n>`), replace that deploy (`--replace`), or wait. Running alongside is offered
|
|
38
38
|
only when the playbook allows it (`parallelDev` is not `no`, `dev`/`health` read `$DEV_FLOW_PORT`) and
|
|
39
|
-
the resources fit.
|
|
39
|
+
the resources fit. `--port=<n>` and `--replace` are the operator's answer, so they bind like
|
|
40
|
+
`--confirmed` (gh#203): a re-run carrying either before the operator has sent a message since
|
|
41
|
+
`Dev port?` was asked is refused. A finished or aborted flow holds no port. `flow finish` stops a flow's
|
|
40
42
|
non-default-port instance with `devDown`.
|
|
41
43
|
|
|
42
44
|
**The review is of the tree that ships.** Parallel flows release while others are still implementing,
|
package/docs/gates.md
CHANGED
|
@@ -20,7 +20,7 @@ so it needs no `--confirmed`. The agent's own `flow` call never opens a dialog (
|
|
|
20
20
|
| `verify [--yolo] [--port=<n>\|--replace] [--version=<v>\|--no-version]` | implement → pre-release | **the release call rides on Verified?** (gh#198): on a versioned project (`versionFile`) whose playbook leaves `version = ask`, the NEEDS-OPERATOR Verified? also asks *a patch, minor or major release (each with the number it makes from the manifest's current version), or merge unreleased?*, and `--confirmed --version=patch|minor|major` (or an exact `--version=<v>`) / `--confirmed --no-version` records the answer (`release call: …` in the output, the version on the stage line) so pre-release prepares the right thing; a playbook `version = versioned \| unversioned` makes the call for every flow, and a re-verify keeps the recorded call unless it is given again; **at pre-release it is the re-verify** (gh#187): after review fixes it runs the same build, deploy and probes over the current tree (no rebase), re-asks Verified? — a standing yolo never answers it — and on the answer moves the verdict (`verifiedHead`) to that tree, staying in pre-release; **without `--confirmed` it is the review deploy**: it fetches and, when the branch is behind `origin/<default>` (or local `<default>` with no remote), **rebases** it — untracked files never block, uncommitted tracked edits and conflicts refuse (the rebase is aborted, the branch untouched); when the dev port (playbook `port`, or the whole stack when none is set) was last deployed by **another live flow** it refuses with `NEEDS-OPERATOR Dev port?`, the measured RAM/disk against `instanceMem`/`instanceDisk`, and the options: run alongside on the next free port (offered only when `parallelDev` is not `no`, `dev`/`health` read `$DEV_FLOW_PORT`, and the resources fit), `--replace`, or wait — nothing is built first; then it deploys and returns `deployed for review` with the chat question. **With `--confirmed`** it never rewrites history: a default branch that moved since refuses (re-run `flow verify`). With `servedBuild` set the served commit must be the worktree's HEAD. Otherwise: all tier-1 checks green — a check with no passing record is **run by the gate itself** (`checks ran at the gate (test)`) rather than refused and pointed at `flow check`, since entering the stage or editing the worktree is what cleared it — and so is a record whose worktree fingerprint differs from the tree now (`stale record(s) rerun after a worktree change: …`): a change made through bash fires no edit-tool hook, the fingerprint is what notices the tree moved — and a failure there prints the run output, **the feature branch holds at least one commit** (verify refuses a branch with nothing committed — the checks describe the working tree, so an uncommitted state has never been recorded — except a **release-only flow** (#161): on a versioned project an empty branch over unreleased commits on the default branch (since the newest local version tag, or all of them before the first release) passes, the line says `release-only flow: N unreleased commit(s)`, and the version bump is the pre-release commit; with nothing unreleased the refusal says there is nothing to release; and prints `commits: N ahead of <default>, M uncommitted path(s)` with what it ran; uncommitted paths are reported, never gated), build (if configured) green, `dev` deploy (if configured) runs first so you can review the running app **and the health probe (if configured) re-runs against what it just deployed, retrying every 2s up to `healthWait` seconds** (a failing probe refuses the gate and reports how many attempts it took: the `flow check` PASS predates the deploy, and a service that needs seconds after its container starts is not a broken deploy; with no probe the output says `health: none configured`); with **no `dev` command but a `health` probe configured the gate live-re-probes the app before asking** (`health: live re-probe PASS` — a killed server refuses with `live probe FAILED`, because process death dirties no worktree fingerprint and a green record alone cannot prove liveness: start the app and rerun), tier-2 checklist (ui-only items excluded for non-UI features) confirmed as a set; a `--docs` feature runs none of it (`docs mode: project commands skipped`) and only asks you; **one question** — or `--confirmed`; `--yolo --confirmed` = you answered 'yolo' at Verified? — answers it and pre-confirms the rest |
|
|
21
21
|
| `release [--yolo|--version=<v>|--no-version|--no-fold-check|--no-marker-check]` | pre-release → release | **the branch carries the release call** (gh#198), checked before the generic version proofs: a patch/minor/major call is **counted from the newest tag at release time**, so when a parallel flow released the number first the refusal names the new one (`bump VERSION to 1.2.0 (minor past 1.1.0) — v1.1.0 was released since Verified?`) and the call still stands; an exact version another flow already tagged is refused as **taken**, for the operator to re-make; a manifest that does not say the version the operator chose, or a bump on a flow whose call is *merge unreleased* (the manifest differs from the merge base's), is refused — re-make the call with `--version=<v>` / `--no-version` and `--confirmed` on the operator's word; **`release.ask = on-change`** (the default; `ask = always` asks every time) answers Release? itself (`auto-answered: release.ask = on-change — …` in the approved line) when the call is on record, a Verified? tree is on record, nothing but release prep landed after it, the session build is current, the playbook does not set `yolo = until-release`, and a playbook-made versioned call is not a major bump — otherwise Release? is asked as before, naming why (`asked: …`) — a call re-made on the release command without `--confirmed` is one of those reasons, since the call is the operator's, and with no call on record it asks that too; checks re-greened after the prep edits; `release.preflight` (when set) passes in the worktree — the build the tag will trigger, proven before anything ships; **the branch adds no merge-conflict marker lines** vs its merge base (#164: a hand-resolved merge that kept a `<<<<<<<`/`>>>>>>>` line is refused with `file:line`; `--no-marker-check` on the operator's word when the lines are meant); **commits after Verified?** are named in the Release? question and the approved line (#162: the operator's word covers the HEAD verify stamped — a warning, never a refusal); a **standing yolo** (given at an earlier checkpoint) does not answer Release? when such commits exist, nor ever under `yolo = until-release` in `## release` — the gate returns NEEDS-OPERATOR Release? (gh#176), while `--confirmed` (the operator's answer, a yolo said at Release? included) still passes; **the worktree holds no uncommitted paths** (gh#131: a merge ships the branch, not the working tree — an uncommitted fix at this gate is a fix that never ships; the refusal lists the paths, and the approved line prints `commits: N ahead of <default>, M uncommitted path(s)` like verify's); with `versioning.file`: the manifest version parses and is **not tagged yet** (the bump must be ahead of the last release); with `release.changelog` the gate **proves the entry mechanically** (#97): a **heading names the version** (prose that mentions it, or a `1.2.0-beta` section when releasing `1.2.0`, is not an entry), **this branch touched the file** (an inherited changelog is not release prep), **every entry that was pending before the release survives inside the new section** — compared on normalized lines, so re-indenting a fold is free while rewording or deleting one is refused by naming the line — and **nothing is left under `Unreleased`**. The proofs guard the **baseline's** pending lines — they do not freeze the wording of the entry this flow writes, so a branch that landed as several iteration commits is free to state its result as one entry (see the changelog-writer rule in the pre-release reference). The pending baseline is the newest tag's changelog (what actually shipped), else the branch's merge base; when neither resolves, the two git-dependent proofs are skipped **with a printed advisory** rather than refusing a legal release for a topology reason, and the content proofs (the heading, its body) always run; tier-2 `## pre-release` checklist confirmed; the manifest version it validates is **stamped as the release's version of record** (`release-done` publishes that, whatever the checkouts say later); **one question** (Release?) — or `--confirmed`; `--no-version` (your call at Release?) ships this flow as **merge + changelog** — the bump/tag requirements and the tag checks at `release-done` are skipped for it, but the branch must still add its **own line under `Unreleased`** (a `--docs` flow is exempt — #163: a playbook/docs change owes no user-facing entry; one it writes is welcome, not proven) (editing an older section releases nothing) and it rides there until the next versioned release folds it (default: versioned); `--no-fold-check` is the operator-granted escape from the line-level fold proofs — one flow, stamped in the gate output, the heading and touched proofs stay; **stale session build** (loaded build behind the checkout): the gate prints both builds, lists what shipped between them (those proofs will not run this release) and folds *update (/reload, then re-run) or proceed with the old release?* into the Release? question — the operator's word, recorded in the release output, **never a block**: publishing under an older gate is a legitimate choice (hotfix, offline reload) |
|
|
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; on GitHub a miss right after the tag push **waits for the CI runs that tag started** — up to 15 min, plus a minute's grace for a registry that lags the green run — then probes again, and a refusal names a failed or still-running run with its URL, gh#179) · 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
|
-
| `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` |
|
|
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; when the playbook's `## release` checklist has open items, that call stops after recording, before anything is removed, and asks Finish? with the items listed — gh#205) — **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
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 |
|
package/docs/playbook.md
CHANGED
|
@@ -52,7 +52,8 @@ executable checks and hard safety rules:
|
|
|
52
52
|
|---|---|---|
|
|
53
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
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
|
-
|
|
|
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) |
|
|
56
57
|
| 3 — prose | any other text | injected to the agent when its stage begins — advisory |
|
|
57
58
|
|
|
58
59
|
Example `## implement` section:
|
|
@@ -89,7 +90,9 @@ servedBuild = curl -fsS http://127.0.0.1:$DEV_FLOW_PORT/version # must print t
|
|
|
89
90
|
```
|
|
90
91
|
|
|
91
92
|
`$DEV_FLOW_SUFFIX` is empty on the default port and `-<slug>` on any other, so a second instance gets its own
|
|
92
|
-
compose project. `
|
|
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
|
|
93
96
|
port it would use belongs to another live flow it asks you first (see [concurrency](concurrency.md)).
|
|
94
97
|
`flow finish` runs `devDown` for an instance on a non-default port. `servedBuild` turns "something answers"
|
|
95
98
|
into "this branch answers": verify refuses when its output names no prefix of the worktree's HEAD.
|
package/extensions/dev-flow.ts
CHANGED
|
@@ -24,7 +24,7 @@ import path from "node:path";
|
|
|
24
24
|
import { Type } from "typebox";
|
|
25
25
|
import { compact, defineTool, isToolCallEventType, type AgentSession, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
26
26
|
import { type ExtensionAPI, type ToolCallEvent, type ToolCallEventResult, type TurnEndEvent, type TurnEndEventResult } from "@earendil-works/pi-coding-agent";
|
|
27
|
-
import { ALLOW_REWRITE, applicableItems, bashFlowGuard, checklistPending, checkoutInvocation, claimBlocks, featureBranchPrefix, FLOW_SHELL_HINT, flowShellInvocation, forcePushInvocation, freshenChecks, gitInvocation, guardBash, guardPath, mergeStyleInvocation, parsePushRefs, playbookTamper, playbookOnlyChange, pluginVersion, reflectionNudges, buildReflectBrief, parseReflectReport, renderReflectFindings, childSessionFiles, workerSteer, WORKER_STEER_AT, WORKER_SALVAGE, WORKER_SALVAGE_MS, WORKER_NUDGE_READONLY, stageReference, needsOperator, NEEDS_OPERATOR, nextHint, roadmapOpenCount, shouldTakeOverCompaction, stageGuidance, stateTamper, statusFor, sq, featureTmpDir, compactionStateBlock, withTmpDir, widgetLines, chipLabel, writeGuard, buildWorkerBrief, clampBudgetMin, parseWorkerReport, workerTurnError, hollowStop, hollowStopNote, workerOpError, WORKER_NUDGE, WORKER_NUDGES, releaseOrderInvocation, type WorkerOp, type FlowState, type PushRef } from "../src/core.ts";
|
|
27
|
+
import { ALLOW_REWRITE, applicableItems, openItemsNote, bashFlowGuard, checklistPending, checkoutInvocation, claimBlocks, featureBranchPrefix, FLOW_SHELL_HINT, flowShellInvocation, forcePushInvocation, freshenChecks, gitInvocation, guardBash, guardPath, mergeStyleInvocation, parsePushRefs, playbookTamper, playbookOnlyChange, pluginVersion, reflectionNudges, buildReflectBrief, parseReflectReport, renderReflectFindings, childSessionFiles, workerSteer, WORKER_STEER_AT, WORKER_SALVAGE, WORKER_SALVAGE_MS, WORKER_NUDGE_READONLY, stageReference, needsOperator, NEEDS_OPERATOR, nextHint, roadmapOpenCount, shouldTakeOverCompaction, stageGuidance, stateTamper, statusFor, sq, featureTmpDir, compactionStateBlock, withTmpDir, widgetLines, chipLabel, writeGuard, buildWorkerBrief, clampBudgetMin, parseWorkerReport, workerTurnError, hollowStop, hollowStopNote, workerOpError, WORKER_NUDGE, WORKER_NUDGES, releaseOrderInvocation, type WorkerOp, type FlowState, type PushRef } from "../src/core.ts";
|
|
28
28
|
import { loadProject } from "../src/projectmd.ts";
|
|
29
29
|
import { bashTimeout, requireTimeout, timeoutClass } from "../src/timeouts.ts";
|
|
30
30
|
import { AGENT_MARK, operatorCommandAsks, operatorCommandCorrection, viewHeader, askLine, type GateView } from "../src/present.ts";
|
|
@@ -341,6 +341,7 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
341
341
|
commits: await git(`git log --oneline ${sq(cfg.defaultBranch)}..HEAD`),
|
|
342
342
|
status: await git("git status --short"),
|
|
343
343
|
checks: cfg.checkList.map((c) => ({ name: c.name, command: c.cmd })),
|
|
344
|
+
preamble: cfg.workerPreamble,
|
|
344
345
|
note: String(params.note ?? ""),
|
|
345
346
|
});
|
|
346
347
|
// pi-web visibility needs both halves of the lineage: the id the Agents menu links the child
|
|
@@ -878,7 +879,7 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
878
879
|
if (prose) guidance.push(`Stage guidance (${prose.source}): ${prose.text}`);
|
|
879
880
|
guidance.push("Stage reports: open with the stage line the last gate returned, pasted as is; a checkpoint closes with `Done:` / `Next steps:` (see the ground rules).");
|
|
880
881
|
const pend = checklistPending(cfg, state, state.stage);
|
|
881
|
-
if (pend) guidance.push(`Tier-2 checklist NOT yet confirmed
|
|
882
|
+
if (pend) guidance.push(`Tier-2 checklist NOT yet confirmed — ${openItemsNote(cfg, state, state.stage)}${state.stage === "release" ? " — release-stage items close with the operator's Finish? answer; no earlier gate records them" : ""}`);
|
|
882
883
|
// mid-feature is the wrong moment to divert into old reflections — they surface at the release
|
|
883
884
|
// stage (finish runs the reflection), between flows, and in status/doctor
|
|
884
885
|
if (state.stage === "release") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.90.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": [
|
|
@@ -28,7 +28,9 @@ note). Other sessions' worktrees are theirs.
|
|
|
28
28
|
deploy and the health probe against what it deployed, and returns
|
|
29
29
|
`NEEDS-OPERATOR Verified?`. It never opens a dialog.
|
|
30
30
|
- Another flow holds the dev port → `NEEDS-OPERATOR Dev port?` with free
|
|
31
|
-
RAM/disk: ask, then re-run with `--port=<n>` or `--replace
|
|
31
|
+
RAM/disk: ask, stop, then re-run with `--port=<n>` or `--replace` on
|
|
32
|
+
their answer. "wait" means wait; a later "proceed" about the feature is
|
|
33
|
+
not a yes to replacing another flow's stack.
|
|
32
34
|
- The health probe retries every 2s up to `healthWait` (default 30s); a
|
|
33
35
|
service that needs a moment is not a broken deploy.
|
|
34
36
|
2. Look at the change yourself, **keep the app running**, ask **Verified?**
|
|
@@ -19,7 +19,10 @@ friction only, never the same issue twice. `.dev-flow/reflections.md` holds
|
|
|
19
19
|
- No flag → the wording decides and the printed line says why.
|
|
20
20
|
- `flow reflect list` numbers the queue; `flow reflect move <n>
|
|
21
21
|
--playbook|--code` re-files; `flow reflect done <n> ["<what fixed it>"]`
|
|
22
|
-
checks one off; `flow reflect tidy` drops closed items.
|
|
22
|
+
checks one off; `flow reflect tidy` drops closed items. The numbers are
|
|
23
|
+
row numbers: checking items off leaves the others' numbers alone, so a
|
|
24
|
+
batch of `done` calls read off one `list` is safe; after `move` or `tidy`,
|
|
25
|
+
list again.
|
|
23
26
|
- `flow doctor "<observation>"` prints an investigation brief without queueing.
|
|
24
27
|
- The end-of-session reflection runs at finish (see [finish.md](finish.md)).
|
|
25
28
|
|
|
@@ -34,7 +34,10 @@ knobs · merge-policy state.
|
|
|
34
34
|
the mode (`normal` default, or `--patch` / `--docs`), `--ui` when screens
|
|
35
35
|
change, and the merge policy if the playbook has none —
|
|
36
36
|
`flow start <slug> [--ui] [--patch|--docs] [--merge=<style>] --confirmed`.
|
|
37
|
-
Never grant any of them yourself.
|
|
37
|
+
Never grant any of them yourself. When the operator's own request already
|
|
38
|
+
grants one ("start a docs flow"), that is their word: pass `--confirmed` on
|
|
39
|
+
the first call. After a refusal, only a message sent later counts, so a
|
|
40
|
+
`--confirmed` re-run right away is refused too. Ask once.
|
|
38
41
|
- No merge policy → the gate refuses with `NEEDS-OPERATOR Merge policy?` and a
|
|
39
42
|
suggestion read off the repo's history. Ask: squash, merge, rebase or any.
|
|
40
43
|
The answer is written into `## release` once.
|
package/src/core.ts
CHANGED
|
@@ -58,11 +58,13 @@ export interface FlowState {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/** Tier-2 item: operator prose; uiOnly items ("(ui)" in project.md) apply only to --ui features;
|
|
61
|
-
* versionedOnly items ("(versioned)") presuppose a bump/tag and stand down on a --no-version flow (#166)
|
|
61
|
+
* versionedOnly items ("(versioned)") presuppose a bump/tag and stand down on a --no-version flow (#166);
|
|
62
|
+
* docs items ("(docs)") keep an implement item on a --docs flow, where implement items otherwise stand down (gh#207). */
|
|
62
63
|
export interface ChecklistItem {
|
|
63
64
|
text: string;
|
|
64
65
|
uiOnly: boolean;
|
|
65
66
|
versionedOnly?: boolean;
|
|
67
|
+
docs?: boolean;
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
export interface Commands {
|
|
@@ -128,6 +130,9 @@ export interface Config {
|
|
|
128
130
|
bashTimeout: "require" | "inject";
|
|
129
131
|
/** Operator safety rules from the project.md flow-guard block — stage-independent. */
|
|
130
132
|
guard: GuardRules;
|
|
133
|
+
/** Lines from the ## global `flow-worker` block: every flow_stage brief carries them, so a worker can run the
|
|
134
|
+
* project's checks (e.g. an export of a test password read from a gitignored file) — gh#201. */
|
|
135
|
+
workerPreamble?: string[];
|
|
131
136
|
}
|
|
132
137
|
|
|
133
138
|
export const DEFAULTS: Config = {
|
|
@@ -384,8 +389,8 @@ export function verifyGate(state: FlowState, cfg: Config, branch?: BranchState |
|
|
|
384
389
|
: "nothing committed on the feature branch yet — commit as you go, verify proves a committed state",
|
|
385
390
|
);
|
|
386
391
|
if (!state.docs) for (const c of cfg.checkList) if (!state.checks[c.name]?.ok) errs.push(`check "${c.name}" has not passed — run flow check`);
|
|
387
|
-
const pend =
|
|
388
|
-
if (pend) errs.push(`tier-2 checklist not confirmed
|
|
392
|
+
const pend = openItemsNote(cfg, state, "implement");
|
|
393
|
+
if (pend) errs.push(`tier-2 checklist not confirmed — ${pend}; confirm them with the operator, then run flow verify`);
|
|
389
394
|
return errs;
|
|
390
395
|
}
|
|
391
396
|
|
|
@@ -555,8 +560,8 @@ export function preReleaseGate(state: FlowState, cfg: Config, prep: ReleasePrep)
|
|
|
555
560
|
const errs: string[] = [];
|
|
556
561
|
if (state.stage !== "pre-release") errs.push(`stage is "${state.stage}", the release gate only applies to "pre-release"`);
|
|
557
562
|
if (!state.docs) for (const c of cfg.checkList) if (!state.checks[c.name]?.ok) errs.push(`check "${c.name}" has not passed — run flow check`);
|
|
558
|
-
const pend =
|
|
559
|
-
if (pend) errs.push(`tier-2 checklist not confirmed
|
|
563
|
+
const pend = openItemsNote(cfg, state, "pre-release");
|
|
564
|
+
if (pend) errs.push(`tier-2 checklist not confirmed — ${pend}; confirm them with the operator, then run flow release`);
|
|
560
565
|
if (prep.conflictMarkers?.length && !prep.noMarkerCheck)
|
|
561
566
|
errs.push(`the branch adds ${prep.conflictMarkers.length} merge-conflict marker line(s) — a hand-resolved merge kept them; fix and commit (or, when the lines are meant, re-run with --no-marker-check on the operator's word):\n ${prep.conflictMarkers.slice(0, 5).join("\n ")}${prep.conflictMarkers.length > 5 ? `\n …(${prep.conflictMarkers.length - 5} more)` : ""}`);
|
|
562
567
|
if (state.noVersion) {
|
|
@@ -623,7 +628,7 @@ export function unreleasedPending(content: string): boolean {
|
|
|
623
628
|
|
|
624
629
|
export function checklistHash(items: ChecklistItem[]): string {
|
|
625
630
|
return createHash("sha1")
|
|
626
|
-
.update(items.map((i) => `${i.uiOnly ? "(ui) " : ""}${i.versionedOnly ? "(versioned) " : ""}${i.text}`).join("\n"))
|
|
631
|
+
.update(items.map((i) => `${i.uiOnly ? "(ui) " : ""}${i.versionedOnly ? "(versioned) " : ""}${i.docs ? "(docs) " : ""}${i.text}`).join("\n"))
|
|
627
632
|
.digest("hex")
|
|
628
633
|
.slice(0, 12);
|
|
629
634
|
}
|
|
@@ -658,9 +663,38 @@ export function freshenChecks(state: FlowState, fp: string | null, keep: (name:
|
|
|
658
663
|
return stale;
|
|
659
664
|
}
|
|
660
665
|
|
|
661
|
-
/**
|
|
666
|
+
/** gh#204: what a dev command resolved to. The playbook command prints verbatim (`COMPOSE_PROJECT_NAME=app$DEV_FLOW_SUFFIX`),
|
|
667
|
+
* and on the default port `DEV_FLOW_SUFFIX` is "" — the difference between a private stack and the machine's shared
|
|
668
|
+
* one. Names the DEV_FLOW_* values the command reads and the compose project it lands on; "" when it reads none. */
|
|
669
|
+
export function resolvedDevEnv(cmd: string, env: Record<string, string>): string {
|
|
670
|
+
const esc = (k: string) => k.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
671
|
+
const names = Object.keys(env).filter((k) => k.startsWith("DEV_FLOW_") && new RegExp(`\\$\\{?${esc(k)}(?![A-Za-z0-9_])`).test(cmd));
|
|
672
|
+
let expanded = cmd;
|
|
673
|
+
for (const k of names) {
|
|
674
|
+
const v = env[k];
|
|
675
|
+
expanded = expanded.replace(new RegExp(`\\$\\{${esc(k)}(?::?-[^}]*)?\\}`, "g"), () => v).replace(new RegExp(`\\$${esc(k)}(?![A-Za-z0-9_])`, "g"), () => v);
|
|
676
|
+
}
|
|
677
|
+
const compose = /\bdocker[ -]compose\b/.test(cmd);
|
|
678
|
+
const proj = expanded.match(/\bCOMPOSE_PROJECT_NAME=("[^"]*"|'[^']*'|[^\s;&|]*)/)?.[1] ?? expanded.match(/\bdocker[ -]compose\b[^;&|]*?\s(?:-p|--project-name)[ =]("[^"]*"|'[^']*'|[^\s;&|]+)/)?.[1];
|
|
679
|
+
const parts = names.map((k) => `${k}=${env[k] === "" ? '""' : env[k]}`);
|
|
680
|
+
if (proj !== undefined) parts.push(`compose project ${proj.replace(/^(["'])(.*)\1$/, "$2") || '""'}`);
|
|
681
|
+
else if (compose) parts.push("compose project not set by the command (compose names it after the directory)");
|
|
682
|
+
return parts.length ? `resolved: ${parts.join(", ")}` : "";
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/** Items that apply to this feature — "(ui)" items only when the UI flag is set. A --docs flow skips build,
|
|
686
|
+
* deploy and health at implement, so the implement items that check the running app stand down there too:
|
|
687
|
+
* only the ones tagged "(docs)" apply (gh#207). */
|
|
662
688
|
export function applicableItems(cfg: Config, state: FlowState, stage: string): ChecklistItem[] {
|
|
663
|
-
return (cfg.checklist[stage] ?? []).filter((i) => (!i.uiOnly || state.ui) && (!i.versionedOnly || !state.noVersion));
|
|
689
|
+
return (cfg.checklist[stage] ?? []).filter((i) => (!i.uiOnly || state.ui) && (!i.versionedOnly || !state.noVersion) && (!state.docs || stage !== "implement" || !!i.docs));
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
/** gh#207: an open tier-2 count names its items and where they live — "tier-2 3 open" alone could not be found
|
|
693
|
+
* in project.md (the word "tier-2" is not in it). "" when nothing is open. */
|
|
694
|
+
export function openItemsNote(cfg: Config, state: FlowState, stage: string): string {
|
|
695
|
+
if (!checklistPending(cfg, state, stage)) return "";
|
|
696
|
+
const items = applicableItems(cfg, state, stage);
|
|
697
|
+
return `${items.length} item(s) under ## ${stage} in .dev-flow/project.md: ${items.map((i) => `"${i.text}"`).join(" | ")}`;
|
|
664
698
|
}
|
|
665
699
|
|
|
666
700
|
/** Items exist for the stage and current confirmation does not match their hash; returns pending count or 0. */
|
|
@@ -1763,6 +1797,10 @@ export interface ReflectItem {
|
|
|
1763
1797
|
line: string;
|
|
1764
1798
|
/** the note without checkbox and without the ` — attribution` tail */
|
|
1765
1799
|
body: string;
|
|
1800
|
+
/** gh#197: the row's stable number — its position among every checklist row of the file, open or closed. Checking
|
|
1801
|
+
* an item off leaves every other number where it was, so a batch of `done <n>` read off one list stays paired;
|
|
1802
|
+
* only `tidy` (drops closed rows) and `move` (relocates one) renumber. */
|
|
1803
|
+
n: number;
|
|
1766
1804
|
}
|
|
1767
1805
|
|
|
1768
1806
|
/** Open items of reflections.md, each carrying the heading that owns it. Items above every known
|
|
@@ -1771,6 +1809,7 @@ export interface ReflectItem {
|
|
|
1771
1809
|
export function reflectItems(text: string): ReflectItem[] {
|
|
1772
1810
|
const out: ReflectItem[] = [];
|
|
1773
1811
|
let section: KnownSection | "unfiled" = "unfiled";
|
|
1812
|
+
let row = 0;
|
|
1774
1813
|
for (const raw of text.split("\n")) {
|
|
1775
1814
|
const l = raw.trim();
|
|
1776
1815
|
if (ANY_HEADING.test(l)) {
|
|
@@ -1778,12 +1817,25 @@ export function reflectItems(text: string): ReflectItem[] {
|
|
|
1778
1817
|
section = h ? (h[1].toLowerCase() as KnownSection) : "unfiled";
|
|
1779
1818
|
continue;
|
|
1780
1819
|
}
|
|
1820
|
+
if (isDoneItem(l)) row++;
|
|
1781
1821
|
if (!isOpenItem(l)) continue;
|
|
1782
|
-
out.push({ section, line: l, body: reflectionBody(l) });
|
|
1822
|
+
out.push({ section, line: l, body: reflectionBody(l), n: ++row });
|
|
1783
1823
|
}
|
|
1784
1824
|
return out;
|
|
1785
1825
|
}
|
|
1786
1826
|
|
|
1827
|
+
/** Row `n` of reflections.md (the stable numbering, gh#197): its line index and whether it is still open; null when no such row. */
|
|
1828
|
+
export function reflectRow(text: string, n: number): { index: number; open: boolean; line: string } | null {
|
|
1829
|
+
const lines = text.split("\n");
|
|
1830
|
+
let row = 0;
|
|
1831
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1832
|
+
const open = isOpenItem(lines[i]);
|
|
1833
|
+
if (!open && !isDoneItem(lines[i])) continue;
|
|
1834
|
+
if (++row === n) return { index: i, open, line: lines[i].trim() };
|
|
1835
|
+
}
|
|
1836
|
+
return null;
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1787
1839
|
/** Open items the file does not place in a known section — doctor names the count so a note that
|
|
1788
1840
|
* would once have quietly migrated to `## playbook` on the next write gets moved on purpose. */
|
|
1789
1841
|
export const reflectUnfiledCount = (text: string) => reflectItems(text).filter((i) => i.section === "unfiled").length;
|
|
@@ -1880,37 +1932,25 @@ export function reflectionRoutes(items: ReflectItem[], selfRepo: boolean): Refle
|
|
|
1880
1932
|
});
|
|
1881
1933
|
}
|
|
1882
1934
|
|
|
1883
|
-
/** Move open
|
|
1884
|
-
*
|
|
1885
|
-
*
|
|
1935
|
+
/** Move open row n (the stable numbering `flow reflect list` prints, gh#197) under `## section`. null = no open
|
|
1936
|
+
* row n; an item already in that section comes back unchanged, so the caller can say so instead of pretending
|
|
1937
|
+
* to relocate it. */
|
|
1886
1938
|
export function reflectMove(text: string, n: number, section: ReflectSection): string | null {
|
|
1939
|
+
const row = reflectRow(text, n);
|
|
1940
|
+
if (!row?.open) return null;
|
|
1887
1941
|
const lines = text.split("\n");
|
|
1888
|
-
|
|
1889
|
-
let hit = -1;
|
|
1890
|
-
for (let i = 0; i < lines.length; i++) {
|
|
1891
|
-
if (!isOpenItem(lines[i])) continue;
|
|
1892
|
-
if (++seen === n) {
|
|
1893
|
-
hit = i;
|
|
1894
|
-
break;
|
|
1895
|
-
}
|
|
1896
|
-
}
|
|
1897
|
-
if (hit < 0) return null;
|
|
1898
|
-
const [line] = lines.splice(hit, 1);
|
|
1942
|
+
const [line] = lines.splice(row.index, 1);
|
|
1899
1943
|
return appendReflection(lines.join("\n"), [section], line.trim());
|
|
1900
1944
|
}
|
|
1901
1945
|
|
|
1902
|
-
/** Check open
|
|
1903
|
-
* doctor reads as closed, so a folded item stops re-nagging (#165). null when there is no
|
|
1946
|
+
/** Check open row `n` (the stable `flow reflect list` numbering, gh#197) off: `- [x] … — fixed: <note>` — the
|
|
1947
|
+
* convention doctor reads as closed, so a folded item stops re-nagging (#165). null when there is no open row `n`. */
|
|
1904
1948
|
export function reflectDone(text: string, n: number, note: string): string | null {
|
|
1949
|
+
const row = reflectRow(text, n);
|
|
1950
|
+
if (!row?.open) return null;
|
|
1905
1951
|
const lines = text.split("\n");
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
if (!isOpenItem(lines[i])) continue;
|
|
1909
|
-
if (++seen !== n) continue;
|
|
1910
|
-
lines[i] = `${lines[i].replace(/^(\s*)- \[ \] /, "$1- [x] ").trimEnd()} — fixed: ${note.trim()}`;
|
|
1911
|
-
return lines.join("\n");
|
|
1912
|
-
}
|
|
1913
|
-
return null;
|
|
1952
|
+
lines[row.index] = `${lines[row.index].replace(/^(\s*)- \[ \] /, "$1- [x] ").trimEnd()} — fixed: ${note.trim()}`;
|
|
1953
|
+
return lines.join("\n");
|
|
1914
1954
|
}
|
|
1915
1955
|
|
|
1916
1956
|
/** What `flow doctor <note>` prints: the note is an investigation order, not an answer —
|
|
@@ -2232,7 +2272,10 @@ export function nextHint(state: FlowState, cfg: Config): string {
|
|
|
2232
2272
|
if (state.patch || state.docs) return `${state.patch ? "patch" : "docs"}: describe the change in one line, ask Approve? in chat, then flow approve --confirmed — no plan file${state.docs ? ", no tier-1 checks" : ""}`;
|
|
2233
2273
|
return `clarify the direction in chat, write .dev-flow/${state.slug}/plan/plan.md${state.ui ? ` and render mockups to plan/mockups/ (${cfg.mockupGlobs.join(", ")}) with headless chromium, embedded in plan.md` : ""}, then ask Approve? and run flow approve --confirmed on the answer`;
|
|
2234
2274
|
case "implement":
|
|
2235
|
-
if (state.docs)
|
|
2275
|
+
if (state.docs) {
|
|
2276
|
+
const open = openItemsNote(cfg, state, "implement");
|
|
2277
|
+
return `edit in ${state.worktree} (docs mode: no project commands)${open ? `, go through the checklist with the operator (${open})` : ""}, ask Verified?, then flow verify --confirmed`;
|
|
2278
|
+
}
|
|
2236
2279
|
return `build and test in ${state.worktree}, commit as you go, flow check; then flow verify (deploys for review), look yourself, keep the app running, ask Verified? and run flow verify --confirmed on the answer`;
|
|
2237
2280
|
case "pre-release": {
|
|
2238
2281
|
// gh#198: the release call made with Verified? decides which prep this is
|
|
@@ -2372,6 +2415,8 @@ export interface WorkerBriefInput {
|
|
|
2372
2415
|
commits: string; // `git log --oneline <base>..HEAD`
|
|
2373
2416
|
status: string; // `git status --short`
|
|
2374
2417
|
checks: { name: string; command: string }[];
|
|
2418
|
+
/** the playbook's `flow-worker` lines (gh#201): setup a worker needs before any project check can run */
|
|
2419
|
+
preamble?: string[];
|
|
2375
2420
|
note: string;
|
|
2376
2421
|
}
|
|
2377
2422
|
|
|
@@ -2390,9 +2435,12 @@ export function buildWorkerBrief(o: WorkerBriefInput): string {
|
|
|
2390
2435
|
`- Branch base: ${o.defaultBranch}`,
|
|
2391
2436
|
`- Commits on the branch so far:\n${o.commits.trim() ? o.commits.trim().split("\n").map((l) => ` ${l}`).join("\n") : " (none)"}`,
|
|
2392
2437
|
`- Uncommitted now: ${o.status.trim() ? `\n${o.status.trim().split("\n").map((l) => ` ${l}`).join("\n")}` : "clean"}`,
|
|
2393
|
-
`- Project checks (run them before you report):\n${checks}`,
|
|
2438
|
+
`- Project checks (run them before you report${o.preamble?.length ? ", in a shell that ran the setup below first" : ""}):\n${checks}`,
|
|
2394
2439
|
"- You hold no flow tool: gates, checkpoints and the operator stay with the driving session.",
|
|
2395
2440
|
"",
|
|
2441
|
+
...(o.preamble?.length
|
|
2442
|
+
? ["## Setup (from the project's playbook)", "Run these lines in every shell that runs a project check: each bash call is a fresh shell, so prefix the check with them or chain them with `&&`.", "```sh", ...o.preamble, "```", ""]
|
|
2443
|
+
: []),
|
|
2396
2444
|
"## Your task",
|
|
2397
2445
|
o.note.trim() || "(no note — do what the plan's next unfinished step asks)",
|
|
2398
2446
|
"",
|
|
@@ -2414,6 +2462,7 @@ export function buildWorkerBrief(o: WorkerBriefInput): string {
|
|
|
2414
2462
|
"## Contract",
|
|
2415
2463
|
`- Check, don't fix: read ${o.planFile ? "the plan" : "the task"}, the diff (\`git diff ${o.defaultBranch}...HEAD\`) and the code; run the checks and any probe that proves a claim. Change no files, make no commits.`,
|
|
2416
2464
|
"- Look for correctness bugs, claims in docs/changelog the code does not back, missing tests for risky paths, and plan items not delivered.",
|
|
2465
|
+
"- A project check you could not run (a missing variable, file or service) is not a pass: name it and why under `checks not run:` in the REPORT, and say in the verdict line that the review is read-only for it.",
|
|
2417
2466
|
"- Finish with a final message whose last section starts with a line `REPORT` followed by: `verdict: PASS` or `verdict: FAIL`, then findings (most severe first, each with file:line and how you proved it).",
|
|
2418
2467
|
];
|
|
2419
2468
|
return [...head, ...contract].join("\n");
|
|
@@ -2626,7 +2675,7 @@ export interface ReflectBriefInput {
|
|
|
2626
2675
|
* the operator decides fold or drop per finding in the driving session. */
|
|
2627
2676
|
export function buildReflectBrief(o: ReflectBriefInput): string {
|
|
2628
2677
|
const up = o.upstream || "(unknown — say so in the REPORT)";
|
|
2629
|
-
const open = o.items.length ? o.items.map((it
|
|
2678
|
+
const open = o.items.length ? o.items.map((it) => ` ${it.n}. [${it.section}] ${it.line.replace(/^- \[ \] /, "")}`).join("\n") : " (none)";
|
|
2630
2679
|
const kids = o.children.length ? o.children.map((c) => ` - ${c.file}${c.name ? ` (${c.name})` : ""}`).join("\n") : " (none — no flow_stage worker ran in this session)";
|
|
2631
2680
|
const digests = o.digests?.length ? o.digests.map((d) => ` - ${d.digest} (of ${path.basename(d.transcript)})`).join("\n") : "";
|
|
2632
2681
|
const upIssues = o.upstreamIssues ? (o.upstreamIssues.length ? o.upstreamIssues.map((i) => ` gh#${i.number} [${i.state.toLowerCase()}] ${i.title}`).join("\n") : " (none)") : "";
|
package/src/projectmd.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface ParsedMd {
|
|
|
21
21
|
guard: GuardRules;
|
|
22
22
|
checklist: Record<string, ChecklistItem[]>;
|
|
23
23
|
prose: Record<string, string>;
|
|
24
|
+
/** ## global `flow-worker` block lines — the setup every stage worker's brief carries (gh#201) */
|
|
25
|
+
workerPreamble: string[];
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
// stage → flow-key → config dot-path (aliases); unknown keys warn
|
|
@@ -123,7 +125,7 @@ function parseGuardRules(entries: { line: string; where: string }[], stage: stri
|
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
export function parseProjectMd(text: string): ParsedMd {
|
|
126
|
-
const p: ParsedMd = { hard: [], warn: [], global: {}, flow: Object.fromEntries(MD_STAGES.map((s) => [s, {}])) as Record<MdStage, Record<string, string>>, checks: [], guard: structuredClone(DEFAULTS.guard), checklist: {}, prose: {} };
|
|
128
|
+
const p: ParsedMd = { hard: [], warn: [], global: {}, flow: Object.fromEntries(MD_STAGES.map((s) => [s, {}])) as Record<MdStage, Record<string, string>>, checks: [], guard: structuredClone(DEFAULTS.guard), checklist: {}, prose: {}, workerPreamble: [] };
|
|
127
129
|
let stage: string | null = null;
|
|
128
130
|
const prose: Record<string, string[]> = {};
|
|
129
131
|
let inFence: string | null = null; // "flow" | "flow-check" | other lang
|
|
@@ -192,6 +194,11 @@ export function parseProjectMd(text: string): ParsedMd {
|
|
|
192
194
|
}
|
|
193
195
|
}
|
|
194
196
|
} else if (inFence === "flow-check") checkBody.push(line);
|
|
197
|
+
else if (inFence === "flow-worker") {
|
|
198
|
+
if (stage === "global") {
|
|
199
|
+
if (line.trim()) p.workerPreamble.push(line.trimEnd());
|
|
200
|
+
} else if (line.trim()) p.warn.push(`${where}: flow-worker lines belong to ## global — ignored under ## ${stage ?? "(no stage)"}`);
|
|
201
|
+
}
|
|
195
202
|
else if (inFence === "flow-guard") guardBody.push({ line, where });
|
|
196
203
|
return;
|
|
197
204
|
}
|
|
@@ -204,6 +211,7 @@ export function parseProjectMd(text: string): ParsedMd {
|
|
|
204
211
|
inFence = "flow-check";
|
|
205
212
|
checkName = lang.slice("flow-check".length).trim();
|
|
206
213
|
} else if (lang === "flow-guard") inFence = "flow-guard";
|
|
214
|
+
else if (lang === "flow-worker") inFence = "flow-worker";
|
|
207
215
|
else inFence = lang || "code";
|
|
208
216
|
return;
|
|
209
217
|
}
|
|
@@ -216,16 +224,19 @@ export function parseProjectMd(text: string): ParsedMd {
|
|
|
216
224
|
if (!stage || stage === "global" || !MD_STAGES.includes(stage as MdStage)) return; // preamble/unknown → not injected
|
|
217
225
|
const item = line.match(CHECK_ITEM);
|
|
218
226
|
if (item) {
|
|
219
|
-
// qualifiers lead the item in any order: (ui) = --ui features only, (versioned) = not on a --no-version flow
|
|
227
|
+
// qualifiers lead the item in any order: (ui) = --ui features only, (versioned) = not on a --no-version flow,
|
|
228
|
+
// (docs) = an implement item that still applies on a --docs flow (gh#207)
|
|
220
229
|
let text = item[1].trim();
|
|
221
230
|
let uiOnly = false;
|
|
222
231
|
let versionedOnly = false;
|
|
223
|
-
|
|
232
|
+
let docs = false;
|
|
233
|
+
for (let q = /^\((ui|versioned|docs)\)\s+/.exec(text); q; q = /^\((ui|versioned|docs)\)\s+/.exec(text)) {
|
|
224
234
|
if (q[1] === "ui") uiOnly = true;
|
|
235
|
+
else if (q[1] === "docs") docs = true;
|
|
225
236
|
else versionedOnly = true;
|
|
226
237
|
text = text.slice(q[0].length);
|
|
227
238
|
}
|
|
228
|
-
(p.checklist[stage] ??= []).push(
|
|
239
|
+
(p.checklist[stage] ??= []).push({ text, uiOnly, ...(versionedOnly ? { versionedOnly } : {}), ...(docs ? { docs } : {}) });
|
|
229
240
|
return;
|
|
230
241
|
}
|
|
231
242
|
if (/^(#|```|<!--|\s*$)/.test(line) && !line.startsWith("### ")) return; // h1/html comments/blank are not prose
|
|
@@ -262,6 +273,7 @@ export function mdToConfig(p: ParsedMd): Config {
|
|
|
262
273
|
];
|
|
263
274
|
c.checklist = p.checklist;
|
|
264
275
|
c.prose = p.prose;
|
|
276
|
+
if (p.workerPreamble.length) c.workerPreamble = [...p.workerPreamble];
|
|
265
277
|
return c;
|
|
266
278
|
}
|
|
267
279
|
|
|
@@ -552,6 +564,7 @@ export function mdDigest(text: string): string {
|
|
|
552
564
|
if (s === "global") {
|
|
553
565
|
const rules = (["deny", "confirm", "protect", "forbid"] as const).flatMap((v) => p.guard[v].map((r) => `${v} ${r.pattern}`));
|
|
554
566
|
if (rules.length) bits.push(`safety rules: ${rules.join(" · ")}`);
|
|
567
|
+
if (p.workerPreamble.length) bits.push(`stage-worker setup: ${p.workerPreamble.length} line(s) in every flow_stage brief`);
|
|
555
568
|
}
|
|
556
569
|
if (relStage && keys.file) {
|
|
557
570
|
bits.push(`version in ${keys.file} → tag ${keys.pattern ?? "v{version}"}`);
|
|
@@ -560,7 +573,7 @@ export function mdDigest(text: string): string {
|
|
|
560
573
|
}
|
|
561
574
|
if (s === "pre-release" && !keys.file && !p.flow.release["versioning.file"]) bits.push("version: no version file set — releases cannot bump or tag");
|
|
562
575
|
const items = p.checklist[s] ?? [];
|
|
563
|
-
if (items.length) bits.push(`manual check: ${items.map((i) => `${i.uiOnly ? "(UI only) " : ""}${i.versionedOnly ? "(versioned only) " : ""}\"${i.text}\"`).join(" · ")}`);
|
|
576
|
+
if (items.length) bits.push(`manual check: ${items.map((i) => `${i.uiOnly ? "(UI only) " : ""}${i.versionedOnly ? "(versioned only) " : ""}${i.docs ? "(docs flows too) " : ""}\"${i.text}\"`).join(" · ")}`);
|
|
564
577
|
if (p.prose[s]) bits.push(`guidance: "${p.prose[s].replace(/\s+/g, " ").trim()}"`);
|
|
565
578
|
if (bits.length) rows.push(`${label} — ${bits.join(" · ")}`);
|
|
566
579
|
}
|
package/src/runtime/gates.ts
CHANGED
|
@@ -273,6 +273,12 @@ export async function gateInit(o: GateCtx): Promise<RunResult> {
|
|
|
273
273
|
return { text: notes.join("\n") };
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
+
/** gh#206: an operator-granted refusal states the rule that makes an immediate --confirmed re-run useless
|
|
277
|
+
* (gh#190 binds only a message that postdates the ask), so the agent asks once instead of burning a call
|
|
278
|
+
* to learn it — and says what to do next time the operator's own request carries the grant. */
|
|
279
|
+
export const GRANT_AFTER =
|
|
280
|
+
"ask the operator in chat and stop; re-run with --confirmed once they reply. Only an operator message sent after this refusal counts, so a grant given before it (even in the request that started this) must be asked again, and an immediate re-run is refused. When the operator's own request already grants it, pass --confirmed on the first call";
|
|
281
|
+
|
|
276
282
|
export async function gateStart(o: GateCtx): Promise<RunResult> {
|
|
277
283
|
const { root, sess, cfg, rest, flag, slugArg } = o;
|
|
278
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 };
|
|
@@ -299,7 +305,7 @@ export async function gateStart(o: GateCtx): Promise<RunResult> {
|
|
|
299
305
|
// proof at approve and every (ui) checklist item (lettuce rail-ui-fixes shipped 20 ungated mockups)
|
|
300
306
|
const existing = readState(root, slugArg);
|
|
301
307
|
if (flag("ui") && existing && sess.slug === slugArg) {
|
|
302
|
-
if (!flag("confirmed")) return { text:
|
|
308
|
+
if (!flag("confirmed")) return { text: `--ui is operator-granted — it adds a rendered-mockup requirement to the plan gate; ${GRANT_AFTER}`, isError: true };
|
|
303
309
|
if (existing.ui) return { text: `feature ${slugArg} already has the ui flag` };
|
|
304
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 };
|
|
305
311
|
writeState(root, { ...existing, ui: true });
|
|
@@ -313,9 +319,9 @@ export async function gateStart(o: GateCtx): Promise<RunResult> {
|
|
|
313
319
|
// every grant start needs goes into one question: a refusal for one names the others still open, so
|
|
314
320
|
// the operator answers mode, mockups and merge policy in a single message
|
|
315
321
|
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` : "";
|
|
316
|
-
if (mode && !flag("confirmed")) return { text: `${mode} mode is operator-granted —
|
|
322
|
+
if (mode && !flag("confirmed")) return { text: `${mode} mode is operator-granted — ${GRANT_AFTER}${alsoMerge}`, isError: true };
|
|
317
323
|
// --ui adds the rendered-mockup gate to plan: worth it only when screens change, and the operator says so
|
|
318
|
-
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;
|
|
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 };
|
|
319
325
|
// branch discipline: features branch off the default branch — starting from a stale checkout poisons the base
|
|
320
326
|
const curBr = await currentBranch(root);
|
|
321
327
|
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 };
|
|
@@ -605,7 +611,7 @@ export async function gateDoctor(o: GateCtx): Promise<RunResult> {
|
|
|
605
611
|
findings.push(` [${r.sections.join("+")}] ${r.text}${link ? linkedTag(link.issue) : ""}\n → ${r.route}${link ? ` — already upstream (gh#${link.issue}); check off with — filed: gh#${link.issue} once it lands` : ""}`);
|
|
606
612
|
});
|
|
607
613
|
}
|
|
608
|
-
findings.push(...foldRows(fold, isSelfRepo(root)));
|
|
614
|
+
findings.push(...foldRows(fold, isSelfRepo(root), refl));
|
|
609
615
|
const reflText = readReflectionsText(root);
|
|
610
616
|
const unfiled = reflectUnfiledCount(reflText);
|
|
611
617
|
if (unfiled) findings.push(` reflections: ${unfiled} open item(s) sit outside ## playbook / ## code — flow reflect list shows them, flow reflect move <n> --playbook|--code files them`);
|
package/src/runtime/grants.ts
CHANGED
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
* B. a feature started in this session gets a mode flag (--ui/--patch/--docs) granted with --confirmed
|
|
9
9
|
* before any operator message arrived after the start.
|
|
10
10
|
*
|
|
11
|
+
* --confirmed is not the only answer a gate takes: `Dev port?` is answered with --replace or --port=<n>
|
|
12
|
+
* (gh#203), and those bind the same way — a re-run of the gate that asked, carrying any of them, needs
|
|
13
|
+
* an operator message after the question.
|
|
14
|
+
*
|
|
11
15
|
* It never decides what the operator meant — one message after the question is all it asks for. A
|
|
12
16
|
* session it cannot read (no session manager) is not checked. Pure module: no pi imports. */
|
|
13
17
|
import { NEEDS_OPERATOR } from "../core.ts";
|
|
@@ -35,16 +39,22 @@ export const newGrantLedger = (): GrantLedger => ({ asked: new Map(), started: n
|
|
|
35
39
|
|
|
36
40
|
const ASKS_FOR_WORD = /operator-granted|operator's (?:explicit )?word|the operator must grant/;
|
|
37
41
|
const MODE_FLAGS = ["--ui", "--patch", "--docs"];
|
|
42
|
+
/** Flags that carry the operator's answer to the question a gate asked — `--confirmed`, and the
|
|
43
|
+
* `Dev port?` answers (gh#203). */
|
|
44
|
+
export function answerFlags(args: readonly string[]): string[] {
|
|
45
|
+
return args.filter((a) => a === "--confirmed" || a === "--replace" || a.startsWith("--port="));
|
|
46
|
+
}
|
|
38
47
|
const slugOf = (args: readonly string[]) => args.slice(1).find((a) => !a.startsWith("--")) ?? "";
|
|
39
48
|
|
|
40
49
|
/** The refusal for a `--confirmed` no operator message stands behind, or null when the call may run. */
|
|
41
50
|
export function grantCheck(args: readonly string[], key: string, users: number | null, ledger: GrantLedger): string | null {
|
|
42
|
-
|
|
51
|
+
const answers = answerFlags(args);
|
|
52
|
+
if (users === null || !answers.length) return null;
|
|
43
53
|
const sub = args[0] ?? "";
|
|
44
54
|
const asked = ledger.asked.get(key);
|
|
45
55
|
if (asked && asked.sub === sub && users <= asked.users)
|
|
46
|
-
return `${NEEDS_OPERATOR} no operator message since flow ${sub} asked for their word —
|
|
47
|
-
if (sub === "start" && args.some((a) => MODE_FLAGS.includes(a))) {
|
|
56
|
+
return `${NEEDS_OPERATOR} no operator message since flow ${sub} asked for their word — ${answers.join(" ")} records the operator's answer in chat, it is not yours to give. A word given before the question does not count, so re-running now is refused again: ask in chat, stop, and re-run once they reply (gh#190)`;
|
|
57
|
+
if (sub === "start" && args.includes("--confirmed") && args.some((a) => MODE_FLAGS.includes(a))) {
|
|
48
58
|
const at = ledger.started.get(`${key}\u0000${slugOf(args)}`);
|
|
49
59
|
if (at !== undefined && users <= at)
|
|
50
60
|
return `${NEEDS_OPERATOR} ${args.filter((a) => MODE_FLAGS.includes(a)).join(" ")} on ${slugOf(args)} is operator-granted, and the operator has said nothing since it started — ask them in chat whether to turn it on, stop, and re-run with --confirmed once they reply (gh#190)`;
|
package/src/runtime/reflect.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** dev-flow runtime — Reflections and the upstream issue fold. Moved out of extensions/dev-flow.ts as is (exports added). */
|
|
2
2
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { appendReflection, doneItemCount, githubSlug, pluginVersion, guessReflectSections, reflectItems, reflectMove, reflectDone, reflectLegacyPluginCount, reflectionNudges, pluginIssueRecipe, reflectionLine, reflectionsTidy, openChecklistItems, type ReflectTarget, type ReflectItem, type ReflectSection } from "../core.ts";
|
|
4
|
+
import { appendReflection, doneItemCount, githubSlug, pluginVersion, guessReflectSections, reflectItems, reflectMove, reflectDone, reflectRow, reflectLegacyPluginCount, reflectionNudges, pluginIssueRecipe, reflectionLine, reflectionsTidy, openChecklistItems, type ReflectTarget, type ReflectItem, type ReflectSection } from "../core.ts";
|
|
5
5
|
import { dedupeReflections, linkedTag, parseGhIssues, similarNote, type FoldResult, type GhIssue } from "../fold.ts";
|
|
6
6
|
import { dfDir, now, originUrl, readReflections, readReflectionsText, sh } from "./base.ts";
|
|
7
7
|
import { type RunResult, type Session } from "./checks.ts";
|
|
@@ -70,13 +70,13 @@ export async function foldView(root: string, items: ReflectItem[]): Promise<Fold
|
|
|
70
70
|
/** The fold block shared by flow doctor and flow reflect list: header, one row per unmatched
|
|
71
71
|
* issue with its route, then the unmerged near-miss hints. Local rows carry their ⟷ gh#N tag
|
|
72
72
|
* at the call site — the fold lists upstream items, it never re-numbers the local queue. */
|
|
73
|
-
export function foldRows(fold: FoldView, selfRepo: boolean): string[] {
|
|
73
|
+
export function foldRows(fold: FoldView, selfRepo: boolean, items: readonly ReflectItem[] = []): string[] {
|
|
74
74
|
if (fold.state === "absent") return [];
|
|
75
75
|
if (fold.state === "skipped") return [`upstream issues: skipped (${fold.why})`];
|
|
76
76
|
if (!fold.open) return [];
|
|
77
77
|
const rows = [`upstream on ${fold.slug} — ${fold.open} open issue(s) on GitHub (canonical there — close on GitHub, never here; this is a fold, not a copy):`];
|
|
78
78
|
for (const i of fold.result.upstreamOnly) rows.push(` gh#${i.number} ${i.title} → ${selfRepo ? "fix in a flow here (patch flow if small)" : "fix in a flow here, or close won't-fix on GitHub"}`);
|
|
79
|
-
for (const s of fold.result.similar) rows.push(` ${similarNote(s, s.item + 1)}`);
|
|
79
|
+
for (const s of fold.result.similar) rows.push(` ${similarNote(s, items[s.item]?.n ?? s.item + 1)}`);
|
|
80
80
|
return rows;
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -88,16 +88,16 @@ export async function reflectList(root: string): Promise<RunResult> {
|
|
|
88
88
|
const fold = await foldView(root, items);
|
|
89
89
|
const local = items.length
|
|
90
90
|
? [
|
|
91
|
-
`reflections — ${items.length} open:`,
|
|
91
|
+
`reflections — ${items.length} open (numbers are row numbers: checking one off leaves the others as they are; tidy and move renumber):`,
|
|
92
92
|
...items.map((it, i) => {
|
|
93
93
|
const link = fold.state === "ok" ? fold.result.linked.find((l) => l.item === i) : undefined;
|
|
94
|
-
return ` ${
|
|
94
|
+
return ` ${it.n}. [${it.section}] ${it.line.replace(/^- \[ \] /, "")}${link ? linkedTag(link.issue) : ""}`;
|
|
95
95
|
}),
|
|
96
96
|
]
|
|
97
97
|
: fold.state === "absent" || fold.state === "skipped"
|
|
98
98
|
? ["reflections: nothing open"]
|
|
99
99
|
: ["reflections: nothing open locally"];
|
|
100
|
-
return { text: [...local, ...legacyPluginRows(readReflectionsText(root), isSelfRepo(root)), ...foldRows(fold, isSelfRepo(root))].join("\n") };
|
|
100
|
+
return { text: [...local, ...legacyPluginRows(readReflectionsText(root), isSelfRepo(root)), ...foldRows(fold, isSelfRepo(root), items)].join("\n") };
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
/** Open rows still under the legacy `## plugin` heading: they belong on GitHub, not in a project's queue. */
|
|
@@ -121,30 +121,42 @@ export function reflectMoveNote(root: string, args: string[], forced: ReflectTar
|
|
|
121
121
|
const n = Number(args[0]);
|
|
122
122
|
const text = readReflectionsText(root);
|
|
123
123
|
const items = reflectItems(text);
|
|
124
|
-
|
|
125
|
-
if (
|
|
124
|
+
const it = items.find((x) => x.n === n);
|
|
125
|
+
if (!it) return { text: `move: ${noOpenRow(text, n, items)}`, isError: true };
|
|
126
|
+
if (it.section === section) return { text: `reflect: item ${n} is already under ## ${section}` };
|
|
126
127
|
// the same note open under both headings (an old --both filing): the move merges it, it does not copy it
|
|
127
|
-
const twin = items.some((
|
|
128
|
+
const twin = items.some((x) => x !== it && x.section === section && x.body === it.body);
|
|
128
129
|
const next = reflectMove(text, n, section);
|
|
129
|
-
if (next === null) return { text: `move:
|
|
130
|
+
if (next === null) return { text: `move: ${noOpenRow(text, n, items)}`, isError: true };
|
|
130
131
|
writeFileSync(path.join(dfDir(root), "reflections.md"), next);
|
|
131
|
-
const note =
|
|
132
|
-
return { text: twin ? `reflect: item ${n} was already recorded under ## ${section} — the duplicate is gone (${note})` : `reflect: item ${n} re-filed under ## ${section} — ${note}` };
|
|
132
|
+
const note = it.line.replace(/^- \[ \] /, "");
|
|
133
|
+
return { text: `${twin ? `reflect: item ${n} was already recorded under ## ${section} — the duplicate is gone (${note})` : `reflect: item ${n} re-filed under ## ${section} — ${note}`}\n${RENUMBERED}` };
|
|
133
134
|
}
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
const RENUMBERED = "the row numbers changed — run flow reflect list before the next done or move";
|
|
137
|
+
|
|
138
|
+
/** Why `<n>` names no open row (gh#197): a row already checked off says which note it holds, so a batch that
|
|
139
|
+
* drifted shows the mismatch instead of closing the wrong line. */
|
|
140
|
+
function noOpenRow(text: string, n: number, items: readonly ReflectItem[]): string {
|
|
141
|
+
const row = Number.isInteger(n) && n > 0 ? reflectRow(text, n) : null;
|
|
142
|
+
if (row && !row.open) return `item ${n} is already checked off (${row.line.replace(/^-\s*\[[xX]\]\s*/, "")}) — flow reflect list shows the open ones`;
|
|
143
|
+
return items.length ? `no open item ${n} — open: ${items.map((i) => i.n).join(", ")} (flow reflect list numbers them)` : "nothing open in reflections.md";
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** `flow reflect done <n> [what fixed it]` — check a folded/fixed item off, so doctor stops re-reporting it (#165).
|
|
147
|
+
* `<n>` is the stable row number (gh#197): closing one leaves every other number where `list` printed it. */
|
|
136
148
|
export function reflectDoneNote(root: string, sess: Session, args: string[]): RunResult {
|
|
137
149
|
const text = readReflectionsText(root);
|
|
138
150
|
const items = reflectItems(text);
|
|
139
151
|
const n = Number(args[0]);
|
|
140
|
-
|
|
141
|
-
|
|
152
|
+
const it = items.find((x) => x.n === n);
|
|
153
|
+
if (!it) return { text: `done: ${noOpenRow(text, n, items)}`, isError: true };
|
|
142
154
|
const stamp = [now().slice(0, 10), sess.slug].filter(Boolean).join(" ");
|
|
143
155
|
const what = args.slice(1).join(" ").trim();
|
|
144
156
|
const next = reflectDone(text, n, what ? `${stamp} — ${what}` : stamp)!;
|
|
145
157
|
writeFileSync(path.join(dfDir(root), "reflections.md"), next);
|
|
146
158
|
const { tidy } = reflectionNudges(next, now().slice(0, 10));
|
|
147
|
-
return { text: `reflect: item ${n} checked off — ${
|
|
159
|
+
return { text: `reflect: item ${n} checked off — ${it.body}${what ? ` — fixed: ${what}` : ""}` + (tidy ? `\n${tidy}` : "") };
|
|
148
160
|
}
|
|
149
161
|
|
|
150
162
|
/** `flow reflect tidy` — drop the closed (`- [x]`) items; the `— fixed:` note already recorded the outcome. */
|
|
@@ -156,5 +168,5 @@ export function reflectTidy(root: string): RunResult {
|
|
|
156
168
|
const open = openChecklistItems(text).length;
|
|
157
169
|
if (!closed) return { text: `reflections: nothing to tidy (${open} open, 0 closed)` };
|
|
158
170
|
writeFileSync(file, reflectionsTidy(text));
|
|
159
|
-
return { text: `reflections: dropped ${closed} closed item(s) — ${open} open` };
|
|
171
|
+
return { text: `reflections: dropped ${closed} closed item(s) — ${open} open; ${RENUMBERED}` };
|
|
160
172
|
}
|
package/src/runtime/ship.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** dev-flow runtime — The gates that ship: verify, release, release-done, finish. Moved out of extensions/dev-flow.ts as is (exports added). */
|
|
2
2
|
import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { applicableItems, changelogVersionsBetween, normalizeReleaseBody, pendingEntryLines, pickReleaseNotes, checklistHash, checklistPending, cmpVersions, freshenChecks, healthProbe, mergeShapeProof, preReleaseGate, reflectionNudges, conflictMarkerLines, isReleaseOnly, looksLikeShellError, needsOperator, newestTaggedVersion, nextHint, releaseGate, parseVersion, roadmapDoneForSlug, sq, tagNotesCommand, verifyGate, versionTagGate, servedBuildMatches, versionArg, playbookVersionChoice, describeVersionChoice, majorBump, bumpVersion, isBumpKind } from "../core.ts";
|
|
4
|
+
import { applicableItems, changelogVersionsBetween, normalizeReleaseBody, pendingEntryLines, pickReleaseNotes, checklistHash, checklistPending, cmpVersions, freshenChecks, healthProbe, mergeShapeProof, preReleaseGate, reflectionNudges, conflictMarkerLines, isReleaseOnly, looksLikeShellError, needsOperator, newestTaggedVersion, nextHint, releaseGate, parseVersion, roadmapDoneForSlug, sq, tagNotesCommand, verifyGate, versionTagGate, servedBuildMatches, versionArg, playbookVersionChoice, describeVersionChoice, majorBump, bumpVersion, isBumpKind, resolvedDevEnv } from "../core.ts";
|
|
5
5
|
import type { Config, FlowState } from "../core.ts";
|
|
6
6
|
import { AGENT_MARK } from "../present.ts";
|
|
7
7
|
import { buildSkew, copyWarning, currentBranch, featDir, flagValue, forgeMergeStyle, forgeOf, gateCwd, mergeBase, needState, now, originUrl, readReflectionsText, readRoadmap, readState, releaseTags, roadmapFile, sh, tail, worktreeAbs, writeState } from "./base.ts";
|
|
@@ -70,11 +70,14 @@ export async function gateVerify(o: GateCtx): Promise<RunResult> {
|
|
|
70
70
|
// deploy to dev before asking — the operator reviews the running dev app, not a promise
|
|
71
71
|
const probe = healthProbe(cfg);
|
|
72
72
|
if (cfg.commands.dev) {
|
|
73
|
-
const
|
|
73
|
+
const env = devEnv(root, state!, cfg);
|
|
74
|
+
const res = await sh(cfg.commands.dev, gateCwd(root, state!), undefined, env);
|
|
74
75
|
state!.checks.dev = { ok: res.ok, at: now() };
|
|
75
76
|
writeState(root, state!);
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
// gh#204: the command prints as the playbook wrote it — say what its $DEV_FLOW_* and compose project resolved to
|
|
78
|
+
const resolved = resolvedDevEnv(cfg.commands.dev, env);
|
|
79
|
+
if (!res.ok) return { text: `dev deploy FAILED (${cfg.commands.dev})${resolved ? ` — ${resolved}` : ""}:\n${tail(res.out)}`, isError: true };
|
|
80
|
+
did.push(`dev ran (${cfg.commands.dev})${devPortOf(state!, cfg) !== undefined ? ` on port ${devPortOf(state!, cfg)}` : ""}${resolved ? ` — ${resolved}` : ""}`);
|
|
78
81
|
// the deploy is what must be proven, not just run: a container that came back unhealthy, or
|
|
79
82
|
// still serves the previous build, must not pass on a health PASS recorded before it was
|
|
80
83
|
// recreated. What "the expected version" means is the project's business — the probe runs in
|
|
@@ -618,8 +621,20 @@ export async function gateFinish(o: GateCtx): Promise<RunResult> {
|
|
|
618
621
|
if (err || !state || state.approvals.release || state.stage !== "release" || !state.approvals["pre-release"]) return gateFinishCore(o);
|
|
619
622
|
const rec = await gateReleaseDone({ ...o, rest: o.rest.filter((a) => a !== "--confirmed" && a !== "--yolo") });
|
|
620
623
|
if (rec.isError) return rec;
|
|
621
|
-
const fin = await gateFinishCore(o);
|
|
622
624
|
const recorded = rec.text.split("\n").filter((l) => !l.startsWith(AGENT_MARK)).join("\n");
|
|
625
|
+
// gh#205: release-stage items (a post-merge build, a deploy check from the default branch) are work done after
|
|
626
|
+
// the merge. A separate release-done names them while the worktree still stands; folded into finish, one
|
|
627
|
+
// call recorded the release and removed everything, so an unversioned flow never saw them. Stop once here.
|
|
628
|
+
const cur = readState(o.root, state.slug) ?? state;
|
|
629
|
+
if (checklistPending(o.cfg, cur, "release")) {
|
|
630
|
+
markPendingAsk(o.root, cur, "Finish?");
|
|
631
|
+
const items = applicableItems(o.cfg, cur, "release").map((i) => `"${i.text}"`).join(" | ");
|
|
632
|
+
return {
|
|
633
|
+
text: `${recorded}\n\n${needsOperator(`release recorded — nothing was removed yet: the release-stage checklist (## release in .dev-flow/project.md) is still open: ${items}`, "Finish?", `do each release-stage item now (they run after the merge, from ${o.cfg.defaultBranch} — not the worktree), tell the operator what each showed, then ask Finish? and run flow finish --confirmed when they answer`)}`,
|
|
634
|
+
isError: true,
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
const fin = await gateFinishCore(o);
|
|
623
638
|
return { ...fin, text: `${recorded}\n\n${fin.text}` };
|
|
624
639
|
}
|
|
625
640
|
|
|
@@ -724,7 +739,9 @@ export async function gateFinishCore(o: GateCtx): Promise<RunResult> {
|
|
|
724
739
|
if (askPending) {
|
|
725
740
|
markPendingAsk(root, state!, "Finish?");
|
|
726
741
|
if (!ui.hasUI) {
|
|
727
|
-
|
|
742
|
+
// the Finish? answer is what closes the release-stage items: name them in the question it asks
|
|
743
|
+
const openRelease = checklistPending(cfg, state!, "release") ? ` Release-stage checklist to close with this answer: ${applicableItems(cfg, state!, "release").map((i) => `"${i.text}"`).join(" | ")}.` : "";
|
|
744
|
+
return { text: needsOperator(`cleanup removes the worktree, branch and feature folder.${openRelease}${quietNote}${forgeSkipNote}`, "Finish?", "ask the operator Finish? in chat, then re-run with --confirmed"), isError: true };
|
|
728
745
|
}
|
|
729
746
|
const ok = await ui.confirm("Finish feature", `Finish ${state!.slug}?${unmergedNote}${forgeSkipNote} Removes worktree, branch ${state!.branch || "-"} and .dev-flow/${state!.slug}/.`);
|
|
730
747
|
if (!ok) {
|