tickmarkr 1.81.0 → 1.83.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 (49) hide show
  1. package/README.md +4 -4
  2. package/dist/brand.d.ts +4 -1
  3. package/dist/brand.js +46 -7
  4. package/dist/cli/commands/approve.js +53 -8
  5. package/dist/cli/commands/plan.js +17 -2
  6. package/dist/cli/commands/report.js +15 -6
  7. package/dist/cli/commands/ui.js +13 -1
  8. package/dist/cli/index.d.ts +1 -1
  9. package/dist/cli/index.js +1 -1
  10. package/dist/compile/collateral.d.ts +19 -0
  11. package/dist/compile/collateral.js +90 -0
  12. package/dist/compile/index.js +18 -4
  13. package/dist/drivers/herdr.d.ts +1 -0
  14. package/dist/drivers/herdr.js +19 -0
  15. package/dist/drivers/types.d.ts +1 -0
  16. package/dist/gates/acceptance.js +50 -8
  17. package/dist/gates/llm.js +34 -19
  18. package/dist/gates/review.d.ts +9 -1
  19. package/dist/gates/review.js +173 -7
  20. package/dist/gates/run-gates.d.ts +1 -0
  21. package/dist/gates/run-gates.js +18 -1
  22. package/dist/report/bundle.d.ts +6 -1
  23. package/dist/report/bundle.js +13 -3
  24. package/dist/run/daemon.d.ts +5 -0
  25. package/dist/run/daemon.js +188 -27
  26. package/dist/run/journal.d.ts +5 -0
  27. package/dist/run/journal.js +71 -1
  28. package/dist/tui/cockpit/capture.d.ts +107 -1
  29. package/dist/tui/cockpit/capture.js +287 -10
  30. package/dist/tui/cockpit/components.d.ts +12 -46
  31. package/dist/tui/cockpit/components.js +48 -48
  32. package/dist/tui/cockpit/derive.d.ts +73 -1
  33. package/dist/tui/cockpit/derive.js +211 -15
  34. package/dist/tui/cockpit/keys.d.ts +114 -19
  35. package/dist/tui/cockpit/keys.js +413 -44
  36. package/dist/tui/cockpit/layout.d.ts +162 -0
  37. package/dist/tui/cockpit/layout.js +229 -0
  38. package/dist/tui/cockpit/live.d.ts +52 -3
  39. package/dist/tui/cockpit/live.js +216 -40
  40. package/dist/tui/cockpit/run-cockpit.d.ts +64 -8
  41. package/dist/tui/cockpit/run-cockpit.js +686 -163
  42. package/dist/tui/cockpit/setup-cockpit.d.ts +146 -1
  43. package/dist/tui/cockpit/setup-cockpit.js +337 -5
  44. package/dist/tui/cockpit/views.d.ts +72 -0
  45. package/dist/tui/cockpit/views.js +56 -0
  46. package/dist/tui/cockpit/width.d.ts +105 -0
  47. package/dist/tui/cockpit/width.js +276 -0
  48. package/fixtures/speckit-sample/tasks.md +2 -2
  49. package/package.json +3 -1
@@ -72,5 +72,167 @@ export interface PlainCockpitLayout {
72
72
  arrangement: "plain";
73
73
  }
74
74
  export type CockpitLayout = FrameCockpitLayout | PlainCockpitLayout;
