@huseynsnmz/pi-suite 0.0.0-stage → 0.1.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 (219) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE +21 -0
  3. package/README.md +87 -2
  4. package/SECURITY.md +5 -0
  5. package/package.json +113 -4
  6. package/packages/board/CHANGELOG.md +340 -0
  7. package/packages/board/CONTRIBUTING.md +7 -0
  8. package/packages/board/LICENSE +21 -0
  9. package/packages/board/README.md +88 -0
  10. package/packages/board/SECURITY.md +19 -0
  11. package/packages/board/docs/how-it-works.md +31 -0
  12. package/packages/board/docs/reference.md +278 -0
  13. package/packages/board/package.json +83 -0
  14. package/packages/board/runner/job-runner-legacy.mjs +68 -0
  15. package/packages/board/runner/job-runner.mjs +834 -0
  16. package/packages/board/runner/pty-runner-legacy.mjs +50 -0
  17. package/packages/board/runner/pty-runner.mjs +2175 -0
  18. package/packages/board/runner/state-coordinator.mjs +673 -0
  19. package/packages/board/runner/state-runner.mjs +203 -0
  20. package/packages/board/runner/title-runner.mjs +80 -0
  21. package/packages/board/src/commands/agent-board.ts +394 -0
  22. package/packages/board/src/commands/attach-decision.mjs +66 -0
  23. package/packages/board/src/commands/attach-flow.ts +251 -0
  24. package/packages/board/src/commands/bg.ts +103 -0
  25. package/packages/board/src/commands/board-model.ts +21 -0
  26. package/packages/board/src/core/atomic.mjs +184 -0
  27. package/packages/board/src/core/attach-delete.mjs +24 -0
  28. package/packages/board/src/core/attach-frame-proof.mjs +870 -0
  29. package/packages/board/src/core/attach-frame-reporter.mjs +648 -0
  30. package/packages/board/src/core/attach-frame-stream.mjs +266 -0
  31. package/packages/board/src/core/attach-view-proof.mjs +709 -0
  32. package/packages/board/src/core/auto-state.mjs +377 -0
  33. package/packages/board/src/core/background-runs.mjs +273 -0
  34. package/packages/board/src/core/code-refs-store.mjs +315 -0
  35. package/packages/board/src/core/code-refs.mjs +913 -0
  36. package/packages/board/src/core/config.mjs +77 -0
  37. package/packages/board/src/core/control-protocol.mjs +482 -0
  38. package/packages/board/src/core/coordinator-client.mjs +633 -0
  39. package/packages/board/src/core/coordinator-journal.mjs +282 -0
  40. package/packages/board/src/core/coordinator-protocol.mjs +14 -0
  41. package/packages/board/src/core/cwd-stats.mjs +114 -0
  42. package/packages/board/src/core/dashboard-render.mjs +10 -0
  43. package/packages/board/src/core/derive.mjs +117 -0
  44. package/packages/board/src/core/diagnostics.mjs +133 -0
  45. package/packages/board/src/core/double-press.mjs +26 -0
  46. package/packages/board/src/core/editor-state-reporter.mjs +112 -0
  47. package/packages/board/src/core/events.mjs +286 -0
  48. package/packages/board/src/core/evidence.mjs +245 -0
  49. package/packages/board/src/core/follow-up-queue.mjs +211 -0
  50. package/packages/board/src/core/foreground-preview-cache.mjs +117 -0
  51. package/packages/board/src/core/foreground-projection-cache.mjs +99 -0
  52. package/packages/board/src/core/frame-witness-update.mjs +35 -0
  53. package/packages/board/src/core/heuristics.mjs +313 -0
  54. package/packages/board/src/core/hold-input.mjs +27 -0
  55. package/packages/board/src/core/host-coordination.mjs +300 -0
  56. package/packages/board/src/core/host-crash.mjs +79 -0
  57. package/packages/board/src/core/host-probe.mjs +207 -0
  58. package/packages/board/src/core/host-protocol.mjs +73 -0
  59. package/packages/board/src/core/ids.mjs +35 -0
  60. package/packages/board/src/core/ime-cursor-coalesce.mjs +193 -0
  61. package/packages/board/src/core/invocation.mjs +43 -0
  62. package/packages/board/src/core/launch-options.mjs +418 -0
  63. package/packages/board/src/core/launch.mjs +157 -0
  64. package/packages/board/src/core/load-config.mjs +4 -0
  65. package/packages/board/src/core/locks.mjs +530 -0
  66. package/packages/board/src/core/paths.mjs +183 -0
  67. package/packages/board/src/core/pid.mjs +75 -0
  68. package/packages/board/src/core/prewarm-schedule.mjs +41 -0
  69. package/packages/board/src/core/process-identity-probe.mjs +228 -0
  70. package/packages/board/src/core/prompt-transport.mjs +13 -0
  71. package/packages/board/src/core/pty-attach-jiggle-controller.mjs +356 -0
  72. package/packages/board/src/core/pty-attach-jiggle-retry.mjs +109 -0
  73. package/packages/board/src/core/pty-attach-reconnect.mjs +61 -0
  74. package/packages/board/src/core/pty-attach-render.mjs +229 -0
  75. package/packages/board/src/core/pty-links.mjs +81 -0
  76. package/packages/board/src/core/pty-scroll.mjs +522 -0
  77. package/packages/board/src/core/pty-support.mjs +327 -0
  78. package/packages/board/src/core/repo.mjs +103 -0
  79. package/packages/board/src/core/rows.mjs +398 -0
  80. package/packages/board/src/core/screen-log-gc.mjs +198 -0
  81. package/packages/board/src/core/screen-log.mjs +160 -0
  82. package/packages/board/src/core/session-view.mjs +174 -0
  83. package/packages/board/src/core/slash-commands.mjs +52 -0
  84. package/packages/board/src/core/state-commands.mjs +757 -0
  85. package/packages/board/src/core/status-consistency.mjs +98 -0
  86. package/packages/board/src/core/steering-prompts.mjs +34 -0
  87. package/packages/board/src/core/steering.mjs +133 -0
  88. package/packages/board/src/core/stop-latch.mjs +41 -0
  89. package/packages/board/src/core/store.mjs +523 -0
  90. package/packages/board/src/core/suspend.mjs +36 -0
  91. package/packages/board/src/core/terminal-attach-client.mjs +981 -0
  92. package/packages/board/src/core/terminal-attach-protocol.mjs +460 -0
  93. package/packages/board/src/core/terminal-model.mjs +222 -0
  94. package/packages/board/src/core/terminal-query-sequences.mjs +239 -0
  95. package/packages/board/src/core/terminal-reply-guard.mjs +222 -0
  96. package/packages/board/src/core/terminal-snapshot.mjs +440 -0
  97. package/packages/board/src/core/test-knobs.mjs +28 -0
  98. package/packages/board/src/core/title.mjs +43 -0
  99. package/packages/board/src/core/types.mjs +414 -0
  100. package/packages/board/src/core/warm-host-sweeper.mjs +168 -0
  101. package/packages/board/src/core/worktree.mjs +65 -0
  102. package/packages/board/src/index.ts +303 -0
  103. package/packages/board/src/runtime/service.mjs +3222 -0
  104. package/packages/board/src/ui/chrome.ts +20 -0
  105. package/packages/board/src/ui/dashboard-decisions.mjs +55 -0
  106. package/packages/board/src/ui/dashboard-evidence.mjs +85 -0
  107. package/packages/board/src/ui/dashboard.ts +2221 -0
  108. package/packages/board/src/ui/double-left.ts +30 -0
  109. package/packages/board/src/ui/external-editor.ts +25 -0
  110. package/packages/board/src/ui/focus.ts +32 -0
  111. package/packages/board/src/ui/pty-attach.ts +3184 -0
  112. package/packages/board/src/ui/waiting.ts +30 -0
  113. package/packages/frame/CHANGELOG.md +113 -0
  114. package/packages/frame/CONTRIBUTING.md +7 -0
  115. package/packages/frame/LICENSE +22 -0
  116. package/packages/frame/README.md +105 -0
  117. package/packages/frame/SECURITY.md +16 -0
  118. package/packages/frame/docs/how-it-works.md +53 -0
  119. package/packages/frame/docs/reference.md +78 -0
  120. package/packages/frame/package.json +75 -0
  121. package/packages/frame/src/data/git.ts +90 -0
  122. package/packages/frame/src/data/github.ts +140 -0
  123. package/packages/frame/src/data/gitlab.ts +63 -0
  124. package/packages/frame/src/data/mode.ts +23 -0
  125. package/packages/frame/src/data/past-prompts.ts +57 -0
  126. package/packages/frame/src/data/runner.ts +32 -0
  127. package/packages/frame/src/data/snapshot.ts +223 -0
  128. package/packages/frame/src/data/start-notes.ts +104 -0
  129. package/packages/frame/src/data/telemetry.ts +337 -0
  130. package/packages/frame/src/data/todos.ts +162 -0
  131. package/packages/frame/src/data/totals.ts +94 -0
  132. package/packages/frame/src/data/visits.ts +45 -0
  133. package/packages/frame/src/index.ts +676 -0
  134. package/packages/frame/src/render/diff.ts +104 -0
  135. package/packages/frame/src/render/fit.ts +86 -0
  136. package/packages/frame/src/render/format.ts +108 -0
  137. package/packages/frame/src/render/frame.ts +106 -0
  138. package/packages/frame/src/render/glyphs.ts +189 -0
  139. package/packages/frame/src/render/keys.ts +43 -0
  140. package/packages/frame/src/render/lead.ts +37 -0
  141. package/packages/frame/src/render/paint.ts +135 -0
  142. package/packages/frame/src/render/safe.ts +19 -0
  143. package/packages/frame/src/render/segments.ts +735 -0
  144. package/packages/frame/src/render/streaming.ts +223 -0
  145. package/packages/frame/src/render/timing.ts +106 -0
  146. package/packages/frame/src/render/tools.ts +167 -0
  147. package/packages/frame/src/settings.ts +105 -0
  148. package/packages/frame/src/ui/editor.ts +272 -0
  149. package/packages/frame/src/ui/effort.ts +36 -0
  150. package/packages/frame/src/ui/footer.ts +165 -0
  151. package/packages/frame/src/ui/header.ts +362 -0
  152. package/packages/frame/src/ui/history-search.ts +23 -0
  153. package/packages/frame/src/ui/interrupt.ts +21 -0
  154. package/packages/frame/src/ui/outputs.ts +170 -0
  155. package/packages/frame/src/ui/pi-entries.ts +276 -0
  156. package/packages/frame/src/ui/previews.ts +72 -0
  157. package/packages/frame/src/ui/queue.ts +75 -0
  158. package/packages/frame/src/ui/screen.ts +59 -0
  159. package/packages/frame/src/ui/timings.ts +48 -0
  160. package/packages/frame/src/ui/todos.ts +205 -0
  161. package/packages/frame/src/ui/tool-frame.ts +595 -0
  162. package/packages/frame/src/ui/working.ts +25 -0
  163. package/packages/frame/src/view/state.ts +97 -0
  164. package/packages/frame/src/view/transcript.ts +175 -0
  165. package/packages/frame/src/view/view.ts +162 -0
  166. package/packages/memory/CONTRIBUTING.md +7 -0
  167. package/packages/memory/LICENSE +21 -0
  168. package/packages/memory/README.md +44 -0
  169. package/packages/memory/SECURITY.md +20 -0
  170. package/packages/memory/package.json +55 -0
  171. package/packages/memory/skills/review-memory/SKILL.md +48 -0
  172. package/packages/memory/src/index.ts +163 -0
  173. package/packages/memory/src/prompt.ts +25 -0
  174. package/packages/memory/src/review.ts +150 -0
  175. package/packages/memory/src/secrets.ts +22 -0
  176. package/packages/memory/src/store.ts +173 -0
  177. package/packages/modes/CHANGELOG.md +104 -0
  178. package/packages/modes/CONTRIBUTING.md +7 -0
  179. package/packages/modes/LICENSE +21 -0
  180. package/packages/modes/README.md +174 -0
  181. package/packages/modes/SECURITY.md +17 -0
  182. package/packages/modes/package.json +55 -0
  183. package/packages/modes/skills/review-permissions/SKILL.md +54 -0
  184. package/packages/modes/src/bash.ts +218 -0
  185. package/packages/modes/src/deny-off.ts +62 -0
  186. package/packages/modes/src/git-safety.ts +72 -0
  187. package/packages/modes/src/index.ts +338 -0
  188. package/packages/modes/src/interview.ts +206 -0
  189. package/packages/modes/src/judge-gate.ts +113 -0
  190. package/packages/modes/src/modes.ts +121 -0
  191. package/packages/modes/src/review/apply.mjs +156 -0
  192. package/packages/modes/src/review/collect.mjs +208 -0
  193. package/packages/modes/src/review/tools.ts +71 -0
  194. package/packages/modes/src/sandbox.ts +37 -0
  195. package/packages/router/CHANGELOG.md +8 -0
  196. package/packages/router/LICENSE +21 -0
  197. package/packages/router/README.md +90 -0
  198. package/packages/router/package.json +51 -0
  199. package/packages/router/src/config.ts +65 -0
  200. package/packages/router/src/index.ts +172 -0
  201. package/packages/router/src/judge.ts +51 -0
  202. package/packages/router/src/route.ts +67 -0
  203. package/packages/web/CHANGELOG.md +36 -0
  204. package/packages/web/LICENSE +21 -0
  205. package/packages/web/README.md +87 -0
  206. package/packages/web/SECURITY.md +13 -0
  207. package/packages/web/package.json +61 -0
  208. package/packages/web/src/config.ts +109 -0
  209. package/packages/web/src/dnsfilter.ts +97 -0
  210. package/packages/web/src/extract.ts +65 -0
  211. package/packages/web/src/index.ts +217 -0
  212. package/packages/web/src/net.ts +109 -0
  213. package/packages/web/src/reader.ts +73 -0
  214. package/packages/web/src/sanitize.ts +50 -0
  215. package/packages/web/src/search.ts +76 -0
  216. package/packages/web/src/secrets.ts +22 -0
  217. package/packages/web/src/validate.ts +186 -0
  218. package/src/index.ts +156 -0
  219. package/src/settings.ts +78 -0
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The board blanks Pi's header and footer while it is up. Pi can only hand them back as its
3
+ * defaults, so this also tells any extension that drew its own to draw them again.
4
+ */
5
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
6
+
7
+ export const BOARD_CLOSED_EVENT = "agent-board:closed";
8
+
9
+ let events: ExtensionAPI["events"] | null = null;
10
+
11
+ export function announceBoardClosedOn(bus: ExtensionAPI["events"]): void {
12
+ events = bus;
13
+ }
14
+
15
+ export function restoreChrome(ctx: Pick<ExtensionContext, "ui">): void {
16
+ ctx.ui.setHeader(undefined);
17
+ ctx.ui.setFooter(undefined);
18
+ ctx.ui.setWorkingVisible(true);
19
+ events?.emit(BOARD_CLOSED_EVENT, undefined);
20
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Dashboard decision helpers for host prewarm and attach prelude (issue #70 A14).
3
+ *
4
+ * Pure functions extracted from src/ui/dashboard.ts so the branching contract is
5
+ * node-testable without pi's TS loader (same pattern as commands/attach-decision.mjs).
6
+ * `hostActive` covers starting/alive/stopping claims from store.loadRow — pending
7
+ * claims count as an already-registered launch, so prewarm never re-spawns them.
8
+ */
9
+
10
+ /**
11
+ * Prewarm decision for the selected row.
12
+ * - "mark-only": the row has an active host claim — mark it prewarmed WITHOUT
13
+ * calling prewarmHost (a pending/starting claim is already a launch; the old
14
+ * hostAlive guard re-checked it on every debounce tick).
15
+ * - "skip": busy row without a host claim — no prewarm, no mark.
16
+ * - "prewarm": no claim — call service.prewarmHost once; the caller marks only on ok.
17
+ * @param {{ hostActive?: boolean, agentBusy?: boolean }} row
18
+ * @returns {{ action: "mark-only" | "skip" | "prewarm" }}
19
+ */
20
+ export function planPrewarm({ hostActive, agentBusy }) {
21
+ if (hostActive) return { action: "mark-only" };
22
+ if (agentBusy) return { action: "skip" };
23
+ return { action: "prewarm" };
24
+ }
25
+
26
+ /**
27
+ * Attach prelude for a dashboard row. A hostActive row attaches directly — the
28
+ * async resolver owns starting/stopping wait, so no interrupt confirmation is
29
+ * offered even when the row is busy. A busy row WITHOUT a host claim keeps the
30
+ * existing stopFirst confirm; everything else attaches directly.
31
+ * @param {{ hostActive?: boolean, agentBusy?: boolean }} row
32
+ * @returns {{ plan: "attach" | "confirm-stop-first" }}
33
+ */
34
+ export function planDashboardAttach({ hostActive, agentBusy }) {
35
+ if (!hostActive && agentBusy) return { plan: "confirm-stop-first" };
36
+ return { plan: "attach" };
37
+ }
38
+
39
+ /**
40
+ * Map a service reply() result to the dashboard notice (issue #70: queued and
41
+ * sent are different outcomes — a queued reply is durable, not yet delivered).
42
+ * Result shapes from service.reply(): {ok:false,error} | {ok:true,queued:true}
43
+ * | {ok:true,sent:true} | {ok:true,hostMode,fallbackReason?}.
44
+ * @param {{ ok?: boolean, error?: string, queued?: boolean, sent?: boolean, hostMode?: string|null, fallbackReason?: string }} res
45
+ * @returns {{ level: "info" | "warn" | "error", text: string }}
46
+ */
47
+ export function replyNotice(res) {
48
+ if (!res?.ok) return { level: "error", text: res?.error ?? "Reply failed" };
49
+ if (res.queued) return { level: "info", text: "Reply queued — will deliver when the host is ready" };
50
+ if (res.sent) return { level: "info", text: "Reply sent" };
51
+ if (res.hostMode === "json-runner") {
52
+ return { level: "warn", text: `Reply sent with non-live fallback: ${res.fallbackReason ?? "PTY unavailable"}` };
53
+ }
54
+ return { level: "info", text: "Reply sent" };
55
+ }
@@ -0,0 +1,85 @@
1
+ /** Pure evidence panel rendering helpers for dashboard evidence mode. */
2
+ import { relativeTime, truncate } from "../core/heuristics.mjs";
3
+
4
+ /**
5
+ * @param {{ row:any, evidence:any, diagnostics:any[], paths?:Record<string,string>, width:number, now?:number }} opts
6
+ * @returns {string[]}
7
+ */
8
+ export function buildEvidencePanel(opts) {
9
+ const width = opts.width ?? 80;
10
+ const now = opts.now ?? Date.now();
11
+ const evidence = opts.evidence ?? {};
12
+ const diagnostics = Array.isArray(opts.diagnostics) ? opts.diagnostics : [];
13
+ const paths = opts.paths ?? {};
14
+ const lines = [];
15
+ lines.push(`Evidence / diagnostics for ${opts.row?.meta?.name ?? "session"}`);
16
+ lines.push(`State: ${opts.row?.state?.semanticState ?? "unknown"} · Outcome: ${evidence.outcome ?? "unknown"}${evidence.ready ? " · ready" : ""}`);
17
+ if (evidence.summary) lines.push(...wrap(`Summary: ${evidence.summary}`, width));
18
+ lines.push("");
19
+ lines.push(`Changed files (${evidence.fileChanges?.length ?? 0})`);
20
+ if (evidence.fileChanges?.length) {
21
+ for (const f of evidence.fileChanges.slice(-12)) lines.push(` ${f.action ?? "changed"} ${f.path}${f.count > 1 ? ` ×${f.count}` : ""}`);
22
+ } else lines.push(" —");
23
+ lines.push("");
24
+ lines.push(`Commands (${evidence.commands?.length ?? 0})`);
25
+ if (evidence.commands?.length) {
26
+ for (const c of evidence.commands.slice(-12)) {
27
+ const status = c.status === "failed" ? "✗" : c.status === "passed" ? "✓" : c.status === "started" ? "…" : "?";
28
+ lines.push(...wrap(` ${status} [${c.kind ?? "other"}] ${c.command || "command"}`, width, 2));
29
+ if (c.outputPreview) lines.push(...wrap(` ${c.outputPreview}`, width, 2));
30
+ }
31
+ } else lines.push(" —");
32
+ lines.push("");
33
+ lines.push(`Errors (${evidence.errors?.length ?? 0})`);
34
+ if (evidence.errors?.length) {
35
+ for (const e of evidence.errors.slice(-8)) lines.push(...wrap(` ${e.source ?? "error"}: ${e.message}`, width, 2));
36
+ } else lines.push(" —");
37
+ lines.push("");
38
+ lines.push("Latest assistant evidence");
39
+ const latest = evidence.assistantEvidence?.[evidence.assistantEvidence.length - 1]?.text;
40
+ lines.push(...wrap(` ${latest || "—"}`, width, 8));
41
+ lines.push("");
42
+ lines.push(`Diagnostics (${diagnostics.length} shown)`);
43
+ if (diagnostics.length) {
44
+ for (const d of diagnostics.slice(-12)) {
45
+ const age = d.at ? relativeTime(d.at, now) : "?";
46
+ lines.push(...wrap(` ${age} ${String(d.level ?? "info").toUpperCase()} ${d.code ?? "event"}: ${d.message ?? ""}`, width, 2));
47
+ }
48
+ } else lines.push(" —");
49
+ lines.push("");
50
+ lines.push("Artifacts");
51
+ for (const [name, value] of Object.entries(paths)) {
52
+ if (value) lines.push(...wrap(` ${name}: ${value}`, width, 2));
53
+ }
54
+ if (Object.keys(paths).length === 0) lines.push(" —");
55
+ return lines.map((line) => clip(line, width));
56
+ }
57
+
58
+ /** @param {string} text @param {number} width @param {number} [maxLines] */
59
+ function wrap(text, width, maxLines = 10) {
60
+ const words = String(text ?? "").split(/\s+/);
61
+ const out = [];
62
+ let line = "";
63
+ for (const word of words) {
64
+ if (!word) continue;
65
+ const next = line ? `${line} ${word}` : word;
66
+ if (visibleLength(next) > width && line) {
67
+ out.push(line);
68
+ line = word;
69
+ } else line = next;
70
+ if (out.length >= maxLines) break;
71
+ }
72
+ if (line && out.length < maxLines) out.push(line);
73
+ if (out.length === maxLines && words.length > 0) out[out.length - 1] = truncate(out[out.length - 1], Math.max(1, width - 1));
74
+ return out.length ? out : [""];
75
+ }
76
+
77
+ /** @param {string} line @param {number} width */
78
+ function clip(line, width) {
79
+ return truncate(line, Math.max(1, width));
80
+ }
81
+
82
+ /** @param {string} s */
83
+ function visibleLength(s) {
84
+ return String(s || "").replace(/\x1b\[[0-9;]*m/g, "").length;
85
+ }