@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,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
+ }
@@ -0,0 +1,71 @@
1
+ // Generic session-file tree-walking utilities.
2
+
3
+ import type { FileEntry, SessionEntry } from "@earendil-works/pi-coding-agent";
4
+
5
+ /**
6
+ * Minimal pi API surface needed to track the current session display name reactively.
7
+ * Accept `ExtensionAPI` or any object satisfying this shape.
8
+ */
9
+ export interface SessionNameTrackerHost {
10
+ on(event: string, handler: (...args: unknown[]) => unknown): void;
11
+ getSessionName(): string | undefined;
12
+ }
13
+
14
+ /**
15
+ * Create a reactive session-name tracker that stays consistent across
16
+ * session starts, renames, and shutdowns without polling.
17
+ *
18
+ * Subscribes to `session_start` (initial name), `session_info_changed`
19
+ * (renames via `/name`, `pi.setSessionName()`, or RPC), and
20
+ * `session_shutdown` (reset to `undefined`).
21
+ *
22
+ * @returns a zero-arg getter that always returns the current session name
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const getSessionName = createSessionNameTracker(pi);
27
+ * // …later, during tool execute or spinner rendering:
28
+ * const name = getSessionName();
29
+ * ```
30
+ */
31
+ export function createSessionNameTracker(pi: SessionNameTrackerHost): () => string | undefined {
32
+ let name: string | undefined;
33
+
34
+ pi.on("session_start", () => {
35
+ name = pi.getSessionName();
36
+ });
37
+ pi.on("session_info_changed", (event) => {
38
+ name = (event as { name?: string }).name;
39
+ });
40
+ pi.on("session_shutdown", () => {
41
+ name = undefined;
42
+ });
43
+
44
+ return () => name;
45
+ }
46
+
47
+ /**
48
+ * Resolve the active branch path using PI's append-only tree semantics.
49
+ *
50
+ * The active branch is the path from the **last entry** (current leaf)
51
+ * back to the root via `parentId`. This follows PI's tree structure where
52
+ * entries are append-only and the last entry in the file is always the
53
+ * current leaf of the active branch.
54
+ */
55
+ export function getActiveBranchEntries(entries: FileEntry[]): SessionEntry[] {
56
+ const sessionEntries = entries.filter((e): e is SessionEntry => e.type !== "session");
57
+ const byId = new Map(sessionEntries.map((entry) => [entry.id, entry]));
58
+ const leaf = sessionEntries.at(-1);
59
+ if (!leaf) return [];
60
+
61
+ const path: SessionEntry[] = [];
62
+ const visited = new Set<string>();
63
+ let current: SessionEntry | undefined = leaf;
64
+ while (current) {
65
+ if (visited.has(current.id)) break;
66
+ visited.add(current.id);
67
+ path.unshift(current);
68
+ current = current.parentId ? byId.get(current.parentId) : undefined;
69
+ }
70
+ return path;
71
+ }
@@ -0,0 +1,8 @@
1
+ // supi-core session domain — session utilities and registries.
2
+
3
+ export { createRegistry, createSessionStateRegistry } from "./registry-utils.ts";
4
+ export type { SessionNameTrackerHost } from "./session-utils.ts";
5
+ export {
6
+ createSessionNameTracker,
7
+ getActiveBranchEntries,
8
+ } from "./session-utils.ts";
@@ -0,0 +1,105 @@
1
+ // Event-backed settings module registration and collection.
2
+
3
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
4
+ import type { ScopedFieldValue, SettingsAction } from "./settings-schema.ts";
5
+
6
+ export const SUPI_SETTINGS_COLLECT_EVENT = "supi:settings:collect";
7
+
8
+ export type SettingsScope = "project" | "global";
9
+
10
+ /** Scope and PI runtime state supplied for each settings read. */
11
+ export interface SettingsContext {
12
+ scope: SettingsScope;
13
+ cwd: string;
14
+ ctx?: ExtensionContext;
15
+ }
16
+
17
+ /** A resolved, source-aware settings view. */
18
+ export interface SettingsSnapshot {
19
+ rows: ScopedFieldValue[];
20
+ }
21
+
22
+ /** One user action routed to its owning settings module. */
23
+ export interface SettingsActionRequest extends SettingsContext {
24
+ fieldKey: string;
25
+ action: SettingsAction;
26
+ }
27
+
28
+ /** Optional user-facing result from a successful settings action. */
29
+ export interface SettingsApplyResult {
30
+ notice?: {
31
+ message: string;
32
+ level: "info" | "warning" | "error";
33
+ };
34
+ }
35
+
36
+ /**
37
+ * Canonical settings interface consumed by `/supi-settings`.
38
+ *
39
+ * Reads are always asynchronous. Apply resolves only after durable writes and
40
+ * module-owned refresh work complete. Implementations throw on failed writes.
41
+ */
42
+ export interface SettingsModule {
43
+ id: string;
44
+ /** Human-readable section label shown in the UI. */
45
+ label: string;
46
+ /** Optional label that groups this module within its section. */
47
+ subsection?: string;
48
+ read(context: SettingsContext): Promise<SettingsSnapshot>;
49
+ apply(request: SettingsActionRequest): Promise<SettingsApplyResult>;
50
+ }
51
+
52
+ export interface SettingsContributionCollector {
53
+ add(module: SettingsModule): void;
54
+ }
55
+
56
+ export interface SettingsCollectionDiagnostic {
57
+ kind: "warning";
58
+ message: string;
59
+ }
60
+
61
+ export interface SettingsCollectionResult {
62
+ modules: SettingsModule[];
63
+ diagnostics: SettingsCollectionDiagnostic[];
64
+ }
65
+
66
+ export function isSettingsContributionCollector(
67
+ value: unknown,
68
+ ): value is SettingsContributionCollector {
69
+ return (
70
+ typeof value === "object" &&
71
+ value !== null &&
72
+ typeof (value as { add?: unknown }).add === "function"
73
+ );
74
+ }
75
+
76
+ /** Create a collector with last-wins duplicate handling and warning diagnostics. */
77
+ export function createSettingsContributionCollector(): SettingsContributionCollector & {
78
+ result(): SettingsCollectionResult;
79
+ } {
80
+ const modules = new Map<string, SettingsModule>();
81
+ const diagnostics: SettingsCollectionDiagnostic[] = [];
82
+
83
+ return {
84
+ add(module: SettingsModule): void {
85
+ if (modules.has(module.id)) {
86
+ diagnostics.push({
87
+ kind: "warning",
88
+ message: `Duplicate SuPi settings contribution "${module.id}"; using the last contribution.`,
89
+ });
90
+ }
91
+ modules.set(module.id, module);
92
+ },
93
+ result(): SettingsCollectionResult {
94
+ return { modules: Array.from(modules.values()), diagnostics: [...diagnostics] };
95
+ },
96
+ };
97
+ }
98
+
99
+ /** Register one settings module during extension factory setup. */
100
+ export function registerSettings(pi: ExtensionAPI, module: SettingsModule): void {
101
+ const dispose = pi.events.on(SUPI_SETTINGS_COLLECT_EVENT, (collector) => {
102
+ if (isSettingsContributionCollector(collector)) collector.add(module);
103
+ });
104
+ pi.on("session_shutdown", () => dispose());
105
+ }