pi-dev-flow 0.72.0 → 0.74.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 +51 -0
- package/README.md +5 -3
- package/docs/gates.md +4 -4
- package/docs/guardrails.md +6 -4
- package/docs/headless.md +3 -4
- package/docs/playbook.md +8 -16
- package/extensions/dev-flow.ts +416 -1138
- package/package.json +1 -1
- package/skills/dev-flow/SKILL.md +4 -9
- package/skills/dev-flow/references/finish.md +3 -7
- package/skills/dev-flow/references/implement.md +28 -47
- package/skills/dev-flow/references/plan.md +0 -4
- package/skills/dev-flow/references/pre-release.md +1 -6
- package/skills/dev-flow/references/reflect.md +1 -6
- package/skills/dev-flow/references/release.md +3 -1
- package/skills/dev-flow/references/start.md +3 -15
- package/src/core.ts +168 -1014
- package/src/projectmd.ts +20 -40
- package/src/timeouts.ts +2 -2
- package/docs/stage-agent.md +0 -227
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", //
|
|
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",
|
|
@@ -35,12 +35,6 @@ const KEYMAP: Record<string, Record<string, string>> = {
|
|
|
35
35
|
forge: "forge",
|
|
36
36
|
"versioning.file": "versioning.file",
|
|
37
37
|
"versioning.pattern": "versioning.pattern",
|
|
38
|
-
"release.review": "release.review",
|
|
39
|
-
"release.changelog": "release.changelog",
|
|
40
|
-
"release.github": "release.releases",
|
|
41
|
-
"release.releases": "release.releases",
|
|
42
|
-
"release.artifact": "release.artifact",
|
|
43
|
-
"release.merge": "release.merge",
|
|
44
38
|
},
|
|
45
39
|
plan: {},
|
|
46
40
|
implement: {
|
|
@@ -58,9 +52,9 @@ const KEYMAP: Record<string, Record<string, string>> = {
|
|
|
58
52
|
versionTag: "versioning.pattern",
|
|
59
53
|
review: "release.review",
|
|
60
54
|
changelog: "release.changelog",
|
|
61
|
-
github: "release.releases", // legacy alias for `releases` — parse warns about the rename
|
|
62
55
|
releases: "release.releases",
|
|
63
56
|
artifact: "release.artifact",
|
|
57
|
+
preflight: "release.preflight", // run in the worktree at flow release, before anything ships (e.g. docker build .)
|
|
64
58
|
merge: "release.merge", // how a merged branch lands: squash | merge | rebase | any
|
|
65
59
|
},
|
|
66
60
|
};
|
|
@@ -157,10 +151,9 @@ export function parseProjectMd(text: string): ParsedMd {
|
|
|
157
151
|
const mapped = KEYMAP[stage][m[1]];
|
|
158
152
|
if (!mapped) p.warn.push(`${where}: unknown key "${m[1]}" in ## ${stage} — ignored`);
|
|
159
153
|
else {
|
|
160
|
-
if (mapped === "release.releases" && m[1].endsWith("github")) p.warn.push(`${where}: key "${m[1]}" is renamed "releases" — rename it`);
|
|
161
154
|
// the only enum-valued key: a junk mode must not silently mean "block every shell call"
|
|
162
155
|
if (m[1] === "bashTimeout" && !/^(require|inject)$/i.test(m[2].trim())) {
|
|
163
|
-
p.warn.push(`${where}: bashTimeout = "${m[2]}" — expected require or inject, keeping
|
|
156
|
+
p.warn.push(`${where}: bashTimeout = "${m[2]}" — expected require or inject, keeping inject`);
|
|
164
157
|
return;
|
|
165
158
|
}
|
|
166
159
|
// merge is the other enum: a typo here must not quietly mean "no policy" and drop the teeth
|
|
@@ -215,7 +208,7 @@ export function mdToConfig(p: ParsedMd): Config {
|
|
|
215
208
|
const c: Config = structuredClone(DEFAULTS);
|
|
216
209
|
const raw: Record<string, unknown> = {};
|
|
217
210
|
for (const stage of MD_STAGES) for (const [key, val] of Object.entries(p.flow[stage])) applyAnswer(raw, key, val);
|
|
218
|
-
//
|
|
211
|
+
// playbook values arrive as strings: normalize the boolean and list keys
|
|
219
212
|
if (typeof raw.mainHook === "string") raw.mainHook = /^(yes|true)$/i.test(raw.mainHook);
|
|
220
213
|
if (typeof raw.mockupGlobs === "string") raw.mockupGlobs = String(raw.mockupGlobs).split(",").map((s) => s.trim()).filter(Boolean);
|
|
221
214
|
// flow keys were mapped to dot paths (commands.x, versioning.y, release.z) — rebuild nested
|
|
@@ -226,9 +219,11 @@ export function mdToConfig(p: ParsedMd): Config {
|
|
|
226
219
|
mergeInto(c, nested);
|
|
227
220
|
// a flow-guard block is the whole rule set; with none in project.md the DEFAULTS (empty) stand
|
|
228
221
|
if (GUARD_VERBS.some((v) => p.guard[v].length)) c.guard = structuredClone(p.guard);
|
|
222
|
+
// one check per name: an explicit flow-check block wins over the `test =` / `health =` shorthand
|
|
223
|
+
const named = new Set(p.checks.map((x) => x.name));
|
|
229
224
|
c.checkList = [
|
|
230
|
-
...(c.commands.test ? [{ name: "test", cmd: c.commands.test }] : []),
|
|
231
|
-
...(c.commands.health ? [{ name: "health", cmd: c.commands.health }] : []),
|
|
225
|
+
...(c.commands.test && !named.has("test") ? [{ name: "test", cmd: c.commands.test }] : []),
|
|
226
|
+
...(c.commands.health && !named.has("health") ? [{ name: "health", cmd: c.commands.health }] : []),
|
|
232
227
|
...p.checks.map((x) => ({ name: x.name, cmd: x.cmd })),
|
|
233
228
|
];
|
|
234
229
|
c.checklist = p.checklist;
|
|
@@ -288,7 +283,7 @@ export function setPlaybookKey(text: string, stage: MdStage, key: string, value:
|
|
|
288
283
|
return { text: lines.join("\n"), where: `## ${stage} — opened a flow block for it` };
|
|
289
284
|
}
|
|
290
285
|
|
|
291
|
-
/** Load the project config: project.md
|
|
286
|
+
/** Load the project config: project.md is the only source. */
|
|
292
287
|
export function loadProject(dfDir: string): { cfg: Config; md: ParsedMd | null } {
|
|
293
288
|
const mdFile = path.join(dfDir, "project.md");
|
|
294
289
|
let mdText: string | null = null;
|
|
@@ -328,7 +323,6 @@ export function ghostFeatureDirs(root: string): string[] {
|
|
|
328
323
|
*/
|
|
329
324
|
export function doctorFindings(root: string, cfg: Config, md: ParsedMd | null): string[] {
|
|
330
325
|
const f: string[] = [];
|
|
331
|
-
if (existsSync(path.join(root, ".dev-flow", "project.json"))) f.push(".dev-flow/project.json is no longer read — fold its values into project.md and delete it");
|
|
332
326
|
const gi = path.join(root, ".dev-flow", ".gitignore");
|
|
333
327
|
if (existsSync(gi) && !readFileSync(gi, "utf8").includes("!project.md")) f.push(".dev-flow/.gitignore still hides project.md from git — re-run flow init to heal it");
|
|
334
328
|
if (cfg.forge && !["github", "gitlab", "self"].includes(cfg.forge)) f.push(`forge "${cfg.forge}" is invalid — use github, gitlab or self`);
|
|
@@ -384,7 +378,7 @@ export function mdDigest(text: string): string {
|
|
|
384
378
|
const keys: Record<string, string> = {};
|
|
385
379
|
for (const [k, v] of Object.entries(p.flow[s] as Record<string, string>)) keys[k.split(".").pop()!] = v; // config dot-paths → display keys
|
|
386
380
|
for (const [k, v] of Object.entries(keys)) {
|
|
387
|
-
if (relStage && ["file", "pattern", "
|
|
381
|
+
if (relStage && ["file", "pattern", "artifact"].includes(k)) continue; // rendered specially below
|
|
388
382
|
bits.push(DIGEST_CMDS[k] ? `${DIGEST_CMDS[k]}: ${JSON.stringify(v)}` : `${DIGEST_WORDS[k] ?? k}: ${v}`);
|
|
389
383
|
}
|
|
390
384
|
if (s === "implement" && p.checks.length) bits.push(`named checks: ${p.checks.map((c) => c.name).join(", ")}`);
|
|
@@ -401,40 +395,26 @@ export function mdDigest(text: string): string {
|
|
|
401
395
|
return `${rows.join("\n") || "(empty)"}\n\nnothing is executed or uploaded now — gates only run later inside the flow`;
|
|
402
396
|
}
|
|
403
397
|
|
|
404
|
-
/** Draft project.md
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
const
|
|
408
|
-
const cmd = (k: string) => (fresh ? undefined : (c.commands as Record<string, string>)[k]) || det.partial.commands[k];
|
|
409
|
-
const branch = fresh ? det.partial.defaultBranch : c.defaultBranch;
|
|
410
|
-
const verFile = (fresh ? undefined : c.versioning.file) || det.partial.versioning?.file || "package.json";
|
|
398
|
+
/** Draft project.md from detection (first init, --force). Never a regeneration of an existing playbook:
|
|
399
|
+
* a draft cannot reproduce hand-written prose, checklist items and keys. */
|
|
400
|
+
export function buildDraft(det: { report: string[]; partial: { defaultBranch: string; commands: Record<string, string>; versioning?: { file: string }; forge?: string } }): string {
|
|
401
|
+
const cmd = (k: string) => det.partial.commands[k];
|
|
411
402
|
const L: string[] = [];
|
|
412
403
|
L.push("# dev-flow", "", "<!-- Operator-owned playbook. Regenerate with: flow init --draft -->", "");
|
|
413
|
-
L.push("## global", "", "```flow", `defaultBranch = ${
|
|
404
|
+
L.push("## global", "", "```flow", `defaultBranch = ${det.partial.defaultBranch}`);
|
|
414
405
|
if (det.partial.forge) L.push(`forge = ${det.partial.forge}`); // from the origin URL — confirm or correct
|
|
415
406
|
L.push("```", "");
|
|
416
|
-
L.push("## plan", "", "- [ ] rendered mockups attached for every changed screen", "", "<!-- what the plan must contain, UI expectations -->", "");
|
|
407
|
+
L.push("## plan", "", "- [ ] (ui) rendered mockups attached for every changed screen", "", "<!-- what the plan must contain, UI expectations -->", "");
|
|
417
408
|
L.push("## implement", "", "```flow");
|
|
418
409
|
for (const k of ["setup", "test", "build", "run", "seedData", "dev"]) if (cmd(k)) L.push(`${k} = ${cmd(k)}`);
|
|
419
|
-
// a hand-set wait budget is a real setting: a refresh that dropped it would silently make the probe single-shot again
|
|
420
|
-
if (!fresh && c.healthWait !== DEFAULTS.healthWait) L.push(`healthWait = ${c.healthWait}`);
|
|
421
410
|
L.push("```", "");
|
|
422
|
-
const healthCmd = cmd("health") || (fresh ? undefined : c.checkList.find((x) => x.name === "health")?.cmd);
|
|
423
411
|
// never invent a health check: a placeholder that can't pass blocks verify forever (dogfooded: curl localhost:3000 in a library repo)
|
|
424
|
-
if (
|
|
412
|
+
if (cmd("health")) L.push("```flow-check health", cmd("health"), "```", "");
|
|
425
413
|
else L.push("<!-- optional tier-1: add a flow-check 'health' block once the app exposes a health endpoint -->", "");
|
|
426
|
-
// carry every other explicit check through a refresh, or regeneration would silently drop teeth
|
|
427
|
-
for (const x of fresh ? [] : c.checkList) {
|
|
428
|
-
if (x.name === "test" || x.name === "health") continue; // implicit ones ride the flow key block / healthCmd above
|
|
429
|
-
L.push("```flow-check " + x.name, x.cmd, "```", "");
|
|
430
|
-
}
|
|
431
414
|
L.push("- [ ] app runs locally with real data; visual pass: no overflows or stray scrollbars", "", "<!-- tier-3: standing guidance for this stage -->", "");
|
|
432
|
-
L.push("## pre-release", "", "<!-- e.g. review policy, docs expectations, who picks the version -->", "", "```flow", `versionFile = ${
|
|
433
|
-
// the merge policy is never invented by detection:
|
|
434
|
-
|
|
435
|
-
L.push("## release", "");
|
|
436
|
-
if (c.release.merge) L.push("```flow", `merge = ${c.release.merge}`, "```", "");
|
|
437
|
-
else L.push("<!-- merge = squash | merge | rebase — how a merged PR lands on the default branch (`any` = no policy). flow start also asks and writes it. -->", "");
|
|
415
|
+
L.push("## pre-release", "", "<!-- e.g. review policy, docs expectations, who picks the version -->", "", "```flow", `versionFile = ${det.partial.versioning?.file || "package.json"}`, "versionTag = v{version}", "```", "");
|
|
416
|
+
// the merge policy is never invented by detection: flow start asks and writes it
|
|
417
|
+
L.push("## release", "", "<!-- merge = squash | merge | rebase — how a merged PR lands on the default branch (`any` = no policy). flow start also asks and writes it. -->", "");
|
|
438
418
|
L.push("<!-- e.g. tag policy, who publishes artifacts -->", "");
|
|
439
419
|
return L.join("\n") + "\n";
|
|
440
420
|
}
|
package/src/timeouts.ts
CHANGED
|
@@ -67,8 +67,8 @@ export function bashTimeout(command: string, explicit?: number): number {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
* `bashTimeout = require` (the default): the model must state the timeout itself,
|
|
71
|
-
* injected value never reaches the transcript — the tool call entry records the arguments the model
|
|
70
|
+
* `bashTimeout = require` (opt-in; `inject` is the default): the model must state the timeout itself,
|
|
71
|
+
* because the injected value never reaches the transcript — the tool call entry records the arguments the model
|
|
72
72
|
* emitted, and the handler mutates them afterwards. Returns the refusal, or undefined when the call
|
|
73
73
|
* already carries an explicit timeout. The refused call is not lost: the reason names the exact
|
|
74
74
|
* value the class table would have armed, so the retry is a one-token fix.
|
package/docs/stage-agent.md
DELETED
|
@@ -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.
|