@mrclrchtr/supi-prompt-suggestions 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.
Files changed (28) hide show
  1. package/README.md +46 -31
  2. package/node_modules/@mrclrchtr/supi-core/README.md +32 -23
  3. package/node_modules/@mrclrchtr/supi-core/package.json +2 -1
  4. package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +22 -8
  5. package/node_modules/@mrclrchtr/supi-core/src/config/prompt-surface.ts +357 -0
  6. package/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -3
  7. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +0 -5
  8. package/node_modules/@mrclrchtr/supi-core/src/prompt-surface.ts +4 -0
  9. package/node_modules/@mrclrchtr/supi-core/src/settings/scoped-settings-list.ts +372 -0
  10. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-action-menu.ts +101 -0
  11. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-command.ts +1 -1
  12. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +55 -27
  13. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +464 -0
  14. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-submenus.ts +124 -0
  15. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +72 -285
  16. package/node_modules/@mrclrchtr/supi-core/src/settings-ui.ts +2 -5
  17. package/node_modules/@mrclrchtr/supi-core/src/settings.ts +27 -5
  18. package/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +10 -0
  19. package/package.json +2 -2
  20. package/src/config/settings.ts +7 -21
  21. package/src/editor/editor.ts +29 -1
  22. package/src/extension.ts +1 -1
  23. package/src/generation/client.ts +9 -6
  24. package/src/generation/generator.ts +74 -24
  25. package/src/generation/model-resolution.ts +13 -2
  26. package/src/generation/normalize.ts +49 -13
  27. package/src/session.ts +52 -15
  28. package/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +0 -188
package/README.md CHANGED
@@ -1,60 +1,75 @@
1
1
  <div align="center">
2
- <h1>@mrclrchtr/supi-prompt-suggestions</h1>
2
+ <a href="https://github.com/mrclrchtr/supi/tree/main/packages/supi-prompt-suggestions">
3
+ <picture>
4
+ <img src="https://raw.githubusercontent.com/mrclrchtr/supi/main/packages/supi-prompt-suggestions/assets/logo.png" alt="SuPi" width="50%">
5
+ </picture>
6
+ </a>
3
7
  </div>
4
8
 
5
9
  # @mrclrchtr/supi-prompt-suggestions
6
10
 
