pi-daddy 0.50.0 → 0.51.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 (39) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +16 -2
  3. package/dist/governance/initiative-coordinator.d.ts +5 -0
  4. package/dist/governance/initiative-coordinator.d.ts.map +1 -1
  5. package/dist/governance/initiative-coordinator.js +16 -0
  6. package/dist/governance/initiative-coordinator.js.map +1 -1
  7. package/dist/products/dashboard-cli.d.ts.map +1 -1
  8. package/dist/products/dashboard-cli.js +9 -1
  9. package/dist/products/dashboard-cli.js.map +1 -1
  10. package/dist/products/dashboard-display-controls.d.ts.map +1 -1
  11. package/dist/products/dashboard-display-controls.js +43 -3
  12. package/dist/products/dashboard-display-controls.js.map +1 -1
  13. package/dist/products/dashboard-layout.d.ts +6 -0
  14. package/dist/products/dashboard-layout.d.ts.map +1 -0
  15. package/dist/products/dashboard-layout.js +45 -0
  16. package/dist/products/dashboard-layout.js.map +1 -0
  17. package/dist/products/dashboard-panels.d.ts +4 -0
  18. package/dist/products/dashboard-panels.d.ts.map +1 -1
  19. package/dist/products/dashboard-panels.js +220 -80
  20. package/dist/products/dashboard-panels.js.map +1 -1
  21. package/dist/products/dashboard-recap.d.ts +4 -0
  22. package/dist/products/dashboard-recap.d.ts.map +1 -0
  23. package/dist/products/dashboard-recap.js +47 -0
  24. package/dist/products/dashboard-recap.js.map +1 -0
  25. package/dist/products/dashboard-screen.d.ts +6 -1
  26. package/dist/products/dashboard-screen.d.ts.map +1 -1
  27. package/dist/products/dashboard-screen.js +151 -45
  28. package/dist/products/dashboard-screen.js.map +1 -1
  29. package/extensions/delegation-artifacts.ts +8 -0
  30. package/extensions/initiative-handoff.ts +59 -0
  31. package/extensions/initiative-runtime.ts +39 -1
  32. package/package.json +1 -1
  33. package/src/governance/initiative-coordinator.ts +16 -0
  34. package/src/products/dashboard-cli.ts +9 -1
  35. package/src/products/dashboard-display-controls.ts +37 -3
  36. package/src/products/dashboard-layout.ts +50 -0
  37. package/src/products/dashboard-panels.ts +261 -99
  38. package/src/products/dashboard-recap.ts +48 -0
  39. package/src/products/dashboard-screen.ts +181 -48
@@ -1,4 +1,12 @@
1
- import { sessionDashboardItems, sessionPanelLines, type DashboardDestination } from "./dashboard-panels.ts";
1
+ import {
2
+ sessionDashboardItems,
3
+ sessionNextLines,
4
+ sessionPanelLines,
5
+ DASHBOARD_DESTINATIONS,
6
+ type DashboardDestination,
7
+ } from "./dashboard-panels.ts";
8
+ import { sessionRecapLines } from "./dashboard-recap.ts";
9
+ import { colorSessionLine, previewWidth, sectionHeading } from "./dashboard-layout.ts";
2
10
  import { dashboardSettingsLines, type DashboardSettingKey } from "./dashboard-settings.ts";
3
11
  /** Height-bounded, task-first view. Permission state is always supplied by the owner. */
4
12
  import type { EcosystemVersionRow } from "./ecosystem-versions.ts";
