@zhuxixi/pi-agent-board 0.12.1 → 0.13.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 (44) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +7 -7
  3. package/docs/superpowers/plans/2026-10-21-issue-221-ask-user-question.md +198 -0
  4. package/docs/superpowers/plans/2026-10-23-issue-225-monotonic-foreground-state.md +450 -0
  5. package/docs/superpowers/plans/2026-10-23-issue-229-vim-jkl.md +449 -0
  6. package/docs/superpowers/plans/2026-10-23-issue-232-attach-bg-only-cells.md +153 -0
  7. package/docs/superpowers/plans/2026-10-23-lease-heartbeat-staleness.md +537 -0
  8. package/docs/superpowers/plans/2026-10-23-selected-row-highlight.md +405 -0
  9. package/docs/superpowers/plans/2026-10-24-issue-217-windows-pid-reuse-stopping.md +367 -0
  10. package/docs/superpowers/plans/2026-10-24-issue-230-warm-host-background-runs.md +806 -0
  11. package/docs/superpowers/plans/2026-10-24-issue-238-windows-process-identity-token.md +490 -0
  12. package/docs/superpowers/plans/2026-10-24-issue-241-coordinator-root-exit.md +461 -0
  13. package/docs/superpowers/plans/2026-10-25-issue-239-coordinator-replacement-identity.md +504 -0
  14. package/docs/superpowers/specs/2026-10-20-issue-221-ask-user-question-design.md +270 -0
  15. package/docs/superpowers/specs/2026-10-22-issue-225-monotonic-foreground-state-design.md +225 -0
  16. package/docs/superpowers/specs/2026-10-23-issue-229-vim-jkl-design.md +90 -0
  17. package/docs/superpowers/specs/2026-10-23-issue-232-attach-bg-only-cells-design.md +146 -0
  18. package/docs/superpowers/specs/2026-10-23-lease-heartbeat-staleness-design.md +271 -0
  19. package/docs/superpowers/specs/2026-10-23-selected-row-highlight-design.md +191 -0
  20. package/docs/superpowers/specs/2026-10-24-issue-217-windows-pid-reuse-stopping-design.md +334 -0
  21. package/docs/superpowers/specs/2026-10-24-issue-230-warm-host-background-runs-design.md +283 -0
  22. package/docs/superpowers/specs/2026-10-24-issue-238-windows-process-identity-token-design.md +286 -0
  23. package/docs/superpowers/specs/2026-10-24-issue-241-coordinator-root-exit-design.md +381 -0
  24. package/docs/superpowers/specs/2026-10-25-issue-239-coordinator-replacement-identity-design.md +331 -0
  25. package/package.json +3 -3
  26. package/runner/pty-runner.mjs +18 -22
  27. package/runner/state-coordinator.mjs +213 -26
  28. package/scripts/run-tests.mjs +375 -0
  29. package/src/core/background-runs.mjs +273 -0
  30. package/src/core/coordinator-client.mjs +346 -26
  31. package/src/core/diagnostics.mjs +24 -0
  32. package/src/core/events.mjs +16 -3
  33. package/src/core/foreground-projection-cache.mjs +99 -0
  34. package/src/core/host-coordination.mjs +69 -1
  35. package/src/core/launch.mjs +21 -1
  36. package/src/core/locks.mjs +176 -31
  37. package/src/core/pid.mjs +4 -2
  38. package/src/core/process-identity-probe.mjs +228 -0
  39. package/src/core/state-commands.mjs +5 -1
  40. package/src/core/types.mjs +1 -0
  41. package/src/core/warm-host-sweeper.mjs +7 -2
  42. package/src/runtime/service.mjs +385 -73
  43. package/src/ui/dashboard.ts +48 -25
  44. package/src/ui/pty-attach.ts +14 -6
package/CHANGELOG.md CHANGED
@@ -5,6 +5,28 @@ conventional commits by `scripts/release_helper.mjs`. Entries are
5
5
  forward-only: they begin with the first release after this file landed —
