pi-dev-flow 0.55.1 → 0.56.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 CHANGED
@@ -4,7 +4,11 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
- ## [0.55.1] - 2026-10-22
7
+ ## [0.56.0] - 2026-10-22
8
+
9
+ ### Added
10
+
11
+ - **`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
12
 
9
13
  ### Fixed
10
14
 
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/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, plain `flow doctor` reviews the open ones and routes
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
@@ -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,
@@ -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>] | 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); 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";
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,6 +344,12 @@ 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);
@@ -600,7 +609,21 @@ function reflectNote(root: string, sess: Session, note: string[]): RunResult {
600
609
  const next = appendReflection(text, sections, line);
601
610
  if (next === text) return { text: `already reflected (duplicate): ${line}` };
602
611
  writeFileSync(file, next);
603
- return { text: `reflected (${sections.join(" + ")}): ${line}` };
612
+ // queueing is exactly when the operator hears about the checked-off pile — nudge instead of letting it grow
613
+ const closed = closedReflectionCount(next);
614
+ return { text: `reflected (${sections.join(" + ")}): ${line}` + (closed ? `\n${reflectionsTidyHint(closed)}` : "") };
615
+ }
616
+
617
+ /** `flow reflect tidy` — drop the closed (`- [x]`) items; the `— fixed:` note already recorded the outcome. */
618
+ function reflectTidy(root: string): RunResult {
619
+ const file = path.join(dfDir(root), "reflections.md");
620
+ if (!existsSync(file)) return { text: "reflections: nothing to tidy (no queue yet)" };
621
+ const text = readFileSync(file, "utf8");
622
+ const closed = closedReflectionCount(text);
623
+ const open = openReflections(text).length;
624
+ if (!closed) return { text: `reflections: nothing to tidy (${open} open, 0 closed)` };
625
+ writeFileSync(file, reflectionsTidy(text));
626
+ return { text: `reflections: dropped ${closed} closed item(s) — ${open} open` };
604
627
  }
605
628
 
606
629
  /** Single runner for both the /flow command and the flow tool. */
@@ -848,11 +871,13 @@ ${mdDigest(draftRefresh)}`))
848
871
  // gate flags belong to the state verbs — pasted into the note they read as part of the operator's
849
872
  // own sentence in reflections.md (#43)
850
873
  const words = rest.filter((a) => !a.startsWith("--"));
874
+ // the single word `tidy` is a verb (roadmap-style); a note merely starting with it stays a note
875
+ if (words.length === 1 && words[0] === "tidy") return reflectTidy(root);
851
876
  if (words.length) return reflectNote(root, sess, words);
852
877
  // upstream for the update probe: the manifest's repository field; the dev-flow checkout itself falls back to its origin
853
878
  const self = pluginVersion(import.meta.dirname);
854
879
  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") };
880
+ return { text: reflectProtocol(readReflections(root), isSelfRepo(root), { version: self.version, upstream, closed: closedReflectionCount(readReflectionsText(root)) }).join("\n") };
856
881
  }
857
882
 
