@mrclrchtr/supi-antigravity 6.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 (67) hide show
  1. package/CLAUDE.md +21 -0
  2. package/CONTEXT.md +53 -0
  3. package/README.md +75 -0
  4. package/docs/adr/0001-use-an-isolated-antigravity-home.md +5 -0
  5. package/node_modules/@mrclrchtr/supi-core/README.md +118 -0
  6. package/node_modules/@mrclrchtr/supi-core/package.json +76 -0
  7. package/node_modules/@mrclrchtr/supi-core/src/api.ts +40 -0
  8. package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +232 -0
  9. package/node_modules/@mrclrchtr/supi-core/src/config/prompt-surface.ts +363 -0
  10. package/node_modules/@mrclrchtr/supi-core/src/config.ts +12 -0
  11. package/node_modules/@mrclrchtr/supi-core/src/context/context-provider-registry.ts +36 -0
  12. package/node_modules/@mrclrchtr/supi-core/src/context/context-tag.ts +31 -0
  13. package/node_modules/@mrclrchtr/supi-core/src/context.ts +8 -0
  14. package/node_modules/@mrclrchtr/supi-core/src/debug-identity.ts +11 -0
  15. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +308 -0
  16. package/node_modules/@mrclrchtr/supi-core/src/debug-timing.ts +120 -0
  17. package/node_modules/@mrclrchtr/supi-core/src/debug.ts +14 -0
  18. package/node_modules/@mrclrchtr/supi-core/src/evidence-badge.ts +41 -0
  19. package/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +57 -0
  20. package/node_modules/@mrclrchtr/supi-core/src/index.ts +34 -0
  21. package/node_modules/@mrclrchtr/supi-core/src/llm.ts +201 -0
  22. package/node_modules/@mrclrchtr/supi-core/src/model-selection.ts +134 -0
  23. package/node_modules/@mrclrchtr/supi-core/src/path-utils.ts +44 -0
  24. package/node_modules/@mrclrchtr/supi-core/src/path.ts +2 -0
  25. package/node_modules/@mrclrchtr/supi-core/src/project-roots.ts +170 -0
  26. package/node_modules/@mrclrchtr/supi-core/src/project.ts +15 -0
  27. package/node_modules/@mrclrchtr/supi-core/src/prompt-surface.ts +4 -0
  28. package/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +93 -0
  29. package/node_modules/@mrclrchtr/supi-core/src/report.ts +121 -0
  30. package/node_modules/@mrclrchtr/supi-core/src/session-utils.ts +71 -0
  31. package/node_modules/@mrclrchtr/supi-core/src/session.ts +8 -0
  32. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +105 -0
  33. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +453 -0
  34. package/node_modules/@mrclrchtr/supi-core/src/settings.ts +36 -0
  35. package/node_modules/@mrclrchtr/supi-core/src/spinner-frames.ts +11 -0
  36. package/node_modules/@mrclrchtr/supi-core/src/status-spinner.ts +68 -0
  37. package/node_modules/@mrclrchtr/supi-core/src/terminal.ts +60 -0
  38. package/package.json +79 -0
  39. package/scripts/live-probe.ts +161 -0
  40. package/src/activity.ts +22 -0
  41. package/src/availability.ts +231 -0
  42. package/src/catalogue.ts +21 -0
  43. package/src/config.ts +26 -0
  44. package/src/conversation/handles.ts +183 -0
  45. package/src/extension.ts +22 -0
  46. package/src/isolated-home.ts +346 -0
  47. package/src/process/environment.ts +33 -0
  48. package/src/process/event-values.ts +279 -0
  49. package/src/process/events.ts +365 -0
  50. package/src/process/hooks.ts +219 -0
  51. package/src/process/ndjson.ts +120 -0
  52. package/src/process/protocol.ts +69 -0
  53. package/src/process/runner.ts +147 -0
  54. package/src/process/subprocess.ts +278 -0
  55. package/src/process/usage.ts +50 -0
  56. package/src/runtime.ts +118 -0
  57. package/src/settings.ts +38 -0
  58. package/src/structured-output.ts +58 -0
  59. package/src/tool/antigravity_run/evidence.ts +169 -0
  60. package/src/tool/antigravity_run/execute.ts +225 -0
  61. package/src/tool/antigravity_run/guidance.ts +3 -0
  62. package/src/tool/antigravity_run/input.ts +106 -0
  63. package/src/tool/antigravity_run/register.ts +36 -0
  64. package/src/tool/antigravity_run/render.ts +236 -0
  65. package/src/tool/antigravity_run/result.ts +186 -0
  66. package/src/tool/antigravity_run/spec.ts +20 -0
  67. package/src/types.ts +107 -0
