@mrclrchtr/supi-debug 2.0.6 → 2.2.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/README.md +2 -4
- package/node_modules/@mrclrchtr/supi-core/README.md +32 -23
- package/node_modules/@mrclrchtr/supi-core/package.json +2 -1
- package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +22 -8
- package/node_modules/@mrclrchtr/supi-core/src/config/prompt-surface.ts +357 -0
- package/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -3
- package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +0 -5
- package/node_modules/@mrclrchtr/supi-core/src/prompt-surface.ts +4 -0
- package/node_modules/@mrclrchtr/supi-core/src/settings/scoped-settings-list.ts +372 -0
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-action-menu.ts +101 -0
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-command.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +55 -27
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +464 -0
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-submenus.ts +124 -0
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +72 -285
- package/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +2 -5
- package/node_modules/@mrclrchtr/supi-core/src/settings.ts +27 -5
- package/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +10 -0
- package/package.json +2 -2
- package/src/debug.ts +14 -39
- package/src/status-log.ts +5 -36
- package/src/tool/guidance.ts +2 -3
- package/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +0 -188
|
@@ -1,327 +1,114 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Declarative settings overlay for SuPi extensions.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// Thin orchestration layer that collects settings contributions and opens the
|
|
4
|
+
// scoped settings list inside a pi-tui custom component overlay.
|
|
5
5
|
|
|
6
|
-
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
-
import {
|
|
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";
|
|
8
10
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Key,
|
|
12
|
-
matchesKey,
|
|
13
|
-
type SelectItem,
|
|
14
|
-
SelectList,
|
|
15
|
-
type SelectListTheme,
|
|
16
|
-
type SettingItem,
|
|
17
|
-
SettingsList,
|
|
18
|
-
Text,
|
|
19
|
-
} from "@earendil-works/pi-tui";
|
|
20
|
-
import { getSelectableModels } from "../model-selection.ts";
|
|
21
|
-
import {
|
|
22
|
-
getRegisteredSettings,
|
|
23
|
-
type SettingsScope,
|
|
24
|
-
type SettingsSection,
|
|
11
|
+
createSettingsContributionCollector,
|
|
12
|
+
SUPI_SETTINGS_COLLECT_EVENT,
|
|
25
13
|
} from "./settings-registry.ts";
|
|
26
14
|
|
|
27
|
-
//
|
|
15
|
+
// Re-export submenu helpers
|
|
16
|
+
export { createInputSubmenu, createModelPickerSubmenu } from "./settings-submenus.ts";
|
|
28
17
|
|
|
29
|
-
|
|
30
|
-
* Creates a pi-tui Input-backed submenu component with enter-to-confirm
|
|
31
|
-
* and escape-to-cancel handling.
|
|
32
|
-
*
|
|
33
|
-
* @param currentValue - Initial value for the text input.
|
|
34
|
-
* @param label - Label text displayed above the input.
|
|
35
|
-
* @param done - Callback invoked with the confirmed value, or undefined on cancel.
|
|
36
|
-
*/
|
|
37
|
-
export function createInputSubmenu(
|
|
38
|
-
currentValue: string,
|
|
39
|
-
label: string,
|
|
40
|
-
done: (selectedValue?: string) => void,
|
|
41
|
-
): {
|
|
42
|
-
render: (width: number) => string[];
|
|
43
|
-
invalidate: () => void;
|
|
44
|
-
handleInput: (data: string) => boolean;
|
|
45
|
-
} {
|
|
46
|
-
const input = new Input();
|
|
47
|
-
input.setValue(currentValue);
|
|
18
|
+
// ── Overlay ────────────────────────────────────────────────────────────────
|
|
48
19
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
lines.push(...input.render(_width));
|
|
53
|
-
lines.push(" enter confirm • esc cancel");
|
|
54
|
-
return lines;
|
|
55
|
-
},
|
|
56
|
-
invalidate: () => {
|
|
57
|
-
input.invalidate();
|
|
58
|
-
},
|
|
59
|
-
handleInput: (data: string) => {
|
|
60
|
-
if (matchesKey(data, Key.escape)) {
|
|
61
|
-
done();
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
if (matchesKey(data, Key.enter)) {
|
|
65
|
-
done(input.getValue());
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
input.handleInput(data);
|
|
69
|
-
return true;
|
|
70
|
-
},
|
|
71
|
-
};
|
|
20
|
+
interface OverlayStatus {
|
|
21
|
+
kind: "warning" | "error";
|
|
22
|
+
message: string;
|
|
72
23
|
}
|
|
73
24
|
|
|
74
|
-
// ── Types ────────────────────────────────────────────────────
|
|
75
|
-
|
|
76
25
|
interface OverlayState {
|
|
77
26
|
scope: SettingsScope;
|
|
78
27
|
cwd: string;
|
|
28
|
+
status?: OverlayStatus;
|
|
79
29
|
}
|
|
80
30
|
|
|
81
|
-
// ── Pure helpers ─────────────────────────────────────────────
|
|
82
|
-
|
|
83
31
|
function getScopeLabel(scope: SettingsScope): string {
|
|
84
32
|
return scope === "project" ? "Project" : "Global";
|
|
85
33
|
}
|
|
86
34
|
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
ctx?: ExtensionContext,
|
|
92
|
-
): SettingItem[] {
|
|
93
|
-
const items: SettingItem[] = [];
|
|
94
|
-
for (const section of sections) {
|
|
95
|
-
const sectionItems = section.loadValues(scope, cwd, ctx);
|
|
96
|
-
for (const item of sectionItems) {
|
|
97
|
-
items.push({
|
|
98
|
-
...item,
|
|
99
|
-
id: `${section.id}.${item.id}`,
|
|
100
|
-
label: `${section.label}: ${item.label}`,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return items;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function findSectionAndId(
|
|
108
|
-
sections: SettingsSection[],
|
|
109
|
-
flatId: string,
|
|
110
|
-
): { section: SettingsSection; itemId: string } | null {
|
|
111
|
-
const dotIndex = flatId.indexOf(".");
|
|
112
|
-
if (dotIndex === -1) return null;
|
|
113
|
-
const sectionId = flatId.slice(0, dotIndex);
|
|
114
|
-
const itemId = flatId.slice(dotIndex + 1);
|
|
115
|
-
const section = sections.find((s) => s.id === sectionId);
|
|
116
|
-
if (!section) return null;
|
|
117
|
-
return { section, itemId };
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// ── Component ────────────────────────────────────────────────
|
|
121
|
-
|
|
122
|
-
interface SettingsOverlayDeps {
|
|
123
|
-
ctx: ExtensionContext;
|
|
124
|
-
state: OverlayState;
|
|
125
|
-
container: Container;
|
|
126
|
-
settingsList: SettingsList | null;
|
|
127
|
-
tui: Parameters<Parameters<ExtensionContext["ui"]["custom"]>[0]>[0];
|
|
128
|
-
theme: Parameters<Parameters<ExtensionContext["ui"]["custom"]>[0]>[1];
|
|
129
|
-
done: () => void;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function createSettingsList(deps: SettingsOverlayDeps): SettingsList {
|
|
133
|
-
const sections = getRegisteredSettings();
|
|
134
|
-
const items = buildFlatItems(sections, deps.state.scope, deps.state.cwd, deps.ctx);
|
|
135
|
-
const onChange = (flatId: string, newValue: string) => {
|
|
136
|
-
const found = findSectionAndId(sections, flatId);
|
|
137
|
-
if (found) {
|
|
138
|
-
found.section.persistChange(
|
|
139
|
-
deps.state.scope,
|
|
140
|
-
deps.state.cwd,
|
|
141
|
-
found.itemId,
|
|
142
|
-
newValue,
|
|
143
|
-
deps.ctx,
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
// Re-read all values to reflect persisted changes, but keep the list
|
|
147
|
-
// instance (and its selectedIndex) intact.
|
|
148
|
-
const updatedItems = buildFlatItems(sections, deps.state.scope, deps.state.cwd, deps.ctx);
|
|
149
|
-
for (const updated of updatedItems) {
|
|
150
|
-
const existing = items.find((i) => i.id === updated.id);
|
|
151
|
-
if (existing && existing.currentValue !== updated.currentValue) {
|
|
152
|
-
settingsList.updateValue(updated.id, updated.currentValue);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
deps.tui.requestRender();
|
|
156
|
-
};
|
|
157
|
-
const settingsList = new SettingsList(
|
|
158
|
-
items,
|
|
159
|
-
Math.min(items.length + 4, 20),
|
|
160
|
-
getSettingsListTheme(),
|
|
161
|
-
onChange,
|
|
162
|
-
() => deps.done(),
|
|
163
|
-
{ enableSearch: true },
|
|
164
|
-
);
|
|
165
|
-
return settingsList;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function rebuildSettingsList(deps: SettingsOverlayDeps): SettingsList {
|
|
169
|
-
const settingsList = createSettingsList(deps);
|
|
170
|
-
deps.settingsList = settingsList;
|
|
171
|
-
|
|
172
|
-
deps.container.clear();
|
|
173
|
-
deps.container.addChild(createHeaderComponent(deps));
|
|
174
|
-
deps.container.addChild(settingsList);
|
|
175
|
-
|
|
176
|
-
return settingsList;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function createHeaderComponent(deps: SettingsOverlayDeps): Text {
|
|
180
|
-
const { theme, state } = deps;
|
|
181
|
-
const scopeLabel = getScopeLabel(state.scope);
|
|
182
|
-
const otherScope = state.scope === "project" ? "Global" : "Project";
|
|
183
|
-
const headerText = new Text(
|
|
184
|
-
`${theme.fg("accent", theme.bold("SuPi Settings"))} ${theme.fg("text", `Scope: ${scopeLabel}`)} ${theme.fg("dim", `(tab → ${otherScope})`)}`,
|
|
185
|
-
0,
|
|
186
|
-
0,
|
|
187
|
-
);
|
|
188
|
-
return headerText;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function handleScopeToggle(deps: SettingsOverlayDeps): void {
|
|
192
|
-
deps.state.scope = deps.state.scope === "project" ? "global" : "project";
|
|
193
|
-
rebuildSettingsList(deps);
|
|
194
|
-
deps.tui.requestRender();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/** Minimal SelectList theme — uses identity so the parent SettingsList provides styling context. */
|
|
198
|
-
const PASSTHROUGH_THEME: SelectListTheme = {
|
|
199
|
-
selectedPrefix: (text) => `› ${text}`,
|
|
200
|
-
selectedText: (text) => text,
|
|
201
|
-
description: (text) => text,
|
|
202
|
-
scrollInfo: (text) => text,
|
|
203
|
-
noMatch: (text) => text,
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Create a model picker submenu for settings.
|
|
208
|
-
*
|
|
209
|
-
* Shows a scrollable list of selectable models from the scoped model set,
|
|
210
|
-
* with the current session model annotated `[current]`. The first entry is
|
|
211
|
-
* always `"disabled"`.
|
|
212
|
-
*
|
|
213
|
-
* @param currentValue - Currently configured canonical model id or `"disabled"`.
|
|
214
|
-
* @param done - Callback invoked with the selected value, or undefined on cancel.
|
|
215
|
-
* @param ctx - Extension context for model listing. When undefined, only
|
|
216
|
-
* `"disabled"` is offered.
|
|
217
|
-
*/
|
|
218
|
-
export function createModelPickerSubmenu(
|
|
219
|
-
currentValue: string,
|
|
220
|
-
done: (selectedValue?: string) => void,
|
|
221
|
-
ctx?: ExtensionContext,
|
|
222
|
-
): {
|
|
223
|
-
render: (width: number) => string[];
|
|
224
|
-
invalidate: () => void;
|
|
225
|
-
handleInput: (data: string) => boolean;
|
|
226
|
-
} {
|
|
227
|
-
const items = buildModelItems(ctx);
|
|
228
|
-
|
|
229
|
-
const initialIndex =
|
|
230
|
-
currentValue === "disabled"
|
|
231
|
-
? 0
|
|
232
|
-
: Math.max(
|
|
233
|
-
0,
|
|
234
|
-
items.findIndex((item) => item.value === currentValue),
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
const container = new Container();
|
|
238
|
-
container.addChild(new Text(" Select suggestion model", 1, 0));
|
|
239
|
-
container.addChild(new Text("", 1, 0));
|
|
240
|
-
|
|
241
|
-
const selectList = new SelectList(items, Math.min(items.length, 15), PASSTHROUGH_THEME);
|
|
242
|
-
|
|
243
|
-
if (initialIndex >= 0) {
|
|
244
|
-
selectList.setSelectedIndex(initialIndex);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
selectList.onSelect = (item) => done(item.value);
|
|
248
|
-
selectList.onCancel = () => done();
|
|
249
|
-
|
|
250
|
-
container.addChild(selectList);
|
|
251
|
-
container.addChild(new Text(" ↑↓ navigate • enter select • esc cancel", 1, 0));
|
|
252
|
-
|
|
253
|
-
return {
|
|
254
|
-
render: (width: number) => container.render(width),
|
|
255
|
-
invalidate: () => container.invalidate(),
|
|
256
|
-
handleInput: (data: string) => {
|
|
257
|
-
selectList.handleInput(data);
|
|
258
|
-
return true;
|
|
259
|
-
},
|
|
260
|
-
};
|
|
35
|
+
function collectSettingsSections(pi: ExtensionAPI) {
|
|
36
|
+
const collector = createSettingsContributionCollector();
|
|
37
|
+
pi.events.emit(SUPI_SETTINGS_COLLECT_EVENT, collector);
|
|
38
|
+
return collector.result();
|
|
261
39
|
}
|
|
262
40
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
{
|
|
267
|
-
value: "disabled",
|
|
268
|
-
label: "disabled",
|
|
269
|
-
description: "No prompt suggestions",
|
|
270
|
-
},
|
|
271
|
-
];
|
|
272
|
-
|
|
273
|
-
if (!ctx) return items;
|
|
274
|
-
|
|
275
|
-
const models = getSelectableModels(ctx);
|
|
276
|
-
|
|
277
|
-
for (const model of models) {
|
|
278
|
-
const suffix = model.isCurrent ? " [current]" : "";
|
|
279
|
-
items.push({
|
|
280
|
-
value: model.canonicalId,
|
|
281
|
-
label: `${model.canonicalId}${suffix}`,
|
|
282
|
-
description: model.label !== model.canonicalId ? model.label : undefined,
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
return items;
|
|
41
|
+
function latestStatus(diagnostics: SettingsCollectionDiagnostic[]): OverlayStatus | undefined {
|
|
42
|
+
const latest = diagnostics.at(-1);
|
|
43
|
+
return latest ? { kind: latest.kind, message: latest.message } : undefined;
|
|
287
44
|
}
|
|
288
45
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
const sections = getRegisteredSettings();
|
|
293
|
-
if (sections.length === 0) {
|
|
46
|
+
export function openSettingsOverlay(pi: ExtensionAPI, ctx: ExtensionContext): void {
|
|
47
|
+
const collection = collectSettingsSections(pi);
|
|
48
|
+
if (collection.sections.length === 0) {
|
|
294
49
|
ctx.ui.notify("No settings registered by SuPi extensions", "info");
|
|
295
50
|
return;
|
|
296
51
|
}
|
|
297
52
|
|
|
298
53
|
void ctx.ui.custom<void>((tui, theme, _kb, done) => {
|
|
299
|
-
const state: OverlayState = {
|
|
300
|
-
|
|
54
|
+
const state: OverlayState = {
|
|
55
|
+
scope: "project",
|
|
56
|
+
cwd: ctx.cwd,
|
|
57
|
+
status: latestStatus(collection.diagnostics),
|
|
58
|
+
};
|
|
301
59
|
|
|
302
|
-
const
|
|
60
|
+
const container = new Container();
|
|
61
|
+
const scopedList = new ScopedSettingsList(
|
|
62
|
+
collection.sections,
|
|
63
|
+
state.scope,
|
|
64
|
+
state.cwd,
|
|
303
65
|
ctx,
|
|
304
|
-
state,
|
|
305
|
-
container,
|
|
306
|
-
settingsList: null,
|
|
307
|
-
tui,
|
|
308
66
|
theme,
|
|
67
|
+
tui,
|
|
309
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
|
+
}
|
|
310
91
|
};
|
|
311
92
|
|
|
312
|
-
|
|
93
|
+
rebuildOverlay();
|
|
313
94
|
|
|
314
95
|
const component = {
|
|
315
|
-
render: (width: number) => container.render(width),
|
|
316
|
-
invalidate: () =>
|
|
96
|
+
render: (width: number) => [...container.render(width), ...scopedList.render(width)],
|
|
97
|
+
invalidate: () => {
|
|
98
|
+
container.invalidate();
|
|
99
|
+
scopedList.invalidate();
|
|
100
|
+
},
|
|
317
101
|
handleInput: (data: string) => {
|
|
318
102
|
if (matchesKey(data, Key.tab)) {
|
|
319
|
-
|
|
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();
|
|
320
108
|
return true;
|
|
321
109
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
deps.tui.requestRender();
|
|
110
|
+
scopedList.handleInput(data);
|
|
111
|
+
tui.requestRender();
|
|
325
112
|
return true;
|
|
326
113
|
},
|
|
327
114
|
};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
// supi-core settings-ui domain — settings TUI components (imports pi-tui at runtime, heavy).
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
createModelPickerSubmenu,
|
|
5
|
-
openSettingsOverlay,
|
|
6
|
-
} from "./settings/settings-ui.ts";
|
|
2
|
+
export { createInputSubmenu, createModelPickerSubmenu } from "./settings/settings-submenus.ts";
|
|
3
|
+
export { openSettingsOverlay } from "./settings/settings-ui.ts";
|
|
@@ -1,9 +1,31 @@
|
|
|
1
|
-
// supi-core settings domain — settings
|
|
1
|
+
// supi-core settings domain — event-backed declarative settings contributions and command wiring.
|
|
2
2
|
|
|
3
3
|
export { registerSettingsCommand } from "./settings/settings-command.ts";
|
|
4
|
-
export type {
|
|
4
|
+
export type {
|
|
5
|
+
SettingsCollectionDiagnostic,
|
|
6
|
+
SettingsCollectionResult,
|
|
7
|
+
SettingsContributionCollector,
|
|
8
|
+
SettingsScope,
|
|
9
|
+
SettingsSection,
|
|
10
|
+
} from "./settings/settings-registry.ts";
|
|
5
11
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
createSettingsContributionCollector,
|
|
13
|
+
isSettingsContributionCollector,
|
|
14
|
+
SUPI_SETTINGS_COLLECT_EVENT,
|
|
9
15
|
} from "./settings/settings-registry.ts";
|
|
16
|
+
export type {
|
|
17
|
+
BoolField,
|
|
18
|
+
ConfigHelpers,
|
|
19
|
+
CustomField,
|
|
20
|
+
DeclarativeSettingsOptions,
|
|
21
|
+
EnumField,
|
|
22
|
+
ModelPickerField,
|
|
23
|
+
NumberField,
|
|
24
|
+
ScopedFieldValue,
|
|
25
|
+
SettingsField,
|
|
26
|
+
SettingsFieldAction,
|
|
27
|
+
SettingsPersistedChange,
|
|
28
|
+
StringListField,
|
|
29
|
+
ValueSource,
|
|
30
|
+
} from "./settings/settings-schema.ts";
|
|
31
|
+
export { registerDeclarativeSettings } from "./settings/settings-schema.ts";
|
|
@@ -53,6 +53,16 @@ export function derivePromptSurface(spec: SuiPiToolSpec): SuiPiToolPromptSurface
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
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
|
+
|
|
56
66
|
// ---------------------------------------------------------------------------
|
|
57
67
|
// Registration
|
|
58
68
|
// ---------------------------------------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-debug",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "SuPi Debug extension — shared debug event inspection for SuPi extensions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"README.md"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@mrclrchtr/supi-core": "2.0
|
|
34
|
+
"@mrclrchtr/supi-core": "2.2.0"
|
|
35
35
|
},
|
|
36
36
|
"bundledDependencies": [
|
|
37
37
|
"@mrclrchtr/supi-core"
|
package/src/debug.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
type TruncationResult,
|
|
8
8
|
truncateHead,
|
|
9
9
|
} from "@earendil-works/pi-coding-agent";
|
|
10
|
-
import { loadSupiConfig
|
|
10
|
+
import { loadSupiConfig } from "@mrclrchtr/supi-core/config";
|
|
11
11
|
import { registerContextProvider } from "@mrclrchtr/supi-core/context";
|
|
12
12
|
import {
|
|
13
13
|
clearDebugEvents,
|
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
type DebugEventQuery,
|
|
18
18
|
type DebugEventView,
|
|
19
19
|
type DebugLevel,
|
|
20
|
-
type DebugNotifyLevel,
|
|
21
20
|
getDebugEvents,
|
|
22
21
|
getDebugSummary,
|
|
23
22
|
} from "@mrclrchtr/supi-core/debug";
|
|
23
|
+
import { registerDeclarativeSettings } from "@mrclrchtr/supi-core/settings";
|
|
24
24
|
import { Type } from "typebox";
|
|
25
25
|
import { formatDataLines } from "./format.ts";
|
|
26
26
|
import { registerDebugMessageRenderer } from "./renderer.ts";
|
|
@@ -30,11 +30,10 @@ import { promptGuidelines, promptSnippet, toolDescription } from "./tool/guidanc
|
|
|
30
30
|
const DEBUG_SECTION = "debug";
|
|
31
31
|
const DEBUG_REPORT_TYPE = "supi-debug-report";
|
|
32
32
|
|
|
33
|
-
interface DebugConfig {
|
|
33
|
+
interface DebugConfig extends Record<string, unknown> {
|
|
34
34
|
enabled: boolean;
|
|
35
35
|
agentAccess: DebugAgentAccess;
|
|
36
36
|
maxEvents: number;
|
|
37
|
-
notifyLevel: DebugNotifyLevel;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
const DEBUG_DEFAULTS: DebugConfig = { ...DEBUG_REGISTRY_DEFAULTS };
|
|
@@ -45,10 +44,6 @@ function normalizeAgentAccess(value: string): DebugAgentAccess {
|
|
|
45
44
|
return value === "off" || value === "raw" ? value : "sanitized";
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
function normalizeNotifyLevel(value: string): DebugNotifyLevel {
|
|
49
|
-
return value === "warning" || value === "error" ? value : "off";
|
|
50
|
-
}
|
|
51
|
-
|
|
52
47
|
function normalizeMaxEvents(value: string | number): number {
|
|
53
48
|
const parsed = typeof value === "number" ? value : Number.parseInt(value, 10);
|
|
54
49
|
return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : DEBUG_DEFAULTS.maxEvents;
|
|
@@ -92,7 +87,6 @@ function loadDebugConfig(cwd: string): DebugConfig {
|
|
|
92
87
|
enabled: normalizeEnabled(config.enabled),
|
|
93
88
|
agentAccess: normalizeAgentAccess(String(config.agentAccess)),
|
|
94
89
|
maxEvents: normalizeMaxEvents(config.maxEvents),
|
|
95
|
-
notifyLevel: normalizeNotifyLevel(String(config.notifyLevel)),
|
|
96
90
|
};
|
|
97
91
|
}
|
|
98
92
|
|
|
@@ -110,54 +104,35 @@ function syncLiveDebugRegistry(cwd: string): DebugConfig {
|
|
|
110
104
|
return config;
|
|
111
105
|
}
|
|
112
106
|
|
|
113
|
-
function registerDebugSettings(): void {
|
|
114
|
-
|
|
107
|
+
function registerDebugSettings(pi: ExtensionAPI): void {
|
|
108
|
+
registerDeclarativeSettings(pi, {
|
|
115
109
|
id: "debug",
|
|
116
110
|
label: "Debug",
|
|
117
111
|
section: DEBUG_SECTION,
|
|
118
112
|
defaults: DEBUG_DEFAULTS,
|
|
119
|
-
|
|
113
|
+
fields: [
|
|
120
114
|
{
|
|
121
|
-
|
|
115
|
+
kind: "boolean" as const,
|
|
116
|
+
key: "enabled",
|
|
122
117
|
label: "Enabled",
|
|
123
118
|
description: "Enable/disable session-local SuPi debug event capture",
|
|
124
|
-
currentValue: settings.enabled ? "on" : "off",
|
|
125
|
-
values: ["on", "off"],
|
|
126
119
|
},
|
|
127
120
|
{
|
|
128
|
-
|
|
121
|
+
kind: "enum" as const,
|
|
122
|
+
key: "agentAccess",
|
|
129
123
|
label: "Agent Access",
|
|
130
124
|
description: "Control whether the agent can fetch sanitized or raw debug events",
|
|
131
|
-
currentValue: normalizeAgentAccess(String(settings.agentAccess)),
|
|
132
125
|
values: ["off", "sanitized", "raw"],
|
|
133
126
|
},
|
|
134
127
|
{
|
|
135
|
-
|
|
128
|
+
kind: "number" as const,
|
|
129
|
+
key: "maxEvents",
|
|
136
130
|
label: "Max Events",
|
|
137
131
|
description: "Maximum session-local debug events retained in memory",
|
|
138
|
-
currentValue: String(normalizeMaxEvents(settings.maxEvents)),
|
|
139
132
|
values: ["50", "100", "250", "500"],
|
|
140
133
|
},
|
|
141
|
-
{
|
|
142
|
-
id: "notifyLevel",
|
|
143
|
-
label: "Notify Level",
|
|
144
|
-
description: "Minimum debug event severity that may notify the user",
|
|
145
|
-
currentValue: normalizeNotifyLevel(String(settings.notifyLevel)),
|
|
146
|
-
values: ["off", "warning", "error"],
|
|
147
|
-
},
|
|
148
134
|
],
|
|
149
|
-
|
|
150
|
-
persistChange: (_scope, cwd, settingId, value, helpers) => {
|
|
151
|
-
if (settingId === "enabled") {
|
|
152
|
-
helpers.set("enabled", value === "on");
|
|
153
|
-
} else if (settingId === "agentAccess") {
|
|
154
|
-
helpers.set("agentAccess", normalizeAgentAccess(value));
|
|
155
|
-
} else if (settingId === "maxEvents") {
|
|
156
|
-
helpers.set("maxEvents", normalizeMaxEvents(value));
|
|
157
|
-
} else if (settingId === "notifyLevel") {
|
|
158
|
-
helpers.set("notifyLevel", normalizeNotifyLevel(value));
|
|
159
|
-
}
|
|
160
|
-
|
|
135
|
+
afterPersist: ({ cwd }) => {
|
|
161
136
|
syncLiveDebugRegistry(cwd);
|
|
162
137
|
},
|
|
163
138
|
});
|
|
@@ -292,7 +267,7 @@ function buildToolResult(params: DebugToolParams, config: DebugConfig) {
|
|
|
292
267
|
/** Register the shared SuPi debug command, settings, context summary, and agent tool. */
|
|
293
268
|
export default function debugExtension(pi: ExtensionAPI) {
|
|
294
269
|
applyDebugConfig(process.cwd());
|
|
295
|
-
registerDebugSettings();
|
|
270
|
+
registerDebugSettings(pi);
|
|
296
271
|
registerDebugMessageRenderer(pi);
|
|
297
272
|
|
|
298
273
|
registerContextProvider({
|
package/src/status-log.ts
CHANGED
|
@@ -2,28 +2,6 @@ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
|
|
3
3
|
const STATUS_LOG_PREFIX = "SUPI_STATUS ";
|
|
4
4
|
const STATUS_LOG_ENV = "SUPI_LOG_STATUS";
|
|
5
|
-
const EXPECTED_SUPI_TOOLS = [
|
|
6
|
-
"ask_user",
|
|
7
|
-
"code_resolve",
|
|
8
|
-
"code_inspect",
|
|
9
|
-
"code_orientation",
|
|
10
|
-
"code_graph",
|
|
11
|
-
"code_impact",
|
|
12
|
-
"code_find",
|
|
13
|
-
"code_health",
|
|
14
|
-
"code_refactor_plan",
|
|
15
|
-
"code_refactor_apply",
|
|
16
|
-
"supi_debug",
|
|
17
|
-
];
|
|
18
|
-
const EXPECTED_SUPI_COMMANDS = [
|
|
19
|
-
"supi-settings",
|
|
20
|
-
"supi-debug",
|
|
21
|
-
"supi-context",
|
|
22
|
-
"supi-cache",
|
|
23
|
-
"supi-ci-status",
|
|
24
|
-
"supi-review",
|
|
25
|
-
];
|
|
26
|
-
|
|
27
5
|
function byName(a: string, b: string): number {
|
|
28
6
|
return a.localeCompare(b);
|
|
29
7
|
}
|
|
@@ -35,7 +13,10 @@ function statusLogEnabled(): boolean {
|
|
|
35
13
|
}
|
|
36
14
|
|
|
37
15
|
/**
|
|
38
|
-
* Emit a stderr-only SuPi load status marker for external log inspection.
|
|
16
|
+
* Emit a stderr-only SuPi load status inventory marker for external log inspection.
|
|
17
|
+
*
|
|
18
|
+
* The marker reports observed tools and commands only; consumers own their
|
|
19
|
+
* harness-specific validation policy.
|
|
39
20
|
*
|
|
40
21
|
* This deliberately does not call `pi.sendMessage()`: custom messages are part
|
|
41
22
|
* of pi's session history and are converted into LLM-visible user messages.
|
|
@@ -55,21 +36,9 @@ export function maybeLogLoadStatus(pi: ExtensionAPI, cwd: string): void {
|
|
|
55
36
|
|
|
56
37
|
const status = {
|
|
57
38
|
type: "supi_status",
|
|
58
|
-
version:
|
|
39
|
+
version: 2,
|
|
59
40
|
phase: "session_start",
|
|
60
41
|
cwd,
|
|
61
|
-
expectedTools: Object.fromEntries(
|
|
62
|
-
EXPECTED_SUPI_TOOLS.map((tool) => [
|
|
63
|
-
tool,
|
|
64
|
-
{
|
|
65
|
-
registered: registeredToolNames.includes(tool),
|
|
66
|
-
active: activeToolNames.includes(tool),
|
|
67
|
-
},
|
|
68
|
-
]),
|
|
69
|
-
),
|
|
70
|
-
expectedCommands: Object.fromEntries(
|
|
71
|
-
EXPECTED_SUPI_COMMANDS.map((command) => [command, commandNames.includes(command)]),
|
|
72
|
-
),
|
|
73
42
|
tools: {
|
|
74
43
|
registered: registeredToolNames,
|
|
75
44
|
active: activeToolNames,
|
package/src/tool/guidance.ts
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
|
|
5
|
-
export const toolDescription = `Fetch recent session-local SuPi debug events
|
|
5
|
+
export const toolDescription = `Fetch recent session-local SuPi debug events with optional filters; raw data only when allowed. Output is truncated to ${DEFAULT_MAX_LINES} lines or ${formatSize(DEFAULT_MAX_BYTES)} (whichever is hit first).`;
|
|
6
6
|
|
|
7
7
|
export const promptSnippet = "supi_debug — fetch recent SuPi debug events";
|
|
8
8
|
|
|
9
9
|
export const promptGuidelines = [
|
|
10
|
-
"Use supi_debug
|
|
11
|
-
"Use supi_debug's default sanitized output unless the user explicitly asks for raw diagnostics and settings allow raw supi_debug data.",
|
|
10
|
+
"Use supi_debug for SuPi failures, fallback reasons, or recent session debug events; request raw data only when explicitly asked and settings allow it.",
|
|
12
11
|
];
|