@zhuxixi/pi-agent-board 0.13.0 → 0.14.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 +65 -0
- package/README.md +37 -12
- package/docs/SECTION_FOLDING.md +53 -0
- package/docs/superpowers/plans/2026-10-23-issue-222-attach-ready.md +290 -0
- package/docs/superpowers/plans/2026-10-26-issue-245-key-hints-doc-sync.md +244 -0
- package/docs/superpowers/plans/2026-10-27-issue-172-fullscreen-selection-clear.md +344 -0
- package/docs/superpowers/plans/2026-10-27-issue-252-select-key-hints.md +209 -0
- package/docs/superpowers/plans/2026-10-28-issue-255-coordinator-endpoint-zombie.md +442 -0
- package/docs/superpowers/plans/2026-10-28-issue-257-legacy-pty-runner-endpoint-cleanup.md +256 -0
- package/docs/superpowers/plans/2026-11-03-cwd-favorites-full-pool.md +266 -0
- package/docs/superpowers/plans/2026-11-03-issue-266-alt-h-detach.md +467 -0
- package/docs/superpowers/plans/2026-11-04-issue-270-scenario-stdout-flush.md +584 -0
- package/docs/superpowers/plans/2026-11-05-issue-278-ctrl-g-external-editor.md +381 -0
- package/docs/superpowers/plans/2026-11-06-issue-280-frame-witness-delivery.md +430 -0
- package/docs/superpowers/plans/2026-11-07-issue-284-attach-recovery.md +115 -0
- package/docs/superpowers/plans/2026-11-07-issue-284-u1-u2-trial-guide.md +39 -0
- package/docs/superpowers/plans/2026-11-08-host-restart-model-override.md +894 -0
- package/docs/superpowers/plans/2026-11-08-issue-288-cap-floor.md +51 -0
- package/docs/superpowers/plans/2026-11-09-dashboard-fold-flake.md +166 -0
- package/docs/superpowers/plans/2026-11-09-issue-273-harness-console-log-exit.md +369 -0
- package/docs/superpowers/plans/2026-11-10-issue-258-board-selection-settle.md +760 -0
- package/docs/superpowers/plans/2026-11-13-issue-294-snapshot-resize-intent.md +590 -0
- package/docs/superpowers/plans/2026-11-16-greeting-title-poll.md +838 -0
- package/docs/superpowers/plans/2026-11-22-issue-297-compaction-mirror.md +797 -0
- package/docs/superpowers/plans/2026-11-23-issue-254-cursor-keep-position.md +663 -0
- package/docs/superpowers/plans/2026-11-23-issue-95-legacy-quarantine.md +320 -0
- package/docs/superpowers/specs/2026-10-23-issue-222-attach-ready-design.md +204 -0
- package/docs/superpowers/specs/2026-10-26-issue-245-key-hints-doc-sync-design.md +72 -0
- package/docs/superpowers/specs/2026-10-27-issue-172-fullscreen-selection-clear-design.md +248 -0
- package/docs/superpowers/specs/2026-10-27-issue-252-select-key-hints-design.md +95 -0
- package/docs/superpowers/specs/2026-10-28-issue-255-coordinator-endpoint-zombie-design.md +380 -0
- package/docs/superpowers/specs/2026-10-28-issue-257-legacy-pty-runner-endpoint-cleanup-design.md +197 -0
- package/docs/superpowers/specs/2026-11-03-cwd-favorites-full-pool-design.md +106 -0
- package/docs/superpowers/specs/2026-11-03-issue-266-alt-h-detach-design.md +185 -0
- package/docs/superpowers/specs/2026-11-04-issue-270-scenario-stdout-flush-design.md +176 -0
- package/docs/superpowers/specs/2026-11-05-issue-278-ctrl-g-external-editor-design.md +185 -0
- package/docs/superpowers/specs/2026-11-07-issue-284-attach-recovery-design.md +166 -0
- package/docs/superpowers/specs/2026-11-08-host-restart-model-override-design.md +115 -0
- package/docs/superpowers/specs/2026-11-08-issue-288-cap-floor-design.md +86 -0
- package/docs/superpowers/specs/2026-11-09-dashboard-fold-flake-design.md +109 -0
- package/docs/superpowers/specs/2026-11-09-issue-273-harness-console-log-exit-design.md +182 -0
- package/docs/superpowers/specs/2026-11-10-issue-258-board-selection-settle-design.md +109 -0
- package/docs/superpowers/specs/2026-11-13-issue-294-snapshot-resize-intent-design.md +141 -0
- package/docs/superpowers/specs/2026-11-16-greeting-title-poll-design.md +174 -0
- package/docs/superpowers/specs/2026-11-22-issue-297-compaction-mirror-design.md +158 -0
- package/docs/superpowers/specs/2026-11-22-issue-95-legacy-quarantine-design.md +209 -0
- package/docs/superpowers/specs/2026-11-23-issue-254-cursor-keep-position-design.md +201 -0
- package/package.json +1 -1
- package/runner/pty-runner.mjs +526 -63
- package/runner/state-coordinator.mjs +62 -5
- package/runner/title-runner.mjs +33 -24
- package/src/commands/agent-board.ts +5 -1
- package/src/core/attach-detach.mjs +27 -0
- package/src/core/attach-frame-proof.mjs +897 -0
- package/src/core/attach-frame-reporter.mjs +738 -0
- package/src/core/attach-frame-stream.mjs +266 -0
- package/src/core/attach-pr-label.mjs +12 -0
- package/src/core/attach-recovery.mjs +239 -0
- package/src/core/attach-screen-owner.mjs +55 -0
- package/src/core/attach-view-proof.mjs +709 -0
- package/src/core/auto-state.mjs +6 -1
- package/src/core/cwd-stats.mjs +3 -1
- package/src/core/dashboard-prefs.mjs +31 -0
- package/src/core/derive.mjs +8 -1
- package/src/core/events.mjs +127 -1
- package/src/core/foreground-projection-cache.mjs +1 -0
- package/src/core/frame-witness-update.mjs +35 -0
- package/src/core/fullscreen-selection.mjs +60 -0
- package/src/core/host-coordination.mjs +48 -0
- package/src/core/host-protocol.mjs +13 -2
- package/src/core/hosted-frame-witness.mjs +60 -0
- package/src/core/paths.mjs +10 -3
- package/src/core/pty-attach-render.mjs +239 -0
- package/src/core/pty-kitty-images.mjs +237 -0
- package/src/core/pty-scroll.mjs +8 -8
- package/src/core/rows.mjs +43 -7
- package/src/core/session-entries.mjs +82 -0
- package/src/core/session-launch-prefs.mjs +45 -0
- package/src/core/session-view.mjs +3 -63
- package/src/core/store.mjs +1 -0
- package/src/core/terminal-attach-client.mjs +199 -20
- package/src/core/terminal-attach-protocol.mjs +221 -7
- package/src/core/terminal-model.mjs +24 -3
- package/src/core/terminal-snapshot.mjs +10 -0
- package/src/core/title-flow.mjs +66 -0
- package/src/core/title.mjs +101 -0
- package/src/core/types.mjs +17 -0
- package/src/index.ts +85 -0
- package/src/runtime/service.mjs +87 -18
- package/src/ui/dashboard.ts +206 -49
- package/src/ui/pty-attach.ts +1472 -99
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
repairJournalTail,
|
|
55
55
|
writeCheckpoint,
|
|
56
56
|
} from "../src/core/coordinator-journal.mjs";
|
|
57
|
-
import {
|
|
57
|
+
import { classifyEndpointHealth, shouldUnlinkEndpoint, socketIdentityObservation } from "../src/core/host-coordination.mjs";
|
|
58
58
|
import { appendDiagnostic } from "../src/core/diagnostics.mjs";
|
|
59
59
|
import { acquireOwnedViewLock, describeLeaseConflict, heartbeatFailureAction, withViewLockSync } from "../src/core/locks.mjs";
|
|
60
60
|
import { captureStartToken } from "../src/core/pid.mjs";
|
|
@@ -303,6 +303,10 @@ async function main() {
|
|
|
303
303
|
}
|
|
304
304
|
/** {dev,ino} recorded at bind time; cleanup unlinks only this exact inode. */
|
|
305
305
|
let boundSocketIdentity = null;
|
|
306
|
+
/** Set by the supervised tick when the bound endpoint is gone or replaced:
|
|
307
|
+
* shutdown must then leave the path alone even while the lease still looks
|
|
308
|
+
* ours (issue #255). */
|
|
309
|
+
let endpointCompromised = false;
|
|
306
310
|
|
|
307
311
|
const server = createServer((socket) => {
|
|
308
312
|
let buffer = "";
|
|
@@ -335,7 +339,11 @@ async function main() {
|
|
|
335
339
|
try {
|
|
336
340
|
const st = statSync(socketPath);
|
|
337
341
|
boundSocketIdentity = { dev: st.dev, ino: st.ino };
|
|
338
|
-
} catch {
|
|
342
|
+
} catch (err) {
|
|
343
|
+
// Without the bind identity both endpoint cleanup and self-supervision
|
|
344
|
+
// degrade to a no-op; say so instead of failing silently (issue #255).
|
|
345
|
+
process.stderr.write(`state-coordinator: endpoint identity unavailable (${err instanceof Error ? err.message : String(err)}); self-supervision disabled\n`);
|
|
346
|
+
}
|
|
339
347
|
}
|
|
340
348
|
// Supervision starts only after the endpoint is bound (issue #224 D4):
|
|
341
349
|
// a live-but-stuck holder must step down before its lease can be
|
|
@@ -374,6 +382,28 @@ async function main() {
|
|
|
374
382
|
shutdown(0);
|
|
375
383
|
return;
|
|
376
384
|
}
|
|
385
|
+
// Self-supervise the endpoint (issue #255): a lease holder whose socket
|
|
386
|
+
// vanished or was replaced serves nobody — every client write fails with
|
|
387
|
+
// ENOENT while its fresh heartbeat keeps replacement coordinators losing
|
|
388
|
+
// the lease race. Step down so the next ensureCoordinator() binds a fresh
|
|
389
|
+
// endpoint. MUST stay after the root guard: a diagnostic append for a
|
|
390
|
+
// deleted root would recreate the directory skeleton (#241). `unknown`
|
|
391
|
+
// (transient stat error, or no bound identity) never steps a holder down.
|
|
392
|
+
// Short-circuit on the bound identity: without it (win32 named pipe, or a
|
|
393
|
+
// failed bind-time stat) there is nothing to compare against, and skipping
|
|
394
|
+
// the stat also avoids win32's non-trivial pipe stat side effects.
|
|
395
|
+
const endpointState = boundSocketIdentity
|
|
396
|
+
? classifyEndpointHealth(boundSocketIdentity, statSocketObservation(socketPath))
|
|
397
|
+
: "unknown";
|
|
398
|
+
if (endpointState === "missing" || endpointState === "replaced") {
|
|
399
|
+
endpointCompromised = true; // veto endpoint cleanup in shutdown (R1)
|
|
400
|
+
try {
|
|
401
|
+
appendCoordinatorDiagnostic("coordinator_endpoint_lost", { state: endpointState }, "warn");
|
|
402
|
+
} catch { /* a failing diagnostic must not block the step-down (#224 D4) */ }
|
|
403
|
+
process.stderr.write(`state-coordinator: endpoint ${endpointState} (${socketPath}); stepping down\n`);
|
|
404
|
+
shutdown(0);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
377
407
|
let ok;
|
|
378
408
|
try {
|
|
379
409
|
ok = process.env.AGENT_BOARD_TEST_FORCE_TOUCH_FAILURE === "1" ? false : lease.touch();
|
|
@@ -403,15 +433,42 @@ async function main() {
|
|
|
403
433
|
process.on("SIGTERM", () => shutdown(0));
|
|
404
434
|
process.on("SIGINT", () => shutdown(0));
|
|
405
435
|
|
|
436
|
+
/** One stat attempt, classified into the supervised observation discriminator.
|
|
437
|
+
* A transient access error is `unknown`, never `missing`/`replaced` (issue #255). */
|
|
438
|
+
function statSocketObservation(path) {
|
|
439
|
+
let stat = null;
|
|
440
|
+
let errorCode = null;
|
|
441
|
+
try {
|
|
442
|
+
stat = statSync(path);
|
|
443
|
+
} catch (err) {
|
|
444
|
+
errorCode = /** @type {NodeJS.ErrnoException} */ (err)?.code ?? "UNKNOWN";
|
|
445
|
+
}
|
|
446
|
+
return socketIdentityObservation(stat, errorCode);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/** Lease ownership at cleanup time; a read failure fails closed (no unlink). */
|
|
450
|
+
function safeIsOwner() {
|
|
451
|
+
try { return lease.isOwner(); } catch { return false; }
|
|
452
|
+
}
|
|
453
|
+
|
|
406
454
|
function shutdown(code) {
|
|
407
455
|
if (shuttingDown) return;
|
|
408
456
|
shuttingDown = true;
|
|
409
457
|
try { clearInterval(heartbeatTimer); } catch { /* best effort */ }
|
|
410
|
-
|
|
411
|
-
|
|
458
|
+
// Do NOT call server.close() (issue #255, nodejs/node#19729): libuv unlinks the
|
|
459
|
+
// unix-socket bind path when the handle closes, so a deposed coordinator closing
|
|
460
|
+
// after a successor bound would delete the successor's endpoint. The process is
|
|
461
|
+
// exiting anyway, and process.exit() skips the uv handle cleanup, so the implicit
|
|
462
|
+
// unlink never runs. Cleanup is explicit and ownership-gated below — the #70
|
|
463
|
+
// contract: unlink only while this instance still holds the lease AND the path
|
|
464
|
+
// still carries the inode it bound.
|
|
465
|
+
// `endpointCompromised` (set by the supervised tick) vetoes that explicit unlink
|
|
466
|
+
// as well; it is defence in depth on top of the dev+ino comparison.
|
|
467
|
+
const stillOwner = safeIsOwner();
|
|
468
|
+
if (process.platform !== "win32" && stillOwner && !endpointCompromised && boundSocketIdentity) {
|
|
412
469
|
try {
|
|
413
470
|
const st = statSync(socketPath);
|
|
414
|
-
if (
|
|
471
|
+
if (shouldUnlinkEndpoint({ stillOwner, compromised: endpointCompromised, bound: boundSocketIdentity, current: { dev: st.dev, ino: st.ino } })) {
|
|
415
472
|
try { unlinkSync(socketPath); } catch { /* best effort */ }
|
|
416
473
|
}
|
|
417
474
|
} catch { /* path gone — nothing to clean */ }
|
package/runner/title-runner.mjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* Detached title-runner shim
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Detached title-runner shim (issue #295): non-greeting prompts generate a
|
|
4
|
+
* title immediately (previous behavior); greeting prompts poll the session
|
|
5
|
+
* file for the first substantive user message. Best-effort only — the manual
|
|
6
|
+
* rename always wins. All orchestration lives in src/core/title-flow.mjs.
|
|
7
7
|
*/
|
|
8
8
|
import { spawn } from "node:child_process";
|
|
9
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
9
10
|
import { readJson } from "../src/core/atomic.mjs";
|
|
10
11
|
import { readMeta, writeMeta } from "../src/core/store.mjs";
|
|
11
|
-
import {
|
|
12
|
+
import { runTitleFlow } from "../src/core/title-flow.mjs";
|
|
13
|
+
import { resolveTitleSettings, titlePrompt } from "../src/core/title.mjs";
|
|
12
14
|
|
|
13
15
|
function main() {
|
|
14
16
|
const configPath = process.argv[2];
|
|
@@ -17,29 +19,36 @@ function main() {
|
|
|
17
19
|
const config = readJson(configPath, null);
|
|
18
20
|
if (!config?.viewId || !config.prompt) process.exit(2);
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
const settings = resolveTitleSettings(process.env, config.model);
|
|
23
|
+
if (!settings.enabled) return;
|
|
24
|
+
|
|
25
|
+
runTitleFlow(config, realDeps(config, settings))
|
|
21
26
|
.catch(() => {})
|
|
22
27
|
.finally(() => process.exit(0));
|
|
23
28
|
}
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
/**
|
|
31
|
+
* @param {import("../src/core/types.mjs").TitleConfig} config
|
|
32
|
+
* @param {{ enabled: boolean, model: string, thinking: string }} settings
|
|
33
|
+
*/
|
|
34
|
+
function realDeps(config, settings) {
|
|
35
|
+
return {
|
|
36
|
+
now: () => Date.now(),
|
|
37
|
+
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
38
|
+
readMeta: (root, viewId) => readMeta(root, viewId),
|
|
39
|
+
commitMeta: (meta) => writeMeta(config.root, meta),
|
|
40
|
+
readSessionText: () => {
|
|
41
|
+
const meta = readMeta(config.root, config.viewId);
|
|
42
|
+
if (!meta?.sessionFile) return null;
|
|
43
|
+
return existsSync(meta.sessionFile) ? readFileSync(meta.sessionFile, "utf8") : null;
|
|
44
|
+
},
|
|
45
|
+
runOneShot: (prompt) => {
|
|
46
|
+
const args = [...(config.piArgsPrefix ?? []), "--mode", "json", "-p", "--no-session", "--model", settings.model];
|
|
47
|
+
if (settings.thinking && settings.thinking !== "off") args.push("--thinking", settings.thinking);
|
|
48
|
+
args.push(titlePrompt(prompt));
|
|
49
|
+
return runOneShot(config.piCommand, args, 15000);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
43
52
|
}
|
|
44
53
|
|
|
45
54
|
function runOneShot(command, args, timeoutMs = 20000) {
|
|
@@ -15,6 +15,7 @@ import { screenLogPath } from "../core/paths.mjs";
|
|
|
15
15
|
import { appendDiagnostic } from "../core/diagnostics.mjs";
|
|
16
16
|
import { DashboardComponent, type DashboardResult } from "../ui/dashboard.ts";
|
|
17
17
|
import { PtyAttachComponent, type PtyAttachResult } from "../ui/pty-attach.ts";
|
|
18
|
+
import { attachPrLabel } from "../core/attach-pr-label.mjs";
|
|
18
19
|
|
|
19
20
|
const POLL_MS = 700;
|
|
20
21
|
|
|
@@ -199,7 +200,8 @@ async function attach(
|
|
|
199
200
|
const plan = planAttachResolved(await service.resolveAttachTarget(viewId));
|
|
200
201
|
if (plan.plan === "open-pty") {
|
|
201
202
|
void service.markVisited?.(viewId)?.catch(() => {});
|
|
202
|
-
const
|
|
203
|
+
const latest = service.row(viewId) ?? row;
|
|
204
|
+
const result = await openPtyAttach(ctx, root, row.meta.id, row.meta.name, plan.socketPath, attachPrLabel(latest.codeRefs));
|
|
203
205
|
void service.markVisited?.(viewId)?.catch(() => {});
|
|
204
206
|
if (result.action === "delete") {
|
|
205
207
|
// Issue #147: the component already tore down and exited — archive
|
|
@@ -254,6 +256,7 @@ async function openPtyAttach(
|
|
|
254
256
|
viewId: string,
|
|
255
257
|
name: string,
|
|
256
258
|
socketPath: string,
|
|
259
|
+
prLabel: string,
|
|
257
260
|
): Promise<PtyAttachResult> {
|
|
258
261
|
ctx.ui.setWorkingVisible(false);
|
|
259
262
|
ctx.ui.setHeader(() => ({ render: () => [], invalidate() {} }));
|
|
@@ -266,6 +269,7 @@ async function openPtyAttach(
|
|
|
266
269
|
socketPath,
|
|
267
270
|
screenLogPath: root ? screenLogPath(root, viewId) : undefined,
|
|
268
271
|
title: name,
|
|
272
|
+
prLabel,
|
|
269
273
|
onDiagnostic: root
|
|
270
274
|
? (event) => {
|
|
271
275
|
// Best effort, like every other diagnostics writer.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Key, matchesKey } from "@earendil-works/pi-tui";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Issue #266: the attach view's unconditional detach chords. Pure — no
|
|
5
|
+
* component state, no socket, no editor cache: a chord is exit intent or it is
|
|
6
|
+
* forwarded. Callers must run the #147 delete-confirm resolver first, so an
|
|
7
|
+
* armed confirm still cancels before the chord closes the surface.
|
|
8
|
+
*
|
|
9
|
+
* - `ctrl+\` (raw 0x1c) — the terminal-independent escape (issue #126): one raw
|
|
10
|
+
* ASCII byte every terminal forwards unchanged in raw mode; the kitty CSI-u
|
|
11
|
+
* and modifyOtherKeys encodings of the same chord match too.
|
|
12
|
+
* - `ctrl+left` — unambiguous intent while a draft sits in the editor
|
|
13
|
+
* (issue #89); a single ← stays gated on the pushed editorEmpty channel.
|
|
14
|
+
* - `alt+h` — vim's h is "left" (issue #266). The bare letter must keep
|
|
15
|
+
* reaching the child editor, so the chord is the modified key; a segment
|
|
16
|
+
* that coalesces the chord with other bytes does not match and is forwarded
|
|
17
|
+
* unchanged.
|
|
18
|
+
* @param {string} data one key segment from splitAttachInput
|
|
19
|
+
* @returns {boolean}
|
|
20
|
+
*/
|
|
21
|
+
export function resolveAttachDetachChord(data) {
|
|
22
|
+
return (
|
|
23
|
+
matchesKey(data, "ctrl+\\") ||
|
|
24
|
+
matchesKey(data, Key.ctrl("left")) ||
|
|
25
|
+
matchesKey(data, Key.alt("h"))
|
|
26
|
+
);
|
|
27
|
+
}
|