@pellux/goodvibes-tui 1.0.0 → 1.7.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 (209) hide show
  1. package/CHANGELOG.md +130 -127
  2. package/README.md +32 -14
  3. package/docs/foundation-artifacts/operator-contract.json +1 -1
  4. package/package.json +2 -2
  5. package/src/cli/ensure-goodvibes-gitignore.ts +32 -0
  6. package/src/cli/entrypoint.ts +2 -0
  7. package/src/core/alert-gating.ts +67 -0
  8. package/src/core/approval-alert.ts +72 -0
  9. package/src/core/budget-breach-notifier.ts +106 -0
  10. package/src/core/conversation-rendering.ts +19 -0
  11. package/src/core/conversation.ts +58 -0
  12. package/src/core/focus-tracker.ts +41 -0
  13. package/src/core/long-task-notifier.ts +33 -6
  14. package/src/core/stream-event-wiring.ts +104 -2
  15. package/src/core/stream-stall-watchdog.ts +41 -17
  16. package/src/core/system-message-router.ts +37 -51
  17. package/src/core/turn-cancellation.ts +20 -0
  18. package/src/core/turn-event-wiring.ts +64 -3
  19. package/src/export/cost-utils.ts +126 -8
  20. package/src/input/command-registry.ts +54 -1
  21. package/src/input/commands/checkpoint-runtime.ts +280 -0
  22. package/src/input/commands/codebase-runtime.ts +192 -0
  23. package/src/input/commands/diff-runtime.ts +61 -30
  24. package/src/input/commands/eval.ts +1 -1
  25. package/src/input/commands/health-runtime.ts +1 -1
  26. package/src/input/commands/image-runtime.ts +112 -0
  27. package/src/input/commands/intelligence-runtime.ts +11 -1
  28. package/src/input/commands/local-auth-runtime.ts +4 -1
  29. package/src/input/commands/local-runtime.ts +9 -3
  30. package/src/input/commands/marketplace-runtime.ts +2 -2
  31. package/src/input/commands/memory.ts +6 -1
  32. package/src/input/commands/operator-panel-runtime.ts +40 -24
  33. package/src/input/commands/planning-runtime.ts +26 -3
  34. package/src/input/commands/platform-sandbox-runtime.ts +1 -6
  35. package/src/input/commands/plugin-runtime.ts +2 -2
  36. package/src/input/commands/policy-dispatch.ts +21 -0
  37. package/src/input/commands/provider-accounts-runtime.ts +1 -1
  38. package/src/input/commands/qrcode-runtime.ts +3 -3
  39. package/src/input/commands/recall-review.ts +35 -0
  40. package/src/input/commands/remote-runtime.ts +3 -3
  41. package/src/input/commands/runtime-services.ts +54 -13
  42. package/src/input/commands/services-runtime.ts +1 -1
  43. package/src/input/commands/session-content.ts +12 -0
  44. package/src/input/commands/session-workflow.ts +19 -1
  45. package/src/input/commands/settings-sync-runtime.ts +1 -1
  46. package/src/input/commands/share-runtime.ts +9 -2
  47. package/src/input/commands/shell-core.ts +15 -7
  48. package/src/input/commands/skills-runtime.ts +2 -8
  49. package/src/input/commands/subscription-runtime.ts +2 -2
  50. package/src/input/commands/test-runtime.ts +277 -0
  51. package/src/input/commands/websearch-runtime.ts +101 -0
  52. package/src/input/commands/work-plan-runtime.ts +36 -10
  53. package/src/input/commands/workstream-runtime.ts +338 -0
  54. package/src/input/commands.ts +12 -0
  55. package/src/input/config-modal-types.ts +161 -0
  56. package/src/input/config-modal.ts +377 -0
  57. package/src/input/feed-context-factory.ts +7 -8
  58. package/src/input/handler-command-route.ts +27 -17
  59. package/src/input/handler-content-actions.ts +22 -8
  60. package/src/input/handler-feed-routes.ts +107 -7
  61. package/src/input/handler-feed.ts +49 -13
  62. package/src/input/handler-interactions.ts +3 -3
  63. package/src/input/handler-modal-routes.ts +65 -0
  64. package/src/input/handler-modal-stack.ts +3 -5
  65. package/src/input/handler-modal-token-routes.ts +16 -49
  66. package/src/input/handler-picker-routes.ts +11 -94
  67. package/src/input/handler-shortcuts.ts +24 -14
  68. package/src/input/handler-types.ts +3 -6
  69. package/src/input/handler-ui-state.ts +10 -22
  70. package/src/input/handler.ts +10 -28
  71. package/src/input/keybindings.ts +22 -8
  72. package/src/input/model-picker-types.ts +24 -6
  73. package/src/input/model-picker.ts +58 -0
  74. package/src/input/panel-integration-actions.ts +9 -170
  75. package/src/input/settings-modal-data.ts +95 -0
  76. package/src/input/settings-modal-mutations.ts +6 -4
  77. package/src/main.ts +41 -44
  78. package/src/panels/agent-inspector-shared.ts +35 -11
  79. package/src/panels/base-panel.ts +22 -1
  80. package/src/panels/builtin/agent.ts +21 -107
  81. package/src/panels/builtin/development.ts +16 -62
  82. package/src/panels/builtin/knowledge.ts +8 -32
  83. package/src/panels/builtin/operations.ts +84 -428
  84. package/src/panels/builtin/session.ts +21 -112
  85. package/src/panels/builtin/shared.ts +9 -43
  86. package/src/panels/builtin-modals.ts +218 -0
  87. package/src/panels/builtin-panels.ts +5 -0
  88. package/src/panels/cost-tracker-panel.ts +63 -14
  89. package/src/panels/diff-panel.ts +123 -60
  90. package/src/panels/eval-registry.ts +60 -0
  91. package/src/panels/fleet-panel.ts +800 -0
  92. package/src/panels/fleet-read-model.ts +477 -0
  93. package/src/panels/fleet-steer.ts +92 -0
  94. package/src/panels/fleet-stop.ts +125 -0
  95. package/src/panels/fleet-tabs.ts +230 -0
  96. package/src/panels/fleet-transcript.ts +356 -0
  97. package/src/panels/git-panel.ts +9 -9
  98. package/src/panels/index.ts +7 -31
  99. package/src/panels/local-auth-panel.ts +10 -0
  100. package/src/panels/modals/hooks-modal.ts +187 -0
  101. package/src/panels/modals/keybindings-modal.ts +151 -0
  102. package/src/panels/modals/knowledge-modal.ts +158 -0
  103. package/src/panels/modals/local-auth-modal.ts +132 -0
  104. package/src/panels/modals/marketplace-modal.ts +218 -0
  105. package/src/panels/modals/memory-modal.ts +180 -0
  106. package/src/panels/modals/modal-surface-helpers.ts +54 -0
  107. package/src/panels/modals/modal-theme.ts +36 -0
  108. package/src/panels/modals/pairing-modal.ts +144 -0
  109. package/src/panels/modals/planning-modal.ts +282 -0
  110. package/src/panels/modals/plugins-modal.ts +174 -0
  111. package/src/panels/modals/policy-modal.ts +256 -0
  112. package/src/panels/modals/provider-health-modal.ts +136 -0
  113. package/src/panels/modals/remote-modal.ts +115 -0
  114. package/src/panels/modals/sandbox-modal.ts +150 -0
  115. package/src/panels/modals/security-modal.ts +217 -0
  116. package/src/panels/modals/services-modal.ts +179 -0
  117. package/src/panels/modals/settings-sync-modal.ts +142 -0
  118. package/src/panels/modals/skills-modal.ts +189 -0
  119. package/src/panels/modals/subscription-modal.ts +172 -0
  120. package/src/panels/modals/work-plan-modal.ts +149 -0
  121. package/src/panels/panel-confirm-overlay.ts +72 -0
  122. package/src/panels/panel-manager.ts +108 -5
  123. package/src/panels/project-planning-answer-actions.ts +4 -2
  124. package/src/panels/scrollable-list-panel.ts +9 -0
  125. package/src/panels/skills-panel.ts +7 -51
  126. package/src/panels/token-budget-panel.ts +5 -3
  127. package/src/panels/types.ts +26 -0
  128. package/src/permissions/hunk-selection.ts +179 -0
  129. package/src/permissions/prompt.ts +60 -4
  130. package/src/renderer/compaction-history-modal.ts +19 -3
  131. package/src/renderer/compaction-preview.ts +13 -2
  132. package/src/renderer/compaction-quality.ts +100 -0
  133. package/src/renderer/config-modal.ts +81 -0
  134. package/src/renderer/conversation-overlays.ts +10 -17
  135. package/src/renderer/fleet-tab-strip.ts +56 -0
  136. package/src/renderer/footer-tips.ts +10 -2
  137. package/src/renderer/git-status.ts +40 -0
  138. package/src/renderer/help-overlay.ts +2 -2
  139. package/src/renderer/model-workspace.ts +44 -1
  140. package/src/renderer/panel-workspace-bar.ts +8 -2
  141. package/src/renderer/shell-surface.ts +8 -1
  142. package/src/renderer/turn-injection.ts +114 -0
  143. package/src/renderer/ui-factory.ts +91 -7
  144. package/src/runtime/bootstrap-command-context.ts +24 -1
  145. package/src/runtime/bootstrap-command-parts.ts +36 -7
  146. package/src/runtime/bootstrap-core.ts +19 -4
  147. package/src/runtime/bootstrap-hook-bridge.ts +5 -0
  148. package/src/runtime/bootstrap-shell.ts +41 -17
  149. package/src/runtime/bootstrap.ts +11 -17
  150. package/src/runtime/code-index-services.ts +112 -0
  151. package/src/runtime/orchestrator-core-services.ts +49 -0
  152. package/src/runtime/process-lifecycle.ts +3 -1
  153. package/src/runtime/services.ts +91 -43
  154. package/src/runtime/ui-services.ts +8 -0
  155. package/src/runtime/workstream-services.ts +195 -0
  156. package/src/shell/blocking-input.ts +22 -1
  157. package/src/shell/ui-openers.ts +129 -17
  158. package/src/utils/format-duration.ts +8 -18
  159. package/src/utils/splash-lines.ts +1 -1
  160. package/src/version.ts +1 -1
  161. package/src/panels/agent-inspector-panel.ts +0 -786
  162. package/src/panels/approval-panel.ts +0 -252
  163. package/src/panels/automation-control-panel.ts +0 -479
  164. package/src/panels/cockpit-panel.ts +0 -481
  165. package/src/panels/cockpit-read-model.ts +0 -233
  166. package/src/panels/communication-panel.ts +0 -256
  167. package/src/panels/control-plane-panel.ts +0 -470
  168. package/src/panels/debug-panel.ts +0 -609
  169. package/src/panels/docs-panel.ts +0 -375
  170. package/src/panels/eval-panel.ts +0 -627
  171. package/src/panels/file-explorer-panel.ts +0 -664
  172. package/src/panels/file-preview-panel.ts +0 -517
  173. package/src/panels/hooks-panel.ts +0 -401
  174. package/src/panels/incident-review-panel.ts +0 -406
  175. package/src/panels/intelligence-panel.ts +0 -383
  176. package/src/panels/knowledge-graph-panel.ts +0 -506
  177. package/src/panels/marketplace-panel.ts +0 -399
  178. package/src/panels/memory-panel.ts +0 -558
  179. package/src/panels/ops-control-panel.ts +0 -329
  180. package/src/panels/ops-strategy-panel.ts +0 -321
  181. package/src/panels/orchestration-panel.ts +0 -465
  182. package/src/panels/panel-list-panel.ts +0 -557
  183. package/src/panels/plan-dashboard-panel.ts +0 -707
  184. package/src/panels/policy-panel.ts +0 -517
  185. package/src/panels/project-planning-panel.ts +0 -721
  186. package/src/panels/provider-health-panel.ts +0 -678
  187. package/src/panels/provider-health-tracker.ts +0 -306
  188. package/src/panels/provider-health-views.ts +0 -560
  189. package/src/panels/qr-panel.ts +0 -280
  190. package/src/panels/remote-panel.ts +0 -534
  191. package/src/panels/routes-panel.ts +0 -241
  192. package/src/panels/sandbox-panel.ts +0 -456
  193. package/src/panels/security-panel.ts +0 -447
  194. package/src/panels/services-panel.ts +0 -329
  195. package/src/panels/session-browser-panel.ts +0 -487
  196. package/src/panels/settings-sync-panel.ts +0 -398
  197. package/src/panels/subscription-panel.ts +0 -342
  198. package/src/panels/symbol-outline-panel.ts +0 -619
  199. package/src/panels/system-messages-panel.ts +0 -364
  200. package/src/panels/tasks-panel.ts +0 -608
  201. package/src/panels/thinking-panel.ts +0 -333
  202. package/src/panels/tool-inspector-panel.ts +0 -537
  203. package/src/panels/work-plan-panel.ts +0 -530
  204. package/src/panels/worktree-panel.ts +0 -360
  205. package/src/panels/wrfc-panel.ts +0 -790
  206. package/src/renderer/agent-detail-modal.ts +0 -465
  207. package/src/renderer/live-tail-modal.ts +0 -156
  208. package/src/renderer/process-modal.ts +0 -656
  209. package/src/renderer/qr-renderer.ts +0 -120