858
883
  case "roadmap": {
@@ -909,6 +934,8 @@ ${mdDigest(draftRefresh)}`))
909
934
  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
935
  for (const r of reflectionRoutes(refl, isSelfRepo(root))) findings.push(` [${r.sections.join("+")}] ${r.text}\n → ${r.route}`);
911
936
  }
937
+ const closedRefl = closedReflectionCount(readReflectionsText(root));
938
+ if (closedRefl) findings.push(reflectionsTidyHint(closedRefl));
912
939
  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
940
  // flow doctor <note>: a fresh observation gets an investigation brief and a fix route
914
941
  return { text: investigationBrief(rest.filter((a) => !a.startsWith("--")).join(" "), isSelfRepo(root)).join("\n") };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.55.1",
3
+ "version": "0.56.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": [
@@ -361,6 +361,10 @@ a note about both goes to both. The open count shows in status and stage
361
361
  context; the operator decides:
362
362
 
363
363
  - Reflect real friction only, one line each, never the same issue twice.
364
+ - **`flow reflect tidy` drops the closed (`- [x]`) items** — the `— fixed:` note has
365
+ already recorded the outcome, so the check-off is history and the file stays
366
+ scannable. Queueing a note, bare `reflect` and `doctor` all print the closed
367
+ count with this verb when the pile grows; offer the tidy to the operator then.
364
368
  - **Bare `flow reflect` is the end-of-session reflection** — it runs as part
365
369
  of every finish (before the slug folder is deleted — see Stage: finish) and
366
370
  whenever the operator asks. It prints the
package/src/core.ts CHANGED
@@ -1212,6 +1212,44 @@ export function openReflections(text: string): string[] {
1212
1212
  return openChecklistItems(text);
1213
1213
  }
1214
1214
 
1215
+ /** Closed (checked-off) reflection items — what `flow reflect tidy` drops (roadmap shares the checkbox test). */
1216
+ export const closedReflectionCount = (text: string) => text.split("\n").filter(isDoneItem).length;
1217
+
1218
+ /** Drop the closed (`- [x]`) reflection items: the preamble and the open lines stay verbatim
1219
+ * (a line filter — no re-bucketing like appendReflection's rewrite), and a `## section` heading
1220
+ * left with no open items under it goes with its items. */
1221
+ export function reflectionsTidy(text: string): string {
1222
+ const headerRe = new RegExp(`^## (${REFLECT_SECTIONS.join("|")})\\s*$`, "i");
1223
+ const lines = text.split("\n");
1224
+ // pass 1: open items per heading decides which sections survive; items above every heading are legacy flat lines with no heading to drop
1225
+ let section: string | null = null;
1226
+ const openUnder = new Map<string, number>();
1227
+ for (const raw of lines) {
1228
+ const l = raw.trim();
1229
+ const h = headerRe.exec(l);
1230
+ if (h) section = h[1].toLowerCase();
1231
+ else if (section && isOpenItem(l)) openUnder.set(section, (openUnder.get(section) ?? 0) + 1);
1232
+ }
1233
+ // pass 2: closed items never survive; an emptied heading never survives
1234
+ const out: string[] = [];
1235
+ section = null;
1236
+ for (const raw of lines) {
1237
+ const l = raw.trim();
1238
+ const h = headerRe.exec(l);
1239
+ if (h) {
1240
+ section = h[1].toLowerCase();
1241
+ if ((openUnder.get(section) ?? 0) > 0) out.push(raw);
1242
+ continue;
1243
+ }
1244
+ if (isDoneItem(raw)) continue;
1245
+ out.push(raw);
1246
+ }
1247
+ return out.join("\n").replace(/\n{3,}/g, "\n\n");
1248
+ }
1249
+
1250
+ /** Shared wording for every surface that notices closed items piling up, so all hints read alike. */
1251
+ export const reflectionsTidyHint = (closed: number) => `↻ ${closed} closed reflection(s) — flow reflect tidy drops them`;
1252
+
1215
1253
  /** The note text of an item, without the checkbox and without the trailing ` — <attribution>`: what
1216
1254
  * two reflects are compared on, so the same note at another date is still the same note.
1217
1255
  * shortcut: split on the last em dash — matches what the tool writes; a hand-written item ending in
@@ -1278,7 +1316,7 @@ export function investigationBrief(note: string, selfRepo: boolean): string[] {
1278
1316
  /** Bare `flow reflect`: the full session-reflection protocol for the agent (the plugin has no LLM —
1279
1317
  * the agent reviews the session log, re-checks open items against shipped fixes, dedupes new
1280
1318
  * 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[] {
1319
+ export function reflectProtocol(items: string[], selfRepo: boolean, facts: { version: string | null; upstream: string; closed?: number }): string[] {
1282
1320
  const ver = facts.version ? `dev-flow ${facts.version}` : "dev-flow version unknown";
1283
1321
  const up = facts.upstream || "<upstream — ask the operator for the dev-flow repo>";
1284
1322
  const url = facts.upstream ? `https://github.com/${facts.upstream}` : "<upstream-url>";
@@ -1293,6 +1331,7 @@ export function reflectProtocol(items: string[], selfRepo: boolean, facts: { ver
1293
1331
  ` 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
1332
  " b. playbook items: run flow doctor — it reviews each open item and routes it to the docs flow that implements the fix.",
1295
1333
  ];
1334
+ 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
1335
  if (!items.length) lines.push("open items: none — steps 1 and 3 still apply.");
1297
1336
  else {
1298
1337
  lines.push(`open items (${items.length}):`);