@astrosheep/keiyaku 2.9.8 → 2.9.9

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.
@@ -239,12 +239,14 @@ async function settleProjection(shared) {
239
239
  }, shared.terms.idleTimeoutMs);
240
240
  idleTimeout.unref?.();
241
241
  };
242
- executionTimeout = setTimeout(() => {
243
- policyBudgetExceeded = true;
244
- requestPolicyBudgetCleanup(shared, createAbortError(`${shared.terms.provider} execution policy budget expired`));
245
- resolvePolicyBudget();
246
- }, shared.terms.executionTimeoutMs);
247
- executionTimeout.unref?.();
242
+ if (shared.terms.executionTimeoutMs > 0) {
243
+ executionTimeout = setTimeout(() => {
244
+ policyBudgetExceeded = true;
245
+ requestPolicyBudgetCleanup(shared, createAbortError(`${shared.terms.provider} execution policy budget expired`));
246
+ resolvePolicyBudget();
247
+ }, shared.terms.executionTimeoutMs);
248
+ executionTimeout.unref?.();
249
+ }
248
250
  const requestLiveAbort = () => {
249
251
  if (shared.explicitlyAborted)
250
252
  return;
@@ -1,25 +1,82 @@
1
+ import { getConfig } from "../../config/env.js";
1
2
  import { formatAgeMs } from "./format.js";
3
+ import { displayColumns, resolveLineColumns, truncateColumns } from "./line-width.js";
4
+ import { renderPendingProjectionTell, renderProjectionActivity, selectProjectionActivityWindow, } from "./projection-activity.js";
5
+ const KANSHI_MAX_COLUMNS = 120;
6
+ const KANSHI_ACTIVITY_ROWS = 3;
2
7
  function shortHead(hash) {
3
- if (!hash)
4
- return "????????";
5
- return hash.slice(0, 7);
8
+ return hash?.slice(0, 7);
9
+ }
10
+ function supportsColor() {
11
+ const { terminal } = getConfig();
12
+ if (terminal.noColor !== undefined || terminal.forceColor === "0")
13
+ return false;
14
+ if (terminal.forceColor !== undefined)
15
+ return true;
16
+ return process.stdout.isTTY === true && terminal.term?.toLowerCase() !== "dumb";
17
+ }
18
+ function tone(text, value) {
19
+ if (!supportsColor() || value === undefined || value === "normal")
20
+ return text;
21
+ return value === "description"
22
+ ? `\x1b[2m${text}\x1b[0m`
23
+ : `\x1b[31m${text}\x1b[0m`;
24
+ }
25
+ function renderFacts(facts) {
26
+ return {
27
+ plain: facts.map((fact) => fact.text).join(" · "),
28
+ rendered: facts.map((fact) => tone(fact.text, fact.tone)).join(" · "),
29
+ };
30
+ }
31
+ /** Align facts without allowing ANSI bytes to enter width arithmetic. */
32
+ function alignedBoardRow(input) {
33
+ const facts = renderFacts(input.facts);
34
+ const prefix = `${input.prefix} `;
35
+ const titleBudget = Math.max(0, input.width - displayColumns(prefix) - displayColumns(facts.plain) - 1);
36
+ const visibleTitle = truncateColumns(input.title, titleBudget);
37
+ const spaces = " ".repeat(Math.max(1, input.width - displayColumns(prefix) - displayColumns(visibleTitle) - displayColumns(facts.plain)));
38
+ return `${prefix}${tone(visibleTitle, input.titleTone ?? "description")}${spaces}${facts.rendered}`;
6
39
  }
7
40
  function arcSparkline(arcs) {
8
- if (arcs <= 0)
9
- return "";
41
+ if (arcs <= 1)
42
+ return undefined;
10
43
  return Array.from({ length: arcs }, () => "·").join("──");
11
44
  }
12
45
  function pendingAfterIds(contract) {
13
46
  return contract.after.filter((item) => !item.terminal).map((item) => item.id);
14
47
  }
15
- function kanshiGlyph(contract) {
16
- if (contract.state.state === "corrupt")
17
- return "×";
18
- if (pendingAfterIds(contract).length > 0)
19
- return "○";
20
- if (contract.state.state === "petitioned")
21
- return "◎";
22
- return "●";
48
+ /**
49
+ * The Kanshi shape is the after DAG, not the petition/claim settlement queue.
50
+ * Stable input order settles independent lanes and any malformed cycle remains
51
+ * observable rather than dropping a contract.
52
+ */
53
+ export function orderKanshiContracts(contracts) {
54
+ const byId = new Map(contracts.map((contract) => [contract.id, contract]));
55
+ const remaining = new Set(contracts.map((contract) => contract.id));
56
+ const emitted = new Set();
57
+ const ordered = [];
58
+ while (remaining.size > 0) {
59
+ const next = contracts.find((contract) => (remaining.has(contract.id)
60
+ && pendingAfterIds(contract)
61
+ .filter((id) => byId.has(id))
62
+ .every((id) => emitted.has(id))));
63
+ if (!next) {
64
+ // The bind boundary normally rejects cycles. Keep a corrupt historical
65
+ // graph visible in its original deterministic order instead of inventing
66
+ // a dependency edge or omitting work from the board.
67
+ const fallback = contracts.find((contract) => remaining.has(contract.id));
68
+ if (!fallback)
69
+ break;
70
+ ordered.push(fallback);
71
+ emitted.add(fallback.id);
72
+ remaining.delete(fallback.id);
73
+ continue;
74
+ }
75
+ ordered.push(next);
76
+ emitted.add(next.id);
77
+ remaining.delete(next.id);
78
+ }
79
+ return ordered;
23
80
  }
24
81
  function renderDriftMark(drift) {
25
82
  if (drift.state === "drift")
@@ -28,73 +85,174 @@ function renderDriftMark(drift) {
28
85
  return "▲orphaned";
29
86
  return undefined;
30
87
  }
31
- export function renderKanshiBoard(status) {
32
- const head = shortHead(status.defaultHead);
33
- if (status.contracts.length === 0) {
34
- if (status.targetFilter !== null) {
35
- return `現世 ${head} · target selected\nno commissions on selected target\n`;
36
- }
37
- return `現世 ${head} 无在飞契约\n`;
88
+ function contractGlyph(contract) {
89
+ if (contract.state.state === "corrupt")
90
+ return "×";
91
+ return pendingAfterIds(contract).length > 0 ? "⧗" : "□";
92
+ }
93
+ function contractFacts(contract) {
94
+ const facts = [];
95
+ const spark = arcSparkline(contract.arcs);
96
+ if (spark)
97
+ facts.push({ text: spark });
98
+ const drift = renderDriftMark(contract.baseDrift);
99
+ if (drift)
100
+ facts.push({ text: drift });
101
+ const lifecycle = contract.state.state === "active" ? "open" : contract.state.state;
102
+ const age = formatAgeMs(contract.lastActiveMs);
103
+ facts.push({ text: age ? `${lifecycle} ${age}` : lifecycle });
104
+ if (contract.queueHeadStalled) {
105
+ facts.push({ text: age ? `stalled ${age}` : "stalled", tone: "alert" });
38
106
  }
39
- const header = status.targetFilter !== null
40
- ? `現世 ${head} · target selected`
41
- : `現世 ${head}`;
42
- const lines = [header, ""];
43
- for (const contract of status.contracts) {
44
- const glyph = kanshiGlyph(contract);
45
- const name = contract.place ? `${contract.slug} @${contract.place}` : contract.slug;
46
- const spark = arcSparkline(contract.arcs);
47
- const facts = [];
48
- const lifecycle = contract.state.state === "active" ? "open" : contract.state.state;
49
- if (lifecycle === "bound" || lifecycle === "open" || lifecycle === "petitioned") {
50
- facts.push(lifecycle);
51
- }
52
- const arcMark = contract.currentArc.state === "open"
53
- ? `a${contract.currentArc.number}+`
54
- : `a${contract.currentArc.number}`;
55
- facts.push(contract.title);
56
- facts.push(arcMark);
57
- facts.push(`next ${contract.nextStep.detail}`);
58
- const age = formatAgeMs(contract.lastActiveMs);
59
- if (age)
60
- facts.push(age);
61
- if (contract.queuePosition)
62
- facts.push(`Q${contract.queuePosition}`);
63
- const drift = renderDriftMark(contract.baseDrift);
64
- if (drift)
65
- facts.push(drift);
66
- if (contract.nextStep.hint)
67
- facts.push(contract.nextStep.hint);
68
- const pending = pendingAfterIds(contract);
69
- if (pending.length > 0) {
70
- facts.push(`⧗ ${pending.map((id) => {
71
- const dot = id.indexOf(".");
72
- return dot > 0 ? id.slice(0, dot) : id;
73
- }).join(",")}`);
74
- }
75
- if (contract.state.state === "corrupt") {
76
- facts.push(`corrupt (${contract.state.reason ?? contract.corruptReason ?? "unknown"})`);
77
- }
78
- if (contract.queueHeadStalled) {
79
- facts.push("朱 stall 去广场");
80
- }
81
- const sparkCol = spark.padEnd(14);
82
- const factText = facts.join(" · ");
83
- lines.push(`${glyph} ${name.padEnd(18)} ${sparkCol} ${factText}`.trimEnd());
84
- if (contract.bootstrapDiagnostics.some((diagnostic) => diagnostic.kind === "plan-without-result")) {
85
- lines.push(" ! bootstrap · no result recorded · forfeit and re-bind");
86
- }
87
- for (const diagnostic of contract.queueDiagnostics) {
88
- if (diagnostic.kind === "legacy-petition") {
89
- lines.push(" ! legacy petition · no seat · reject then re-petition");
90
- continue;
91
- }
92
- if (diagnostic.kind === "duplicate-seat") {
93
- lines.push(` ! seat ${diagnostic.seat} duplicated with ${diagnostic.with} · ordered by contract id`);
94
- continue;
95
- }
96
- lines.push(" ! target mismatch");
97
- }
107
+ return facts;
108
+ }
109
+ function renderKeiyakuSection(board, width) {
110
+ if (!board.contractsObservable)
111
+ return undefined;
112
+ const lines = [`keiyaku ${board.contracts.length}`];
113
+ for (const contract of orderKanshiContracts(board.contracts)) {
114
+ lines.push(alignedBoardRow({
115
+ prefix: `${contractGlyph(contract)} ${contract.place ?? contract.slug}`,
116
+ title: contract.title,
117
+ facts: contractFacts(contract),
118
+ width,
119
+ }));
120
+ }
121
+ return lines.join("\n");
122
+ }
123
+ function activityState(row) {
124
+ switch (row.state) {
125
+ case "lost": return "lost";
126
+ case "startup-timeout": return "stalled";
127
+ case "unknown":
128
+ case "incompatible": return "unknown";
129
+ case "failed":
130
+ case "dead": return "dead";
131
+ case "done": return "returned";
132
+ case "killed":
133
+ case "dismissed": return "dismissed";
134
+ case "minting":
135
+ case "out": return "running";
136
+ }
137
+ }
138
+ function projectionBinding(board, row) {
139
+ if (row.binding?.kind !== "commission")
140
+ return "";
141
+ const place = board.commissionPlaces.get(row.binding.commissionId);
142
+ return place ? `@${place}` : "";
143
+ }
144
+ function projectionFacts(row) {
145
+ const facts = [];
146
+ if (row.durationMs !== undefined)
147
+ facts.push({ text: `up ${formatAgeMs(row.durationMs) ?? "0s"}` });
148
+ if (row.activityAgeMs !== undefined)
149
+ facts.push({ text: `active ${formatAgeMs(row.activityAgeMs) ?? "0s"}` });
150
+ if (row.state !== "out" && row.state !== "minting")
151
+ facts.push({ text: row.state, tone: row.state === "startup-timeout" ? "alert" : "normal" });
152
+ return facts;
153
+ }
154
+ function renderEmbeddedActivity(row, width) {
155
+ const observedAtMs = row.observedAtMs ?? Date.now();
156
+ const selection = row.activity
157
+ ? selectProjectionActivityWindow(row.activity, KANSHI_ACTIVITY_ROWS)
158
+ : undefined;
159
+ const ordinary = row.activity
160
+ ? renderProjectionActivity(selection.activity, {
161
+ anchorMs: observedAtMs,
162
+ state: activityState(row),
163
+ showPlan: false,
164
+ showSilence: false,
165
+ ...(row.workspaceRoot ? { workspaceRoot: row.workspaceRoot } : {}),
166
+ maxColumns: width,
167
+ leadingOmittedCount: selection.leadingOmittedCount,
168
+ })
169
+ : undefined;
170
+ const rendered = ordinary?.lines.map((line, index) => ({
171
+ line,
172
+ at: ordinary.rowAts[index],
173
+ order: index,
174
+ })) ?? [];
175
+ const tells = (row.pendingTells ?? []).map((tell, index) => ({
176
+ line: renderPendingProjectionTell(tell, {
177
+ anchorMs: observedAtMs,
178
+ maxColumns: width,
179
+ renderUnconsumedTail: (tail) => tone(tail, "alert"),
180
+ }),
181
+ at: tell.createdAt,
182
+ order: rendered.length + index,
183
+ }));
184
+ return [...rendered, ...tells]
185
+ .sort((left, right) => {
186
+ const leftAt = Date.parse(left.at ?? "");
187
+ const rightAt = Date.parse(right.at ?? "");
188
+ const safeLeft = Number.isFinite(leftAt) ? leftAt : Number.POSITIVE_INFINITY;
189
+ const safeRight = Number.isFinite(rightAt) ? rightAt : Number.POSITIVE_INFINITY;
190
+ return safeLeft - safeRight || left.order - right.order;
191
+ })
192
+ .map((entry) => entry.line);
193
+ }
194
+ function terminalSummary(board) {
195
+ const omitted = board.projections?.omitted;
196
+ if (!omitted)
197
+ return undefined;
198
+ const compatibleStates = ["failed", "dead", "done", "killed", "dismissed"];
199
+ const details = compatibleStates
200
+ .flatMap((state) => omitted.byState[state] > 0 ? [`${omitted.byState[state]} ${state}`] : []);
201
+ return details.length > 0 ? `+ ${details.join(" · ")}` : undefined;
202
+ }
203
+ function renderAkumaSection(board, width) {
204
+ if (!board.projections)
205
+ return undefined;
206
+ const lines = [`akuma ${board.projections.rows.length}`];
207
+ for (const row of board.projections.rows) {
208
+ const alias = row.alias ? ` ${row.alias}` : "";
209
+ lines.push(alignedBoardRow({
210
+ prefix: `◆ ${row.id}${alias}`,
211
+ title: projectionBinding(board, row),
212
+ titleTone: "normal",
213
+ facts: projectionFacts(row),
214
+ width,
215
+ }));
216
+ lines.push(...renderEmbeddedActivity(row, width));
98
217
  }
99
- return `${lines.join("\n")}\n`;
218
+ const folded = terminalSummary(board);
219
+ if (folded)
220
+ lines.push(tone(folded, "description"));
221
+ return lines.join("\n");
222
+ }
223
+ function taskLabel(task) {
224
+ return task.title === task.id ? `P${task.pri} ${task.id}` : `P${task.pri} ${task.id} ${task.title}`;
225
+ }
226
+ function renderTaskSection(tasks, width) {
227
+ if (!tasks)
228
+ return undefined;
229
+ const lines = [`task ${tasks.total}`];
230
+ for (const task of tasks.topTasks) {
231
+ lines.push(alignedBoardRow({
232
+ prefix: "▶",
233
+ title: taskLabel(task),
234
+ facts: [{ text: `in_progress · active ${formatAgeMs(task.activityAgeMs) ?? "0s"}` }],
235
+ width,
236
+ }));
237
+ }
238
+ const folded = [
239
+ tasks.ready > 0 ? `${tasks.ready} ready` : undefined,
240
+ tasks.blocked > 0 ? `${tasks.blocked} blocked` : undefined,
241
+ ].filter((fact) => fact !== undefined);
242
+ if (folded.length > 0)
243
+ lines.push(tone(`+ ${folded.join(" · ")}`, "description"));
244
+ return lines.join("\n");
245
+ }
246
+ export function renderKanshiBoard(board) {
247
+ const width = Math.min(KANSHI_MAX_COLUMNS, resolveLineColumns());
248
+ const left = "kanshi ";
249
+ const head = shortHead(board.defaultHead);
250
+ const right = head ? ` 現世 ${head}` : " 現世";
251
+ const dashes = "─".repeat(Math.max(1, width - displayColumns(left) - displayColumns(right)));
252
+ const sections = [
253
+ renderKeiyakuSection(board, width),
254
+ renderAkumaSection(board, width),
255
+ renderTaskSection(board.tasks, width),
256
+ ].filter((section) => section !== undefined);
257
+ return `${[`${left}${dashes}${right}`, ...sections].join("\n\n")}\n`;
100
258
  }
@@ -1,11 +1,31 @@
1
1
  import { compactText } from "./compact-text.js";
2
- import { displayColumns, fitVariableLine, resolveLineColumns, truncateMiddleColumns } from "./line-width.js";
2
+ import { displayColumns, fitVariableLine, resolveLineColumns, truncateMiddleColumns, truncateColumns } from "./line-width.js";
3
3
  import { presentFoldedToolActivity, } from "./tool-presentation.js";
4
4
  import { presentLedgerPath, summarizeToolLedger } from "./tool-ledger-rollup.js";
5
5
  const TIME_GUTTER_WIDTH = 5;
6
6
  const VERB_WIDTH = 7;
7
7
  const SILENCE_THRESHOLD_MS = 60_000;
8
8
  const TIMELINE_GAP_MARKER = "⋮";
9
+ /** Keep the renderer and its gap grammar while giving Kanshi its smaller live window. */
10
+ export function selectProjectionActivityWindow(activity, ordinaryRows) {
11
+ // A Kanshi flow narrows only the settled history window. Unfinished activity
12
+ // remains pinned in its timeline position; it is not another history row.
13
+ const selected = activity.window.slice(-ordinaryRows);
14
+ const selectedOrders = new Set([
15
+ ...selected.map((row) => row.order),
16
+ ...activity.pinned.map((row) => row.order),
17
+ ]);
18
+ return {
19
+ activity: {
20
+ ...activity,
21
+ window: selected,
22
+ // Turn seals are a wait concern. Kanshi's narrow operational flow contains
23
+ // only ordinary activity plus durable tells.
24
+ timeline: activity.timeline.filter((row) => selectedOrders.has(row.order)),
25
+ },
26
+ leadingOmittedCount: activity.omittedSettledCount + activity.window.length - selected.length,
27
+ };
28
+ }
9
29
  export function formatTimelineDuration(ms) {
10
30
  const totalSeconds = Math.max(0, Math.floor(ms / 1_000));
11
31
  if (totalSeconds < 60)
@@ -40,6 +60,14 @@ export function formatWallClock(at) {
40
60
  return " : │";
41
61
  return `${String(value.getHours()).padStart(2, "0")}:${String(value.getMinutes()).padStart(2, "0")}│`;
42
62
  }
63
+ /** One durable-tell line dialect shared by wait and the embedded Kanshi flow. */
64
+ export function renderPendingProjectionTell(tell, input) {
65
+ const createdAtMs = Date.parse(tell.createdAt);
66
+ const age = Math.max(0, input.anchorMs - (Number.isFinite(createdAtMs) ? createdAtMs : input.anchorMs));
67
+ const fixed = `${formatWallClock(tell.createdAt)} ${"told".padEnd(VERB_WIDTH)} `;
68
+ const tail = ` — ${formatTimelineDuration(age)}…`;
69
+ return `${fixed}${truncateColumns(`“${tell.text}”`, Math.max(0, input.maxColumns - displayColumns(fixed) - displayColumns(tail)))}${input.renderUnconsumedTail?.(tail) ?? tail}`;
70
+ }
43
71
  function commonPrefix(left, right) {
44
72
  const a = [...left];
45
73
  const b = [...right];
@@ -73,8 +101,8 @@ function compressedPrefix(prefix) {
73
101
  function timelineGutter(label, spine) {
74
102
  return label || `${"".padStart(TIME_GUTTER_WIDTH)}${spine}`;
75
103
  }
76
- function renderTimelineGap(omittedEventCount, maxColumns) {
77
- return fitVariableLine(`${timelineGutter("", TIMELINE_GAP_MARKER)} `, `${omittedEventCount} more`, maxColumns);
104
+ function renderTimelineGap(omittedRowCount, maxColumns) {
105
+ return fitVariableLine(`${timelineGutter("", TIMELINE_GAP_MARKER)} `, `${omittedRowCount} more`, maxColumns);
78
106
  }
79
107
  function compactTokens(value) {
80
108
  if (value < 1_000)
@@ -148,13 +176,15 @@ function renderTerminalRollup(activity, input) {
148
176
  ? fitVariableLine(`${endPrefix} `, segments.join(" · "), input.maxColumns)
149
177
  : endPrefix,
150
178
  });
151
- for (const file of summary.files) {
152
- const repeat = file.count > 1 ? ` ×${file.count}` : "";
153
- const diffstat = file.diffstat ? ` +${file.diffstat.additions} −${file.diffstat.deletions}` : "";
154
- rows.push({ kind: "file", line: fitVariableLine("", `${file.path}${repeat}${diffstat}`, input.maxColumns) });
155
- }
156
- if (summary.hiddenFileCount > 0) {
157
- rows.push({ kind: "file", line: fitVariableLine("", `… ${summary.hiddenFileCount} more files`, input.maxColumns) });
179
+ if (input.includeFiles !== false) {
180
+ for (const file of summary.files) {
181
+ const repeat = file.count > 1 ? ` ×${file.count}` : "";
182
+ const diffstat = file.diffstat ? ` +${file.diffstat.additions} −${file.diffstat.deletions}` : "";
183
+ rows.push({ kind: "file", line: fitVariableLine("", `${file.path}${repeat}${diffstat}`, input.maxColumns) });
184
+ }
185
+ if (summary.hiddenFileCount > 0) {
186
+ rows.push({ kind: "file", line: fitVariableLine("", `… ${summary.hiddenFileCount} more files`, input.maxColumns) });
187
+ }
158
188
  }
159
189
  return { rows, hasMutationFiles: summary.files.length > 0 };
160
190
  }
@@ -174,33 +204,36 @@ function timelineEntries(activity) {
174
204
  export function renderProjectionActivity(activity, input) {
175
205
  const lines = [];
176
206
  const rowKinds = [];
207
+ const rowAts = [];
177
208
  let priorAtMs;
178
- let priorOrder;
179
209
  let priorMinute;
180
210
  let priorCompletedRan;
181
211
  let hasEndAnchor = false;
182
212
  let lastRunningTool;
183
213
  const maxColumns = input.maxColumns ?? resolveLineColumns();
184
214
  const entries = timelineEntries(activity);
185
- const pushRow = (line, kind) => {
215
+ const gapBeforeOrder = input.leadingOmittedCount ? activity.window[0]?.order : undefined;
216
+ let gapEmitted = false;
217
+ const pushRow = (line, kind, at) => {
186
218
  lines.push(line);
187
219
  rowKinds.push(kind);
220
+ rowAts.push(at);
188
221
  return true;
189
222
  };
190
223
  for (let index = 0; index < entries.length; index += 1) {
191
224
  const entry = entries[index];
192
225
  const atMs = Date.parse(entry.at);
193
- if (priorOrder !== undefined && entry.order > priorOrder + 1) {
194
- pushRow(renderTimelineGap(entry.order - priorOrder - 1, maxColumns), "activity");
195
- }
196
- priorOrder = entry.order;
197
226
  if (entry.kind === "clock") {
198
227
  if (Number.isFinite(atMs))
199
228
  priorAtMs = atMs;
200
229
  continue;
201
230
  }
202
- if (priorAtMs !== undefined && Number.isFinite(atMs) && atMs - priorAtMs >= SILENCE_THRESHOLD_MS) {
203
- pushRow(fitVariableLine(`${"".padStart(TIME_GUTTER_WIDTH)}┆ `, `${formatTimelineDuration(atMs - priorAtMs)} pass in silence`, maxColumns), "silence");
231
+ if (!gapEmitted && input.leadingOmittedCount && gapBeforeOrder !== undefined && entry.row.order >= gapBeforeOrder) {
232
+ pushRow(renderTimelineGap(input.leadingOmittedCount, maxColumns), "activity", entry.at);
233
+ gapEmitted = true;
234
+ }
235
+ if (input.showSilence !== false && priorAtMs !== undefined && Number.isFinite(atMs) && atMs - priorAtMs >= SILENCE_THRESHOLD_MS) {
236
+ pushRow(fitVariableLine(`${"".padStart(TIME_GUTTER_WIDTH)}┆ `, `${formatTimelineDuration(atMs - priorAtMs)} pass in silence`, maxColumns), "silence", entry.at);
204
237
  }
205
238
  if (Number.isFinite(atMs))
206
239
  priorAtMs = atMs;
@@ -235,22 +268,22 @@ export function renderProjectionActivity(activity, input) {
235
268
  }
236
269
  priorCompletedRan = row.state === "completed" ? presentation.variableText : undefined;
237
270
  const budget = Math.max(0, maxColumns - displayColumns(fixed) - displayColumns(presentation.fixedSuffix));
238
- pushRow(`${fixed}${truncateMiddleColumns(variable, budget)}${presentation.fixedSuffix}`, "activity");
271
+ pushRow(`${fixed}${truncateMiddleColumns(variable, budget)}${presentation.fixedSuffix}`, "activity", entry.at);
239
272
  continue;
240
273
  }
241
274
  if (row.kind === "said") {
242
275
  priorCompletedRan = undefined;
243
- pushRow(fitVariableLine(`${timelineGutter(label, spine)} ${"said".padEnd(VERB_WIDTH)} `, `“${compactText(row.text)}”`, maxColumns), "activity");
276
+ pushRow(fitVariableLine(`${timelineGutter(label, spine)} ${"said".padEnd(VERB_WIDTH)} `, `“${compactText(row.text)}”`, maxColumns), "activity", entry.at);
244
277
  }
245
278
  else if (row.kind === "thought") {
246
279
  priorCompletedRan = undefined;
247
280
  const text = `${compactText(row.text)}${row.truncated && !row.text.endsWith("…") ? "…" : ""}`;
248
281
  const duration = formatActionDuration(row.durationMs);
249
- pushRow(fitVariableLine(`${timelineGutter(label, spine)} ${"thought".padEnd(VERB_WIDTH)} `, `${duration ? `${duration} — ` : ""}“${text}”`, maxColumns), "activity");
282
+ pushRow(fitVariableLine(`${timelineGutter(label, spine)} ${"thought".padEnd(VERB_WIDTH)} `, `${duration ? `${duration} — ` : ""}“${text}”`, maxColumns), "activity", entry.at);
250
283
  }
251
284
  else if (row.kind === "warning") {
252
285
  priorCompletedRan = undefined;
253
- pushRow(fitVariableLine(`${timelineGutter(label, spine)} ${"warning".padEnd(VERB_WIDTH)} `, warningText(row), maxColumns), "activity");
286
+ pushRow(fitVariableLine(`${timelineGutter(label, spine)} ${"warning".padEnd(VERB_WIDTH)} `, warningText(row), maxColumns), "activity", entry.at);
254
287
  }
255
288
  else {
256
289
  priorCompletedRan = undefined;
@@ -258,7 +291,7 @@ export function renderProjectionActivity(activity, input) {
258
291
  ? ` · ${compactTokens(row.inputTokens)}▸${compactTokens(row.outputTokens)} tok`
259
292
  : "";
260
293
  const cost = row.costUsd !== undefined ? ` · $${row.costUsd.toFixed(2)}` : "";
261
- pushRow(fitVariableLine(`${"".padStart(TIME_GUTTER_WIDTH)}├ `, `turn ${row.turn}${usage}${cost}`, maxColumns), "activity");
294
+ pushRow(fitVariableLine(`${"".padStart(TIME_GUTTER_WIDTH)}├ `, `turn ${row.turn}${usage}${cost}`, maxColumns), "activity", entry.at);
262
295
  }
263
296
  }
264
297
  for (const row of activity.pinned) {
@@ -267,10 +300,10 @@ export function renderProjectionActivity(activity, input) {
267
300
  }
268
301
  if (input.showPlan && activity.plan) {
269
302
  const planAtMs = Date.parse(activity.plan.at);
270
- if (priorAtMs !== undefined && Number.isFinite(planAtMs) && planAtMs - priorAtMs >= SILENCE_THRESHOLD_MS) {
271
- pushRow(fitVariableLine(`${"".padStart(TIME_GUTTER_WIDTH)}┆ `, `${formatTimelineDuration(planAtMs - priorAtMs)} pass in silence`, maxColumns), "silence");
303
+ if (input.showSilence !== false && priorAtMs !== undefined && Number.isFinite(planAtMs) && planAtMs - priorAtMs >= SILENCE_THRESHOLD_MS) {
304
+ pushRow(fitVariableLine(`${"".padStart(TIME_GUTTER_WIDTH)}┆ `, `${formatTimelineDuration(planAtMs - priorAtMs)} pass in silence`, maxColumns), "silence", activity.plan.at);
272
305
  }
273
- pushRow(renderPlan(activity.plan, maxColumns), "plan");
306
+ pushRow(renderPlan(activity.plan, maxColumns), "plan", activity.plan.at);
274
307
  }
275
308
  let hasMutationFiles = false;
276
309
  if (["returned", "dead", "lost", "dismissed"].includes(input.state)) {
@@ -278,10 +311,11 @@ export function renderProjectionActivity(activity, input) {
278
311
  anchorMs: input.anchorMs,
279
312
  ...(input.workspaceRoot ? { workspaceRoot: input.workspaceRoot } : {}),
280
313
  ...(input.terminalDiagnostic ? { diagnostic: input.terminalDiagnostic } : {}),
314
+ includeFiles: input.showTerminalFiles !== false,
281
315
  maxColumns,
282
316
  });
283
317
  for (const row of rollup.rows) {
284
- pushRow(row.line, row.kind);
318
+ pushRow(row.line, row.kind, new Date(input.anchorMs).toISOString());
285
319
  }
286
320
  hasEndAnchor = true;
287
321
  hasMutationFiles = rollup.hasMutationFiles;
@@ -289,6 +323,7 @@ export function renderProjectionActivity(activity, input) {
289
323
  return {
290
324
  lines,
291
325
  rowKinds,
326
+ rowAts,
292
327
  ...(lastRunningTool ? { lastRunningTool } : {}),
293
328
  hasEndAnchor,
294
329
  hasMutationFiles,
@@ -69,12 +69,12 @@ function terminalFailureSuffix(row) {
69
69
  function renderProjectionOmission(board) {
70
70
  if (!board.omitted)
71
71
  return undefined;
72
- const counts = ["failed", "dead", "done", "killed", "dismissed", "incompatible"]
72
+ const counts = ["failed", "dead", "done", "killed", "dismissed"]
73
73
  .flatMap((state) => {
74
74
  const count = board.omitted?.byState[state] ?? 0;
75
75
  return count > 0 ? [`${count} ${state}`] : [];
76
76
  });
77
- return ` · +${board.omitted.total} historical projections not shown (${counts.join(" · ")})`;
77
+ return counts.length > 0 ? `+ ${counts.join(" · ")}` : undefined;
78
78
  }
79
79
  function renderProjectionAge(row) {
80
80
  const duration = formatAgeMs(row.durationMs) ?? "?";
@@ -209,27 +209,12 @@ function renderClaimReconciliationSection(recon) {
209
209
  */
210
210
  export function renderStatusBoard(board) {
211
211
  const boardText = renderKanshiBoard(board);
212
- const projectionText = renderProjectionStatusSection(board.projections);
213
- const receiptsText = renderClaimReconciliationSection(board.claimReconciliation);
214
- const taskText = renderTaskStatusSection(board.tasks);
215
212
  const taskDiseaseText = [
216
213
  ...(board.tasks?.diseases ?? []).map((disease) => disease.message),
217
214
  ...(board.tasks?.diagnostic ? [board.tasks.diagnostic] : []),
218
215
  ];
219
216
  const diseasesText = renderSettingsDiseasesSection(board.diseases, taskDiseaseText);
220
- if (!projectionText && !receiptsText && !taskText && diseasesText === "")
217
+ if (diseasesText === "")
221
218
  return boardText;
222
- const sections = [boardText.trimEnd()];
223
- if (board.targetFilter !== null && (projectionText || receiptsText || diseasesText)) {
224
- sections.push("repository-wide — not filtered by target");
225
- }
226
- if (projectionText)
227
- sections.push(projectionText.trimEnd());
228
- if (receiptsText)
229
- sections.push(receiptsText.trimEnd());
230
- if (taskText)
231
- sections.push(taskText.trimEnd());
232
- if (diseasesText)
233
- sections.push(diseasesText.trimEnd());
234
- return `${sections.join("\n\n")}\n`;
219
+ return `${[boardText.trimEnd(), diseasesText.trimEnd()].join("\n\n")}\n`;
235
220
  }