@mrclrchtr/supi-review 7.3.1 → 7.4.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 (46) hide show
  1. package/README.md +4 -0
  2. package/node_modules/@mrclrchtr/supi-agent-runtime/README.md +10 -0
  3. package/node_modules/@mrclrchtr/supi-agent-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-agent-runtime/package.json +7 -3
  5. package/node_modules/@mrclrchtr/supi-agent-runtime/src/api.ts +37 -1
  6. package/node_modules/@mrclrchtr/supi-agent-runtime/src/run.ts +151 -21
  7. package/node_modules/@mrclrchtr/supi-agent-runtime/src/session/agent-run-registry-types.ts +95 -0
  8. package/node_modules/@mrclrchtr/supi-agent-runtime/src/session/agent-run-registry.ts +372 -0
  9. package/node_modules/@mrclrchtr/supi-agent-runtime/src/session/transcript-format.ts +184 -0
  10. package/node_modules/@mrclrchtr/supi-agent-runtime/src/session/transcript-store.ts +284 -0
  11. package/node_modules/@mrclrchtr/supi-agent-runtime/src/types.ts +22 -0
  12. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-command.ts +206 -0
  13. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-overlay-data.ts +78 -0
  14. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-overlay-render.ts +167 -0
  15. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-overlay.ts +400 -0
  16. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-list.ts +95 -0
  17. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-switcher.ts +29 -0
  18. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-viewer-input.ts +69 -0
  19. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-viewer-render.ts +246 -0
  20. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-viewer.ts +400 -0
  21. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-viewport.ts +112 -0
  22. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-steering-input.ts +50 -0
  23. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-transcript-context.ts +56 -0
  24. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-transcript-pane.ts +386 -0
  25. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-transcript-payload.ts +66 -0
  26. package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-transcript.ts +380 -0
  27. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  28. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  29. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  30. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  31. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  32. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  33. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  34. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  35. package/node_modules/@mrclrchtr/supi-code-intelligence/package.json +5 -5
  36. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  37. package/package.json +4 -4
  38. package/src/review.ts +5 -2
  39. package/src/tool/review_run/child-session.ts +29 -7
  40. package/src/tool/review_run/execute.ts +6 -1
  41. package/src/tool/review_run/execution.ts +6 -0
  42. package/src/tool/review_run/register.ts +3 -1
  43. package/src/tool/review_run/runner.ts +40 -0
  44. package/src/tool/review_run/workflow.ts +7 -1
  45. package/src/tui/review-command.ts +74 -3
  46. package/src/types.ts +5 -0
