@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
package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/README.md
CHANGED
|
@@ -39,15 +39,17 @@ Config file locations:
|
|
|
39
39
|
|
|
40
40
|
### Settings helpers
|
|
41
41
|
|
|
42
|
-
- `
|
|
43
|
-
- `
|
|
44
|
-
- `
|
|
45
|
-
- `openSettingsOverlay()` — open the shared settings UI directly
|
|
42
|
+
- `registerDeclarativeSettings(pi, options)` — contribute a config-backed declarative settings section with source-aware scoped persistence
|
|
43
|
+
- `registerSettingsCommand(pi)` — register `/supi-settings` (used by `@mrclrchtr/supi-settings`)
|
|
44
|
+
- `openSettingsOverlay(pi, ctx)` — open the shared settings UI directly
|
|
46
45
|
- `createInputSubmenu()` — helper for simple text-entry submenus
|
|
46
|
+
- `createModelPickerSubmenu()` — helper for scoped model selection submenus
|
|
47
47
|
|
|
48
48
|
The built-in settings UI supports:
|
|
49
49
|
|
|
50
50
|
- project/global scope toggle
|
|
51
|
+
- source badges for project, global, and default values
|
|
52
|
+
- Inherit/Reset actions that delete scoped config keys
|
|
51
53
|
- grouped extension sections
|
|
52
54
|
- searchable setting lists
|
|
53
55
|
|
|
@@ -83,25 +85,32 @@ The built-in settings UI supports:
|
|
|
83
85
|
## Example
|
|
84
86
|
|
|
85
87
|
```ts
|
|
86
|
-
import {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
88
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
89
|
+
import { loadSupiConfig, registerDeclarativeSettings, wrapExtensionContext } from "@mrclrchtr/supi-core/api";
|
|
90
|
+
|
|
91
|
+
export default function myExtension(pi: ExtensionAPI) {
|
|
92
|
+
const defaults = { enabled: true };
|
|
93
|
+
const config = loadSupiConfig("my-extension", process.cwd(), defaults);
|
|
94
|
+
|
|
95
|
+
registerDeclarativeSettings(pi, {
|
|
96
|
+
id: "my-extension",
|
|
97
|
+
label: "My Extension",
|
|
98
|
+
section: "my-extension",
|
|
99
|
+
defaults,
|
|
100
|
+
fields: [
|
|
101
|
+
{
|
|
102
|
+
kind: "boolean" as const,
|
|
103
|
+
key: "enabled",
|
|
104
|
+
label: "Enabled",
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const message = wrapExtensionContext("my-extension", "hello", {
|
|
110
|
+
enabled: config.enabled,
|
|
111
|
+
});
|
|
112
|
+
void message;
|
|
113
|
+
}
|
|
105
114
|
```
|
|
106
115
|
|
|
107
116
|
## Source
|
package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-core",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "SuPi core — shared infrastructure for SuPi extensions (XML context tags, config system)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"./status-spinner": "./src/status-spinner.ts",
|
|
71
71
|
"./terminal": "./src/terminal.ts",
|
|
72
72
|
"./tool-framework": "./src/tool-framework.ts",
|
|
73
|
+
"./prompt-surface": "./src/prompt-surface.ts",
|
|
73
74
|
"./types": "./src/types.ts"
|
|
74
75
|
}
|
|
75
76
|
}
|
|
@@ -21,6 +21,15 @@ function getProjectConfigPath(cwd: string): string {
|
|
|
21
21
|
return path.join(cwd, PROJECT_CONFIG_DIR, CONFIG_FILE);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/** Return the SuPi config file path for one scope. */
|
|
25
|
+
export function getSupiConfigPath(
|
|
26
|
+
scope: "global" | "project",
|
|
27
|
+
cwd: string,
|
|
28
|
+
options?: SupiConfigOptions,
|
|
29
|
+
): string {
|
|
30
|
+
return scope === "global" ? getGlobalConfigPath(options?.homeDir) : getProjectConfigPath(cwd);
|
|
31
|
+
}
|
|
32
|
+
|
|
24
33
|
export function readJsonFile(filePath: string): Record<string, unknown> | null {
|
|
25
34
|
let content: string;
|
|
26
35
|
try {
|
|
@@ -95,15 +104,22 @@ export function loadSupiConfigForScope<T>(
|
|
|
95
104
|
defaults: T,
|
|
96
105
|
options: { scope: "global" | "project" } & SupiConfigOptions,
|
|
97
106
|
): T {
|
|
98
|
-
const config =
|
|
99
|
-
options.scope === "global"
|
|
100
|
-
? readJsonFile(getGlobalConfigPath(options.homeDir))
|
|
101
|
-
: readJsonFile(getProjectConfigPath(cwd));
|
|
107
|
+
const config = readJsonFile(getSupiConfigPath(options.scope, cwd, { homeDir: options.homeDir }));
|
|
102
108
|
|
|
103
109
|
const scopedSection = extractSection(config, section);
|
|
104
110
|
return shallowMerge(defaults, scopedSection);
|
|
105
111
|
}
|
|
106
112
|
|
|
113
|
+
/** Load the raw object for one config section and one scope. */
|
|
114
|
+
export function loadSupiConfigSectionForScope(
|
|
115
|
+
section: string,
|
|
116
|
+
cwd: string,
|
|
117
|
+
options: { scope: "global" | "project" } & SupiConfigOptions,
|
|
118
|
+
): Record<string, unknown> | null {
|
|
119
|
+
const config = readJsonFile(getSupiConfigPath(options.scope, cwd, { homeDir: options.homeDir }));
|
|
120
|
+
return extractSection(config, section);
|
|
121
|
+
}
|
|
122
|
+
|
|
107
123
|
export interface SupiConfigLocation {
|
|
108
124
|
section: string;
|
|
109
125
|
scope: "global" | "project";
|
|
@@ -118,8 +134,7 @@ export function writeSupiConfig(
|
|
|
118
134
|
value: Record<string, unknown>,
|
|
119
135
|
options?: SupiConfigOptions,
|
|
120
136
|
): void {
|
|
121
|
-
const configPath =
|
|
122
|
-
loc.scope === "global" ? getGlobalConfigPath(options?.homeDir) : getProjectConfigPath(loc.cwd);
|
|
137
|
+
const configPath = getSupiConfigPath(loc.scope, loc.cwd, options);
|
|
123
138
|
|
|
124
139
|
const dir = path.dirname(configPath);
|
|
125
140
|
fs.mkdirSync(dir, { recursive: true });
|
|
@@ -142,8 +157,7 @@ export function removeSupiConfigKey(
|
|
|
142
157
|
key: string,
|
|
143
158
|
options?: SupiConfigOptions,
|
|
144
159
|
): void {
|
|
145
|
-
const configPath =
|
|
146
|
-
loc.scope === "global" ? getGlobalConfigPath(options?.homeDir) : getProjectConfigPath(loc.cwd);
|
|
160
|
+
const configPath = getSupiConfigPath(loc.scope, loc.cwd, options);
|
|
147
161
|
|
|
148
162
|
const existing = readJsonFile(configPath);
|
|
149
163
|
if (!existing) return;
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
// Configurable tool prompt-surface overrides.
|
|
2
|
+
//
|
|
3
|
+
// Resolution order: package defaults ← global SuPi config ← trusted project SuPi config.
|
|
4
|
+
// Project overrides are trust-gated; they require PI project trust and a PI-recognized
|
|
5
|
+
// trust-requiring resource (e.g. .pi/settings.json).
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
type ExtensionContext,
|
|
9
|
+
hasTrustRequiringProjectResources,
|
|
10
|
+
} from "@earendil-works/pi-coding-agent";
|
|
11
|
+
import type { SuiPiToolPromptSurface } from "../tool-framework.ts";
|
|
12
|
+
import { loadSupiConfigSectionForScope, type SupiConfigOptions } from "./config.ts";
|
|
13
|
+
|
|
14
|
+
// ── Public types ───────────────────────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
export type ToolPromptSurfaceDiagnosticCode =
|
|
17
|
+
| "invalidPromptSurfaceConfig"
|
|
18
|
+
| "invalidPromptSurfaceField"
|
|
19
|
+
| "projectPromptSurfaceIgnored";
|
|
20
|
+
|
|
21
|
+
export interface ToolPromptSurfaceDiagnostic {
|
|
22
|
+
code: ToolPromptSurfaceDiagnosticCode;
|
|
23
|
+
scope: "global" | "project";
|
|
24
|
+
section: string;
|
|
25
|
+
toolName: string;
|
|
26
|
+
message: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ResolveToolPromptSurfaceOptions extends SupiConfigOptions {
|
|
30
|
+
section: string;
|
|
31
|
+
toolName: string;
|
|
32
|
+
defaults: SuiPiToolPromptSurface;
|
|
33
|
+
ctx: Pick<ExtensionContext, "cwd" | "isProjectTrusted">;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ResolveToolPromptSurfaceResult {
|
|
37
|
+
surface: SuiPiToolPromptSurface;
|
|
38
|
+
diagnostics: ToolPromptSurfaceDiagnostic[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ── Private types ──────────────────────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
type PromptSurfaceField = keyof SuiPiToolPromptSurface;
|
|
44
|
+
type PromptSurfaceScope = ToolPromptSurfaceDiagnostic["scope"];
|
|
45
|
+
|
|
46
|
+
const PROMPT_SURFACE_FIELDS = new Set<string>(["description", "promptSnippet", "promptGuidelines"]);
|
|
47
|
+
|
|
48
|
+
const PROMPT_SURFACE_DIAGNOSTICS_KEY = Symbol.for(
|
|
49
|
+
"@mrclrchtr/supi-core/tool-prompt-surface/notified-diagnostics",
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
// ── Resolution ─────────────────────────────────────────────────────────────
|
|
53
|
+
|
|
54
|
+
/** Resolve a tool's model-facing prompt surface from defaults + SuPi config overrides. */
|
|
55
|
+
export function resolveToolPromptSurface(
|
|
56
|
+
options: ResolveToolPromptSurfaceOptions,
|
|
57
|
+
): ResolveToolPromptSurfaceResult {
|
|
58
|
+
const diagnostics: ToolPromptSurfaceDiagnostic[] = [];
|
|
59
|
+
let surface = clonePromptSurface(options.defaults);
|
|
60
|
+
|
|
61
|
+
const globalSection = loadSupiConfigSectionForScope(options.section, options.ctx.cwd, {
|
|
62
|
+
scope: "global",
|
|
63
|
+
homeDir: options.homeDir,
|
|
64
|
+
});
|
|
65
|
+
surface = applyPromptSurfaceScope(surface, options, "global", globalSection, diagnostics);
|
|
66
|
+
|
|
67
|
+
const projectSection = loadSupiConfigSectionForScope(options.section, options.ctx.cwd, {
|
|
68
|
+
scope: "project",
|
|
69
|
+
homeDir: options.homeDir,
|
|
70
|
+
});
|
|
71
|
+
const projectPromptSurface = getPromptSurfaceConfig(projectSection, options.toolName, {
|
|
72
|
+
diagnostics,
|
|
73
|
+
options,
|
|
74
|
+
scope: "project",
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if (projectPromptSurface) {
|
|
78
|
+
const hasTrustMarker = hasTrustRequiringProjectResources(options.ctx.cwd);
|
|
79
|
+
const projectTrusted = options.ctx.isProjectTrusted();
|
|
80
|
+
if (hasTrustMarker && projectTrusted) {
|
|
81
|
+
surface = applyPromptSurfaceConfig(
|
|
82
|
+
surface,
|
|
83
|
+
options.defaults,
|
|
84
|
+
projectPromptSurface,
|
|
85
|
+
options,
|
|
86
|
+
"project",
|
|
87
|
+
diagnostics,
|
|
88
|
+
);
|
|
89
|
+
} else {
|
|
90
|
+
diagnostics.push({
|
|
91
|
+
code: "projectPromptSurfaceIgnored",
|
|
92
|
+
scope: "project",
|
|
93
|
+
section: options.section,
|
|
94
|
+
toolName: options.toolName,
|
|
95
|
+
message: hasTrustMarker
|
|
96
|
+
? `Project prompt-surface overrides for ${options.toolName} were ignored because the project is not trusted in PI.`
|
|
97
|
+
: `Project prompt-surface overrides for ${options.toolName} were ignored because ${options.ctx.cwd}/.pi/supi/config.json is not PI trust-gated. Add .pi/settings.json and trust the project to enable them.`,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return { surface, diagnostics };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Notify prompt-surface diagnostics once per session/tool/diagnostic code. */
|
|
106
|
+
export function notifyToolPromptSurfaceDiagnostics(
|
|
107
|
+
ctx: Pick<ExtensionContext, "sessionManager" | "ui">,
|
|
108
|
+
diagnostics: readonly ToolPromptSurfaceDiagnostic[],
|
|
109
|
+
): void {
|
|
110
|
+
const globalRecord = globalThis as Record<symbol, Set<string> | undefined>;
|
|
111
|
+
const notified = globalRecord[PROMPT_SURFACE_DIAGNOSTICS_KEY] ?? new Set<string>();
|
|
112
|
+
globalRecord[PROMPT_SURFACE_DIAGNOSTICS_KEY] = notified;
|
|
113
|
+
const sessionId = ctx.sessionManager.getSessionId();
|
|
114
|
+
|
|
115
|
+
for (const diagnostic of diagnostics) {
|
|
116
|
+
const key = `${sessionId}:${diagnostic.section}:${diagnostic.toolName}:${diagnostic.code}`;
|
|
117
|
+
if (notified.has(key)) continue;
|
|
118
|
+
notified.add(key);
|
|
119
|
+
ctx.ui.notify(diagnostic.message, "warning");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ── Scope helpers ──────────────────────────────────────────────────────────
|
|
124
|
+
|
|
125
|
+
// biome-ignore lint/complexity/useMaxParams: resolver dispatch with diagnostics
|
|
126
|
+
function applyPromptSurfaceScope(
|
|
127
|
+
current: SuiPiToolPromptSurface,
|
|
128
|
+
options: ResolveToolPromptSurfaceOptions,
|
|
129
|
+
scope: PromptSurfaceScope,
|
|
130
|
+
sectionConfig: Record<string, unknown> | null,
|
|
131
|
+
diagnostics: ToolPromptSurfaceDiagnostic[],
|
|
132
|
+
): SuiPiToolPromptSurface {
|
|
133
|
+
const promptSurface = getPromptSurfaceConfig(sectionConfig, options.toolName, {
|
|
134
|
+
diagnostics,
|
|
135
|
+
options,
|
|
136
|
+
scope,
|
|
137
|
+
});
|
|
138
|
+
if (!promptSurface) return current;
|
|
139
|
+
return applyPromptSurfaceConfig(
|
|
140
|
+
current,
|
|
141
|
+
options.defaults,
|
|
142
|
+
promptSurface,
|
|
143
|
+
options,
|
|
144
|
+
scope,
|
|
145
|
+
diagnostics,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// biome-ignore lint/complexity/useMaxParams: per-scope config merger with diagnostics
|
|
150
|
+
function applyPromptSurfaceConfig(
|
|
151
|
+
current: SuiPiToolPromptSurface,
|
|
152
|
+
defaults: SuiPiToolPromptSurface,
|
|
153
|
+
config: Record<string, unknown>,
|
|
154
|
+
options: ResolveToolPromptSurfaceOptions,
|
|
155
|
+
scope: PromptSurfaceScope,
|
|
156
|
+
diagnostics: ToolPromptSurfaceDiagnostic[],
|
|
157
|
+
): SuiPiToolPromptSurface {
|
|
158
|
+
let next = clonePromptSurface(current);
|
|
159
|
+
|
|
160
|
+
for (const field of getResetFields(config.$reset, options, scope, diagnostics)) {
|
|
161
|
+
next = { ...next, [field]: clonePromptSurfaceField(defaults[field]) };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const description = getOptionalNonEmptyString(
|
|
165
|
+
config.description,
|
|
166
|
+
"description",
|
|
167
|
+
options,
|
|
168
|
+
scope,
|
|
169
|
+
diagnostics,
|
|
170
|
+
);
|
|
171
|
+
if (description !== undefined) next.description = description;
|
|
172
|
+
|
|
173
|
+
const promptSnippet = getOptionalNonEmptyString(
|
|
174
|
+
config.promptSnippet,
|
|
175
|
+
"promptSnippet",
|
|
176
|
+
options,
|
|
177
|
+
scope,
|
|
178
|
+
diagnostics,
|
|
179
|
+
);
|
|
180
|
+
if (promptSnippet !== undefined) next.promptSnippet = promptSnippet;
|
|
181
|
+
|
|
182
|
+
const promptGuidelines = getOptionalStringArray(
|
|
183
|
+
config.promptGuidelines,
|
|
184
|
+
"promptGuidelines",
|
|
185
|
+
options,
|
|
186
|
+
scope,
|
|
187
|
+
diagnostics,
|
|
188
|
+
);
|
|
189
|
+
if (promptGuidelines !== undefined) next.promptGuidelines = promptGuidelines;
|
|
190
|
+
|
|
191
|
+
const prepend = getOptionalStringArray(
|
|
192
|
+
config.prependPromptGuidelines,
|
|
193
|
+
"prependPromptGuidelines",
|
|
194
|
+
options,
|
|
195
|
+
scope,
|
|
196
|
+
diagnostics,
|
|
197
|
+
);
|
|
198
|
+
if (prepend !== undefined) next.promptGuidelines = [...prepend, ...next.promptGuidelines];
|
|
199
|
+
|
|
200
|
+
const append = getOptionalStringArray(
|
|
201
|
+
config.appendPromptGuidelines,
|
|
202
|
+
"appendPromptGuidelines",
|
|
203
|
+
options,
|
|
204
|
+
scope,
|
|
205
|
+
diagnostics,
|
|
206
|
+
);
|
|
207
|
+
if (append !== undefined) next.promptGuidelines = [...next.promptGuidelines, ...append];
|
|
208
|
+
|
|
209
|
+
return next;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ── Config extraction ──────────────────────────────────────────────────────
|
|
213
|
+
|
|
214
|
+
function getPromptSurfaceConfig(
|
|
215
|
+
sectionConfig: Record<string, unknown> | null,
|
|
216
|
+
toolName: string,
|
|
217
|
+
deps: {
|
|
218
|
+
diagnostics: ToolPromptSurfaceDiagnostic[];
|
|
219
|
+
options: ResolveToolPromptSurfaceOptions;
|
|
220
|
+
scope: PromptSurfaceScope;
|
|
221
|
+
},
|
|
222
|
+
): Record<string, unknown> | null {
|
|
223
|
+
if (!sectionConfig) return null;
|
|
224
|
+
if (sectionConfig.tools === undefined) return null;
|
|
225
|
+
if (!isRecord(sectionConfig.tools)) {
|
|
226
|
+
pushInvalidConfig(deps, "tools must be an object.");
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
const toolConfig = sectionConfig.tools[toolName];
|
|
230
|
+
if (toolConfig === undefined) return null;
|
|
231
|
+
if (!isRecord(toolConfig)) {
|
|
232
|
+
pushInvalidConfig(deps, `tools.${toolName} must be an object.`);
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
if (toolConfig.promptSurface === undefined) return null;
|
|
236
|
+
if (!isRecord(toolConfig.promptSurface)) {
|
|
237
|
+
pushInvalidConfig(deps, `tools.${toolName}.promptSurface must be an object.`);
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
return toolConfig.promptSurface;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// ── Field validation ───────────────────────────────────────────────────────
|
|
244
|
+
|
|
245
|
+
function getResetFields(
|
|
246
|
+
value: unknown,
|
|
247
|
+
options: ResolveToolPromptSurfaceOptions,
|
|
248
|
+
scope: PromptSurfaceScope,
|
|
249
|
+
diagnostics: ToolPromptSurfaceDiagnostic[],
|
|
250
|
+
): PromptSurfaceField[] {
|
|
251
|
+
if (value === undefined) return [];
|
|
252
|
+
if (!Array.isArray(value)) {
|
|
253
|
+
pushInvalidField(options, scope, diagnostics, "$reset", "must be an array.");
|
|
254
|
+
return [];
|
|
255
|
+
}
|
|
256
|
+
const fields: PromptSurfaceField[] = [];
|
|
257
|
+
for (const item of value) {
|
|
258
|
+
if (typeof item === "string" && PROMPT_SURFACE_FIELDS.has(item)) {
|
|
259
|
+
fields.push(item as PromptSurfaceField);
|
|
260
|
+
} else {
|
|
261
|
+
pushInvalidField(
|
|
262
|
+
options,
|
|
263
|
+
scope,
|
|
264
|
+
diagnostics,
|
|
265
|
+
"$reset",
|
|
266
|
+
`contains unsupported field ${JSON.stringify(item)}.`,
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return fields;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// biome-ignore lint/complexity/useMaxParams: validation helper with diagnostics
|
|
274
|
+
function getOptionalNonEmptyString(
|
|
275
|
+
value: unknown,
|
|
276
|
+
field: string,
|
|
277
|
+
options: ResolveToolPromptSurfaceOptions,
|
|
278
|
+
scope: PromptSurfaceScope,
|
|
279
|
+
diagnostics: ToolPromptSurfaceDiagnostic[],
|
|
280
|
+
): string | undefined {
|
|
281
|
+
if (value === undefined) return undefined;
|
|
282
|
+
if (typeof value === "string" && value.length > 0) return value;
|
|
283
|
+
pushInvalidField(options, scope, diagnostics, field, "must be a non-empty string.");
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// biome-ignore lint/complexity/useMaxParams: validation helper with diagnostics
|
|
288
|
+
function getOptionalStringArray(
|
|
289
|
+
value: unknown,
|
|
290
|
+
field: string,
|
|
291
|
+
options: ResolveToolPromptSurfaceOptions,
|
|
292
|
+
scope: PromptSurfaceScope,
|
|
293
|
+
diagnostics: ToolPromptSurfaceDiagnostic[],
|
|
294
|
+
): string[] | undefined {
|
|
295
|
+
if (value === undefined) return undefined;
|
|
296
|
+
if (Array.isArray(value) && value.every((item) => typeof item === "string")) {
|
|
297
|
+
return [...value];
|
|
298
|
+
}
|
|
299
|
+
pushInvalidField(options, scope, diagnostics, field, "must be an array of strings.");
|
|
300
|
+
return undefined;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// ── Diagnostics ────────────────────────────────────────────────────────────
|
|
304
|
+
|
|
305
|
+
function pushInvalidConfig(
|
|
306
|
+
deps: {
|
|
307
|
+
diagnostics: ToolPromptSurfaceDiagnostic[];
|
|
308
|
+
options: ResolveToolPromptSurfaceOptions;
|
|
309
|
+
scope: PromptSurfaceScope;
|
|
310
|
+
},
|
|
311
|
+
detail: string,
|
|
312
|
+
): void {
|
|
313
|
+
deps.diagnostics.push({
|
|
314
|
+
// biome-ignore lint/security/noSecrets: false positive on string constant
|
|
315
|
+
code: "invalidPromptSurfaceConfig",
|
|
316
|
+
scope: deps.scope,
|
|
317
|
+
section: deps.options.section,
|
|
318
|
+
toolName: deps.options.toolName,
|
|
319
|
+
message: `Invalid prompt-surface config for ${deps.options.section}.${deps.options.toolName}: ${detail}`,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// biome-ignore lint/complexity/useMaxParams: diagnostics utility with many fields
|
|
324
|
+
function pushInvalidField(
|
|
325
|
+
options: ResolveToolPromptSurfaceOptions,
|
|
326
|
+
scope: PromptSurfaceScope,
|
|
327
|
+
diagnostics: ToolPromptSurfaceDiagnostic[],
|
|
328
|
+
field: string,
|
|
329
|
+
detail: string,
|
|
330
|
+
): void {
|
|
331
|
+
diagnostics.push({
|
|
332
|
+
// biome-ignore lint/security/noSecrets: false positive on string constant
|
|
333
|
+
code: "invalidPromptSurfaceField",
|
|
334
|
+
scope,
|
|
335
|
+
section: options.section,
|
|
336
|
+
toolName: options.toolName,
|
|
337
|
+
message: `Invalid prompt-surface field ${field} for ${options.section}.${options.toolName}: ${detail}`,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// ── Cloning ────────────────────────────────────────────────────────────────
|
|
342
|
+
|
|
343
|
+
function clonePromptSurface(surface: SuiPiToolPromptSurface): SuiPiToolPromptSurface {
|
|
344
|
+
return {
|
|
345
|
+
description: surface.description,
|
|
346
|
+
promptSnippet: surface.promptSnippet,
|
|
347
|
+
promptGuidelines: [...surface.promptGuidelines],
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function clonePromptSurfaceField<T extends string | string[]>(value: T): T {
|
|
352
|
+
return (Array.isArray(value) ? [...value] : value) as T;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
356
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
357
|
+
}
|
package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
// supi-core config domain — config loading
|
|
1
|
+
// supi-core config domain — config loading.
|
|
2
2
|
export type { SupiConfigLocation, SupiConfigOptions } from "./config/config.ts";
|
|
3
3
|
export {
|
|
4
4
|
loadSectionConfig,
|
|
5
5
|
loadSupiConfig,
|
|
6
6
|
loadSupiConfigForScope,
|
|
7
|
+
loadSupiConfigSectionForScope,
|
|
7
8
|
readJsonFile,
|
|
8
9
|
removeSupiConfigKey,
|
|
9
10
|
writeSupiConfig,
|
|
10
11
|
} from "./config/config.ts";
|
|
11
|
-
export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config/config-settings.ts";
|
|
12
|
-
export { registerConfigSettings } from "./config/config-settings.ts";
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
export type DebugLevel = "debug" | "info" | "warning" | "error";
|
|
8
8
|
export type DebugAgentAccess = "off" | "sanitized" | "raw";
|
|
9
|
-
export type DebugNotifyLevel = "off" | "warning" | "error";
|
|
10
|
-
|
|
11
9
|
export interface DebugRegistryConfig {
|
|
12
10
|
/** Whether producers should retain debug events. */
|
|
13
11
|
enabled: boolean;
|
|
@@ -15,15 +13,12 @@ export interface DebugRegistryConfig {
|
|
|
15
13
|
agentAccess: DebugAgentAccess;
|
|
16
14
|
/** Maximum number of session-local events to keep in memory. */
|
|
17
15
|
maxEvents: number;
|
|
18
|
-
/** Minimum level that should notify the user; interpreted by UI extensions. */
|
|
19
|
-
notifyLevel: DebugNotifyLevel;
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
export const DEBUG_REGISTRY_DEFAULTS: DebugRegistryConfig = {
|
|
23
19
|
enabled: false,
|
|
24
20
|
agentAccess: "sanitized",
|
|
25
21
|
maxEvents: 100,
|
|
26
|
-
notifyLevel: "off",
|
|
27
22
|
};
|
|
28
23
|
|
|
29
24
|
export interface DebugEventInput {
|