7
11
  Advisory ghost-text prompt suggestions for the [pi coding agent](https://github.com/earendil-works/pi).
8
12
 
13
+ <p align="center">
14
+ <a href="https://raw.githubusercontent.com/mrclrchtr/supi/main/packages/supi-prompt-suggestions/assets/demo.mp4">
15
+ <img src="https://raw.githubusercontent.com/mrclrchtr/supi/main/packages/supi-prompt-suggestions/assets/demo.gif" width="100%" alt="Demo of ghost-text prompt suggestions">
16
+ </a>
17
+ </p>
18
+
9
19
  ## Install
10
20
 
11
21
  ```bash
12
22
  pi install npm:@mrclrchtr/supi-prompt-suggestions
13
23
  ```
14
24
 
15
- For local development:
25
+ ## What it does
16
26
 
17
- ```bash
18
- pi install ./packages/supi-prompt-suggestions
19
- ```
27
+ After each assistant response, the extension can suggest a concise next prompt as dim ghost text in the editor.
28
+
29
+ Suggestions only appear when:
20
30
 
21
- ## What you get
31
+ - you selected a suggestion model in `/supi-settings`
32
+ - the editor is empty
33
+ - the model finds a useful follow-up
22
34
 
23
- After install and configuration, suggested next user prompts appear as dim **ghost text** in the editor after each assistant response.
35
+ ## Using suggestions
24
36
 
25
- - **Right Arrow** accept the suggestion without submitting
26
- - **Escape** or **any keystroke** — dismiss the suggestion
37
+ | Key | Action |
38
+ |-----|--------|
39
+ | `→` / Right Arrow | Accept the suggestion into the editor without submitting it |
40
+ | `Esc` | Dismiss the suggestion |
41
+ | Any text input | Dismiss the suggestion and continue typing |
27
42
 
28
- Suggestions are generated by a cheap, fast model you choose. Only the last assistant text is sent — no transcript, files, or project data.
43
+ Accepted suggestions are inserted into the editor so you can edit them before sending.
29
44
 
30
45
  ## Configuration
31
46
 
32
- Settings live under `/supi-settings` → **Prompt suggestions**:
47
+ Open `/supi-settings` → **Prompt suggestions**.
33
48
 
34
- - **Suggestion model** — `disabled` (default) or a model from PI's scoped `enabledModels`
35
- - Uses SuPi's normal scoped config: set a global default, override per project
49
+ - **Suggestion model** — choose `disabled` or one of PI's scoped enabled models
50
+
51
+ The default is `disabled`. Pick a cheap, fast model if you want lightweight suggestions after assistant turns.
52
+
53
+ Settings follow SuPi's normal scoped config behavior: set a global default, then override it per project when needed.
36
54
 
37
55
  ## Privacy
38
56
 
39
- - Only the last 8,000 characters of the final assistant message are sent
40
- - The system prompt does not mention PI, SuPi, the project, or the conversation
41
- - No tool outputs, file contents, or session metadata are included
57
+ When suggestions are enabled, the suggestion model receives only the last assistant message, trimmed to the final 8,000 characters.
58
+
59
+ The extension does **not** send:
42
60
 
43
- ## Package surfaces
61
+ - the full conversation transcript
62
+ - tool outputs
63
+ - file contents
64
+ - project metadata
65
+ - session metadata
44
66
 
45
- - `@mrclrchtr/supi-prompt-suggestions/extension` — pi extension entrypoint
46
- - `@mrclrchtr/supi-prompt-suggestions/api` — public config type: `PromptSuggestionsConfig`
67
+ ## Troubleshooting
47
68
 
48
- ## Source layout
69
+ If no suggestion appears:
49
70
 
50
- - `src/extension.ts` pi extension entrypoint: registers settings, wires events to `SessionLifecycle`
51
- - `src/session.ts` `SessionLifecycle` class: owns ghost editor, status spinner, and generation orchestration
52
- - `src/api.ts` package API surface (`./api` export)
53
- - `src/index.ts` package root re-export
54
- - `src/config/config.ts` config types and defaults
55
- - `src/config/settings.ts` — settings registration + model picker submenu
56
- - `src/editor/editor.ts` — ghost-text editor wrapper component
57
- - `src/generation/generator.ts` — `SuggestionGenerator` class: async orchestration with concurrency control
58
- - `src/generation/client.ts` — low-level model API client (pure functions)
59
- - `src/generation/model-resolution.ts` — model + API key resolution from scoped config
60
- - `src/generation/normalize.ts` — suggestion text normalization
71
+ - confirm **Suggestion model** is not `disabled`
72
+ - confirm the selected model is still enabled in PI for the current scope
73
+ - confirm the selected model has an API key configured
74
+ - make sure the editor is empty after the assistant finishes
75
+ - wait for the suggestion spinner to finish; generation times out after about 20 seconds
@@ -39,15 +39,17 @@ Config file locations:
39
39
 
40
40
  ### Settings helpers
41
41
 
42
- - `registerSettings()` — register an arbitrary settings section
43
- - `registerConfigSettings()` — register a config-backed settings section with scoped persistence helpers
44
- - `registerSettingsCommand()` — register `/supi-settings`
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 { loadSupiConfig, registerConfigSettings, wrapExtensionContext } from "@mrclrchtr/supi-core/api";
87
-
88
- const config = loadSupiConfig("my-extension", process.cwd(), {
89
- enabled: true,
90
- });
91
-
92
- registerConfigSettings({
93
- id: "my-extension",
94
- label: "My Extension",
95
- section: "my-extension",
96
- defaults: { enabled: true },
97
- buildItems: () => [],
98
- persistChange: () => {},
99
- });
100
-
101
- const message = wrapExtensionContext("my-extension", "hello", {
102
- file: "CLAUDE.md",
103
- turn: 1,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "2.0.6",
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
+ }
@@ -1,12 +1,11 @@
1
- // supi-core config domain — config loading and config-settings helpers.
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 {
@@ -0,0 +1,4 @@
1
+ // supi-core prompt-surface — configurable tool prompt-surface resolver (package boundary for @mrclrchtr/supi-core/prompt-surface).
2
+
3
+ // biome-ignore lint/performance/noReExportAll: intentional barrel
4
+ export * from "./config/prompt-surface.ts";