pi-dev-flow 0.74.0 → 0.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@ Format: newest first. `Unreleased` collects what's merged but not yet tagged.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.76.0] - 2026-11-03
8
+
9
+ **The status bar now lists the flows.** In pi-web the footer was text — nothing to click, and no way to see what was in flight without asking the agent.
10
+
11
+ ### Added
12
+ - In pi-web, dev-flow carries a collapsible flow-list widget beside the footer: a `dev-flow` chip in the status shelf whose panel shows one line per unfinished flow — `→` marks the session's bound flow, the stage word is spelled out, footer markers (`⚡ 📚 🎱 💬`) and `⚠️` on failing checks read exactly as in the footer. It repaints at session start, at every run start and after every gate, and hides while nothing is open. The terminal keeps the footer as its only surface.
13
+
14
+ ## [0.75.0] - 2026-11-03
15
+
16
+ **`flow_stage` workers are now visible in pi-web.** A delegated worker used to be a session pi-web never mentioned — the operator watched the driving session go quiet.
17
+
18
+ ### Added
19
+ - `flow_stage` workers register themselves as pi-web subagents: the worker's session file carries the `pi-web:subagent` meta where pi-web's scanner looks for it (first data entry) and a terminal result when the run ends, so the worker appears in the session's Agents menu under profile `flow-implement` / `flow-review` — ✓ with its REPORT, ✗ failed, or interrupted. The row settles when the run ends; while it runs pi-web displays it as interrupted, because only pi-web's own sessions can prove liveness. Plain pi is unchanged, and a stamp that cannot write never breaks a worker.
20
+
7
21
  ## [0.74.0] - 2026-11-03
8
22
 
9
23
  **Audit: gaps closed, dead code out.** A full read of the extension, core and playbook parser after 0.73.0's reset.
package/README.md CHANGED
@@ -185,7 +185,9 @@ tests as contract, and a structural-vs-cheap self-audit so the diff shrank becau
185
185
  got smaller, not because comments got deleted. For a big implement slice the session can hand
186
186
  the work to **`flow_stage`**: a fresh pi session in the worktree that edits, commits and reports,
187
187
  or a fresh read-only reviewer (`op: "review"`) whose PASS/FAIL is advice, not a gate. Both are
188
- optional, and the plan path, commits and checks are briefed automatically. And while a flow writes code, the
188
+ optional, and the plan path, commits and checks are briefed automatically. In pi-web a worker also
189
+ shows up in the session's Agents menu as a subagent, its final status on the row and its report in
190
+ the opened transcript. And while a flow writes code, the
189
191
  implement stage injects a compact senior-discipline guidance — smallest complete change, no
190
192
  speculative abstraction, finish what your change breaks, a failing-first test for risky logic —
191
193
  your playbook's `prose.implement` replaces it wholesale whenever you write your own. (The review
@@ -17,7 +17,7 @@ While a feature is active, the extension intercepts every tool call:
17
17
  - **Shell calls can't hang forever**: pi kills a shell command only when the model passed a `timeout` — it omits one in ~75% of calls, so a `gh` waiting on a prompt or a dead `curl` froze sessions for hours. In an initiated repo (`.dev-flow/project.md` exists) every shell call without one therefore gets the class default armed silently (30s quick inspection · 120s local git and unknown · 180s network · 300s containers/services · 900s builds/tests/installs · 1,200s watchers like `gh run watch`), and absurd explicit values clamp to 1,800s. A project that wants the timeout visible on every call line sets `bashTimeout = require` in `## global` — then a call without one is refused, naming the value it would have armed (each refusal costs a turn, which is why it is no longer the default). Uninitiated folders hear nothing at all: without the playbook dev-flow enforces no rules.