6
6
  for earlier history, see the git log and the pull-request list.
7
7
 
8
+ ## [0.13.0] - 2026-10-26
9
+
10
+ ### Features
11
+
12
+ - **ui**: vim-style j/k/l board keys — j/k navigate, l attaches (issue #229) (#237)
13
+ - **ui**: paint the selected board row with selectedBg (issue #231) (#233)
14
+
15
+ ### Fixes
16
+
17
+ - **coordinator**: verify lease identity before signalling (issue #239) (#247)
18
+ - **dashboard**: keep selected rows visible beside scroll markers (#226)
19
+ - **attach**: render cells that only carry a background (#235)
20
+ - **coordinator**: root-vanished self-exit and suite leak gate (issue #241) (#244)
21
+ - **host**: unify process identity tokens and produce them on win32 (issue #238) (#243)
22
+ - **host**: keep warm hosts alive while a background workflow run is active (issue #230) (#242)
23
+ - **host**: corroborate unverified process identity to unstick pid-reuse recovery (issue #217) (#240)
24
+ - **lease**: reclaim stale coordinator leases by heartbeat instead of pid liveness (issue #224) (#236)
25
+ - keep foreground rows monotonic across out-of-order state writes (#228)
26
+ - recognize ask_user_question and questionnaire-shaped tools as pending questions (#223)
27
+
28
+ [0.13.0]: https://github.com/zhuxixi/pi-agent-board/compare/v0.12.1...v0.13.0
29
+
8
30
  ## [0.12.1] - 2026-10-20
9
31
 
10
32
  ### Fixes
package/README.md CHANGED
@@ -127,10 +127,10 @@ Shortcuts are scoped to the view where they are available:
127
127
 
128
128
  | Key | Action |
129
129
  | --- | --- |
130
- | `Up` / `Down` | Move the selection. |
130
+ | `Up` / `Down` / `j` / `k` | Move the selection. |
131
131
  | `i` | Enter INSERT mode for a new task. |
132
132
  | `Enter` | Open Start session for a draft, or attach/resume when the input is empty. |
133
- | `Right` / `>` | Attach to the selected session. |
133
+ | `Right` / `>` / `l` | Attach to the selected session. |
134
134
  | `Space` | Open Peek. |
135
135
  | `v` | Open the read-only transcript. |
136
136
  | `e` | Open Evidence / Diagnostics. |
@@ -156,12 +156,12 @@ Peek shows the selected session's summary, blocker or question, latest output, a
156
156
  | Key | Action |
157
157
  | --- | --- |
158
158
  | `r` or `Enter` | Enter reply mode; type a follow-up and press `Enter` to send it without attaching. |
159
- | `a`, `Right`, or `>` | Attach to the session. |
159
+ | `a`, `Right`, `>`, or `l` | Attach to the session. |
160
160
  | `v` | Open the read-only transcript. |
161
161
  | `e` | Open Evidence / Diagnostics. |
162
162
  | `d` | Confirm marking the inactive session Done. |
163
163
  | `h` | Hold or unhold the session. |
164
- | `Up` / `Down` | Move to the previous or next session. |
164
+ | `Up` / `Down` / `j` / `k` | Move to the previous or next session. |
165
165
  | `Esc` | Return to the main list. |
166
166
 
167
167
  When a Pi question or questionnaire tool is pending, inline reply is rejected; attach to answer that interactive question in the real Pi session.
@@ -172,7 +172,7 @@ The `v` view is a read-only projection of the durable Pi session JSONL. It does
172
172
 
173
173
  | Key | Action |
174
174
  | --- | --- |
175
- | `Up` / `Down` | Scroll one line. |
175
+ | `Up` / `Down` / `j` / `k` | Scroll one line. |
176
176
  | `PageUp` / `PageDown` | Scroll one page. |
177
177
  | `Space` | Open Peek. |
178
178
  | `r` | Enter reply mode. |
@@ -188,11 +188,11 @@ The `e` view shows durable session evidence, including changed files, commands a
188
188
 
189
189
  | Key | Action |
190
190
  | --- | --- |
191
- | `Up` / `Down` | Scroll one line. |
191
+ | `Up` / `Down` / `j` / `k` | Scroll one line. |
192
192
  | `PageUp` / `PageDown` | Scroll one page. |
193
193
  | `r` | Enter reply mode. |
194
194
  | `v` | Open the read-only transcript. |
195
- | `Enter`, `a`, or `Right` | Attach to the session. |
195
+ | `Enter`, `a`, `Right`, or `l` | Attach to the session. |
196
196
  | `x` | Clear diagnostics; evidence is preserved. |
197
197
  | `Left` / `Esc` / `<` | Return to the main list. |
198
198
 
@@ -0,0 +1,198 @@
1
+ # Recognize `ask_user_question` (name OR questionnaire shape) Implementation Plan
2
+
3
+ > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4
+
5
+ **Goal:** Make an interactive run blocked on `ask_user_question` — or on any tool using the questionnaire arg shape — group under "Needs answer" instead of "RUNNING".
6
+
7
+ **Architecture:** Two private helpers in `src/core/events.mjs` (`isQuestionArgShape`, `isQuestionToolCall`); the start gate uses `isQuestionToolCall(name, args)`, the end gate becomes name-agnostic and removes by `toolCallId`. Two reducer tests in `test/events.test.mjs` drive the public surface (`createRunStatus` / `reduceEvent` / `projectViewState`).
8
+
9
+ **Tech Stack:** Node 22, `node:test` + `assert/strict`, plain ESM `.mjs` (no build step).
10
+
11
+ **Spec:** `docs/superpowers/specs/2026-10-20-issue-221-ask-user-question-design.md`
12
+
13
+ ## Global Constraints
14
+
15
+ - Tabs for indentation; English comments and commit messages.
16
+ - Conventional commit subject with the PR number appended as `(#N)` (this branch's PR number is filled in at PR time; use `(#221)` for the issue-numbered commits that predate the PR).
17
+ - Run `npm run verify` before claiming completion — `npm test` alone skips the perf gate and coverage thresholds.
18
+ - Do not touch `detectNeedsInput()`, `message_end` classification, or the `"ask_questions"` no-id fallback ids (`events.mjs:242/250`).
19
+ - Detached (non-interactive) runs must keep the legacy `currentTool` behavior.
20
+
21
+ ## Review Focus
22
+
23
+ - A tool whose args are `{ questions: [] }` or `{ questions: "…" }` must **not** be treated as awaiting input (shape check needs a non-empty array whose first item has a string `question`).
24
+ - Detached runs: the shape fallback must never produce `needs_input` (headless sessions cannot answer).
25
+ - Parallel calls: ending one question must not clear another pending one (existing multi-question test at `test/events.test.mjs:135`).
26
+ - An end event for a non-question tool must be a no-op for `pendingQuestions`.
27
+ - `args` missing entirely on a question-tool start (`ask_questions` with `{}`) must still count via the name set.
28
+
29
+ ---
30
+
31
+ ### Task 1: Hybrid question-tool detection
32
+
33
+ **Files:**
34
+ - Modify: `src/core/events.mjs:20-21` (set), `:86` (start gate), `:100` (end gate), add helpers near `questionFromArgs` (`:232`)
35
+ - Test: `test/events.test.mjs` (append after the existing `interactive pi question tool …` test at `:185-204`)
36
+
37
+ **Interfaces:**
38
+ - Consumes: `createRunStatus(config, pid, now)`, `reduceEvent(status, event, now, opts)`, `projectViewState(status, now)` from `src/core/events.mjs`.
39
+ - Produces: module-private `isQuestionArgShape(args: unknown): boolean` and `isQuestionToolCall(name: string, args: unknown): boolean`; no exports change.
40
+
41
+ - [ ] **Step 1: Write the failing tests**
42
+
43
+ Append to `test/events.test.mjs`:
44
+
45
+ ```js
46
+ test("interactive ask_user_question waits for input and clears on end", () => {
47
+ const s = createRunStatus(cfg(), 1, 1000);
48
+ reduceEvent(s, {
49
+ type: "tool_execution_start",
50
+ toolCallId: "q1",
51
+ toolName: "ask_user_question",
52
+ args: { questions: [{ question: "Which approach?", header: "Approach", options: [{ label: "A", description: "a" }] }] },
53
+ }, 2000, { interactive: true });
54
+ assert.equal(s.semanticState, "needs_input");
55
+ assert.equal(s.summary, "Which approach?");
56
+ assert.equal(s.question, "Which approach?");
57
+ assert.equal(s.currentTool, null);
58
+ assert.deepEqual(s.pendingQuestions, [{ toolCallId: "q1", question: "Which approach?" }]);
59
+ assert.equal(projectViewState(s, 2100).needsInput, true);
60
+
61
+ reduceEvent(s, { type: "tool_execution_end", toolCallId: "q1", toolName: "ask_user_question", isError: false }, 2400, { interactive: true });
62
+ assert.equal(s.semanticState, "working");
63
+ assert.equal(s.question, null);
64
+ assert.deepEqual(s.pendingQuestions, []);
65
+
66
+ const detached = createRunStatus(cfg(), 1, 1000);
67
+ reduceEvent(detached, {
68
+ type: "tool_execution_start",
69
+ toolCallId: "q1",
70
+ toolName: "ask_user_question",
71
+ args: { questions: [{ question: "Which approach?" }] },
72
+ }, 2000);
73
+ assert.equal(detached.semanticState, "working");
74
+ assert.equal(detached.currentTool.name, "ask_user_question");
75
+ assert.deepEqual(detached.pendingQuestions, []);
76
+ });
77
+
78
+ test("interactive unknown questionnaire shape is treated as a pending question", () => {
79
+ const s = createRunStatus(cfg(), 1, 1000);
80
+ reduceEvent(s, {
81
+ type: "tool_execution_start",
82
+ toolCallId: "q1",
83
+ toolName: "mystery_questionnaire",
84
+ args: { questions: [{ question: "Ship it?", header: "Release", options: [{ label: "Yes" }] }] },
85
+ }, 2000, { interactive: true });
86
+ assert.equal(s.semanticState, "needs_input");
87
+ assert.equal(s.question, "Ship it?");
88
+ assert.equal(s.currentTool, null);
89
+ assert.deepEqual(s.pendingQuestions, [{ toolCallId: "q1", question: "Ship it?" }]);
90
+
91
+ reduceEvent(s, { type: "tool_execution_end", toolCallId: "q1", toolName: "mystery_questionnaire", isError: false }, 2400, { interactive: true });
92
+ assert.equal(s.semanticState, "working");
93
+ assert.equal(s.question, null);
94
+ assert.deepEqual(s.pendingQuestions, []);
95
+
96
+ for (const args of [{ questions: [] }, { questions: "nope" }, { command: "ls" }]) {
97
+ const negative = createRunStatus(cfg(), 1, 1000);
98
+ reduceEvent(negative, { type: "tool_execution_start", toolCallId: "t1", toolName: "bash", args }, 2000, { interactive: true });
99
+ assert.equal(negative.semanticState, "working", JSON.stringify(args));
100
+ assert.deepEqual(negative.pendingQuestions, []);
101
+ }
102
+ });
103
+ ```
104
+
105
+ - [ ] **Step 2: Run the tests to verify they fail**
106
+
107
+ Run: `npm test -- --test-name-pattern="ask_user_question|unknown questionnaire"`
108
+ Expected: FAIL — the first test reports `semanticState === "working"` / `summary === "Ask_user_question"`; the second reports `semanticState === "working"` for `mystery_questionnaire`.
109
+
110
+ - [ ] **Step 3: Implement the detection helpers**
111
+
112
+ In `src/core/events.mjs`, replace the set definition:
113
+
114
+ ```js
115
+ /** Tool names whose interactive execution blocks on a user answer. */
116
+ const QUESTION_TOOL_NAMES = new Set(["ask_user_question", "ask_questions", "question", "questionnaire"]);
117
+
118
+ /** Questionnaire args shared by pi/Claude-Code style question tools. */
119
+ function isQuestionArgShape(args) {
120
+ const questions = Array.isArray(args?.questions) ? args.questions : null;
121
+ return Boolean(questions && questions.length > 0 && typeof questions[0]?.question === "string");
122
+ }
123
+
124
+ /** A start event is a question when its name is known or its args carry the questionnaire shape. */
125
+ function isQuestionToolCall(name, args) {
126
+ return QUESTION_TOOL_NAMES.has(name) || isQuestionArgShape(args);
127
+ }
128
+ ```
129
+
130
+ - [ ] **Step 4: Wire the start and end gates**
131
+
132
+ In the `tool_execution_start` case, replace
133
+
134
+ ```js
135
+ if (opts.interactive && QUESTION_TOOL_NAMES.has(name)) {
136
+ ```
137
+
138
+ with
139
+
140
+ ```js
141
+ if (opts.interactive && isQuestionToolCall(name, args)) {
142
+ ```
143
+
144
+ In the `tool_execution_end` case, replace
145
+
146
+ ```js
147
+ if (opts.interactive && QUESTION_TOOL_NAMES.has(event.toolName ?? "")) removePendingQuestion(status, event.toolCallId);
148
+ ```
149
+
150
+ with
151
+
152
+ ```js
153
+ // The end event carries no args, so a shape-matched start cannot be recognized here;
154
+ // remove by call id instead (a no-op when this call had no pending question).
155
+ if (opts.interactive) removePendingQuestion(status, event.toolCallId);
156
+ ```
157
+
158
+ - [ ] **Step 5: Run the reducer tests and the whole suite**
159
+
160
+ Run: `npm test`
161
+ Expected: PASS — the two new tests plus the existing `ask_questions` / `question` / `questionnaire` / parallel-question tests stay green. (A1–A4, A5–A7)
162
+
163
+ - [ ] **Step 6: Run the full gate**
164
+
165
+ Run: `npm run verify`
166
+ Expected: PASS — typecheck, perf gate, tests, coverage thresholds (85/80/70), pack dry-run. (A8)
167
+
168
+ - [ ] **Step 7: Commit**
169
+
170
+ ```bash
171
+ git add src/core/events.mjs test/events.test.mjs
172
+ git commit -m "fix: recognize ask_user_question and questionnaire-shaped tools as pending questions (#221)"
173
+ ```
174
+
175
+ ---
176
+
177
+ ### Task 2: Post-merge live verification (manual, not a code task)
178
+
179
+ **Files:** none.
180
+
181
+ - [ ] **Step 1: Update the board clone the running process loads**
182
+
183
+ ```bash
184
+ cd ~/.pi/agent/git/github.com/zhuxixi/pi-agent-board
185
+ git checkout -- package-lock.json
186
+ git pull
187
+ git log -1 --oneline
188
+ ```
189
+
190
+ Expected: HEAD is the merged commit from this branch.
191
+
192
+ - [ ] **Step 2: Restart Pi / the board service**, then open the dashboard.
193
+
194
+ - [ ] **Step 3: Dispatch a session that blocks on `ask_user_question`** (the `@juicesharp/rpiv-ask-user-question` extension is installed at user level), answer it via attach.
195
+
196
+ Expected: the row sits under **Needs answer** with the question text as summary; after answering it returns to **RUNNING**. (U1)
197
+
198
+ If the merge has not happened yet, record U1 as `pending` — do not mark it passed.