pi-dev-flow 0.80.0 → 0.82.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 +24 -0
- package/README.md +3 -1
- package/docs/gates.md +3 -3
- package/docs/playbook.md +1 -1
- package/extensions/dev-flow.ts +77 -23
- package/package.json +1 -1
- package/skills/dev-flow/references/implement.md +13 -5
- package/skills/dev-flow/references/plan.md +9 -1
- package/skills/dev-flow/references/reflect.md +7 -0
- package/skills/dev-flow/references/start.md +3 -1
- package/src/core.ts +98 -7
- package/src/projectmd.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,30 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.82.0] - 2026-11-05
|
|
8
|
+
|
|
9
|
+
**A feature split off mid-flow is parked in the roadmap with its notes, and a hand-made feature dir can be adopted instead of deleted.**
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- **A feature split off mid-flow no longer ends up as an unpickable ghost.** An agent asked for "a separate flow" wrote `.dev-flow/<new>/plan/` by hand; the next session's `flow start` said it already existed, `flow use` found no state, and doctor offered to delete it. A bound session can no longer write another feature's dir or a hand-made `<x>/plan/` (the refusal names the roadmap route); `flow start <slug> --confirmed` adopts an existing ghost and keeps its plan files; `flow use` on a ghost points there.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- **Roadmap spin-offs carry a brief.** `flow roadmap add "<title>" --slug=<slug> --brief=<notes>` (or `--brief-file=<path>`) adds and stamps the item in one call, records `— split from <bound slug>`, and keeps the notes under it as quoted lines. `flow start <slug>` seeds `plan/plan.md` with the item and brief. Tidy removes a done item's brief with it.
|
|
16
|
+
|
|
17
|
+
## [0.81.0] - 2026-11-04
|
|
18
|
+
|
|
19
|
+
**Temp-dir fixtures stay outside the repo for git; a UI flag can be added at plan; compaction keeps the real stage.**
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
- **Tests that make temp dirs no longer find the enclosing repo under dev-flow.** Since 0.79.0 a bound feature's commands run with `TMPDIR` in `.dev-flow/<slug>/tmp/`, inside the checkout, so git walked up out of a test's `mkdtemp` fixture and answered with the project's repo; a suite asserting "no repository here" failed only under the gates. That dir is now also the commands' `GIT_CEILING_DIRECTORIES` (an inherited list is kept).
|
|
23
|
+
- **The "this session runs an older dev-flow" warning named the versions backwards** in projects that install dev-flow: after an in-place update it said the session ran the new build and the install shipped the old one. The loaded version is now the one read at load, and the shipped one is read fresh.
|
|
24
|
+
- **A flow-aware compaction can no longer carry a stale stage forward.** Its summary ends with a block written from `state.json` (stage, approvals, checks, next) that says it outranks the prose above it; one pre-release summary had still said "implement, next: flow verify".
|
|
25
|
+
- **An implement worker sharing a dirty worktree is told the uncommitted paths are the driver's**: commit only its own paths by name, never `git add -A` / `commit -a`.
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
- `flow start <slug> --ui --confirmed` on the plan-stage feature this session drives switches the mockup gate on instead of refusing with "already exists". Past plan it refuses, and a plain re-start names `flow use`.
|
|
29
|
+
- The approve gate refuses a mockup that links another feature's worktree (href, src or `@import`); at plan, link the main checkout's stylesheet.
|
|
30
|
+
|
|
7
31
|
## [0.80.0] - 2026-11-03
|
|
8
32
|
|
|
9
33
|
**A reflection that runs out of time still hands back its findings; release-only flows pass verify.**
|
package/README.md
CHANGED
|
@@ -253,7 +253,9 @@ While a feature is active, every tool call passes a guard:
|
|
|
253
253
|
```
|
|
254
254
|
|
|
255
255
|
`roadmap.md` is your backlog of future features (`flow roadmap add / pick / done`), also advisory — a
|
|
256
|
-
shipped feature checks off the item it was picked from.
|
|
256
|
+
shipped feature checks off the item it was picked from. A new feature that comes up mid-flow is parked
|
|
257
|
+
there as a spin-off (`flow roadmap add "<title>" --slug=<slug> --brief=<notes>`); `flow start <slug>`
|
|
258
|
+
later seeds its plan from the brief.
|
|
257
259
|
|
|
258
260
|
## Documentation
|
|
259
261
|
|
package/docs/gates.md
CHANGED
|
@@ -9,9 +9,9 @@ so it needs no `--confirmed`.
|
|
|
9
9
|
|
|
10
10
|
| Gate | Advances | Refuses unless |
|
|
11
11
|
|---|---|---|
|
|
12
|
-
| `start <slug> [--ui|--patch|--docs --confirmed] [--merge=squash\|merge\|rebase\|any] [--check-upstream]` | → plan | slug is new (binds the session); `--ui` and the relaxed modes are operator-granted in chat, anchored by `--confirmed` (`--ui` = the plan gate demands rendered mockups); `--patch` = chore release, no plan document, every gate unchanged; `--docs` = docs-only, no plan document and no tier-1 checks (worktree and release intact). Start prints the dev-flow build and stamps it into the feature state (`flow status` shows `flow=<ver>`), warns when **this session runs an older build than the checkout** (`--check-upstream` also asks npm for the published one), prints the playbook gaps `flow doctor` would report — and **refuses while the playbook has no `merge` policy**: it names the question (squash / merge / rebase / any), the style its own history suggests, and the re-run `--merge=<style> --confirmed`, which writes the answer into `## release` (single-line insert, validated, `.bak` kept, committed as a playbook chore only when the playbook is the only dirty path) and never asks again |
|
|
12
|
+
| `start <slug> [--ui|--patch|--docs --confirmed] [--merge=squash\|merge\|rebase\|any] [--check-upstream]` | → plan | slug is new (binds the session); `--ui` and the relaxed modes are operator-granted in chat, anchored by `--confirmed` (`--ui` = the plan gate demands rendered mockups; on an existing feature still at plan, `start <slug> --ui --confirmed` from its bound session switches the flag on instead of refusing); `--patch` = chore release, no plan document, every gate unchanged; `--docs` = docs-only, no plan document and no tier-1 checks (worktree and release intact). Start prints the dev-flow build and stamps it into the feature state (`flow status` shows `flow=<ver>`), warns when **this session runs an older build than the checkout** (`--check-upstream` also asks npm for the published one), prints the playbook gaps `flow doctor` would report — and **refuses while the playbook has no `merge` policy**: it names the question (squash / merge / rebase / any), the style its own history suggests, and the re-run `--merge=<style> --confirmed`, which writes the answer into `## release` (single-line insert, validated, `.bak` kept, committed as a playbook chore only when the playbook is the only dirty path) and never asks again |
|
|
13
13
|
| `use <slug>` | — (binds this session to a feature) | slug unfinished — the binding is persisted to disk as a claim (`flow version` lists every dev-flow copy registered in the process, and a copy whose in-memory bindings never saw the bind attributes commands from the claim, so a two-sources setup does not misjudge your git) |
|
|
14
|
-
| `approve [--yolo]` | plan → implement (creates worktree + branch) | `plan/plan.md` exists **by name** (a separate pre-plan/direction file does not open the gate — a preliminary direction belongs inside plan.md); if `--ui`, rendered mockup screenshots (per `mockupGlobs`, default `*.png`) exist under `plan/` — headless chromium renders embedded in plan.md, and the gate opens plan.md to prove it: every image file under `plan/` must appear in an embed (``, case-insensitive) and every `mockups/<screen>.html` must carry an embedded `<screen>-<width>.` shot
|
|
14
|
+
| `approve [--yolo]` | plan → implement (creates worktree + branch) | `plan/plan.md` exists **by name** (a separate pre-plan/direction file does not open the gate — a preliminary direction belongs inside plan.md); if `--ui`, rendered mockup screenshots (per `mockupGlobs`, default `*.png`) exist under `plan/` — headless chromium renders embedded in plan.md, and the gate opens plan.md to prove it: every image file under `plan/` must appear in an embed (``, case-insensitive) and every `mockups/<screen>.html` must carry an embedded `<screen>-<width>.` shot, and no mockup may link (href/src/@import) into another feature's `.dev-flow/<other>/worktree/`; **one question** — or `--confirmed` after you answered in chat; **yolo** (your chat answer at **any** checkpoint question) → run that gate with `--yolo --confirmed` (`approve`/`verify`/`release`/`finish`): that question is answered and every later one (Verified?/Release?/Finish?) is pre-confirmed — the agent then runs the remaining gates back to back, honoring guidance attached to the yolo word (e.g. "yolo, create a patch version release") — checks and guardrails stay fully enforced. `commands.setup` runs in the worktree and is retried until it succeeds once (a worktree left behind by a failed setup is set up on the next `approve`, never silently reused); a `--docs` feature runs no project command at all and says `setup skipped (docs mode)` |
|
|
15
15
|
| `test` | records a check | — (runs the `test` command/check, records pass/fail) |
|
|
16
16
|
| `check` | records all tier-1 checks | — (runs every `flow-check`/test/health from project.md `## implement`); a `--docs` feature runs none of them and says `docs mode: project commands skipped` — a docs flow builds nothing, so a fresh checkout must not read as a failed deploy (#96) |
|
|
17
17
|
| `health` | records a check | — (runs `seedData` + the health command, retrying up to `healthWait` seconds; app must be up locally with real data) |
|
|
@@ -20,7 +20,7 @@ so it needs no `--confirmed`.
|
|
|
20
20
|
| `release-done` | records the release (the stage stays `release`) | **no question — the Release? answer covered the publication**; verify approval; the version published is the one `release` **stamped** from the manifest it validated (a main checkout still behind cannot republish the previous version), and it must not be older than the newest matching tag **on origin** (tag lists come from `git ls-remote`, so an unfetched clone does not decide what exists; when an origin exists but cannot be asked (offline, no ssh agent) **both release gates refuse** rather than answering with local tags); with `versioning.file`: that tag exists, is reachable from the default branch **and is on origin** (a local-only tag is not a release); with `release.artifact`: the published-artifact check runs (`{version}`/`{tag}` placeholders — the line it prints names the version it verified; skip once with `--no-artifact-check`, operator-instructed only) · creates the forge release from the tag, its body **the `release.changelog` entry for that version** — the changelog is the source of truth, and the tag's annotation stands in only when the changelog has no entry for the version, else nothing (and it says why — a body that is really a shell error is dropped, never shipped) — `gh` for GitHub, `glab` for GitLab) and then **proves the release exists**: it asks the forge (`gh release view <tag>` / `glab release view <tag>`) and refuses when nothing is there, because #51, #60 and #63 were three ways of ending `release recorded as complete` with nothing published — and when the changelog was the body it **reads the stored body back** and refuses a mismatch, so the release page and the changelog cannot drift (#97; normalized before comparing, skipped with a printed note on another forge). Skipping is deliberate and loud — `--no-release-create`, `release.releases = false` or `forge = self` each print that no forge release was created, and the view check is skipped for them; **with a `merge` policy** it also proves the merge that shipped matches it — branch ancestry plus what the forge says (`gh pr view` / `glab api`), so a squash under `merge = merge` (or a merge commit under `merge = squash`) refuses the release record, while a shape it cannot see prints an advisory instead (#97's split: an invisible topology never blocks a legal release); when the release went out on a stale build the operator acknowledged at the release gate, it prints that acknowledgement in place of the after-the-fact version-skew warning, and that warning prints the session vs disk version pair plus the duplicate-copy note when a second copy is registered (#117) |
|
|
21
21
|
| `finish [--yolo] [slug]` | release → done (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` |
|
|
22
22
|
| `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 |
|
|
23
|
-
| `roadmap [add "<feature>" \| pick <n> <slug> \| done <n> \| tidy]` | — | manages `.dev-flow/roadmap.md`, the gitignored backlog of future features (`- [ ]` checklist): bare prints the numbered open items, `add` appends one, `pick <n> <slug>` stamps open item n with `(slug)` so `flow start <slug>` can take it — **`finish` checks the stamped item off when that feature ships**; `done <n>` checks off by hand (items shipped outside a flow), `tidy` drops the checked lines. Never gates; the open count is surfaced in `status` and session context |
|
|
23
|
+
| `roadmap [add "<feature>" [--slug=<slug>] [--brief=<notes>\|--brief-file=<path>] \| pick <n> <slug> \| done <n> \| tidy]` | — | manages `.dev-flow/roadmap.md`, the gitignored backlog of future features (`- [ ]` checklist): bare prints the numbered open items, `add` appends one (`--slug=` stamps it like pick, `--brief=`/`--brief-file=` keeps notes under it as ` > ` lines, and a bound session records `— split from <slug>` — the spin-off route for a new feature surfaced mid-flow), `pick <n> <slug>` stamps open item n with `(slug)` so `flow start <slug>` can take it (start seeds `plan/plan.md` with the item and its brief) — **`finish` checks the stamped item off when that feature ships**; `done <n>` checks off by hand (items shipped outside a flow), `tidy` drops the checked lines. Never gates; the open count is surfaced in `status` and session context |
|
|
24
24
|
| `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 |
|
|
25
25
|
| `status [slug]` / `abort [slug]` | — | — |
|
|
26
26
|
| `help` (`--help`, `-h`) | — | — (prints the gate help — answerable in any repo, at any stage, with no `.dev-flow/`) |
|
package/docs/playbook.md
CHANGED
|
@@ -200,7 +200,7 @@ On a **fresh repo** it prints the setup brief: the detection report, plus one qu
|
|
|
200
200
|
|
|
201
201
|
`--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.
|
|
202
202
|
|
|
203
|
-
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. It never runs your commands.
|
|
203
|
+
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.
|
|
204
204
|
|
|
205
205
|
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.
|
|
206
206
|
|
package/extensions/dev-flow.ts
CHANGED
|
@@ -112,6 +112,7 @@ import {
|
|
|
112
112
|
roadmapDone,
|
|
113
113
|
roadmapDoneForSlug,
|
|
114
114
|
roadmapOpenCount,
|
|
115
|
+
roadmapBriefFor,
|
|
115
116
|
roadmapPick,
|
|
116
117
|
roadmapTidy,
|
|
117
118
|
shouldSelfCompact,
|
|
@@ -123,6 +124,9 @@ import {
|
|
|
123
124
|
subst,
|
|
124
125
|
sq,
|
|
125
126
|
featureTmpDir,
|
|
127
|
+
featureTmpEnv,
|
|
128
|
+
compactionStateBlock,
|
|
129
|
+
foreignWorktreeLinks,
|
|
126
130
|
withTmpDir,
|
|
127
131
|
tagNotesCommand,
|
|
128
132
|
validSlug,
|
|
@@ -155,17 +159,20 @@ import { detectProject, type Detection } from "../src/detect.ts";
|
|
|
155
159
|
|
|
156
160
|
const execAsync = promisify(exec);
|
|
157
161
|
|
|
158
|
-
/**
|
|
159
|
-
*
|
|
160
|
-
|
|
161
|
-
|
|
162
|
+
/** This build's own identity, read once at load: it is what this session's code IS — an update that
|
|
163
|
+
* rewrites the package on disk later does not change the code already running. */
|
|
164
|
+
const SELF_BUILD = pluginVersion(import.meta.dirname);
|
|
165
|
+
|
|
166
|
+
/** The dev-flow build this session actually loaded — see sessionRunsOlderBuild. The load-time
|
|
167
|
+
* manifest, never a fresh read: re-reading the package after an in-place update reported the NEW
|
|
168
|
+
* version as loaded and the stale one as shipped (lettuce rail-ui-fixes, 0.79.0 → 0.80.0).
|
|
169
|
+
* DEV_FLOW_LOADED_VERSION (read at call time) can stand in for it (the smoke suite runs gates
|
|
170
|
+
* in-process and needs to pretend it is an old session): the override can only ever make a gate more
|
|
171
|
+
* cautious — it never lifts a proof, it turns a release into a warn-and-ask. */
|
|
162
172
|
function loadedVersion(): string | null {
|
|
163
|
-
return process.env.DEV_FLOW_LOADED_VERSION?.trim() ||
|
|
173
|
+
return process.env.DEV_FLOW_LOADED_VERSION?.trim() || SELF_BUILD.version;
|
|
164
174
|
}
|
|
165
175
|
|
|
166
|
-
/** This build's own identity, read once (the guard hot path must not re-walk the fs per call). */
|
|
167
|
-
const SELF_BUILD = pluginVersion(import.meta.dirname);
|
|
168
|
-
|
|
169
176
|
/** The dev-flow build this session *should* be running, as the disk describes it, and how to call it.
|
|
170
177
|
* In the dev-flow repo that is the checkout's own manifest: main moves ahead of the installed copy at
|
|
171
178
|
* every release, while `loadedVersion()` and the plugin's own package.json are the same file — so a
|
|
@@ -174,7 +181,7 @@ const SELF_BUILD = pluginVersion(import.meta.dirname);
|
|
|
174
181
|
function checkoutBuild(root: string): { version: string | null; dir: string; repo: string; label: string } {
|
|
175
182
|
return isSelfRepo(root)
|
|
176
183
|
? { ...pluginVersion(root), label: "this checkout" }
|
|
177
|
-
: { ...
|
|
184
|
+
: { ...pluginVersion(import.meta.dirname), label: "the dev-flow install" }; // fresh: what the disk ships NOW
|
|
178
185
|
}
|
|
179
186
|
|
|
180
187
|
/** The build this session runs vs the one the disk ships: `behind` is the loaded version when they differ
|
|
@@ -279,7 +286,7 @@ const initiated = (root: string): boolean => existsSync(path.join(dfDir(root), "
|
|
|
279
286
|
* with parseMergeStyle so a typo is reported instead of ignored. */
|
|
280
287
|
function flagValue(rest: string[], name: string): string | null {
|
|
281
288
|
for (const a of rest) {
|
|
282
|
-
const m = a.match(new RegExp(`^--${name}=(
|
|
289
|
+
const m = a.match(new RegExp(`^--${name}=([\\s\\S]+)$`)); // a --brief= value spans lines
|
|
283
290
|
if (m) return m[1];
|
|
284
291
|
}
|
|
285
292
|
return null;
|
|
@@ -377,7 +384,7 @@ async function releaseTags(root: string): Promise<string[] | null> {
|
|
|
377
384
|
}
|
|
378
385
|
|
|
379
386
|
const GATE_HELP =
|
|
380
|
-
"help [--json] | init [--force|--draft|--write <text>|--write-file <path>|--answers key=value…|--answers-file <path>] [--confirmed] [--track] | reflect [<note>|list|tidy|move <n> --playbook|--code|done <n> [<what>]] | roadmap [add <text
|
|
387
|
+
"help [--json] | init [--force|--draft|--write <text>|--write-file <path>|--answers key=value…|--answers-file <path>] [--confirmed] [--track] | reflect [<note>|list|tidy|move <n> --playbook|--code|done <n> [<what>]] | roadmap [add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui|--patch|--docs --confirmed] [--force] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | approve [--yolo] | verify [--yolo] | release [--yolo|--no-version|--no-fold-check|--no-marker-check] | release-done [--no-artifact-check|--no-release-create] | finish [--yolo] [slug] | abort [slug] | version [--check-upstream] — state gates take [slug] and --confirmed (the operator already answered in chat); without it they ask in a dialog, or refuse with NEEDS-OPERATOR when no UI is present — --ui/--patch/--docs and --merge=<style> on start are operator-granted (--confirmed); start refuses until the playbook has a merge policy and writes the answer into project.md — --yolo (with --confirmed) answers that checkpoint and pre-confirms every later one; checks and guardrails stay — release --no-version ships merge + changelog only (no bump, tag or forge release); --no-fold-check skips the changelog fold line proofs on the operator's word; --no-marker-check lets a branch add conflict-marker-shaped lines on purpose — release names a session running an older dev-flow build than the disk ships and asks update (/reload) or proceed — recorded, never a block — reflect <note> queues a project suggestion in reflections.md (--playbook = docs-flow fix, --code = patch-flow fix); --plugin never writes — dev-flow feedback goes upstream and it prints the GitHub issue recipe; bare reflect prints the session-reflection protocol (bound: run flow_stage op reflect); list numbers open items, move <n> re-files one, done <n> checks a fixed one off, tidy drops closed ones — roadmap manages .dev-flow/roadmap.md: pick <n> <slug> (or add --slug=) stamps an item for flow start, which seeds the new plan from its brief; finish checks it off — a new feature asked for mid-flow is parked there, never as a hand-made .dev-flow/<slug>/; start <slug> --confirmed adopts such a ghost dir — doctor reviews structure, git consistency and open reflections (never writes); doctor <note> prints an investigation brief — version prints the build the disk ships and any other dev-flow copies in this process (--check-upstream asks the registry)";
|
|
381
388
|
const featDir = (root: string, slug: string) => path.join(dfDir(root), slug);
|
|
382
389
|
const stateFile = (root: string, slug: string) => path.join(featDir(root, slug), "state.json");
|
|
383
390
|
const claimFile = (root: string, slug: string) => path.join(featDir(root, slug), "claim.json");
|
|
@@ -618,7 +625,7 @@ function gateCwd(root: string, state: FlowState): string {
|
|
|
618
625
|
function featureEnv(root: string, state: FlowState): Record<string, string> {
|
|
619
626
|
const dir = featureTmpDir(dfDir(root), state.slug);
|
|
620
627
|
mkdirSync(dir, { recursive: true });
|
|
621
|
-
return
|
|
628
|
+
return featureTmpEnv(dir);
|
|
622
629
|
}
|
|
623
630
|
|
|
624
631
|
/** Tier-1 checks the gate still has to see green. Entering a stage — and every edit of the worktree —
|
|
@@ -1641,8 +1648,8 @@ async function gateInit(o: GateCtx): Promise<RunResult> {
|
|
|
1641
1648
|
// ghosts: feature dirs whose state.json is gone — inert, invisible to status and guards, and only findable by eye
|
|
1642
1649
|
const ghosts = ghostFeatureDirs(root);
|
|
1643
1650
|
if (ghosts.length) {
|
|
1644
|
-
if (!ui.hasUI) notes.push(`${ghosts.length} ghost feature dir(s) — a plan/ with no state.json, no flow owns them (${ghosts.join(", ")}); delete them or run flow init interactively`);
|
|
1645
|
-
else if (await ui.confirm("Remove ghost feature dirs?", `${ghosts.map((g) => `${g} — plan/ with no state.json`).join("\n")}\n\nNo flow owns these; their plan/*.md is not recoverable afterwards.`)) {
|
|
1651
|
+
if (!ui.hasUI) notes.push(`${ghosts.length} ghost feature dir(s) — a plan/ with no state.json, no flow owns them (${ghosts.join(", ")}); adopt one with flow start <slug> --confirmed, delete them, or run flow init interactively`);
|
|
1652
|
+
else if (await ui.confirm("Remove ghost feature dirs?", `${ghosts.map((g) => `${g} — plan/ with no state.json`).join("\n")}\n\nNo flow owns these; their plan/*.md is not recoverable afterwards. To keep one as a new feature's draft, decline and run flow start <slug> --confirmed.`)) {
|
|
1646
1653
|
for (const g of ghosts) rmSync(path.join(root, g), { recursive: true, force: true });
|
|
1647
1654
|
notes.push(`removed ${ghosts.length} ghost feature dir(s): ${ghosts.map((g) => g.slice(".dev-flow/".length)).join(", ")}`);
|
|
1648
1655
|
} else notes.push(`kept ${ghosts.length} ghost feature dir(s) — inert, remove them whenever you like`);
|
|
@@ -1772,7 +1779,27 @@ async function gateInit(o: GateCtx): Promise<RunResult> {
|
|
|
1772
1779
|
async function gateStart(o: GateCtx): Promise<RunResult> {
|
|
1773
1780
|
const { root, sess, cfg, rest, flag, slugArg } = o;
|
|
1774
1781
|
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 };
|
|
1775
|
-
|
|
1782
|
+
// a ghost (plan/ but no state.json — typically a spin-off someone wrote by hand) is adopted, never a dead end:
|
|
1783
|
+
// "already exists, flow use it" sent the agent to use, which found no state, and doctor offered to delete it
|
|
1784
|
+
const ghost = existsSync(featDir(root, slugArg)) && !existsSync(stateFile(root, slugArg)) && existsSync(path.join(featDir(root, slugArg), "plan"));
|
|
1785
|
+
if (ghost && !flag("confirmed")) {
|
|
1786
|
+
const files = listFiles(path.join(featDir(root, slugArg), "plan"));
|
|
1787
|
+
return { text: `.dev-flow/${slugArg}/ is a ghost — plan/ (${files.join(", ") || "empty"}) but no state.json, so no flow owns it. Adopt it as this feature's draft plan: flow start ${slugArg} --confirmed (the operator agrees in chat), or delete the dir to start clean`, isError: true };
|
|
1788
|
+
}
|
|
1789
|
+
if (existsSync(featDir(root, slugArg)) && !ghost) {
|
|
1790
|
+
// --ui on the plan-stage feature this session drives: the operator asked for mockups after the start,
|
|
1791
|
+
// so turn the mockup gate on instead of refusing — a UI feature left at ui=false skips the mockup
|
|
1792
|
+
// proof at approve and every (ui) checklist item (lettuce rail-ui-fixes shipped 20 ungated mockups)
|
|
1793
|
+
const existing = readState(root, slugArg);
|
|
1794
|
+
if (flag("ui") && existing && sess.slug === slugArg) {
|
|
1795
|
+
if (!flag("confirmed")) return { text: "--ui is operator-granted — it adds a rendered-mockup requirement to the plan gate; ask the operator, then re-run with --confirmed", isError: true };
|
|
1796
|
+
if (existing.ui) return { text: `feature ${slugArg} already has the ui flag` };
|
|
1797
|
+
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 };
|
|
1798
|
+
writeState(root, { ...existing, ui: true });
|
|
1799
|
+
return { text: `ui flag set on existing feature ${slugArg} (plan stage): the approve gate now requires rendered mockups under plan/mockups/ (${cfg.mockupGlobs.join(", ")}), each embedded in plan.md, and the (ui) checklist items apply` };
|
|
1800
|
+
}
|
|
1801
|
+
return { text: `feature ${slugArg} already exists — flow use ${slugArg} to resume it${existing?.stage === "plan" ? `; to add the mockup gate at plan, run flow start ${slugArg} --ui --confirmed from the session bound to it` : ""}`, isError: true };
|
|
1802
|
+
}
|
|
1776
1803
|
// relaxed modes are operator-granted: --confirmed anchors a literal chat grant, same convention as the gate verbs
|
|
1777
1804
|
if (flag("patch") && flag("docs")) return { text: "--patch and --docs are exclusive — ask the operator which mode they grant", isError: true };
|
|
1778
1805
|
const mode = flag("patch") ? "patch" : flag("docs") ? "docs" : null;
|
|
@@ -1821,7 +1848,19 @@ async function gateStart(o: GateCtx): Promise<RunResult> {
|
|
|
1821
1848
|
// stamp the dev-flow build that started this feature — a stuck flow can later be read against its tooling.
|
|
1822
1849
|
// the stamp is what ran, not what the disk claims (that mismatch is the warning above).
|
|
1823
1850
|
const state = newState(slugArg, flag("ui"), flag("patch"), flag("docs"), loadedVersion() ?? undefined);
|
|
1824
|
-
|
|
1851
|
+
const planDir = path.join(featDir(root, slugArg), "plan");
|
|
1852
|
+
if (ghost) notes.push(`adopted ghost .dev-flow/${slugArg}/ — its plan/ (${listFiles(planDir).join(", ") || "empty"}) is this feature's draft`);
|
|
1853
|
+
mkdirSync(planDir, { recursive: true });
|
|
1854
|
+
// a roadmap item stamped for this slug carries its brief into the plan: the spin-off's context outlives the session that split it
|
|
1855
|
+
const picked = roadmapBriefFor(readRoadmap(root), slugArg);
|
|
1856
|
+
if (picked) {
|
|
1857
|
+
const planMd = path.join(planDir, "plan.md");
|
|
1858
|
+
const carried = `> Carried over from the roadmap: ${picked.item}${picked.brief ? `\n>\n${picked.brief.split("\n").map((l) => `> ${l}`.trimEnd()).join("\n")}` : ""}\n`;
|
|
1859
|
+
if (!existsSync(planMd)) {
|
|
1860
|
+
writeFileSync(planMd, `# ${slugArg} — plan (draft)\n\n${carried}`);
|
|
1861
|
+
notes.push(`roadmap item "${picked.item}" seeded plan/plan.md${picked.brief ? " with its brief" : ""} — a draft: plan it out and approve as usual`);
|
|
1862
|
+
} else notes.push(`roadmap item "${picked.item}"${picked.brief ? ` — brief:\n${picked.brief}` : ""}`);
|
|
1863
|
+
}
|
|
1825
1864
|
writeState(root, state);
|
|
1826
1865
|
sess.bind(slugArg);
|
|
1827
1866
|
sess.rename(slugArg);
|
|
@@ -1836,7 +1875,9 @@ async function gateApprove(o: GateCtx): Promise<RunResult> {
|
|
|
1836
1875
|
// the embed proofs read the plan document itself: a render that exists on disk but is not
|
|
1837
1876
|
// embedded in plan.md is one the operator would never be shown
|
|
1838
1877
|
const planMd = path.join(planDir, "plan.md");
|
|
1839
|
-
const
|
|
1878
|
+
const planFiles = listFiles(planDir);
|
|
1879
|
+
const mockupHtml = planFiles.filter((f) => /^mockups\/.+\.html?$/i.test(f)).map((f) => ({ file: f, html: readFileSync(path.join(planDir, f), "utf8") }));
|
|
1880
|
+
const errs = approveGate(state!, cfg, planFiles, existsSync(planMd) ? readFileSync(planMd, "utf8") : undefined, foreignWorktreeLinks(dfDir(root), state!.slug, mockupHtml));
|
|
1840
1881
|
if (errs.length) return { text: `plan gate FAILED:\n- ${errs.join("\n- ")}`, isError: true };
|
|
1841
1882
|
const planItems = applicableItems(cfg, state!, "plan");
|
|
1842
1883
|
const audit = flag("confirmed") ? " (confirmed by operator instruction)" : "";
|
|
@@ -1973,9 +2014,17 @@ async function gateRoadmap(o: GateCtx): Promise<RunResult> {
|
|
|
1973
2014
|
return { text: [`roadmap — ${open} open (${done} done):`, ...openChecklistItems(text).map((l, i) => ` ${i + 1}. ${l.slice(6)}`)].join("\n") };
|
|
1974
2015
|
}
|
|
1975
2016
|
case "add": {
|
|
1976
|
-
if (!args.length) return { text: 'usage: flow roadmap add "<future feature>"', isError: true };
|
|
1977
|
-
|
|
1978
|
-
|
|
2017
|
+
if (!args.length) return { text: 'usage: flow roadmap add "<future feature>" [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]', isError: true };
|
|
2018
|
+
// a spin-off: --slug stamps it like pick (flow start finds it), the brief carries what was worked
|
|
2019
|
+
// out in chat into the new feature's plan, and a bound session records where it was split from
|
|
2020
|
+
const slug = flagValue(rest, "slug");
|
|
2021
|
+
if (slug !== null && !validSlug(slug)) return { text: `--slug=${slug} is not a slug (lowercase, dashes)`, isError: true };
|
|
2022
|
+
const briefFile = flagValue(rest, "brief-file");
|
|
2023
|
+
if (briefFile !== null && !existsSync(path.resolve(root, briefFile))) return { text: `--brief-file=${briefFile} does not exist`, isError: true };
|
|
2024
|
+
const brief = briefFile !== null ? readFileSync(path.resolve(root, briefFile), "utf8") : (flagValue(rest, "brief") ?? "");
|
|
2025
|
+
const item = [args.join(" "), sess.slug && sess.slug !== slug ? `— split from ${sess.slug}` : "", slug ? `(${slug})` : ""].filter(Boolean).join(" ");
|
|
2026
|
+
save(appendRoadmapItem(text, item, brief));
|
|
2027
|
+
return { text: `roadmap: added — ${open + 1} open${slug ? `; stamped for ${slug}${brief.trim() ? " with a brief" : ""} — flow start ${slug} seeds its plan from it${sess.slug ? ` (after ${sess.slug} ships)` : ""}` : ""}` };
|
|
1979
2028
|
}
|
|
1980
2029
|
case "pick": {
|
|
1981
2030
|
const slug = args[1] ?? "";
|
|
@@ -1996,7 +2045,7 @@ async function gateRoadmap(o: GateCtx): Promise<RunResult> {
|
|
|
1996
2045
|
return { text: `roadmap: dropped ${done} done item(s) — ${open} open` };
|
|
1997
2046
|
}
|
|
1998
2047
|
default:
|
|
1999
|
-
return { text: "usage: flow roadmap [list|add <text
|
|
2048
|
+
return { text: "usage: flow roadmap [list|add <text> [--slug=<slug>] [--brief=<notes>|--brief-file=<path>]|pick <n> <slug>|done <n>|tidy]", isError: true };
|
|
2000
2049
|
}
|
|
2001
2050
|
}
|
|
2002
2051
|
|
|
@@ -2102,7 +2151,10 @@ async function gateUse(o: GateCtx): Promise<RunResult> {
|
|
|
2102
2151
|
const { root, sess, slugArg } = o;
|
|
2103
2152
|
if (!slugArg) return { text: "usage: flow use <slug>", isError: true };
|
|
2104
2153
|
const st = readState(root, slugArg);
|
|
2105
|
-
if (!st)
|
|
2154
|
+
if (!st) {
|
|
2155
|
+
const ghost = existsSync(path.join(featDir(root, slugArg), "plan"));
|
|
2156
|
+
return { text: ghost ? `.dev-flow/${slugArg}/ is a ghost — plan/ but no state.json, so there is nothing to resume: flow start ${slugArg} --confirmed adopts its plan as a new feature` : `no unfinished feature ${slugArg}`, isError: true };
|
|
2157
|
+
}
|
|
2106
2158
|
const prior = readClaim(root, slugArg);
|
|
2107
2159
|
const takeover = claimBlocks(prior, sess.key) ? ` — taken over from live session (pid ${prior!.pid})` : "";
|
|
2108
2160
|
sess.bind(slugArg);
|
|
@@ -2784,7 +2836,9 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
2784
2836
|
const headers = auth.headers ? (Object.fromEntries(Object.entries(auth.headers).filter(([, v]) => v !== null)) as Record<string, string>) : undefined;
|
|
2785
2837
|
// same function pi itself calls — same split-turn merge, file lists and prompts, just flow-aware instructions
|
|
2786
2838
|
const result = await compactionTakeover.run(event.preparation, model, auth.apiKey, headers, flowCompactInstructions(st!), event.signal, undefined, undefined, auth.env);
|
|
2787
|
-
|
|
2839
|
+
// re-read: the summarize call took a while, and the block must state the disk as it is now
|
|
2840
|
+
const now = readState(root, st!.slug) ?? st!;
|
|
2841
|
+
return { compaction: { ...result, summary: result.summary + compactionStateBlock(now, loadProject(dfDir(root)).cfg) } };
|
|
2788
2842
|
} catch {
|
|
2789
2843
|
return undefined; // pi's default compaction proceeds untouched
|
|
2790
2844
|
} finally {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.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": [
|
|
@@ -26,7 +26,9 @@ feature).
|
|
|
26
26
|
blocks).
|
|
27
27
|
Throwaway scripts and scratch output go in `$TMPDIR` (or `mktemp`), not a
|
|
28
28
|
hard-coded `/tmp/...`: in a bound session, and in every command a gate runs,
|
|
29
|
-
it is `.dev-flow/<slug>/tmp/`, and finish removes it with the feature.
|
|
29
|
+
it is `.dev-flow/<slug>/tmp/`, and finish removes it with the feature. The
|
|
30
|
+
same commands get that dir as `GIT_CEILING_DIRECTORIES`, so a test fixture
|
|
31
|
+
made under it is not inside the checkout (git does not climb out of it).
|
|
30
32
|
3. `flow check` runs every tier-1 check (test, health, named `flow-check`
|
|
31
33
|
blocks) and records each against a fingerprint of the worktree; any later
|
|
32
34
|
worktree change makes them stale — verify reruns stale checks itself.
|
|
@@ -135,10 +137,16 @@ Verify lands the feature in **pre-release**.
|
|
|
135
137
|
Mid-stage additions — do not bounce the flow, do not grow it silently:
|
|
136
138
|
**this feature grew** → stay at implement, append a `**Added mid-stage:**` line
|
|
137
139
|
to `plan.md` (what was asked and how), implement, `flow check` again — edits
|
|
138
|
-
make the checks stale, so verify re-covers the addition. **Different problem** →
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
make the checks stale, so verify re-covers the addition. **Different problem** →
|
|
141
|
+
a spin-off: once the operator agrees to split it, park it in the roadmap with
|
|
142
|
+
what you worked out — `flow roadmap add "<title>" --slug=<new-slug>
|
|
143
|
+
--brief=<notes>` (or `--brief-file=<path>`; the item records it was split from
|
|
144
|
+
this feature) — then finish this feature, and `flow start <new-slug>` (any
|
|
145
|
+
session, fresh is fine) seeds the new `plan/plan.md` from the brief. **Never
|
|
146
|
+
create `.dev-flow/<new-slug>/` by hand**: a plan dir with no `state.json` is a
|
|
147
|
+
ghost no gate picks up (the guard refuses it; `flow start <slug> --confirmed`
|
|
148
|
+
adopts one that already exists). Never fold two features into one plan, PR and
|
|
149
|
+
verify — the audit trail is the point. **Heavily amended plan** → show it and have the
|
|
142
150
|
operator re-approve in chat; verify remains the checkpoint — no reopen command
|
|
143
151
|
exists by design.
|
|
144
152
|
|
|
@@ -17,12 +17,20 @@
|
|
|
17
17
|
name is itself the gate's proof: **plan.md** — a preliminary direction
|
|
18
18
|
belongs *inside* plan.md (marked draft), never a separate
|
|
19
19
|
`pre-plan`/`direction.md` file: the approve gate requires plan.md by name.
|
|
20
|
+
Scope splits off at plan (the operator wants part of it later)? Park that
|
|
21
|
+
part with `flow roadmap add "<title>" --slug=<slug> --brief=<notes>` — never
|
|
22
|
+
a second `.dev-flow/<slug>/` written by hand.
|
|
20
23
|
First check
|
|
21
24
|
`git log origin/<default>..<default> --oneline`: local-only default-branch
|
|
22
25
|
commits fall out of the worktree's base (push them or re-plan).
|
|
23
26
|
4. **UI flag set?** Mockups live in `plan/mockups/`, one HTML per screen/state
|
|
24
27
|
(`<screen>.html`), linking the project's real stylesheet and class names
|
|
25
|
-
where they exist (relative links work from `.dev-flow/`).
|
|
28
|
+
where they exist (relative links work from `.dev-flow/`). At plan the
|
|
29
|
+
feature has **no worktree yet** — link the main checkout's stylesheet
|
|
30
|
+
(`../../../../<path>` from `plan/mockups/`), never another feature's
|
|
31
|
+
worktree (the approve gate refuses it: that branch drifts and is removed at
|
|
32
|
+
its finish); after approve, re-render against this feature's worktree any
|
|
33
|
+
mockup you keep using. Every mockup
|
|
26
34
|
must be **rendered** — an unrendered mockup is not a mockup:
|
|
27
35
|
- Headless chromium: PATH `chromium`/`chromium-browser`/`google-chrome`,
|
|
28
36
|
else playwright's
|
|
@@ -76,5 +76,12 @@ content, you maintain and honor it. Advisory like reflections, never gating:
|
|
|
76
76
|
- Handed a feature: `flow roadmap pick <n> <slug>` stamps the item with the
|
|
77
77
|
slug (pick is one verb — it starts nothing), then `flow start <slug>` builds
|
|
78
78
|
it as a normal flow; its `flow finish` checks the item off automatically.
|
|
79
|
+
- **Spin-off** (a new feature surfaced mid-flow, split off on the operator's
|
|
80
|
+
word): `flow roadmap add "<title>" --slug=<slug> --brief=<notes>` (or
|
|
81
|
+
`--brief-file=<path>`) adds and stamps in one call; the brief sits under the
|
|
82
|
+
item as ` > ` lines and a bound session's slug is recorded as `— split from
|
|
83
|
+
<slug>`. `flow start <slug>` seeds `plan/plan.md` with the item and brief (a
|
|
84
|
+
draft — plan and approve as usual). A hand-made `.dev-flow/<slug>/plan/` with
|
|
85
|
+
no `state.json` is a ghost: `flow start <slug> --confirmed` adopts it.
|
|
79
86
|
- Shipped outside a flow: `flow roadmap done <n>` (date-stamped by hand);
|
|
80
87
|
`flow roadmap tidy` drops checked lines when history clutters the list.
|
|
@@ -27,7 +27,9 @@ writing.
|
|
|
27
27
|
|
|
28
28
|
`flow start <slug> [--ui --confirmed]` — `--ui` adds a rendered-mockup gate to plan, so it is
|
|
29
29
|
operator-granted like `--patch`/`--docs`: propose it when screens change, start with it only on their word;
|
|
30
|
-
slug lowercase words-dashed; check `flow status` for an active feature first.
|
|
30
|
+
slug lowercase words-dashed; check `flow status` for an active feature first. Screens turned out to
|
|
31
|
+
change after a plain start (the operator asks for mockups)? While the feature is still at plan,
|
|
32
|
+
`flow start <slug> --ui --confirmed` from its session switches the mockup gate on; past plan it refuses.
|
|
31
33
|
|
|
32
34
|
`flow start` **preflights** before it creates anything: it warns when this session runs an older dev-flow
|
|
33
35
|
build than the checkout (`/reload` before trusting gate output), prints the playbook gaps `flow doctor`
|
package/src/core.ts
CHANGED
|
@@ -242,7 +242,32 @@ const IMG_EXT = /\.(?:png|jpe?g|webp|gif)$/i;
|
|
|
242
242
|
* planDoc is the text of plan/plan.md (undefined = absent) — the embed proofs read the plan
|
|
243
243
|
* document itself. Before it, the gate checked only that *a* *.md and *a* *.png existed, which
|
|
244
244
|
* let a pre-plan/direction file with unembedded screenshots walk through Approve. */
|
|
245
|
-
|
|
245
|
+
/** Links in a feature's mockup HTML that resolve into ANOTHER feature's worktree, as `file: href`.
|
|
246
|
+
* At plan this feature has no worktree yet, and a sibling's is a tempting stand-in for "the branch's
|
|
247
|
+
* stylesheet" — but it is a different branch that drifts or vanishes when that feature finishes, so
|
|
248
|
+
* every later re-render silently describes someone else's styles (lettuce rail-ui-fixes linked
|
|
249
|
+
* status-and-loading's). `mockups` are paths relative to plan/ with their HTML; dfDir is absolute. */
|
|
250
|
+
export function foreignWorktreeLinks(dfDir: string, slug: string, mockups: { file: string; html: string }[]): string[] {
|
|
251
|
+
const out: string[] = [];
|
|
252
|
+
const base = path.join(dfDir, slug, "plan");
|
|
253
|
+
for (const m of mockups) {
|
|
254
|
+
const refs = [
|
|
255
|
+
...m.html.matchAll(/\b(?:href|src)\s*=\s*["']([^"']+)["']/gi),
|
|
256
|
+
...m.html.matchAll(/@import\s+(?:url\(\s*)?["']?([^"')\s;]+)/gi),
|
|
257
|
+
].map((x) => x[1]);
|
|
258
|
+
for (const ref of refs) {
|
|
259
|
+
if (/^(?:https?:|data:|#|mailto:)/i.test(ref)) continue;
|
|
260
|
+
const p = ref.replace(/^file:\/\//i, "").split(/[?#]/)[0];
|
|
261
|
+
const abs = path.isAbsolute(p) ? path.normalize(p) : path.resolve(path.dirname(path.join(base, m.file)), p);
|
|
262
|
+
const rel = path.relative(dfDir, abs);
|
|
263
|
+
const owner = /^([^/\\]+)[/\\]worktree(?:[/\\]|$)/.exec(rel)?.[1];
|
|
264
|
+
if (owner && owner !== slug && !rel.startsWith("..")) out.push(`${m.file}: ${ref}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return out;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export function approveGate(state: FlowState, cfg: Config, planFiles: string[], planDoc?: string, foreignLinks: string[] = []): string[] {
|
|
246
271
|
const errs: string[] = [];
|
|
247
272
|
if (state.stage !== "plan") errs.push(`stage is "${state.stage}", approval only applies to "plan"`);
|
|
248
273
|
if (!state.patch && !state.docs && !planFiles.includes("plan.md"))
|
|
@@ -264,6 +289,8 @@ export function approveGate(state: FlowState, cfg: Config, planFiles: string[],
|
|
|
264
289
|
});
|
|
265
290
|
if (unrendered.length) errs.push(`mockups without an embedded render — ${unrendered.join(", ")} (render each screen and name the shot after it: <screen>-<width>.png)`);
|
|
266
291
|
}
|
|
292
|
+
if (foreignLinks.length)
|
|
293
|
+
errs.push(`mockups link another feature's worktree — ${foreignLinks.join(", ")}: that branch drifts and is removed at its finish; at plan link the main checkout's stylesheet (this feature's worktree does not exist until approve) and re-render`);
|
|
267
294
|
return errs;
|
|
268
295
|
}
|
|
269
296
|
|
|
@@ -1377,10 +1404,20 @@ export function featureTmpDir(dfDir: string, slug: string): string {
|
|
|
1377
1404
|
return path.join(dfDir, slug, "tmp");
|
|
1378
1405
|
}
|
|
1379
1406
|
|
|
1380
|
-
/** The
|
|
1407
|
+
/** The env every process of a bound feature gets: TMPDIR in the feature's scratch dir, and that dir as a
|
|
1408
|
+
* git ceiling. The scratch dir sits inside the repo, so without the ceiling git walks up out of a
|
|
1409
|
+
* test's mkdtemp fixture and answers with the enclosing checkout — a suite asserting "no repo here"
|
|
1410
|
+
* goes red only under dev-flow (lettuce rail-ui-fixes: a build-info test failed every gate run).
|
|
1411
|
+
* Commands run from the worktree or the main checkout never climb through the scratch dir, so they
|
|
1412
|
+
* are untouched. An inherited ceiling list is kept. */
|
|
1413
|
+
export function featureTmpEnv(dir: string, inherited = process.env.GIT_CEILING_DIRECTORIES): Record<string, string> {
|
|
1414
|
+
return { TMPDIR: dir, GIT_CEILING_DIRECTORIES: inherited ? `${dir}${path.delimiter}${inherited}` : dir };
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
/** The agent's shell command with the feature env (featureTmpEnv) exported (newline-prefixed, the
|
|
1381
1418
|
* shape pi's own commandPrefix uses — the command itself stays byte-for-byte what the guards judged). */
|
|
1382
1419
|
export function withTmpDir(command: string, dir: string): string {
|
|
1383
|
-
return `export TMPDIR=${sq(dir)}\n${command}`;
|
|
1420
|
+
return `export TMPDIR=${sq(dir)} GIT_CEILING_DIRECTORIES=${sq(dir)}\${GIT_CEILING_DIRECTORIES:+:\$GIT_CEILING_DIRECTORIES}\n${command}`;
|
|
1384
1421
|
}
|
|
1385
1422
|
|
|
1386
1423
|
export function inScratchDir(abs: string, repoRoot?: string | null): boolean {
|
|
@@ -1436,6 +1473,12 @@ export function writeGuard(o: { abs: string; dfDir: string; features: FeatureRef
|
|
|
1436
1473
|
// agent owns stay writable with no binding; project.md is refused above, state/claim.json too.
|
|
1437
1474
|
if (DF_ADVISORY_FILES.has(path.relative(dfDir, abs))) return null;
|
|
1438
1475
|
if (!bound) return `.dev-flow/ holds flow state — an unbound session may write only its advisory files there (.dev-flow/reflections.md, .dev-flow/roadmap.md); bind with flow start <slug> or flow use <slug>, and a throwaway script goes outside the repo (under $TMPDIR)`;
|
|
1476
|
+
// another feature's directory, or a hand-made one shaped like a feature (`<x>/plan/…`): a plan dir
|
|
1477
|
+
// with no state.json is a ghost no gate can pick up — `flow start` refuses the existing dir, `flow use`
|
|
1478
|
+
// finds no state, doctor offers to delete it. A spin-off feature is parked in the roadmap instead.
|
|
1479
|
+
const [top, second] = path.relative(dfDir, abs).split(path.sep);
|
|
1480
|
+
if (top !== bound.state.slug && (second === "plan" || o.features.some((f) => f.state.slug === top)))
|
|
1481
|
+
return `.dev-flow/${top}/ is not this session's feature (${bound.state.slug}) — never create a feature dir by hand: park a new feature with flow roadmap add "<title>" --slug=${top} --brief=<notes> (the brief seeds its plan), and flow start ${top} once ${bound.state.slug} ships`;
|
|
1439
1482
|
return null;
|
|
1440
1483
|
}
|
|
1441
1484
|
if (bound) {
|
|
@@ -1924,9 +1967,27 @@ const isOpenItem = (line: string) => line.trim().startsWith("- [ ] ");
|
|
|
1924
1967
|
const isDoneItem = (line: string) => /^\s*-\s*\[[xX]\]\s/.test(line);
|
|
1925
1968
|
const stampItem = (line: string, stamp: string) => `- [x] ${line.trim().slice(6)} — done: ${stamp}`;
|
|
1926
1969
|
|
|
1927
|
-
/**
|
|
1928
|
-
|
|
1929
|
-
|
|
1970
|
+
/** A brief line under a roadmap item: indented blockquote (` > …`). The quote keeps a brief's own
|
|
1971
|
+
* `- [ ]` lines from counting as backlog items (item matching trims, then wants a leading dash). */
|
|
1972
|
+
const isBriefLine = (line: string) => /^\s+>/.test(line);
|
|
1973
|
+
|
|
1974
|
+
/** Append an open item to roadmap.md content; a header is minted from empty content. An optional
|
|
1975
|
+
* brief (the notes a spin-off feature carries into its plan) lands as indented ` > ` lines under it. */
|
|
1976
|
+
export function appendRoadmapItem(text: string, item: string, brief?: string): string {
|
|
1977
|
+
const body = (brief ?? "").replace(/\r/g, "").trim();
|
|
1978
|
+
const quoted = body ? `${body.split("\n").map((l) => ` > ${l}`.trimEnd()).join("\n")}\n` : "";
|
|
1979
|
+
return `${text.trimEnd() || ROADMAP_HEADER.trimEnd()}\n- [ ] ${item.trim()}\n${quoted}`;
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
/** The open item stamped `(slug)` and its brief (quote markers stripped) — what flow start seeds a
|
|
1983
|
+
* picked feature's plan with. Null when no open item carries the stamp. */
|
|
1984
|
+
export function roadmapBriefFor(text: string, slug: string): { item: string; brief: string } | null {
|
|
1985
|
+
const lines = text.split("\n");
|
|
1986
|
+
const i = lines.findIndex((l) => isOpenItem(l) && l.includes(`(${slug})`));
|
|
1987
|
+
if (i === -1) return null;
|
|
1988
|
+
const brief: string[] = [];
|
|
1989
|
+
for (let j = i + 1; j < lines.length && isBriefLine(lines[j]); j++) brief.push(lines[j].replace(/^\s+> ?/, ""));
|
|
1990
|
+
return { item: lines[i].trim().slice(6), brief: brief.join("\n").trim() };
|
|
1930
1991
|
}
|
|
1931
1992
|
|
|
1932
1993
|
/** Number of open roadmap items. */
|
|
@@ -1975,7 +2036,14 @@ export function roadmapDoneForSlug(text: string, slug: string, stamp: string): {
|
|
|
1975
2036
|
|
|
1976
2037
|
/** Drop the done (`- [x]`) items; preamble and open items stay verbatim. */
|
|
1977
2038
|
export function roadmapTidy(text: string): string {
|
|
1978
|
-
|
|
2039
|
+
// a done item's brief goes with it — left behind it would read as the brief of the item above
|
|
2040
|
+
let dropping = false;
|
|
2041
|
+
const out = text.split("\n").filter((l) => {
|
|
2042
|
+
if (isBriefLine(l)) return !dropping;
|
|
2043
|
+
dropping = isDoneItem(l);
|
|
2044
|
+
return !dropping;
|
|
2045
|
+
});
|
|
2046
|
+
return out.join("\n").replace(/\n{3,}/g, "\n\n");
|
|
1979
2047
|
}
|
|
1980
2048
|
|
|
1981
2049
|
/** How far before pi's own compaction threshold dev-flow compacts (one fat tool turn). */
|
|
@@ -2014,6 +2082,24 @@ function mergeHintFor(cfg: Config): string {
|
|
|
2014
2082
|
}
|
|
2015
2083
|
|
|
2016
2084
|
/** What the agent/user should do next, per stage. */
|
|
2085
|
+
/** The block a flow-aware compaction appends to its summary: the flow's state as the disk holds it.
|
|
2086
|
+
* A summarizer merging an older summary can carry a stale stage forward (lettuce rail-ui-fixes: a
|
|
2087
|
+
* pre-release compaction still said "implement, next: flow verify"); this block is written from
|
|
2088
|
+
* state.json, never by the model, and says it outranks the prose above it. */
|
|
2089
|
+
export function compactionStateBlock(state: FlowState, cfg: Config): string {
|
|
2090
|
+
const approvals = Object.keys(state.approvals ?? {});
|
|
2091
|
+
const checks = Object.entries(state.checks ?? {}).map(([k, v]) => `${k}:${v?.ok ? "ok" : "FAILED"}`);
|
|
2092
|
+
return [
|
|
2093
|
+
"",
|
|
2094
|
+
"---",
|
|
2095
|
+
"[dev-flow state on disk — authoritative; where the summary above disagrees, this wins]",
|
|
2096
|
+
`- feature ${state.slug}${state.patch ? " (patch)" : state.docs ? " (docs)" : ""}${state.ui ? " (UI)" : ""} — stage: ${state.stage}${state.branch ? `, branch ${state.branch}` : ""}`,
|
|
2097
|
+
`- approvals recorded: ${approvals.length ? approvals.join(", ") : "none"}`,
|
|
2098
|
+
`- checks: ${checks.length ? checks.join(", ") : "none recorded"}`,
|
|
2099
|
+
`- next: ${nextHint(state, cfg)}`,
|
|
2100
|
+
].join("\n");
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2017
2103
|
export function nextHint(state: FlowState, cfg: Config): string {
|
|
2018
2104
|
switch (state.stage) {
|
|
2019
2105
|
case "plan":
|
|
@@ -2183,6 +2269,11 @@ export function buildWorkerBrief(o: WorkerBriefInput): string {
|
|
|
2183
2269
|
? [
|
|
2184
2270
|
"## Contract",
|
|
2185
2271
|
"- Use the edit/write tools for source changes. Commit as you go on the feature branch (small, meaningful commits).",
|
|
2272
|
+
...(o.status.trim()
|
|
2273
|
+
? [
|
|
2274
|
+
"- The uncommitted paths above are the driving session's work in progress, not yours: never stage or commit them. Commit only your own paths by name (`git add <paths>` then `git commit -m … -- <paths>`); never `git add -A`, `git add .` or `git commit -a`. Check `git diff --cached --name-only` before every commit.",
|
|
2275
|
+
]
|
|
2276
|
+
: []),
|
|
2186
2277
|
"- Do not stop to narrate — keep working until the slice is done or you are blocked.",
|
|
2187
2278
|
"- Finish with a final message whose last section starts with a line `REPORT` followed by: done, commits, open items, risks.",
|
|
2188
2279
|
]
|
package/src/projectmd.ts
CHANGED
|
@@ -477,7 +477,7 @@ export function doctorFindings(root: string, cfg: Config, md: ParsedMd | null):
|
|
|
477
477
|
if (cfg.commands.run && !cfg.checkList.some((c) => c.name === "health")) f.push('run command configured but no tier-1 health check — add commands.health or a flow-check so "running and healthy" is enforced');
|
|
478
478
|
if (cfg.commands.dev && !healthProbe(cfg)) f.push("dev deploy configured but no health check — flow verify cannot prove the deploy came back serving this build: add commands.health or a flow-check health block");
|
|
479
479
|
if (!cfg.checkList.length) f.push("implement tier-1 gates nothing — no test, no health, no flow-check block: 'flow check' would pass vacuously");
|
|
480
|
-
for (const g of ghostFeatureDirs(root)) f.push(`${g} has a plan/ but no state.json — ghost of a closed or
|
|
480
|
+
for (const g of ghostFeatureDirs(root)) f.push(`${g} has a plan/ but no state.json — ghost of a closed, aborted or hand-made feature (flow start <slug> --confirmed adopts it as a new feature; flow init offers to remove it)`);
|
|
481
481
|
return f;
|
|
482
482
|
}
|
|
483
483
|
|