@@ -0,0 +1,69 @@
1
+ import type { KeybindingsManager } from "@earendil-works/pi-coding-agent";
2
+ import { Key, type KeyId, matchesKey } from "@earendil-works/pi-tui";
3
+
4
+ type KeybindingAction = Parameters<KeybindingsManager["matches"]>[1];
5
+ type MatchKey = (data: string, action: KeybindingAction, fallback: KeyId) => boolean;
6
+ type TranscriptNavigation = "page-up" | "page-down" | "start" | "end";
7
+
8
+ /** Handle keys that change the selected run view or run. */
9
+ export function handleRunViewerPageInput(
10
+ data: string,
11
+ actions: {
12
+ readonly isCancel: (data: string) => boolean;
13
+ readonly returnToList: () => void;
14
+ readonly toggleView: () => void;
15
+ readonly switchRun: (direction: -1 | 1) => void;
16
+ },
17
+ ): boolean {
18
+ if (actions.isCancel(data)) {
19
+ actions.returnToList();
20
+ return true;
21
+ }
22
+ if (matchesKey(data, Key.tab)) {
23
+ actions.toggleView();
24
+ return true;
25
+ }
26
+ if (matchesKey(data, Key.alt("left"))) {
27
+ actions.switchRun(-1);
28
+ return true;
29
+ }
30
+ if (matchesKey(data, Key.alt("right"))) {
31
+ actions.switchRun(1);
32
+ return true;
33
+ }
34
+ return false;
35
+ }
36
+
37
+ /** Route transcript navigation keys to the active run view. */
38
+ export function handleTranscriptNavigation(
39
+ data: string,
40
+ matches: MatchKey,
41
+ scrollBy: (lines: number) => void,
42
+ navigate: (action: TranscriptNavigation) => void,
43
+ ): boolean {
44
+ if (matches(data, "tui.select.up", Key.up)) {
45
+ scrollBy(-1);
46
+ return true;
47
+ }
48
+ if (matches(data, "tui.select.down", Key.down)) {
49
+ scrollBy(1);
50
+ return true;
51
+ }
52
+ if (matches(data, "tui.altScreen.pageUp", Key.pageUp)) {
53
+ navigate("page-up");
54
+ return true;
55
+ }
56
+ if (matches(data, "tui.altScreen.pageDown", Key.pageDown)) {
57
+ navigate("page-down");
58
+ return true;
59
+ }
60
+ if (matches(data, "tui.altScreen.top", Key.home)) {
61
+ navigate("start");
62
+ return true;
63
+ }
64
+ if (matches(data, "tui.altScreen.bottom", Key.end)) {
65
+ navigate("end");
66
+ return true;
67
+ }
68
+ return false;
69
+ }
@@ -0,0 +1,246 @@
1
+ import {
2
+ DynamicBorder,
3
+ type KeybindingsManager,
4
+ type Theme,
5
+ } from "@earendil-works/pi-coding-agent";
6
+ import { type Input, type SelectList, truncateToWidth } from "@earendil-works/pi-tui";
7
+ import type { AgentsOverlayRun } from "./agents-overlay-data.ts";
8
+ import { centerLegend } from "./agents-overlay-render.ts";
9
+ import { formatElapsed, type RunSection, runListPreview } from "./agents-run-list.ts";
10
+ import { runSwitcherPosition } from "./agents-run-switcher.ts";
11
+
12
+ /** Render the selected run, its filtered position, and its stable status. */
13
+ export function formatRunConversationHeading(
14
+ run: AgentsOverlayRun | undefined,
15
+ runs: readonly AgentsOverlayRun[],
16
+ section: RunSection,
17
+ transcriptIncomplete: boolean,
18
+ ): { readonly text: string; readonly canSwitchRuns: boolean } {
19
+ const position = runSwitcherPosition(runs, run?.key);
20
+ if (!run) return { text: "No Agent Run selected", canSwitchRuns: position.canSwitch };
21
+ const sectionLabel = section === "agents" ? "Agents" : "Reviews";
22
+ const runPosition =
23
+ position.position === undefined ? "pinned" : `${position.position}/${runs.length}`;
24
+ const state = `${run.status} · ${formatElapsed(run)}`;
25
+ const target = run.result?.display?.target ?? run.display?.target;
26
+ const verdict = run.result?.display?.verdict;
27
+ const review = [
28
+ target ? `target ${target}` : undefined,
29
+ verdict ? `verdict ${verdict}` : undefined,
30
+ ]
31
+ .filter(Boolean)
32
+ .join(" · ");
33
+ return {
34
+ text: `${sectionLabel} · ${runPosition} · ${run.taskId} — ${run.label} · ${state}${review ? ` · ${review}` : ""}${transcriptIncomplete ? " · transcript incomplete" : ""}`,
35
+ canSwitchRuns: position.canSwitch,
36
+ };
37
+ }
38
+
39
+ /** Keep incomplete-transcript warnings at the start of the viewer status line. */
40
+ export function formatRunViewerStatus(options: {
41
+ readonly run?: AgentsOverlayRun;
42
+ readonly transcriptStatus: string;
43
+ readonly transcriptIncomplete: boolean;
44
+ }): string {
45
+ const { run, transcriptStatus, transcriptIncomplete } = options;
46
+ const omitted = run?.conversation?.omittedEntryCount ?? 0;
47
+ const retention = omitted > 0 ? ` · ${omitted} entries omitted` : "";
48
+ const state = `${transcriptStatus} · ${run?.status ?? "No run selected"}${retention}`;
49
+ return transcriptIncomplete ? `Transcript incomplete · ${state}` : state;
50
+ }
51
+
52
+ type KeybindingAction = Parameters<KeybindingsManager["matches"]>[1];
53
+
54
+ /** Format one keyboard hint with the active keybinding when available. */
55
+ export function formatAgentsRunKeyHint(options: {
56
+ readonly theme: Theme;
57
+ readonly keybindings?: Pick<KeybindingsManager, "getKeys">;
58
+ readonly action: KeybindingAction;
59
+ readonly fallback: string;
60
+ readonly label: string;
61
+ }): string {
62
+ const { theme, keybindings, action, fallback, label } = options;
63
+ const keys = keybindings?.getKeys(action).join("/") || fallback;
64
+ return `${theme.fg("dim", keys)}${theme.fg("muted", ` ${label}`)}`;
65
+ }
66
+
67
+ /** Return concise keyboard hints for the active viewer page. */
68
+ export function renderAgentsRunHints(options: {
69
+ readonly stopConfirmation: boolean;
70
+ readonly page: "list" | "conversation" | "details";
71
+ readonly height: number;
72
+ readonly run?: AgentsOverlayRun;
73
+ readonly theme: Theme;
74
+ readonly keybindings?: Pick<KeybindingsManager, "getKeys">;
75
+ readonly canSwitchRuns: boolean;
76
+ }): string[] {
77
+ const { stopConfirmation, page, height, run, theme, keybindings, canSwitchRuns } = options;
78
+ if (stopConfirmation) return ["Enter/y confirm stop · Esc cancel"];
79
+ if (page === "list") return renderAgentsRunListHints(height);
80
+ if (height <= 8) return renderCompactRunHints(page, canSwitchRuns);
81
+ const controls = renderRunControlHints(run);
82
+ const toolsHint = formatAgentsRunKeyHint({
83
+ theme,
84
+ keybindings,
85
+ action: "app.tools.expand",
86
+ fallback: "ctrl+o",
87
+ label: "tools",
88
+ });
89
+ const thinkingHint = formatAgentsRunKeyHint({
90
+ theme,
91
+ keybindings,
92
+ action: "app.thinking.toggle",
93
+ fallback: "ctrl+t",
94
+ label: "thinking",
95
+ });
96
+ return [
97
+ "↑↓ scroll · PgUp/PgDn · Home/End",
98
+ ...(canSwitchRuns ? ["Alt+← previous · Alt+→ next"] : []),
99
+ [page === "details" ? "tab conversation" : "tab details", toolsHint, thinkingHint].join(" · "),
100
+ [...controls, "esc list"].join(" · "),
101
+ ];
102
+ }
103
+
104
+ function renderAgentsRunListHints(height: number): string[] {
105
+ return height <= 8
106
+ ? ["↑↓ move · type search · enter open · esc close"]
107
+ : ["↑↓ move · type to search · enter open", "tab sections · esc close"];
108
+ }
109
+
110
+ function renderCompactRunHints(page: "conversation" | "details", canSwitchRuns: boolean): string[] {
111
+ const navigationHint = canSwitchRuns ? "Alt+← previous · Alt+→ next" : "↑↓ scroll";
112
+ return [`${navigationHint} · tab ${page === "details" ? "conversation" : "details"} · esc list`];
113
+ }
114
+
115
+ function renderRunControlHints(run?: AgentsOverlayRun): string[] {
116
+ if (!run?.active) return [];
117
+ const controls: string[] = [];
118
+ if (run.steeringAvailable) controls.push("s steer");
119
+ if (run.status === "starting" || run.status === "running") controls.push("x stop");
120
+ return controls;
121
+ }
122
+
123
+ /** Render the full-width header for the selected section. */
124
+ export function renderAgentsRunHeader(options: {
125
+ readonly theme: Theme;
126
+ readonly header: string;
127
+ readonly tabs: string;
128
+ readonly width: number;
129
+ readonly height: number;
130
+ readonly steeringActive: boolean;
131
+ }): string[] {
132
+ const { theme, header, tabs, width, height, steeringActive } = options;
133
+ if (height <= 8 || steeringActive) return [line(`${header} ${tabs}`, width)];
134
+ return [
135
+ line(header, width),
136
+ line(tabs, width),
137
+ ...new DynamicBorder((text: string) => theme.fg("accent", text)).render(width),
138
+ ];
139
+ }
140
+
141
+ /** Render the selected page's instructions and current run status. */
142
+ export function renderAgentsRunFooter(options: {
143
+ readonly theme: Theme;
144
+ readonly hints: readonly string[];
145
+ readonly notice?: string;
146
+ readonly status?: string;
147
+ readonly steeringLines: readonly string[];
148
+ readonly steeringActive: boolean;
149
+ readonly width: number;
150
+ }): string[] {
151
+ const { theme, hints, notice, status, steeringLines, steeringActive, width } = options;
152
+ if (steeringActive) {
153
+ return [...steeringLines, ...(notice ? [line(theme.fg("warning", notice), width)] : [])];
154
+ }
155
+ return [
156
+ ...hints.map((hint) => centerLegend(theme.fg("dim", hint), width)),
157
+ ...(notice ? [line(theme.fg("warning", notice), width)] : []),
158
+ ...(status ? [line(status, width)] : []),
159
+ ];
160
+ }
161
+
162
+ /** Fit list rows and the scroll marker inside the rows available to the list. */
163
+ export function runListViewport(
164
+ height: number,
165
+ searchLineCount: number,
166
+ previewLineCount: number,
167
+ itemCount: number,
168
+ ): {
169
+ readonly previewHeight: number;
170
+ readonly listBudget: number;
171
+ readonly maxVisible: number;
172
+ readonly visibleItemCount: number;
173
+ } {
174
+ const previewHeight = Math.min(previewLineCount, Math.max(0, height - searchLineCount - 1));
175
+ const listBudget = Math.max(0, height - searchLineCount - previewHeight);
176
+ const scrollInfoRows = itemCount > listBudget && listBudget > 1 ? 1 : 0;
177
+ const maxVisible = Math.max(1, Math.min(itemCount || 1, listBudget - scrollInfoRows));
178
+ return {
179
+ previewHeight,
180
+ listBudget,
181
+ maxVisible,
182
+ visibleItemCount: Math.min(itemCount, maxVisible, listBudget),
183
+ };
184
+ }
185
+
186
+ /** Render the search box, run rows, and selected-run preview. */
187
+ export function renderAgentsRunList(options: {
188
+ readonly theme: Theme;
189
+ readonly search: Input;
190
+ readonly getSelectList: (maxVisible: number) => SelectList;
191
+ readonly selectedRun?: AgentsOverlayRun;
192
+ readonly itemCount: number;
193
+ readonly emptyMessage: string;
194
+ readonly width: number;
195
+ readonly height: number;
196
+ readonly bodyTop: number;
197
+ }): {
198
+ readonly lines: string[];
199
+ readonly listTop: number;
200
+ readonly listHeight: number;
201
+ readonly visibleItemCount: number;
202
+ } {
203
+ const {
204
+ theme,
205
+ search,
206
+ getSelectList,
207
+ selectedRun,
208
+ itemCount,
209
+ emptyMessage,
210
+ width,
211
+ height,
212
+ bodyTop,
213
+ } = options;
214
+ if (height <= 0) return { lines: [], listTop: bodyTop, listHeight: 0, visibleItemCount: 0 };
215
+ const searchLines = search.render(width).slice(0, height);
216
+ if (!selectedRun) {
217
+ const query = search.getValue().trim();
218
+ const message = query ? `No tasks match “${query}”.` : emptyMessage;
219
+ const listTop = bodyTop + searchLines.length;
220
+ const messageLines = height > searchLines.length ? [line(theme.fg("dim", message), width)] : [];
221
+ return {
222
+ lines: [...searchLines, ...messageLines],
223
+ listTop,
224
+ listHeight: messageLines.length,
225
+ visibleItemCount: 0,
226
+ };
227
+ }
228
+ const preview = runListPreview(selectedRun);
229
+ const viewport = runListViewport(height, searchLines.length, preview.length, itemCount);
230
+ const listTop = bodyTop + searchLines.length;
231
+ const selectList = getSelectList(viewport.maxVisible);
232
+ const listLines = selectList.render(width).slice(0, viewport.listBudget);
233
+ const previewLines = preview
234
+ .slice(0, viewport.previewHeight)
235
+ .map((text) => line(theme.fg("dim", text), width));
236
+ return {
237
+ lines: [...searchLines, ...listLines, ...previewLines],
238
+ listTop,
239
+ listHeight: listLines.length,
240
+ visibleItemCount: viewport.visibleItemCount,
241
+ };
242
+ }
243
+
244
+ function line(text: string, width: number): string {
245
+ return truncateToWidth(` ${text}`, width);
246
+ }