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