@mrclrchtr/supi-code-intelligence 1.12.1 → 1.14.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 (54) hide show
  1. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/README.md +10 -0
  2. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  3. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  4. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +57 -0
  5. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +4 -0
  6. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/progress-widget.ts +98 -17
  7. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +8 -1
  8. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/report.ts +121 -0
  9. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
  10. package/node_modules/@mrclrchtr/supi-core/README.md +10 -0
  11. package/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  12. package/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  13. package/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +57 -0
  14. package/node_modules/@mrclrchtr/supi-core/src/index.ts +4 -0
  15. package/node_modules/@mrclrchtr/supi-core/src/progress-widget.ts +98 -17
  16. package/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +8 -1
  17. package/node_modules/@mrclrchtr/supi-core/src/report.ts +121 -0
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/README.md +10 -0
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +4 -2
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +57 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +4 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/progress-widget.ts +98 -17
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +8 -1
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/report.ts +121 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/README.md +10 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  29. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +57 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/index.ts +4 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/progress-widget.ts +98 -17
  33. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +8 -1
  34. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/report.ts +121 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  36. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/README.md +10 -0
  37. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +4 -2
  38. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  39. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +57 -0
  40. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/index.ts +4 -0
  41. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/progress-widget.ts +98 -17
  42. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +8 -1
  43. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/report.ts +121 -0
  44. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
  45. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/README.md +10 -0
  46. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +3 -1
  47. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -0
  48. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +57 -0
  49. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/index.ts +4 -0
  50. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/progress-widget.ts +98 -17
  51. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +8 -1
  52. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/report.ts +121 -0
  53. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  54. package/package.json +5 -5
@@ -8,16 +8,38 @@ import { CancellableLoader, Container, Text } from "@earendil-works/pi-tui";
8
8
 
9
9
  // ── Types ──────────────────────────────────────────────────────────────────
10
10
 
11
+ /** What the reviewer is currently doing and on what. */
12
+ export interface CurrentFocus {
13
+ /** Display label for the active tool (e.g. "Reading", "Searching", "Finding"). */
14
+ label: string;
15
+ /** Context detail (e.g. file path, search pattern, directory). */
16
+ detail: string;
17
+ }
18
+
11
19
  /** Progress state for widget display, compatible with child-session updates. */
12
20
  export interface WidgetProgress {
13
21
  /** Number of agent turns completed. */
14
22
  turns: number;
15
23
  /** Number of tool executions started. */
16
24
  toolUses: number;
17
- /** Human-readable active tool descriptions. */
18
- activities: string[];
19
25
  /** Token usage stats, if available. */
20
- tokens?: { input: number; output: number; total: number };
26
+ tokens?: {
27
+ input: number;
28
+ output: number;
29
+ total: number;
30
+ cacheRead?: number;
31
+ cacheWrite?: number;
32
+ };
33
+ /** Per-tool execution counts keyed by short display label (e.g. "diffs", "reads", "greps"). */
34
+ toolCounts?: Record<string, number>;
35
+ /** Number of distinct files inspected so far (via read_snapshot_diff / read_snapshot_file). */
36
+ filesInspected?: number;
37
+ /** Total files in the review snapshot. */
38
+ filesTotal?: number;
39
+ /** Current tool + context for the progress narrative line. */
40
+ currentFocus?: CurrentFocus;
41
+ /** Elapsed time in milliseconds since the operation started. */
42
+ elapsedMs?: number;
21
43
  }
22
44
 
23
45
  // ── Widget ─────────────────────────────────────────────────────────────────
