pi-daddy 0.49.5 → 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.
- package/CHANGELOG.md +57 -1
- package/README.md +231 -27
- package/dist/governance/initiative-coordinator.d.ts +63 -0
- package/dist/governance/initiative-coordinator.d.ts.map +1 -0
- package/dist/governance/initiative-coordinator.js +364 -0
- package/dist/governance/initiative-coordinator.js.map +1 -0
- package/dist/governance/initiative-effects.d.ts +20 -0
- package/dist/governance/initiative-effects.d.ts.map +1 -0
- package/dist/governance/initiative-effects.js +108 -0
- package/dist/governance/initiative-effects.js.map +1 -0
- package/dist/governance/initiative-state.d.ts +13 -0
- package/dist/governance/initiative-state.d.ts.map +1 -0
- package/dist/governance/initiative-state.js +122 -0
- package/dist/governance/initiative-state.js.map +1 -0
- package/dist/governance/operation-artifact-io.d.ts +8 -0
- package/dist/governance/operation-artifact-io.d.ts.map +1 -0
- package/dist/governance/operation-artifact-io.js +95 -0
- package/dist/governance/operation-artifact-io.js.map +1 -0
- package/dist/governance/operation-artifact-scan.d.ts +13 -0
- package/dist/governance/operation-artifact-scan.d.ts.map +1 -0
- package/dist/governance/operation-artifact-scan.js +71 -0
- package/dist/governance/operation-artifact-scan.js.map +1 -0
- package/dist/governance/operation-artifacts.d.ts +53 -0
- package/dist/governance/operation-artifacts.d.ts.map +1 -0
- package/dist/governance/operation-artifacts.js +309 -0
- package/dist/governance/operation-artifacts.js.map +1 -0
- package/dist/governance/runtime-settlement.d.ts +2 -0
- package/dist/governance/runtime-settlement.d.ts.map +1 -1
- package/dist/governance/runtime-settlement.js +26 -0
- package/dist/governance/runtime-settlement.js.map +1 -1
- package/dist/governance/workspace-acceptance.d.ts +5 -0
- package/dist/governance/workspace-acceptance.d.ts.map +1 -1
- package/dist/governance/workspace-acceptance.js +16 -0
- package/dist/governance/workspace-acceptance.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/kernel/dashboard-observation.d.ts +76 -0
- package/dist/kernel/dashboard-observation.d.ts.map +1 -0
- package/dist/kernel/dashboard-observation.js +49 -0
- package/dist/kernel/dashboard-observation.js.map +1 -0
- package/dist/kernel/dispatch-operation.d.ts +2 -0
- package/dist/kernel/dispatch-operation.d.ts.map +1 -1
- package/dist/kernel/dispatch-operation.js.map +1 -1
- package/dist/kernel/initiative.d.ts +94 -0
- package/dist/kernel/initiative.d.ts.map +1 -0
- package/dist/kernel/initiative.js +38 -0
- package/dist/kernel/initiative.js.map +1 -0
- package/dist/kernel/operation-artifact.d.ts +49 -0
- package/dist/kernel/operation-artifact.d.ts.map +1 -0
- package/dist/kernel/operation-artifact.js +4 -0
- package/dist/kernel/operation-artifact.js.map +1 -0
- package/dist/kernel/principal-binding.d.ts +4 -0
- package/dist/kernel/principal-binding.d.ts.map +1 -0
- package/dist/kernel/principal-binding.js +94 -0
- package/dist/kernel/principal-binding.js.map +1 -0
- package/dist/kernel/project-paths.d.ts +6 -0
- package/dist/kernel/project-paths.d.ts.map +1 -1
- package/dist/kernel/project-paths.js +12 -0
- package/dist/kernel/project-paths.js.map +1 -1
- package/dist/kernel/selected-definitions.d.ts.map +1 -1
- package/dist/kernel/selected-definitions.js +5 -91
- package/dist/kernel/selected-definitions.js.map +1 -1
- package/dist/kernel/workspace-diagnostics.d.ts +24 -0
- package/dist/kernel/workspace-diagnostics.d.ts.map +1 -0
- package/dist/kernel/workspace-diagnostics.js +81 -0
- package/dist/kernel/workspace-diagnostics.js.map +1 -0
- package/dist/products/activity-storage.d.ts +2 -0
- package/dist/products/activity-storage.d.ts.map +1 -0
- package/dist/products/activity-storage.js +119 -0
- package/dist/products/activity-storage.js.map +1 -0
- package/dist/products/activity-timeline.d.ts +4 -0
- package/dist/products/activity-timeline.d.ts.map +1 -1
- package/dist/products/activity-timeline.js +12 -0
- package/dist/products/activity-timeline.js.map +1 -1
- package/dist/products/dashboard-cli.d.ts +2 -0
- package/dist/products/dashboard-cli.d.ts.map +1 -1
- package/dist/products/dashboard-cli.js +50 -10
- package/dist/products/dashboard-cli.js.map +1 -1
- package/dist/products/dashboard-display-controls.d.ts.map +1 -1
- package/dist/products/dashboard-display-controls.js +72 -2
- package/dist/products/dashboard-display-controls.js.map +1 -1
- package/dist/products/dashboard-file-cache.d.ts +10 -0
- package/dist/products/dashboard-file-cache.d.ts.map +1 -0
- package/dist/products/dashboard-file-cache.js +38 -0
- package/dist/products/dashboard-file-cache.js.map +1 -0
- package/dist/products/dashboard-layout.d.ts +6 -0
- package/dist/products/dashboard-layout.d.ts.map +1 -0
- package/dist/products/dashboard-layout.js +45 -0
- package/dist/products/dashboard-layout.js.map +1 -0
- package/dist/products/dashboard-panels.d.ts +10 -0
- package/dist/products/dashboard-panels.d.ts.map +1 -0
- package/dist/products/dashboard-panels.js +319 -0
- package/dist/products/dashboard-panels.js.map +1 -0
- package/dist/products/dashboard-recap.d.ts +4 -0
- package/dist/products/dashboard-recap.d.ts.map +1 -0
- package/dist/products/dashboard-recap.js +47 -0
- package/dist/products/dashboard-recap.js.map +1 -0
- package/dist/products/dashboard-screen.d.ts +14 -1
- package/dist/products/dashboard-screen.d.ts.map +1 -1
- package/dist/products/dashboard-screen.js +217 -40
- package/dist/products/dashboard-screen.js.map +1 -1
- package/dist/products/dashboard-session-client.d.ts +16 -2
- package/dist/products/dashboard-session-client.d.ts.map +1 -1
- package/dist/products/dashboard-session-client.js +64 -11
- package/dist/products/dashboard-session-client.js.map +1 -1
- package/dist/products/dashboard-settings.d.ts.map +1 -1
- package/dist/products/dashboard-settings.js +4 -6
- package/dist/products/dashboard-settings.js.map +1 -1
- package/dist/products/ecosystem-versions.d.ts +1 -1
- package/dist/products/ecosystem-versions.d.ts.map +1 -1
- package/extensions/activity-timeline.ts +3 -1
- package/extensions/artifact-bridge.ts +130 -0
- package/extensions/dashboard-live.ts +63 -0
- package/extensions/dashboard-observation.ts +39 -0
- package/extensions/dashboard-session-server.ts +45 -3
- package/extensions/dashboard-sources.ts +124 -0
- package/extensions/delegation-artifacts.ts +133 -0
- package/extensions/delegation-operations.ts +42 -13
- package/extensions/ecosystem-versions.ts +12 -5
- package/extensions/grants-command.ts +34 -6
- package/extensions/grants.ts +9 -20
- package/extensions/initiative-dashboard.ts +143 -0
- package/extensions/initiative-handoff.ts +59 -0
- package/extensions/initiative-runtime.ts +444 -0
- package/extensions/runtime-snapshot.ts +118 -2
- package/extensions/session-environment.ts +13 -1
- package/extensions/session.ts +28 -10
- package/extensions/workspace-diagnostics.ts +90 -0
- package/package.json +1 -1
- package/src/governance/initiative-coordinator.ts +416 -0
- package/src/governance/initiative-effects.ts +146 -0
- package/src/governance/initiative-state.ts +144 -0
- package/src/governance/operation-artifact-io.ts +103 -0
- package/src/governance/operation-artifact-scan.ts +77 -0
- package/src/governance/operation-artifacts.ts +363 -0
- package/src/governance/runtime-settlement.ts +28 -0
- package/src/governance/workspace-acceptance.ts +18 -0
- package/src/index.ts +13 -0
- package/src/kernel/dashboard-observation.ts +109 -0
- package/src/kernel/dispatch-operation.ts +2 -0
- package/src/kernel/initiative.ts +126 -0
- package/src/kernel/operation-artifact.ts +46 -0
- package/src/kernel/principal-binding.ts +104 -0
- package/src/kernel/project-paths.ts +16 -0
- package/src/kernel/selected-definitions.ts +5 -100
- package/src/kernel/workspace-diagnostics.ts +110 -0
- package/src/products/activity-storage.ts +128 -0
- package/src/products/activity-timeline.ts +11 -0
- package/src/products/dashboard-cli.ts +53 -10
- package/src/products/dashboard-display-controls.ts +63 -2
- package/src/products/dashboard-file-cache.ts +38 -0
- package/src/products/dashboard-layout.ts +50 -0
- package/src/products/dashboard-panels.ts +379 -0
- package/src/products/dashboard-recap.ts +48 -0
- package/src/products/dashboard-screen.ts +266 -43
- package/src/products/dashboard-session-client.ts +78 -14
- package/src/products/dashboard-settings.ts +4 -6
- package/src/products/ecosystem-versions.ts +2 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { dashboardFile, dashboardTimeline, dashboardSelectedDetail } from "./dashboard-file-cache.ts";
|
|
2
3
|
/**
|
|
3
4
|
* `pi-daddy-dashboard` — the view of one ledger or activity timeline plus session model controls.
|
|
4
5
|
*
|
|
@@ -64,6 +65,8 @@ export interface DashboardFrameOptions {
|
|
|
64
65
|
screen?: DashboardScreenState;
|
|
65
66
|
notice?: string;
|
|
66
67
|
pending?: boolean;
|
|
68
|
+
connected?: boolean;
|
|
69
|
+
acknowledgment?: string;
|
|
67
70
|
command?: string;
|
|
68
71
|
}
|
|
69
72
|
|
|
@@ -146,10 +149,21 @@ async function compactFrame(options: DashboardFrameOptions): Promise<string> {
|
|
|
146
149
|
items: [],
|
|
147
150
|
problem: "INCOMPATIBLE dashboard protocol; relink this package.",
|
|
148
151
|
});
|
|
152
|
+
if (options.screen?.view === "recap")
|
|
153
|
+
return renderDashboardScreen({
|
|
154
|
+
...options,
|
|
155
|
+
width: options.width ?? 80,
|
|
156
|
+
height: options.height!,
|
|
157
|
+
screen: options.screen,
|
|
158
|
+
items: [],
|
|
159
|
+
});
|
|
149
160
|
try {
|
|
150
|
-
const text = await readFile(path, "utf8");
|
|
161
|
+
const text = options.session?.observation ? await dashboardFile(path) : await readFile(path, "utf8");
|
|
151
162
|
if (!options.ledgerPath || isActivityTimelineText(text)) {
|
|
152
|
-
const
|
|
163
|
+
const parsed = dashboardTimeline(path, text);
|
|
164
|
+
const timeline = options.session?.observation
|
|
165
|
+
? { ...parsed, tasks: parsed.tasks.filter((task) => task.rootId === options.session!.activity?.rootId) }
|
|
166
|
+
: parsed;
|
|
153
167
|
items = activityDashboardItems(timeline, aliases, options.now ?? new Date()).map((item) => ({
|
|
154
168
|
...item,
|
|
155
169
|
timelinePath: path,
|
|
@@ -157,6 +171,22 @@ async function compactFrame(options: DashboardFrameOptions): Promise<string> {
|
|
|
157
171
|
problem = timeline.refusals[0];
|
|
158
172
|
} else {
|
|
159
173
|
const projection = parseDashboardLedger(text, { now: options.now });
|
|
174
|
+
if (options.session?.observation) {
|
|
175
|
+
const owner = options.session.observation.logicalOwnerId;
|
|
176
|
+
const admitted = new Set(
|
|
177
|
+
projection.nodes.filter((node) => owner && node.logicalParentId === owner).map((node) => node.executionId),
|
|
178
|
+
);
|
|
179
|
+
for (let pass = 0; pass < projection.nodes.length; pass++) {
|
|
180
|
+
let changed = false;
|
|
181
|
+
for (const node of projection.nodes)
|
|
182
|
+
if (node.parentExecutionId && admitted.has(node.parentExecutionId) && !admitted.has(node.executionId)) {
|
|
183
|
+
admitted.add(node.executionId);
|
|
184
|
+
changed = true;
|
|
185
|
+
}
|
|
186
|
+
if (!changed) break;
|
|
187
|
+
}
|
|
188
|
+
projection.nodes = projection.nodes.filter((node) => admitted.has(node.executionId));
|
|
189
|
+
}
|
|
160
190
|
items = ledgerDashboardItems(projection);
|
|
161
191
|
if (projection.corrupt.length) problem = `Ledger unavailable: ${projection.corrupt.length} corrupt line(s)`;
|
|
162
192
|
}
|
|
@@ -172,15 +202,22 @@ async function compactFrame(options: DashboardFrameOptions): Promise<string> {
|
|
|
172
202
|
const key = activityTaskKey(activity.rootId, activity.taskId);
|
|
173
203
|
current = `Task ${activity.taskId}`;
|
|
174
204
|
try {
|
|
175
|
-
const
|
|
176
|
-
|
|
205
|
+
const text = options.session?.observation
|
|
206
|
+
? await dashboardFile(activity.path)
|
|
207
|
+
: await readFile(activity.path, "utf8");
|
|
208
|
+
const parsed = dashboardTimeline(activity.path, text);
|
|
209
|
+
const timeline = {
|
|
210
|
+
...parsed,
|
|
211
|
+
tasks: parsed.tasks.filter((task) => activityTaskKey(task.rootId, task.id) === key),
|
|
212
|
+
};
|
|
177
213
|
const item = activityDashboardItems(timeline, aliases, options.now ?? new Date())[0];
|
|
178
214
|
if (item) {
|
|
179
215
|
current = item.label;
|
|
180
216
|
currentStatus = item.status;
|
|
181
217
|
if (!items.some((existing) => existing.key === key)) items.unshift({ ...item, timelinePath: activity.path });
|
|
182
218
|
try {
|
|
183
|
-
|
|
219
|
+
if (!options.session?.observation)
|
|
220
|
+
current = (await detailForTimeline(activity.path, key, "prompt")).text.slice(0, 600);
|
|
184
221
|
} catch {
|
|
185
222
|
/* Metadata-only/off and unavailable retained content retain the exact task identity. */
|
|
186
223
|
}
|
|
@@ -189,7 +226,7 @@ async function compactFrame(options: DashboardFrameOptions): Promise<string> {
|
|
|
189
226
|
/* The owner identity remains useful when its local timeline is unavailable. */
|
|
190
227
|
}
|
|
191
228
|
}
|
|
192
|
-
if (options.activityDetail) {
|
|
229
|
+
if (options.activityDetail && options.screen?.view === "details") {
|
|
193
230
|
try {
|
|
194
231
|
const requested = aliases.resolve(options.activityDetail.taskKey) ?? options.activityDetail.taskKey;
|
|
195
232
|
const key = items.find((value) => value.taskKey === requested)?.taskKey;
|
|
@@ -198,8 +235,10 @@ async function compactFrame(options: DashboardFrameOptions): Promise<string> {
|
|
|
198
235
|
const source = items.find((value) => value.taskKey === key)?.timelinePath;
|
|
199
236
|
if (!source) throw Error("task has no retained activity source");
|
|
200
237
|
content = {
|
|
201
|
-
title: `PRIVATE ${options.activityDetail.field.toUpperCase()}`,
|
|
202
|
-
text:
|
|
238
|
+
title: `PRIVATE ${options.activityDetail.field.toUpperCase()} · selected snapshot`,
|
|
239
|
+
text: options.session?.observation
|
|
240
|
+
? (await dashboardSelectedDetail(options.activityDetail, source, key)).text
|
|
241
|
+
: (await detailForTimeline(source, key, options.activityDetail.field)).text,
|
|
203
242
|
};
|
|
204
243
|
} catch (error) {
|
|
205
244
|
problem = `Activity detail unavailable: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -328,7 +367,11 @@ export async function runDashboard(argv = process.argv.slice(2), env: NodeJS.Pro
|
|
|
328
367
|
width: process.stdout.columns || 80,
|
|
329
368
|
...display.state,
|
|
330
369
|
activityAliases: display.aliases,
|
|
331
|
-
session: connection.state.snapshot,
|
|
370
|
+
session: connection.state.snapshot ?? connection.state.lastObserved,
|
|
371
|
+
connected: Boolean(connection.state.snapshot),
|
|
372
|
+
acknowledgment: connection.state.acknowledgment
|
|
373
|
+
? `${connection.state.acknowledgment.action}: ${connection.state.acknowledgment.state} · ${connection.state.acknowledgment.effect}`
|
|
374
|
+
: undefined,
|
|
332
375
|
...(interactive
|
|
333
376
|
? {
|
|
334
377
|
height: process.stdout.rows || 24,
|
|
@@ -414,7 +457,7 @@ export async function runDashboard(argv = process.argv.slice(2), env: NodeJS.Pro
|
|
|
414
457
|
let action = display.key(
|
|
415
458
|
key.name === "return"
|
|
416
459
|
? "return"
|
|
417
|
-
: ["up", "down", "escape", "tab"].includes(key.name || "")
|
|
460
|
+
: ["up", "down", "pageup", "pagedown", "escape", "tab"].includes(key.name || "")
|
|
418
461
|
? key.name!
|
|
419
462
|
: text || "",
|
|
420
463
|
);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DASHBOARD_DESTINATIONS } from "./dashboard-panels.ts";
|
|
1
2
|
import { DASHBOARD_SETTING_KEYS } from "./dashboard-settings.ts";
|
|
2
3
|
/** Local display controls; these never dispatch actions to an owner or change ledger state. */
|
|
3
4
|
import { dashboardScreenState } from "./dashboard-screen.ts";
|
|
@@ -14,26 +15,82 @@ export function createDashboardDisplayControls(details: boolean, ledger: boolean
|
|
|
14
15
|
const aliases = new ActivityTimelineAliases();
|
|
15
16
|
const screen = dashboardScreenState();
|
|
16
17
|
if (details) screen.view = "details";
|
|
18
|
+
let returnFromReading: Pick<typeof screen, "view" | "offset" | "manualScroll" | "selectedKey"> | undefined;
|
|
17
19
|
return {
|
|
18
20
|
state,
|
|
19
21
|
screen,
|
|
20
22
|
key(key: string): "auto" | "quit" | "command" | "setting" | undefined {
|
|
23
|
+
if (key === "?" || key === "r") {
|
|
24
|
+
const reading = key === "?" ? "help" : "recap";
|
|
25
|
+
if (screen.view === reading) key = "escape";
|
|
26
|
+
else {
|
|
27
|
+
returnFromReading ??= {
|
|
28
|
+
view: screen.view,
|
|
29
|
+
offset: screen.offset,
|
|
30
|
+
manualScroll: screen.manualScroll,
|
|
31
|
+
selectedKey: screen.selectedKey,
|
|
32
|
+
};
|
|
33
|
+
screen.view = reading;
|
|
34
|
+
screen.offset = 0;
|
|
35
|
+
screen.manualScroll = false;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (screen.view === "help" || screen.view === "recap") {
|
|
40
|
+
if (key === "escape" && returnFromReading) {
|
|
41
|
+
Object.assign(screen, returnFromReading);
|
|
42
|
+
returnFromReading = undefined;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (key === "return" || key === "d" || key === "tab" || key === "p" || key === "f") return;
|
|
46
|
+
if (/^[1-6mvs]$/.test(key)) returnFromReading = undefined;
|
|
47
|
+
}
|
|
48
|
+
if (/^[1-6]$/.test(key)) {
|
|
49
|
+
screen.selections ??= {};
|
|
50
|
+
if (screen.selectedKey) screen.selections[screen.destination ?? "now"] = screen.selectedKey;
|
|
51
|
+
if ((screen.destination ?? "now") !== DASHBOARD_DESTINATIONS[Number(key) - 1] && state.filter)
|
|
52
|
+
state.filter = "everything";
|
|
53
|
+
screen.destination = DASHBOARD_DESTINATIONS[Number(key) - 1];
|
|
54
|
+
screen.selectedKey = screen.selections[screen.destination!];
|
|
55
|
+
screen.view = screen.destination === "settings" ? "settings" : "main";
|
|
56
|
+
screen.offset = 0;
|
|
57
|
+
screen.manualScroll = false;
|
|
58
|
+
state.activityDetail = undefined;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (key === "pageup" || key === "pagedown") {
|
|
62
|
+
screen.manualScroll = true;
|
|
63
|
+
screen.offset = Math.max(0, screen.offset + (key === "pageup" ? -8 : 8));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (key === "x") {
|
|
67
|
+
if (screen.view === "details") {
|
|
68
|
+
screen.sourceDetails = !screen.sourceDetails;
|
|
69
|
+
screen.offset = 0;
|
|
70
|
+
} else if (screen.view === "main") screen.expanded = !screen.expanded;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
21
73
|
if (key === "a") return "auto";
|
|
22
74
|
if (key === "q" || key === "ctrl-c") return "quit";
|
|
23
75
|
if (key === ":") return "command";
|
|
24
76
|
if (screen.view === "settings" && (key === "return" || key === "d")) return "setting";
|
|
25
77
|
if (key === "escape") {
|
|
26
78
|
screen.view = screen.view === "version-details" ? "versions" : "main";
|
|
79
|
+
if (screen.view === "main" && screen.destination === "settings") screen.destination = "now";
|
|
27
80
|
state.activityDetail = undefined;
|
|
28
81
|
screen.offset = 0;
|
|
29
|
-
} else if (key === "
|
|
30
|
-
screen.view = key === "
|
|
82
|
+
} else if (key === "m" || key === "v" || key === "s") {
|
|
83
|
+
screen.view = key === "v" ? "versions" : key === "s" ? "settings" : "models";
|
|
84
|
+
if (key === "s") screen.destination = "settings";
|
|
31
85
|
state.activityDetail = undefined;
|
|
32
86
|
screen.offset = 0;
|
|
33
87
|
} else if (key === "return" || key === "d") {
|
|
88
|
+
if (screen.view !== "versions" && (screen.view !== "main" || !screen.selectedKey)) return;
|
|
34
89
|
screen.view = screen.view === "versions" ? "version-details" : "details";
|
|
90
|
+
screen.sourceDetails = false;
|
|
35
91
|
screen.offset = 0;
|
|
36
92
|
} else if (["up", "down", "j", "k"].includes(key)) {
|
|
93
|
+
screen.manualScroll = false;
|
|
37
94
|
const delta = key === "up" || key === "k" ? -1 : 1;
|
|
38
95
|
if (screen.view === "settings") {
|
|
39
96
|
const index = DASHBOARD_SETTING_KEYS.indexOf(screen.settingKey ?? "auto");
|
|
@@ -53,8 +110,12 @@ export function createDashboardDisplayControls(details: boolean, ledger: boolean
|
|
|
53
110
|
state.activityDetail = undefined;
|
|
54
111
|
}
|
|
55
112
|
} else if (key === "tab") {
|
|
113
|
+
screen.selections ??= {};
|
|
114
|
+
if (screen.selectedKey)
|
|
115
|
+
screen.selections[`${screen.destination ?? "now"}:${state.filter ?? "everything"}`] = screen.selectedKey;
|
|
56
116
|
const filters = ["everything", "agents", "skills", "needs-you"] as const;
|
|
57
117
|
state.filter = filters[(filters.indexOf(state.filter ?? "everything") + 1) % filters.length];
|
|
118
|
+
screen.selectedKey = screen.selections[`${screen.destination ?? "now"}:${state.filter}`];
|
|
58
119
|
screen.view = "main";
|
|
59
120
|
state.activityDetail = undefined;
|
|
60
121
|
} else if (key === "p" || key === "f") {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Small display cache: bounded metadata reads, no filesystem traversal or durable writes. */
|
|
2
|
+
import { stat } from "node:fs/promises";
|
|
3
|
+
import { readBoundedTextSync } from "../kernel/bounded-read-sync.ts";
|
|
4
|
+
import { parseActivityTimeline, detailForTimeline } from "./activity-timeline.ts";
|
|
5
|
+
const MAX_BYTES = 2 * 1024 * 1024;
|
|
6
|
+
const files = new Map<
|
|
7
|
+
string,
|
|
8
|
+
{ checked: number; identity: string; text: string; timeline?: ReturnType<typeof parseActivityTimeline> }
|
|
9
|
+
>();
|
|
10
|
+
export async function dashboardFile(path: string, now = Date.now()): Promise<string> {
|
|
11
|
+
const cached = files.get(path);
|
|
12
|
+
if (cached && now - cached.checked < 1000) return cached.text;
|
|
13
|
+
const s = await stat(path);
|
|
14
|
+
if (!s.isFile() || s.size > MAX_BYTES)
|
|
15
|
+
throw Error("Dashboard metadata file unavailable or exceeds 2 MiB; no full-history restore");
|
|
16
|
+
const identity = `${s.dev}:${s.ino}:${s.size}:${s.mtimeMs}:${s.ctimeMs}`;
|
|
17
|
+
if (cached?.identity === identity) {
|
|
18
|
+
cached.checked = now;
|
|
19
|
+
return cached.text;
|
|
20
|
+
}
|
|
21
|
+
const text = readBoundedTextSync(path, { maxBytes: MAX_BYTES }).text;
|
|
22
|
+
files.set(path, { checked: now, identity, text });
|
|
23
|
+
while (files.size > 4) files.delete(files.keys().next().value!);
|
|
24
|
+
return text;
|
|
25
|
+
}
|
|
26
|
+
export function dashboardTimeline(path: string, text: string) {
|
|
27
|
+
const cached = files.get(path);
|
|
28
|
+
if (cached?.text === text) return (cached.timeline ??= parseActivityTimeline(text));
|
|
29
|
+
return parseActivityTimeline(text);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// One explicit selection, read once. A fresh p/f selection obtains a new checked snapshot.
|
|
33
|
+
let detail: { selection: object; source: string; key: string; value: ReturnType<typeof detailForTimeline> } | undefined;
|
|
34
|
+
export function dashboardSelectedDetail(selection: { field: "prompt" | "final" }, source: string, key: string) {
|
|
35
|
+
if (detail?.selection !== selection || detail.source !== source || detail.key !== key)
|
|
36
|
+
detail = { selection, source, key, value: detailForTimeline(source, key, selection.field) };
|
|
37
|
+
return detail.value;
|
|
38
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { cellWidth, truncate } from "./dashboard-render.ts";
|
|
2
|
+
|
|
3
|
+
/** Keep related content together on wide terminals without filling the entire row with decoration. */
|
|
4
|
+
export function sectionHeading(title: string, width: number): string {
|
|
5
|
+
const remaining = Math.min(width, 100) - cellWidth(title) - 2;
|
|
6
|
+
return remaining >= 3 ? title + " " + "─".repeat(remaining) : truncate(title, width);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function previewWidth(destination: string, expanded: boolean, width: number): number | undefined {
|
|
10
|
+
if (width < 96 || (!expanded && (width < 110 || !["now", "work", "reviews"].includes(destination)))) return;
|
|
11
|
+
return Math.min(56, Math.floor(width * 0.45));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const sgr = (value: string, code: string) => (value ? `\x1b[${code}m${value}\x1b[0m` : "");
|
|
15
|
+
|
|
16
|
+
/** Apply terminal styles only to already-sanitized and measured display text. */
|
|
17
|
+
export function colorSessionLine(line: string, role: "header" | "navigation" | "footer" | "body"): string {
|
|
18
|
+
if (role === "header") {
|
|
19
|
+
const parts = /^(PI DADDY)(.*?)( · Connected)?$/.exec(line);
|
|
20
|
+
return parts ? sgr(parts[1]!, "1;36") + parts[2] + sgr(parts[3] ?? "", "32") : line;
|
|
21
|
+
}
|
|
22
|
+
if (role === "navigation")
|
|
23
|
+
return line.includes("[") ? line.replace(/\[[^\]]+\]/, (s) => sgr(s, "1;7")) : sgr(line, "1");
|
|
24
|
+
if (role === "footer")
|
|
25
|
+
return line.replace(
|
|
26
|
+
/(^| · )(↑↓|Enter|Esc|PgUp\/PgDn|1–6|[?rqxpfs])/g,
|
|
27
|
+
(_, space: string, key: string) => space + sgr(key, "1;36"),
|
|
28
|
+
);
|
|
29
|
+
const divider = line.indexOf(" │ ");
|
|
30
|
+
if (divider >= 0) return paintCell(line.slice(0, divider)) + sgr(" │ ", "36") + paintCell(line.slice(divider + 3));
|
|
31
|
+
return paintCell(line);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function paintCell(cell: string): string {
|
|
35
|
+
const text = cell.trimEnd();
|
|
36
|
+
const padding = cell.slice(text.length);
|
|
37
|
+
if (text.startsWith("> ")) return sgr(text, "1;7") + padding;
|
|
38
|
+
const rule = /^(.*?) (─{3,})$/.exec(text);
|
|
39
|
+
if (rule) {
|
|
40
|
+
const title = rule[1]!;
|
|
41
|
+
const attention =
|
|
42
|
+
/^(?:SESSION PRIORITY|YOUR DECISIONS|PERMISSION REQUESTS|NEXT ACTION|NEEDS ATTENTION|AWAITING REVIEW)/.test(
|
|
43
|
+
title,
|
|
44
|
+
);
|
|
45
|
+
return sgr(title, attention ? "1;33" : "1;36") + " " + sgr(rule[2]!, "36") + padding;
|
|
46
|
+
}
|
|
47
|
+
if (text === "/bookie-work review") return sgr(text, "1;36") + padding;
|
|
48
|
+
if (/^(?:!|LAST OBSERVED|Disconnected)/.test(text)) return sgr(text, "1;33") + padding;
|
|
49
|
+
return cell;
|
|
50
|
+
}
|