pi-dev-flow 0.72.0 → 0.73.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/src/projectmd.ts CHANGED
@@ -27,7 +27,7 @@ export interface ParsedMd {
27
27
  const KEYMAP: Record<string, Record<string, string>> = {
28
28
  global: {
29
29
  defaultBranch: "defaultBranch",
30
- bashTimeout: "bashTimeout", // require (default) | inject — must a shell call state its own timeout?
30
+ bashTimeout: "bashTimeout", // inject (default) | require — must a shell call state its own timeout?
31
31
  branchPattern: "branchPattern",
32
32
  worktreeDir: "worktreeDir",
33
33
  mainHook: "mainHook",
@@ -40,6 +40,7 @@ const KEYMAP: Record<string, Record<string, string>> = {
40
40
  "release.github": "release.releases",
41
41
  "release.releases": "release.releases",
42
42
  "release.artifact": "release.artifact",
43
+ "release.preflight": "release.preflight",
43
44
  "release.merge": "release.merge",
44
45
  },
45
46
  plan: {},
@@ -61,6 +62,7 @@ const KEYMAP: Record<string, Record<string, string>> = {
61
62
  github: "release.releases", // legacy alias for `releases` — parse warns about the rename
62
63
  releases: "release.releases",
63
64
  artifact: "release.artifact",
65
+ preflight: "release.preflight", // run in the worktree at flow release, before anything ships (e.g. docker build .)
64
66
  merge: "release.merge", // how a merged branch lands: squash | merge | rebase | any
65
67
  },
66
68
  };
@@ -160,7 +162,7 @@ export function parseProjectMd(text: string): ParsedMd {
160
162
  if (mapped === "release.releases" && m[1].endsWith("github")) p.warn.push(`${where}: key "${m[1]}" is renamed "releases" — rename it`);
161
163
  // the only enum-valued key: a junk mode must not silently mean "block every shell call"
162
164
  if (m[1] === "bashTimeout" && !/^(require|inject)$/i.test(m[2].trim())) {
163
- p.warn.push(`${where}: bashTimeout = "${m[2]}" — expected require or inject, keeping require`);
165
+ p.warn.push(`${where}: bashTimeout = "${m[2]}" — expected require or inject, keeping inject`);
164
166
  return;
165
167
  }
166
168
  // merge is the other enum: a typo here must not quietly mean "no policy" and drop the teeth
@@ -1,227 +0,0 @@
1
- # Stage worker: a stage's work or an independent review in a disposable sub-session
2
-
3
- A big `implement` costs more context than the rest of the flow will ever need:
4
- the driving session carries those hundred tool calls into every later gate and
5
- checkpoint. `flow_stage` runs that work in a fresh, disposable session
6
- instead, and hands back one bounded report. The conversation that talks to you
7
- stays lean — which is why implement work is **delegated**, not inlined, and why
8
- `flow verify` proves it from the ledger below (see `references/implement.md`). Three ops share one mechanism: `run` (a stage's work), `verify` (an
9
- independent, check-only reviewer of the implement work) and `reflect` (an
10
- independent review of the whole finished flow at release). Only the brief, the
11
- toolset, the budget default and the closing contract differ — the safety story
12
- is identical, and a second mechanism would drift.
13
-
14
- ## What delegates, what does not
15
-
16
- **The ledger proves who worked.** Every finished `run` worker appends its stage and its commit
17
- range to `.dev-flow/<slug>/stage-sessions/delegations.log` — one line, `[<iso>] run (<stage>):
18
- <start>..<end> <n> commit(s)` — written by the same completion code that renames the worker with
19
- its commit count. The file is dev-flow-owned — the write guard refuses it to a session, the bash tamper patterns refuse a write, move or delete of it, and only a worker run's completion appends it, in-process — precisely so the session whose work it proves cannot sign its own proof. `flow verify` reads it fresh and refuses when it shows no implement-stage
20
- delivery, or when a commit on the branch falls outside every implement window (the refusal counts
21
- the strays and names the fix: delegate a fixer that redoes them, or reset them). A range, not a
22
- count, is what makes it hold: an amend or a rebase after the fact moves the sha out of every window
23
- the ledger recorded, which no write guard could see. `--docs` and `--patch` flows are exempt —
24
- nothing to delegate in a docs pass or a one-file chore — and a git question that cannot be answered
25
- is never proof of a violation. Coverage is judged only at verify: the driver's own commits after it
26
- (changelog, bump) are pre-release work and belong to the session by design. The write guard is the
27
- early nudge of the same rule — a driver's edit inside its own worktree at implement is refused, a
28
- registered worker session's is not — while bash stays unguarded: running commands is driving, and
29
- the ledger's commit ranges are what carry the proof. A worktree session is judged by the **main
30
- checkout's** `.dev-flow/`, which is where the state actually lives: a linked worktree carries only the
31
- tracked playbook copy, so reading the worktree's own copy found no features and every guard answered
32
- "no active flow" — including for the worker it had to attribute.
33
-
34
- `flow_stage(stage: "implement" | "pre-release", note)` runs the **work** of
35
- the stage you are in; `flow_stage(op: "verify")` (legal only while the flow is
36
- at implement) and `flow_stage(op: "reflect")` (at release, after
37
- `release-done`) run the two independent reviews. Everything else stays with
38
- the driving session:
39
-
40
- - **every gate and every checkpoint** — the worker holds no flow tool; Approve?/
41
- Verified?/Release?/Finish? are still your chat, answered by you, run by the
42
- bound session;
43
- - **the claim** — the driving session binds the feature and keeps the live
44
- claim the whole time; nothing is taken over;
45
- - **verification** — no worker's report is a check: after a `run` the driving
46
- session reruns `flow check` (the worker's edits invalidated the tier-1
47
- records like any other edit) and still faces the normal `verify` gate. The
48
- **verify worker is a checker, not the gate**: its `VERIFY REPORT` PASS stamps
49
- the current tree and `flow verify` refuses without that stamp, but the gate
50
- re-runs everything itself and the operator's **Verified?** stays the
51
- checkpoint. Any tree edit after the PASS drops the stamp like a tier-1
52
- record — every fix cycle owes a fresh verify worker.
53
-
54
- `plan` is the operator dialogue and `release`/`finish` carry the checkpoint
55
- words — both stay in-session by design. One worker per session at a time
56
- (`flow_stage { op: "status" }` reads the live one); sequential re-delegation is
57
- legal and often right.
58
-
59
- ## Why an unbound worker is safe here
60
-
61
- The guards already judge a second session by attribution, so a helper needs no
62
- binding of its own:
63
-
64
- - worktree writes are judged by the **owning feature's stage** — a `run` worker
65
- may edit and commit on the feature branch exactly while the flow allows it,
66
- and nothing else; `verify` and `reflect` workers hold no edit/write tool at
67
- all, and a check-only worker that moves the tree through `bash` anyway
68
- **voids its own verdict**: the tool diffs `git status`, `git rev-parse HEAD`,
69
- the branch pointer and a hash of the feature's plan dir before and after
70
- (each leg alone has a clean-tree bypass; the proof sees the tracked tree —
71
- the same documented shortcut as every other fingerprint here), a moved tree
72
- is snapshotted and the stamp never lands —
73
- and the PASS itself is stamped against a worktree+plan fingerprint, so even a
74
- later edit to the plan it was written against demotes it;
75
- - default-branch discipline (no commit/merge/push on main) is enforced on every
76
- session's git calls alike;
77
- - `.dev-flow/state.json` and `claim.json` stay flow-owned — the guard denies
78
- workers the edit/write tools for them and `stateTamper` refuses the direct
79
- bash shapes, and the worker runs no gates because its toolset holds coding
80
- tools only. Honest scope, same line guardrails.md draws: these are strong
81
- guardrails for what an agent types, **not a sandbox** — a determined wrapper
82
- reaching around them is a hardening decision, not a control this feature
83
- claims.
84
-
85
- The worker loads your extensions like any session, dev-flow included — that is
86
- how the guards above hold inside it. What it does **not** get is the driver's
87
- context: dev-flow registers each worker it spawns and injects neither the
88
- playbook core nor the unbound-session posture into it (that text told a worker
89
- to pre-plan and `flow start`, and read its worktree as a main checkout on the
90
- wrong branch). The brief is the worker's whole instruction.
91
-
92
- ## The handoff
93
-
94
- The worker receives a brief assembled by the tool. A `run` worker gets the
95
- stage's playbook reference, `flow status --json`, live `git status` in the
96
- worktree, the plan file, and the driving session's `note`. A `verify` worker
97
- gets the plan, the branch diff, the tier-1 commands and the standing order
98
- **check, don't fix**. A `reflect` worker gets the driver's own session file,
99
- every worker transcript listed in the flow's `transcripts.log`, the plan and
100
- live status. The note is the only channel for conversation-only context —
101
- operator answers not yet recorded by a gate, decisions, warnings, the exact
102
- next action. Everything else the worker re-reads from disk.
103
-
104
- Each op closes with its bounded contract: `run` a `STAGE REPORT` (`done` /
105
- `files` / `notes` / `blockers`), `verify` a `VERIFY REPORT` (`verdict:
106
- pass|fail` / `findings` / `evidence`), `reflect` `[playbook]`/`[plugin]`-tagged
107
- finding lines — and the parent digests exactly that. A worker that skips its
108
- block is surfaced loudly (`reportMissing`), never silently trusted.
109
-
110
- The brief also carries a standing order: **commit each completed unit of work
111
- as you go** (one module, one file-group). If a run is ever cut, that costs one
112
- unit — never a worktree.
113
-
114
- ## You can watch it work
115
-
116
- The **tool card is the guaranteed surface**: every worker line (current tool +
117
- args, last assistant line, ✓/✗ tool results, clock against budget, usage)
118
- travels as the tool's own streamed update, so the live tail rides inside the
119
- driver's transcript wherever the host renders streamed tool updates (the TUI
120
- does; expansion adds the fuller stream, the report and the transcript path).
121
- Around it, three mirrors:
122
-
123
- - a worker is a real pi session, **stamped as this session's child**: its header
124
- carries `parentSession` → the driver's session file, and its transcript lands in
125
- the driver's own session bucket — so `pi --resume` nests it under the driver in
126
- its default **Current Folder** scope, in the Threaded sort, with no scope switch
127
- (pi #1108 built that link for exactly this: extensions may stamp it on sessions
128
- they create on a user's behalf). One layout exception: if you point pi at a
129
- configured session directory (settings `sessionDir`, or `--session-dir`) that is
130
- not the default for the folder you started it in, that scope filters by each
131
- session's own cwd and a worker's cwd is its worktree — the family is still
132
- threaded, one Tab away under **All**, and dev-flow's text view below lists it in
133
- either layout. On a host with no file-backed session the stamp
134
- is skipped and the worker keeps pi's default location, unlinked. Named by role
135
- glyph, ordinal and purpose — `⏳ 🔨 #2 · wire ops` while it runs, renamed
136
- at the end with its outcome: `✓ 🔨 #2 · 3 commits · wire ops`, a verify `✓ 🔍 #3 ·
137
- PASS · stamp attack` (verify rounds are numbered like runs, so a feature that took
138
- six rounds reads as a sequence), a cut-off worker `✗ 🔨 #3 · hard-cut`; the verdict
139
- never depends on opening the row (a `label` on the call supplies the purpose; with
140
- none, the ordinal still separates the rows). The live name is written onto the
141
- session before its first prompt — pi fires `session_start` only for sessions a host
142
- binds, never for an SDK-built worker, so a name hung on that event never landed and
143
- an auto-namer was left to title the row from the brief. It appears in the `/resume`
144
- picker, and its
145
- transcript grows live on disk, readable at any moment — whether a viewer
146
- tails a session still running is the viewer's choice, the card above is what
147
- the flow promises. Every finished worker appends its transcript path to
148
- `.dev-flow/<slug>/stage-sessions/transcripts.log` — the durable index the
149
- reflect worker reads, next to `delegations.log` — the delegation ledger the verify gate reads;
150
- - the driving session's **footer** beats `⏳ 🔨 implement · <label> · <slug>
151
- mm:ss · <tool>` while a worker runs (cleared when it ends);
152
- - every line appends to `.dev-flow/<slug>/stage-live.log` — tail-able, and
153
- `flow_stage { op: "status" }` prints the same tail plus elapsed time, budget,
154
- the worktree state and recent commits, on any host, no model call.
155
-
156
- ### The family, on a host with no tree
157
-
158
- The parent link makes pi's own picker the lineage view. Where a host has no tree
159
- (or you want the answer in text), the settled card and
160
- `flow_stage { op: "status" }` list the family instead: one line per worker this
161
- session spawned — its picker name (so the outcome is right there), message count,
162
- last-write time, transcript path, newest first, older ones folded behind one
163
- counted line. The worker the card or status is reporting on is left out — it is the
164
- section above it — and the section appears only inside a flow, because an unbound
165
- session has never spawned one:
166
-
167
- ```
168
- workers this session spawned:
169
- ✓ 🔍 #2 · PASS · stamp attack · 7 msgs · 2026-10-30 12:04 · ~/.pi/agent/sessions/…/w2.jsonl
170
- ✗ 🔨 #1 · hard-cut · 31 msgs · 2026-10-30 11:02 · ~/.pi/agent/sessions/…/w1.jsonl
171
- ```
172
-
173
- It is read back from pi's session listing, not from a dev-flow index, so renames,
174
- deletions and workers an earlier session already delegated all read correctly for
175
- free. A host that gives dev-flow no session file to be a parent of falls back to
176
- the lines the flow's own `transcripts.log` already holds — coarser (no message
177
- count, no rename), still the same answer. A family read opens only the first line
178
- of each transcript in the bucket to find the workers whose header names this
179
- session, and reads only those in full — its cost follows the family, not the
180
- bucket's history. The polled live view still re-reads at most once every two
181
- seconds, while the settled card and an idle status always read fresh.
182
-
183
- Lifecycle is also on the bus: `dev-flow:worker-started` / `-completed` /
184
- `-failed` events (slug, op, elapsed, usage) let other extensions react without
185
- touching dev-flow. `pi export <file>` turns any finished transcript into
186
- readable HTML; the tool result names the file and the export command.
187
-
188
- ## The budget, and the soft landing
189
-
190
- One run gets `budgetMin` minutes (default 45 for `run`, 30 for `verify` and
191
- `reflect`, clamped 5–120). At 75% of the budget the worker is not killed — it
192
- is **steered**: “stop starting new units, finish the edit you are in, commit
193
- everything done, close with the report”. A worker that obeys lands its work and
194
- reports honestly (the result says so). The hard cut at the full budget is the
195
- backstop for a worker that ignores the steer or wedges; a hard-cut run is
196
- marked mid-stage and is an error.
197
-
198
- Either way, **a dirty worktree is never handed back**: the tool snapshots it
199
- (tracked *and* untracked) with a throwaway index — no WIP commit on the branch,
200
- no touching the real index — and names the `.dev-flow/<slug>/stage-sessions/*.diff`
201
- file to read before deciding what to keep.
202
-
203
- ## Transcripts
204
-
205
- Session JSONL lives in the **driver's own session bucket** (the directory pi already
206
- uses for this session), which is what lets pi's picker show a flow's workers as one
207
- nested family; `pi export` and the picker find them there. Two consequences worth
208
- knowing: a worker's header `cwd` is still the worktree, so after `flow finish`
209
- removes that worktree the row points at a directory that is gone (browsing and
210
- `pi export` still work — resuming it would not); and the bucket is shared with the
211
- driver's own history, so worker transcripts are only ever deleted by path, never
212
- by clearing a folder. Workers from before 0.70 sit in a bucket of their own per
213
- worktree, which no folder scope opened from the checkout shows; `flow doctor` names
214
- those buckets once their feature is finished or its worktree is gone, with the
215
- `rm -r` that removes them — it never removes them itself. Snapshots and the
216
- `transcripts.log` index live under
217
- `.dev-flow/<slug>/stage-sessions/` (gitignored, like all flow-owned state).
218
-
219
- ## Deliberate limits (v2)
220
-
221
- Same model for worker and driver (a per-stage model/tool policy is a playbook
222
- conversation for later); the verify worker's fixing is delegated too — the
223
- checker is fresh each cycle and so is the fixer, because at implement the guard
224
- refuses the driver's own pen in its own worktree (the driver decides *what* the
225
- fix is and sends the note; a `run` worker writes it, then a fresh verify worker
226
- re-reads the tree); the worker cannot ask you anything — if it needed to, the note
227
- was too thin.