@mrclrchtr/supi-debug 4.6.0 → 4.8.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.
- package/node_modules/@mrclrchtr/supi-core/README.md +26 -34
- package/node_modules/@mrclrchtr/supi-core/package.json +4 -7
- package/node_modules/@mrclrchtr/supi-core/src/api.ts +4 -6
- package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +0 -20
- package/node_modules/@mrclrchtr/supi-core/src/config/prompt-surface.ts +7 -1
- package/node_modules/@mrclrchtr/supi-core/src/config.ts +0 -1
- package/node_modules/@mrclrchtr/supi-core/src/context.ts +1 -9
- package/node_modules/@mrclrchtr/supi-core/src/index.ts +4 -6
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +54 -28
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +91 -125
- package/node_modules/@mrclrchtr/supi-core/src/settings.ts +10 -7
- package/package.json +2 -4
- package/src/debug.ts +34 -33
- package/node_modules/@mrclrchtr/supi-core/src/context/context-messages.ts +0 -119
- package/node_modules/@mrclrchtr/supi-core/src/progress-widget.ts +0 -189
- package/node_modules/@mrclrchtr/supi-core/src/settings/scoped-settings-list.ts +0 -373
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-action-menu.ts +0 -102
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-command.ts +0 -15
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-submenus.ts +0 -141
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +0 -118
- package/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +0 -3
- package/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +0 -192
- package/src/api.ts +0 -1
- package/src/index.ts +0 -1
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
// Declarative settings overlay for SuPi extensions.
|
|
2
|
-
//
|
|
3
|
-
// Thin orchestration layer that collects settings contributions and opens the
|
|
4
|
-
// scoped settings list inside a pi-tui custom component overlay.
|
|
5
|
-
|
|
6
|
-
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
-
import { Container, Key, matchesKey, Text } from "@earendil-works/pi-tui";
|
|
8
|
-
import { ScopedSettingsList } from "./scoped-settings-list.ts";
|
|
9
|
-
import type { SettingsCollectionDiagnostic, SettingsScope } from "./settings-registry.ts";
|
|
10
|
-
import {
|
|
11
|
-
createSettingsContributionCollector,
|
|
12
|
-
SUPI_SETTINGS_COLLECT_EVENT,
|
|
13
|
-
} from "./settings-registry.ts";
|
|
14
|
-
|
|
15
|
-
// Re-export submenu helpers
|
|
16
|
-
export { createInputSubmenu, createModelPickerSubmenu } from "./settings-submenus.ts";
|
|
17
|
-
|
|
18
|
-
// ── Overlay ────────────────────────────────────────────────────────────────
|
|
19
|
-
|
|
20
|
-
interface OverlayStatus {
|
|
21
|
-
kind: "warning" | "error";
|
|
22
|
-
message: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface OverlayState {
|
|
26
|
-
scope: SettingsScope;
|
|
27
|
-
cwd: string;
|
|
28
|
-
status?: OverlayStatus;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function getScopeLabel(scope: SettingsScope): string {
|
|
32
|
-
return scope === "project" ? "Project" : "Global";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function collectSettingsSections(pi: ExtensionAPI) {
|
|
36
|
-
const collector = createSettingsContributionCollector();
|
|
37
|
-
pi.events.emit(SUPI_SETTINGS_COLLECT_EVENT, collector);
|
|
38
|
-
return collector.result();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function latestStatus(diagnostics: SettingsCollectionDiagnostic[]): OverlayStatus | undefined {
|
|
42
|
-
const latest = diagnostics.at(-1);
|
|
43
|
-
return latest ? { kind: latest.kind, message: latest.message } : undefined;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function openSettingsOverlay(pi: ExtensionAPI, ctx: ExtensionContext): void {
|
|
47
|
-
const collection = collectSettingsSections(pi);
|
|
48
|
-
if (collection.sections.length === 0) {
|
|
49
|
-
ctx.ui.notify("No settings registered by SuPi extensions", "info");
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
void ctx.ui.custom<void>((tui, theme, _kb, done) => {
|
|
54
|
-
const state: OverlayState = {
|
|
55
|
-
scope: "project",
|
|
56
|
-
cwd: ctx.cwd,
|
|
57
|
-
status: latestStatus(collection.diagnostics),
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const container = new Container();
|
|
61
|
-
const scopedList = new ScopedSettingsList(
|
|
62
|
-
collection.sections,
|
|
63
|
-
state.scope,
|
|
64
|
-
state.cwd,
|
|
65
|
-
ctx,
|
|
66
|
-
theme,
|
|
67
|
-
tui,
|
|
68
|
-
done,
|
|
69
|
-
(message) => {
|
|
70
|
-
state.status = { kind: "error", message };
|
|
71
|
-
rebuildOverlay();
|
|
72
|
-
tui.requestRender();
|
|
73
|
-
},
|
|
74
|
-
);
|
|
75
|
-
scopedList.enableSearch();
|
|
76
|
-
|
|
77
|
-
const rebuildOverlay = () => {
|
|
78
|
-
container.clear();
|
|
79
|
-
const scopeLabel = getScopeLabel(state.scope);
|
|
80
|
-
const otherScope = state.scope === "project" ? "Global" : "Project";
|
|
81
|
-
container.addChild(
|
|
82
|
-
new Text(
|
|
83
|
-
`${theme.fg("accent", theme.bold("SuPi Settings"))} ${theme.fg("text", `Scope: ${scopeLabel}`)} ${theme.fg("dim", `(tab → ${otherScope})`)}`,
|
|
84
|
-
0,
|
|
85
|
-
0,
|
|
86
|
-
),
|
|
87
|
-
);
|
|
88
|
-
if (state.status) {
|
|
89
|
-
container.addChild(new Text(theme.fg(state.status.kind, state.status.message), 0, 0));
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
rebuildOverlay();
|
|
94
|
-
|
|
95
|
-
const component = {
|
|
96
|
-
render: (width: number) => [...container.render(width), ...scopedList.render(width)],
|
|
97
|
-
invalidate: () => {
|
|
98
|
-
container.invalidate();
|
|
99
|
-
scopedList.invalidate();
|
|
100
|
-
},
|
|
101
|
-
handleInput: (data: string) => {
|
|
102
|
-
if (matchesKey(data, Key.tab)) {
|
|
103
|
-
state.scope = state.scope === "project" ? "global" : "project";
|
|
104
|
-
state.status = undefined;
|
|
105
|
-
scopedList.reload(state.scope, state.cwd, ctx);
|
|
106
|
-
rebuildOverlay();
|
|
107
|
-
tui.requestRender();
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
scopedList.handleInput(data);
|
|
111
|
-
tui.requestRender();
|
|
112
|
-
return true;
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
return component;
|
|
117
|
-
});
|
|
118
|
-
}
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
// Shared tool framework for SuPi extensions.
|
|
2
|
-
//
|
|
3
|
-
// Provides a standard ToolSpec→PromptSurface→registerTool pipeline so
|
|
4
|
-
// individual packages do not duplicate spec interfaces, guidance derivation,
|
|
5
|
-
// registration loops, or common TypeBox parameter schemas.
|
|
6
|
-
|
|
7
|
-
import type {
|
|
8
|
-
AgentToolResult,
|
|
9
|
-
AgentToolUpdateCallback,
|
|
10
|
-
ExtensionAPI,
|
|
11
|
-
ExtensionCommandContext,
|
|
12
|
-
ExtensionContext,
|
|
13
|
-
} from "@earendil-works/pi-coding-agent";
|
|
14
|
-
import { type TSchema, Type } from "typebox";
|
|
15
|
-
import { ProgressWidget, type WidgetProgress } from "./progress-widget.ts";
|
|
16
|
-
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
// Types
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
|
|
21
|
-
/** Minimum contract for a SuPi tool definition. */
|
|
22
|
-
export interface SuiPiToolSpec {
|
|
23
|
-
name: string;
|
|
24
|
-
label: string;
|
|
25
|
-
description: string;
|
|
26
|
-
promptSnippet: string;
|
|
27
|
-
promptGuidelines: string[];
|
|
28
|
-
parameters: TSchema;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** Derived prompt surface — what pi flattens into the system prompt. */
|
|
32
|
-
export interface SuiPiToolPromptSurface {
|
|
33
|
-
description: string;
|
|
34
|
-
promptSnippet: string;
|
|
35
|
-
promptGuidelines: string[];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// ---------------------------------------------------------------------------
|
|
39
|
-
// Guidance derivation
|
|
40
|
-
// ---------------------------------------------------------------------------
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Static derivation: copies spec fields into a prompt surface.
|
|
44
|
-
*
|
|
45
|
-
* Packages that need dynamic guidance (e.g. server-coverage injection) should
|
|
46
|
-
* build their own surfaces, optionally starting from the output of this helper.
|
|
47
|
-
*/
|
|
48
|
-
export function derivePromptSurface(spec: SuiPiToolSpec): SuiPiToolPromptSurface {
|
|
49
|
-
return {
|
|
50
|
-
description: spec.description,
|
|
51
|
-
promptSnippet: spec.promptSnippet,
|
|
52
|
-
promptGuidelines: [...spec.promptGuidelines],
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Re-export prompt-surface types (implemented in config/prompt-surface.ts)
|
|
57
|
-
export {
|
|
58
|
-
notifyToolPromptSurfaceDiagnostics,
|
|
59
|
-
type ResolveToolPromptSurfaceOptions,
|
|
60
|
-
type ResolveToolPromptSurfaceResult,
|
|
61
|
-
resolveToolPromptSurface,
|
|
62
|
-
type ToolPromptSurfaceDiagnostic,
|
|
63
|
-
type ToolPromptSurfaceDiagnosticCode,
|
|
64
|
-
} from "./config/prompt-surface.ts";
|
|
65
|
-
|
|
66
|
-
// ---------------------------------------------------------------------------
|
|
67
|
-
// Registration
|
|
68
|
-
// ---------------------------------------------------------------------------
|
|
69
|
-
|
|
70
|
-
// biome-ignore lint/complexity/useMaxParams: matches pi ToolDefinition.execute signature
|
|
71
|
-
export type ToolExecuteFn = (
|
|
72
|
-
toolCallId: string,
|
|
73
|
-
params: unknown,
|
|
74
|
-
signal: AbortSignal | undefined,
|
|
75
|
-
onUpdate: AgentToolUpdateCallback<Record<string, unknown>> | undefined,
|
|
76
|
-
ctx: ExtensionContext,
|
|
77
|
-
) => Promise<AgentToolResult<Record<string, unknown>>>;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Register a set of tools from specs + pre-derived surfaces.
|
|
81
|
-
*
|
|
82
|
-
* `createExecute` receives the spec and returns a pi-compatible execute
|
|
83
|
-
* function. This keeps execute-logic package-local while the framework owns
|
|
84
|
-
* the declarative surface and registration boilerplate.
|
|
85
|
-
*/
|
|
86
|
-
export function registerSuiPiTools(
|
|
87
|
-
pi: ExtensionAPI,
|
|
88
|
-
specs: readonly SuiPiToolSpec[],
|
|
89
|
-
surfaces: Record<string, SuiPiToolPromptSurface>,
|
|
90
|
-
createExecute: (spec: SuiPiToolSpec) => ToolExecuteFn,
|
|
91
|
-
): void {
|
|
92
|
-
for (const spec of specs) {
|
|
93
|
-
const surface = surfaces[spec.name];
|
|
94
|
-
pi.registerTool({
|
|
95
|
-
name: spec.name,
|
|
96
|
-
label: spec.label,
|
|
97
|
-
description: surface?.description ?? spec.description,
|
|
98
|
-
promptSnippet: surface?.promptSnippet ?? spec.promptSnippet,
|
|
99
|
-
promptGuidelines: surface?.promptGuidelines ?? [...spec.promptGuidelines],
|
|
100
|
-
parameters: spec.parameters,
|
|
101
|
-
execute: createExecute(spec),
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// ---------------------------------------------------------------------------
|
|
107
|
-
// Shared parameter builders
|
|
108
|
-
// ---------------------------------------------------------------------------
|
|
109
|
-
|
|
110
|
-
/** File path (relative or absolute). */
|
|
111
|
-
export const FileParam = Type.String({ description: "File path (relative or absolute)" });
|
|
112
|
-
|
|
113
|
-
/** 1-based line number. */
|
|
114
|
-
export const LineParam = Type.Number({ description: "1-based line number", minimum: 1 });
|
|
115
|
-
|
|
116
|
-
/** 1-based character column (UTF-16). */
|
|
117
|
-
export const CharacterParam = Type.Number({
|
|
118
|
-
description: "1-based column number (UTF-16)",
|
|
119
|
-
minimum: 1,
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
/** Symbol name for discovery-based resolution. */
|
|
123
|
-
export const SymbolParam = Type.String({
|
|
124
|
-
description: "Symbol name for discovery-based resolution",
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
/** Maximum results to return. */
|
|
128
|
-
export const MaxResultsParam = Type.Number({ description: "Maximum results to return" });
|
|
129
|
-
|
|
130
|
-
// ---------------------------------------------------------------------------
|
|
131
|
-
// Progress widget runner
|
|
132
|
-
// ---------------------------------------------------------------------------
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Run an async operation with a live TUI progress widget.
|
|
136
|
-
*
|
|
137
|
-
* Automatically manages:
|
|
138
|
-
* - The {@link ProgressWidget} lifecycle
|
|
139
|
-
* - `supi:working:start` / `supi:working:end` events for tab-spinner integration
|
|
140
|
-
* - Abort signal handling
|
|
141
|
-
* - Error catching (returns `null` on failure)
|
|
142
|
-
*
|
|
143
|
-
* Falls back to running without a widget when `ctx.hasUI` is false.
|
|
144
|
-
*
|
|
145
|
-
* @param pi - The extension API (for event emission).
|
|
146
|
-
* @param ctx - The command context (for UI access and hasUI check).
|
|
147
|
-
* @param title - The progress widget title.
|
|
148
|
-
* @param runner - Async function that receives (signal, onProgress).
|
|
149
|
-
* @returns The runner result, or `null` on cancel/error.
|
|
150
|
-
*/
|
|
151
|
-
export async function runWithProgressWidget<T>(
|
|
152
|
-
pi: ExtensionAPI,
|
|
153
|
-
ctx: ExtensionCommandContext,
|
|
154
|
-
title: string,
|
|
155
|
-
runner: (signal: AbortSignal, onProgress: (p: WidgetProgress) => void) => Promise<T>,
|
|
156
|
-
): Promise<T | null> {
|
|
157
|
-
if (!ctx.hasUI) {
|
|
158
|
-
// No UI — run without progress widget but still emit working events
|
|
159
|
-
pi.events.emit("supi:working:start", { source: "supi-core" });
|
|
160
|
-
try {
|
|
161
|
-
return await runner(new AbortController().signal, () => {});
|
|
162
|
-
} catch {
|
|
163
|
-
return null;
|
|
164
|
-
} finally {
|
|
165
|
-
pi.events.emit("supi:working:end", { source: "supi-core" });
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return ctx.ui.custom<T | null>((tui, theme, _kb, done) => {
|
|
170
|
-
const widget = new ProgressWidget(tui, theme, title);
|
|
171
|
-
let finished = false;
|
|
172
|
-
|
|
173
|
-
const finish = (result: T | null) => {
|
|
174
|
-
if (finished) return;
|
|
175
|
-
finished = true;
|
|
176
|
-
pi.events.emit("supi:working:end", { source: "supi-core" });
|
|
177
|
-
widget.dispose();
|
|
178
|
-
done(result);
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
widget.onAbort = () => {
|
|
182
|
-
// Widget handles abort signal; runner resolves with cancel/error.
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
pi.events.emit("supi:working:start", { source: "supi-core" });
|
|
186
|
-
runner(widget.signal, (progress) => widget.updateProgress(progress))
|
|
187
|
-
.then((result) => finish(result))
|
|
188
|
-
.catch(() => finish(null));
|
|
189
|
-
|
|
190
|
-
return widget;
|
|
191
|
-
});
|
|
192
|
-
}
|
package/src/api.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./debug.ts";
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./debug.ts";
|