@mrclrchtr/supi-lsp 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/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/README.md +32 -23
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +2 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config.ts +22 -8
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/prompt-surface.ts +357 -0
- 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/prompt-surface.ts +4 -0
- 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-command.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +55 -27
- 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 +72 -285
- 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 +27 -5
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +10 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
- 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 +3 -3
- 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 -188
- package/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +0 -188
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
// Config-aware settings helper for SuPi config-backed settings sections.
|
|
2
|
-
// Wraps registerSettings() and centralizes selected-scope loading + scoped persistence.
|
|
3
|
-
//
|
|
4
|
-
// Setting items can declare a `configType` ("boolean" | "number" | "stringList")
|
|
5
|
-
// to enable auto-generated persistChange. When all items have a configType,
|
|
6
|
-
// the persistChange callback can be omitted.
|
|
7
|
-
|
|
8
|
-
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
9
|
-
import type { SettingItem } from "@earendil-works/pi-tui";
|
|
10
|
-
import type { SettingsScope } from "../settings/settings-registry.ts";
|
|
11
|
-
import { registerSettings } from "../settings/settings-registry.ts";
|
|
12
|
-
import { loadSupiConfigForScope, removeSupiConfigKey, writeSupiConfig } from "./config.ts";
|
|
13
|
-
|
|
14
|
-
// ── Types ──────────────────────────────────────────────────────────────────
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Supported config value types for declarative persistChange.
|
|
18
|
-
*
|
|
19
|
-
* - `"boolean"`: maps "on" → true, "off" → false
|
|
20
|
-
* - `"number"`: parses integer via Number.parseInt, falls back to unset on invalid
|
|
21
|
-
* - `"stringList"`: splits on comma, trims whitespace, unsets on empty
|
|
22
|
-
*/
|
|
23
|
-
export type ConfigSettingType = "boolean" | "number" | "stringList";
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Extended setting item that can declare its config type for auto-generated
|
|
27
|
-
* persistence handling.
|
|
28
|
-
*/
|
|
29
|
-
export interface ConfigSettingItem extends SettingItem {
|
|
30
|
-
/**
|
|
31
|
-
* When set, persistChange for this item is auto-generated.
|
|
32
|
-
* All items must declare a configType for auto-generation to activate.
|
|
33
|
-
*/
|
|
34
|
-
configType?: ConfigSettingType;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Helpers provided to the persistChange callback for writing or removing
|
|
39
|
-
* scoped config values.
|
|
40
|
-
*/
|
|
41
|
-
export interface ConfigSettingsHelpers {
|
|
42
|
-
/** Write a key to the selected scope's config section. */
|
|
43
|
-
set(key: string, value: unknown): void;
|
|
44
|
-
/** Remove a key from the selected scope's config section. */
|
|
45
|
-
unset(key: string): void;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface ConfigSettingsOptions<T> {
|
|
49
|
-
/** Extension identifier — e.g. "lsp", "claude-md" */
|
|
50
|
-
id: string;
|
|
51
|
-
/** Human-readable label shown in the UI */
|
|
52
|
-
label: string;
|
|
53
|
-
/** SuPi config section name — e.g. "lsp", "claude-md" */
|
|
54
|
-
section: string;
|
|
55
|
-
/** Default config values */
|
|
56
|
-
defaults: T;
|
|
57
|
-
/**
|
|
58
|
-
* Build SettingItem[] from scoped config. Called by loadValues.
|
|
59
|
-
*
|
|
60
|
-
* Items can include a `configType` property for auto-generated
|
|
61
|
-
* persistChange handling. When ALL items declare a configType,
|
|
62
|
-
* the `persistChange` callback can be omitted.
|
|
63
|
-
*/
|
|
64
|
-
buildItems: (
|
|
65
|
-
settings: T,
|
|
66
|
-
scope: SettingsScope,
|
|
67
|
-
cwd: string,
|
|
68
|
-
ctx?: ExtensionContext,
|
|
69
|
-
) => ConfigSettingItem[];
|
|
70
|
-
/**
|
|
71
|
-
* Handle a settings change with scoped persistence helpers.
|
|
72
|
-
*
|
|
73
|
-
* Optional when all items returned by `buildItems` declare a `configType`.
|
|
74
|
-
* Required when any item lacks a `configType`.
|
|
75
|
-
*/
|
|
76
|
-
persistChange?: (
|
|
77
|
-
scope: SettingsScope,
|
|
78
|
-
cwd: string,
|
|
79
|
-
settingId: string,
|
|
80
|
-
value: string,
|
|
81
|
-
helpers: ConfigSettingsHelpers,
|
|
82
|
-
) => void;
|
|
83
|
-
/** Optional home directory for config resolution (testing). */
|
|
84
|
-
homeDir?: string;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// ── Auto-generated persistChange ───────────────────────────────────────────
|
|
88
|
-
|
|
89
|
-
function autoPersistChange(
|
|
90
|
-
settingId: string,
|
|
91
|
-
value: string,
|
|
92
|
-
helpers: ConfigSettingsHelpers,
|
|
93
|
-
items: ConfigSettingItem[],
|
|
94
|
-
): void {
|
|
95
|
-
const item = items.find((i) => i.id === settingId);
|
|
96
|
-
if (!item?.configType) return;
|
|
97
|
-
|
|
98
|
-
switch (item.configType) {
|
|
99
|
-
case "boolean": {
|
|
100
|
-
helpers.set(settingId, value === "on");
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
case "number": {
|
|
104
|
-
const num = Number.parseInt(value, 10);
|
|
105
|
-
if (Number.isFinite(num) && num > 0) {
|
|
106
|
-
helpers.set(settingId, num);
|
|
107
|
-
} else {
|
|
108
|
-
helpers.unset(settingId);
|
|
109
|
-
}
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
case "stringList": {
|
|
113
|
-
const names = value
|
|
114
|
-
.split(",")
|
|
115
|
-
.map((s) => s.trim())
|
|
116
|
-
.filter((s) => s.length > 0);
|
|
117
|
-
if (names.length > 0) {
|
|
118
|
-
helpers.set(settingId, names);
|
|
119
|
-
} else {
|
|
120
|
-
helpers.unset(settingId);
|
|
121
|
-
}
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function areAllItemsDeclarative(items: ConfigSettingItem[]): boolean {
|
|
128
|
-
return items.length > 0 && items.every((i) => i.configType !== undefined);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// ── Registration ───────────────────────────────────────────────────────────
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Register a config-backed settings section.
|
|
135
|
-
*
|
|
136
|
-
* Loads display values from the selected scope only (`defaults <- selected scope`)
|
|
137
|
-
* instead of merged effective runtime config. Provides scoped `set` / `unset`
|
|
138
|
-
* persistence helpers so extensions don't need to wire `writeSupiConfig` /
|
|
139
|
-
* `removeSupiConfigKey` by hand.
|
|
140
|
-
*
|
|
141
|
-
* When every item returned by `buildItems` declares a `configType`, the
|
|
142
|
-
* `persistChange` callback is optional and will be auto-generated.
|
|
143
|
-
*/
|
|
144
|
-
export function registerConfigSettings<T>(options: ConfigSettingsOptions<T>): void {
|
|
145
|
-
let cachedItems: ConfigSettingItem[] | undefined;
|
|
146
|
-
|
|
147
|
-
registerSettings({
|
|
148
|
-
id: options.id,
|
|
149
|
-
label: options.label,
|
|
150
|
-
loadValues: (scope, cwd, ctx) => {
|
|
151
|
-
const settings = loadSupiConfigForScope(options.section, cwd, options.defaults, {
|
|
152
|
-
scope,
|
|
153
|
-
homeDir: options.homeDir,
|
|
154
|
-
});
|
|
155
|
-
const items = options.buildItems(settings, scope, cwd, ctx);
|
|
156
|
-
cachedItems = items;
|
|
157
|
-
return items;
|
|
158
|
-
},
|
|
159
|
-
persistChange: (scope, cwd, settingId, value) => {
|
|
160
|
-
const helpers: ConfigSettingsHelpers = {
|
|
161
|
-
set: (key, val) => {
|
|
162
|
-
writeSupiConfig(
|
|
163
|
-
{ section: options.section, scope, cwd },
|
|
164
|
-
{ [key]: val },
|
|
165
|
-
{ homeDir: options.homeDir },
|
|
166
|
-
);
|
|
167
|
-
},
|
|
168
|
-
unset: (key) => {
|
|
169
|
-
removeSupiConfigKey({ section: options.section, scope, cwd }, key, {
|
|
170
|
-
homeDir: options.homeDir,
|
|
171
|
-
});
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
// Use manual persistChange when provided
|
|
176
|
-
if (options.persistChange) {
|
|
177
|
-
options.persistChange(scope, cwd, settingId, value, helpers);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Auto-generate when all items are declarative
|
|
182
|
-
const items = cachedItems ?? options.buildItems(options.defaults, scope, cwd, undefined);
|
|
183
|
-
if (areAllItemsDeclarative(items)) {
|
|
184
|
-
autoPersistChange(settingId, value, helpers, items);
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
});
|
|
188
|
-
}
|