@zhuxixi/pi-agent-board 0.13.1 → 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.
Files changed (80) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +15 -8
  3. package/docs/SECTION_FOLDING.md +53 -0
  4. package/docs/superpowers/plans/2026-10-23-issue-222-attach-ready.md +290 -0
  5. package/docs/superpowers/plans/2026-10-28-issue-257-legacy-pty-runner-endpoint-cleanup.md +256 -0
  6. package/docs/superpowers/plans/2026-11-03-cwd-favorites-full-pool.md +266 -0
  7. package/docs/superpowers/plans/2026-11-03-issue-266-alt-h-detach.md +467 -0
  8. package/docs/superpowers/plans/2026-11-04-issue-270-scenario-stdout-flush.md +584 -0
  9. package/docs/superpowers/plans/2026-11-05-issue-278-ctrl-g-external-editor.md +381 -0
  10. package/docs/superpowers/plans/2026-11-06-issue-280-frame-witness-delivery.md +430 -0
  11. package/docs/superpowers/plans/2026-11-07-issue-284-attach-recovery.md +115 -0
  12. package/docs/superpowers/plans/2026-11-07-issue-284-u1-u2-trial-guide.md +39 -0
  13. package/docs/superpowers/plans/2026-11-08-host-restart-model-override.md +894 -0
  14. package/docs/superpowers/plans/2026-11-08-issue-288-cap-floor.md +51 -0
  15. package/docs/superpowers/plans/2026-11-09-dashboard-fold-flake.md +166 -0
  16. package/docs/superpowers/plans/2026-11-09-issue-273-harness-console-log-exit.md +369 -0
  17. package/docs/superpowers/plans/2026-11-10-issue-258-board-selection-settle.md +760 -0
  18. package/docs/superpowers/plans/2026-11-13-issue-294-snapshot-resize-intent.md +590 -0
  19. package/docs/superpowers/plans/2026-11-16-greeting-title-poll.md +838 -0
  20. package/docs/superpowers/plans/2026-11-22-issue-297-compaction-mirror.md +797 -0
  21. package/docs/superpowers/plans/2026-11-23-issue-254-cursor-keep-position.md +663 -0
  22. package/docs/superpowers/plans/2026-11-23-issue-95-legacy-quarantine.md +320 -0
  23. package/docs/superpowers/specs/2026-10-23-issue-222-attach-ready-design.md +204 -0
  24. package/docs/superpowers/specs/2026-10-28-issue-257-legacy-pty-runner-endpoint-cleanup-design.md +197 -0
  25. package/docs/superpowers/specs/2026-11-03-cwd-favorites-full-pool-design.md +106 -0
  26. package/docs/superpowers/specs/2026-11-03-issue-266-alt-h-detach-design.md +185 -0
  27. package/docs/superpowers/specs/2026-11-04-issue-270-scenario-stdout-flush-design.md +176 -0
  28. package/docs/superpowers/specs/2026-11-05-issue-278-ctrl-g-external-editor-design.md +185 -0
  29. package/docs/superpowers/specs/2026-11-07-issue-284-attach-recovery-design.md +166 -0
  30. package/docs/superpowers/specs/2026-11-08-host-restart-model-override-design.md +115 -0
  31. package/docs/superpowers/specs/2026-11-08-issue-288-cap-floor-design.md +86 -0
  32. package/docs/superpowers/specs/2026-11-09-dashboard-fold-flake-design.md +109 -0
  33. package/docs/superpowers/specs/2026-11-09-issue-273-harness-console-log-exit-design.md +182 -0
  34. package/docs/superpowers/specs/2026-11-10-issue-258-board-selection-settle-design.md +109 -0
  35. package/docs/superpowers/specs/2026-11-13-issue-294-snapshot-resize-intent-design.md +141 -0
  36. package/docs/superpowers/specs/2026-11-16-greeting-title-poll-design.md +174 -0
  37. package/docs/superpowers/specs/2026-11-22-issue-297-compaction-mirror-design.md +158 -0
  38. package/docs/superpowers/specs/2026-11-22-issue-95-legacy-quarantine-design.md +209 -0
  39. package/docs/superpowers/specs/2026-11-23-issue-254-cursor-keep-position-design.md +201 -0
  40. package/package.json +1 -1
  41. package/runner/pty-runner.mjs +526 -63
  42. package/runner/title-runner.mjs +33 -24
  43. package/src/commands/agent-board.ts +5 -1
  44. package/src/core/attach-detach.mjs +27 -0
  45. package/src/core/attach-frame-proof.mjs +897 -0
  46. package/src/core/attach-frame-reporter.mjs +738 -0
  47. package/src/core/attach-frame-stream.mjs +266 -0
  48. package/src/core/attach-pr-label.mjs +12 -0
  49. package/src/core/attach-recovery.mjs +239 -0
  50. package/src/core/attach-screen-owner.mjs +55 -0
  51. package/src/core/attach-view-proof.mjs +709 -0
  52. package/src/core/auto-state.mjs +6 -1
  53. package/src/core/cwd-stats.mjs +3 -1
  54. package/src/core/dashboard-prefs.mjs +31 -0
  55. package/src/core/derive.mjs +8 -1
  56. package/src/core/events.mjs +127 -1
  57. package/src/core/foreground-projection-cache.mjs +1 -0
  58. package/src/core/frame-witness-update.mjs +35 -0
  59. package/src/core/fullscreen-selection.mjs +60 -0
  60. package/src/core/host-protocol.mjs +13 -2
  61. package/src/core/hosted-frame-witness.mjs +60 -0
  62. package/src/core/paths.mjs +10 -3
  63. package/src/core/pty-attach-render.mjs +239 -0
  64. package/src/core/pty-kitty-images.mjs +237 -0
  65. package/src/core/rows.mjs +43 -7
  66. package/src/core/session-entries.mjs +82 -0
  67. package/src/core/session-launch-prefs.mjs +45 -0
  68. package/src/core/session-view.mjs +3 -63
  69. package/src/core/store.mjs +1 -0
  70. package/src/core/terminal-attach-client.mjs +199 -20
  71. package/src/core/terminal-attach-protocol.mjs +221 -7
  72. package/src/core/terminal-model.mjs +24 -3
  73. package/src/core/terminal-snapshot.mjs +10 -0
  74. package/src/core/title-flow.mjs +66 -0
  75. package/src/core/title.mjs +101 -0
  76. package/src/core/types.mjs +17 -0
  77. package/src/index.ts +85 -0
  78. package/src/runtime/service.mjs +87 -18
  79. package/src/ui/dashboard.ts +198 -44
  80. package/src/ui/pty-attach.ts +1462 -117
