@zhuxixi/pi-agent-board 0.3.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.
Files changed (65) hide show
  1. package/IMPLEMENTATION_PLAN.md +920 -0
  2. package/LICENSE +21 -0
  3. package/PRD.md +484 -0
  4. package/PROGRESS.md +127 -0
  5. package/README.md +131 -0
  6. package/VERIFY.md +113 -0
  7. package/docs/BATCH_SELECTION_READ_FLOW.md +277 -0
  8. package/docs/EXPLORATION.md +187 -0
  9. package/docs/PTY_ATTACH_IMPLEMENTATION_PLAN.md +579 -0
  10. package/docs/superpowers/plans/2026-08-15-screenlog-gc.md +704 -0
  11. package/docs/superpowers/plans/2026-08-16-attach-double-cursor-jiggle-retry.md +499 -0
  12. package/docs/superpowers/plans/2026-08-21-dashboard-keypress-lag.md +366 -0
  13. package/docs/superpowers/specs/2026-08-15-screenlog-gc-design.md +105 -0
  14. package/docs/superpowers/specs/2026-08-16-attach-double-cursor-jiggle-retry-design.md +142 -0
  15. package/docs/superpowers/specs/2026-08-21-dashboard-keypress-lag-design.md +59 -0
  16. package/index.ts +6 -0
  17. package/package.json +81 -0
  18. package/runner/job-runner.mjs +420 -0
  19. package/runner/pty-runner.mjs +310 -0
  20. package/runner/state-runner.mjs +120 -0
  21. package/runner/title-runner.mjs +80 -0
  22. package/scripts/patch-vulns.mjs +59 -0
  23. package/src/commands/agent-board.ts +318 -0
  24. package/src/commands/attach-flow.ts +231 -0
  25. package/src/commands/bg.ts +70 -0
  26. package/src/core/atomic.mjs +145 -0
  27. package/src/core/auto-state.mjs +320 -0
  28. package/src/core/dashboard-render.mjs +10 -0
  29. package/src/core/derive.mjs +114 -0
  30. package/src/core/diagnostics.mjs +109 -0
  31. package/src/core/events.mjs +268 -0
  32. package/src/core/evidence.mjs +242 -0
  33. package/src/core/follow-up-queue.mjs +193 -0
  34. package/src/core/heuristics.mjs +240 -0
  35. package/src/core/ids.mjs +35 -0
  36. package/src/core/invocation.mjs +43 -0
  37. package/src/core/launch-options.mjs +317 -0
  38. package/src/core/launch.mjs +116 -0
  39. package/src/core/locks.mjs +80 -0
  40. package/src/core/paths.mjs +86 -0
  41. package/src/core/pid.mjs +42 -0
  42. package/src/core/prewarm-schedule.mjs +41 -0
  43. package/src/core/prompt-transport.mjs +13 -0
  44. package/src/core/pty-attach-jiggle-retry.mjs +90 -0
  45. package/src/core/pty-attach-render.mjs +51 -0
  46. package/src/core/pty-input.mjs +15 -0
  47. package/src/core/pty-links.mjs +71 -0
  48. package/src/core/pty-scroll.mjs +155 -0
  49. package/src/core/pty-support.mjs +327 -0
  50. package/src/core/repo.mjs +47 -0
  51. package/src/core/rows.mjs +290 -0
  52. package/src/core/screen-log-gc.mjs +198 -0
  53. package/src/core/screen-log.mjs +160 -0
  54. package/src/core/session-view.mjs +174 -0
  55. package/src/core/steering-prompts.mjs +34 -0
  56. package/src/core/steering.mjs +133 -0
  57. package/src/core/store.mjs +308 -0
  58. package/src/core/title.mjs +43 -0
  59. package/src/core/types.mjs +380 -0
  60. package/src/core/worktree.mjs +64 -0
  61. package/src/index.ts +109 -0
  62. package/src/runtime/service.mjs +1194 -0
  63. package/src/ui/dashboard-evidence.mjs +85 -0
  64. package/src/ui/dashboard.ts +1952 -0
  65. package/src/ui/pty-attach.ts +1378 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pi Agent Board contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/PRD.md ADDED
