pi-dev-flow 0.55.1 → 0.57.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 +11 -1
- package/docs/concurrency.md +4 -4
- package/docs/gates.md +1 -1
- package/docs/guardrails.md +1 -1
- package/docs/headless.md +2 -2
- package/docs/playbook.md +2 -1
- package/extensions/dev-flow.ts +52 -35
- package/package.json +1 -1
- package/skills/dev-flow/SKILL.md +10 -5
- package/src/core.ts +53 -2
- package/src/projectmd.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,17 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
-
## [0.
|
|
7
|
+
## [0.57.0] - 2026-10-23
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- **The footer now tells the truth about bindings: a slug only when bound, a count when not — and nothing binds itself anymore.** The status bar rendered only for a session's bound feature, so an unbound session saw a blank footer however much work was in flight — and `boundFeature` made that blank worse than it looked: with exactly one unfinished feature it silently auto-bound *and claimed* it, so merely opening a new session steered the lone feature nobody handed it. Sessions now bind **explicitly and only** — `flow start` binds its own feature, `flow use <slug>` takes one over; `boundFeature` lost its lone-feature fallback and its claim-writing side effect, and slugless gates answer `nothing bound — flow use <slug> or pass an explicit slug (unfinished: …)` instead of quietly picking the one left. The unbound footer reads `⧖ N flow(s) open` — the count of unfinished features, never a slug, no `⚠️` (the failing-check marker stays the bound flow's own signal); with nothing unfinished the footer stays clear, and rendering stays a pure read that can never claim anything. `flow status --json`'s `current` follows the same rule — only a bound session has a current feature — and the guardrails, concurrency and headless docs plus the skill teach the explicit-bind model (`flow use <slug>` is now the *only* way onto a feature, not the takeover of an auto-bind).
|
|
12
|
+
|
|
13
|
+
## [0.56.0] - 2026-10-22
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **`flow reflect tidy` drops the closed reflections.** Checking items off was the end of their story — the `- [x]` lines just piled up in `reflections.md` while every surface counts only open ones, so the checked-off history was invisible weight the agent kept walking past. Now the verb mirrors `roadmap tidy`: it deletes every `- [x]` item (the `— fixed:` note has already recorded the outcome), leaves the preamble and the open lines verbatim, and drops a `## playbook`/`## plugin` heading left empty. And the pile no longer waits to be noticed: queueing a note, the bare `reflect` protocol and `flow doctor` all print `↻ N closed reflection(s) — flow reflect tidy drops them` while any closed items exist — exactly the surfaces where items get checked off, quiet once the file is clean.
|
|
8
18
|
|
|
9
19
|
### Fixed
|
|
10
20
|
|
package/docs/concurrency.md
CHANGED
|
@@ -5,10 +5,10 @@ How several agents work one repo at the same time without stepping on each other
|
|
|
5
5
|
**One pi session = one feature** (flow + branch + worktree). A repo can host any number of
|
|
6
6
|
features, worked by separate sessions in parallel — that is the supported shape, not an edge
|
|
7
7
|
case. The binding lives with the session (persisted via session entries, restored on
|
|
8
|
-
resume/fork), so nothing is repo-global.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
resume/fork), so nothing is repo-global. A session binds **explicitly, never automatically**:
|
|
9
|
+
`flow start` binds its own feature, `flow use <slug>` takes one over — even the lone unfinished
|
|
10
|
+
feature waits to be claimed. Every bind leaves a claim (`claim.json`, session + pid),
|
|
11
|
+
and the gates honor the claim too:
|
|
12
12
|
passing another session's slug to `flow approve`/`verify`/`finish` is refused until you take over,
|
|
13
13
|
or two sessions quietly overwrite one state file. `flow use <slug>` switches, and ambiguous sessions must
|
|
14
14
|
bind or pass explicit slugs. With nothing unfinished and no binding, the session must start a
|
package/docs/gates.md
CHANGED
|
@@ -19,7 +19,7 @@ so it needs no `--confirmed`.
|
|
|
19
19
|
| `release [--yolo|--no-version|--no-fold-check]` | pre-release → release | checks re-greened after the prep edits; 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 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`** (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) |
|
|
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 |
|
|
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; 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
|
-
| `reflect ["<note>"]` | — | `reflect "<note>"` queues a suggestion in `reflections.md` (never gates; gate flags such as `--confirmed` are ignored, they never become part of the note). Bare `reflect` prints the full **session-reflection protocol** for the agent (from the `/flow reflect` bar it additionally wakes the model, so the protocol executes immediately): review the whole session log, re-check every open item against the current playbook and **newer dev-flow versions** (`npm view pi-dev-flow version` vs the running version — dev-flow ships from npm; recommend `pi install npm:pi-dev-flow` + `/reload`, the operator performs updates), dedupe new findings against the open ones, then report playbook vs plugin items to the operator and ask whether to fix now — plugin items: search upstream issues first (`gh issue list --repo <upstream> --state all --search …`; an author-addressed match is reported back, no match → `gh issue create` with a detailed description and a suggested fix), playbook items: `flow doctor` routes each to the docs flow that implements it |
|
|
22
|
+
| `reflect ["<note>"|tidy]` | — | `reflect "<note>"` queues a suggestion in `reflections.md` (never gates; gate flags such as `--confirmed` are ignored, they never become part of the note). `reflect tidy` drops the closed (`- [x]`) items — the preamble and open items stay verbatim and a `## section` heading left empty goes with its items; every surface that queues or reviews reflections (`reflect "<note>"`, bare `reflect`, `doctor`) nudges with the closed count when the checked-off pile grows. Bare `reflect` prints the full **session-reflection protocol** for the agent (from the `/flow reflect` bar it additionally wakes the model, so the protocol executes immediately): review the whole session log, re-check every open item against the current playbook and **newer dev-flow versions** (`npm view pi-dev-flow version` vs the running version — dev-flow ships from npm; recommend `pi install npm:pi-dev-flow` + `/reload`, the operator performs updates), dedupe new findings against the open ones, then report playbook vs plugin items to the operator and ask whether to fix now — plugin items: search upstream issues first (`gh issue list --repo <upstream> --state all --search …`; an author-addressed match is reported back, no match → `gh issue create` with a detailed description and a suggested fix), playbook items: `flow doctor` routes each to the docs flow that implements it |
|
|
23
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 |
|
|
24
24
|
| `doctor ["<issue note>"]` | — | read-only findings: playbook drift, dead commands/scripts, untracked playbook, ghost feature dirs, orphan worktrees/branches — **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). 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 |
|
|
25
25
|
| `status [slug]` / `abort [slug]` | — | — |
|
package/docs/guardrails.md
CHANGED
|
@@ -14,7 +14,7 @@ While a feature is active, the extension intercepts every tool call:
|
|
|
14
14
|
- **Shell calls can't hang forever**: pi kills a shell command only when the model passed a `timeout` — it omits one in ~75% of calls, so a `gh` waiting on a prompt or a dead `curl` froze sessions for hours. By default the call is therefore **refused** until the model states one (`bashTimeout = require`): the refusal names the exact value the class table would have armed, so the retry is a one-token fix and the call line in the transcript shows the timeout that is actually running. The injected class default (30s quick inspection · 120s local git and unknown · 180s network · 300s containers/services · 900s builds/tests/installs · 1,200s watchers like `gh run watch`) stays armed underneath either way, and absurd explicit values clamp to 1,800s. A project that would rather not nag sets `bashTimeout = inject` in `## global` — then the default is armed silently and the call passes. It applies to every session that loads the package, flow-bound or not (a session with no playbook has no way to opt out).
|
|
15
15
|
- **Compact-aware**: dev-flow paces compaction the way pi counts it: the self-compaction trigger uses the *effective* `reserveTokens` (settings and per-model overrides, not the built-in default) and is checked at every turn end, not only when a run settles. When pi force-compacts on its threshold anyway — the chat-only states (open tier-2 dialog, plan discussion not yet in `plan/`) refuse to self-compact by design — dev-flow takes the compaction over and redoes it with flow-aware summary instructions (overflow recovery keeps pi's compact-and-retry and is left alone). Auto-compaction turned off in settings is honored; a note about any compaction dev-flow could not shape still lands in `reflections.md`.
|
|
16
16
|
- The active stage is injected into the model's context every turn; the bundled `dev-flow` skill is the agent's playbook, including the recommended sequences: pre-release — review (`/ponytail-review`) → fixes → docs → changelog/version bump; release — PR → merge → tag → `release-done`.
|
|
17
|
-
- **Status bar**: while
|
|
17
|
+
- **Status bar**: while the session **is bound** to a feature the pi footer shows `<stage glyph> <slug>` plus mode markers — stages 📝 plan, 🔨 implement, 🔍 pre-release, 🚀 release; markers ⚡ patch, 📚 docs, 🎱 yolo, and `⚠️` while a check of the bound feature fails (emoji render in their own color, so the footer carries no theme coloring). An **unbound** session never sees a slug — it shows `⧖ N flow(s) open` (unfinished-feature count only, no warning marker), or nothing when nothing is in flight; a session binds only via `flow start`/`flow use`, never by opening. `flow status` is the spelled-out surface: `stage=implement`, the per-feature mode tags (`[ui]`, `[yolo]`, `[no-version]`) and the `flow=<ver>` stamp of the build that started the feature.
|
|
18
18
|
|
|
19
19
|
## Limitations (deliberate, v1)
|
|
20
20
|
|
package/docs/headless.md
CHANGED
|
@@ -29,8 +29,8 @@ The contract a headless driver (a session with no UI) relies on:
|
|
|
29
29
|
`.dev-flow/`: `status`, `help`, `version`, `doctor`, `roadmap` (list).
|
|
30
30
|
- **One session = one feature.** Bindings are per-session and survive resume/fork; a
|
|
31
31
|
reconnecting driver either rejoins the same session or rebinds with `flow use <slug>`.
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
Nothing auto-binds — always bind explicitly or pass the slug explicitly.
|
|
33
|
+
Parallel features = parallel sessions.
|
|
34
34
|
- **Budget for long gates.** `approve` runs `commands.setup`; `verify` runs build and the
|
|
35
35
|
`dev` deploy (runs are killed past 15 min) and re-probes health with `healthWait` retries.
|
|
36
36
|
A remote timeout must be minutes, not seconds — the gate prints progress lines while it
|
package/docs/playbook.md
CHANGED
|
@@ -162,7 +162,8 @@ anything (findings are also printed whenever `flow init` runs without a UI, e.g.
|
|
|
162
162
|
rewrites from fresh detection. Improvement
|
|
163
163
|
ideas the agent notices along the way queue up in `.dev-flow/reflections.md` under `## playbook`
|
|
164
164
|
(what to change in *your* playbook) and `## plugin` (what to change in dev-flow itself) —
|
|
165
|
-
`flow reflect "<note>"` appends them,
|
|
165
|
+
`flow reflect "<note>"` appends them, `flow reflect tidy` drops the closed (`- [x]`) ones,
|
|
166
|
+
plain `flow doctor` reviews the open ones and routes
|
|
166
167
|
each fix to the flow that implements it (docs flow for playbook items — those edits only pass a
|
|
167
168
|
docs/patch flow's worktree), bare `flow reflect` hands the agent the full end-of-session
|
|
168
169
|
reflection protocol (review the session log, re-check open items against fixes that already
|
package/extensions/dev-flow.ts
CHANGED
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
classifyMergeHistory,
|
|
44
44
|
cmpVersions,
|
|
45
45
|
cleanupAssess,
|
|
46
|
+
closedReflectionCount,
|
|
46
47
|
compactionReflectionLine,
|
|
47
48
|
detectForge,
|
|
48
49
|
featureBranchPrefix,
|
|
@@ -70,6 +71,8 @@ import {
|
|
|
70
71
|
reflectSections,
|
|
71
72
|
reflectionLine,
|
|
72
73
|
reflectionRoutes,
|
|
74
|
+
reflectionsTidy,
|
|
75
|
+
reflectionsTidyHint,
|
|
73
76
|
sessionRunsOlderBuild,
|
|
74
77
|
|
|
75
78
|
listFiles,
|
|
@@ -91,7 +94,7 @@ import {
|
|
|
91
94
|
shouldSelfCompact,
|
|
92
95
|
shouldTakeOverCompaction,
|
|
93
96
|
stateTamper,
|
|
94
|
-
|
|
97
|
+
statusFor,
|
|
95
98
|
statusJson,
|
|
96
99
|
subst,
|
|
97
100
|
sq,
|
|
@@ -281,7 +284,7 @@ async function releaseTags(root: string): Promise<string[] | null> {
|
|
|
281
284
|
}
|
|
282
285
|
|
|
283
286
|
const GATE_HELP =
|
|
284
|
-
"help [--json] | init [--force|--draft|--write <text>] | reflect [<note
|
|
287
|
+
"help [--json] | init [--force|--draft|--write <text>] | reflect [<note>|tidy] | roadmap [add <text>|pick <n> <slug>|done <n>|tidy] | doctor [<issue note>] | status [slug] [--json] | start <slug> [--ui] [--force] [--patch|--docs --confirmed] [--merge=squash|merge|rebase|any] [--check-upstream] | use <slug> | test | check | health | approve [--yolo] | verify [--yolo] | release [--yolo|--no-version|--no-fold-check] | release-done [--no-artifact-check|--no-release-create] | finish [--yolo] [slug] | abort [slug] | version [--check-upstream] — start preflights the playbook before creating anything: it prints playbook gaps and warns when the session runs an older dev-flow build, and it refuses until a merge policy is set (ask the operator squash / merge / rebase / any in chat, then re-run with --merge=<style> --confirmed — the answer is written into project.md and enforced from then on: gh/glab merges that contradict it are blocked, and release-done proves what actually landed); version prints the loaded build and names any other dev-flow copies registered in the same process (--check-upstream also asks the registry for the published one) — reflect <note> queues a suggestion in reflections.md (gate flags like --confirmed are ignored there); reflect tidy drops the closed (`- [x]`) items from reflections.md — every surface that queues or reviews reflections nudges when the checked-off pile grows; bare reflect prints the full session-reflection protocol (review the session log, re-check open items against shipped fixes and newer dev-flow versions, dedupe and report new findings, put the fix decision to the operator); roadmap manages .dev-flow/roadmap.md, the gitignored backlog of future features (bare lists open items; add appends one; pick <n> <slug> stamps open item <n> with the slug a later flow start uses — flow finish checks it off when that feature ships; done <n> checks off by hand; tidy drops done items); bare doctor reviews structure, git consistency and open reflections (routes each fix to a flow; it never writes); doctor <note> prints an investigation brief for a fresh observation; state gates take [slug] and --confirmed (the operator already answered in chat); --patch/--docs likewise need --confirmed (the operator granted the mode); --yolo on any state gate (approve/verify/release/finish) = the operator said \"yolo\" at that checkpoint: it answers that question and pre-confirms every later one (needs --confirmed; checks and guardrails stay); release --no-fold-check = operator-granted escape from the changelog fold proofs (the entries pending before the release are not line-checked; the entry heading and the 'this branch touched the changelog' proofs stay); release --no-version = this flow ships merge + changelog only — no bump, tag or forge release; the entry rides under Unreleased until the next versioned release folds it (default: versioned); when the session runs an older dev-flow build than the checkout, release names both builds, lists what the running code can no longer prove, and asks the operator update (/reload) or proceed with the old release — an operator decision recorded in state and repeated by release-done, never a block";
|
|
285
288
|
const featDir = (root: string, slug: string) => path.join(dfDir(root), slug);
|
|
286
289
|
const stateFile = (root: string, slug: string) => path.join(featDir(root, slug), "state.json");
|
|
287
290
|
const claimFile = (root: string, slug: string) => path.join(featDir(root, slug), "claim.json");
|
|
@@ -341,32 +344,31 @@ const readReflections = (root: string): string[] => {
|
|
|
341
344
|
return existsSync(f) ? openReflections(readFileSync(f, "utf8")) : [];
|
|
342
345
|
};
|
|
343
346
|
|
|
347
|
+
/** Raw reflections.md content — the closed-item count needs the checked lines the open-only reader drops. */
|
|
348
|
+
const readReflectionsText = (root: string): string => {
|
|
349
|
+
const f = path.join(dfDir(root), "reflections.md");
|
|
350
|
+
return existsSync(f) ? readFileSync(f, "utf8") : "";
|
|
351
|
+
};
|
|
352
|
+
|
|
344
353
|
const roadmapFile = (root: string) => path.join(dfDir(root), "roadmap.md");
|
|
345
354
|
const readRoadmap = (root: string): string => {
|
|
346
355
|
const f = roadmapFile(root);
|
|
347
356
|
return existsSync(f) ? readFileSync(f, "utf8") : "";
|
|
348
357
|
};
|
|
349
358
|
|
|
350
|
-
/** The session's feature
|
|
359
|
+
/** The session's feature — explicit bindings only: flow start/flow use bind, resume restores from session
|
|
360
|
+
* history. Never binds on its own: an unbound session stays unbound however few features are unfinished,
|
|
361
|
+
* and reading it must never claim anything. The claim on disk IS the persisted binding — bind() stamps the
|
|
362
|
+
* session key into claim.json — so trust the disk after the in-memory map: a second registered dev-flow
|
|
363
|
+
* copy (both copies evaluate the guard hooks) or a re-instantiated module then attributes the session's
|
|
364
|
+
* own feature from disk instead of misjudging with stage null. */
|
|
351
365
|
function boundFeature(root: string, key: string): FlowState | null {
|
|
352
366
|
const bound = bindings.get(key);
|
|
353
367
|
if (bound) {
|
|
354
368
|
const s = readState(root, bound);
|
|
355
369
|
if (s && s.stage !== "done") return s;
|
|
356
370
|
}
|
|
357
|
-
|
|
358
|
-
// the claim is the persisted binding: bind() already stamps the session key into claim.json, so
|
|
359
|
-
// trust the disk after the in-memory map — a second registered dev-flow copy (both copies
|
|
360
|
-
// evaluate the guard hooks) or a re-instantiated module then attributes the session's own
|
|
361
|
-
// feature from disk instead of misjudging with stage null
|
|
362
|
-
const mine = un.find((s) => readClaim(root, s.slug)?.key === key);
|
|
363
|
-
if (mine) return mine;
|
|
364
|
-
if (un.length !== 1) return null;
|
|
365
|
-
const claim = readClaim(root, un[0].slug);
|
|
366
|
-
// shortcut: liveness is pid-only — pid reuse can read "live" and force an explicit flow use; friction only, never a wrong commit.
|
|
367
|
-
if (claimBlocks(claim, key)) return null;
|
|
368
|
-
if (claim?.key !== key) writeClaim(root, un[0].slug, key);
|
|
369
|
-
return un[0];
|
|
371
|
+
return unfinishedStates(root).find((s) => readClaim(root, s.slug)?.key === key) ?? null;
|
|
370
372
|
}
|
|
371
373
|
|
|
372
374
|
function readClaim(root: string, slug: string): SessionClaim | null {
|
|
@@ -394,7 +396,7 @@ function releaseSession(root: string, key: string): void {
|
|
|
394
396
|
}
|
|
395
397
|
}
|
|
396
398
|
|
|
397
|
-
/**
|
|
399
|
+
/** A lone unfinished feature another live session holds — lets the unbound-context message name it and offer the explicit takeover. */
|
|
398
400
|
function claimBlocker(root: string, key: string): { state: FlowState; claim: SessionClaim } | null {
|
|
399
401
|
const un = unfinishedStates(root);
|
|
400
402
|
if (un.length !== 1) return null;
|
|
@@ -600,7 +602,21 @@ function reflectNote(root: string, sess: Session, note: string[]): RunResult {
|
|
|
600
602
|
const next = appendReflection(text, sections, line);
|
|
601
603
|
if (next === text) return { text: `already reflected (duplicate): ${line}` };
|
|
602
604
|
writeFileSync(file, next);
|
|
603
|
-
|
|
605
|
+
// queueing is exactly when the operator hears about the checked-off pile — nudge instead of letting it grow
|
|
606
|
+
const closed = closedReflectionCount(next);
|
|
607
|
+
return { text: `reflected (${sections.join(" + ")}): ${line}` + (closed ? `\n${reflectionsTidyHint(closed)}` : "") };
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/** `flow reflect tidy` — drop the closed (`- [x]`) items; the `— fixed:` note already recorded the outcome. */
|
|
611
|
+
function reflectTidy(root: string): RunResult {
|
|
612
|
+
const file = path.join(dfDir(root), "reflections.md");
|
|
613
|
+
if (!existsSync(file)) return { text: "reflections: nothing to tidy (no queue yet)" };
|
|
614
|
+
const text = readFileSync(file, "utf8");
|
|
615
|
+
const closed = closedReflectionCount(text);
|
|
616
|
+
const open = openReflections(text).length;
|
|
617
|
+
if (!closed) return { text: `reflections: nothing to tidy (${open} open, 0 closed)` };
|
|
618
|
+
writeFileSync(file, reflectionsTidy(text));
|
|
619
|
+
return { text: `reflections: dropped ${closed} closed item(s) — ${open} open` };
|
|
604
620
|
}
|
|
605
621
|
|
|
606
622
|
/** Single runner for both the /flow command and the flow tool. */
|
|
@@ -818,8 +834,7 @@ ${mdDigest(draftRefresh)}`))
|
|
|
818
834
|
const rmap = roadmapOpenCount(readRoadmap(root));
|
|
819
835
|
const rmapLine = rmap ? [`◇ ${rmap} roadmap item(s) open — flow roadmap`] : [];
|
|
820
836
|
const slugs = slugArg ? [slugArg] : existsSync(df) ? (await listDirs(df)).filter((s) => readState(root, s)) : [];
|
|
821
|
-
const
|
|
822
|
-
const cur = sess.slug ?? (un0.length === 1 ? un0[0].slug : null);
|
|
837
|
+
const cur = sess.slug; // only a bound session has a current feature — the lone-unfinished hint would pose unbound sessions as owning it
|
|
823
838
|
if (flag("json")) {
|
|
824
839
|
const sts = slugs.map((s) => readState(root, s)).filter((s): s is FlowState => s !== null);
|
|
825
840
|
return { text: statusJson(sts, cur, cfg) }; // before the prose "no features" answer — an orchestrator must be able to parse the empty case too
|
|
@@ -848,11 +863,13 @@ ${mdDigest(draftRefresh)}`))
|
|
|
848
863
|
// gate flags belong to the state verbs — pasted into the note they read as part of the operator's
|
|
849
864
|
// own sentence in reflections.md (#43)
|
|
850
865
|
const words = rest.filter((a) => !a.startsWith("--"));
|
|
866
|
+
// the single word `tidy` is a verb (roadmap-style); a note merely starting with it stays a note
|
|
867
|
+
if (words.length === 1 && words[0] === "tidy") return reflectTidy(root);
|
|
851
868
|
if (words.length) return reflectNote(root, sess, words);
|
|
852
869
|
// upstream for the update probe: the manifest's repository field; the dev-flow checkout itself falls back to its origin
|
|
853
870
|
const self = pluginVersion(import.meta.dirname);
|
|
854
871
|
const upstream = self.repo || (isSelfRepo(root) ? githubSlug((await sh("git remote get-url origin", root)).out) : "");
|
|
855
|
-
return { text: reflectProtocol(readReflections(root), isSelfRepo(root), { version: self.version, upstream }).join("\n") };
|
|
872
|
+
return { text: reflectProtocol(readReflections(root), isSelfRepo(root), { version: self.version, upstream, closed: closedReflectionCount(readReflectionsText(root)) }).join("\n") };
|
|
856
873
|
}
|
|
857
874
|
|
|
858
875
|
case "roadmap": {
|
|
@@ -909,6 +926,8 @@ ${mdDigest(draftRefresh)}`))
|
|
|
909
926
|
findings.push(`reflection review — ${refl.length} open item(s); doctor never implements: investigate each, present the fix, the operator confirms, then the routed flow implements it:`);
|
|
910
927
|
for (const r of reflectionRoutes(refl, isSelfRepo(root))) findings.push(` [${r.sections.join("+")}] ${r.text}\n → ${r.route}`);
|
|
911
928
|
}
|
|
929
|
+
const closedRefl = closedReflectionCount(readReflectionsText(root));
|
|
930
|
+
if (closedRefl) findings.push(reflectionsTidyHint(closedRefl));
|
|
912
931
|
if (!rest.length) return { text: findings.length ? `doctor: ${findings.length} finding(s)\n${findings.map((f) => ` ${f}`).join("\n")}` : "doctor: no findings — playbook, flow state and git layout are consistent" };
|
|
913
932
|
// flow doctor <note>: a fresh observation gets an investigation brief and a fix route
|
|
914
933
|
return { text: investigationBrief(rest.filter((a) => !a.startsWith("--")).join(" "), isSelfRepo(root)).join("\n") };
|
|
@@ -1492,8 +1511,8 @@ ${mdDigest(draftRefresh)}`))
|
|
|
1492
1511
|
const st = readState(root, target);
|
|
1493
1512
|
if (sess.slug === target) sess.bind(null);
|
|
1494
1513
|
if (st && !st.worktree) {
|
|
1495
|
-
// plan-stage abort = drop: no worktree/branch exists, so the state dir
|
|
1496
|
-
// the
|
|
1514
|
+
// plan-stage abort = drop: no worktree/branch exists, so the state dir would linger
|
|
1515
|
+
// as a ghost the doctor flags (a plan/ whose state.json is gone)
|
|
1497
1516
|
rmSync(featDir(root, target), { recursive: true, force: true });
|
|
1498
1517
|
return { text: `aborted ${target} — feature removed (nothing approved, nothing to recover)` };
|
|
1499
1518
|
}
|
|
@@ -1511,12 +1530,13 @@ async function currentBranch(root: string): Promise<string> {
|
|
|
1511
1530
|
}
|
|
1512
1531
|
|
|
1513
1532
|
function needState(root: string, sess: Session, slugArg?: string): { state: FlowState | null; err?: RunResult } {
|
|
1514
|
-
|
|
1533
|
+
// no implicit feature: gates run on this session's binding or an explicit slug — never on "the one
|
|
1534
|
+
// feature left", which is how an unbound session would end up steering a flow it never took
|
|
1535
|
+
const slug = slugArg ?? sess.slug;
|
|
1515
1536
|
if (!slug) {
|
|
1516
1537
|
const un = unfinishedStates(root);
|
|
1517
|
-
if (un.length
|
|
1518
|
-
|
|
1519
|
-
else return { state: null, err: { text: `multiple unfinished features (${un.map((s) => s.slug).join(", ")}) — flow use <slug> or pass an explicit slug`, isError: true } };
|
|
1538
|
+
if (!un.length) return { state: null, err: { text: "no unfinished features — flow start <slug> [--ui]", isError: true } };
|
|
1539
|
+
return { state: null, err: { text: `nothing bound — flow use <slug> or pass an explicit slug (unfinished: ${un.map((s) => s.slug).join(", ")})`, isError: true } };
|
|
1520
1540
|
}
|
|
1521
1541
|
const state = readState(root, slug);
|
|
1522
1542
|
if (!state) return { state: null, err: { text: `no state for feature ${slug}`, isError: true } };
|
|
@@ -1540,16 +1560,13 @@ function tail(out: string, n = 15): string {
|
|
|
1540
1560
|
|
|
1541
1561
|
// ------------------------------------------------------------------ extension
|
|
1542
1562
|
|
|
1543
|
-
/** Compact footer
|
|
1563
|
+
/** Compact footer: bound flow = stage glyph, slug, mode markers, ⚠️ on its failing checks; unbound = the
|
|
1564
|
+
* count of unfinished flows only (statusFor). Pure read — rendering never binds or claims anything. */
|
|
1544
1565
|
function refreshStatus(ctx: ExtensionContext): void {
|
|
1545
1566
|
if (!ctx.hasUI) return;
|
|
1546
|
-
const
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
return;
|
|
1550
|
-
}
|
|
1551
|
-
const { text, failed } = statusCompact(st);
|
|
1552
|
-
ctx.ui.setStatus("dev-flow", failed ? `${text} ⚠️` : text);
|
|
1567
|
+
const open = existsSync(dfDir(ctx.cwd)) ? unfinishedStates(ctx.cwd).length : 0;
|
|
1568
|
+
const s = statusFor(boundFeature(ctx.cwd, sessionKey(ctx)), open);
|
|
1569
|
+
ctx.ui.setStatus("dev-flow", s ? s.text : undefined);
|
|
1553
1570
|
}
|
|
1554
1571
|
|
|
1555
1572
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.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": [
|
package/skills/dev-flow/SKILL.md
CHANGED
|
@@ -27,11 +27,12 @@ Ground rules:
|
|
|
27
27
|
`/reload` when `flow version` says this session runs an older build).
|
|
28
28
|
|
|
29
29
|
- **One session = exactly one feature** (flow + branch + worktree); parallel
|
|
30
|
-
sessions, one feature each, are the model.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
sessions, one feature each, are the model. A session binds **explicitly and
|
|
31
|
+
only**: `flow start <slug>` sets the bind (main checkout must be on the
|
|
32
|
+
default branch); `flow use <slug>` takes over an open or foreign-held
|
|
33
|
+
feature. Nothing auto-binds — a new session with unfinished features stays
|
|
34
|
+
unbound until someone says `flow use`. Unbound: the footer shows only the
|
|
35
|
+
open-feature count, gates demand an explicit slug and main-checkout writes
|
|
35
36
|
stay blocked. There is no bypass — an unbound session cannot edit source.
|
|
36
37
|
- **Project `flow-guard` rules** (`deny`/`confirm`/`protect`/`forbid` in
|
|
37
38
|
project.md `## global`) apply at **every** stage and are judged ahead of
|
|
@@ -361,6 +362,10 @@ a note about both goes to both. The open count shows in status and stage
|
|
|
361
362
|
context; the operator decides:
|
|
362
363
|
|
|
363
364
|
- Reflect real friction only, one line each, never the same issue twice.
|
|
365
|
+
- **`flow reflect tidy` drops the closed (`- [x]`) items** — the `— fixed:` note has
|
|
366
|
+
already recorded the outcome, so the check-off is history and the file stays
|
|
367
|
+
scannable. Queueing a note, bare `reflect` and `doctor` all print the closed
|
|
368
|
+
count with this verb when the pile grows; offer the tidy to the operator then.
|
|
364
369
|
- **Bare `flow reflect` is the end-of-session reflection** — it runs as part
|
|
365
370
|
of every finish (before the slug folder is deleted — see Stage: finish) and
|
|
366
371
|
whenever the operator asks. It prints the
|
package/src/core.ts
CHANGED
|
@@ -1189,7 +1189,7 @@ export function pidAlive(pid: number): boolean {
|
|
|
1189
1189
|
}
|
|
1190
1190
|
}
|
|
1191
1191
|
|
|
1192
|
-
/** True only when another live session holds the claim —
|
|
1192
|
+
/** True only when another live session holds the claim — its feature can only be taken by an explicit `flow use`, never quietly. */
|
|
1193
1193
|
export function claimBlocks(claim: SessionClaim | null, myKey: string, alive: (pid: number) => boolean = pidAlive): boolean {
|
|
1194
1194
|
return !!claim && claim.key !== myKey && alive(claim.pid);
|
|
1195
1195
|
}
|
|
@@ -1202,6 +1202,18 @@ export function statusCompact(state: FlowState): { text: string; failed: boolean
|
|
|
1202
1202
|
return { text: `${STAGE_EMOJI[state.stage]} ${state.slug}${state.patch ? " ⚡" : state.docs ? " 📚" : ""}${state.yolo ? " 🎱" : ""}`, failed };
|
|
1203
1203
|
}
|
|
1204
1204
|
|
|
1205
|
+
/** Footer decision for any session: a bound feature renders as statusCompact, its ⚠️ from its own failing
|
|
1206
|
+
* checks only; an unbound session shows the count of unfinished features — never a slug, so a fresh
|
|
1207
|
+
* session is never shown (or made to feel bound to) a feature it did not take with flow use. null clears. */
|
|
1208
|
+
export function statusFor(bound: FlowState | null, openCount: number): { text: string } | null {
|
|
1209
|
+
if (bound && bound.stage !== "done") {
|
|
1210
|
+
const { text, failed } = statusCompact(bound);
|
|
1211
|
+
return { text: failed ? `${text} ⚠️` : text };
|
|
1212
|
+
}
|
|
1213
|
+
if (openCount < 1) return null;
|
|
1214
|
+
return { text: `⧖ ${openCount} flow${openCount === 1 ? "" : "s"} open` };
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1205
1217
|
/** `- [ ]` checklist items of a markdown document (reflections.md and roadmap.md share the format). */
|
|
1206
1218
|
export function openChecklistItems(text: string): string[] {
|
|
1207
1219
|
return text.split("\n").map((l) => l.trim()).filter((l) => l.startsWith("- [ ] "));
|
|
@@ -1212,6 +1224,44 @@ export function openReflections(text: string): string[] {
|
|
|
1212
1224
|
return openChecklistItems(text);
|
|
1213
1225
|
}
|
|
1214
1226
|
|
|
1227
|
+
/** Closed (checked-off) reflection items — what `flow reflect tidy` drops (roadmap shares the checkbox test). */
|
|
1228
|
+
export const closedReflectionCount = (text: string) => text.split("\n").filter(isDoneItem).length;
|
|
1229
|
+
|
|
1230
|
+
/** Drop the closed (`- [x]`) reflection items: the preamble and the open lines stay verbatim
|
|
1231
|
+
* (a line filter — no re-bucketing like appendReflection's rewrite), and a `## section` heading
|
|
1232
|
+
* left with no open items under it goes with its items. */
|
|
1233
|
+
export function reflectionsTidy(text: string): string {
|
|
1234
|
+
const headerRe = new RegExp(`^## (${REFLECT_SECTIONS.join("|")})\\s*$`, "i");
|
|
1235
|
+
const lines = text.split("\n");
|
|
1236
|
+
// pass 1: open items per heading decides which sections survive; items above every heading are legacy flat lines with no heading to drop
|
|
1237
|
+
let section: string | null = null;
|
|
1238
|
+
const openUnder = new Map<string, number>();
|
|
1239
|
+
for (const raw of lines) {
|
|
1240
|
+
const l = raw.trim();
|
|
1241
|
+
const h = headerRe.exec(l);
|
|
1242
|
+
if (h) section = h[1].toLowerCase();
|
|
1243
|
+
else if (section && isOpenItem(l)) openUnder.set(section, (openUnder.get(section) ?? 0) + 1);
|
|
1244
|
+
}
|
|
1245
|
+
// pass 2: closed items never survive; an emptied heading never survives
|
|
1246
|
+
const out: string[] = [];
|
|
1247
|
+
section = null;
|
|
1248
|
+
for (const raw of lines) {
|
|
1249
|
+
const l = raw.trim();
|
|
1250
|
+
const h = headerRe.exec(l);
|
|
1251
|
+
if (h) {
|
|
1252
|
+
section = h[1].toLowerCase();
|
|
1253
|
+
if ((openUnder.get(section) ?? 0) > 0) out.push(raw);
|
|
1254
|
+
continue;
|
|
1255
|
+
}
|
|
1256
|
+
if (isDoneItem(raw)) continue;
|
|
1257
|
+
out.push(raw);
|
|
1258
|
+
}
|
|
1259
|
+
return out.join("\n").replace(/\n{3,}/g, "\n\n");
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
/** Shared wording for every surface that notices closed items piling up, so all hints read alike. */
|
|
1263
|
+
export const reflectionsTidyHint = (closed: number) => `↻ ${closed} closed reflection(s) — flow reflect tidy drops them`;
|
|
1264
|
+
|
|
1215
1265
|
/** The note text of an item, without the checkbox and without the trailing ` — <attribution>`: what
|
|
1216
1266
|
* two reflects are compared on, so the same note at another date is still the same note.
|
|
1217
1267
|
* shortcut: split on the last em dash — matches what the tool writes; a hand-written item ending in
|
|
@@ -1278,7 +1328,7 @@ export function investigationBrief(note: string, selfRepo: boolean): string[] {
|
|
|
1278
1328
|
/** Bare `flow reflect`: the full session-reflection protocol for the agent (the plugin has no LLM —
|
|
1279
1329
|
* the agent reviews the session log, re-checks open items against shipped fixes, dedupes new
|
|
1280
1330
|
* findings and puts the fix decision to the operator). Writes nothing, runs no network calls. */
|
|
1281
|
-
export function reflectProtocol(items: string[], selfRepo: boolean, facts: { version: string | null; upstream: string }): string[] {
|
|
1331
|
+
export function reflectProtocol(items: string[], selfRepo: boolean, facts: { version: string | null; upstream: string; closed?: number }): string[] {
|
|
1282
1332
|
const ver = facts.version ? `dev-flow ${facts.version}` : "dev-flow version unknown";
|
|
1283
1333
|
const up = facts.upstream || "<upstream — ask the operator for the dev-flow repo>";
|
|
1284
1334
|
const url = facts.upstream ? `https://github.com/${facts.upstream}` : "<upstream-url>";
|
|
@@ -1293,6 +1343,7 @@ export function reflectProtocol(items: string[], selfRepo: boolean, facts: { ver
|
|
|
1293
1343
|
` a. plugin items: search upstream first — gh issue list --repo ${up} --state all --search "<keywords>" — an author-addressed match → report the verdict back to the operator (fixed in v… / closed won't-fix + reason), do not re-file; no match → gh issue create --repo ${up} with a detailed description, session evidence and a suggested fix.`,
|
|
1294
1344
|
" b. playbook items: run flow doctor — it reviews each open item and routes it to the docs flow that implements the fix.",
|
|
1295
1345
|
];
|
|
1346
|
+
if (facts.closed) lines.push(`${reflectionsTidyHint(facts.closed)} — check an item off only when it is handled; tidy once the checked-off pile grows.`);
|
|
1296
1347
|
if (!items.length) lines.push("open items: none — steps 1 and 3 still apply.");
|
|
1297
1348
|
else {
|
|
1298
1349
|
lines.push(`open items (${items.length}):`);
|
package/src/projectmd.ts
CHANGED
|
@@ -312,7 +312,7 @@ const safeJson = (s: string): unknown => {
|
|
|
312
312
|
|
|
313
313
|
/** `.dev-flow/<slug>/` directories holding a plan/ with no state.json — a closed or aborted feature
|
|
314
314
|
* whose directory outlived its flow state (a hand-close from before auto-close, an interrupted
|
|
315
|
-
* start). Nothing reads them: `flow status`, the guards and
|
|
315
|
+
* start). Nothing reads them: `flow status`, the guards and the footer all key off state.json.
|
|
316
316
|
* Root-relative paths, for the doctor report and the operator-confirmed remover. */
|
|
317
317
|
export function ghostFeatureDirs(root: string): string[] {
|
|
318
318
|
const df = path.join(root, ".dev-flow");
|