@mrclrchtr/supi-lsp 2.1.0 → 2.2.1
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-code-runtime/node_modules/@mrclrchtr/supi-core/README.md +9 -8
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -3
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +0 -5
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/scoped-settings-list.ts +372 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-action-menu.ts +101 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +13 -7
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +464 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-submenus.ts +124 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +50 -309
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +2 -5
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings.ts +17 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-core/README.md +9 -8
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- 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/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-registry.ts +13 -7
- 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 +50 -309
- package/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +2 -5
- package/node_modules/@mrclrchtr/supi-core/src/settings.ts +17 -1
- package/package.json +3 -3
- package/src/client/client.ts +49 -12
- package/src/config/lsp-settings.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +0 -207
- package/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +0 -207
|
@@ -1,79 +1,21 @@
|
|
|
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
6
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
Input,
|
|
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";
|
|
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";
|
|
21
10
|
import {
|
|
22
11
|
createSettingsContributionCollector,
|
|
23
|
-
type SettingsCollectionDiagnostic,
|
|
24
|
-
type SettingsScope,
|
|
25
|
-
type SettingsSection,
|
|
26
12
|
SUPI_SETTINGS_COLLECT_EVENT,
|
|
27
13
|
} from "./settings-registry.ts";
|
|
28
14
|
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Creates a pi-tui Input-backed submenu component with enter-to-confirm
|
|
33
|
-
* and escape-to-cancel handling.
|
|
34
|
-
*
|
|
35
|
-
* @param currentValue - Initial value for the text input.
|
|
36
|
-
* @param label - Label text displayed above the input.
|
|
37
|
-
* @param done - Callback invoked with the confirmed value, or undefined on cancel.
|
|
38
|
-
*/
|
|
39
|
-
export function createInputSubmenu(
|
|
40
|
-
currentValue: string,
|
|
41
|
-
label: string,
|
|
42
|
-
done: (selectedValue?: string) => void,
|
|
43
|
-
): {
|
|
44
|
-
render: (width: number) => string[];
|
|
45
|
-
invalidate: () => void;
|
|
46
|
-
handleInput: (data: string) => boolean;
|
|
47
|
-
} {
|
|
48
|
-
const input = new Input();
|
|
49
|
-
input.setValue(currentValue);
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
render: (_width: number) => {
|
|
53
|
-
const lines = [` ${label}`];
|
|
54
|
-
lines.push(...input.render(_width));
|
|
55
|
-
lines.push(" enter confirm • esc cancel");
|
|
56
|
-
return lines;
|
|
57
|
-
},
|
|
58
|
-
invalidate: () => {
|
|
59
|
-
input.invalidate();
|
|
60
|
-
},
|
|
61
|
-
handleInput: (data: string) => {
|
|
62
|
-
if (matchesKey(data, Key.escape)) {
|
|
63
|
-
done();
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
if (matchesKey(data, Key.enter)) {
|
|
67
|
-
done(input.getValue());
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
input.handleInput(data);
|
|
71
|
-
return true;
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
}
|
|
15
|
+
// Re-export submenu helpers
|
|
16
|
+
export { createInputSubmenu, createModelPickerSubmenu } from "./settings-submenus.ts";
|
|
75
17
|
|
|
76
|
-
// ──
|
|
18
|
+
// ── Overlay ────────────────────────────────────────────────────────────────
|
|
77
19
|
|
|
78
20
|
interface OverlayStatus {
|
|
79
21
|
kind: "warning" | "error";
|
|
@@ -86,45 +28,10 @@ interface OverlayState {
|
|
|
86
28
|
status?: OverlayStatus;
|
|
87
29
|
}
|
|
88
30
|
|
|
89
|
-
// ── Pure helpers ─────────────────────────────────────────────
|
|
90
|
-
|
|
91
31
|
function getScopeLabel(scope: SettingsScope): string {
|
|
92
32
|
return scope === "project" ? "Project" : "Global";
|
|
93
33
|
}
|
|
94
34
|
|
|
95
|
-
function buildFlatItems(
|
|
96
|
-
sections: SettingsSection[],
|
|
97
|
-
scope: SettingsScope,
|
|
98
|
-
cwd: string,
|
|
99
|
-
ctx?: ExtensionContext,
|
|
100
|
-
): SettingItem[] {
|
|
101
|
-
const items: SettingItem[] = [];
|
|
102
|
-
for (const section of sections) {
|
|
103
|
-
const sectionItems = section.loadValues(scope, cwd, ctx);
|
|
104
|
-
for (const item of sectionItems) {
|
|
105
|
-
items.push({
|
|
106
|
-
...item,
|
|
107
|
-
id: `${section.id}.${item.id}`,
|
|
108
|
-
label: `${section.label}: ${item.label}`,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return items;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function findSectionAndId(
|
|
116
|
-
sections: SettingsSection[],
|
|
117
|
-
flatId: string,
|
|
118
|
-
): { section: SettingsSection; itemId: string } | null {
|
|
119
|
-
const dotIndex = flatId.indexOf(".");
|
|
120
|
-
if (dotIndex === -1) return null;
|
|
121
|
-
const sectionId = flatId.slice(0, dotIndex);
|
|
122
|
-
const itemId = flatId.slice(dotIndex + 1);
|
|
123
|
-
const section = sections.find((s) => s.id === sectionId);
|
|
124
|
-
if (!section) return null;
|
|
125
|
-
return { section, itemId };
|
|
126
|
-
}
|
|
127
|
-
|
|
128
35
|
function collectSettingsSections(pi: ExtensionAPI) {
|
|
129
36
|
const collector = createSettingsContributionCollector();
|
|
130
37
|
pi.events.emit(SUPI_SETTINGS_COLLECT_EVENT, collector);
|
|
@@ -136,199 +43,6 @@ function latestStatus(diagnostics: SettingsCollectionDiagnostic[]): OverlayStatu
|
|
|
136
43
|
return latest ? { kind: latest.kind, message: latest.message } : undefined;
|
|
137
44
|
}
|
|
138
45
|
|
|
139
|
-
function formatSettingsError(settingId: string, error: unknown): string {
|
|
140
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
141
|
-
return `Could not save SuPi setting "${settingId}": ${message}`;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// ── Component ────────────────────────────────────────────────
|
|
145
|
-
|
|
146
|
-
interface SettingsOverlayDeps {
|
|
147
|
-
ctx: ExtensionContext;
|
|
148
|
-
sections: SettingsSection[];
|
|
149
|
-
state: OverlayState;
|
|
150
|
-
container: Container;
|
|
151
|
-
settingsList: SettingsList | null;
|
|
152
|
-
tui: Parameters<Parameters<ExtensionContext["ui"]["custom"]>[0]>[0];
|
|
153
|
-
theme: Parameters<Parameters<ExtensionContext["ui"]["custom"]>[0]>[1];
|
|
154
|
-
done: () => void;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function createSettingsList(deps: SettingsOverlayDeps): SettingsList {
|
|
158
|
-
const items = buildFlatItems(deps.sections, deps.state.scope, deps.state.cwd, deps.ctx);
|
|
159
|
-
const onChange = (flatId: string, newValue: string) => {
|
|
160
|
-
const found = findSectionAndId(deps.sections, flatId);
|
|
161
|
-
try {
|
|
162
|
-
if (found) {
|
|
163
|
-
found.section.persistChange(deps.state.scope, deps.state.cwd, found.itemId, newValue);
|
|
164
|
-
deps.state.status = undefined;
|
|
165
|
-
}
|
|
166
|
-
} catch (error) {
|
|
167
|
-
deps.state.status = {
|
|
168
|
-
kind: "error",
|
|
169
|
-
message: formatSettingsError(found?.itemId ?? flatId, error),
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
// Re-read all values to reflect persisted changes, but keep the list
|
|
173
|
-
// instance (and its selectedIndex) intact.
|
|
174
|
-
const updatedItems = buildFlatItems(deps.sections, deps.state.scope, deps.state.cwd, deps.ctx);
|
|
175
|
-
for (const updated of updatedItems) {
|
|
176
|
-
const existing = items.find((i) => i.id === updated.id);
|
|
177
|
-
if (existing && existing.currentValue !== updated.currentValue) {
|
|
178
|
-
settingsList.updateValue(updated.id, updated.currentValue);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
deps.tui.requestRender();
|
|
182
|
-
};
|
|
183
|
-
const settingsList = new SettingsList(
|
|
184
|
-
items,
|
|
185
|
-
Math.min(items.length + 4, 20),
|
|
186
|
-
getSettingsListTheme(),
|
|
187
|
-
onChange,
|
|
188
|
-
() => deps.done(),
|
|
189
|
-
{ enableSearch: true },
|
|
190
|
-
);
|
|
191
|
-
return settingsList;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function rebuildSettingsList(deps: SettingsOverlayDeps): SettingsList {
|
|
195
|
-
const settingsList = createSettingsList(deps);
|
|
196
|
-
deps.settingsList = settingsList;
|
|
197
|
-
|
|
198
|
-
deps.container.clear();
|
|
199
|
-
deps.container.addChild(createHeaderComponent(deps));
|
|
200
|
-
deps.container.addChild(createStatusComponent(deps));
|
|
201
|
-
deps.container.addChild(settingsList);
|
|
202
|
-
|
|
203
|
-
return settingsList;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function createHeaderComponent(deps: SettingsOverlayDeps): Text {
|
|
207
|
-
const { theme, state } = deps;
|
|
208
|
-
const scopeLabel = getScopeLabel(state.scope);
|
|
209
|
-
const otherScope = state.scope === "project" ? "Global" : "Project";
|
|
210
|
-
const headerText = new Text(
|
|
211
|
-
`${theme.fg("accent", theme.bold("SuPi Settings"))} ${theme.fg("text", `Scope: ${scopeLabel}`)} ${theme.fg("dim", `(tab → ${otherScope})`)}`,
|
|
212
|
-
0,
|
|
213
|
-
0,
|
|
214
|
-
);
|
|
215
|
-
return headerText;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function createStatusComponent(deps: SettingsOverlayDeps): {
|
|
219
|
-
render: () => string[];
|
|
220
|
-
invalidate: () => void;
|
|
221
|
-
} {
|
|
222
|
-
return {
|
|
223
|
-
render: () => {
|
|
224
|
-
const status = deps.state.status;
|
|
225
|
-
if (!status) return [];
|
|
226
|
-
return [deps.theme.fg(status.kind, status.message)];
|
|
227
|
-
},
|
|
228
|
-
invalidate: () => {},
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function handleScopeToggle(deps: SettingsOverlayDeps): void {
|
|
233
|
-
deps.state.scope = deps.state.scope === "project" ? "global" : "project";
|
|
234
|
-
rebuildSettingsList(deps);
|
|
235
|
-
deps.tui.requestRender();
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/** Minimal SelectList theme — uses identity so the parent SettingsList provides styling context. */
|
|
239
|
-
const PASSTHROUGH_THEME: SelectListTheme = {
|
|
240
|
-
selectedPrefix: (text) => `› ${text}`,
|
|
241
|
-
selectedText: (text) => text,
|
|
242
|
-
description: (text) => text,
|
|
243
|
-
scrollInfo: (text) => text,
|
|
244
|
-
noMatch: (text) => text,
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Create a model picker submenu for settings.
|
|
249
|
-
*
|
|
250
|
-
* Shows a scrollable list of selectable models from the scoped model set,
|
|
251
|
-
* with the current session model annotated `[current]`. The first entry is
|
|
252
|
-
* always `"disabled"`.
|
|
253
|
-
*
|
|
254
|
-
* @param currentValue - Currently configured canonical model id or `"disabled"`.
|
|
255
|
-
* @param done - Callback invoked with the selected value, or undefined on cancel.
|
|
256
|
-
* @param ctx - Extension context for model listing. When undefined, only
|
|
257
|
-
* `"disabled"` is offered.
|
|
258
|
-
*/
|
|
259
|
-
export function createModelPickerSubmenu(
|
|
260
|
-
currentValue: string,
|
|
261
|
-
done: (selectedValue?: string) => void,
|
|
262
|
-
ctx?: ExtensionContext,
|
|
263
|
-
): {
|
|
264
|
-
render: (width: number) => string[];
|
|
265
|
-
invalidate: () => void;
|
|
266
|
-
handleInput: (data: string) => boolean;
|
|
267
|
-
} {
|
|
268
|
-
const items = buildModelItems(ctx);
|
|
269
|
-
|
|
270
|
-
const initialIndex =
|
|
271
|
-
currentValue === "disabled"
|
|
272
|
-
? 0
|
|
273
|
-
: Math.max(
|
|
274
|
-
0,
|
|
275
|
-
items.findIndex((item) => item.value === currentValue),
|
|
276
|
-
);
|
|
277
|
-
|
|
278
|
-
const container = new Container();
|
|
279
|
-
container.addChild(new Text(" Select suggestion model", 1, 0));
|
|
280
|
-
container.addChild(new Text("", 1, 0));
|
|
281
|
-
|
|
282
|
-
const selectList = new SelectList(items, Math.min(items.length, 15), PASSTHROUGH_THEME);
|
|
283
|
-
|
|
284
|
-
if (initialIndex >= 0) {
|
|
285
|
-
selectList.setSelectedIndex(initialIndex);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
selectList.onSelect = (item) => done(item.value);
|
|
289
|
-
selectList.onCancel = () => done();
|
|
290
|
-
|
|
291
|
-
container.addChild(selectList);
|
|
292
|
-
container.addChild(new Text(" ↑↓ navigate • enter select • esc cancel", 1, 0));
|
|
293
|
-
|
|
294
|
-
return {
|
|
295
|
-
render: (width: number) => container.render(width),
|
|
296
|
-
invalidate: () => container.invalidate(),
|
|
297
|
-
handleInput: (data: string) => {
|
|
298
|
-
selectList.handleInput(data);
|
|
299
|
-
return true;
|
|
300
|
-
},
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/** Build selectable model items with "disabled" first. */
|
|
305
|
-
function buildModelItems(ctx?: ExtensionContext): SelectItem[] {
|
|
306
|
-
const items: SelectItem[] = [
|
|
307
|
-
{
|
|
308
|
-
value: "disabled",
|
|
309
|
-
label: "disabled",
|
|
310
|
-
description: "No prompt suggestions",
|
|
311
|
-
},
|
|
312
|
-
];
|
|
313
|
-
|
|
314
|
-
if (!ctx) return items;
|
|
315
|
-
|
|
316
|
-
const models = getSelectableModels(ctx);
|
|
317
|
-
|
|
318
|
-
for (const model of models) {
|
|
319
|
-
const suffix = model.isCurrent ? " [current]" : "";
|
|
320
|
-
items.push({
|
|
321
|
-
value: model.canonicalId,
|
|
322
|
-
label: `${model.canonicalId}${suffix}`,
|
|
323
|
-
description: model.label !== model.canonicalId ? model.label : undefined,
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
return items;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// ── Entry point ──────────────────────────────────────────────
|
|
331
|
-
|
|
332
46
|
export function openSettingsOverlay(pi: ExtensionAPI, ctx: ExtensionContext): void {
|
|
333
47
|
const collection = collectSettingsSections(pi);
|
|
334
48
|
if (collection.sections.length === 0) {
|
|
@@ -342,32 +56,59 @@ export function openSettingsOverlay(pi: ExtensionAPI, ctx: ExtensionContext): vo
|
|
|
342
56
|
cwd: ctx.cwd,
|
|
343
57
|
status: latestStatus(collection.diagnostics),
|
|
344
58
|
};
|
|
345
|
-
const container = new Container();
|
|
346
59
|
|
|
347
|
-
const
|
|
60
|
+
const container = new Container();
|
|
61
|
+
const scopedList = new ScopedSettingsList(
|
|
62
|
+
collection.sections,
|
|
63
|
+
state.scope,
|
|
64
|
+
state.cwd,
|
|
348
65
|
ctx,
|
|
349
|
-
sections: collection.sections,
|
|
350
|
-
state,
|
|
351
|
-
container,
|
|
352
|
-
settingsList: null,
|
|
353
|
-
tui,
|
|
354
66
|
theme,
|
|
67
|
+
tui,
|
|
355
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
|
+
}
|
|
356
91
|
};
|
|
357
92
|
|
|
358
|
-
|
|
93
|
+
rebuildOverlay();
|
|
359
94
|
|
|
360
95
|
const component = {
|
|
361
|
-
render: (width: number) => container.render(width),
|
|
362
|
-
invalidate: () =>
|
|
96
|
+
render: (width: number) => [...container.render(width), ...scopedList.render(width)],
|
|
97
|
+
invalidate: () => {
|
|
98
|
+
container.invalidate();
|
|
99
|
+
scopedList.invalidate();
|
|
100
|
+
},
|
|
363
101
|
handleInput: (data: string) => {
|
|
364
102
|
if (matchesKey(data, Key.tab)) {
|
|
365
|
-
|
|
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();
|
|
366
108
|
return true;
|
|
367
109
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
deps.tui.requestRender();
|
|
110
|
+
scopedList.handleInput(data);
|
|
111
|
+
tui.requestRender();
|
|
371
112
|
return true;
|
|
372
113
|
},
|
|
373
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,4 +1,4 @@
|
|
|
1
|
-
// supi-core settings domain — event-backed 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
4
|
export type {
|
|
@@ -13,3 +13,19 @@ export {
|
|
|
13
13
|
isSettingsContributionCollector,
|
|
14
14
|
SUPI_SETTINGS_COLLECT_EVENT,
|
|
15
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";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-lsp",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "SuPi LSP extension — Language Server Protocol integration for pi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"vscode-jsonrpc": "^9.0.0",
|
|
39
39
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
40
40
|
"vscode-languageserver-types": "^3.17.5",
|
|
41
|
-
"@mrclrchtr/supi-code-runtime": "2.1
|
|
42
|
-
"@mrclrchtr/supi-core": "2.1
|
|
41
|
+
"@mrclrchtr/supi-code-runtime": "2.2.1",
|
|
42
|
+
"@mrclrchtr/supi-core": "2.2.1"
|
|
43
43
|
},
|
|
44
44
|
"bundledDependencies": [
|
|
45
45
|
"@mrclrchtr/supi-code-runtime",
|
package/src/client/client.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Handles initialize handshake, document sync, shutdown, and crash recovery.
|
|
3
3
|
|
|
4
4
|
// biome-ignore lint/style/noExcessiveLinesPerFile: LspClient remains a cohesive stateful wrapper; refresh logic is already split out.
|
|
5
|
-
import { type ChildProcess, spawn } from "node:child_process";
|
|
5
|
+
import { type ChildProcess, execSync, spawn } from "node:child_process";
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
7
7
|
import * as path from "node:path";
|
|
8
8
|
import { recordDebugEvent } from "@mrclrchtr/supi-core/debug";
|
|
@@ -37,6 +37,31 @@ import { JsonRpcClient, JsonRpcRequestError } from "./transport.ts";
|
|
|
37
37
|
const SHUTDOWN_TIMEOUT_MS = 5_000;
|
|
38
38
|
const DIAGNOSTIC_WAIT_MS = 3_000;
|
|
39
39
|
|
|
40
|
+
// ── Process-tree cleanup ──────────────────────────────────────────────
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Kill a process and all its descendants.
|
|
44
|
+
*
|
|
45
|
+
* On Unix, sends SIGTERM to the process group (negative PID).
|
|
46
|
+
* This requires the child to be spawned with `detached: true`.
|
|
47
|
+
* On Windows, uses `taskkill /T /F` to force-kill the entire tree.
|
|
48
|
+
*/
|
|
49
|
+
function killProcessTree(pid: number): void {
|
|
50
|
+
if (process.platform === "win32") {
|
|
51
|
+
try {
|
|
52
|
+
execSync(`taskkill /PID ${pid} /T /F`, { stdio: "ignore" });
|
|
53
|
+
} catch {
|
|
54
|
+
// Process may have already exited — ignore.
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
process.kill(-pid, "SIGTERM");
|
|
60
|
+
} catch {
|
|
61
|
+
// Process group may already be dead — ignore.
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
40
65
|
// ── Types ─────────────────────────────────────────────────────────────
|
|
41
66
|
export type ClientStatus = "initializing" | "running" | "error" | "shutdown";
|
|
42
67
|
|
|
@@ -116,6 +141,10 @@ export class LspClient {
|
|
|
116
141
|
cwd: this.root,
|
|
117
142
|
stdio: ["pipe", "pipe", "pipe"],
|
|
118
143
|
env: { ...process.env },
|
|
144
|
+
// Run the server in its own process group so we can atomically
|
|
145
|
+
// kill the entire tree (server + subprocesses like tsserver)
|
|
146
|
+
// with `process.kill(-pid, signal)` on Unix or `taskkill /T` on Windows.
|
|
147
|
+
detached: true,
|
|
119
148
|
});
|
|
120
149
|
} catch (err) {
|
|
121
150
|
this._status = "error";
|
|
@@ -209,18 +238,26 @@ export class LspClient {
|
|
|
209
238
|
|
|
210
239
|
this.rpc.dispose();
|
|
211
240
|
|
|
212
|
-
//
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
241
|
+
// Kill the entire process tree (server + subprocesses like tsserver).
|
|
242
|
+
// The LSP shutdown/exit protocol above should trigger a graceful exit,
|
|
243
|
+
// but the process-group kill ensures no orphans survive.
|
|
244
|
+
const pid = this.process.pid;
|
|
245
|
+
if (this.process.exitCode === null && pid) {
|
|
246
|
+
killProcessTree(pid);
|
|
247
|
+
if (process.platform !== "win32") {
|
|
248
|
+
// Escalate to SIGKILL after a brief grace period on Unix.
|
|
249
|
+
// Windows taskkill /F is already forceful.
|
|
250
|
+
await new Promise<void>((resolve) => {
|
|
251
|
+
setTimeout(() => {
|
|
252
|
+
try {
|
|
253
|
+
process.kill(-pid, "SIGKILL");
|
|
254
|
+
} catch {
|
|
255
|
+
// Already dead — ignore.
|
|
256
|
+
}
|
|
257
|
+
resolve();
|
|
258
|
+
}, 500);
|
|
222
259
|
});
|
|
223
|
-
}
|
|
260
|
+
}
|
|
224
261
|
}
|
|
225
262
|
|
|
226
263
|
this.openDocs.clear();
|
|
@@ -8,7 +8,7 @@ import { loadSupiConfig, loadSupiConfigForScope } from "@mrclrchtr/supi-core/con
|
|
|
8
8
|
|
|
9
9
|
// ── Types ────────────────────────────────────────────────────
|
|
10
10
|
|
|
11
|
-
export interface LspSettings {
|
|
11
|
+
export interface LspSettings extends Record<string, unknown> {
|
|
12
12
|
enabled: boolean;
|
|
13
13
|
severity: number;
|
|
14
14
|
active: string[];
|