75
+ export interface MeasuredSize {
76
+ columns: number;
77
+ rows: number;
78
+ }
79
+ /** The five sidebar views, in jump-key order (1–5). */
80
+ export declare const FRAME_VIEWS: readonly ["run", "tasks", "gates", "journal", "fleet"];
81
+ export type FrameView = (typeof FRAME_VIEWS)[number];
82
+ export type FrameTab = "watch" | "setup";
83
+ export interface FrameState {
84
+ /** Active top-level tab; SETUP turns the journal tail into PENDING WRITES. */
85
+ tab?: FrameTab;
86
+ /** A row's full detail is open in the body (sidebar and tail stay). */
87
+ detail?: boolean;
88
+ /** Header caption, pre-measured in terminal cells by the caller. */
89
+ captionCells?: number;
90
+ }
91
+ export declare const FRAME_WIDTH_FLOOR = 40;
92
+ export declare const FRAME_HEIGHT_FLOOR = 14;
93
+ export declare const SIDEBAR_COLUMN_FLOOR = 64;
94
+ export declare const RAIL_COLUMNS = 15;
95
+ export declare const STANDARD_TAIL_HEIGHT = 16;
96
+ export declare const FULL_TAIL_HEIGHT = 24;
97
+ export declare const TAIL_STANDARD_ROWS = 1;
98
+ export declare const TAIL_FULL_ROWS = 3;
99
+ /**
100
+ * The header's fixed parts beside the caption — brand and version, then the
101
+ * two tab labels — joined by the contracted gap. Composed from named parts so
102
+ * a header change moves the caption fit check with it; the suite pins the
103
+ * composed text so an unreviewed header change fails a test. Measured in
104
+ * display cells by the cockpit's width authority, never String length.
105
+ */
106
+ export declare const FRAME_HEADER_PARTS: readonly ["tickmarkr 1.83.0", "[ WATCH ]", "SETUP"];
107
+ export declare const FRAME_HEADER_GAP = " ";
108
+ export declare const HEADER_FIXED_CELLS: number;
109
+ /** Every (columns, rows) pair the sweep holds the plan to. */
110
+ export declare const FRAME_CONTRACT_DOMAIN: {
111
+ readonly minColumns: 40;
112
+ readonly maxColumns: 220;
113
+ readonly minRows: 14;
114
+ readonly maxRows: 50;
115
+ };
116
+ /** The fixed order in which the fit check surrenders regions, first to last. */
117
+ export declare const FRAME_SURRENDER_ORDER: readonly ["caption", "tail"];
118
+ export type SurrenderedRegionId = (typeof FRAME_SURRENDER_ORDER)[number];
119
+ export interface FrameFit {
120
+ columns: number;
121
+ tailRows: number;
122
+ captionCells: number;
123
+ }
124
+ /**
125
+ * The fit predicate for each surrenderable region. The fit check walks
126
+ * FRAME_SURRENDER_ORDER and applies these predicates, so the constant is the
127
+ * ordering decision — not a comment about one.
128
+ */
129
+ export declare const FRAME_SURRENDER_FIT: Readonly<Record<SurrenderedRegionId, (fit: FrameFit) => boolean>>;
130
+ export type FrameRegionId = "header" | "rule" | "strip" | "rail" | "body" | "rule2" | "tail" | "status" | "keybar" | "caption";
131
+ /** The vitals elements in block order, top first; a short rail surrenders from the top, so the meter is the last to go. */
132
+ export declare const SIDEBAR_VITALS_ORDER: readonly ["tasks", "gates", "meter"];
133
+ export type SidebarVitalsElement = (typeof SIDEBAR_VITALS_ORDER)[number];
134
+ /** The rail rows at and above which the menu carries its label row. */
135
+ export declare const SIDEBAR_MENU_LABEL_ROWS = 10;
136
+ /** Rows one vitals element occupies in each mode: label plus sparkline, or one inline row. */
137
+ export declare const SIDEBAR_VITALS_FULL_ELEMENT_ROWS = 2;
138
+ export declare const SIDEBAR_VITALS_COMPACT_ELEMENT_ROWS = 1;
139
+ export interface SidebarPlan {
140
+ /** Rows the menu block occupies at the rail's top: the five views, plus the label row when it fits. */
141
+ menuRows: number;
142
+ /**
143
+ * Blank rows between the last menu row and the first vitals row. Never zero
144
+ * while any vitals element draws — a short rail surrenders whole vitals
145
+ * elements rather than closing the gap.
146
+ */
147
+ gapRows: number;
148
+ /** Two rows per element, or one when the rail cannot pay for the full block. */
149
+ vitalsMode: "full" | "compact";
150
+ /** The vitals elements that draw, top to bottom, anchored to the rail's bottom. */
151
+ vitals: readonly SidebarVitalsElement[];
152
+ }
153
+ /**
154
+ * Compose the sidebar band for a rail of `railRows` rows — pure. The menu sits
155
+ * at the top; the vitals block sits at the bottom; the gap between them absorbs
156
+ * every surplus row and is never traded away: what remains after the menu and
157
+ * one gap row is the vitals budget, spent on the full two-row block when it
158
+ * fits whole, else on the one-row elements, surrendered from the top of the
159
+ * block with the meter surrendered last. An element draws whole or not at all.
160
+ */
161
+ export declare function planSidebar(railRows: number): SidebarPlan;
162
+ export interface FrameRegion {
163
+ id: FrameRegionId;
164
+ row: number;
165
+ rows: number;
166
+ column: number;
167
+ columns: number;
168
+ }
169
+ export interface FrameBandContent {
170
+ /** Body band: view rows, an open row detail, or the full-height journal tail. */
171
+ body: "rows" | "detail" | "journal";
172
+ /** Tail band: the compact journal tail, or PENDING WRITES on the SETUP tab. */
173
+ tail: "journal" | "pending-writes";
174
+ }
175
+ export interface PlannedFrame {
176
+ kind: "frame";
177
+ size: MeasuredSize;
178
+ view: FrameView;
179
+ tab: FrameTab;
180
+ band: "strip" | "sidebar";
181
+ /** What the view and state draw into each flexible band. */
182
+ content: FrameBandContent;
183
+ regions: readonly FrameRegion[];
184
+ /**
185
+ * Row bands, top to bottom; their spans tile the height exactly. A band
186
+ * map: the nested caption sub-region is deliberately excluded.
187
+ */
188
+ rowSpans: Readonly<Record<string, number>>;
189
+ /**
190
+ * Column bands of the body band; their spans tile the width exactly. A
191
+ * band map: the nested caption sub-region is deliberately excluded.
192
+ */
193
+ columnSpans: Readonly<Record<string, number>>;
194
+ /** The single surplus-absorbing element on each axis. */
195
+ flexible: {
196
+ readonly row: "body";
197
+ readonly column: "body";
198
+ };
199
+ /**
200
+ * The rail band's composition — menu, gap and vitals — planned when the
201
+ * band is the sidebar, null on the strip band. The renderer draws it
202
+ * unmodified.
203
+ */
204
+ sidebar: SidebarPlan | null;
205
+ /** Regions the fit check surrendered, in FRAME_SURRENDER_ORDER. */
206
+ surrendered: readonly SurrenderedRegionId[];
207
+ }
208
+ export interface PlainFallbackPlan {
209
+ kind: "plain";
210
+ size: MeasuredSize;
211
+ }
212
+ export type FramePlan = PlannedFrame | PlainFallbackPlan;
213
+ /**
214
+ * Plan the frame for a measured size, a view and a state — pure: no
215
+ * rendering, no I/O, no read of the live terminal. Below either floor the
216
+ * plan is the plain fallback. Otherwise the frame is row bands that tile the
217
+ * height exactly — header, rule, the view strip (40–63 columns), the body
218
+ * band, a second rule, the journal tail surrendered whole by height tier,
219
+ * status, keybar — and, at ≥64 columns, column bands that tile the width
220
+ * exactly: the constant 15-column rail beside the body. The body is the sole
221
+ * flexible element on both axes. The view and state decide what the flexible
222
+ * bands draw (the Journal view is the full-height tail; SETUP turns the tail
223
+ * into PENDING WRITES; an open detail owns the body) without moving any
224
+ * span. The caption is a nested sub-region sharing row 0 with the header
225
+ * band, so cells on that row are owned by the header band and refinable by
226
+ * the caption; it is surrendered first when it does not fit beside the fixed
227
+ * header text, never squeezed to a zero or negative span. On the sidebar band
228
+ * the plan also owns the rail's composition: the menu at the top, the vitals
229
+ * anchored to the bottom, and at least one blank row between them whenever
230
+ * both draw — a too-short rail surrenders whole vitals elements from the top
231
+ * of the block, the meter last, rather than closing the gap. rowSpans and
232
+ * columnSpans are band maps: they deliberately exclude the nested caption,
233
+ * and column bands are reported for the body band only, so each map's spans
234
+ * sum to the full height and width respectively.
235
+ */
236
+ export declare function planFrame(size: MeasuredSize, view?: FrameView, state?: FrameState): FramePlan;
75
237
  export declare function resolveCockpitLayout(columns: number, rows: number): CockpitLayout;