@@ -0,0 +1,484 @@
1
+ # PRD: Pi Agent Board Extension
2
+
3
+ **Status:** Draft
4
+ **Last Updated:** 2026-05-30
5
+ **Owner:** TBD
6
+
7
+ ## 1. Summary
8
+
9
+ Build a Pi extension that delivers a Claude Code agent-view-like experience inside Pi, packaged as **Pi Agent Board**: a single terminal UI to dispatch, monitor, reply to, attach to, and manage multiple **background Pi sessions**.
10
+
11
+ Each row in the view must represent a **real Pi session** with persisted history and resumable state, not just a transient subagent job.
12
+
13
+ ## 1.1 Locked product decisions
14
+
15
+ These decisions were confirmed on 2026-05-30 and are part of the MVP contract:
16
+
17
+ - dashboard is **global across projects** by default,
18
+ - `/agent-board` is the required MVP entry point,
19
+ - implementation should remain extensible for a future `/bg` flow,
20
+ - attaching to a running background session should **interrupt with confirmation, then attach**,
21
+ - same-repo parallel writer sessions must **require worktree isolation**,
22
+ - MVP may use a **cheap model summarizer**,
23
+ - returning to the dashboard via `/agent-board` is acceptable for MVP.
24
+
25
+ ## 2. Problem
26
+
27
+ Pi has strong primitives for sessions, extensions, tools, TUI components, and subagents, but it does **not** have a first-class built-in agent board. Today, users must manually juggle sessions and subagents and cannot easily:
28
+
29
+ - see all active/background work in one place,
30
+ - know which session needs input,
31
+ - reply inline without opening full transcripts,
32
+ - safely run several coding sessions in parallel,
33
+ - treat background work as first-class resumable conversations.
34
+
35
+ ## 3. Product Goal
36
+
37
+ Provide a Pi-native “agent board” that feels behaviorally equivalent to Claude’s agent board where Pi’s extension APIs allow it.
38
+
39
+ The product should let a user:
40
+
41
+ 1. dispatch a new background coding task,
42
+ 2. watch its state and summary live,
43
+ 3. peek and reply inline,
44
+ 4. attach to the full session when needed,
45
+ 5. detach without losing work,
46
+ 6. manage many background sessions safely.
47
+
48
+ ## 4. Non-Goals
49
+
50
+ ### V1 non-goals
51
+
52
+ - Exact top-level CLI parity with `claude agents`.
53
+ - Cloud-hosted/background remote execution.
54
+ - Replacing `pi-subagents` as a general orchestration package.
55
+ - Multi-user/shared dashboards.
56
+ - Full PR integration, PR badges, or SCM review workflows.
57
+ - Perfect parity for every Claude keyboard shortcut.
58
+ - Full shell-job support (`! command`) in MVP.
59
+
60
+ ## 5. Core Product Principles
61
+
62
+ 1. **Session-oriented, not job-oriented**
63
+ Background work is a real Pi session with a session file.
64
+
65
+ 2. **Dashboard first, transcript second**
66
+ Most triage should happen from the dashboard or peek panel.
67
+
68
+ 3. **Safe parallelism**
69
+ Background coding sessions must not silently trample each other’s files.
70
+
71
+ 4. **Resumable and durable**
72
+ The dashboard should survive Pi restart/reload and be able to rehydrate rows from disk.
73
+
74
+ 5. **Public-API-first implementation**
75
+ Build on Pi’s documented extension/session/TUI APIs, not unstable internal package imports.
76
+
77
+ ## 6. Users / Primary Use Cases
78
+
79
+ ### Primary user
80
+ A Pi power user working on several independent coding tasks at once.
81
+
82
+ ### Core use cases
83
+
84
+ - Dispatch a bug fix, refactor, and review task in parallel.
85
+ - Keep coding in one attached session while other sessions continue in background.
86
+ - Return to a dashboard to see which sessions are blocked or complete.
87
+ - Reply to a question from a background session without reopening the full transcript.
88
+ - Attach to a session for deep work, then return to the dashboard.
89
+ - Safely isolate edits from concurrent tasks.
90
+
91
+ ## 7. User Experience
92
+
93
+ ## 7.1 Entry points
94
+
95
+ V1 should support:
96
+
97
+ - `/agent-board` — open the dashboard from within Pi.
98
+ - CLI slash-command entrypoint such as `pi /agent-board`, if Pi supports passing slash commands at startup.
99
+
100
+ Stretch goals:
101
+
102
+ - `/bg [prompt]` — move current work into a managed background session, or send a follow-up prompt while backgrounding.
103
+ - `pi agents` style entrypoint, if Pi core or packaging model allows it cleanly.
104
+
105
+ ## 7.2 Main dashboard
106
+
107
+ The dashboard is a full-screen custom TUI component.
108
+
109
+ It must include:
110
+
111
+ - header with current global scope/defaults,
112
+ - grouped session rows,
113
+ - bottom input for dispatch/filter,
114
+ - footer with key hints.
115
+
116
+ ### Row fields
117
+ Each row should show at minimum:
118
+
119
+ - session name,
120
+ - current summary,
121
+ - semantic state,
122
+ - process/liveness state,
123
+ - relative last-activity time,
124
+ - cwd or project context,
125
+ - pin status,
126
+ - optional model/agent label.
127
+
128
+ ### Row grouping
129
+ V1 groups:
130
+
131
+ - Queued
132
+ - Running
133
+ - Needs input
134
+ - In Progress
135
+ - Done
136
+
137
+ Stretch:
138
+
139
+ - Group by directory/project.
140
+ - “Ready for review” style secondary grouping.
141
+
142
+ ## 7.3 States
143
+
144
+ Each session row needs two state dimensions.
145
+
146
+ ### Semantic state
147
+
148
+ - `queued`
149
+ - `working`
150
+ - `needs_input`
151
+ - `idle`
152
+ - `completed`
153
+ - `failed`
154
+ - `stopped`
155
+
156
+ ### Process/liveness state
157
+
158
+ - `alive`
159
+ - `exited`
160
+
161
+ This distinction is required so a session can remain resumable even when no worker process is currently alive.
162
+
163
+ ## 7.4 Core interactions
164
+
165
+ ### From dashboard
166
+
167
+ - `↑ / ↓` — move selection
168
+ - `Enter` — attach to selected session
169
+ - `Space` — open peek panel
170
+ - `Shift+Enter` — dispatch and attach
171
+ - `Ctrl+R` — rename session
172
+ - `Ctrl+T` — pin/unpin session
173
+ - `Ctrl+X` — stop/delete flow
174
+ - `Ctrl+S` — switch grouping mode
175
+ - `Esc` — close/clear/back
176
+ - `?` — help
177
+
178
+ Keybindings should be extension-configurable and aligned with Pi keybinding conventions.
179
+
180
+ ## 7.5 Peek panel
181
+
182
+ Peek panel is the lightweight triage surface.
183
+
184
+ It must show:
185
+
186
+ - current summary,
187
+ - latest meaningful output,
188
+ - current question/blocker (if any),
189
+ - inline reply box.
190
+
191
+ It should support:
192
+
193
+ - sending a normal reply,
194
+ - optional suggested reply later,
195
+ - navigating between adjacent sessions without fully closing.
196
+
197
+ ## 7.6 Attach / detach
198
+
199
+ ### Attach
200
+ Attaching opens the full interactive Pi session for that row’s session file.
201
+
202
+ ### Detach
203
+ Detaching returns the user to agent board without losing session state.
204
+
205
+ V1 requirement:
206
+
207
+ - attaching must work,
208
+ - detaching back to agent board must work at least from an idle/known-safe state.
209
+
210
+ Stretch:
211
+
212
+ - detach while a session is actively running by handing execution back to a headless worker.
213
+
214
+ ## 8. Functional Requirements
215
+
216
+ ### FR1. Background session model
217
+ Each background row must map to:
218
+
219
+ - a Pi session file,
220
+ - a persisted session ID,
221
+ - a working directory,
222
+ - a stored dashboard record,
223
+ - zero or one live worker processes at a time.
224
+
225
+ ### FR2. Background execution engine
226
+ The extension must be able to:
227
+
228
+ - create a background session,
229
+ - append user messages to it,
230
+ - spawn a headless Pi worker to advance it,
231
+ - parse streaming JSON events,
232
+ - update row state live,
233
+ - mark the session resumable when the worker exits.
234
+
235
+ ### FR3. Dashboard persistence
236
+ Agent-view state must persist across:
237
+
238
+ - Pi restart,
239
+ - `/reload`,
240
+ - session switching,
241
+ - worker exit.
242
+
243
+ ### FR4. Dispatch
244
+ Dispatch input must:
245
+
246
+ - create a new background session from a user prompt,
247
+ - support dispatch + attach,
248
+ - support filtering mode when input matches reserved patterns.
249
+
250
+ V1 filtering support:
251
+
252
+ - `s:<state>`
253
+ - free-text substring on name/summary/cwd
254
+
255
+ Stretch:
256
+
257
+ - `a:<agent>`
258
+ - `#PR` or URL mapping
259
+
260
+ ### FR5. Reply from peek
261
+ A user must be able to send a reply from peek without manually opening the attached session.
262
+
263
+ ### FR6. Attach to session
264
+ A user must be able to switch into the selected session’s full transcript and continue working interactively.
265
+
266
+ ### FR7. Rename / pin / stop / delete
267
+ The dashboard must support:
268
+
269
+ - renaming a session,
270
+ - pinning/unpinning,
271
+ - stopping active work,
272
+ - deleting dashboard entries,
273
+ - preserving transcript safety unless user explicitly chooses destructive cleanup.
274
+
275
+ ### FR8. Safe file isolation
276
+ When background sessions may edit the same repository, the system must provide an isolation strategy.
277
+
278
+ V1:
279
+
280
+ - support optional git worktree isolation.
281
+
282
+ Later:
283
+
284
+ - automatically create worktree isolation before first mutation.
285
+
286
+ ### FR9. Session summaries
287
+ Each row must have a short summary suitable for dashboard scanning.
288
+
289
+ V1:
290
+
291
+ - heuristic summary based on current tool, latest assistant text, blocker text, and terminal state.
292
+
293
+ Later:
294
+
295
+ - lightweight summarizer model pass with throttling.
296
+
297
+ ### FR10. Recovery / respawn
298
+ If a worker process exits, the session must remain attachable and replyable.
299
+
300
+ If Pi is restarted, the extension must be able to reconstruct the dashboard from persisted state and resume/respawn sessions as needed.
301
+
302
+ ## 9. Technical Constraints
303
+
304
+ ### 9.1 Runtime target
305
+ Implementation must target the active Pi runtime:
306
+
307
+ - `/opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent`
308
+
309
+ Do **not** anchor on the stale legacy copy under `~/.pi/agent/npm/node_modules/@mariozechner/...`.
310
+
311
+ ### 9.2 Public API constraint
312
+ Implementation should use Pi’s documented/public extension APIs, especially:
313
+
314
+ - extension lifecycle/events,
315
+ - `ctx.ui.custom()` and TUI components,
316
+ - widgets/footer/header,
317
+ - message renderers,
318
+ - session switching / newSession / switchSession / fork APIs,
319
+ - extension commands and shortcuts.
320
+
321
+ ### 9.3 No unstable internal imports
322
+ Do **not** runtime-import `~/.pi/agent/npm/node_modules/pi-subagents/src/...` internals.
323
+
324
+ Allowed:
325
+
326
+ - study `pi-subagents` source as a reference,
327
+ - copy/adapt patterns if necessary.
328
+
329
+ Not allowed:
330
+
331
+ - depending on its internal TS files as if they were a stable library contract.
332
+
333
+ ### 9.4 Headless child constraint
334
+ Background workers will run headless.
335
+
336
+ This means:
337
+
338
+ - child Pi processes should run in JSON/print-style non-interactive mode,
339
+ - child sessions do not own UI,
340
+ - parent agent board owns all live visualization and state aggregation.
341
+
342
+ ## 10. Suggested Architecture
343
+
344
+ ### Option A — recommended
345
+ Build a **session-oriented background engine** specifically for agent board.
346
+
347
+ Components:
348
+
349
+ - `dashboard.ts` — main TUI
350
+ - `peek-panel.ts` — inline triage UI
351
+ - `store.ts` — persisted roster/state
352
+ - `supervisor.ts` — worker spawn/watch/respawn
353
+ - `session-launch.ts` — create/advance background sessions
354
+ - `session-summary.ts` — short summary generation
355
+ - `worktree.ts` — optional edit isolation
356
+
357
+ Why: this best matches Claude’s product shape.
358
+
359
+ ### Option B — fallback
360
+ Fork/copy the official `examples/extensions/subagent` example and evolve it into a session-based engine.
361
+
362
+ Why: uses clean public APIs, but requires more features to be built from scratch.
363
+
364
+ ### Option C — partial reuse
365
+ Use `pi-subagents` only as a design reference for:
366
+
367
+ - async tracking,
368
+ - widget rendering,
369
+ - nested progress ideas,
370
+ - worktree patterns.
371
+
372
+ Why: high leverage, lower coupling.
373
+
374
+ ## 11. MVP Scope
375
+
376
+ ### Included in MVP
377
+
378
+ - `/agent-board` dashboard
379
+ - global cross-project session view by default
380
+ - persisted roster/store
381
+ - create background Pi sessions
382
+ - spawn headless workers to process prompts
383
+ - live row updates
384
+ - project-safe attach to full session
385
+ - peek + reply
386
+ - rename/pin/stop/delete
387
+ - basic grouping
388
+ - cheap model-backed summaries with heuristic fallback
389
+ - required worktree isolation for same-repo parallel writer sessions
390
+
391
+ ### Excluded from MVP
392
+
393
+ - shell job rows (`! command`)
394
+ - PR badges / PR-aware grouping
395
+ - full Claude-style detach semantics while actively running
396
+
397
+ ## 12. Phase Plan
398
+
399
+ ### Phase 1 — foundation
400
+
401
+ - Extension scaffold
402
+ - Persistent store format
403
+ - Worker launcher
404
+ - Event parser
405
+ - `/agent-board` TUI
406
+ - Dispatch + live updates
407
+
408
+ ### Phase 2 — interactive workflow
409
+
410
+ - Peek panel
411
+ - Inline reply
412
+ - Attach flow
413
+ - Safe detach-back path
414
+ - Rename/pin/stop/delete polish
415
+ - Restore dashboard after restart/reload
416
+
417
+ ### Phase 3 — parity improvements
418
+
419
+ - Better summaries
420
+ - Auto worktree isolation
421
+ - Idle reap + lazy respawn
422
+ - Shell job rows
423
+ - Advanced filtering/grouping
424
+ - `/bg` flow for current interactive session
425
+
426
+ ## 13. Acceptance Criteria
427
+
428
+ The PRD is satisfied for MVP when:
429
+
430
+ 1. A user can open `/agent-board` and see a dashboard UI.
431
+ 2. A user can dispatch a new background coding task from the dashboard.
432
+ 3. The task creates a real persisted Pi session file.
433
+ 4. The row updates while the background worker runs.
434
+ 5. If the worker exits, the row remains in the dashboard and is still resumable.
435
+ 6. A user can open peek, read current context, and send a reply.
436
+ 7. A user can attach to the full session from the dashboard.
437
+ 8. Dashboard state survives Pi restart or `/reload`.
438
+ 9. Two tasks in the same repo can be run without silent file corruption when worktree mode is enabled.
439
+ 10. The implementation does not depend on unstable `pi-subagents/src/...` runtime imports.
440
+
441
+ ## 14. Success Metrics
442
+
443
+ Initial success measures:
444
+
445
+ - User can manage at least 3 concurrent background sessions comfortably.
446
+ - Attach/peek/reply flows feel faster than manual `/resume` juggling.
447
+ - Dashboard rehydration works reliably after reload/restart.
448
+ - No known file-clobber incidents in supported isolation mode.
449
+
450
+ ## 15. Risks / Open Questions
451
+
452
+ 1. **Detach semantics**
453
+ How close can we get to Claude’s “return to agent board” behavior using only extension/session APIs?
454
+
455
+ 2. **Top-level launch experience**
456
+ Is `/agent-board` enough, or do we need a true standalone startup path?
457
+
458
+ 3. **Worktree timing**
459
+ Should worktrees be created at dispatch time or lazily on first mutation?
460
+
461
+ 4. **Current session backgrounding**
462
+ When `/bg` lands later, should it create a fresh managed background session from current transcript, or simply convert current session ownership?
463
+
464
+ ## 16. Reference Inputs
465
+
466
+ Product/behavior reference:
467
+
468
+ - Claude agent-view docs: https://code.claude.com/docs/en/agent-view
469
+
470
+ Pi implementation references:
471
+
472
+ - `/opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/docs/extensions.md`
473
+ - `/opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/docs/tui.md`
474
+ - `/opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/docs/sessions.md`
475
+ - `/opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/docs/keybindings.md`
476
+ - `/opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/examples/extensions/subagent/index.ts`
477
+ - `/opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/examples/extensions/plan-mode/index.ts`
478
+ - `~/.pi/agent/npm/node_modules/pi-subagents/README.md`
479
+
480
+ ## 17. Recommendation
481
+
482
+ Proceed with a **session-oriented agent-board extension** as the primary implementation path.
483
+
484
+ Do **not** treat this as a UI wrapper over `pi-subagents`. Use `pi-subagents` as a source of implementation ideas, but build the actual product around persisted Pi sessions, a parent-owned dashboard, and a lightweight supervisor/store.
package/PROGRESS.md ADDED
@@ -0,0 +1,127 @@
1
+ # Progress Log — Pi Agent Board Extension
2
+
3
+ Living checkpoint log. Newest checkpoint at top. Records what's done, workarounds, and
4
+ nuances future agents must know. Pairs with `docs/EXPLORATION.md` (the Pi API gist).
5
+
6
+ Status legend: ☐ todo · ◐ in progress · ☑ done
7
+
8
+ ---
9
+
10
+ ## Milestone status
11
+
12
+ - ☑ **M0** scaffold + primitives (paths, types, atomic IO, ids, pid)
13
+ - ☑ **M1** detached runner (`job-runner.mjs`) + durable store + dispatch + event reduce
14
+ - ☑ **M2** dashboard list + grouping + filters + live poll
15
+ - ☑ **M3** peek + reply
16
+ - ☑ **M4** attach / attach-while-running confirm / recovery (reconcile) / stop / rename / pin
17
+ - ☑ **M5** repo safety + worktree mode (same-repo writer rule wired into dispatch)
18
+ - ☑ tests: 45/45 green · typecheck 0 errors · extension loads in real pi
19
+ - ⚠️ **Blocked on env:** live end-to-end (real worker producing output) needs pi provider auth
20
+ in this environment; see CP2 + `VERIFY.md`. Code paths validated hermetically.
21
+
22
+ ---
23
+
24
+ ## Checkpoint log
25
+
26
+ ### CP4 — 2026-05-31 — fast non-live attach via warm PTY hosts
27
+ - Non-live attach now uses the same Agent Board PTY host path as live sessions. `ctx.switchSession`
28
+ remains only as a no-PTY fallback, with a fullscreen switching overlay so the previously
29
+ attached session is not visible during fallback startup.
30
+ - Added `ensureHost()` / dashboard prewarm: selected idle/completed sessions are lazily started
31
+ as interactive PTY hosts with `initialPrompt: null`, without mutating row task state. Warm
32
+ attach should be instant; cold attach immediately swaps to the attach surface and retries the
33
+ socket until the host is ready.
34
+ - Kept completed hosts warm instead of terminating them immediately. Warm pool defaults:
35
+ `AGENT_BOARD_MAX_WARM_HOSTS=4`, `AGENT_BOARD_WARM_HOST_TTL_MS=600000`.
36
+ - Fixed PTY detach flow: `ctrl+]`, `ctrl+g`, or `←` from a live attach returns to the dashboard
37
+ loop instead of revealing the original session where `/agent-board` was invoked.
38
+ - Added internal scrollback controls for PTY attach surfaces: mouse wheel, `pgup` / `pgdn`,
39
+ `home`, `end`. Scrolling uses an agent-board-owned absolute viewport and clamps at top/bottom
40
+ so fast wheel events cannot wrap back to the bottom. Normal arrow keys still pass through.
41
+ - Verification: `npm run typecheck` clean; `npm test` 55/55 green.
42
+
43
+ ### CP3 — 2026-05-30 — standalone-ish dashboard UX
44
+ - Added a full-screen **session view** inside `/agent-board`: **v** opens the selected row's
45
+ live transcript from its managed session file without interrupting the worker; **← / <**
46
+ returns to the dashboard. **→ / >** now attaches to the real Pi session, matching the
47
+ primary agent-board navigation expectation. **enter** also attaches. In an attached managed
48
+ session, **←** from an empty input reopens agent board directly using the command-capable
49
+ replacement context (no slash-command text injection).
50
+ - Added `src/core/session-view.mjs` to parse managed Pi session JSONL files and project the
51
+ active branch into a readable transcript surface (messages, visible custom messages,
52
+ compactions, branch summaries).
53
+ - Changed the main dashboard UX to match the Claude-style screenshot more closely: the bottom
54
+ input is always available, typing there and pressing **Enter** dispatches a new Pi session,
55
+ and **Enter** on an empty input attaches to the selected session.
56
+ - Added a startup entrypoint; on `session_start(reason:"startup")` the extension opens the
57
+ dashboard **directly** from the startup event with hidden Pi header/footer chrome, so users
58
+ can launch with `pi /agent-board` into a cleaner fullscreen surface. Quitting that dashboard
59
+ exits Pi instead of dropping into a chat session.
60
+
61
+
62
+ ### CP2 — 2026-05-30 — full MVP wired (M2–M5) + ⚠️ real-worker hang found
63
+ - Built the Pi-coupled layer: `src/runtime/service.mjs` (dispatch/reply/stop/pin/rename/
64
+ archive/reconcile + same-repo worktree safety), `src/ui/dashboard.ts` (one `ctx.ui.custom`
65
+ component: list/peek/reply/dispatch/filter/rename/confirm/help modes, live 700ms poll, scroll),
66
+ `src/commands/agent-board.ts` (`/agent-board` command + action loop + attach via `ctx.switchSession`),
67
+ `src/index.ts` (entry: command, footer status, session_start recovery),
68
+ root `index.ts` (re-export for auto-discovery).
69
+ - **`npx tsc --noEmit` = 0 errors** against the real Pi `.d.ts` (path-mapped). **45/45 tests pass.**
70
+ - **Smoke: `pi --list-models -e src/index.ts` loads the extension cleanly** (factory + all imports
71
+ resolve under pi's jiti, exit 0).
72
+ - **⚠️ REAL-WORKER HANG (env auth, not a bug):** running the real `pi` worker through the runner
73
+ (and `pi --mode json -p` directly) **blocks at the provider request** — emits up to the *user*
74
+ `message_end` then nothing (no assistant reply, no `agent_end`, no exit; idle 3% CPU). Cause:
75
+ pi has no working provider auth/network in this non-interactive context (pi auth ≠ Claude
76
+ Code `/login`). The credential-scan probe was (correctly) blocked by the sandbox classifier.
77
+ Extension behaves correctly: row stays `working` until stopped. **To validate live dispatch,
78
+ pi itself must be authed** — see `VERIFY.md`. Hermetic fake-pi tests prove the runner pipeline.
79
+ - **Change (user):** default summary model → **`gpt-4o`** (was claude-haiku-4-5). Still ON by
80
+ default, heuristic fallback retained. Needs OpenAI auth or it falls back.
81
+ - **UX fix (nuance):** runner now persists the terminal state (heuristic summary) **immediately**
82
+ on worker close, *then* upgrades the summary via the model (15s timeout) and re-persists — so a
83
+ slow/unreachable summary model can't delay a row flipping to `completed`.
84
+
85
+
86
+ ### CP0 — 2026-05-30 — recon done, scaffolding started
87
+ - Read full Pi API (extensions, tui, sessions, json, session-format) + subagent/plan-mode
88
+ examples + dist type defs. Findings distilled into `docs/EXPLORATION.md` (read that first).
89
+ - **Decisions locked for impl** (see EXPLORATION §8): detached `.mjs` runner spawns
90
+ `pi --mode json -p --session <file> "<prompt>"`; dashboard is one `ctx.ui.custom` component;
91
+ heuristics are the default summarizer (model summary opt-in); attach = `ctx.switchSession`.
92
+ - **Workaround/nuance:**
93
+ - Node 24 runs `.ts` directly (type-stripping) ⇒ unit tests need no build step; write
94
+ pure-logic modules with only `node:*` imports so `node --test` can run them.
95
+ - **Avoid `typebox`**: MVP has no LLM-facing tool; `/agent-board` is a command. Store schemas are
96
+ plain TS interfaces (erasable), not typebox — keeps modules node-testable & dep-free.
97
+ - Pi packages aren't in this repo's node_modules; they're resolved by Pi's jiti at runtime.
98
+ For local typecheck only, `tsconfig.json` path-maps `@earendil-works/*` to the global
99
+ install. Runtime needs no install.
100
+ - Verification can't use a TTY/API key here ⇒ integration test runs the real runner against
101
+ a **fake pi** stub (`test-support/fake-pi.mjs`) that prints canned JSON event lines.
102
+
103
+ ---
104
+
105
+ ### CP1 — 2026-05-30 — core brain + runner green (M0+M1)
106
+ - Wrote `src/core/*.mjs`: paths, ids, atomic, types, heuristics, derive, events, pid, store,
107
+ repo, worktree, launch, invocation, rows. All pure node, JSDoc-typed.
108
+ - Wrote `runner/job-runner.mjs` (detached monitor) + `test-support/fake-pi.mjs` (hermetic
109
+ worker stub) + 7 test files. **`node --test` → 45/45 pass.** Validates dispatch→events→
110
+ status/state→finalize, needs_input/failed/stopped classification, and durable artifacts,
111
+ all without an API key or TTY.
112
+ - **Design fix (nuance):** `latestAssistantPreview` now stores the *full* latest assistant text
113
+ (truncated 240) so peek shows real output; `deriveSummary()` condenses it to a first sentence
114
+ (falling back to full text if the 1st sentence is <12 chars, e.g. "Done."). Don't re-conflate.
115
+ - **Change per user:** cheap-model summary is now **ON by default** (`DEFAULT_SUMMARY_MODEL=
116
+ claude-haiku-4-5` in the runner), heuristic kept as graceful fallback (no-key/offline/timeout)
117
+ and for state detection. Disable with `AGENT_BOARD_SUMMARY_MODEL=off`; override with a model id.
118
+ Tests set it `off` so the fake worker's stream doesn't get re-summarized.
119
+ - **Invocation nuance:** `src/core/invocation.mjs` resolves how to spawn pi (node+cli.js vs
120
+ compiled binary vs `pi` on PATH) — mirrors the subagent example. Runner runs under real `node`.
121
+ - **pid nuance:** `pid.json` holds the *runner/monitor* pid (parent polls it for liveness);
122
+ `status.json.pid` holds the *worker* pid. `isAlive` treats EPERM as alive.
123
+
124
+ ## Known risks / open items
125
+ - `ctx.ui.custom` full-screen height: drive off `tui.terminal.rows`; verify scrolling math.
126
+ - Worktree edge cases (dirty repo, cleanup) — M5; ship strict single-writer rule first.
127
+ - Model summarizer spawns a pi process per summary — must throttle; default off.