@mrclrchtr/supi-code-intelligence 7.4.0 → 8.0.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.
Files changed (74) hide show
  1. package/README.md +6 -6
  2. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  3. package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +22 -4
  5. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  6. package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
  7. package/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
  8. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
  9. package/node_modules/@mrclrchtr/supi-lsp/README.md +29 -6
  10. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  11. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -1
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +22 -4
  13. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  14. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
  17. package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  18. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +25 -3
  19. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +2 -1
  20. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +5 -2
  21. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +39 -6
  22. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +82 -12
  23. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-semantic-input-barrier.ts +28 -5
  24. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +606 -30
  25. package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +9 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +69 -8
  27. package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +196 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +15 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/src/config/types.ts +9 -1
  30. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +2 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +31 -2
  32. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +72 -2
  33. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +9 -43
  34. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +102 -50
  35. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +49 -3
  36. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +78 -18
  37. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +46 -2
  38. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +14 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/src/workspace-path-policy.ts +30 -4
  40. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  41. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -1
  42. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +22 -4
  43. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  44. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
  45. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
  46. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
  47. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  48. package/package.json +5 -5
  49. package/src/analysis/capability/capability-warnings.ts +64 -25
  50. package/src/analysis/health/server-status.ts +23 -1
  51. package/src/analysis/health/signals.ts +1 -0
  52. package/src/analysis/search/ast-scan.ts +42 -8
  53. package/src/analysis/search/pattern.ts +4 -0
  54. package/src/config.ts +64 -34
  55. package/src/extension.ts +29 -10
  56. package/src/headless.ts +1 -0
  57. package/src/session/find-types.ts +2 -1
  58. package/src/session/find-workflow.ts +5 -0
  59. package/src/session/health-types.ts +3 -0
  60. package/src/session/health-workflow.ts +10 -1
  61. package/src/session/session.ts +34 -2
  62. package/src/substrate/lsp/lifecycle.ts +2 -0
  63. package/src/substrate/lsp/recovery.ts +3 -3
  64. package/src/substrate/lsp/settings.ts +191 -108
  65. package/src/substrate/workspace-provider-host.ts +50 -12
  66. package/src/tool/code_find/markdown.ts +12 -0
  67. package/src/tool/code_find/render.ts +20 -0
  68. package/src/tool/code_find/result.ts +3 -0
  69. package/src/tool/code_health/markdown.ts +3 -0
  70. package/src/tool/code_health/result.ts +3 -1
  71. package/src/tool/result/types.ts +3 -1
  72. package/src/ui/status-command.ts +54 -6
  73. package/src/ui/status-overlay.ts +5 -0
  74. package/node_modules/@mrclrchtr/supi-lsp/src/config/lsp-settings.ts +0 -22
@@ -4,69 +4,113 @@
4
4
  // supported opt-out.
5
5
  //
6
6
  // Registered fields:
7
- // - exclude: stringList
8
- // - disabled_servers: custom submenu whose module action writes per-language disable config
7
+ // - disabled_servers: custom submenu whose module action writes per-language enablement config
9
8
 
10
9
  import { type ExtensionAPI, getSettingsListTheme } from "@earendil-works/pi-coding-agent";
11
10
  import type { Component, SettingItem } from "@earendil-works/pi-tui";
12
11
  import { Container, Key, matchesKey, SettingsList, Text } from "@earendil-works/pi-tui";
13
12
 
14
- import { loadSupiConfigSectionForScope, writeSupiConfig } from "@mrclrchtr/supi-core/config";
13
+ import {
14
+ loadSupiConfigSectionForScope,
15
+ replaceSupiConfigSection,
16
+ } from "@mrclrchtr/supi-core/config";
15
17
  import {
16
18
  defineConfigSettings,
17
19
  registerSettings,
18
20
  type SettingsScope,
19
- type ValueSource,
20
21
  } from "@mrclrchtr/supi-core/settings";
21
- import { type LspSettings, loadConfig } from "@mrclrchtr/supi-lsp/api";
22
+ import { loadConfig } from "@mrclrchtr/supi-lsp/api";
23
+
24
+ const LSP_DEFAULTS = {};
22
25
 