76
238
  export {};
@@ -1,3 +1,4 @@
1
+ import { cellWidth } from "./width.js";
1
2
  export const COCKPIT_ROW_FLOOR = 14;
2
3
  export const COCKPIT_COLUMN_FLOOR = 40;
3
4
  export const FULL_JOURNAL_ROWS = 3;
@@ -50,6 +51,234 @@ function allocateRows(rows) {
50
51
  allocation.journal += available;
51
52
  return allocation;
52
53
  }
54
+ /** The five sidebar views, in jump-key order (1–5). */
55
+ export const FRAME_VIEWS = ["run", "tasks", "gates", "journal", "fleet"];
56
+ export const FRAME_WIDTH_FLOOR = COCKPIT_COLUMN_FLOOR;
57
+ export const FRAME_HEIGHT_FLOOR = COCKPIT_ROW_FLOOR;
58
+ export const SIDEBAR_COLUMN_FLOOR = 64;
59
+ export const RAIL_COLUMNS = 15;
60
+ export const STANDARD_TAIL_HEIGHT = 16;
61
+ export const FULL_TAIL_HEIGHT = 24;
62
+ export const TAIL_STANDARD_ROWS = 1;
63
+ export const TAIL_FULL_ROWS = FULL_JOURNAL_ROWS;
64
+ /**
65
+ * The header's fixed parts beside the caption — brand and version, then the
66
+ * two tab labels — joined by the contracted gap. Composed from named parts so
67
+ * a header change moves the caption fit check with it; the suite pins the
68
+ * composed text so an unreviewed header change fails a test. Measured in
69
+ * display cells by the cockpit's width authority, never String length.
70
+ */
71
+ export const FRAME_HEADER_PARTS = [
72
+ "tickmarkr 1.83.0",
73
+ "[ WATCH ]",
74
+ "SETUP",
75
+ ];
76
+ export const FRAME_HEADER_GAP = " ";
77
+ export const HEADER_FIXED_CELLS = cellWidth(FRAME_HEADER_PARTS.join(FRAME_HEADER_GAP));
78
+ /** Every (columns, rows) pair the sweep holds the plan to. */
79
+ export const FRAME_CONTRACT_DOMAIN = {
80
+ minColumns: 40,
81
+ maxColumns: 220,
82
+ minRows: 14,
83
+ maxRows: 50,
84
+ };
85
+ /** The fixed order in which the fit check surrenders regions, first to last. */
86
+ export const FRAME_SURRENDER_ORDER = ["caption", "tail"];
87
+ /**
88
+ * The fit predicate for each surrenderable region. The fit check walks
89
+ * FRAME_SURRENDER_ORDER and applies these predicates, so the constant is the
90
+ * ordering decision — not a comment about one.
91
+ */
92
+ export const FRAME_SURRENDER_FIT = {
93
+ caption: ({ captionCells, columns }) => captionCells >= 1 && captionCells <= columns - HEADER_FIXED_CELLS,
94
+ tail: ({ tailRows }) => tailRows > 0,
95
+ };
96
+ /* ------------------------------------------------------------------ */
97
+ /* The sidebar band's composition: the menu at the rail's top, the */
98
+ /* vitals anchored to the rail's bottom, and at least one blank row */
99
+ /* between them whenever both draw. The plan owns this geometry; the */
100
+ /* band composition draws it unmodified. */
101
+ /* ------------------------------------------------------------------ */
102
+ /** The vitals elements in block order, top first; a short rail surrenders from the top, so the meter is the last to go. */
103
+ export const SIDEBAR_VITALS_ORDER = ["tasks", "gates", "meter"];
104
+ /** The rail rows at and above which the menu carries its label row. */
105
+ export const SIDEBAR_MENU_LABEL_ROWS = 10;
106
+ /** Rows one vitals element occupies in each mode: label plus sparkline, or one inline row. */
107
+ export const SIDEBAR_VITALS_FULL_ELEMENT_ROWS = 2;
108
+ export const SIDEBAR_VITALS_COMPACT_ELEMENT_ROWS = 1;
109
+ /**
110
+ * Compose the sidebar band for a rail of `railRows` rows — pure. The menu sits
111
+ * at the top; the vitals block sits at the bottom; the gap between them absorbs
112
+ * every surplus row and is never traded away: what remains after the menu and
113
+ * one gap row is the vitals budget, spent on the full two-row block when it
114
+ * fits whole, else on the one-row elements, surrendered from the top of the
115
+ * block with the meter surrendered last. An element draws whole or not at all.
116
+ */
117
+ export function planSidebar(railRows) {
118
+ const menuRows = railRows >= SIDEBAR_MENU_LABEL_ROWS
119
+ ? 1 + FRAME_VIEWS.length
120
+ : FRAME_VIEWS.length;
121
+ const fullRows = SIDEBAR_VITALS_ORDER.length * SIDEBAR_VITALS_FULL_ELEMENT_ROWS;
122
+ // The gap is funded before the vitals are: the budget is what remains after it.
123
+ const budget = railRows - menuRows - 1;
124
+ if (budget >= fullRows) {
125
+ return {
126
+ menuRows,
127
+ gapRows: railRows - menuRows - fullRows,
128
+ vitalsMode: "full",
129
+ vitals: SIDEBAR_VITALS_ORDER,
130
+ };
131
+ }
132
+ const kept = Math.max(0, Math.min(SIDEBAR_VITALS_ORDER.length, Math.floor(budget)));
133
+ return {
134
+ menuRows,
135
+ gapRows: kept > 0 ? railRows - menuRows - kept : 0,
136
+ vitalsMode: "compact",
137
+ vitals: SIDEBAR_VITALS_ORDER.slice(SIDEBAR_VITALS_ORDER.length - kept),
138
+ };
139
+ }
140
+ function tailRowsFor(rows) {
141
+ if (rows >= FULL_TAIL_HEIGHT)
142
+ return TAIL_FULL_ROWS;
143
+ if (rows >= STANDARD_TAIL_HEIGHT)
144
+ return TAIL_STANDARD_ROWS;
145
+ return 0;
146
+ }
147
+ /**
148
+ * Plan the frame for a measured size, a view and a state — pure: no
149
+ * rendering, no I/O, no read of the live terminal. Below either floor the
150
+ * plan is the plain fallback. Otherwise the frame is row bands that tile the
151
+ * height exactly — header, rule, the view strip (40–63 columns), the body
152
+ * band, a second rule, the journal tail surrendered whole by height tier,
153
+ * status, keybar — and, at ≥64 columns, column bands that tile the width
154
+ * exactly: the constant 15-column rail beside the body. The body is the sole
155
+ * flexible element on both axes. The view and state decide what the flexible
156
+ * bands draw (the Journal view is the full-height tail; SETUP turns the tail
157
+ * into PENDING WRITES; an open detail owns the body) without moving any
158
+ * span. The caption is a nested sub-region sharing row 0 with the header
159
+ * band, so cells on that row are owned by the header band and refinable by
160
+ * the caption; it is surrendered first when it does not fit beside the fixed
161
+ * header text, never squeezed to a zero or negative span. On the sidebar band
162
+ * the plan also owns the rail's composition: the menu at the top, the vitals
163
+ * anchored to the bottom, and at least one blank row between them whenever
164
+ * both draw — a too-short rail surrenders whole vitals elements from the top
165
+ * of the block, the meter last, rather than closing the gap. rowSpans and
166
+ * columnSpans are band maps: they deliberately exclude the nested caption,
167
+ * and column bands are reported for the body band only, so each map's spans
168
+ * sum to the full height and width respectively.
169
+ */
170
+ export function planFrame(size, view = "tasks", state = {}) {
171
+ const columns = Math.floor(size.columns);
172
+ const rows = Math.floor(size.rows);
173
+ if (!Number.isFinite(columns) ||
174
+ !Number.isFinite(rows) ||
175
+ columns < FRAME_WIDTH_FLOOR ||
176
+ rows < FRAME_HEIGHT_FLOOR) {
177
+ return { kind: "plain", size: { columns, rows } };
178
+ }
179
+ const tab = state.tab ?? "watch";
180
+ const band = columns >= SIDEBAR_COLUMN_FLOOR ? "sidebar" : "strip";
181
+ const stripRows = band === "strip" ? 1 : 0;
182
+ const tailRows = tailRowsFor(rows);
183
+ // Fixed chrome is five rows: header, rule, a second rule below the body
184
+ // band, status and keybar.
185
+ const bodyRows = rows - (5 + stripRows + tailRows);
186
+ const fit = {
187
+ columns,
188
+ tailRows,
189
+ captionCells: state.captionCells ?? 0,
190
+ };
191
+ // The fit check walks the declared order; the constant is what orders the
192
+ // surrender decisions.
193
+ const surrendered = FRAME_SURRENDER_ORDER.filter((id) => !FRAME_SURRENDER_FIT[id](fit));
194
+ const captionFits = FRAME_SURRENDER_FIT.caption(fit);
195
+ const captionCells = fit.captionCells;
196
+ const regions = [];
197
+ let row = 0;
198
+ regions.push({ id: "header", row, rows: 1, column: 0, columns });
199
+ row += 1;
200
+ regions.push({ id: "rule", row, rows: 1, column: 0, columns });
201
+ row += 1;
202
+ if (stripRows > 0) {
203
+ regions.push({ id: "strip", row, rows: stripRows, column: 0, columns });
204
+ row += stripRows;
205
+ }
206
+ const bodyRow = row;
207
+ row += bodyRows;
208
+ regions.push({ id: "rule2", row, rows: 1, column: 0, columns });
209
+ row += 1;
210
+ if (tailRows > 0) {
211
+ regions.push({ id: "tail", row, rows: tailRows, column: 0, columns });
212
+ row += tailRows;
213
+ }
214
+ regions.push({ id: "status", row, rows: 1, column: 0, columns });
215
+ row += 1;
216
+ regions.push({ id: "keybar", row, rows: 1, column: 0, columns });
217
+ row += 1;
218
+ if (band === "sidebar") {
219
+ regions.push({
220
+ id: "rail",
221
+ row: bodyRow,
222
+ rows: bodyRows,
223
+ column: 0,
224
+ columns: RAIL_COLUMNS,
225
+ });
226
+ regions.push({
227
+ id: "body",
228
+ row: bodyRow,
229
+ rows: bodyRows,
230
+ column: RAIL_COLUMNS,
231
+ columns: columns - RAIL_COLUMNS,
232
+ });
233
+ }
234
+ else {
235
+ regions.push({
236
+ id: "body",
237
+ row: bodyRow,
238
+ rows: bodyRows,
239
+ column: 0,
240
+ columns,
241
+ });
242
+ }
243
+ if (captionFits) {
244
+ regions.push({
245
+ id: "caption",
246
+ row: 0,
247
+ rows: 1,
248
+ column: columns - captionCells,
249
+ columns: captionCells,
250
+ });
251
+ }
252
+ const rowSpans = { header: 1, rule: 1 };
253
+ if (stripRows > 0)
254
+ rowSpans.strip = stripRows;
255
+ rowSpans.body = bodyRows;
256
+ rowSpans.rule2 = 1;
257
+ if (tailRows > 0)
258
+ rowSpans.tail = tailRows;
259
+ rowSpans.status = 1;
260
+ rowSpans.keybar = 1;
261
+ const columnSpans = band === "sidebar"
262
+ ? { rail: RAIL_COLUMNS, body: columns - RAIL_COLUMNS }
263
+ : { body: columns };
264
+ return {
265
+ kind: "frame",
266
+ size: { columns, rows },
267
+ view,
268
+ tab,
269
+ band,
270
+ content: {
271
+ body: view === "journal" ? "journal" : state.detail ? "detail" : "rows",
272
+ tail: tab === "setup" ? "pending-writes" : "journal",
273
+ },
274
+ regions,
275
+ rowSpans,
276
+ columnSpans,
277
+ flexible: { row: "body", column: "body" },
278
+ sidebar: band === "sidebar" ? planSidebar(bodyRows) : null,
279
+ surrendered,
280
+ };
281
+ }
53
282
  export function resolveCockpitLayout(columns, rows) {
54
283
  if (!Number.isFinite(columns) ||
55
284
  !Number.isFinite(rows) ||
@@ -1,4 +1,5 @@
1
- import type { RunCockpitData, RunCockpitSource } from "./derive.js";
1
+ import type { CockpitGraph, RunCockpitData, RunCockpitSource } from "./derive.js";
2
+ import { type RunInteractionState, type RunKeyEvent } from "./keys.js";
2
3
  /**
3
4
  * THE engagement selection rule — stated once, here, so it can change in one
4
5
  * place without touching the renderer or the command: an explicit engagement
@@ -11,6 +12,18 @@ export declare function selectEngagementRunId(cwd: string, explicit?: string): s
11
12
  * failure throws: the caller refuses rather than drawing from nothing.
12
13
  */
13
14
  export declare function loadEngagementSource(cwd: string, runId: string): RunCockpitSource;
15
+ /**
16
+ * The compiled graph, when the repository has one. It lends the tasks view its
17
+ * identities and nothing else, so an engagement with no compiled graph at all
18
+ * still draws every task the journal mentions rather than refusing to open.
19
+ *
20
+ * Absence is the only fallback. A graph that exists and cannot be read, parsed
21
+ * or validated is a fault, and swallowing it would quietly demote the surface:
22
+ * every task the graph alone knows about would vanish from the rows, and a
23
+ * selection standing on one of them would be cleared as if the engagement had
24
+ * dropped it. So it throws, and the caller keeps its last good frame instead.
25
+ */
26
+ export declare function loadEngagementGraph(cwd: string): CockpitGraph | undefined;
14
27
  export declare function formatEventAge(ageMs: number): string;
15
28
  /**
16
29
  * Live derivation over a real engagement's journal bytes. The header's
@@ -19,8 +32,40 @@ export declare function formatEventAge(ageMs: number): string;
19
32
  * than as current. Throws on unreadable bytes (empty capture, no run-start) —
20
33
  * the caller refuses instead of rendering a plausible surface from nothing.
21
34
  */
22
- export declare function deriveLiveRunCockpitData(source: RunCockpitSource, binaryVersion: string, now?: () => number): RunCockpitData;
23
- export declare function runLiveCockpit({ input, output, cwd, runId, binaryVersion, refreshMs, now, }: {
35
+ export declare function deriveLiveRunCockpitData(source: RunCockpitSource, binaryVersion: string, now?: () => number, graph?: CockpitGraph): RunCockpitData;
36
+ /**
37
+ * Repair the interaction state against the rows a refreshed view now owns.
38
+ * Selection is held by the row's source identity, so it survives rows landing
39
+ * above it and is dropped — never slid onto whoever inherited its index —
40
+ * when the refreshed engagement no longer carries it.
41
+ */
42
+ export declare function reconcileLiveRunInteraction(interaction: RunInteractionState, data: RunCockpitData): RunInteractionState;
43
+ /**
44
+ * The rows the live surface hands its keys — the engagement's own identities,
45
+ * minus the journal's, which are never selectable in either tab. This is the
46
+ * one place rows enter the dispatcher, so no key can reach a journal row.
47
+ */
48
+ export declare function liveRunViewRowIds(interaction: RunInteractionState, data: RunCockpitData): readonly string[];
49
+ export type LiveCockpitSurface = {
50
+ readonly data: RunCockpitData;
51
+ readonly interaction: RunInteractionState;
52
+ /** The tab waiting behind the drawn one, holding the state it was left in. */
53
+ readonly stashed: RunInteractionState;
54
+ };
55
+ /**
56
+ * The live owner's delivery boundary. A refresh is the real journal read and
57
+ * state transition used by the timer; snapshot exposes the state subsequent
58
+ * deliveries will read. Batch keeps applying transitions synchronously while
59
+ * deferring only the redraw notification, so multiple sources can be ordered
60
+ * in one turn without substituting a helper state machine for the live one.
61
+ */
62
+ export type LiveCockpitDelivery = {
63
+ readonly snapshot: () => LiveCockpitSurface;
64
+ readonly refresh: () => boolean;
65
+ readonly key: (event: RunKeyEvent, columns?: number) => boolean;
66
+ readonly batch: <Result>(deliver: () => Result) => Result;
67
+ };
68
+ export declare function runLiveCockpit({ input, output, cwd, runId, binaryVersion, refreshMs, now, debug, onDelivery, }: {
24
69
  input: NodeJS.ReadStream;
25
70
  output: NodeJS.WriteStream;
26
71
  cwd: string;
@@ -28,4 +73,8 @@ export declare function runLiveCockpit({ input, output, cwd, runId, binaryVersio
28
73
  binaryVersion: string;
29
74
  refreshMs?: number;
30
75
  now?: () => number;
76
+ /** Emit complete frames for diagnostics instead of terminal diffs. */
77
+ debug?: boolean;
78
+ /** Observe and control the production delivery boundary. */
79
+ onDelivery?: (delivery: LiveCockpitDelivery) => void;
31
80
  }): Promise<void>;