@@ -0,0 +1,308 @@
1
+ // Shared debug event registry for SuPi extensions.
2
+ //
3
+ // Extensions record session-local diagnostic events here. The user-facing
4
+ // supi-debug extension owns policy/configuration and exposes events through a
5
+ // command/tool while this module stays dependency-free for producers.
6
+
7
+ export type DebugLevel = "debug" | "info" | "warning" | "error";
8
+ export type DebugAgentAccess = "off" | "sanitized" | "raw";
9
+ export interface DebugRegistryConfig {
10
+ /** Whether producers should retain debug events. */
11
+ enabled: boolean;
12
+ /** What the agent-callable debug tool may return. */
13
+ agentAccess: DebugAgentAccess;
14
+ /** Maximum number of session-local events to keep in memory. */
15
+ maxEvents: number;
16
+ }
17
+
18
+ export const DEBUG_REGISTRY_DEFAULTS: DebugRegistryConfig = {
19
+ enabled: false,
20
+ agentAccess: "sanitized",
21
+ maxEvents: 100,
22
+ };
23
+
24
+ export interface DebugEventInput {
25
+ /** Opaque identity for events directly owned by one public Tool call. */
26
+ operationId?: string;
27
+ source: string;
28
+ level: DebugLevel;
29
+ category: string;
30
+ message: string;
31
+ cwd?: string;
32
+ data?: unknown;
33
+ rawData?: unknown;
34
+ }
35
+
36
+ export interface DebugEvent extends DebugEventInput {
37
+ id: number;
38
+ timestamp: number;
39
+ data?: unknown;
40
+ rawData?: unknown;
41
+ }
42
+
43
+ export interface DebugEventQuery {
44
+ /** Match one exact Debug Operation ID. */
45
+ operationId?: string;
46
+ source?: string;
47
+ level?: DebugLevel;
48
+ category?: string;
49
+ limit?: number;
50
+ includeRaw?: boolean;
51
+ allowRaw?: boolean;
52
+ }
53
+
54
+ export interface DebugEventView {
55
+ id: number;
56
+ timestamp: number;
57
+ operationId?: string;
58
+ source: string;
59
+ level: DebugLevel;
60
+ category: string;
61
+ message: string;
62
+ cwd?: string;
63
+ data?: unknown;
64
+ rawData?: unknown;
65
+ }
66
+
67
+ export interface DebugEventQueryResult {
68
+ events: DebugEventView[];
69
+ rawAccessDenied: boolean;
70
+ }
71
+
72
+ /** Receives a sanitized event whenever the registry records one. */
73
+ export type DebugEventListener = (event: DebugEventView) => void;
74
+
75
+ export interface DebugSummary {
76
+ total: number;
77
+ byLevel: Partial<Record<DebugLevel, number>>;
78
+ bySource: Record<string, number>;
79
+ }
80
+
81
+ interface DebugRegistryState {
82
+ config: DebugRegistryConfig;
83
+ events: DebugEvent[];
84
+ listeners: Set<DebugEventListener>;
85
+ nextId: number;
86
+ }
87
+
88
+ const REGISTRY_KEY = Symbol.for("@mrclrchtr/supi-core/debug-registry");
89
+ const DEBUG_OPERATION_ID_RE = /^op-[A-Za-z0-9_-]{21}[AQgw]$/;
90
+ const SECRET_KEY_RE = /(?:token|password|passwd|secret|api[_-]?key|authorization|credential)/i;
91
+ const ENV_SECRET_RE =
92
+ /\b([A-Za-z0-9_]*(?:token|password|passwd|secret|api[_-]?key|authorization|credential)[A-Za-z0-9_]*)=(?:'[^']*'|"[^"]*"|\S+)/gi;
93
+ const AUTH_HEADER_RE = /\b(authorization\s*[:=]\s*)(?:bearer\s+)?[^\s;&|]+/gi;
94
+ const URL_SECRET_RE =
95
+ /([?&](?:token|password|passwd|secret|api[_-]?key|authorization|credential)=)[^&\s]+/gi;
96
+ const REDACTED = "[REDACTED]";
97
+
98
+ function cloneConfig(config: DebugRegistryConfig): DebugRegistryConfig {
99
+ return { ...config };
100
+ }
101
+
102
+ function getState(): DebugRegistryState {
103
+ let state = (globalThis as Record<symbol, unknown>)[REGISTRY_KEY] as
104
+ | DebugRegistryState
105
+ | undefined;
106
+ if (!state) {
107
+ state = {
108
+ config: cloneConfig(DEBUG_REGISTRY_DEFAULTS),
109
+ events: [],
110
+ listeners: new Set(),
111
+ nextId: 1,
112
+ };
113
+ (globalThis as Record<symbol, unknown>)[REGISTRY_KEY] = state;
114
+ }
115
+ // Keep the shared registry compatible with extension reloads that reuse an
116
+ // instance created before listeners existed.
117
+ if (!state.listeners) state.listeners = new Set();
118
+ return state;
119
+ }
120
+
121
+ function normalizeMaxEvents(value: number): number {
122
+ if (!Number.isFinite(value) || value <= 0) {
123
+ return DEBUG_REGISTRY_DEFAULTS.maxEvents;
124
+ }
125
+ return Math.floor(value);
126
+ }
127
+
128
+ function trimToMaxEvents(state: DebugRegistryState): void {
129
+ const maxEvents = normalizeMaxEvents(state.config.maxEvents);
130
+ if (state.events.length <= maxEvents) {
131
+ return;
132
+ }
133
+ state.events.splice(0, state.events.length - maxEvents);
134
+ }
135
+
136
+ /** Return whether a debug level is recognized by the registry. */
137
+ export function isDebugLevel(value: unknown): value is DebugLevel {
138
+ return value === "debug" || value === "info" || value === "warning" || value === "error";
139
+ }
140
+
141
+ /** Return whether a value has the exact 16-byte base64url Debug Operation ID form. */
142
+ export function isDebugOperationId(value: unknown): value is string {
143
+ return typeof value === "string" && DEBUG_OPERATION_ID_RE.test(value);
144
+ }
145
+
146
+ /** Match a debug event against the supported exact filters. */
147
+ export function matchesDebugEventQuery(
148
+ event: Pick<DebugEventView, "operationId" | "source" | "level" | "category">,
149
+ query: Pick<DebugEventQuery, "operationId" | "source" | "level" | "category">,
150
+ ): boolean {
151
+ if (query.operationId && event.operationId !== query.operationId) return false;
152
+ if (query.source && event.source !== query.source) return false;
153
+ if (query.level && event.level !== query.level) return false;
154
+ if (query.category && event.category !== query.category) return false;
155
+ return true;
156
+ }
157
+
158
+ function sanitizeString(value: string): string {
159
+ return value
160
+ .replace(ENV_SECRET_RE, (_match, key: string) => `${key}=${REDACTED}`)
161
+ .replace(AUTH_HEADER_RE, (_match, prefix: string) => `${prefix}${REDACTED}`)
162
+ .replace(URL_SECRET_RE, (_match, prefix: string) => `${prefix}${REDACTED}`);
163
+ }
164
+
165
+ function redactValue(value: unknown, depth: number): unknown {
166
+ if (depth <= 0) return "[MaxDepth]";
167
+ if (typeof value === "string") return sanitizeString(value);
168
+ if (typeof value !== "object" || value === null) return value;
169
+ if (Array.isArray(value)) return value.map((item) => redactValue(item, depth - 1));
170
+
171
+ const redacted: Record<string, unknown> = {};
172
+ for (const [key, item] of Object.entries(value)) {
173
+ redacted[key] = SECRET_KEY_RE.test(key) ? REDACTED : redactValue(item, depth - 1);
174
+ }
175
+ return redacted;
176
+ }
177
+
178
+ /** Configure the shared debug registry. Existing events are trimmed to the new max size. */
179
+ export function configureDebugRegistry(config: Partial<DebugRegistryConfig>): DebugRegistryConfig {
180
+ const state = getState();
181
+ state.config = {
182
+ ...state.config,
183
+ ...config,
184
+ maxEvents: normalizeMaxEvents(config.maxEvents ?? state.config.maxEvents),
185
+ };
186
+ trimToMaxEvents(state);
187
+ return getDebugRegistryConfig();
188
+ }
189
+
190
+ /** Return the active debug registry configuration. */
191
+ export function getDebugRegistryConfig(): DebugRegistryConfig {
192
+ return cloneConfig(getState().config);
193
+ }
194
+
195
+ /** Return whether the Debug Registry currently retains producer events. */
196
+ export function isDebugRegistryEnabled(): boolean {
197
+ return getState().config.enabled;
198
+ }
199
+
200
+ /** Best-effort redaction helper for data exposed through sanitized debug views. */
201
+ export function redactDebugData<T>(value: T): T {
202
+ return redactValue(value, 8) as T;
203
+ }
204
+
205
+ function toSanitizedView(event: DebugEvent): DebugEventView {
206
+ return {
207
+ id: event.id,
208
+ timestamp: event.timestamp,
209
+ operationId: event.operationId,
210
+ source: event.source,
211
+ level: event.level,
212
+ category: event.category,
213
+ message: event.message,
214
+ cwd: event.cwd,
215
+ data: event.data,
216
+ };
217
+ }
218
+
219
+ /** Subscribe to sanitized events. Listeners are isolated so diagnostics cannot disrupt producers. */
220
+ export function subscribeDebugEvents(listener: DebugEventListener): () => void {
221
+ const state = getState();
222
+ state.listeners.add(listener);
223
+ return () => state.listeners.delete(listener);
224
+ }
225
+
226
+ /** Record a session-local debug event if debugging is enabled. */
227
+ export function recordDebugEvent(input: DebugEventInput): DebugEvent | null {
228
+ const state = getState();
229
+ if (input.operationId !== undefined && !isDebugOperationId(input.operationId)) {
230
+ return null;
231
+ }
232
+ if (!state.config.enabled) {
233
+ return null;
234
+ }
235
+
236
+ const event: DebugEvent = {
237
+ ...input,
238
+ id: state.nextId++,
239
+ timestamp: Date.now(),
240
+ data: input.data === undefined ? undefined : redactDebugData(input.data),
241
+ };
242
+ state.events.push(event);
243
+ trimToMaxEvents(state);
244
+ const view = toSanitizedView(event);
245
+ for (const listener of state.listeners) {
246
+ try {
247
+ listener(view);
248
+ } catch {
249
+ // Debug-event consumers must not alter producer behavior.
250
+ }
251
+ }
252
+ return { ...event };
253
+ }
254
+
255
+ /** Query retained debug events newest-first. Results are sanitized unless raw access is requested and allowed. */
256
+ export function getDebugEvents(query: DebugEventQuery = {}): DebugEventQueryResult {
257
+ const state = getState();
258
+ const allowRaw = Boolean(
259
+ query.includeRaw && query.allowRaw && state.config.agentAccess === "raw",
260
+ );
261
+ const rawAccessDenied = Boolean(query.includeRaw && !allowRaw);
262
+ const limit = query.limit && query.limit > 0 ? Math.floor(query.limit) : state.config.maxEvents;
263
+
264
+ const events = state.events
265
+ .filter((event) => matchesDebugEventQuery(event, query))
266
+ .slice()
267
+ .reverse()
268
+ .slice(0, limit)
269
+ .map((event): DebugEventView => {
270
+ const view = toSanitizedView(event);
271
+ if (allowRaw && event.rawData !== undefined) {
272
+ view.rawData = event.rawData;
273
+ }
274
+ return view;
275
+ });
276
+
277
+ return { events, rawAccessDenied };
278
+ }
279
+
280
+ /** Return aggregate debug counts suitable for summary displays. */
281
+ export function getDebugSummary(): DebugSummary | null {
282
+ const events = getState().events;
283
+ if (events.length === 0) {
284
+ return null;
285
+ }
286
+
287
+ const summary: DebugSummary = { total: events.length, byLevel: {}, bySource: {} };
288
+ for (const event of events) {
289
+ summary.byLevel[event.level] = (summary.byLevel[event.level] ?? 0) + 1;
290
+ summary.bySource[event.source] = (summary.bySource[event.source] ?? 0) + 1;
291
+ }
292
+ return summary;
293
+ }
294
+
295
+ /** Clear retained events while preserving configuration. */
296
+ export function clearDebugEvents(): void {
297
+ const state = getState();
298
+ state.events = [];
299
+ }
300
+
301
+ /** Reset the debug registry to defaults; intended for tests. */
302
+ export function resetDebugRegistry(): void {
303
+ const state = getState();
304
+ state.config = cloneConfig(DEBUG_REGISTRY_DEFAULTS);
305
+ state.events = [];
306
+ state.listeners.clear();
307
+ state.nextId = 1;
308
+ }
@@ -0,0 +1,120 @@
1
+ import { performance } from "node:perf_hooks";
2
+ import {
3
+ type DebugEvent,
4
+ type DebugEventInput,
5
+ isDebugRegistryEnabled,
6
+ recordDebugEvent,
7
+ } from "./debug-registry.ts";
8
+
9
+ /** Monotonic duration data added to a timed debug event. */
10
+ export interface DebugTiming {
11
+ readonly durationMs: number;
12
+ readonly phasesMs: Readonly<Record<string, number>>;
13
+ }
14
+
15
+ /** Debug event input whose data can receive the reserved `timing` field. */
16
+ export interface TimedDebugEventInput extends Omit<DebugEventInput, "data"> {
17
+ readonly data?: Readonly<Record<string, unknown>>;
18
+ }
19
+
20
+ /** Test seam for the monotonic clock used by a debug timer. */
21
+ export interface DebugTimerOptions {
22
+ readonly now?: () => number;
23
+ }
24
+
25
+ /** Lazy timed-event input that is not evaluated when Debug is disabled. */
26
+ export type TimedDebugEventFactory = () => TimedDebugEventInput;
27
+
28
+ /** One-shot debug timer with optional sequential phase measurements. */
29
+ export interface DebugTimer {
30
+ /** Whether this timer sampled Debug as enabled when it started. */
31
+ readonly enabled: boolean;
32
+ /** Finish the current phase and start the next unnamed interval. */
33
+ mark(phase: string): void;
34
+ /** Record one event. A second call returns `null` without recording another event. */
35
+ finish(
36
+ input: TimedDebugEventInput | TimedDebugEventFactory,
37
+ finalPhase?: string,
38
+ ): DebugEvent | null;
39
+ }
40
+
41
+ /**
42
+ * Start a monotonic timer for one debug event.
43
+ *
44
+ * Each `mark(name)` stores the interval since the previous mark. `finish()`
45
+ * stores the total duration and can name the final interval. Repeated phase
46
+ * names are accumulated. Event data reserves the `timing` field. When Debug is
47
+ * disabled at start, this returns a no-op timer and does not read the clock.
48
+ * Pass a factory to `finish()` to avoid event-data construction when disabled.
49
+ * Clock, event-construction, and registry failures are isolated from the
50
+ * measured operation and make the timer a no-op.
51
+ */
52
+ export function startDebugTimer(options: DebugTimerOptions = {}): DebugTimer {
53
+ if (!isDebugRegistryEnabled()) return DISABLED_DEBUG_TIMER;
54
+ const now = options.now ?? performance.now.bind(performance);
55
+ let startedAt: number;
56
+ try {
57
+ startedAt = now();
58
+ } catch {
59
+ return DISABLED_DEBUG_TIMER;
60
+ }
61
+ let previousAt = startedAt;
62
+ let finished = false;
63
+ let failed = false;
64
+ const phases = new Map<string, number>();
65
+
66
+ const markAt = (phase: string, current: number): void => {
67
+ const name = phase.trim();
68
+ if (!name) return;
69
+ phases.set(name, (phases.get(name) ?? 0) + Math.max(0, current - previousAt));
70
+ previousAt = current;
71
+ };
72
+
73
+ return {
74
+ enabled: true,
75
+ mark(phase) {
76
+ if (finished || failed) return;
77
+ try {
78
+ markAt(phase, now());
79
+ } catch {
80
+ failed = true;
81
+ }
82
+ },
83
+ finish(input, finalPhase) {
84
+ if (finished || failed) return null;
85
+ finished = true;
86
+ try {
87
+ if (!isDebugRegistryEnabled()) return null;
88
+ const completedAt = now();
89
+ if (finalPhase) markAt(finalPhase, completedAt);
90
+ const phasesMs = Object.fromEntries(
91
+ [...phases.entries()].map(([name, value]) => [name, duration(value)]),
92
+ );
93
+ const timing: DebugTiming = {
94
+ durationMs: duration(completedAt - startedAt),
95
+ phasesMs,
96
+ };
97
+ const eventInput = typeof input === "function" ? input() : input;
98
+ return recordDebugEvent({
99
+ ...eventInput,
100
+ data: { ...eventInput.data, timing },
101
+ });
102
+ } catch {
103
+ return null;
104
+ }
105
+ },
106
+ };
107
+ }
108
+
109
+ const DISABLED_DEBUG_TIMER: DebugTimer = Object.freeze({
110
+ enabled: false,
111
+ mark() {},
112
+ finish() {
113
+ return null;
114
+ },
115
+ });
116
+
117
+ function duration(value: number): number {
118
+ if (!Number.isFinite(value)) return 0;
119
+ return Math.round(Math.max(0, value) * 10) / 10;
120
+ }
@@ -0,0 +1,14 @@
1
+ // Debug domain entry for `@mrclrchtr/supi-core/debug`.
2
+ //
3
+ // Kept separate from debug-registry.ts so debug-timing.ts can import the
4
+ // registry without creating an import cycle through the barrel re-export.
5
+
6
+ export {
7
+ DEBUG_IDENTITY_TRUNCATION_MARKER,
8
+ MAX_DEBUG_IDENTITY_STRING,
9
+ truncateDebugIdentity,
10
+ } from "./debug-identity.ts";
11
+ // biome-ignore lint/performance/noReExportAll: preserve the stable debug domain entry point
12
+ export * from "./debug-registry.ts";
13
+ // biome-ignore lint/performance/noReExportAll: preserve the stable debug domain entry point
14
+ export * from "./debug-timing.ts";
@@ -0,0 +1,41 @@
1
+ /**
2
+ * TUI-facing evidence badge string formatter.
3
+ *
4
+ * Pure string formatting — no pi-tui dependency. Consumes evidence
5
+ * completeness metadata and produces compact human-readable badges.
6
+ */
7
+
8
+ /** Metadata describing how many evidence atoms were shown vs exist. */
9
+ export interface EvidenceBadgeInput {
10
+ shownCount: number;
11
+ totalCount: number | null;
12
+ omittedCount: number | null;
13
+ partialReason: string | null;
14
+ /** Human-readable label for the badge, e.g. "references", "symbols". */
15
+ label: string;
16
+ }
17
+
18
+ /**
19
+ * Format a compact evidence completeness badge.
20
+ *
21
+ * | Input | Output |
22
+ * |------------------------------------------------------|---------------------------------------|
23
+ * | shown=12, total=12, omitted=0, label="references" | `12 references` |
24
+ * | shown=8, total=20, omitted=12, label="symbols" | `8 of 20 symbols (12 omitted)` |
25
+ * | shown=5, total=null, omitted=2, reason="timeout" | `5 matches (2 collected omitted; more may exist — timeout)` |
26
+ */
27
+ export function formatEvidenceBadge(input: EvidenceBadgeInput): string {
28
+ const { shownCount, totalCount, omittedCount, partialReason, label } = input;
29
+
30
+ if (totalCount === null) {
31
+ const reasonSuffix = partialReason ? ` — ${partialReason}` : "";
32
+ const omittedPrefix = (omittedCount ?? 0) > 0 ? `${omittedCount} collected omitted; ` : "";
33
+ return `${shownCount} ${label} (${omittedPrefix}more may exist${reasonSuffix})`;
34
+ }
35
+
36
+ if (omittedCount !== null && omittedCount > 0) {
37
+ return `${shownCount} of ${totalCount} ${label} (${omittedCount} omitted)`;
38
+ }
39
+
40
+ return `${shownCount} ${label}`;
41
+ }
@@ -0,0 +1,57 @@
1
+ // Shared footer contribution registry for SuPi extensions.
2
+ //
3
+ // Extensions register pre-styled text chunks with a placement hint
4
+ // ("stats" for the metrics line, "status" for the extension status line).
5
+ // The custom footer in supi-extras (or PI's built-in footer) reads these
6
+ // contributions and renders them alongside the built-in metrics.
7
+
8
+ import { createRegistry } from "./registry-utils.ts";
9
+
10
+ /** Where the contribution should appear in the footer. */
11
+ export type FooterPlacement = "stats" | "stats-end" | "status";
12
+
13
+ /** A single footer contribution registered by an extension. */
14
+ export interface FooterContribution {
15
+ /** Unique key for this contribution. Re-registering with the same key replaces it. */
16
+ key: string;
17
+ /** Which footer line this belongs on. */
18
+ placement: FooterPlacement;
19
+ /**
20
+ * Sort order within the placement (lower values render further left). Default: 100.
21
+ * Priority 0 is reserved for the turn cache-hit part so it stays adjacent to CH.
22
+ */
23
+ priority?: number;
24
+ /** Return the pre-styled text for this contribution. Called on every render. */
25
+ render: () => string;
26
+ }
27
+
28
+ const registry = createRegistry<FooterContribution>("footer-contributions");
29
+
30
+ function sortByPriority(a: FooterContribution, b: FooterContribution): number {
31
+ return (a.priority ?? 100) - (b.priority ?? 100);
32
+ }
33
+
34
+ export const footerContributions = {
35
+ /** Register or replace a footer contribution. */
36
+ register(contribution: FooterContribution): void {
37
+ registry.register(contribution.key, contribution);
38
+ },
39
+
40
+ /** Remove a contribution (e.g. on session_shutdown or when disabled). */
41
+ unregister(key: string): void {
42
+ registry.unregister(key);
43
+ },
44
+
45
+ /** Get contributions for a specific placement, sorted by priority. */
46
+ getByPlacement(placement: FooterPlacement): FooterContribution[] {
47
+ return registry
48
+ .getAll()
49
+ .filter((c) => c.placement === placement)
50
+ .sort(sortByPriority);
51
+ },
52
+
53
+ /** Remove all contributions (primarily for tests). */
54
+ clear(): void {
55
+ registry.clear();
56
+ },
57
+ };
@@ -0,0 +1,34 @@
1
+ // supi-core — shared infrastructure for SuPi extensions.
2
+ // Provides XML context tag wrapping, unified config, prompt-surface resolution,
3
+ // and shared settings, reporting, and session utilities.
4
+ //
5
+ // Convenience barrel — re-exports all domain entry points.
6
+ // For lighter imports, use one of the domain subpaths directly
7
+ // (e.g. @mrclrchtr/supi-core/config, @mrclrchtr/supi-core/context).
8
+
9
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
10
+ export * from "./config.ts";
11
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
12
+ export * from "./context.ts";
13
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
14
+ export * from "./debug.ts";
15
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
16
+ export * from "./footer-registry.ts";
17
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
18
+ export * from "./model-selection.ts";
19
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
20
+ export * from "./path.ts";
21
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
22
+ export * from "./project.ts";
23
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
24
+ export * from "./prompt-surface.ts";
25
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
26
+ export * from "./report.ts";
27
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
28
+ export * from "./session.ts";
29
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
30
+ export * from "./settings.ts";
31
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
32
+ export * from "./status-spinner.ts";
33
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
34
+ export * from "./terminal.ts";