18
18
  - **Compact-aware**: dev-flow paces compaction the way pi counts it: the self-compaction trigger uses the *effective* `reserveTokens` (settings and per-model overrides, not the built-in default) and is checked at every turn end, not only when a run settles. When pi force-compacts on its threshold anyway — the chat-only states (open tier-2 dialog, plan discussion not yet in `plan/`) refuse to self-compact by design — dev-flow takes the compaction over and redoes it with flow-aware summary instructions (overflow recovery keeps pi's compact-and-retry and is left alone). Auto-compaction turned off in settings is honored.
19
19
  - The active stage is injected into the model's context every turn; the bundled `dev-flow` skill is the agent's playbook, including the recommended sequences: pre-release — review (`/flow-review`) → fixes → docs → changelog/version bump; release — PR → merge → tag → `release-done`. The package also bundles the review skills themselves — `/flow-review` (a change, read against its `plan/plan.md`), `/flow-audit` (the whole repo) and `/flow-simplify` (the operative cut: deletes dead and duplicated code, one verified commit at a time) — and injects a built-in senior-discipline guidance at implement stage unless the playbook sets its own `prose.implement`.
20
- - **Status bar**: an initiated repo (`.dev-flow/project.md` exists) always carries the dev-flow footer; while the session **is bound** to a feature it shows `<stage glyph> <slug>` plus mode markers — stages 📝 plan, 🔨 implement, 🔍 pre-release, 🚀 release; markers ⚡ patch, 📚 docs, 🎱 yolo, `💬` while a checkpoint (Approve?/Verified?/Release?/Finish?) still waits on the operator's word — the legend's "operator, your turn" glyph, the same one stage lines open with — and `⚠️` while a check of the bound feature fails (emoji render in their own color, so the footer carries no theme coloring). An **unbound** session never sees a slug — it shows `💬 N flow(s) open` (unfinished-feature count only, no warning marker) or `💬 no flows` when nothing is in flight: the pre-flow glyph, because an unbound session is parked on the operator by definition; a session binds only via `flow start`/`flow use`, never by opening. The footer repaints at session start, at the start of every agent run (the earliest a late-attaching web client is listening) and after every gate; an uninitiated folder gets no footer at all. `flow status` is the spelled-out surface: `stage=implement`, the per-feature mode tags (`[ui]`, `[yolo]`, `[no-version]`), the `💬 <word>` marker of a checkpoint the operator has not answered, and the `flow=<ver>` stamp of the build that started the feature.
20
+ - **Status bar**: an initiated repo (`.dev-flow/project.md` exists) always carries the dev-flow footer; while the session **is bound** to a feature it shows `<stage glyph> <slug>` plus mode markers — stages 📝 plan, 🔨 implement, 🔍 pre-release, 🚀 release; markers ⚡ patch, 📚 docs, 🎱 yolo, `💬` while a checkpoint (Approve?/Verified?/Release?/Finish?) still waits on the operator's word — the legend's "operator, your turn" glyph, the same one stage lines open with — and `⚠️` while a check of the bound feature fails (emoji render in their own color, so the footer carries no theme coloring). An **unbound** session never sees a slug — it shows `💬 N flow(s) open` (unfinished-feature count only, no warning marker) or `💬 no flows` when nothing is in flight: the pre-flow glyph, because an unbound session is parked on the operator by definition; a session binds only via `flow start`/`flow use`, never by opening. In **pi-web** the footer text is not clickable, so an initiated repo also carries a `dev-flow` widget there: a chip in the status shelf whose panel expands (click again to collapse) to one lean line per unfinished flow — `→` marks the session's bound flow, the stage word is spelled out, markers and `⚠️` follow the footer vocabulary — and no chip appears while nothing is open. The TUI never shows it: a widget there is an always-present block, and in a terminal the footer stays the legend. The footer repaints at session start, at the start of every agent run (the earliest a late-attaching web client is listening) and after every gate; an uninitiated folder gets no footer at all. `flow status` is the spelled-out surface: `stage=implement`, the per-feature mode tags (`[ui]`, `[yolo]`, `[no-version]`), the `💬 <word>` marker of a checkpoint the operator has not answered, and the `flow=<ver>` stamp of the build that started the feature.
21
21
 
22
22
  ## Limitations (deliberate, v1)
23
23
 
@@ -109,6 +109,7 @@ import {
109
109
  validSlug,
110
110
  verifyGate,
111
111
  versionTagGate,
112
+ widgetLines,
112
113
  writeGuard,
113
114
  mainCheckoutRoot,
114
115
  buildWorkerBrief,
@@ -206,7 +207,7 @@ function copyWarning(): string | null {
206
207
  }
207
208
  /** Test seam: the smoke suite cannot load a second copy of this module, so it plants registry
208
209
  * entries and asserts the warnings the real duplicate would print. */
209
- export const testSeams = { copies: COPIES, skillCore: { value: undefined as string | null | undefined } };
210
+ export const testSeams = { copies: COPIES, skillCore: { value: undefined as string | null | undefined }, piweb: { meta: piwebWorkerMeta, stamp: piwebStamp } };
210
211
 
211
212
  interface Ui {
212
213
  hasUI: boolean;
@@ -1914,14 +1915,58 @@ const workerSessions = new Set<string>();
1914
1915
  /** Toolset per worker op: an implementer codes, a reviewer reads and runs commands only. */
1915
1916
  const WORKER_TOOLS: Record<WorkerOp, string[]> = { implement: ["read", "bash", "edit", "write"], review: ["read", "bash"] };
1916
1917
 
1918
+ /** What makes a worker show up in pi-web's Agents menu: pi-web classifies a subagent from the
1919
+ * custom entries its own runtime writes into the child's session file (pi-web lib/subagents.ts
1920
+ * readSubagentRun, fed by lib/session-reader.ts). Two placement rules the reader enforces:
1921
+ * the meta entry must be the file's FIRST data entry (the scanner reads header + one line and
1922
+ * calls anything else a fork), and a persisted `running` the host cannot prove live displays as
1923
+ * `interrupted` — so the final result entry is what the menu really rests on.
1924
+ * Unknown entry types are inert in plain pi, so stamping is unconditional. */
1925
+ const PIWEB_SUBAGENT = { meta: "pi-web:subagent", status: "pi-web:subagent-status", result: "pi-web:subagent-result" } as const;
1926
+
1927
+ interface WorkerSubagentMeta {
1928
+ parentId: string;
1929
+ parentFile: string;
1930
+ toolCallId: string;
1931
+ profile: string;
1932
+ description: string;
1933
+ task: string;
1934
+ }
1935
+
1936
+ /** Only version 1 + the two lineage strings are hard-validated by pi-web's reader; the rest is
1937
+ * display. resourceSnapshot is deliberately absent: its presence pins the tool set strictly when
1938
+ * pi-web reopens the child, and these workers are never resumed by pi-web. */
1939
+ function piwebWorkerMeta(m: WorkerSubagentMeta): Record<string, unknown> {
1940
+ return {
1941
+ version: 1,
1942
+ parentSessionId: m.parentId,
1943
+ parentSessionPath: m.parentFile,
1944
+ parentToolCallId: m.toolCallId,
1945
+ profile: m.profile,
1946
+ description: m.description,
1947
+ task: m.task,
1948
+ runInBackground: false,
1949
+ createdAt: now(),
1950
+ };
1951
+ }
1952
+
1953
+ /** Best-effort by contract: a stamp that will not write must never break the worker run —
1954
+ * visibility, not function (same rule as the worker's setSessionName renames). */
1955
+ function piwebStamp(target: { appendCustomEntry?(customType: string, data?: unknown): unknown } | undefined, customType: string, data: unknown): void {
1956
+ try { target?.appendCustomEntry?.(customType, data); } catch { /* visibility only */ }
1957
+ }
1958
+
1917
1959
  /** Seam that spawns a worker as a real pi session — tests replace `.run`. With the driver's session
1918
1960
  * file and directory known, the worker's header links back to the driver (`parentSession`), so pi's
1919
- * picker nests it under the driver. */
1920
- export const stageWorkerSpawn: { run: (o: { work: string; model: unknown; name: string; tools: string[]; parent?: string; dir?: string }) => Promise<AgentSession> } = {
1921
- run: async ({ work, model, name, tools, parent, dir }) => {
1961
+ * picker nests it under the driver, and the pi-web meta lands as the file's first data entry. */
1962
+ export const stageWorkerSpawn: { run: (o: { work: string; model: unknown; name: string; tools: string[]; parent?: string; dir?: string; subagent?: WorkerSubagentMeta }) => Promise<AgentSession> } = {
1963
+ run: async ({ work, model, name, tools, parent, dir, subagent }) => {
1922
1964
  const loader = new DefaultResourceLoader({ cwd: work, agentDir: getAgentDir() });
1923
1965
  await loader.reload();
1924
1966
  const sessionManager = parent && dir ? SessionManager.create(work, dir, { parentSession: parent }) : undefined;
1967
+ // The meta must be stamped here — before createAgentSession appends model_change/session_info,
1968
+ // because pi-web's scanner classifies the child only from the first data entry after the header.
1969
+ if (sessionManager && subagent) piwebStamp(sessionManager, PIWEB_SUBAGENT.meta, piwebWorkerMeta(subagent));
1925
1970
  const { session } = await createAgentSession({ cwd: work, model: model as never, tools, excludeTools: ["flow", "flow_stage"], resourceLoader: loader, sessionManager });
1926
1971
  try { workerSessions.add(session.sessionManager.getSessionId()); } catch { /* an id-less session just gets the default context */ }
1927
1972
  try { session.setSessionName(name); } catch { /* naming is visibility, not function */ }
@@ -1981,15 +2026,22 @@ function tail(out: string, n = 15): string {
1981
2026
 
1982
2027
  /** Compact footer: bound flow = stage glyph, slug, mode markers, ⚠️ on its failing checks; unbound = the
1983
2028
  * unfinished-flow count, or `💬 no flows` — an initiated repo always carries the footer. An uninitiated
1984
- * folder gets nothing: the status is cleared. Pure read — rendering never binds or claims anything. */
2029
+ * folder gets nothing: the status is cleared. In pi-web the footer text is not clickable, so the same
2030
+ * snapshot also feeds a flow-list widget (a `dev-flow` chip whose panel lists every open flow, one lean
2031
+ * line each). Pure read — rendering never binds or claims anything. */
1985
2032
  function refreshStatus(ctx: ExtensionContext, root: string): void {
1986
2033
  if (!ctx.hasUI) return;
1987
2034
  if (!initiated(root)) {
1988
2035
  ctx.ui.setStatus("dev-flow", undefined);
2036
+ if (ctx.mode !== "tui") ctx.ui.setWidget("dev-flow", undefined);
1989
2037
  return;
1990
2038
  }
1991
- const s = statusFor(boundFeature(root, sessionKey(ctx)), unfinishedStates(root).length);
1992
- ctx.ui.setStatus("dev-flow", s.text);
2039
+ const un = unfinishedStates(root);
2040
+ const bound = boundFeature(root, sessionKey(ctx));
2041
+ ctx.ui.setStatus("dev-flow", statusFor(bound, un.length).text);
2042
+ // TUI keeps the footer as its only surface: a lines-widget there is an always-present block above the
2043
+ // editor (no click to collapse), which competes with "the footer is the legend". pi-web gets the chip.
2044
+ if (ctx.mode !== "tui") ctx.ui.setWidget("dev-flow", un.length ? widgetLines(bound, un) : undefined);
1993
2045
  }
1994
2046
 
1995
2047
 
@@ -2120,15 +2172,15 @@ export default function devFlow(pi: ExtensionAPI) {
2120
2172
  name: "flow_stage",
2121
2173
  label: "Stage worker",
2122
2174
  description:
2123
- '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.',
2124
- promptSnippet: 'flow_stage(op: "implement"|"review", note, label?) — optional fresh-session worker for a big implement slice, or an independent review; gates stay with you',
2175
+ '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; the row carries its final status, the opened transcript its report.',
2176
+ promptSnippet: 'flow_stage(op: "implement"|"review", note, label?) — optional fresh-session worker for a big implement slice, or an independent review; gates stay with you; in pi-web workers show up as subagents in the Agents menu',
2125
2177
  parameters: Type.Object({
2126
2178
  op: Type.String({ description: '"implement" (a worker edits + commits a slice) or "review" (read-only reviewer, findings + verdict)' }),
2127
2179
  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." }),
2128
2180
  label: Type.Optional(Type.String({ description: "A few words naming this delegation, shown in the worker's session name." })),
2129
2181
  budgetMin: Type.Optional(Type.Number({ description: "Wall-clock budget in minutes (5-180; default 60 implement, 30 review). Past it the worker is interrupted." })),
2130
2182
  }),
2131
- execute: async (_id, params, signal, onUpdate, ctx) => {
2183
+ execute: async (id, params, signal, onUpdate, ctx) => {
2132
2184
  const err = (text: string) => ({ content: [{ type: "text" as const, text }], details: undefined, isError: true });
2133
2185
  const op = String(params.op ?? "").trim().toLowerCase();
2134
2186
  const root = await flowRoot(ctx.cwd);
@@ -2160,8 +2212,11 @@ export default function devFlow(pi: ExtensionAPI) {
2160
2212
  checks: cfg.checkList.map((c) => ({ name: c.name, command: c.cmd })),
2161
2213
  note: String(params.note ?? ""),
2162
2214
  });
2163
- let lineage: { file?: string; dir?: string } = {};
2164
- try { lineage = { file: ctx.sessionManager.getSessionFile() ?? undefined, dir: ctx.sessionManager.getSessionDir() ?? undefined }; } catch { /* unbacked driver: the worker is unlinked */ }
2215
+ let lineage: { id?: string; file?: string; dir?: string } = {};
2216
+ try { lineage = { id: ctx.sessionManager.getSessionId(), file: ctx.sessionManager.getSessionFile() ?? undefined, dir: ctx.sessionManager.getSessionDir() ?? undefined }; } catch { /* unbacked driver: the worker is unlinked */ }
2217
+ // pi-web visibility needs both halves of the lineage: the id the Agents menu links the child
2218
+ // to, the file the parentSession header points at — without either the worker stays unlinked.
2219
+ const subagent = !lineage.id || !lineage.file ? undefined : { parentId: lineage.id, parentFile: lineage.file, toolCallId: id, profile: `flow-${wop}`, description: name, task: brief };
2165
2220
  let child: AgentSession | undefined;
2166
2221
  let timedOut = false;
2167
2222
  let crash: string | null = null;
@@ -2172,7 +2227,8 @@ export default function devFlow(pi: ExtensionAPI) {
2172
2227
  signal?.addEventListener("abort", abortChild);
2173
2228
  let unsub: (() => void) | undefined;
2174
2229
  try {
2175
- child = await stageWorkerSpawn.run({ work, model: ctx.model, name: `⏳ ${name}`, tools: WORKER_TOOLS[wop], parent: lineage.file, dir: lineage.dir });
2230
+ child = await stageWorkerSpawn.run({ work, model: ctx.model, name: `⏳ ${name}`, tools: WORKER_TOOLS[wop], parent: lineage.file, dir: lineage.dir, subagent });
2231
+ if (subagent) piwebStamp(child.sessionManager, PIWEB_SUBAGENT.status, { version: 1, status: "running" });
2176
2232
  unsub = child.subscribe((ev: unknown) => {
2177
2233
  const e = ev as { type?: string; toolName?: string };
2178
2234
  if (e.type === "tool_execution_start") {
@@ -2201,8 +2257,20 @@ export default function devFlow(pi: ExtensionAPI) {
2201
2257
  const newCommits = headBefore && headAfter && headBefore !== headAfter ? await git(`git log --oneline ${sq(headBefore)}..HEAD`) : "";
2202
2258
  const dirty = (await git("git status --short")).trim();
2203
2259
  const outcome = crash ? `crashed: ${crash}` : timedOut ? `interrupted at the ${budgetMin}-min budget` : report.found ? "reported" : `ended without REPORT after ${nudges} nudge(s)`;
2260
+ // the terminal entry is what settles the Agents menu row (a persisted `running` the host
2261
+ // cannot prove live displays as `interrupted`); a no-REPORT run is a failure, not a ✓.
2262
+ if (subagent) {
2263
+ const doneAt = now();
2264
+ piwebStamp(child?.sessionManager, PIWEB_SUBAGENT.result, crash
2265
+ ? { version: 1, status: "failed", completedAt: doneAt, error: crash }
2266
+ : timedOut || signal?.aborted
2267
+ ? { version: 1, status: "aborted", completedAt: doneAt }
2268
+ : report.found
2269
+ ? { version: 1, status: "completed", completedAt: doneAt, result: report.body }
2270
+ : { version: 1, status: "failed", completedAt: doneAt, error: `ended without REPORT after ${nudges} nudge(s)`, result: report.body });
2271
+ }
2204
2272
  try { if (child) workerSessions.delete(child.sessionManager.getSessionId()); } catch { /* id-less session: nothing was registered */ }
2205
- try { child?.setSessionName(`${report.found && !crash && !timedOut ? "✓" : "✗"} ${name}${report.verdict ? ` · ${report.verdict}` : ""}`); } catch { /* visibility only */ }
2273
+ try { child?.setSessionName(`${report.found && !crash && !timedOut && !signal?.aborted ? "✓" : "✗"} ${name}${report.verdict ? ` · ${report.verdict}` : ""}`); } catch { /* visibility only */ }
2206
2274
  const parts = [
2207
2275
  `${glyph} ${wop} worker ${outcome} (${Math.round((Date.now() - started) / 60_000)} min)`,
2208
2276
  report.found ? `REPORT:\n${report.body.slice(0, 6000)}` : `no REPORT — last words:\n${report.body}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-dev-flow",
3
- "version": "0.74.0",
3
+ "version": "0.76.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/src/core.ts CHANGED
@@ -1440,6 +1440,18 @@ export function statusFor(bound: FlowState | null, openCount: number): { text: s
1440
1440
  return { text: `💬 ${openCount} flow${openCount === 1 ? "" : "s"} open` };
1441
1441
  }
1442
1442
 
1443
+ /** The pi-web widget panel's lines: one lean line per unfinished flow — `→` marks this session's bound
1444
+ * flow, glyph + markers ride on statusCompact so the panel and the footer never drift in vocabulary —
1445
+ * plus the spelled-out stage word and the `⚠️` on failing checks the compact footer cannot show. The
1446
+ * panel is the glance surface; `flow status` stays the detailed one. Empty in, empty out (the caller
1447
+ * clears the widget — no chip with nothing to expand). */
1448
+ export function widgetLines(bound: FlowState | null, states: FlowState[]): string[] {
1449
+ return states.map((st) => {
1450
+ const { text, failed } = statusCompact(st);
1451
+ return `${st.slug === bound?.slug ? "→" : " "} ${text} · ${st.stage}${failed ? " ⚠️" : ""}`;
1452
+ });
1453
+ }
1454
+
1443
1455
  /** `- [ ]` checklist items of a markdown document (reflections.md and roadmap.md share the format). */
1444
1456
  export function openChecklistItems(text: string): string[] {
1445
1457
  return text.split("\n").map((l) => l.trim()).filter((l) => l.startsWith("- [ ] "));