23
- const LSP_DEFAULTS = {
24
- exclude: [] as string[],
25
- } satisfies LspSettings;
26
+ function isRecord(value: unknown): value is Record<string, unknown> {
27
+ return typeof value === "object" && value !== null && !Array.isArray(value);
28
+ }
26
29
 
27
- /** Discover configured servers from the defaults + effective LSP config. */
28
- function getConfiguredServers(cwd: string): string[] {
30
+ /** Discover servers that may shape the selected settings scope. */
31
+ function getConfiguredServers(
32
+ scope: SettingsScope,
33
+ cwd: string,
34
+ homeDir?: string,
35
+ projectTrusted = true,
36
+ ): string[] {
37
+ const names = new Set<string>();
38
+ const includeProject = scope === "project" && projectTrusted;
29
39
  try {
30
- const config = loadConfig(cwd);
31
- return Object.keys(config.servers);
40
+ for (const name of Object.keys(
41
+ loadConfig(cwd, { homeDir, projectTrusted: includeProject }).servers,
42
+ )) {
43
+ names.add(name);
44
+ }
32
45
  } catch {
33
- return ["typescript"];
46
+ // Raw scope reads below still expose names that need a settings action.
34
47
  }
48
+ const scopes = includeProject ? (["global", "project"] as const) : (["global"] as const);
49
+ for (const configScope of scopes) {
50
+ const section = loadSupiConfigSectionForScope("lsp", cwd, {
51
+ scope: configScope,
52
+ homeDir,
53
+ });
54
+ const servers = section?.servers;
55
+ if (!servers || typeof servers !== "object" || Array.isArray(servers)) continue;
56
+ for (const name of Object.keys(servers)) names.add(name);
57
+ }
58
+ return names.size > 0 ? [...names] : ["typescript"];
35
59
  }
36
60
 
37
- /**
38
- * Load the raw LSP section for a single scope to inspect the currently
39
- * configured disabled servers from the persisted config.
40
- */
41
- function getDisabledServersFromConfig(scope: SettingsScope, cwd: string): Set<string> {
42
- const section = loadSupiConfigSectionForScope("lsp", cwd, {
43
- scope,
44
- });
45
- if (!section) return new Set();
46
- const servers = section.servers as Record<string, { enabled?: boolean }> | undefined;
47
- const disabled = new Set<string>();
48
- if (servers) {
49
- for (const [name, srv] of Object.entries(servers)) {
50
- if (srv.enabled === false) disabled.add(name);
61
+ /** Load explicit per-server enabled values from one persisted scope. */
62
+ function getServerEnablement(
63
+ scope: SettingsScope,
64
+ cwd: string,
65
+ homeDir?: string,
66
+ projectTrusted = true,
67
+ ): Map<string, boolean> {
68
+ if (scope === "project" && !projectTrusted) return new Map();
69
+ const section = loadSupiConfigSectionForScope("lsp", cwd, { scope, homeDir });
70
+ const servers = section?.servers as Record<string, { enabled?: unknown }> | undefined;
71
+ const enabled = new Map<string, boolean>();
72
+ if (!servers || typeof servers !== "object" || Array.isArray(servers)) return enabled;
73
+ for (const [name, server] of Object.entries(servers)) {
74
+ if (
75
+ server &&
76
+ typeof server === "object" &&
77
+ !Array.isArray(server) &&
78
+ typeof server.enabled === "boolean"
79
+ ) {
80
+ enabled.set(name, server.enabled);
51
81
  }
52
82
  }
53
- return disabled;
83
+ return enabled;
54
84
  }
55
85
 
56
- function createDisabledServersSubmenu(
57
- scope: SettingsScope,
58
- cwd: string,
59
- done: (selectedValue?: string) => void,
60
- ): Component {
61
- const allServers = getConfiguredServers(cwd);
62
- const disabledServers = getDisabledServersFromConfig(scope, cwd);
63
-
64
- const items: SettingItem[] = allServers.map((name) => ({
65
- id: name,
66
- label: name,
67
- currentValue: disabledServers.has(name) ? "disabled" : "enabled",
68
- values: ["enabled", "disabled"],
69
- }));
86
+ interface DisabledServersSubmenuOptions {
87
+ scope: SettingsScope;
88
+ cwd: string;
89
+ done: (selectedValue?: string) => void;
90
+ homeDir?: string;
91
+ projectTrusted: boolean;
92
+ }
93
+
94
+ function createDisabledServersSubmenu(options: DisabledServersSubmenuOptions): Component {
95
+ const { scope, cwd, done, homeDir, projectTrusted } = options;
96
+ const allServers = getConfiguredServers(scope, cwd, homeDir, projectTrusted);
97
+ const scopedEnablement = getServerEnablement(scope, cwd, homeDir, projectTrusted);
98
+ const inheritedEnablement =
99
+ scope === "project"
100
+ ? getServerEnablement("global", cwd, homeDir, projectTrusted)
101
+ : new Map<string, boolean>();
102
+
103
+ const items: SettingItem[] = allServers.map((name) => {
104
+ const direct = scopedEnablement.get(name);
105
+ const effective = direct ?? inheritedEnablement.get(name) ?? true;
106
+ return {
107
+ id: name,
108
+ label:
109
+ direct === undefined ? `${name} (inherit: ${effective ? "enabled" : "disabled"})` : name,
110
+ currentValue: direct === undefined ? "inherit" : direct ? "enabled" : "disabled",
111
+ values: ["inherit", "enabled", "disabled"],
112
+ };
113
+ });
70
114
 
71
115
  let dirty = false;
72
116
  const container = new Container();
@@ -98,10 +142,8 @@ function createDisabledServersSubmenu(
98
142
  done();
99
143
  return;
100
144
  }
101
- const disabled = items
102
- .filter((item) => item.currentValue === "disabled")
103
- .map((item) => item.id);
104
- done(JSON.stringify(disabled));
145
+ const values = Object.fromEntries(items.map((item) => [item.id, item.currentValue]));
146
+ done(JSON.stringify(values));
105
147
  return;
106
148
  }
107
149
  settingsList.handleInput?.(data);
@@ -109,35 +151,69 @@ function createDisabledServersSubmenu(
109
151
  };
110
152
  }
111
153
 
112
- /** Persist the complete disabled-server choice through the settings module action path. */
113
- function persistDisabledServers(
114
- scope: SettingsScope,
115
- cwd: string,
116
- value: string | undefined,
117
- ): void {
118
- const selected = value ? JSON.parse(value) : [];
119
- if (!Array.isArray(selected) || !selected.every((item) => typeof item === "string")) {
120
- throw new Error("Invalid disabled-server selection");
154
+ /** Persist complete per-language enablement choices through the settings module action path. */
155
+ type ServerEnablementChoice = "inherit" | "enabled" | "disabled";
156
+
157
+ function parseServerEnablement(value: string | undefined): Record<string, ServerEnablementChoice> {
158
+ const selected: unknown = value ? JSON.parse(value) : {};
159
+ if (
160
+ !isRecord(selected) ||
161
+ !Object.values(selected).every(
162
+ (choice) => choice === "inherit" || choice === "enabled" || choice === "disabled",
163
+ )
164
+ ) {
165
+ throw new Error("Invalid language-server enablement selection");
121
166
  }
122
- const disabled = new Set<string>(selected);
123
- const currentSection = loadSupiConfigSectionForScope("lsp", cwd, { scope });
124
- const servers =
125
- (currentSection?.servers as Record<string, Record<string, unknown>> | undefined) ?? {};
126
- const names = new Set([...Object.keys(servers), ...getConfiguredServers(cwd)]);
127
- for (const name of names) {
128
- if (disabled.has(name)) {
129
- servers[name] = { ...(servers[name] ?? {}), enabled: false };
130
- continue;
131
- }
132
- const server = servers[name];
133
- if (!server) continue;
167
+ return selected as Record<string, ServerEnablementChoice>;
168
+ }
169
+
170
+ function applyServerEnablementChoice(
171
+ servers: Record<string, unknown>,
172
+ name: string,
173
+ choice: ServerEnablementChoice,
174
+ ): void {
175
+ const rawServer = servers[name];
176
+ const server = isRecord(rawServer) ? { ...rawServer } : undefined;
177
+ if (choice === "inherit") {
178
+ if (!server) return;
134
179
  delete server.enabled;
135
180
  if (Object.keys(server).length === 0) delete servers[name];
181
+ else servers[name] = server;
182
+ return;
136
183
  }
137
- writeSupiConfig({ section: "lsp", scope, cwd }, { servers });
184
+ servers[name] = { ...(server ?? {}), enabled: choice === "enabled" };
138
185
  }
139
186
 
140
- export function registerLspSettings(pi: ExtensionAPI): void {
187
+ interface PersistServerEnablementOptions {
188
+ scope: SettingsScope;
189
+ cwd: string;
190
+ value?: string;
191
+ homeDir?: string;
192
+ projectTrusted: boolean;
193
+ }
194
+
195
+ /** Persist complete per-language enablement choices through the settings module action path. */
196
+ function persistServerEnablement(options: PersistServerEnablementOptions): void {
197
+ const { scope, cwd, value, homeDir, projectTrusted } = options;
198
+ const choices = parseServerEnablement(value);
199
+ const currentSection = loadSupiConfigSectionForScope("lsp", cwd, { scope, homeDir });
200
+ const rawServers = currentSection?.servers;
201
+ const servers: Record<string, unknown> = isRecord(rawServers) ? { ...rawServers } : {};
202
+ const visibleNames = new Set(getConfiguredServers(scope, cwd, homeDir, projectTrusted));
203
+ const names = new Set([
204
+ ...Object.keys(choices),
205
+ ...Object.keys(servers).filter((name) => visibleNames.has(name)),
206
+ ]);
207
+ for (const name of names) applyServerEnablementChoice(servers, name, choices[name] ?? "inherit");
208
+
209
+ const nextSection = { ...(currentSection ?? {}) };
210
+ if (Object.keys(servers).length > 0) nextSection.servers = servers;
211
+ else delete nextSection.servers;
212
+ replaceSupiConfigSection({ section: "lsp", scope, cwd }, nextSection, { homeDir });
213
+ }
214
+
215
+ /** Register per-language LSP enablement controls with the shared settings registry. */
216
+ export function registerLspSettings(pi: ExtensionAPI, homeDir?: string): void {
141
217
  registerSettings(
142
218
  pi,
143
219
  defineConfigSettings({
@@ -146,53 +222,60 @@ export function registerLspSettings(pi: ExtensionAPI): void {
146
222
  section: "lsp",
147
223
  defaults: LSP_DEFAULTS,
148
224
  fields: [
149
- {
150
- kind: "stringList" as const,
151
- key: "exclude",
152
- label: "Exclude Patterns",
153
- description:
154
- "Comma-separated gitignore patterns for automatic LSP workspace work. Exact file requests stay available.",
155
- },
156
225
  {
157
226
  kind: "custom" as const,
158
227
  key: "disabled_servers",
159
228
  label: "Disabled Servers",
160
229
  description: "Press Enter to choose which language servers to disable",
161
- resolve: (scope, cwd) => {
162
- const scopedDisabled = getDisabledServersFromConfig(scope, cwd);
163
- const otherScope = scope === "project" ? "global" : "project";
164
- const otherDisabled =
165
- scope === "project" ? getDisabledServersFromConfig("global", cwd) : new Set<string>();
166
-
167
- // Effective disabled servers = union of both scopes (since either disables)
168
- const effectiveDisabled = new Set([...scopedDisabled, ...otherDisabled]);
230
+ resolve: (scope, cwd, ctx) => {
231
+ const projectTrusted = ctx?.isProjectTrusted() ?? true;
232
+ const scopedEnablement = getServerEnablement(scope, cwd, homeDir, projectTrusted);
233
+ const globalEnablement = getServerEnablement("global", cwd, homeDir, projectTrusted);
234
+ const names = new Set([
235
+ ...getConfiguredServers(scope, cwd, homeDir, projectTrusted),
236
+ ...scopedEnablement.keys(),
237
+ ...globalEnablement.keys(),
238
+ ]);
239
+ const effectiveDisabled = [...names]
240
+ .filter(
241
+ (name) =>
242
+ (scopedEnablement.get(name) ?? globalEnablement.get(name) ?? true) === false,
243
+ )
244
+ .sort((a, b) => a.localeCompare(b));
169
245
  const label =
170
- effectiveDisabled.size > 0
171
- ? [...effectiveDisabled].sort().join(", ")
172
- : "none disabled";
173
-
174
- // Source: where the override comes from
175
- let source: ValueSource;
176
- if (scopedDisabled.size > 0) {
177
- source = scope;
178
- } else if (otherDisabled.size > 0) {
179
- source = otherScope as ValueSource;
180
- } else {
181
- source = "default";
182
- }
183
-
184
- let inheritanceSource: "global" | "default" | undefined;
185
- if (scope === "project" && source === "project") {
186
- inheritanceSource =
187
- getDisabledServersFromConfig("global", cwd).size > 0 ? "global" : "default";
188
- }
189
-
246
+ effectiveDisabled.length > 0 ? effectiveDisabled.join(", ") : "none disabled";
247
+ const source =
248
+ scopedEnablement.size > 0
249
+ ? scope
250
+ : scope === "project" && globalEnablement.size > 0
251
+ ? "global"
252
+ : "default";
253
+ const inheritanceSource =
254
+ scope === "project" && scopedEnablement.size > 0
255
+ ? globalEnablement.size > 0
256
+ ? "global"
257
+ : "default"
258
+ : undefined;
190
259
  return { displayValue: label, source, inheritanceSource };
191
260
  },
192
- submenu: (_currentValue, done, scope, cwd) =>
193
- createDisabledServersSubmenu(scope, cwd, done),
194
- persist: (scope, cwd, action) =>
195
- persistDisabledServers(scope, cwd, action.kind === "set" ? action.value : undefined),
261
+ // biome-ignore lint/complexity/useMaxParams: custom settings callbacks receive the shared scope and ExtensionContext arguments.
262
+ submenu: (_currentValue, done, scope, cwd, ctx) =>
263
+ createDisabledServersSubmenu({
264
+ scope,
265
+ cwd,
266
+ done,
267
+ homeDir,
268
+ projectTrusted: ctx?.isProjectTrusted() ?? true,
269
+ }),
270
+ // biome-ignore lint/complexity/useMaxParams: custom settings callbacks receive the shared scope and ExtensionContext arguments.
271
+ persist: (scope, cwd, action, _helpers, ctx) =>
272
+ persistServerEnablement({
273
+ scope,
274
+ cwd,
275
+ value: action.kind === "set" ? action.value : undefined,
276
+ homeDir,
277
+ projectTrusted: ctx?.isProjectTrusted() ?? true,
278
+ }),
196
279
  },
197
280
  ],
198
281
  }),
@@ -1,7 +1,12 @@
1
1
  import { realpathSync } from "node:fs";
2
+ import { homedir } from "node:os";
2
3
  import { resolve } from "node:path";
3
4
  import { getDefaultWorkspaceRuntime } from "@mrclrchtr/supi-code-runtime/api";
4
- import { LspRuntimeController } from "@mrclrchtr/supi-lsp/api";
5
+ import {
6
+ type AutomaticLspPathPolicy,
7
+ createDefaultAutomaticLspPathPolicy,
8
+ LspRuntimeController,
9
+ } from "@mrclrchtr/supi-lsp/api";
5
10
  import { TreeSitterRuntimeController } from "@mrclrchtr/supi-tree-sitter/api";
6
11
 
7
12
  const HOSTS = Symbol.for("supi-code-intelligence/workspace-provider-hosts");
@@ -15,6 +20,8 @@ type ClosingHostRegistry = Map<string, Promise<void>>;
15
20
  export interface WorkspaceProviderHostLease {
16
21
  cwd: string;
17
22
  lspController: LspRuntimeController | null;
23
+ /** Immutable automatic exclusion policy captured for this lease. */
24
+ automaticPathPolicy: AutomaticLspPathPolicy;
18
25
  sentinelSnapshot: Map<string, number>;
19
26
  release(): Promise<void>;
20
27
  }
@@ -31,11 +38,11 @@ function closingRegistry(): ClosingHostRegistry {
31
38
  return global[CLOSING_HOSTS];
32
39
  }
33
40
 
34
- function canonicalWorkspace(cwd: string): string {
41
+ function canonicalPath(candidate: string): string {
35
42
  try {
36
- return realpathSync(cwd);
43
+ return realpathSync(candidate);
37
44
  } catch {
38
- return resolve(cwd);
45
+ return resolve(candidate);
39
46
  }
40
47
  }
41
48
 
@@ -58,23 +65,41 @@ class WorkspaceProviderHost {
58
65
  #lspStarted = false;
59
66
  #settledStart = Promise.resolve();
60
67
  #closed = false;
68
+ #automaticPathPolicies = new Map<boolean, AutomaticLspPathPolicy>();
69
+ /** One configuration home owns all providers and policies until shutdown. */
70
+ #homeDir: string | null = null;
61
71
 
62
72
  constructor(cwd: string) {
63
73
  this.cwd = cwd;
64
74
  }
65
75
 
66
- async acquire(projectTrusted: boolean): Promise<WorkspaceProviderHostLease> {
76
+ async acquire(projectTrusted: boolean, homeDir?: string): Promise<WorkspaceProviderHostLease> {
67
77
  if (this.#closed) throw new Error("Workspace provider host is closed.");
78
+ const normalizedHome = canonicalPath(homeDir ?? homedir());
79
+ if (this.#homeDir !== null && this.#homeDir !== normalizedHome) {
80
+ throw new Error(
81
+ `Workspace ${this.cwd} already uses configuration home ${this.#homeDir}. Cannot use ${normalizedHome} until all existing provider leases are released.`,
82
+ );
83
+ }
84
+ const automaticPathPolicy =
85
+ this.#automaticPathPolicies.get(projectTrusted) ??
86
+ createDefaultAutomaticLspPathPolicy(this.cwd, {
87
+ projectTrusted,
88
+ homeDir: normalizedHome,
89
+ });
90
+ this.#homeDir = normalizedHome;
91
+ this.#automaticPathPolicies.set(projectTrusted, automaticPathPolicy);
68
92
  // Count this pending acquirer before awaiting startup so the final active lease cannot shut it down.
69
93
  this.#leases++;
70
94
  this.#settledStart = this.#settledStart
71
- .then(() => this.#startMissing(projectTrusted))
95
+ .then(() => this.#startMissing(projectTrusted, automaticPathPolicy, normalizedHome))
72
96
  .catch(() => undefined);
73
97
  await this.#settledStart;
74
98
  let released = false;
75
99
  return {
76
100
  cwd: this.cwd,
77
101
  lspController: projectTrusted ? this.#lsp : null,
102
+ automaticPathPolicy,
78
103
  sentinelSnapshot:
79
104
  projectTrusted && this.#lsp?.kind === "ready"
80
105
  ? (this.#lsp.workspaceRuntime?.scanWorkspaceSentinels() ?? new Map())
@@ -99,7 +124,11 @@ class WorkspaceProviderHost {
99
124
  };
100
125
  }
101
126
 
102
- async #startMissing(projectTrusted: boolean): Promise<void> {
127
+ async #startMissing(
128
+ projectTrusted: boolean,
129
+ automaticPathPolicy: AutomaticLspPathPolicy,
130
+ homeDir?: string,
131
+ ): Promise<void> {
103
132
  const runtime = getDefaultWorkspaceRuntime();
104
133
  if (!this.#treeStarted) {
105
134
  this.#treeStarted = true;
@@ -108,7 +137,11 @@ class WorkspaceProviderHost {
108
137
  }
109
138
  if (!projectTrusted || this.#lspStarted) return;
110
139
  this.#lspStarted = true;
111
- this.#lsp = new LspRuntimeController(this.cwd, runtime);
140
+ this.#lsp = new LspRuntimeController(this.cwd, runtime, {
141
+ automaticPathPolicy,
142
+ projectTrusted,
143
+ homeDir,
144
+ });
112
145
  await this.#lsp.start().catch(() => undefined);
113
146
  }
114
147
 
@@ -121,15 +154,20 @@ class WorkspaceProviderHost {
121
154
  ]);
122
155
  this.#lsp = null;
123
156
  this.#tree = null;
157
+ this.#automaticPathPolicies.clear();
124
158
  }
125
159
  }
126
160
 
127
- /** Acquire shared semantic and structural providers for one canonical workspace. */
161
+ /**
162
+ * Acquire shared providers for one canonical workspace and configuration home.
163
+ * A different home is rejected until all existing leases are released.
164
+ * An omitted home uses the operating system's default home directory.
165
+ */
128
166
  export async function acquireWorkspaceProviderHost(
129
167
  cwd: string,
130
- options: { projectTrusted: boolean },
168
+ options: { projectTrusted: boolean; homeDir?: string },
131
169
  ): Promise<WorkspaceProviderHostLease> {
132
- const workspace = canonicalWorkspace(cwd);
170
+ const workspace = canonicalPath(cwd);
133
171
  for (;;) {
134
172
  const closing = closingRegistry().get(workspace);
135
173
  if (!closing) break;
@@ -141,7 +179,7 @@ export async function acquireWorkspaceProviderHost(
141
179
  host = new WorkspaceProviderHost(workspace);
142
180
  hosts.set(workspace, host);
143
181
  }
144
- return host.acquire(options.projectTrusted);
182
+ return host.acquire(options.projectTrusted, options.homeDir);
145
183
  }
146
184
 
147
185
  /** Clear process-shared hosts between isolated tests. */
@@ -54,6 +54,18 @@ function renderScanLimitations(limitations: readonly StructuredScanLimitation[])
54
54
  }
55
55
 
56
56
  function appendScanAndFailures(lines: string[], result: StructuredPatternResult): void {
57
+ const configuredExclusion = result.scan.exclusions.find(
58
+ (exclusion) => exclusion.reason === "configured-exclusion",
59
+ );
60
+ if (configuredExclusion) {
61
+ const examples = configuredExclusion.examples.length
62
+ ? ` Examples: ${configuredExclusion.examples.map((file) => `\`${file}\``).join(", ")}.`
63
+ : "";
64
+ lines.push(
65
+ "",
66
+ `_AST Scan excluded ${configuredExclusion.pathCount} configured path${configuredExclusion.pathCount === 1 ? "" : "s"} by \`code-intelligence.exclude\`. Explicit scopes remain available.${examples}`,
67
+ );
68
+ }
57
69
  const operationExclusion = result.scan.exclusions.find(
58
70
  (exclusion) => exclusion.reason === "unsupported-operation",
59
71
  );
@@ -51,11 +51,27 @@ function renderSemantic(assembly: FindResultAssembly, evidence: EvidenceListMeta
51
51
  }
52
52
  const disclosure = renderEvidenceListMetadataDisclosure(evidence);
53
53
  if (disclosure) lines.push(disclosure);
54
+ const exclusionDisclosure = renderAutomaticPathExclusionDisclosure(
55
+ outcome.data.partialMetadata?.automaticPathExclusion,
56
+ );
57
+ if (exclusionDisclosure) lines.push(exclusionDisclosure);
54
58
  return lines.join("\n");
55
59
  }
56
60
 
61
+ function renderAutomaticPathExclusionDisclosure(
62
+ exclusion: { readonly excludedCount: number; readonly examples: readonly string[] } | undefined,
63
+ ): string | null {
64
+ if (!exclusion || exclusion.excludedCount <= 0) return null;
65
+ const noun = `workspace-symbol result${exclusion.excludedCount === 1 ? "" : "s"}`;
66
+ const examples = exclusion.examples.length
67
+ ? ` Examples: ${exclusion.examples.map((file) => `\`${file}\``).join(", ")}.`
68
+ : "";
69
+ return `_Automatic path policy excluded ${exclusion.excludedCount} ${noun}.${examples}_`;
70
+ }
71
+
57
72
  function renderEmptySemantic(assembly: FindResultAssembly, evidence: EvidenceListMetadata): string {
58
73
  const { outcome } = assembly;
74
+ if (outcome.data.kind !== "semantic") return "";
59
75
  const lines = [
60
76
  `**Semantic search** — \`${outcome.query}\``,
61
77
  "",
@@ -65,6 +81,10 @@ function renderEmptySemantic(assembly: FindResultAssembly, evidence: EvidenceLis
65
81
  ];
66
82
  const disclosure = renderEvidenceListMetadataDisclosure(evidence);
67
83
  if (disclosure) lines.push("", disclosure);
84
+ const exclusionDisclosure = renderAutomaticPathExclusionDisclosure(
85
+ outcome.data.partialMetadata?.automaticPathExclusion,
86
+ );
87
+ if (exclusionDisclosure) lines.push("", exclusionDisclosure);
68
88
  lines.push("", "Document-level semantic symbols can differ from the workspace index.");
69
89
  const fileQuery = assembly.assembled.actions.find(
70
90
  (action) => action.kind === "query" && action.instruction.startsWith("If you know the file"),
@@ -73,6 +73,9 @@ export function assembleFindWorkflowResult(
73
73
  evidenceLists: [...assembled.evidenceLists],
74
74
  nextQueries: assembledNextQueries(assembled),
75
75
  ...(outcome.data.kind === "ast" ? { scan: outcome.data.result.scan } : {}),
76
+ ...(outcome.data.kind === "semantic" && outcome.data.partialMetadata?.automaticPathExclusion
77
+ ? { automaticPathExclusion: outcome.data.partialMetadata.automaticPathExclusion }
78
+ : {}),
76
79
  },
77
80
  };
78
81
  }
@@ -1,6 +1,7 @@
1
1
  /** Markdown renderer for code_health results. */
2
2
  import type { CapabilityWarningReport } from "../../analysis/capability/capability-warnings.ts";
3
3
  import {
4
+ formatProjectServerOperationSupport,
4
5
  formatProjectServerRoot,
5
6
  formatProjectServerRouteSummary,
6
7
  formatProjectServerStatusReason,
@@ -381,6 +382,8 @@ function renderServersSection(
381
382
  lines.push(
382
383
  `- ${statusIcon} **${server.name}** @ \`${formatProjectServerRoot(cwd, server.root)}\` (${server.fileTypes.join(", ")}) — ${server.status}${reason}`,
383
384
  );
385
+ const operationSupport = formatProjectServerOperationSupport(server.operationSupport);
386
+ if (operationSupport) lines.push(` - ${operationSupport}`);
384
387
  }
385
388
  }
386
389
  lines.push("");
@@ -1,6 +1,7 @@
1
1
  import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
2
2
  import {
3
3
  countProjectServerRouteStatuses,
4
+ formatProjectServerOperationSupport,
4
5
  formatProjectServerRoot,
5
6
  formatProjectServerStatusReason,
6
7
  } from "../../analysis/health/server-status.ts";
@@ -116,7 +117,8 @@ function buildHealthDisplaySections(data: HealthData, cwd?: string): ToolDisplay
116
117
  totalCount: data.servers.length,
117
118
  format: (server) => {
118
119
  const root = cwd ? formatProjectServerRoot(cwd, server.root) : server.root;
119
- return `${server.name} @ ${root} (${server.fileTypes.join(", ")}) — ${server.status}${server.statusReason ? ` — ${formatProjectServerStatusReason(server.statusReason)}` : ""}`;
120
+ const support = formatProjectServerOperationSupport(server.operationSupport);
121
+ return `${server.name} @ ${root} (${server.fileTypes.join(", ")}) — ${server.status}${server.statusReason ? ` — ${formatProjectServerStatusReason(server.statusReason)}` : ""}${support ? ` — ${support}` : ""}`;
120
122
  },
121
123
  }),
122
124
  );
@@ -1,4 +1,4 @@
1
- import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
1
+ import type { CodeQueryPartialMetadata, ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
2
2
  import type { CapabilityWarningReport } from "../../analysis/capability/capability-warnings.ts";
3
3
  import type { EvidenceListMetadata } from "../../analysis/evidence.ts";
4
4
  import type { InstructionFilesMetadata } from "../../analysis/instruction-files.ts";
@@ -90,6 +90,8 @@ export interface SearchDetails {
90
90
  changedFiles?: readonly string[];
91
91
  /** Present for AST mode; declares the operation-specific source-file universe and completeness. */
92
92
  scan?: StructuredScanSummary;
93
+ /** Structured disclosure for semantic results removed by the automatic path policy. */
94
+ automaticPathExclusion?: CodeQueryPartialMetadata["automaticPathExclusion"];
93
95
  }
94
96
 
95
97
  // Canonical disambiguation candidate — re-exported from resolution/types.ts