@@ -1,14 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Detached title-runner shim.
4
- *
5
- * Best-effort only: generates a short GPT-4o title from the initial task prompt and updates
6
- * the row's meta name if the user has not already renamed it.
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 { DEFAULT_TITLE_MODEL, DEFAULT_TITLE_THINKING_LEVEL, normalizeGeneratedTitle, titlePrompt } from "../src/core/title.mjs";
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
- maybeGenerateTitle(config)
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
- async function maybeGenerateTitle(config) {
26
- const configured = process.env.AGENT_BOARD_TITLE_MODEL ?? process.env.AGENT_VIEW_TITLE_MODEL;
27
- if (configured === "off") return;
28
- const model = config.model ?? configured ?? DEFAULT_TITLE_MODEL;
29
- const thinking = process.env.AGENT_BOARD_TITLE_THINKING_LEVEL ?? process.env.AGENT_VIEW_TITLE_THINKING_LEVEL ?? DEFAULT_TITLE_THINKING_LEVEL;
30
- const prompt = titlePrompt(config.prompt);
31
- const args = [...config.piArgsPrefix, "--mode", "json", "-p", "--no-session", "--model", model];
32
- if (thinking && thinking !== "off") args.push("--thinking", thinking);
33
- args.push(prompt);
34
- const out = await runOneShot(config.piCommand, args, 15000);
35
- const title = normalizeGeneratedTitle(out.trim().split("\n").slice(-1)[0]?.trim(), config.fallbackName);
36
- if (!title || title === config.fallbackName) return;
37
-
38
- const meta = readMeta(config.root, config.viewId);
39
- if (!meta) return;
40
- if (meta.name !== config.fallbackName) return;
41
- meta.name = title;
42
- writeMeta(config.root, meta);
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 result = await openPtyAttach(ctx, root, row.meta.id, row.meta.name, plan.socketPath);
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
+ }