@@ -1,627 +0,0 @@
1
- /**
2
- * Eval Panel — renders evaluation harness results in list and detail modes.
3
- *
4
- * Displays suite run summaries, per-scenario scorecards, and regression
5
- * indicators. Wired with an EvalRegistry that holds the latest run results.
6
- */
7
-
8
- import { join } from 'node:path';
9
- import { BasePanel } from './base-panel.ts';
10
- import { truncateDisplay } from '../utils/terminal-width.ts';
11
- import type { Line } from '../types/grid.ts';
12
- import type { KeyName, PanelIntegrationContext } from './types.ts';
13
- import { createEmptyLine } from '../types/grid.ts';
14
- import {
15
- buildAlignedRow,
16
- buildKeyboardHints,
17
- buildMeterLine,
18
- buildPanelLine,
19
- buildPanelWorkspace,
20
- buildTable,
21
- resolveScrollablePanelSection,
22
- DEFAULT_PANEL_PALETTE,
23
- extendPalette,
24
- } from './polish.ts';
25
-
26
- // ── EvalRegistry ─────────────────────────────────────────────────────────────
27
-
28
- import type {
29
- EvalSuiteResult,
30
- EvalResult,
31
- EvalGateResult,
32
- EvalDimension,
33
- EvalBaseline,
34
- RegressionEntry,
35
- } from '@/runtime/index.ts';
36
- import { loadBaseline } from '@/runtime/index.ts';
37
- import { formatShortDuration } from '../utils/format-duration.ts';
38
-
39
- const BASELINE_PATH = '.goodvibes/eval/baseline.json';
40
-
41
- /**
42
- * Holds the latest eval run state for display in EvalPanel.
43
- * Created externally, injected into the panel.
44
- */
45
- export class EvalRegistry {
46
- private _suiteResults: EvalSuiteResult[] = [];
47
- private _gateResults: EvalGateResult[] = [];
48
- private _running = false;
49
- private _lastRunAt: number | null = null;
50
- private readonly _subscribers = new Set<() => void>();
51
-
52
- push(result: EvalSuiteResult): void {
53
- const idx = this._suiteResults.findIndex((r) => r.suite === result.suite);
54
- if (idx >= 0) {
55
- this._suiteResults[idx] = result;
56
- } else {
57
- this._suiteResults.push(result);
58
- }
59
- this._lastRunAt = Date.now();
60
- this._notify();
61
- }
62
-
63
- pushGate(gate: EvalGateResult): void {
64
- const idx = this._gateResults.findIndex((g) => g.suite === gate.suite);
65
- if (idx >= 0) {
66
- this._gateResults[idx] = gate;
67
- } else {
68
- this._gateResults.push(gate);
69
- }
70
- this._notify();
71
- }
72
-
73
- setRunning(running: boolean): void {
74
- this._running = running;
75
- this._notify();
76
- }
77
-
78
- isRunning(): boolean { return this._running; }
79
- getLastRunAt(): number | null { return this._lastRunAt; }
80
- getSuiteResults(): EvalSuiteResult[] { return this._suiteResults; }
81
- getGateResults(): EvalGateResult[] { return this._gateResults; }
82
-
83
- subscribe(cb: () => void): () => void {
84
- this._subscribers.add(cb);
85
- return () => this._subscribers.delete(cb);
86
- }
87
-
88
- private _notify(): void {
89
- for (const cb of this._subscribers) cb();
90
- }
91
- }
92
-
93
- // ── Colour palette (no inline hex in render bodies) ──────────────────────────
94
-
95
- // Domain accents only; base chrome (header/headerBg/info/good/warn/bad/
96
- // value/selectBg) comes from DEFAULT_PANEL_PALETTE.
97
- const C = extendPalette(DEFAULT_PANEL_PALETTE, {
98
- selected: '#f1f5f9', // emphasized row/text highlight, brighter than value
99
- });
100
-
101
- // ── Helpers ───────────────────────────────────────────────────────────────────
102
-
103
- function scoreColor(score: number): string {
104
- if (score >= 80) return C.good;
105
- if (score >= 60) return C.warn;
106
- return C.bad;
107
- }
108
-
109
- function fmtTime(ms: number): string {
110
- return formatShortDuration(ms);
111
- }
112
-
113
- const DIMENSION_ORDER: EvalDimension[] = ['safety', 'quality', 'latency', 'cost', 'recovery'];
114
-
115
- // ── EvalPanel ─────────────────────────────────────────────────────────────────
116
-
117
- export class EvalPanel extends BasePanel {
118
- private readonly _registry: EvalRegistry;
119
- private readonly _projectRoot: string;
120
- private _mode: 'list' | 'detail' = 'list';
121
- private _selectedSuiteIdx = 0;
122
- private _selectedScenarioIdx = 0;
123
- private _scrollOffset = 0;
124
- private _unsub: (() => void) | null = null;
125
- private _baseline: EvalBaseline | null = null;
126
- private _baselineLoading = false;
127
-
128
- public constructor(registry: EvalRegistry, projectRoot = '.') {
129
- super('eval', 'Eval', '▮', 'incidents-diagnostics');
130
- this._registry = registry;
131
- this._projectRoot = projectRoot;
132
- }
133
-
134
- public override onActivate(): void {
135
- this._unsub = this._registry.subscribe(() => this.markDirty());
136
- this._loadBaselineIfNeeded();
137
- this.markDirty();
138
- }
139
-
140
- public override onDestroy(): void {
141
- this._unsub?.();
142
- this._unsub = null;
143
- }
144
-
145
- /**
146
- * Seed the panel with last-known scores from the on-disk baseline so a
147
- * fresh session shows real data instead of a "run a suite" signpost.
148
- * Only loaded once per activation; a live suite run supersedes it.
149
- *
150
- * Resolved as an absolute path under _projectRoot before handing it to
151
- * loadBaseline() — the SDK helper resolves a relative path against the
152
- * process cwd (not the projectRoot argument), so joining here is what
153
- * actually makes the constructor's projectRoot meaningful.
154
- */
155
- private _loadBaselineIfNeeded(): void {
156
- if (this._baseline || this._baselineLoading) return;
157
- this._baselineLoading = true;
158
- void loadBaseline(join(this._projectRoot, BASELINE_PATH), this._projectRoot)
159
- .then((baseline) => {
160
- this._baseline = baseline ?? null;
161
- })
162
- .catch(() => {
163
- this._baseline = null;
164
- })
165
- .finally(() => {
166
- this._baselineLoading = false;
167
- this.markDirty();
168
- });
169
- }
170
-
171
- /** Number of selectable rows in list mode: live suite results, or baseline suites when none have run yet. */
172
- private _listLength(suites: EvalSuiteResult[]): number {
173
- if (suites.length > 0) return suites.length;
174
- return this._baseline ? Object.keys(this._baseline.suites).length : 0;
175
- }
176
-
177
- /** Name of the suite currently selected in list mode, from live results or the baseline. */
178
- private _selectedSuiteName(suites: EvalSuiteResult[]): string | undefined {
179
- if (suites.length > 0) return suites[this._selectedSuiteIdx]?.suite;
180
- if (!this._baseline) return undefined;
181
- return Object.keys(this._baseline.suites)[this._selectedSuiteIdx];
182
- }
183
-
184
- /** Total scenario/detail line count for the given suite, used to clamp pagedown scrolling. */
185
- private _detailLineCount(suite: EvalSuiteResult): number {
186
- const gates = this._registry.getGateResults();
187
- const gate = gates.find((g) => g.suite === suite.suite);
188
- const regressedIds = new Set((gate?.regressions ?? []).map((r) => r.scenarioId));
189
-
190
- let count = 0;
191
- suite.results.forEach((result, idx) => {
192
- count += 1;
193
- if (idx === this._selectedScenarioIdx) {
194
- count += DIMENSION_ORDER.filter((dim) =>
195
- result.scorecard.dimensions.some((d) => d.dimension === dim),
196
- ).length;
197
- if (regressedIds.has(result.scenario.id)) count += 1;
198
- count += result.scorecard.notes?.length ?? 0;
199
- }
200
- });
201
- return count;
202
- }
203
-
204
- public handleInput(key: KeyName): boolean {
205
- const suites = this._registry.getSuiteResults();
206
-
207
- if (this._mode === 'list') {
208
- if (key === 'up' || key === 'k') {
209
- this._selectedSuiteIdx = Math.max(0, this._selectedSuiteIdx - 1);
210
- this.markDirty();
211
- return true;
212
- }
213
- if (key === 'down' || key === 'j') {
214
- const len = this._listLength(suites);
215
- this._selectedSuiteIdx = Math.min(Math.max(0, len - 1), this._selectedSuiteIdx + 1);
216
- this.markDirty();
217
- return true;
218
- }
219
- if ((key === 'enter' || key === 'return' || key === 'l') && suites.length > 0) {
220
- this._mode = 'detail';
221
- this._selectedScenarioIdx = 0;
222
- this._scrollOffset = 0;
223
- this.markDirty();
224
- return true;
225
- }
226
- return false;
227
- }
228
-
229
- // detail mode
230
- if (key === 'escape' || key === 'q' || key === 'h') {
231
- this._mode = 'list';
232
- this.markDirty();
233
- return true;
234
- }
235
- if (key === 'up' || key === 'k') {
236
- const suite = suites[this._selectedSuiteIdx];
237
- if (suite) {
238
- this._selectedScenarioIdx = Math.max(0, this._selectedScenarioIdx - 1);
239
- this._scrollOffset = 0;
240
- this.markDirty();
241
- }
242
- return true;
243
- }
244
- if (key === 'down' || key === 'j') {
245
- const suite = suites[this._selectedSuiteIdx];
246
- if (suite) {
247
- this._selectedScenarioIdx = Math.min(
248
- suite.results.length - 1,
249
- this._selectedScenarioIdx + 1,
250
- );
251
- this._scrollOffset = 0;
252
- this.markDirty();
253
- }
254
- return true;
255
- }
256
- if (key === 'pageup') {
257
- this._scrollOffset = Math.max(0, this._scrollOffset - 5);
258
- this.markDirty();
259
- return true;
260
- }
261
- if (key === 'pagedown') {
262
- const suite = suites[this._selectedSuiteIdx];
263
- const maxOffset = suite ? Math.max(0, this._detailLineCount(suite) - 1) : 0;
264
- this._scrollOffset = Math.min(maxOffset, this._scrollOffset + 5);
265
- this.markDirty();
266
- return true;
267
- }
268
- return false;
269
- }
270
-
271
- /**
272
- * Cross-panel integration hook: r runs the selected suite, R runs all
273
- * suites, both dispatched through the real /eval command executor rather
274
- * than a printed signpost. registry.setRunning()/push() (already wired in
275
- * src/input/commands/eval.ts) animate the in-panel state as the run proceeds.
276
- */
277
- public handlePanelIntegrationAction(key: string, ctx: PanelIntegrationContext): boolean {
278
- if (key !== 'r' && key !== 'R') return false;
279
- if (!ctx.executeCommand) return false;
280
-
281
- if (key === 'R') {
282
- void ctx.executeCommand('eval', ['run', 'all']).catch(() => {});
283
- return true;
284
- }
285
-
286
- const suites = this._registry.getSuiteResults();
287
- const suiteName = this._selectedSuiteName(suites);
288
- if (!suiteName) return false;
289
- void ctx.executeCommand('eval', ['run', suiteName]).catch(() => {});
290
- return true;
291
- }
292
-
293
- public render(width: number, height: number): Line[] {
294
- this.needsRender = false;
295
- const suites = this._registry.getSuiteResults();
296
- const gates = this._registry.getGateResults();
297
- const intro = 'Evaluation harness runs, gates, scenario scorecards, and regression indicators for model and product validation.';
298
-
299
- if (suites.length === 0) {
300
- if (this._baseline && Object.keys(this._baseline.suites).length > 0) {
301
- const workspace = this._renderBaselineList(this._baseline, width, height, intro);
302
- while (workspace.length < height) workspace.push(createEmptyLine(width));
303
- return workspace;
304
- }
305
-
306
- const workspace = buildPanelWorkspace(width, height, {
307
- title: 'Eval Harness',
308
- intro,
309
- sections: [{
310
- title: 'Status',
311
- lines: [
312
- this._statusLine(width),
313
- buildPanelLine(width, [[' No results yet — no baseline on disk.', C.dim]]),
314
- ],
315
- }],
316
- footerLines: [buildKeyboardHints(width, [
317
- { keys: 'r', label: 'run selected suite' },
318
- { keys: 'R', label: 'run all suites' },
319
- ], C)],
320
- palette: C,
321
- });
322
- while (workspace.length < height) workspace.push(createEmptyLine(width));
323
- return workspace;
324
- }
325
-
326
- const lines: Line[] = [];
327
- if (this._mode === 'list') {
328
- this._renderList(lines, suites, gates, width, height, intro);
329
- } else {
330
- const suite = suites[this._selectedSuiteIdx];
331
- if (suite) {
332
- this._renderDetail(lines, suite, gates, width, height, intro);
333
- }
334
- }
335
-
336
- return lines;
337
- }
338
-
339
- // ── Shared summary line ───────────────────────────────────────────────────
340
-
341
- private _statusLine(width: number): Line {
342
- const running = this._registry.isRunning();
343
- const lastRun = this._registry.getLastRunAt();
344
- const suites = this._registry.getSuiteResults();
345
- const passed = suites.filter((s) => s.passed).length;
346
- const failed = suites.length - passed;
347
- return buildPanelLine(width, [
348
- [' state ', C.label],
349
- [running ? 'running' : 'idle', running ? C.warn : C.dim],
350
- [' passed ', C.label],
351
- [String(passed), passed > 0 ? C.good : C.dim],
352
- [' failed ', C.label],
353
- [String(failed), failed > 0 ? C.bad : C.dim],
354
- [' last ', C.label],
355
- [lastRun ? new Date(lastRun).toLocaleTimeString() : 'n/a', C.dim],
356
- ]);
357
- }
358
-
359
- // ── List view ────────────────────────────────────────────────────────────────
360
-
361
- private _renderList(
362
- lines: Line[],
363
- suites: EvalSuiteResult[],
364
- gates: EvalGateResult[],
365
- width: number,
366
- height: number,
367
- intro: string,
368
- ): void {
369
- const gateMap = new Map(gates.map((g) => [g.suite, g]));
370
-
371
- const tableRows = suites.map((suite, idx) => {
372
- const selected = idx === this._selectedSuiteIdx;
373
- const gate = gateMap.get(suite.suite);
374
- const gateStr = gate ? (gate.passed ? 'ok' : 'FAIL') : '-';
375
- const gateColor = gate ? (gate.passed ? C.good : C.bad) : C.dim;
376
- const durationMs = suite.finishedAt - suite.startedAt;
377
- return {
378
- selected,
379
- cells: [
380
- { text: suite.suite, fg: selected ? C.selected : C.value, bold: selected },
381
- { text: suite.meanScore.toFixed(1), fg: scoreColor(suite.meanScore) },
382
- { text: suite.passed ? 'PASS' : 'FAIL', fg: suite.passed ? C.good : C.bad },
383
- { text: gateStr, fg: gateColor },
384
- { text: fmtTime(durationMs), fg: C.dim },
385
- ],
386
- };
387
- });
388
-
389
- const tableLines = buildTable(width, [
390
- { label: 'Suite' },
391
- { label: 'Score', width: 7, align: 'right' },
392
- { label: 'Pass', width: 6 },
393
- { label: 'Gate', width: 6 },
394
- { label: 'Duration', width: 10, align: 'right' },
395
- ], tableRows, C, { selectedBg: C.selectBg });
396
-
397
- const selectedSuite = suites[this._selectedSuiteIdx];
398
- const detailLines: Line[] = [];
399
- if (selectedSuite) {
400
- const passCount = selectedSuite.results.filter((r) => r.scorecard.passed).length;
401
- detailLines.push(buildPanelLine(width, [
402
- [' selected ', C.label],
403
- [selectedSuite.suite, C.info],
404
- [' scenarios ', C.label],
405
- [`${passCount}/${selectedSuite.results.length} passed`, passCount === selectedSuite.results.length ? C.good : C.warn],
406
- ]));
407
- const meterW = Math.max(10, Math.min(30, width - 24));
408
- detailLines.push(buildMeterLine(width, Math.round((selectedSuite.meanScore / 100) * meterW), meterW, {
409
- filled: scoreColor(selectedSuite.meanScore),
410
- empty: C.empty,
411
- label: C.label,
412
- }, { prefix: ' mean ', suffix: ` ${selectedSuite.meanScore.toFixed(1)}/100 ` }));
413
-
414
- const gate = gateMap.get(selectedSuite.suite);
415
- if (gate && gate.regressions.length > 0) {
416
- const worst = [...gate.regressions].sort((a, b) => a.delta - b.delta)[0];
417
- const segments: Array<[string, string]> = [
418
- [' regressions ', C.label],
419
- [`${gate.regressions.length}`, C.bad],
420
- ];
421
- if (worst) {
422
- segments.push([' worst ', C.label], [`${worst.scenarioName} ${worst.delta.toFixed(1)}`, C.bad]);
423
- }
424
- detailLines.push(buildPanelLine(width, segments));
425
- }
426
- }
427
-
428
- const footer = buildKeyboardHints(width, [
429
- { keys: `${this._selectedSuiteIdx + 1}/${suites.length}`, label: 'suite' },
430
- { keys: '↑/↓', label: 'navigate' },
431
- { keys: 'Enter', label: 'open detail' },
432
- { keys: 'r', label: 'run selected' },
433
- { keys: 'R', label: 'run all' },
434
- ], C);
435
-
436
- lines.push(...buildPanelWorkspace(width, height, {
437
- title: 'Eval Harness',
438
- intro,
439
- sections: [
440
- { lines: [this._statusLine(width)] },
441
- { title: 'Suites', lines: tableLines },
442
- ...(detailLines.length > 0 ? [{ title: 'Selected Suite', lines: detailLines }] : []),
443
- ],
444
- footerLines: [footer],
445
- palette: C,
446
- }));
447
- }
448
-
449
- // ── Detail view ──────────────────────────────────────────────────────────────
450
-
451
- private _renderDetail(
452
- lines: Line[],
453
- suite: EvalSuiteResult,
454
- gates: EvalGateResult[],
455
- width: number,
456
- height: number,
457
- intro: string,
458
- ): void {
459
- const passCount = suite.results.filter((r) => r.scorecard.passed).length;
460
- const gate = gates.find((g) => g.suite === suite.suite);
461
- const regressionMap = new Map((gate?.regressions ?? []).map((r) => [r.scenarioId, r]));
462
-
463
- const headerLines: Line[] = [
464
- this._statusLine(width),
465
- buildPanelLine(width, [
466
- [' suite ', C.label],
467
- [suite.suite, C.info],
468
- [' mean ', C.label],
469
- [suite.meanScore.toFixed(1), scoreColor(suite.meanScore)],
470
- [' ', C.label],
471
- [suite.passed ? 'PASS' : 'FAIL', suite.passed ? C.good : C.bad],
472
- [' scenarios ', C.label],
473
- [`${passCount}/${suite.results.length} passed`, passCount === suite.results.length ? C.good : C.warn],
474
- ]),
475
- ];
476
- if (gate && gate.regressions.length > 0) {
477
- headerLines.push(buildPanelLine(width, [
478
- [' regressions ', C.label],
479
- [`${gate.regressions.length} scenario(s) below baseline`, C.bad],
480
- ]));
481
- }
482
-
483
- const allDetailLines: Line[] = [];
484
- suite.results.forEach((result, idx) => {
485
- const selected = idx === this._selectedScenarioIdx;
486
- this._renderScenarioBlock(allDetailLines, result, selected, width, regressionMap.get(result.scenario.id));
487
- });
488
-
489
- const footer = buildKeyboardHints(width, [
490
- { keys: `${this._selectedScenarioIdx + 1}/${suite.results.length}`, label: 'scenario' },
491
- { keys: 'Esc', label: 'back' },
492
- { keys: '↑/↓', label: 'navigate' },
493
- { keys: 'PgUp/PgDn', label: 'scroll' },
494
- ], C);
495
-
496
- const detailSection = resolveScrollablePanelSection(width, height, {
497
- intro,
498
- footerLines: [footer],
499
- palette: C,
500
- beforeSections: [{ title: `Scenario Detail · ${suite.suite}`, lines: headerLines }],
501
- section: {
502
- scrollableLines: allDetailLines,
503
- scrollOffset: this._scrollOffset,
504
- minRows: 1,
505
- appendWindowSummary: { dimColor: C.dim },
506
- },
507
- });
508
- this._scrollOffset = detailSection.scrollOffset;
509
-
510
- lines.push(...buildPanelWorkspace(width, height, {
511
- title: 'Eval Harness',
512
- intro,
513
- sections: [{ title: `Scenario Detail · ${suite.suite}`, lines: [...headerLines, ...detailSection.section.lines] }],
514
- footerLines: [footer],
515
- palette: C,
516
- }));
517
- }
518
-
519
- private _renderScenarioBlock(
520
- lines: Line[],
521
- result: EvalResult,
522
- selected: boolean,
523
- width: number,
524
- regression: RegressionEntry | undefined,
525
- ): void {
526
- const sc = result.scorecard;
527
- const scoreC = scoreColor(sc.compositeScore);
528
- const passC = sc.passed ? C.good : C.bad;
529
- const nameText = regression ? `▼ ${result.scenario.name}` : result.scenario.name;
530
- const nameColor = selected ? C.selected : (regression ? C.bad : C.value);
531
-
532
- lines.push(buildAlignedRow(
533
- width,
534
- [
535
- { text: nameText, fg: nameColor, bold: selected },
536
- { text: sc.compositeScore.toFixed(1), fg: scoreC },
537
- { text: sc.passed ? 'PASS' : 'FAIL', fg: passC },
538
- ],
539
- [
540
- { width: Math.max(8, width - 16) },
541
- { width: 6, align: 'right' },
542
- { width: 5 },
543
- ],
544
- { gap: 1, selected, selectedBg: C.selectBg, marker: '▸' },
545
- ));
546
-
547
- if (selected) {
548
- for (const dim of DIMENSION_ORDER) {
549
- const d = sc.dimensions.find((x) => x.dimension === dim);
550
- if (!d) continue;
551
- const filled = Math.round(d.score / 10);
552
- lines.push(buildMeterLine(width, filled, 10, {
553
- filled: scoreColor(d.score),
554
- empty: C.empty,
555
- label: C.label,
556
- }, { prefix: ` ${dim.padEnd(9)} `, suffix: ` ${d.score.toFixed(0).padStart(3)}/100 ` }));
557
- }
558
-
559
- if (regression) {
560
- lines.push(buildPanelLine(width, [
561
- [' ▼ regression vs baseline ', C.bad],
562
- [`${regression.baselineScore.toFixed(1)} -> ${regression.freshScore.toFixed(1)} (${regression.delta >= 0 ? '+' : ''}${regression.delta.toFixed(1)})`, C.bad],
563
- ]));
564
- }
565
-
566
- if (sc.notes && sc.notes.length > 0) {
567
- for (const note of sc.notes) {
568
- lines.push(buildPanelLine(width, [
569
- [' ! ', C.warn],
570
- [truncateDisplay(note, Math.max(8, width - 6)), C.warn],
571
- ]));
572
- }
573
- }
574
- }
575
- }
576
-
577
- // ── Baseline-seeded list (no live suite results yet) ─────────────────────────
578
-
579
- private _renderBaselineList(
580
- baseline: EvalBaseline,
581
- width: number,
582
- height: number,
583
- intro: string,
584
- ): Line[] {
585
- const entries = Object.entries(baseline.suites);
586
-
587
- const tableRows = entries.map(([name, summary], idx) => {
588
- const selected = idx === this._selectedSuiteIdx;
589
- const scenarioCount = Object.keys(summary.scenarioScores).length;
590
- return {
591
- selected,
592
- cells: [
593
- { text: name, fg: selected ? C.selected : C.value, bold: selected },
594
- { text: summary.meanScore.toFixed(1), fg: scoreColor(summary.meanScore) },
595
- { text: `${scenarioCount}`, fg: C.dim },
596
- ],
597
- };
598
- });
599
-
600
- const tableLines = buildTable(width, [
601
- { label: 'Suite' },
602
- { label: 'Score', width: 7, align: 'right' },
603
- { label: 'Scenarios', width: 10, align: 'right' },
604
- ], tableRows, C, { selectedBg: C.selectBg });
605
-
606
- const footer = buildKeyboardHints(width, [
607
- { keys: `${entries.length > 0 ? this._selectedSuiteIdx + 1 : 0}/${entries.length}`, label: 'suite' },
608
- { keys: '↑/↓', label: 'navigate' },
609
- { keys: 'r', label: 'run selected' },
610
- { keys: 'R', label: 'run all' },
611
- ], C);
612
-
613
- return buildPanelWorkspace(width, height, {
614
- title: 'Eval Harness',
615
- intro,
616
- sections: [
617
- { lines: [this._statusLine(width)] },
618
- {
619
- title: `Baseline · ${baseline.label} (captured ${new Date(baseline.capturedAt).toLocaleString()})`,
620
- lines: tableLines,
621
- },
622
- ],
623
- footerLines: [footer],
624
- palette: C,
625
- });
626
- }
627
- }