pi-daddy 0.51.0 → 0.52.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 (83) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +11 -32
  3. package/dist/governance/approval-prompt.d.ts +4 -0
  4. package/dist/governance/approval-prompt.d.ts.map +1 -1
  5. package/dist/governance/approval-prompt.js +4 -5
  6. package/dist/governance/approval-prompt.js.map +1 -1
  7. package/dist/governance/permission-question.d.ts +4 -0
  8. package/dist/governance/permission-question.d.ts.map +1 -0
  9. package/dist/governance/permission-question.js +102 -0
  10. package/dist/governance/permission-question.js.map +1 -0
  11. package/dist/kernel/chain.d.ts +1 -0
  12. package/dist/kernel/chain.d.ts.map +1 -1
  13. package/dist/kernel/chain.js.map +1 -1
  14. package/dist/kernel/dashboard-observation.d.ts +15 -5
  15. package/dist/kernel/dashboard-observation.d.ts.map +1 -1
  16. package/dist/kernel/dashboard-observation.js.map +1 -1
  17. package/dist/products/activity-summary.d.ts +8 -0
  18. package/dist/products/activity-summary.d.ts.map +1 -0
  19. package/dist/products/activity-summary.js +101 -0
  20. package/dist/products/activity-summary.js.map +1 -0
  21. package/dist/products/activity-timeline.d.ts +4 -1
  22. package/dist/products/activity-timeline.d.ts.map +1 -1
  23. package/dist/products/activity-timeline.js +9 -1
  24. package/dist/products/activity-timeline.js.map +1 -1
  25. package/dist/products/dashboard-activity.d.ts +9 -0
  26. package/dist/products/dashboard-activity.d.ts.map +1 -0
  27. package/dist/products/dashboard-activity.js +119 -0
  28. package/dist/products/dashboard-activity.js.map +1 -0
  29. package/dist/products/dashboard-cli.d.ts +2 -1
  30. package/dist/products/dashboard-cli.d.ts.map +1 -1
  31. package/dist/products/dashboard-cli.js +8 -5
  32. package/dist/products/dashboard-cli.js.map +1 -1
  33. package/dist/products/dashboard-components.d.ts +10 -0
  34. package/dist/products/dashboard-components.d.ts.map +1 -0
  35. package/dist/products/dashboard-components.js +196 -0
  36. package/dist/products/dashboard-components.js.map +1 -0
  37. package/dist/products/dashboard-layout.js +20 -4
  38. package/dist/products/dashboard-layout.js.map +1 -1
  39. package/dist/products/dashboard-panels.d.ts.map +1 -1
  40. package/dist/products/dashboard-panels.js +128 -67
  41. package/dist/products/dashboard-panels.js.map +1 -1
  42. package/dist/products/dashboard-recap.d.ts +1 -1
  43. package/dist/products/dashboard-recap.d.ts.map +1 -1
  44. package/dist/products/dashboard-recap.js +12 -16
  45. package/dist/products/dashboard-recap.js.map +1 -1
  46. package/dist/products/dashboard-screen.d.ts +5 -2
  47. package/dist/products/dashboard-screen.d.ts.map +1 -1
  48. package/dist/products/dashboard-screen.js +92 -36
  49. package/dist/products/dashboard-screen.js.map +1 -1
  50. package/dist/products/dashboard-session-client.d.ts +6 -5
  51. package/dist/products/dashboard-session-client.d.ts.map +1 -1
  52. package/dist/products/dashboard-session-client.js.map +1 -1
  53. package/dist/products/ecosystem-versions.d.ts +2 -0
  54. package/dist/products/ecosystem-versions.d.ts.map +1 -1
  55. package/extensions/activity-timeline.ts +7 -1
  56. package/extensions/approvals.ts +7 -0
  57. package/extensions/dashboard-live.ts +45 -5
  58. package/extensions/dashboard-observation.ts +1 -3
  59. package/extensions/delegate-chain.ts +2 -0
  60. package/extensions/delegation-artifacts.ts +26 -4
  61. package/extensions/delegation-operations.ts +12 -4
  62. package/extensions/delegation.ts +4 -0
  63. package/extensions/ecosystem-versions.ts +25 -3
  64. package/extensions/execute-child.ts +4 -0
  65. package/extensions/run-delegation.ts +2 -0
  66. package/extensions/runtime-snapshot.ts +8 -4
  67. package/extensions/session.ts +2 -2
  68. package/package.json +1 -1
  69. package/src/governance/approval-prompt.ts +7 -6
  70. package/src/governance/permission-question.ts +108 -0
  71. package/src/kernel/chain.ts +1 -0
  72. package/src/kernel/dashboard-observation.ts +15 -1
  73. package/src/products/activity-summary.ts +101 -0
  74. package/src/products/activity-timeline.ts +11 -0
  75. package/src/products/dashboard-activity.ts +136 -0
  76. package/src/products/dashboard-cli.ts +20 -6
  77. package/src/products/dashboard-components.ts +219 -0
  78. package/src/products/dashboard-layout.ts +27 -6
  79. package/src/products/dashboard-panels.ts +128 -76
  80. package/src/products/dashboard-recap.ts +15 -15
  81. package/src/products/dashboard-screen.ts +101 -38
  82. package/src/products/dashboard-session-client.ts +7 -1
  83. package/src/products/ecosystem-versions.ts +2 -0
