pi-dev-flow 0.76.1 → 0.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +24 -13
- package/docs/gates.md +1 -1
- package/docs/playbook.md +13 -10
- package/extensions/dev-flow.ts +178 -64
- package/package.json +1 -1
- package/skills/dev-flow/SKILL.md +2 -2
- package/skills/dev-flow/references/finish.md +30 -12
- package/skills/dev-flow/references/implement.md +4 -0
- package/skills/dev-flow/references/reflect.md +50 -50
- package/src/core.ts +309 -56
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.77.0] - 2026-11-03
|
|
8
|
+
|
|
9
|
+
**The finish reflection is done by a separate reviewer, and plugin feedback goes upstream.** The driving agent used to review its own session inline (biased, and blind to its workers' transcripts), wrote findings straight into the project's `reflections.md` — dev-flow complaints included — and reminded the operator about open reflections on every turn.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- `flow_stage` op `reflect`: a fresh read-only pi session reviews the driver's transcript and every `flow_stage` worker transcript (found by their `parentSession` header), re-checks the open items, dedupes against them and the upstream issues, and returns numbered findings — each **docs** / **code** / **plugin** with a **fold** or **drop** recommendation. It runs in the main checkout at any stage; finish is its standard moment. A reported run is recorded on the flow, and a finish question without one says so (advisory, never a block).
|
|
13
|
+
- At finish the operator decides fold or drop per finding: fold docs → `## playbook` (docs flow), fold code → `## code` (patch flow), fold plugin → a GitHub issue on the dev-flow repo; drop records nothing.
|
|
14
|
+
- `flow reflect --code "<note>"` and a `## code` section for fixes that touch project code.
|
|
15
|
+
- Timed nudges: *fix the open reflections now?* fires when an item recurred this session, is ≥ 14 days old, ≥ 3 playbook items wait (one docs flow), or a code item waits between flows; *tidy* fires at ≥ 5 closed, closed ≥ open (≥ 3), or a closed item ≥ 30 days old.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- `flow reflect --plugin` never writes `reflections.md`: it prints the upstream recipe (search, then `gh issue create` with the `— reflection from` tail the fold matches). A plugin-shaped note without a flag does the same. In the dev-flow repo itself plugin is code and files under `## code`. `--both` is gone; `reflect move` takes `--playbook|--code`.
|
|
19
|
+
- Existing `## plugin` rows are kept verbatim, never added to, and flagged by `flow doctor` and `reflect list` to be filed upstream (or moved to `## code` in the dev-flow repo).
|
|
20
|
+
- Open-reflection reminders left the per-turn stage context of a feature in progress; they surface at the release stage, at finish, in an unbound session, and in `flow status` / `flow doctor`.
|
|
21
|
+
|
|
7
22
|
## [0.76.1] - 2026-11-03
|
|
8
23
|
|
|
9
24
|
**pi-web workers read Running while they run.** Since 0.75.0 a `flow_stage` worker's Agents-menu row read *Interrupted* for its whole run, and its label repeated the slug.
|
package/README.md
CHANGED
|
@@ -146,12 +146,25 @@ claiming a gate result it never produced. → [Gate reference](docs/gates.md)
|
|
|
146
146
|
|
|
147
147
|
When something costs the agent a step — a playbook command that stopped existing, a guard that
|
|
148
148
|
refused the wrong thing, a gate that forced a detour, a rough edge in dev-flow itself — it does not
|
|
149
|
-
just work around it. It parks a one-line note in `.dev-flow/reflections.md
|
|
150
|
-
(
|
|
151
|
-
`flow reflect --playbook|--
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
149
|
+
just work around it. It parks a one-line note in `.dev-flow/reflections.md` — your project's queue — under **playbook**
|
|
150
|
+
(the fix lives in `project.md`, a docs flow) or **code** (the fix touches your code, a patch flow):
|
|
151
|
+
`flow reflect --playbook|--code "<note>"`. Feedback about **dev-flow itself never lands in your
|
|
152
|
+
project**: `flow reflect --plugin "<note>"` prints the recipe for a GitHub issue on the dev-flow repo
|
|
153
|
+
(search first, then `gh issue create`), filed on your word. A note queued without a flag lands on a
|
|
154
|
+
keyword guess the printed line explains (`flow reflect list` numbers the queue, `flow reflect move
|
|
155
|
+
<n> --code` re-files one). The open count surfaces in `flow status` and `flow doctor`.
|
|
156
|
+
|
|
157
|
+
**At finish, a separate reviewer reflects on the session.** `flow_stage` op `reflect` starts a fresh
|
|
158
|
+
read-only pi session that reads the whole driving transcript *and every worker's*, re-checks the
|
|
159
|
+
open items, dedupes against them and the upstream issues, and returns a numbered list — each
|
|
160
|
+
finding classified docs / code / plugin with a **fold or drop** recommendation. You answer per item
|
|
161
|
+
(`fold 1,3 drop 2`): fold records a docs/code row or files the plugin issue, drop records nothing.
|
|
162
|
+
|
|
163
|
+
The nudges are timed, not constant. *Fix the open reflections now?* is suggested only when an item
|
|
164
|
+
recurred this session, has waited 14 days, three playbook items can share one docs flow, or a code
|
|
165
|
+
item waits while you are between flows — at finish, in an unbound session, in `flow doctor`, never
|
|
166
|
+
mid-feature. *Tidy* is suggested once the closed pile is real (5 closed, more closed than open, or a
|
|
167
|
+
month-old closed item).
|
|
155
168
|
|
|
156
169
|
With a GitHub remote, `flow doctor` and `flow reflect list` also **fold in the open GitHub issues**
|
|
157
170
|
— external submissions land on GitHub while the queue lives in `reflections.md`, so both surfaces
|
|
@@ -164,10 +177,8 @@ the file, never both. No GitHub remote shows nothing; missing or failing `gh` is
|
|
|
164
177
|
They never gate anything, and the fix is never the agent's call alone. You ask it to go through them
|
|
165
178
|
— usually with `flow doctor`, which reviews each open item and routes it: a playbook item becomes a
|
|
166
179
|
small docs flow that edits `project.md` through the flow (so the change is committed and reviewed like
|
|
167
|
-
any other), a
|
|
168
|
-
|
|
169
|
-
Fold, fix or drop them — but leaving them is the one option that lets the same friction come back next
|
|
170
|
-
feature.
|
|
180
|
+
any other), a code item a patch flow. Leaving them is the one option that lets the same friction come
|
|
181
|
+
back next feature — which is exactly what the *recurred* nudge catches.
|
|
171
182
|
|
|
172
183
|
### Reviews and senior discipline, built in
|
|
173
184
|
|
|
@@ -184,8 +195,8 @@ speculative layers — removed in a risk-ascending order, one verified commit pe
|
|
|
184
195
|
tests as contract, and a structural-vs-cheap self-audit so the diff shrank because the system
|
|
185
196
|
got smaller, not because comments got deleted. For a big implement slice the session can hand
|
|
186
197
|
the work to **`flow_stage`**: a fresh pi session in the worktree that edits, commits and reports,
|
|
187
|
-
or a fresh read-only reviewer (`op: "review"`) whose PASS/FAIL is advice, not a gate
|
|
188
|
-
optional, and the plan path, commits and checks are briefed automatically. In pi-web a worker also
|
|
198
|
+
or a fresh read-only reviewer (`op: "review"`) whose PASS/FAIL is advice, not a gate, or the
|
|
199
|
+
end-of-session reflection (`op: "reflect"`, see Reflections). All are optional, and the plan path, commits and checks are briefed automatically. In pi-web a worker also
|
|
189
200
|
shows up in the session's Agents menu as a subagent, its final status on the row and its report in
|
|
190
201
|
the opened transcript. And while a flow writes code, the
|
|
191
202
|
implement stage injects a compact senior-discipline guidance — smallest complete change, no
|
|
@@ -229,7 +240,7 @@ While a feature is active, every tool call passes a guard:
|
|
|
229
240
|
```
|
|
230
241
|
.dev-flow/
|
|
231
242
|
project.md your playbook — the only committed file here
|
|
232
|
-
reflections.md
|
|
243
|
+
reflections.md this project's suggestion queue for you (advisory; plugin feedback goes upstream)
|
|
233
244
|
roadmap.md your backlog of future features (advisory)
|
|
234
245
|
<slug>/
|
|
235
246
|
plan/plan.md the spec you approve (embeds the mockup renders)
|
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; `release.preflight` (when set) passes in the worktree — the build the tag will trigger, proven before anything ships; **the worktree holds no uncommitted paths** (gh#131: a merge ships the branch, not the working tree — an uncommitted fix at this gate is a fix that never ships; the refusal lists the paths, and the approved line prints `commits: N ahead of <default>, M uncommitted path(s)` like verify's); with `versioning.file`: the manifest version parses and is **not tagged yet** (the bump must be ahead of the last release); with `release.changelog` the gate **proves the entry mechanically** (#97): a **heading names the version** (prose that mentions it, or a `1.2.0-beta` section when releasing `1.2.0`, is not an entry), **this branch touched the file** (an inherited changelog is not release prep), **every entry that was pending before the release survives inside the new section** — compared on normalized lines, so re-indenting a fold is free while rewording or deleting one is refused by naming the line — and **nothing is left under `Unreleased`**. The proofs guard the **baseline's** pending lines — they do not freeze the wording of the entry this flow writes, so a branch that landed as several iteration commits is free to state its result as one entry (see the changelog-writer rule in the pre-release reference). The pending baseline is the newest tag's changelog (what actually shipped), else the branch's merge base; when neither resolves, the two git-dependent proofs are skipped **with a printed advisory** rather than refusing a legal release for a topology reason, and the content proofs (the heading, its body) always run; tier-2 `## pre-release` checklist confirmed; the manifest version it validates is **stamped as the release's version of record** (`release-done` publishes that, whatever the checkouts say later); **one question** (Release?) — or `--confirmed`; `--no-version` (your call at Release?) ships this flow as **merge + changelog** — the bump/tag requirements and the tag checks at `release-done` are skipped for it, but the branch must still add its **own line under `Unreleased`** (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, 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
|
-
| `reflect ["<note>"|list|tidy|move <n> --
|
|
22
|
+
| `reflect ["<note>"|list|tidy|move <n> --playbook|--code]` | — | `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; 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
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 — 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]` | — | — |
|
package/docs/playbook.md
CHANGED
|
@@ -168,16 +168,19 @@ you can just edit `.dev-flow/project.md` yourself — the next `flow init` (doct
|
|
|
168
168
|
flags problems, and `flow doctor` runs the same probes on demand without offering to change
|
|
169
169
|
anything (findings are also printed whenever `flow init` runs without a UI, e.g. in CI). `--force`
|
|
170
170
|
rewrites from fresh detection. Improvement
|
|
171
|
-
ideas the agent notices along the way queue up in `.dev-flow/reflections.md`
|
|
172
|
-
(
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
171
|
+
ideas the agent notices along the way queue up in `.dev-flow/reflections.md` — *this project's*
|
|
172
|
+
queue only: `## playbook` (the fix lives in your playbook → docs flow) and `## code` (the fix
|
|
173
|
+
touches your code → patch flow). Feedback about dev-flow itself never lands there: it becomes a
|
|
174
|
+
GitHub issue on the dev-flow repo. `flow reflect --playbook|--code "<note>"` appends a note,
|
|
175
|
+
`flow reflect --plugin "<note>"` prints the upstream issue recipe instead (no flag guesses from the
|
|
176
|
+
wording and prints why), `flow reflect list` numbers the open ones, `flow reflect move <n>
|
|
177
|
+
--playbook|--code` re-files one, `flow reflect tidy` drops the closed (`- [x]`) ones, plain
|
|
178
|
+
`flow doctor` reviews the open ones and routes each fix to the flow that implements it. At finish
|
|
179
|
+
a fresh read-only **reflect worker** (`flow_stage` op `reflect`) reviews the whole session — the
|
|
180
|
+
driver's and every worker's transcript — and returns classified findings with a fold/drop
|
|
181
|
+
recommendation each; the operator decides per item (fold = a queue row or an upstream issue, drop
|
|
182
|
+
= nothing recorded). Suggestions to fix open items or tidy closed ones are timed (finish, between
|
|
183
|
+
flows, doctor — never mid-feature) — and nothing there ever gates.
|
|
181
184
|
Future features have their own file: `.dev-flow/roadmap.md`, a gitignored backlog `flow roadmap`
|
|
182
185
|
manages (add / pick → `flow start` / done / tidy) — a picked item is checked off by `finish` when
|
|
183
186
|
its feature ships, and it never gates either.
|
package/extensions/dev-flow.ts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* Inactive (fully pass-through) in repos without a .dev-flow/ directory.
|
|
21
21
|
*/
|
|
22
22
|
import { exec } from "node:child_process";
|
|
23
|
-
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
23
|
+
import { closeSync, copyFileSync, existsSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
24
24
|
import path from "node:path";
|
|
25
25
|
import { promisify } from "node:util";
|
|
26
26
|
import { Type } from "@earendil-works/pi-ai";
|
|
@@ -74,10 +74,19 @@ import {
|
|
|
74
74
|
reflectMove,
|
|
75
75
|
reflectProtocol,
|
|
76
76
|
reflectUnfiledCount,
|
|
77
|
+
reflectLegacyPluginCount,
|
|
78
|
+
reflectionNudges,
|
|
79
|
+
pluginIssueRecipe,
|
|
80
|
+
type ReflectTarget,
|
|
81
|
+
buildReflectBrief,
|
|
82
|
+
parseReflectReport,
|
|
83
|
+
renderReflectFindings,
|
|
84
|
+
childSessionFiles,
|
|
85
|
+
WORKER_NUDGE_READONLY,
|
|
86
|
+
type SessionHeaderInfo,
|
|
77
87
|
reflectionLine,
|
|
78
88
|
reflectionRoutes,
|
|
79
89
|
reflectionsTidy,
|
|
80
|
-
reflectionsTidyHint,
|
|
81
90
|
type ReflectItem,
|
|
82
91
|
type ReflectSection,
|
|
83
92
|
stageReference,
|
|
@@ -357,7 +366,7 @@ async function releaseTags(root: string): Promise<string[] | null> {
|
|
|
357
366
|
}
|
|
358
367
|
|
|
359
368
|
const GATE_HELP =
|
|
360
|
-
"help [--json] | init [--force|--draft|--write <text>] | reflect [<note>|list|tidy|move <n> --
|
|
369
|
+
"help [--json] | init [--force|--draft|--write <text>] | reflect [<note>|list|tidy|move <n> --playbook|--code] | roadmap [add <text>|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] | 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 — 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, tidy drops closed ones — roadmap manages .dev-flow/roadmap.md: pick <n> <slug> stamps an item for flow start, finish checks it off — 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)";
|
|
361
370
|
const featDir = (root: string, slug: string) => path.join(dfDir(root), slug);
|
|
362
371
|
const stateFile = (root: string, slug: string) => path.join(featDir(root, slug), "state.json");
|
|
363
372
|
const claimFile = (root: string, slug: string) => path.join(featDir(root, slug), "claim.json");
|
|
@@ -742,23 +751,33 @@ function setupQuestions(det: { partial: { defaultBranch: string; versioning?: {
|
|
|
742
751
|
|
|
743
752
|
const GIT_TRACK_NOTE = 'the playbook belongs in git: git add -f .dev-flow/project.md && DEV_FLOW_ALLOW_MAIN=1 git commit -m "track project.md" (force-add: a root .gitignore may exclude .dev-flow/ entirely — tracked once, the ignore stops mattering; the env prefix is for the pre-commit hook, dev-flow itself lets a main commit whose only change is the playbook)';
|
|
744
753
|
|
|
745
|
-
/**
|
|
746
|
-
*
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
754
|
+
/** The dev-flow repo plugin notes are filed against: the manifest's repository field; the dev-flow
|
|
755
|
+
* checkout itself falls back to its origin. */
|
|
756
|
+
async function pluginUpstream(root: string): Promise<string> {
|
|
757
|
+
return pluginVersion(import.meta.dirname).repo || (isSelfRepo(root) ? githubSlug((await originUrl(root)) ?? "") : "");
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/** `flow reflect <note>` — this project's queue, operator decides. `--playbook` / `--code` states the
|
|
761
|
+
* section (the agent knows what its own note is about); `--plugin` is dev-flow feedback, which never
|
|
762
|
+
* lands in a project's file — it prints the upstream issue recipe instead (in the dev-flow repo itself
|
|
763
|
+
* plugin IS code, so it files under `## code`). With no flag the wording guesses and the echo prints why. */
|
|
764
|
+
async function reflectNote(root: string, sess: Session, note: string[], forced: ReflectTarget | null): Promise<RunResult> {
|
|
750
765
|
const file = path.join(dfDir(root), "reflections.md");
|
|
751
766
|
const text = existsSync(file) ? readFileSync(file, "utf8") : "";
|
|
752
767
|
const guess = guessReflectSections(note.join(" "));
|
|
753
|
-
const
|
|
754
|
-
const
|
|
755
|
-
const
|
|
768
|
+
const self = isSelfRepo(root);
|
|
769
|
+
const target = forced ?? guess.target;
|
|
770
|
+
const why = forced ? "as told" : guess.why;
|
|
771
|
+
const date = now().slice(0, 10);
|
|
772
|
+
if (target === "plugin" && !self) return { text: [...pluginIssueRecipe(note.join(" "), await pluginUpstream(root), sess.slug, date), ...(forced ? [] : [`(filed as plugin: ${why} — a project note: flow reflect --playbook|--code "<note>")`])].join("\n") };
|
|
773
|
+
const section: ReflectSection = target === "plugin" ? "code" : target;
|
|
774
|
+
const line = reflectionLine(note.join(" "), sess.slug, date);
|
|
775
|
+
const next = appendReflection(text, [section], line);
|
|
756
776
|
if (next === text) return { text: `already reflected (duplicate): ${line}` };
|
|
757
777
|
writeFileSync(file, next);
|
|
758
|
-
// queueing is exactly when the operator hears about the checked-off pile — nudge
|
|
759
|
-
const
|
|
760
|
-
|
|
761
|
-
return { text: `reflected (${sections.join(" + ")} — ${why}): ${line}` + (closed ? `\n${reflectionsTidyHint(closed)}` : "") };
|
|
778
|
+
// queueing is exactly when the operator hears about the checked-off pile — nudge only once it is worth a tidy
|
|
779
|
+
const { tidy } = reflectionNudges(next, date);
|
|
780
|
+
return { text: `reflected (${section} — ${target === "plugin" ? "dev-flow repo: plugin feedback is this project's code" : why}): ${line}` + (tidy ? `\n${tidy}` : "") };
|
|
762
781
|
}
|
|
763
782
|
|
|
764
783
|
/** In-process TTL cache per repo slug — repeat doctor runs in one session must not re-hit the API. */
|
|
@@ -822,14 +841,27 @@ async function reflectList(root: string): Promise<RunResult> {
|
|
|
822
841
|
: fold.state === "absent" || fold.state === "skipped"
|
|
823
842
|
? ["reflections: nothing open"]
|
|
824
843
|
: ["reflections: nothing open locally"];
|
|
825
|
-
return { text: [...local, ...foldRows(fold, isSelfRepo(root))].join("\n") };
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
/**
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
if (!
|
|
832
|
-
|
|
844
|
+
return { text: [...local, ...legacyPluginRows(readReflectionsText(root), isSelfRepo(root)), ...foldRows(fold, isSelfRepo(root))].join("\n") };
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/** Open rows still under the legacy `## plugin` heading: they belong on GitHub, not in a project's queue. */
|
|
848
|
+
function legacyPluginRows(text: string, selfRepo: boolean): string[] {
|
|
849
|
+
const n = reflectLegacyPluginCount(text);
|
|
850
|
+
if (!n) return [];
|
|
851
|
+
return [
|
|
852
|
+
selfRepo
|
|
853
|
+
? `reflections: ${n} open item(s) under the legacy ## plugin heading — in the dev-flow repo plugin is code: flow reflect move <n> --code`
|
|
854
|
+
: `reflections: ${n} open item(s) under the legacy ## plugin heading belong on GitHub, not here — file each upstream (flow reflect --plugin "<note>" prints the recipe), then check it off '— filed: gh#NNN'`,
|
|
855
|
+
];
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/** `flow reflect move <n> --playbook|--code` — re-file an item under the other heading, so fixing a
|
|
859
|
+
* misfile is one command instead of hand-editing markdown. Nothing moves INTO `## plugin`: dev-flow
|
|
860
|
+
* feedback is filed upstream (flow reflect --plugin prints the recipe), then the row is checked off. */
|
|
861
|
+
function reflectMoveNote(root: string, args: string[], forced: ReflectTarget | null): RunResult {
|
|
862
|
+
if (forced === "plugin") return { text: "move: plugin notes are not kept in reflections.md — file the item upstream (flow reflect --plugin \"<note>\" prints the recipe), then check the row off '— filed: gh#NNN' (in the dev-flow repo itself: move <n> --code)", isError: true };
|
|
863
|
+
if (!forced) return { text: "usage: flow reflect move <n> --playbook | --code", isError: true };
|
|
864
|
+
const section = forced;
|
|
833
865
|
const n = Number(args[0]);
|
|
834
866
|
const text = readReflectionsText(root);
|
|
835
867
|
const items = reflectItems(text);
|
|
@@ -1374,6 +1406,8 @@ async function gateFinish(o: GateCtx): Promise<RunResult> {
|
|
|
1374
1406
|
}
|
|
1375
1407
|
// a forge release that failed at release-done is still the operator's call — but they must see it before the state vanishes (#63)
|
|
1376
1408
|
const forgeSkipNote = state!.forgeReleaseSkipped ? ` WARNING: the forge release was not created (${state!.forgeReleaseSkipped}) — recreate it manually or re-run release-done before finishing.` : "";
|
|
1409
|
+
// the session context dies with the state: name a missing reflection — advisory, never a block (yolo too)
|
|
1410
|
+
const reflectSkipNote = state!.reflectedAt ? "" : ` Note: no reflection recorded for ${state!.slug} — the finish protocol runs flow_stage(op: "reflect") first and puts fold/drop to the operator.`;
|
|
1377
1411
|
// the one finish question — asked after the safety checks so it can never be a wasted question
|
|
1378
1412
|
// yolo works uniformly at every gate: at Finish? nothing later remains to pre-confirm, the flag just answers this one
|
|
1379
1413
|
const yoloWord = takeYoloWord(state!);
|
|
@@ -1382,9 +1416,9 @@ async function gateFinish(o: GateCtx): Promise<RunResult> {
|
|
|
1382
1416
|
if (askPending) {
|
|
1383
1417
|
markPendingAsk(root, state!, "Finish?");
|
|
1384
1418
|
if (!ui.hasUI) {
|
|
1385
|
-
return { text: needsOperator(`finish needs the operator: ask them Finish? in chat, then re-run with --confirmed (or run /flow finish interactively)${forgeSkipNote}`, "Finish?"), isError: true };
|
|
1419
|
+
return { text: needsOperator(`finish needs the operator: ask them Finish? in chat, then re-run with --confirmed (or run /flow finish interactively)${forgeSkipNote}${reflectSkipNote}`, "Finish?"), isError: true };
|
|
1386
1420
|
}
|
|
1387
|
-
const ok = await ui.confirm("Finish feature", `Finish ${state!.slug}?${unmergedNote}${forgeSkipNote} Removes worktree, branch ${state!.branch || "-"} and .dev-flow/${state!.slug}/.`);
|
|
1421
|
+
const ok = await ui.confirm("Finish feature", `Finish ${state!.slug}?${unmergedNote}${forgeSkipNote}${reflectSkipNote} Removes worktree, branch ${state!.branch || "-"} and .dev-flow/${state!.slug}/.`);
|
|
1388
1422
|
if (!ok) {
|
|
1389
1423
|
delete state!.pendingAsk;
|
|
1390
1424
|
writeState(root, state!);
|
|
@@ -1431,7 +1465,10 @@ async function gateFinish(o: GateCtx): Promise<RunResult> {
|
|
|
1431
1465
|
roadmapNote = ` roadmap: ${r.count} item(s) marked done.`;
|
|
1432
1466
|
}
|
|
1433
1467
|
}
|
|
1434
|
-
|
|
1468
|
+
// finish is the moment between flows: name the fix / tidy suggestion when a rule fires, nothing otherwise
|
|
1469
|
+
const nudge = reflectionNudges(readReflectionsText(root), now().slice(0, 10), { between: true });
|
|
1470
|
+
const nudgeNote = [nudge.fix, nudge.tidy].filter(Boolean).map((n) => ` ${n} — offer it to the operator.`).join("");
|
|
1471
|
+
return { text: `feature ${state!.slug} done — ${closeNote}${remoteNote}; .dev-flow/${state!.slug}/ removed.${roadmapNote}${forgeSkipNote}${syncNote}${nudgeNote} Re-read flow status before reporting open flows — a sibling feature may have finished while this session ran.` };
|
|
1435
1472
|
}
|
|
1436
1473
|
|
|
1437
1474
|
async function gateInit(o: GateCtx): Promise<RunResult> {
|
|
@@ -1695,28 +1732,24 @@ async function gateReflect(o: GateCtx): Promise<RunResult> {
|
|
|
1695
1732
|
// own sentence in reflections.md (#43). --plugin/--playbook/--both are reflect's own: they state
|
|
1696
1733
|
// the filing instead of leaving it to a keyword guess.
|
|
1697
1734
|
const words = rest.filter((a) => !a.startsWith("--"));
|
|
1698
|
-
const forced:
|
|
1699
|
-
? (["playbook", "plugin"] as ReflectSection[])
|
|
1700
|
-
: flag("plugin")
|
|
1701
|
-
? (["plugin"] as ReflectSection[])
|
|
1702
|
-
: flag("playbook")
|
|
1703
|
-
? (["playbook"] as ReflectSection[])
|
|
1704
|
-
: null;
|
|
1735
|
+
const forced: ReflectTarget | null = flag("plugin") ? "plugin" : flag("code") ? "code" : flag("playbook") || flag("docs") ? "playbook" : null;
|
|
1705
1736
|
// single words are verbs (roadmap-style); a note merely starting with one stays a note
|
|
1706
1737
|
if (words.length === 1 && words[0] === "tidy") return reflectTidy(root);
|
|
1707
1738
|
if (words.length === 1 && words[0] === "list") return await reflectList(root);
|
|
1708
1739
|
if (words[0] === "move") return reflectMoveNote(root, words.slice(1), forced);
|
|
1709
|
-
if (words.length) return reflectNote(root, sess, words, forced);
|
|
1710
|
-
// upstream for the update probe: the manifest's repository field; the dev-flow checkout itself falls back to its origin
|
|
1740
|
+
if (words.length) return await reflectNote(root, sess, words, forced);
|
|
1711
1741
|
const self = pluginVersion(import.meta.dirname);
|
|
1712
|
-
const upstream =
|
|
1742
|
+
const upstream = await pluginUpstream(root);
|
|
1713
1743
|
const refl = readReflections(root);
|
|
1714
1744
|
const fold = await foldView(root, refl);
|
|
1745
|
+
const nudges = reflectionNudges(readReflectionsText(root), now().slice(0, 10), { between: !sess.slug });
|
|
1715
1746
|
return {
|
|
1716
1747
|
text: reflectProtocol(refl, isSelfRepo(root), {
|
|
1717
1748
|
version: self.version,
|
|
1718
1749
|
upstream,
|
|
1719
|
-
|
|
1750
|
+
bound: !!sess.slug,
|
|
1751
|
+
fix: nudges.fix,
|
|
1752
|
+
tidy: nudges.tidy,
|
|
1720
1753
|
ghFold: fold.state === "ok" && fold.open ? { repo: fold.slug, open: fold.open, similar: fold.result.similar.length } : undefined,
|
|
1721
1754
|
}).join("\n"),
|
|
1722
1755
|
};
|
|
@@ -1785,10 +1818,13 @@ async function gateDoctor(o: GateCtx): Promise<RunResult> {
|
|
|
1785
1818
|
});
|
|
1786
1819
|
}
|
|
1787
1820
|
findings.push(...foldRows(fold, isSelfRepo(root)));
|
|
1788
|
-
const
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1821
|
+
const reflText = readReflectionsText(root);
|
|
1822
|
+
const unfiled = reflectUnfiledCount(reflText);
|
|
1823
|
+
if (unfiled) findings.push(` reflections: ${unfiled} open item(s) sit outside ## playbook / ## code — flow reflect list shows them, flow reflect move <n> --playbook|--code files them`);
|
|
1824
|
+
findings.push(...legacyPluginRows(reflText, isSelfRepo(root)).map((r) => ` ${r}`));
|
|
1825
|
+
const nudges = reflectionNudges(reflText, now().slice(0, 10), { between: !o.sess.slug });
|
|
1826
|
+
if (nudges.fix) findings.push(nudges.fix);
|
|
1827
|
+
if (nudges.tidy) findings.push(nudges.tidy);
|
|
1792
1828
|
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" };
|
|
1793
1829
|
// flow doctor <note>: a fresh observation gets an investigation brief and a fix route
|
|
1794
1830
|
return { text: investigationBrief(rest.filter((a) => !a.startsWith("--")).join(" "), isSelfRepo(root)).join("\n") };
|
|
@@ -1913,7 +1949,30 @@ async function gateAbort(o: GateCtx): Promise<RunResult> {
|
|
|
1913
1949
|
const workerSessions = new Set<string>();
|
|
1914
1950
|
|
|
1915
1951
|
/** Toolset per worker op: an implementer codes, a reviewer reads and runs commands only. */
|
|
1916
|
-
const WORKER_TOOLS: Record<WorkerOp, string[]> = { implement: ["read", "bash", "edit", "write"], review: ["read", "bash"] };
|
|
1952
|
+
const WORKER_TOOLS: Record<WorkerOp, string[]> = { implement: ["read", "bash", "edit", "write"], review: ["read", "bash"], reflect: ["read", "bash"] };
|
|
1953
|
+
|
|
1954
|
+
/** Line 1 of every pi session file in `dir` — the header that names a worker's parent session. A
|
|
1955
|
+
* file is read up to its first newline only (transcripts grow large); unreadable files are skipped. */
|
|
1956
|
+
function sessionHeaders(dir: string | undefined): SessionHeaderInfo[] {
|
|
1957
|
+
if (!dir) return [];
|
|
1958
|
+
let names: string[];
|
|
1959
|
+
try { names = readdirSync(dir).filter((f) => f.endsWith(".jsonl")); } catch { return []; }
|
|
1960
|
+
const out: SessionHeaderInfo[] = [];
|
|
1961
|
+
for (const n of names) {
|
|
1962
|
+
const file = path.join(dir, n);
|
|
1963
|
+
try {
|
|
1964
|
+
const fd = openSync(file, "r");
|
|
1965
|
+
try {
|
|
1966
|
+
const buf = Buffer.alloc(16_384);
|
|
1967
|
+
const len = readSync(fd, buf, 0, buf.length, 0);
|
|
1968
|
+
const first = buf.subarray(0, len).toString("utf8").split("\n")[0];
|
|
1969
|
+
const h = JSON.parse(first) as { type?: unknown; parentSession?: unknown };
|
|
1970
|
+
if (h?.type === "session") out.push({ file, parentSession: typeof h.parentSession === "string" ? h.parentSession : undefined });
|
|
1971
|
+
} finally { closeSync(fd); }
|
|
1972
|
+
} catch { /* not a session file, or a header past the read window: skip */ }
|
|
1973
|
+
}
|
|
1974
|
+
return out;
|
|
1975
|
+
}
|
|
1917
1976
|
|
|
1918
1977
|
/** What makes a worker show up in pi-web's Agents menu: pi-web classifies a subagent from the
|
|
1919
1978
|
* custom entries its own runtime writes into the child's session file (pi-web lib/subagents.ts
|
|
@@ -2210,13 +2269,13 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
2210
2269
|
name: "flow_stage",
|
|
2211
2270
|
label: "Stage worker",
|
|
2212
2271
|
description:
|
|
2213
|
-
'Optional: hand a slice of work to a fresh pi session so this conversation stays lean. op "implement" (stage implement) — the worker edits and commits a slice on the feature branch; op "review" (implement or pre-release) — a fresh read-only reviewer that returns findings and a PASS/FAIL verdict (advisory: no gate depends on it). The plan path, branch, commits so far and the project checks are added to the brief automatically — `note` is just the slice: what to do, operator answers and decisions the worker cannot see. The worker holds no flow tool; gates and checkpoints stay with you. Small work and small fixes are fine to do inline. In pi-web the worker appears in the session\'s Agents menu as a subagent (running while it works, then its final status); the opened transcript holds its report.',
|
|
2214
|
-
promptSnippet: 'flow_stage(op: "implement"|"review", note, label?) — optional fresh-session worker for a big implement slice,
|
|
2272
|
+
'Optional: hand a slice of work to a fresh pi session so this conversation stays lean. op "implement" (stage implement) — the worker edits and commits a slice on the feature branch; op "review" (implement or pre-release) — a fresh read-only reviewer that returns findings and a PASS/FAIL verdict (advisory: no gate depends on it); op "reflect" (any stage, standard at finish) — a fresh read-only reviewer of this session\'s transcript and every worker transcript that returns classified reflection findings (docs / code / plugin) with a fold-or-drop recommendation each, for the operator to decide. The plan path, branch, commits so far and the project checks are added to the brief automatically — `note` is just the slice: what to do, operator answers and decisions the worker cannot see. The worker holds no flow tool; gates and checkpoints stay with you. Small work and small fixes are fine to do inline. In pi-web the worker appears in the session\'s Agents menu as a subagent (running while it works, then its final status); the opened transcript holds its report.',
|
|
2273
|
+
promptSnippet: 'flow_stage(op: "implement"|"review"|"reflect", note, label?) — optional fresh-session worker for a big implement slice, an independent review, or the end-of-session reflection (finish); gates stay with you; in pi-web workers show up as subagents in the Agents menu',
|
|
2215
2274
|
parameters: Type.Object({
|
|
2216
|
-
op: Type.String({ description: '"implement" (a worker edits + commits a slice)
|
|
2275
|
+
op: Type.String({ description: '"implement" (a worker edits + commits a slice), "review" (read-only reviewer, findings + verdict) or "reflect" (read-only reviewer of the session transcripts, reflection findings + fold/drop recommendations)' }),
|
|
2217
2276
|
note: Type.String({ description: "The slice: what to do and anything from this conversation the worker must know (operator answers, decisions). Facts (plan path, commits, checks) are added for you." }),
|
|
2218
2277
|
label: Type.Optional(Type.String({ description: "A few words naming this delegation, shown in the worker's session name." })),
|
|
2219
|
-
budgetMin: Type.Optional(Type.Number({ description: "Wall-clock budget in minutes (5-180; default 60 implement, 30 review). Past it the worker is interrupted." })),
|
|
2278
|
+
budgetMin: Type.Optional(Type.Number({ description: "Wall-clock budget in minutes (5-180; default 60 implement, 30 review, 20 reflect). Past it the worker is interrupted." })),
|
|
2220
2279
|
}),
|
|
2221
2280
|
execute: async (id, params, signal, onUpdate, ctx) => {
|
|
2222
2281
|
const err = (text: string) => ({ content: [{ type: "text" as const, text }], details: undefined, isError: true });
|
|
@@ -2229,28 +2288,52 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
2229
2288
|
const why = workerOpError(op, st.stage);
|
|
2230
2289
|
if (why) return err(why);
|
|
2231
2290
|
const wop = op as WorkerOp;
|
|
2232
|
-
|
|
2291
|
+
// a reflection reviews transcripts, not the branch: it runs in the main checkout, where the
|
|
2292
|
+
// worktree may already be gone at finish time
|
|
2293
|
+
const work = wop === "reflect" ? root : worktreeAbs(root, st);
|
|
2233
2294
|
if (!work || !existsSync(work)) return err(`feature ${st.slug} has no worktree on disk — nothing for a worker to work in`);
|
|
2234
2295
|
if (runningWorkers.has(key)) return err("a worker is already running for this session — wait for it to return");
|
|
2235
2296
|
runningWorkers.add(key);
|
|
2236
2297
|
const cfg = loadProject(dfDir(root)).cfg;
|
|
2237
2298
|
const budgetMin = clampBudgetMin(params.budgetMin, wop);
|
|
2238
|
-
const glyph = wop === "implement" ? "🔨" : "🔍";
|
|
2299
|
+
const glyph = wop === "implement" ? "🔨" : wop === "review" ? "🔍" : "🪞";
|
|
2239
2300
|
const name = workerName(glyph, st.slug, wop, params.label);
|
|
2240
2301
|
const started = Date.now();
|
|
2241
2302
|
const git = async (cmd: string) => { const r = await sh(cmd, work); return r.ok ? r.out : ""; };
|
|
2242
2303
|
const headBefore = (await git("git rev-parse HEAD")).trim();
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
planFile: path.join(featDir(root, st.slug), "plan", "plan.md"),
|
|
2246
|
-
defaultBranch: cfg.defaultBranch,
|
|
2247
|
-
commits: await git(`git log --oneline ${sq(cfg.defaultBranch)}..HEAD`),
|
|
2248
|
-
status: await git("git status --short"),
|
|
2249
|
-
checks: cfg.checkList.map((c) => ({ name: c.name, command: c.cmd })),
|
|
2250
|
-
note: String(params.note ?? ""),
|
|
2251
|
-
});
|
|
2304
|
+
// the reflect worker runs in the main checkout, which may already carry the operator's edits
|
|
2305
|
+
const statusBefore = wop === "reflect" ? (await git("git status --short")).trim() : "";
|
|
2252
2306
|
let lineage: { id?: string; file?: string; dir?: string } = {};
|
|
2253
2307
|
try { lineage = { id: ctx.sessionManager.getSessionId(), file: ctx.sessionManager.getSessionFile() ?? undefined, dir: ctx.sessionManager.getSessionDir() ?? undefined }; } catch { /* unbacked driver: the worker is unlinked */ }
|
|
2308
|
+
const selfRepo = isSelfRepo(root);
|
|
2309
|
+
const brief =
|
|
2310
|
+
wop === "reflect"
|
|
2311
|
+
? await (async () => {
|
|
2312
|
+
const items = readReflections(root);
|
|
2313
|
+
const fold = await foldView(root, items);
|
|
2314
|
+
return buildReflectBrief({
|
|
2315
|
+
slug: st.slug, root, today: now().slice(0, 10),
|
|
2316
|
+
driverFile: lineage.file ?? null,
|
|
2317
|
+
children: lineage.file ? childSessionFiles(lineage.file, sessionHeaders(lineage.dir)) : [],
|
|
2318
|
+
reflectionsFile: path.join(dfDir(root), "reflections.md"),
|
|
2319
|
+
items,
|
|
2320
|
+
projectMd: path.join(dfDir(root), "project.md"),
|
|
2321
|
+
version: pluginVersion(import.meta.dirname).version,
|
|
2322
|
+
upstream: await pluginUpstream(root),
|
|
2323
|
+
selfRepo,
|
|
2324
|
+
projectIssues: fold.state === "ok" && !selfRepo ? { repo: fold.slug, issues: fold.result.upstreamOnly.map((i) => ({ number: i.number, title: i.title })) } : undefined,
|
|
2325
|
+
note: String(params.note ?? ""),
|
|
2326
|
+
});
|
|
2327
|
+
})()
|
|
2328
|
+
: buildWorkerBrief({
|
|
2329
|
+
op: wop, slug: st.slug, workDir: work,
|
|
2330
|
+
planFile: path.join(featDir(root, st.slug), "plan", "plan.md"),
|
|
2331
|
+
defaultBranch: cfg.defaultBranch,
|
|
2332
|
+
commits: await git(`git log --oneline ${sq(cfg.defaultBranch)}..HEAD`),
|
|
2333
|
+
status: await git("git status --short"),
|
|
2334
|
+
checks: cfg.checkList.map((c) => ({ name: c.name, command: c.cmd })),
|
|
2335
|
+
note: String(params.note ?? ""),
|
|
2336
|
+
});
|
|
2254
2337
|
// pi-web visibility needs both halves of the lineage: the id the Agents menu links the child
|
|
2255
2338
|
// to, the file the parentSession header points at — without either the worker stays unlinked.
|
|
2256
2339
|
const subagent = !lineage.id || !lineage.file ? undefined : { parentId: lineage.id, parentFile: lineage.file, toolCallId: id, profile: `flow-${wop}`, description: name, task: brief };
|
|
@@ -2282,7 +2365,7 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
2282
2365
|
// a turn that ends in prose ("now let me write D4…") ends the session: tell it to keep going
|
|
2283
2366
|
while (!report.found && !timedOut && !signal?.aborted && nudges < WORKER_NUDGES) {
|
|
2284
2367
|
nudges++;
|
|
2285
|
-
await child.prompt(WORKER_NUDGE);
|
|
2368
|
+
await child.prompt(wop === "implement" ? WORKER_NUDGE : WORKER_NUDGE_READONLY);
|
|
2286
2369
|
report = parseWorkerReport(child.getLastAssistantText() ?? "");
|
|
2287
2370
|
}
|
|
2288
2371
|
} catch (e) {
|
|
@@ -2316,12 +2399,34 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
2316
2399
|
releaseLive("failed"); // idempotent guard: a throw between claim and result must not leave a live row
|
|
2317
2400
|
try { if (child) workerSessions.delete(child.sessionManager.getSessionId()); } catch { /* id-less session: nothing was registered */ }
|
|
2318
2401
|
try { child?.setSessionName(`${report.found && !crash && !timedOut && !signal?.aborted ? "✓" : "✗"} ${name}${report.verdict ? ` · ${report.verdict}` : ""}`); } catch { /* visibility only */ }
|
|
2319
|
-
const parts = [
|
|
2320
|
-
|
|
2402
|
+
const parts = [`${glyph} ${wop} worker ${outcome} (${Math.round((Date.now() - started) / 60_000)} min)`];
|
|
2403
|
+
let reflected: ReturnType<typeof parseReflectReport> | null = null;
|
|
2404
|
+
if (wop === "reflect") {
|
|
2405
|
+
reflected = report.found ? parseReflectReport(report.body) : null;
|
|
2406
|
+
const rows = reflected && (reflected.findings.length || reflected.open.length || /^\s*F0\b/m.test(report.body)) ? renderReflectFindings(reflected, selfRepo) : null;
|
|
2407
|
+
parts.push(rows ? rows.join("\n") : report.found ? `REPORT (rows did not parse — read them yourself):\n${report.body.slice(0, 6000)}` : `no REPORT — last words:\n${report.body}`);
|
|
2408
|
+
if (report.found) {
|
|
2409
|
+
// the record finish reads: a reflection ran for this flow (advisory — finish never blocks on it)
|
|
2410
|
+
const cur = readState(root, st.slug);
|
|
2411
|
+
if (cur) { cur.reflectedAt = now(); writeState(root, cur); }
|
|
2412
|
+
}
|
|
2413
|
+
const recurred = reflected?.open.filter((x) => x.status === "recurred").length ?? 0;
|
|
2414
|
+
const nudges = reflectionNudges(readReflectionsText(root), now().slice(0, 10), { recurred });
|
|
2415
|
+
parts.push(
|
|
2416
|
+
"Next: show the operator this numbered list with your recommendation per item and ask fold or drop for each (one answer like 'fold 1,3 drop 2' is fine) — then STOP until they answer. " +
|
|
2417
|
+
`Fold docs → flow reflect --playbook "<note>"; fold code → flow reflect --code "<note>"; fold plugin → ${selfRepo ? 'flow reflect --code "<note>" (this is the dev-flow repo)' : 'flow reflect --plugin "<note>" prints the upstream recipe (dedupe search, then gh issue create — the fold answer is the confirmation; never a reflections.md row)'}; drop → record nothing. Open items re-checked as fixed → propose checking them off.`,
|
|
2418
|
+
);
|
|
2419
|
+
if (nudges.fix) parts.push(`${nudges.fix} — offer it after the fold/drop answer.`);
|
|
2420
|
+
if (nudges.tidy) parts.push(`${nudges.tidy} — offer it after the fold/drop answer.`);
|
|
2421
|
+
if (newCommits.trim() || dirty !== statusBefore) parts.push("note: the reflect worker changed the tree — inspect the change; it was told to write nothing");
|
|
2422
|
+
parts.push(`transcript: ${transcript || "(unknown)"}`);
|
|
2423
|
+
return { content: [{ type: "text", text: parts.join("\n\n") }], details: { op: wop, outcome, verdict: null, commits: 0, findings: reflected?.findings.length ?? 0 } };
|
|
2424
|
+
}
|
|
2425
|
+
parts.push(
|
|
2321
2426
|
report.found ? `REPORT:\n${report.body.slice(0, 6000)}` : `no REPORT — last words:\n${report.body}`,
|
|
2322
2427
|
`new commits:\n${newCommits.trim() || "(none)"}`,
|
|
2323
2428
|
`uncommitted: ${dirty ? `\n${dirty}` : "clean"}`,
|
|
2324
|
-
|
|
2429
|
+
);
|
|
2325
2430
|
if (wop === "implement") {
|
|
2326
2431
|
const check = await runFlow(["check"], root, uiFrom(ctx), sessFor(ctx, root));
|
|
2327
2432
|
parts.push(`flow check after the worker: ${check.text.replace(/\s+/g, " ").trim().slice(0, 1500)}`);
|
|
@@ -2567,7 +2672,12 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
2567
2672
|
const curBr = await currentBranch(root);
|
|
2568
2673
|
if (curBr && curBr !== cfg.defaultBranch) content += ` Also: main checkout is on ${curBr}, not ${cfg.defaultBranch} — surface this to the operator before starting work.`;
|
|
2569
2674
|
const refl0 = readReflections(root);
|
|
2570
|
-
if (refl0.length)
|
|
2675
|
+
if (refl0.length) {
|
|
2676
|
+
// between flows is the moment to fix them: the nudge names the docs/patch split when a rule fires
|
|
2677
|
+
const nudge = reflectionNudges(readReflectionsText(root), now().slice(0, 10), { between: true });
|
|
2678
|
+
content += ` Also: ${refl0.length} reflection(s) open — ${nudge.fix ? `${nudge.fix}; mention it to the operator` : "run flow doctor"}.`;
|
|
2679
|
+
if (nudge.tidy) content += ` Also: ${nudge.tidy}.`;
|
|
2680
|
+
}
|
|
2571
2681
|
const rmap0 = roadmapOpenCount(readRoadmap(root));
|
|
2572
2682
|
if (rmap0) content += ` Also: ${rmap0} roadmap item(s) open — flow roadmap lists them, flow roadmap pick <n> <slug> hands one to flow start.`;
|
|
2573
2683
|
content += ` Also: the playbook map is ${path.join(SKILL_DIR, "SKILL.md")} — per-stage detail sits in references/ beside it (start: flow init, modes, ownership).`;
|
|
@@ -2584,8 +2694,12 @@ export default function devFlow(pi: ExtensionAPI) {
|
|
|
2584
2694
|
guidance.push("Stage reports: open every report with the stage line (statusbar glyph + slug + provenance-marked decision fields); close a checkpoint with an event title and `Done:` / `Next steps:` on own lines — italic verbs, recommended first, yolo last. See Stage reports in the ground rules.");
|
|
2585
2695
|
const pend = checklistPending(cfg, state, state.stage);
|
|
2586
2696
|
if (pend) guidance.push(`Tier-2 checklist NOT yet confirmed (${pend} item(s)): ${applicableItems(cfg, state, state.stage).map((i) => i.text).join(" | ")}${state.stage === "release" ? " — release-stage items close with the operator's Finish? answer; no earlier gate records them" : ""}`);
|
|
2587
|
-
|
|
2588
|
-
|
|
2697
|
+
// mid-feature is the wrong moment to divert into old reflections — they surface at the release
|
|
2698
|
+
// stage (finish runs the reflection), between flows, and in status/doctor
|
|
2699
|
+
if (state.stage === "release") {
|
|
2700
|
+
const refl = readReflections(root);
|
|
2701
|
+
if (refl.length) guidance.push(`↻ ${refl.length} reflection(s) open — the finish reflection (flow_stage op "reflect") re-checks them; fix them only on the operator's word.`);
|
|
2702
|
+
}
|
|
2589
2703
|
const rmap = roadmapOpenCount(readRoadmap(root));
|
|
2590
2704
|
if (rmap) guidance.push(`◇ ${rmap} roadmap item(s) open — flow roadmap lists them (pick only on the operator's word).`);
|
|
2591
2705
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-dev-flow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.77.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
|
@@ -91,5 +91,5 @@ session's stage injection names the file to read now, and this is the map.
|
|
|
91
91
|
| `references/implement.md` | implement stage — worktree, commits, checks, tier-2 list, Verified? |
|
|
92
92
|
| `references/pre-release.md` | pre-release — `/flow-review`, docs, changelog + bump, Release? |
|
|
93
93
|
| `references/release.md` | release — PR and merge style, tag, forge release, release-done; hands over to finish |
|
|
94
|
-
| `references/finish.md` | the close-out after `release-done` — reflect first, Finish?, worktree and branch cleanup |
|
|
95
|
-
| `references/reflect.md` | reflections (
|
|
94
|
+
| `references/finish.md` | the close-out after `release-done` — the reflect worker and fold/drop first, Finish?, worktree and branch cleanup |
|
|
95
|
+
| `references/reflect.md` | reflections (this project's queue; plugin feedback → upstream issues), when to fix or tidy, and the roadmap backlog |
|