@@ -13,6 +21,8 @@ export interface DashboardItem {
13
21
  status: string;
14
22
  elapsed: string;
15
23
  details: string[];
24
+ briefDetails?: string[];
25
+ reviewSummary?: boolean;
16
26
  observation?: string;
17
27
  taskKey?: string;
18
28
  timelinePath?: string;
@@ -21,9 +31,10 @@ export interface DashboardItem {
21
31
  agent?: boolean;
22
32
  }
23
33
  export interface DashboardScreenState {
24
- view: "main" | "details" | "models" | "help" | "versions" | "version-details" | "settings";
34
+ view: "main" | "details" | "models" | "help" | "versions" | "version-details" | "settings" | "recap";
25
35
  destination?: DashboardDestination;
26
36
  expanded?: boolean;
37
+ sourceDetails?: boolean;
27
38
  manualScroll?: boolean;
28
39
  selections?: Record<string, string>;
29
40
  settingKey?: DashboardSettingKey;
@@ -40,11 +51,13 @@ export const dashboardText = (value: string) =>
40
51
  .replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "")
41
52
  .replace(/[\p{Cc}\p{Cf}]/gu, " ");
42
53
  const clean = (value: string) => dashboardText(value).replace(/\s+/g, " ").trim();
43
- function wrapped(lines: string[], width: number): string[] {
54
+ export function wrapDashboardLines(lines: string[], width: number): string[] {
44
55
  return lines.flatMap((line) => {
56
+ const safe = dashboardText(line);
57
+ if (cellWidth(safe) <= width) return [safe];
45
58
  const result: string[] = [];
46
59
  let row = "";
47
- for (const word of dashboardText(line).split(/\s+/)) {
60
+ for (const word of safe.split(/\s+/)) {
48
61
  if (row && cellWidth(row + " " + word) > width) {
49
62
  result.push(row);
50
63
  row = "";
@@ -71,13 +84,21 @@ function elapsed(ms: number): string {
71
84
  ? `${Math.floor(minutes / 60)}:${String(minutes % 60).padStart(2, "0")}:${String(seconds % 60).padStart(2, "0")}`
72
85
  : `${minutes}:${String(seconds % 60).padStart(2, "0")}`;
73
86
  }
74
- const friendlyStatus = (status: string) =>
87
+ export const friendlyStatus = (status: string) =>
75
88
  ({
76
89
  active: "Running",
77
90
  running: "Running",
78
91
  starting: "Starting",
79
- authorised: "Approved",
92
+ authorised: "Authorized",
93
+ observed: "Reported",
94
+ "cancel-requested": "Cancel requested",
95
+ unknown: "Unknown",
96
+ unavailable: "Unavailable",
80
97
  "needs-you": "Needs you",
98
+ "approval-wait": "Awaiting decision",
99
+ "dependency-wait": "Waiting on dependency",
100
+ "last-observed": "Last seen",
101
+ settled: "Finished",
81
102
  completed: "Finished",
82
103
  finished: "Finished",
83
104
  failed: "Failed",
@@ -175,13 +196,49 @@ export interface DashboardScreenOptions {
175
196
  acknowledgment?: string;
176
197
  now?: Date;
177
198
  }
199
+ function sessionLocation(screen: DashboardScreenState, width: number): string {
200
+ const destination = screen.destination ?? "now";
201
+ const overlays = {
202
+ details: "Details",
203
+ models: "Models",
204
+ help: "Help",
205
+ versions: "Versions",
206
+ "version-details": "Version details",
207
+ recap: "Session recap",
208
+ };
209
+ if (screen.view in overlays)
210
+ return `${destination.toUpperCase()} / ${overlays[screen.view as keyof typeof overlays]}`;
211
+ if (width < 74)
212
+ return width >= 37 && destination === "now"
213
+ ? "NOW · 2 Work · 3 Reviews"
214
+ : `${destination.toUpperCase()} · 1–6 views`;
215
+ return DASHBOARD_DESTINATIONS.map((view, i) =>
216
+ view === destination ? `[${i + 1} ${view.toUpperCase()}]` : `${i + 1} ${view[0]!.toUpperCase()}${view.slice(1)}`,
217
+ ).join(" ");
218
+ }
219
+
220
+ function sessionKeys(screen: DashboardScreenState, selected: DashboardItem | undefined, width: number): string[] {
221
+ const view = screen.view;
222
+ const brief = width < 34;
223
+ if (view === "main") {
224
+ const keys = selected ? (brief ? "↑↓ · Enter details" : "↑↓ select · Enter details") : "1–6 views";
225
+ return [keys + (brief ? " · ?" : " · ? help"), "r recap · q close"];
226
+ }
227
+ if (view === "versions" || view === "settings")
228
+ return [view === "settings" ? "↑↓ select · Enter edit" : "↑↓ select · Enter details", "Esc back · ? help"];
229
+ return [
230
+ brief ? "↑↓ scroll · Esc back" : "↑↓ scroll · Esc back · q close",
231
+ ...(view === "details" && selected?.taskKey ? ["p prompt · f final · ? help"] : []),
232
+ ...(view === "details" && selected?.briefDetails ? [screen.sourceDetails ? "x hide source" : "x show source"] : []),
233
+ ];
234
+ }
178
235
  /** Selection follows stable identity through refresh, never an unrelated task at the old row index. */
179
236
  export function renderDashboardScreen(options: DashboardScreenOptions): string {
180
237
  const width = Math.max(1, Math.floor(options.width)),
181
238
  height = Math.max(1, Math.floor(options.height));
182
239
  const { screen, session } = options,
183
240
  pending = session?.pendingApprovals ?? [];
184
- const approvals: DashboardItem[] = pending.map((approval) => ({
241
+ const approvals: DashboardItem[] = (options.connected === false ? [] : pending).map((approval) => ({
185
242
  key: `approval:${approval.id}`,
186
243
  label: `${approval.subject} · ${approval.capability.replace(/^tool:/, "")}`,
187
244
  status: "needs-you",
@@ -192,7 +249,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
192
249
  `Subject: ${approval.subject}`,
193
250
  `Capability: ${approval.capability}`,
194
251
  "Waiting for Daddy permission in the owner session.",
195
- "Use the owner's prompt, or a to enable Auto.",
252
+ "Respond to the permission request in the parent Pi session.",
196
253
  ],
197
254
  }));
198
255
  const modern = Boolean(session?.observation);
@@ -217,7 +274,11 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
217
274
  const detail = items.find((item) => item.key === screen.selectedKey);
218
275
  if (detail) screen.items.push(detail);
219
276
  }
220
- if (!screen.items.some((item) => item.key === screen.selectedKey)) screen.selectedKey = screen.items[0]?.key;
277
+ if (
278
+ !screen.items.some((item) => item.key === screen.selectedKey) &&
279
+ !(screen.view === "details" && screen.selectedKey)
280
+ )
281
+ screen.selectedKey = screen.items[0]?.key;
221
282
  const selectedIndex = screen.items.findIndex((item) => item.key === screen.selectedKey),
222
283
  selected = screen.items[selectedIndex];
223
284
  screen.versionRows = session?.versions?.rows ?? [];
@@ -225,47 +286,66 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
225
286
  const selectedVersion = screen.versionRows.find((row) => row.id === screen.versionId);
226
287
  const mode =
227
288
  session && options.connected !== false ? `Auto ${session.auto.enabled ? "ON" : "OFF"}` : "Auto unavailable";
228
- const header = `PI DADDY | ${mode}${options.pending ? " …" : session ? " [a]" : ""}`;
289
+ const header = `PI DADDY | ${mode}${options.pending ? " …" : session && options.connected !== false ? " [a]" : ""}`;
229
290
  const footer =
230
291
  options.command !== undefined
231
292
  ? [`: ${clean(options.command)}`]
232
- : screen.view === "settings"
233
- ? ["↑↓ select · Enter toggle/edit · Esc back", "0 default limit · PgUp/PgDn scroll · s settings"]
234
- : screen.view === "main" || screen.view === "versions"
235
- ? [
236
- modern ? "↑↓ select · PgUp/PgDn scroll · Enter details" : "↑↓ select · Enter details · a Auto",
237
- "m models · v versions · s settings · ?",
238
- ]
239
- : [
240
- "↑↓ scroll · Esc back · a Auto",
241
- screen.view === "details" ? "p prompt · f final · : command · ? help" : ": command · ? help",
242
- ];
293
+ : modern
294
+ ? sessionKeys(screen, selected, width)
295
+ : screen.view === "settings"
296
+ ? ["↑↓ select · Enter toggle/edit · Esc back", "0 default limit · PgUp/PgDn scroll · s settings"]
297
+ : screen.view === "main" || screen.view === "versions"
298
+ ? ["↑↓ select · Enter details · a Auto", "m models · v versions · s settings · ?"]
299
+ : [
300
+ "↑↓ scroll · Esc back · a Auto",
301
+ screen.view === "details" ? "p prompt · f final · : command · ? help" : ": command · ? help",
302
+ ];
243
303
  const fixed = [
244
- header,
245
- session && options.connected !== false
246
- ? `Permissions connected${pending.length ? ` · ${pending.length} needs you` : ""}`
247
- : "Permission controls disconnected",
248
- ...(modern
304
+ modern && options.connected !== false ? `${header} · Connected` : header,
305
+ ...(!modern
249
306
  ? [
250
- width >= 74
251
- ? "1 Now · 2 Work · 3 Reviews · 4 Activity · 5 Evidence · 6 Settings"
252
- : `${(screen.destination ?? "now").toUpperCase()} · 1–6 views · x expand`,
307
+ session && options.connected !== false
308
+ ? `Permissions connected${pending.length ? ` · ${pending.length} needs you` : ""}`
309
+ : "Permission controls disconnected",
253
310
  ]
254
311
  : []),
312
+ ...(modern ? [sessionLocation(screen, width)] : []),
255
313
  ];
256
314
  if (options.notice || options.problem) fixed.push(`! ${clean(options.notice || options.problem || "")}`);
257
315
  if (options.acknowledgment) fixed.push(clean(options.acknowledgment));
316
+ if (modern && options.filter && options.filter !== "everything" && screen.view === "main")
317
+ fixed.push(`Filter: ${options.filter} · Tab to change`);
258
318
  if (modern && options.connected === false)
259
319
  fixed.push(`LAST OBSERVED: ${session!.observation!.observedAt}; live state unknown`);
320
+ if (modern && screen.view === "main" && (screen.destination ?? "now") === "now") {
321
+ const [heading, action] = sessionNextLines(options);
322
+ const actionLines = wrapDashboardLines([action], width);
323
+ fixed.push(sectionHeading(heading.replace("NEXT", "SESSION PRIORITY"), width), actionLines[0]!);
324
+ if (actionLines.length > 1) fixed.push(truncate(actionLines.slice(1).join(" "), width));
325
+ }
260
326
  const body: string[] = [];
261
- if (screen.view === "help")
327
+ if (screen.view === "recap") {
328
+ const recap = sessionRecapLines(options);
329
+ const activity = recap.findIndex(
330
+ (line) => line === "Recent activity · newest first" || line === "No recent session events recorded.",
331
+ );
332
+ const summary = activity < 0 ? recap : recap.slice(0, activity);
333
+ if (summary.length) body.push(sectionHeading("SESSION STATUS", width), ...summary);
334
+ if (activity >= 0)
335
+ body.push(
336
+ sectionHeading("RECENT ACTIVITY", width),
337
+ ...recap.slice(activity + Number(recap[activity] === "Recent activity · newest first")),
338
+ );
339
+ } else if (screen.view === "help")
262
340
  body.push(
263
341
  "DASHBOARD KEYS",
264
342
  "↑/↓ or j/k: select; Enter/d: details",
265
343
  "a: toggle Daddy permission Auto",
266
344
  "m: session models; v: ecosystem versions; s: settings",
267
345
  "1–6: Now / Work / Reviews / Activity / Evidence / Settings",
268
- "x: compact/expanded (96 columns); selection is preserved",
346
+ "r: recent session activity and review counts",
347
+ "Wide terminals preview the selected item. x shows more session information.",
348
+ "x in a review detail: show or hide its source and exact reference",
269
349
  "No cancellation shortcut: request it in the owning Pi session.",
270
350
  "Goals/next steps are owner recommendations, not execution authority.",
271
351
  "Reviews apply only to their exact subject; completed is not accepted.",
@@ -287,18 +367,23 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
287
367
  options.connected === false && session?.settings ? { ...session.settings, editable: false } : session?.settings,
288
368
  session?.auto.enabled,
289
369
  screen.settingKey ?? "auto",
290
- ),
370
+ ).map((line) => {
371
+ if (modern && (line === "SETTINGS" || line === "SETTINGS · current session"))
372
+ return sectionHeading("SESSION CONTROLS", width);
373
+ if (modern && line.startsWith("STARTUP LIMITS")) return sectionHeading(line, width);
374
+ return line;
375
+ }),
291
376
  );
292
377
  if (session?.observation)
293
378
  body.push(
294
- "CAPTURE · startup configuration (not a retention receipt)",
379
+ sectionHeading("CAPTURE · startup configuration", width),
295
380
  `Transcripts: ${session.observation.capture.transcripts ? "configured" : "off"}`,
296
381
  `Diagnostics: ${session.observation.capture.diagnostics ? "configured" : "off"}`,
297
382
  "Capture changes require a new parent launch.",
298
383
  "m models · v versions",
299
384
  );
300
385
  } else if (screen.view === "versions" || screen.view === "version-details") {
301
- body.push("VERSIONS");
386
+ body.push(modern ? sectionHeading("VERSIONS", width) : "VERSIONS");
302
387
  if (!session?.versions) body.push("Owner has not reported versions.");
303
388
  else if (screen.view === "versions") {
304
389
  body.push("Loaded -> on disk");
@@ -323,19 +408,41 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
323
408
  if (session.versions.note) body.push(session.versions.note);
324
409
  }
325
410
  } else if (screen.view === "models") {
326
- body.push("SESSION MODELS");
411
+ body.push(modern ? sectionHeading("SESSION MODELS", width) : "SESSION MODELS");
327
412
  if (!session) body.push("Connect from /grants dashboard to edit models.");
328
413
  for (const row of session?.rows ?? [])
329
414
  body.push(`${row.definition}: ${row.model}`, ` ${row.thinking} · ${row.source}`);
330
415
  body.push(": m <definition|all> <provider:model> <thinking>");
331
416
  } else if (screen.view === "details") {
417
+ const title =
418
+ selected &&
419
+ (selected.status === "approval-wait" && /\bready for review\b/i.test(selected.label)
420
+ ? selected.label
421
+ : selected.status === "last-observed"
422
+ ? `Last seen · ${selected.label}`
423
+ : `${selected.label} · ${friendlyStatus(selected.status)}`);
332
424
  body.push(
333
- selected ? `${selected.label} · ${friendlyStatus(selected.status)}` : "No selected task",
334
- ...(selected?.details ?? []),
425
+ title ??
426
+ (screen.selectedKey ? "This item is no longer visible. Press Esc to return to the list." : "No selected task"),
427
+ ...(modern && selected
428
+ ? [
429
+ sectionHeading(
430
+ screen.sourceDetails
431
+ ? "SOURCE RECORD"
432
+ : (selected.briefDetails && selected.status === "approval-wait") || selected.approval
433
+ ? "NEXT ACTION"
434
+ : "DETAILS",
435
+ width,
436
+ ),
437
+ ]
438
+ : []),
439
+ ...((screen.sourceDetails ? selected?.details : (selected?.briefDetails ?? selected?.details)) ?? []),
335
440
  );
336
- if (options.content) body.push("", options.content.title, ...options.content.text.split(/\r?\n/));
441
+ if (selected && options.content) body.push("", options.content.title, ...options.content.text.split(/\r?\n/));
337
442
  } else if (modern) {
338
- body.push(...sessionPanelLines(options, screen.items, width));
443
+ if (!screen.items.length && options.filter && options.filter !== "everything")
444
+ body.push("No items match this filter. Press Tab to change it.");
445
+ else body.push(...sessionPanelLines(options, screen.items, width));
339
446
  } else {
340
447
  const requestFinished = options.currentStatus && !active(options.currentStatus);
341
448
  body.push(
@@ -381,11 +488,16 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
381
488
  if (history) body.push(history);
382
489
  }
383
490
 
491
+ const left =
492
+ modern && screen.view === "main" && selected
493
+ ? previewWidth(screen.destination ?? "now", Boolean(screen.expanded), width)
494
+ : undefined;
384
495
  const detailBody =
385
- (screen.view === "main" && (!modern || (screen.expanded && width >= 96))) || screen.view === "versions"
386
- ? body
387
- : wrapped(body, width);
388
- const clipped = modern && detailBody.length > Math.max(0, height - fixed.length - footer.length);
496
+ (screen.view === "main" && !modern) || screen.view === "versions" ? body : wrapDashboardLines(body, left ?? width);
497
+ if (modern && height >= 16 && height - fixed.length - footer.length > detailBody.length)
498
+ footer.unshift("─".repeat(Math.min(width, 100)));
499
+ const bodyRoom = height - fixed.length - footer.length;
500
+ const clipped = modern && bodyRoom >= 2 && detailBody.length > bodyRoom;
389
501
  if (clipped) footer.push("");
390
502
  const room = Math.max(0, height - fixed.length - footer.length);
391
503
  if (screen.view === "versions" && selectedVersion && room > 0) {
@@ -409,16 +521,37 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
409
521
  if (clipped)
410
522
  footer[footer.length - 1] =
411
523
  `Rows ${offset + 1}–${Math.min(offset + room, detailBody.length)}/${detailBody.length} · PgUp/PgDn`;
412
- const lines = [...fixed, ...detailBody.slice(offset, offset + room)];
524
+ const page = detailBody.slice(offset, offset + room);
525
+ if (left !== undefined && selected) {
526
+ const right = Math.min(width - left - 3, 72);
527
+ const preview = wrapDashboardLines(
528
+ [
529
+ sectionHeading("SELECTED ITEM", right),
530
+ clean(selected.label),
531
+ "",
532
+ ...(selected.briefDetails ??
533
+ (screen.expanded ? selected.details : [friendlyStatus(selected.status), "Press Enter for details."])),
534
+ ],
535
+ right,
536
+ );
537
+ const count = Math.min(room, Math.max(page.length, preview.length));
538
+ for (let i = 0; i < count; i++) {
539
+ const cell = page[i] ?? "";
540
+ page[i] = cell + " ".repeat(Math.max(0, left - cellWidth(cell))) + " │ " + (preview[i] ?? "");
541
+ }
542
+ }
543
+ const lines = [...fixed, ...page];
413
544
  while (lines.length < height - footer.length) lines.push("");
414
- const output =
415
- height < fixed.length + footer.length
416
- ? fixed.slice(0, height)
417
- : [...lines.slice(0, Math.max(0, height - footer.length)), ...footer].slice(0, height);
545
+ const output = [...lines, ...footer].slice(0, height);
418
546
  return output
419
547
  .map((line, index) => {
420
548
  const safe = truncate(dashboardText(line), width);
421
549
  if (!options.color) return safe;
550
+ if (modern)
551
+ return colorSessionLine(
552
+ safe,
553
+ index === 0 ? "header" : index === 1 ? "navigation" : index >= height - footer.length ? "footer" : "body",
554
+ );
422
555
  const section = [
423
556
  "NOW",
424
557
  "WORK",