@@ -1,3 +1,4 @@
1
+ import type { DashboardAcknowledgment } from "./dashboard-session-client.ts";
1
2
  import {
2
3
  sessionDashboardItems,
3
4
  sessionNextLines,
@@ -5,6 +6,8 @@ import {
5
6
  DASHBOARD_DESTINATIONS,
6
7
  type DashboardDestination,
7
8
  } from "./dashboard-panels.ts";
9
+ import { activityTaskTitle } from "./dashboard-activity.ts";
10
+ import { versionLines } from "./dashboard-components.ts";
8
11
  import { sessionRecapLines } from "./dashboard-recap.ts";
9
12
  import { colorSessionLine, previewWidth, sectionHeading } from "./dashboard-layout.ts";
10
13
  import { dashboardSettingsLines, type DashboardSettingKey } from "./dashboard-settings.ts";
@@ -20,9 +23,11 @@ export interface DashboardItem {
20
23
  label: string;
21
24
  status: string;
22
25
  elapsed: string;
26
+ updatedAt?: string;
23
27
  details: string[];
24
28
  briefDetails?: string[];
25
29
  reviewSummary?: boolean;
30
+ relatedReviewKey?: string;
26
31
  observation?: string;
27
32
  taskKey?: string;
28
33
  timelinePath?: string;
@@ -55,16 +60,18 @@ export function wrapDashboardLines(lines: string[], width: number): string[] {
55
60
  return lines.flatMap((line) => {
56
61
  const safe = dashboardText(line);
57
62
  if (cellWidth(safe) <= width) return [safe];
63
+ const indent = width >= 12 && (safe.startsWith("> ") || safe.startsWith(" ")) ? safe.slice(0, 2) : "";
64
+ const available = width - indent.length;
58
65
  const result: string[] = [];
59
66
  let row = "";
60
- for (const word of safe.split(/\s+/)) {
61
- if (row && cellWidth(row + " " + word) > width) {
67
+ for (const word of safe.slice(indent.length).split(/\s+/)) {
68
+ if (row && cellWidth(row + " " + word) > available) {
62
69
  result.push(row);
63
70
  row = "";
64
71
  }
65
- if (cellWidth(word) > width) {
72
+ if (cellWidth(word) > available) {
66
73
  for (const character of word) {
67
- if (row && cellWidth(row + character) > width) {
74
+ if (row && cellWidth(row + character) > available) {
68
75
  result.push(row);
69
76
  row = "";
70
77
  }
@@ -73,7 +80,7 @@ export function wrapDashboardLines(lines: string[], width: number): string[] {
73
80
  } else row += (row ? " " : "") + word;
74
81
  }
75
82
  result.push(row);
76
- return result;
83
+ return result.map((part, i) => (i === 0 ? indent : " ".repeat(indent.length)) + part);
77
84
  });
78
85
  }
79
86
 
@@ -123,6 +130,7 @@ export function ledgerDashboardItems(projection: DashboardProjection): Dashboard
123
130
  label: node.agentName || "Governed execution",
124
131
  status: node.state,
125
132
  elapsed: elapsed(node.durationMs),
133
+ updatedAt: node.updatedAt,
126
134
  agent: true,
127
135
  details: [
128
136
  `Execution: ${node.executionId}`,
@@ -142,12 +150,16 @@ export function activityDashboardItems(
142
150
  timeline: ActivityTimeline,
143
151
  aliases: ActivityTimelineAliases,
144
152
  now: Date,
153
+ human = false,
145
154
  ): DashboardItem[] {
146
155
  return timeline.tasks.map((task) => ({
147
156
  key: activityTaskKey(task.rootId, task.id),
148
157
  taskKey: activityTaskKey(task.rootId, task.id),
149
- label: `${task.agent || (task.trigger?.type === "custom" ? "Extension turn" : "User turn")} [${aliases.selector(task)}]`,
158
+ label: human
159
+ ? activityTaskTitle(task)
160
+ : `${task.agent || (task.trigger?.type === "custom" ? "Extension turn" : "User turn")} [${aliases.selector(task)}]`,
150
161
  status: task.status,
162
+ updatedAt: task.endedAt ?? task.lastEvent?.at ?? task.startedAt,
151
163
  elapsed: elapsed(Date.parse(task.endedAt ?? now.toISOString()) - Date.parse(task.startedAt)),
152
164
  observation: task.lastEvent
153
165
  ? `${task.lastEvent.tool ? `${task.lastEvent.tool} ` : ""}${task.lastEvent.kind.replaceAll("_", " ")} · ${elapsed(Date.parse(now.toISOString()) - Date.parse(task.lastEvent.at))} ago`
@@ -193,9 +205,17 @@ export interface DashboardScreenOptions {
193
205
  content?: { title: string; text: string };
194
206
  command?: string;
195
207
  connected?: boolean;
196
- acknowledgment?: string;
208
+ acknowledgment?: DashboardAcknowledgment;
197
209
  now?: Date;
198
210
  }
211
+ const destinationNames: Record<DashboardDestination, string> = {
212
+ now: "Overview",
213
+ work: "Tasks",
214
+ reviews: "Reviews",
215
+ activity: "Activity",
216
+ evidence: "Evidence",
217
+ settings: "Settings",
218
+ };
199
219
  function sessionLocation(screen: DashboardScreenState, width: number): string {
200
220
  const destination = screen.destination ?? "now";
201
221
  const overlays = {
@@ -206,15 +226,14 @@ function sessionLocation(screen: DashboardScreenState, width: number): string {
206
226
  "version-details": "Version details",
207
227
  recap: "Session recap",
208
228
  };
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)}`,
229
+ const name = destinationNames[destination];
230
+ if (screen.view in overlays) return `${name} / ${overlays[screen.view as keyof typeof overlays]}`;
231
+ const nav = DASHBOARD_DESTINATIONS.map((view, i) =>
232
+ view === destination ? `[${i + 1} ${name}]` : `${i + 1} ${destinationNames[view]}`,
217
233
  ).join(" ");
234
+ return cellWidth(nav) <= width
235
+ ? nav
236
+ : `[${DASHBOARD_DESTINATIONS.indexOf(destination) + 1} ${name}] · 1–6 views · ? help`;
218
237
  }
219
238
 
220
239
  function sessionKeys(screen: DashboardScreenState, selected: DashboardItem | undefined, width: number): string[] {
@@ -232,15 +251,31 @@ function sessionKeys(screen: DashboardScreenState, selected: DashboardItem | und
232
251
  ...(view === "details" && selected?.briefDetails ? [screen.sourceDetails ? "x hide source" : "x show source"] : []),
233
252
  ];
234
253
  }
254
+ const permissionDescriptions: Record<string, string> = {
255
+ "tool:bash": "shell access",
256
+ "tool:write": "permission to write files",
257
+ "tool:edit": "permission to edit files",
258
+ };
235
259
  /** Selection follows stable identity through refresh, never an unrelated task at the old row index. */
236
260
  export function renderDashboardScreen(options: DashboardScreenOptions): string {
237
261
  const width = Math.max(1, Math.floor(options.width)),
238
262
  height = Math.max(1, Math.floor(options.height));
239
263
  const { screen, session } = options,
240
264
  pending = session?.pendingApprovals ?? [];
265
+ const modern = Boolean(session?.observation);
241
266
  const approvals: DashboardItem[] = (options.connected === false ? [] : pending).map((approval) => ({
242
267
  key: `approval:${approval.id}`,
243
- label: `${approval.subject} · ${approval.capability.replace(/^tool:/, "")}`,
268
+ label: modern
269
+ ? `${clean(approval.subject)} needs ${permissionDescriptions[approval.capability] ?? approval.capability}`
270
+ : `${approval.subject} · ${approval.capability.replace(/^tool:/, "")}`,
271
+ ...(modern
272
+ ? {
273
+ briefDetails: [
274
+ "Open the permission request in your main Pi chat.",
275
+ "Choose whether to grant this access for the task.",
276
+ ],
277
+ }
278
+ : {}),
244
279
  status: "needs-you",
245
280
  elapsed: "",
246
281
  approval: true,
@@ -252,7 +287,6 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
252
287
  "Respond to the permission request in the parent Pi session.",
253
288
  ],
254
289
  }));
255
- const modern = Boolean(session?.observation);
256
290
  const allItems = [
257
291
  ...(!modern || ["now", "work"].includes(screen.destination ?? "now") ? approvals : []),
258
292
  ...(modern ? sessionDashboardItems(options) : options.items),
@@ -263,7 +297,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
263
297
  : options.filter === "skills"
264
298
  ? item.skills
265
299
  : options.filter === "needs-you"
266
- ? item.status === "needs-you"
300
+ ? ["needs-you", "approval-wait"].includes(item.status)
267
301
  : true,
268
302
  );
269
303
  const live = items.filter((item) => active(item.status)),
@@ -311,17 +345,34 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
311
345
  : []),
312
346
  ...(modern ? [sessionLocation(screen, width)] : []),
313
347
  ];
314
- if (options.notice || options.problem) fixed.push(`! ${clean(options.notice || options.problem || "")}`);
315
- if (options.acknowledgment) fixed.push(clean(options.acknowledgment));
348
+ const disconnected = modern && options.connected === false;
349
+ if (disconnected) fixed.push("Disconnected · showing last known status");
350
+ else if (options.notice || options.problem) fixed.push(`! ${clean(options.notice || options.problem || "")}`);
351
+ const ack = options.acknowledgment;
352
+ if (ack?.state === "unconfirmed") {
353
+ const setting =
354
+ ({ "set-auto": "Auto", "set-jev": "JEV", set: "model", "set-limit": "limit" } as Record<string, string>)[
355
+ ack.action
356
+ ] ?? "setting";
357
+ fixed.push(
358
+ ...wrapDashboardLines([`Unconfirmed ${setting} change. Check the main Pi chat before trying again.`], width),
359
+ );
360
+ } else if (ack && (!disconnected || !modern) && (!modern || screen.view === "settings" || ack.state === "refused")) {
361
+ fixed.push(clean(`${ack.action}: ${ack.state} · ${ack.effect}`));
362
+ }
316
363
  if (modern && options.filter && options.filter !== "everything" && screen.view === "main")
317
364
  fixed.push(`Filter: ${options.filter} · Tab to change`);
318
- if (modern && options.connected === false)
319
- fixed.push(`LAST OBSERVED: ${session!.observation!.observedAt}; live state unknown`);
320
- if (modern && screen.view === "main" && (screen.destination ?? "now") === "now") {
365
+ if (modern && options.height >= 22) fixed.push("");
366
+ if (modern && screen.view === "main" && (screen.destination ?? "now") === "now" && !disconnected) {
321
367
  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));
368
+ const recommendation = action !== "No current next step reported.";
369
+ if (recommendation) {
370
+ const title = heading.includes("[3]") ? "Next step · [3] Reviews" : "Next step";
371
+ fixed.push(sectionHeading(title, width), ...wrapDashboardLines([action], width).slice(0, 2));
372
+ } else if (!allItems.some((i) => i.approval || ["needs-you", "approval-wait"].includes(i.status))) {
373
+ fixed.push("No decision requested from you.");
374
+ }
375
+ if (options.height >= 22) fixed.push("");
325
376
  }
326
377
  const body: string[] = [];
327
378
  if (screen.view === "recap") {
@@ -342,7 +393,9 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
342
393
  "↑/↓ or j/k: select; Enter/d: details",
343
394
  "a: toggle Daddy permission Auto",
344
395
  "m: session models; v: ecosystem versions; s: settings",
345
- "1–6: Now / Work / Reviews / Activity / Evidence / Settings",
396
+ "1 Overview · what needs you and what Pi is doing",
397
+ "2 Tasks · full session task list, including finished work",
398
+ "3 Reviews · 4 Activity · 5 Evidence · 6 Settings",
346
399
  "r: recent session activity and review counts",
347
400
  "Wide terminals preview the selected item. x shows more session information.",
348
401
  "x in a review detail: show or hide its source and exact reference",
@@ -363,6 +416,14 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
363
416
  );
364
417
  else if (screen.view === "settings") {
365
418
  body.push(
419
+ ...(disconnected
420
+ ? [
421
+ sectionHeading("Connection details", width),
422
+ `Last contact: ${session!.observation!.observedAt}`,
423
+ ...(options.notice || options.problem ? [clean(options.notice || options.problem || "")] : []),
424
+ "",
425
+ ]
426
+ : []),
366
427
  ...dashboardSettingsLines(
367
428
  options.connected === false && session?.settings ? { ...session.settings, editable: false } : session?.settings,
368
429
  session?.auto.enabled,
@@ -386,12 +447,14 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
386
447
  body.push(modern ? sectionHeading("VERSIONS", width) : "VERSIONS");
387
448
  if (!session?.versions) body.push("Owner has not reported versions.");
388
449
  else if (screen.view === "versions") {
389
- body.push("Loaded -> on disk");
450
+ body.push(modern ? "Packages in this Pi session" : "Loaded -> on disk");
390
451
  for (const row of screen.versionRows)
391
- body.push(
392
- `${row.id === screen.versionId ? ">" : " "} ${row.label}: ${row.loadedVersion ?? "?"} -> ${row.installedVersion ?? "?"}`,
393
- ` ${versionStatus(row)}`,
394
- );
452
+ if (modern) body.push(...versionLines(row, row.id === screen.versionId, options));
453
+ else
454
+ body.push(
455
+ `${row.id === screen.versionId ? ">" : " "} ${row.label}: ${row.loadedVersion ?? "?"} -> ${row.installedVersion ?? "?"}`,
456
+ ` ${versionStatus(row)}`,
457
+ );
395
458
  if (session.versions.note) body.push(session.versions.note);
396
459
  } else if (selectedVersion) {
397
460
  body.push(
@@ -416,7 +479,8 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
416
479
  } else if (screen.view === "details") {
417
480
  const title =
418
481
  selected &&
419
- (selected.status === "approval-wait" && /\bready for review\b/i.test(selected.label)
482
+ (selected.key.startsWith("component:") ||
483
+ (selected.status === "approval-wait" && /\bready for review\b/i.test(selected.label))
420
484
  ? selected.label
421
485
  : selected.status === "last-observed"
422
486
  ? `Last seen · ${selected.label}`
@@ -493,7 +557,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
493
557
  ? previewWidth(screen.destination ?? "now", Boolean(screen.expanded), width)
494
558
  : undefined;
495
559
  const detailBody =
496
- (screen.view === "main" && !modern) || screen.view === "versions" ? body : wrapDashboardLines(body, left ?? width);
560
+ !modern && (screen.view === "main" || screen.view === "versions") ? body : wrapDashboardLines(body, left ?? width);
497
561
  if (modern && height >= 16 && height - fixed.length - footer.length > detailBody.length)
498
562
  footer.unshift("─".repeat(Math.min(width, 100)));
499
563
  const bodyRoom = height - fixed.length - footer.length;
@@ -501,7 +565,7 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
501
565
  if (clipped) footer.push("");
502
566
  const room = Math.max(0, height - fixed.length - footer.length);
503
567
  if (screen.view === "versions" && selectedVersion && room > 0) {
504
- const row = 2 + screen.versionRows.findIndex((value) => value.id === screen.versionId) * 2;
568
+ const row = detailBody.findIndex((line) => line.startsWith(">"));
505
569
  if (row < screen.offset) screen.offset = row;
506
570
  else if (row + 1 >= screen.offset + room) screen.offset = Math.max(0, row + 2 - room);
507
571
  }
@@ -526,11 +590,10 @@ export function renderDashboardScreen(options: DashboardScreenOptions): string {
526
590
  const right = Math.min(width - left - 3, 72);
527
591
  const preview = wrapDashboardLines(
528
592
  [
529
- sectionHeading("SELECTED ITEM", right),
593
+ sectionHeading("Selected item", right),
530
594
  clean(selected.label),
531
595
  "",
532
- ...(selected.briefDetails ??
533
- (screen.expanded ? selected.details : [friendlyStatus(selected.status), "Press Enter for details."])),
596
+ ...(selected.briefDetails ?? [friendlyStatus(selected.status), "Press Enter for details."]),
534
597
  ],
535
598
  right,
536
599
  );
@@ -58,6 +58,12 @@ export async function dashboardSessionRequest(
58
58
  });
59
59
  }
60
60
 
61
+ export type DashboardAcknowledgment = {
62
+ action: string;
63
+ state: "pending" | "applied" | "refused" | "unconfirmed";
64
+ effect: string;
65
+ };
66
+
61
67
  /** Controls use only a connected owner; last observations remain explicitly disconnected evidence. */
62
68
  export function createDashboardConnection(
63
69
  request?: (action: DashboardSessionAction) => Promise<DashboardSessionSnapshot>,
@@ -67,7 +73,7 @@ export function createDashboardConnection(
67
73
  lastObserved?: DashboardSessionSnapshot;
68
74
  pending: boolean;
69
75
  error?: string;
70
- acknowledgment?: { action: string; state: "pending" | "applied" | "refused" | "unconfirmed"; effect: string };
76
+ acknowledgment?: DashboardAcknowledgment;
71
77
  } = { pending: false };
72
78
  let generation = 0,
73
79
  poll = 0,
@@ -11,6 +11,8 @@ export interface EcosystemVersionRow {
11
11
  state: "current" | "reload-required" | "not-reported" | "unavailable" | "multiple";
12
12
  commands: string[];
13
13
  note?: string;
14
+ /** Pi reports the Bookie command from this installed package in the current session. */
15
+ commandAvailable?: boolean;
14
16
  }
15
17
  export interface EcosystemVersions {
16
18
  rows: EcosystemVersionRow[];