@@ -25,12 +47,12 @@ export interface WidgetProgress {
25
47
  /**
26
48
  * TUI progress widget for long-running operations.
27
49
  *
28
- * Shows an animated loader, turn count, tool uses, token count, and any active
29
- * tool descriptions while the child session or operation is running.
50
+ * Two-line layout: top line shows the narrative (current focus + file progress),
51
+ * bottom line shows stats (tokens, elapsed time, turns, tool counts).
30
52
  */
31
53
  export class ProgressWidget extends Container {
32
54
  private message: string;
33
- private progress: WidgetProgress = { turns: 0, toolUses: 0, activities: [] };
55
+ private progress: WidgetProgress = { turns: 0, toolUses: 0 };
34
56
  private loader: CancellableLoader;
35
57
  private tui: { requestRender(): void };
36
58
  private theme: Theme;
@@ -79,30 +101,89 @@ export class ProgressWidget extends Container {
79
101
 
80
102
  private renderContent(): void {
81
103
  this.clear();
104
+ this.renderTopLine();
105
+ this.renderBottomLine();
106
+ }
82
107
 
83
- const stats: string[] = [];
84
- if (this.progress.turns > 0) stats.push(`⟳${this.progress.turns}`);
85
- if (this.progress.toolUses > 0) stats.push(`${this.progress.toolUses} tool uses`);
86
- if (this.progress.tokens) stats.push(`${formatTokens(this.progress.tokens.total)} tokens`);
108
+ private renderTopLine(): void {
109
+ const topParts: string[] = [];
87
110
 
88
- const loaderMessage =
89
- stats.length > 0 ? `${this.message} · ${stats.join(" · ")}` : this.message;
111
+ if (this.progress.currentFocus) {
112
+ const { label, detail } = this.progress.currentFocus;
113
+ topParts.push(detail ? `${label}: ${detail}` : label);
114
+ }
115
+
116
+ if (this.progress.filesTotal && this.progress.filesTotal > 0) {
117
+ const inspected = this.progress.filesInspected ?? 0;
118
+ topParts.push(`${inspected}/${this.progress.filesTotal} files`);
119
+ }
90
120
 
121
+ const loaderMessage =
122
+ topParts.length > 0 ? `${this.message} · ${topParts.join(" · ")}` : this.message;
91
123
  this.loader.setMessage(loaderMessage);
92
124
  this.addChild(this.loader);
125
+ }
126
+
127
+ private renderBottomLine(): void {
128
+ const stats: string[] = [];
129
+
130
+ this.appendTokenStats(stats);
131
+
132
+ if (this.progress.elapsedMs !== undefined && this.progress.elapsedMs >= 1000) {
133
+ stats.push(formatElapsed(this.progress.elapsedMs));
134
+ }
93
135
 
94
- if (this.progress.activities.length > 0) {
95
- this.addChild(
96
- new Text(this.theme.fg("dim", ` ⎿ ${this.progress.activities.join(", ")}…`), 1, 0),
97
- );
136
+ if (this.progress.turns > 0) {
137
+ stats.push(`⟳ ${this.progress.turns}`);
98
138
  }
139
+
140
+ if (this.progress.toolCounts) {
141
+ const parts = Object.entries(this.progress.toolCounts)
142
+ .filter(([, count]) => count > 0)
143
+ .sort(([, a], [, b]) => b - a)
144
+ .map(([label, count]) => `${count} ${label}`);
145
+ if (parts.length > 0) stats.push(parts.join(" · "));
146
+ }
147
+
148
+ if (stats.length > 0) {
149
+ this.addChild(new Text(this.theme.fg("dim", ` ${stats.join(" · ")}`), 1, 0));
150
+ }
151
+ }
152
+
153
+ private appendTokenStats(stats: string[]): void {
154
+ const tokens = this.progress.tokens;
155
+ if (!tokens) return;
156
+
157
+ stats.push(`↑ ${formatTokens(tokens.input)}`);
158
+ if (tokens.cacheRead !== undefined && tokens.cacheRead > 0) {
159
+ stats.push(`↲ ${formatTokens(tokens.cacheRead)}`);
160
+ }
161
+ if (tokens.cacheWrite !== undefined && tokens.cacheWrite > 0) {
162
+ stats.push(`↱ ${formatTokens(tokens.cacheWrite)}`);
163
+ }
164
+ stats.push(`↓ ${formatTokens(tokens.output)}`);
99
165
  }
100
166
  }
101
167
 
102
168
  // ── Helpers ────────────────────────────────────────────────────────────────
103
169
 
104
- function formatTokens(count: number): string {
170
+ export function formatTokens(count: number): string {
105
171
  if (count >= 1_000_000) return `${(count / 1_000_000).toFixed(1)}M`;
106
172
  if (count >= 1_000) return `${(count / 1_000).toFixed(1)}k`;
107
173
  return String(count);
108
174
  }
175
+
176
+ export function formatElapsed(ms: number): string {
177
+ const totalSec = Math.floor(ms / 1000);
178
+ const hours = Math.floor(totalSec / 3600);
179
+ const minutes = Math.floor((totalSec % 3600) / 60);
180
+ const seconds = totalSec % 60;
181
+
182
+ if (hours > 0) {
183
+ return `${hours}h ${minutes}m ${seconds}s`;
184
+ }
185
+ if (minutes > 0) {
186
+ return `${minutes}m ${seconds}s`;
187
+ }
188
+ return `${seconds}s`;
189
+ }
@@ -27,7 +27,7 @@ function getGlobalRegistryMap<T>(name: string): Map<string, T> {
27
27
  *
28
28
  * @typeParam T - The value type stored in the registry.
29
29
  * @param name - Unique registry name (used to construct the `Symbol.for` key).
30
- * @returns An object with `register`, `getAll`, and `clear` functions.
30
+ * @returns An object with `register`, `unregister`, `getAll`, and `clear` functions.
31
31
  */
32
32
  export function createRegistry<T>(name: string) {
33
33
  const getMap = (): Map<string, T> => getGlobalRegistryMap<T>(name);
@@ -40,6 +40,13 @@ export function createRegistry<T>(name: string) {
40
40
  getMap().set(id, value);
41
41
  },
42
42
 
43
+ /**
44
+ * Remove a registration by id. No-op if not registered.
45
+ */
46
+ unregister: (id: string): void => {
47
+ getMap().delete(id);
48
+ },
49
+
43
50
  /**
44
51
  * Get all registered values in registration order.
45
52
  */
@@ -0,0 +1,121 @@
1
+ import type { Theme } from "@earendil-works/pi-coding-agent";
2
+ import { truncateToWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
3
+
4
+ /** Minimal theme surface required by the shared report helpers. */
5
+ export type ReportTheme = Pick<Theme, "fg">;
6
+
7
+ /** Color keys accepted by the report helpers. */
8
+ export type ReportColor = Parameters<Theme["fg"]>[0];
9
+
10
+ /** Options for rendering a themed key/value report row. */
11
+ export interface KeyValueLineOptions {
12
+ /** The label shown on the left. */
13
+ label: string;
14
+ /** The value shown on the right. */
15
+ value: string;
16
+ /** Theme used for color formatting. */
17
+ theme: ReportTheme;
18
+ /** Maximum rendered width. */
19
+ width: number;
20
+ /** Left indentation in spaces. */
21
+ indent?: number;
22
+ /** Theme color applied to the label. Defaults to `"text"`. */
23
+ labelColor?: ReportColor;
24
+ /** Theme color applied to the value. Defaults to `"dim"`. */
25
+ valueColor?: ReportColor;
26
+ /** Separator placed between label and value. Defaults to `": "`. */
27
+ separator?: string;
28
+ }
29
+
30
+ /** Options for rendering a preview-overflow hint. */
31
+ export interface OverflowHintOptions {
32
+ /** Optional follow-up hint such as `run /supi-context full`. */
33
+ hint?: string | null;
34
+ /** Left indentation in spaces. Defaults to `2`. */
35
+ indent?: number;
36
+ }
37
+
38
+ /** Ensure a report width never drops below the minimum readable width. */
39
+ export function clampReportWidth(width: number, minWidth = 24): number {
40
+ return Math.max(minWidth, width);
41
+ }
42
+
43
+ /** Render a top-level report title line with theme color and truncation. */
44
+ export function formatReportTitle(
45
+ title: string,
46
+ theme: ReportTheme,
47
+ width: number,
48
+ color: ReportColor = "accent",
49
+ ): string {
50
+ return truncateToWidth(theme.fg(color, title), width);
51
+ }
52
+
53
+ /**
54
+ * Render a section header with optional dimmed metadata.
55
+ *
56
+ * Example: `Usage by category 42.3k tokens`
57
+ */
58
+ export function formatSectionHeader(
59
+ title: string,
60
+ meta: string | null,
61
+ theme: ReportTheme,
62
+ width: number,
63
+ ): string {
64
+ const left = theme.fg("text", title);
65
+ const content = meta ? `${left}${theme.fg("dim", ` ${meta}`)}` : left;
66
+ return truncateToWidth(content, width);
67
+ }
68
+
69
+ /** Render a single dimmed report line with optional left indentation. */
70
+ export function formatDimLine(text: string, theme: ReportTheme, width: number, indent = 0): string {
71
+ const safeIndent = Math.max(0, indent);
72
+ return truncateToWidth(`${" ".repeat(safeIndent)}${theme.fg("dim", text)}`, width);
73
+ }
74
+
75
+ /** Render a dimmed preview-overflow hint such as `… and 3 more — run /foo full`. */
76
+ export function formatOverflowHint(
77
+ hiddenCount: number,
78
+ theme: ReportTheme,
79
+ width: number,
80
+ options: OverflowHintOptions = {},
81
+ ): string {
82
+ const { hint = null, indent = 2 } = options;
83
+ const suffix = hint ? ` — ${hint}` : "";
84
+ return formatDimLine(`… and ${hiddenCount} more${suffix}`, theme, width, indent);
85
+ }
86
+
87
+ /** Render a single themed `label: value` row with truncation. */
88
+ export function formatKeyValueLine(options: KeyValueLineOptions): string {
89
+ const {
90
+ label,
91
+ value,
92
+ theme,
93
+ width,
94
+ indent = 2,
95
+ labelColor = "text",
96
+ valueColor = "dim",
97
+ separator = ": ",
98
+ } = options;
99
+ const safeIndent = Math.max(0, indent);
100
+
101
+ return truncateToWidth(
102
+ `${" ".repeat(safeIndent)}${theme.fg(labelColor, label)}${separator}${theme.fg(valueColor, value)}`,
103
+ width,
104
+ );
105
+ }
106
+
107
+ /**
108
+ * Wrap a report text block to the available width and optionally prefix each line.
109
+ *
110
+ * This is useful for wrapped bullets or explanatory notes that should align
111
+ * under an existing report indent.
112
+ */
113
+ export function wrapReportText(
114
+ text: string,
115
+ width: number,
116
+ options: { indent?: string } = {},
117
+ ): string[] {
118
+ const indent = options.indent ?? "";
119
+ const wrapped = wrapTextWithAnsi(text, Math.max(1, width - indent.length));
120
+ return indent ? wrapped.map((line) => `${indent}${line}`) : wrapped;
121
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-tree-sitter",
3
- "version": "1.12.1",
3
+ "version": "1.14.0",
4
4
  "description": "SuPi Tree-sitter extension — structural AST analysis for pi",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,8 +24,8 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "web-tree-sitter": "^0.26.8",
27
- "@mrclrchtr/supi-code-runtime": "1.12.1",
28
- "@mrclrchtr/supi-core": "1.12.1"
27
+ "@mrclrchtr/supi-code-runtime": "1.14.0",
28
+ "@mrclrchtr/supi-core": "1.14.0"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@earendil-works/pi-ai": "*",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-code-intelligence",
3
- "version": "1.12.1",
3
+ "version": "1.14.0",
4
4
  "description": "SuPi Code Intelligence extension — architecture briefs, caller/callee analysis, impact assessment, and pattern search for pi",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -19,10 +19,10 @@
19
19
  "src/**/*.ts"
20
20
  ],
21
21
  "dependencies": {
22
- "@mrclrchtr/supi-code-runtime": "1.12.1",
23
- "@mrclrchtr/supi-lsp": "1.12.1",
24
- "@mrclrchtr/supi-tree-sitter": "1.12.1",
25
- "@mrclrchtr/supi-core": "1.12.1"
22
+ "@mrclrchtr/supi-code-runtime": "1.14.0",
23
+ "@mrclrchtr/supi-core": "1.14.0",
24
+ "@mrclrchtr/supi-lsp": "1.14.0",
25
+ "@mrclrchtr/supi-tree-sitter": "1.14.0"
26
26
  },
27
27
  "bundledDependencies": [
28
28
  "@mrclrchtr/supi-code-runtime",