@mrclrchtr/supi-code-intelligence 7.4.0 → 8.0.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 (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
@@ -1,7 +1,7 @@
1
1
  import { type Dirent, lstatSync, readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
2
2
  import * as path from "node:path";
3
+ import { loadAutomaticExclusionPatterns } from "@mrclrchtr/supi-core/config";
3
4
  import ignore from "ignore";
4
- import { loadLspSettings } from "./config/lsp-settings.ts";
5
5
 
6
6
  /** Directory names that automatic LSP work never enters or selects. */
7
7
  export const AUTOMATIC_LSP_EXCLUDED_DIRECTORIES: readonly string[] = Object.freeze([
@@ -22,15 +22,27 @@ export const AUTOMATIC_LSP_EXCLUDED_DIRECTORIES: readonly string[] = Object.free
22
22
 
23
23
  const BUILT_IN_EXCLUSIONS = new Set(AUTOMATIC_LSP_EXCLUDED_DIRECTORIES);
24
24
 
25
+ /** Options for loading one workspace's automatic path policy. */
26
+ export interface AutomaticLspPathPolicyOptions {
27
+ /** Whether project-scoped SuPi configuration is trusted. */
28
+ projectTrusted?: boolean;
29
+ /** Global config home, used by tests and managed sessions. */
30
+ homeDir?: string;
31
+ }
32
+
25
33
  /** Automatic path rules for one Workspace LSP runtime. The rules do not change. */
26
34
  export interface AutomaticLspPathPolicy {
27
35
  /** Canonical absolute workspace root used for all matching. */
28
36
  readonly workspaceRoot: string;
37
+ /** The configured patterns captured by this immutable policy. */
38
+ readonly configuredPatterns?: readonly string[];
29
39
  /**
30
40
  * True when automatic LSP work can use the path.
31
41
  * The policy reads the path kind when the caller does not supply it.
32
42
  */
33
43
  isEligible(candidate: string, kind?: "file" | "directory"): boolean;
44
+ /** True when the shared configured list excludes the path. */
45
+ isConfiguredExcluded?(candidate: string, kind?: "file" | "directory"): boolean;
34
46
  }
35
47
 
36
48
  /** Create the automatic path rules for one Workspace LSP runtime. */
@@ -39,10 +51,20 @@ export function createAutomaticLspPathPolicy(
39
51
  excludePatterns: readonly string[],
40
52
  ): AutomaticLspPathPolicy {
41
53
  const canonicalRoot = canonicalPath(workspaceRoot);
42
- const configuredExclusions = createIgnoreMatcher([...excludePatterns]);
54
+ const configuredPatterns = Object.freeze([...excludePatterns]);
55
+ const configuredExclusions = createIgnoreMatcher(configuredPatterns);
43
56
  const repositoryRules = compileRepositoryRules(canonicalRoot, configuredExclusions);
44
57
  return Object.freeze({
45
58
  workspaceRoot: canonicalRoot,
59
+ configuredPatterns,
60
+ isConfiguredExcluded(candidate: string, kind?: "file" | "directory"): boolean {
61
+ const relativePath = normalizeCandidate(canonicalRoot, workspaceRoot, candidate);
62
+ if (relativePath === null || relativePath === "") return false;
63
+ const candidateKind = kind ?? readCandidateKind(canonicalRoot, relativePath);
64
+ return configuredExclusions.ignores(
65
+ candidateKind === "directory" ? `${relativePath}/` : relativePath,
66
+ );
67
+ },
46
68
  isEligible(candidate: string, kind?: "file" | "directory"): boolean {
47
69
  const relativePath = normalizeCandidate(canonicalRoot, workspaceRoot, candidate);
48
70
  if (relativePath === null) return false;
@@ -62,8 +84,12 @@ export function createAutomaticLspPathPolicy(
62
84
  * Create path rules for an automatic LSP helper used outside a runtime.
63
85
  * Runtime-owned operations should pass the rules created at startup instead.
64
86
  */
65
- export function createDefaultAutomaticLspPathPolicy(workspaceRoot: string): AutomaticLspPathPolicy {
66
- return createAutomaticLspPathPolicy(workspaceRoot, loadLspSettings(workspaceRoot).exclude);
87
+ export function createDefaultAutomaticLspPathPolicy(
88
+ workspaceRoot: string,
89
+ options: AutomaticLspPathPolicyOptions = {},
90
+ ): AutomaticLspPathPolicy {
91
+ const excludePatterns = loadAutomaticExclusionPatterns(workspaceRoot, options);
92
+ return createAutomaticLspPathPolicy(workspaceRoot, excludePatterns);
67
93
  }
68
94
 
69
95
  /**
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-code-runtime",
3
- "version": "7.4.0",
3
+ "version": "8.0.0",
4
4
  "description": "Shared workspace context and capability contracts for code intelligence",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,7 +14,7 @@ export type {
14
14
  StructuralProvider,
15
15
  StructuralResult,
16
16
  } from "./capability/types.ts";
17
- export type { CodeQueryResult } from "./query-result.ts";
17
+ export type { CodeQueryPartialMetadata, CodeQueryResult } from "./query-result.ts";
18
18
  // Shared query-result constructors and contract
19
19
  export {
20
20
  completedCodeQuery,
@@ -1,3 +1,12 @@
1
+ /** Structured metadata for a partial query result. */
2
+ export interface CodeQueryPartialMetadata {
3
+ /** Automatic path-policy evidence removed from a collected result. */
4
+ readonly automaticPathExclusion?: {
5
+ readonly excludedCount: number;
6
+ readonly examples: readonly string[];
7
+ };
8
+ }
9
+
1
10
  /**
2
11
  * Result of a read-only code-provider query.
3
12
  *
@@ -8,7 +17,12 @@
8
17
  */
9
18
  export type CodeQueryResult<T> =
10
19
  | { readonly kind: "completed"; readonly data: T }
11
- | { readonly kind: "partial"; readonly data: T; readonly reason: string }
20
+ | {
21
+ readonly kind: "partial";
22
+ readonly data: T;
23
+ readonly reason: string;
24
+ readonly metadata?: CodeQueryPartialMetadata;
25
+ }
12
26
  | { readonly kind: "unavailable"; readonly reason: string };
13
27
 
14
28
  /** Construct a successfully completed code-query result, including empty data. */
@@ -17,8 +31,12 @@ export function completedCodeQuery<T>(data: T): CodeQueryResult<T> {
17
31
  }
18
32
 
19
33
  /** Construct a usable but incomplete code-query result. */
20
- export function partialCodeQuery<T>(data: T, reason: string): CodeQueryResult<T> {
21
- return { kind: "partial", data, reason };
34
+ export function partialCodeQuery<T>(
35
+ data: T,
36
+ reason: string,
37
+ metadata?: CodeQueryPartialMetadata,
38
+ ): CodeQueryResult<T> {
39
+ return { kind: "partial", data, reason, ...(metadata ? { metadata } : {}) };
22
40
  }
23
41
 
24
42
  /** Construct a code-query result that could not be established. */
@@ -35,7 +53,7 @@ export function mapCodeQueryResult<T, U>(
35
53
  case "completed":
36
54
  return completedCodeQuery(map(result.data));
37
55
  case "partial":
38
- return partialCodeQuery(map(result.data), result.reason);
56
+ return partialCodeQuery(map(result.data), result.reason, result.metadata);
39
57
  case "unavailable":
40
58
  return unavailableCodeQuery(result.reason);
41
59
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "7.4.0",
3
+ "version": "8.0.0",
4
4
  "description": "Shared settings, configuration, reporting, and session infrastructure",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -70,6 +70,116 @@ export interface SupiConfigOptions {
70
70
  homeDir?: string;
71
71
  }
72
72
 
73
+ /** Options for loading automatic code-intelligence exclusions. */
74
+ export interface AutomaticExclusionOptions extends SupiConfigOptions {
75
+ /** Whether the project config is trusted and can apply. Defaults to true. */
76
+ projectTrusted?: boolean;
77
+ }
78
+
79
+ /**
80
+ * Load the one configured exclusion list shared by automatic LSP work and
81
+ * broad AST searches.
82
+ *
83
+ * Project values replace global values. An explicit empty project list clears
84
+ * the global list. The old `lsp.exclude` key is rejected in every applicable
85
+ * scope so automatic work cannot start without its former protection.
86
+ */
87
+ export function loadAutomaticExclusionPatterns(
88
+ cwd: string,
89
+ options: AutomaticExclusionOptions = {},
90
+ ): readonly string[] {
91
+ const projectTrusted = options.projectTrusted !== false;
92
+ const globalCodeIntelligence = loadSupiConfigSectionForScope("code-intelligence", cwd, {
93
+ scope: "global",
94
+ homeDir: options.homeDir,
95
+ });
96
+ const projectCodeIntelligence = projectTrusted
97
+ ? loadSupiConfigSectionForScope("code-intelligence", cwd, { scope: "project" })
98
+ : null;
99
+ const globalLsp = loadSupiConfigSectionForScope("lsp", cwd, {
100
+ scope: "global",
101
+ homeDir: options.homeDir,
102
+ });
103
+ const projectLsp = projectTrusted
104
+ ? loadSupiConfigSectionForScope("lsp", cwd, { scope: "project" })
105
+ : null;
106
+
107
+ const legacyPath = findLegacyExclusionPath(cwd, options, globalLsp, projectLsp);
108
+ if (legacyPath) {
109
+ throw new Error(
110
+ `Unsupported ${legacyPath.scope} configuration at ${legacyPath.path}: "lsp.exclude" was removed. Move its value to "code-intelligence.exclude". Automatic LSP and broad AST work did not start; reload after migration.`,
111
+ );
112
+ }
113
+
114
+ const source = findExclusionSource(cwd, options, {
115
+ projectTrusted,
116
+ globalCodeIntelligence,
117
+ projectCodeIntelligence,
118
+ });
119
+ return validateExclusionSource(source);
120
+ }
121
+
122
+ interface ExclusionSource {
123
+ value: unknown;
124
+ path: string;
125
+ }
126
+
127
+ interface LegacyExclusionPath {
128
+ scope: "global" | "project";
129
+ path: string;
130
+ }
131
+
132
+ function findLegacyExclusionPath(
133
+ cwd: string,
134
+ options: AutomaticExclusionOptions,
135
+ globalLsp: Record<string, unknown> | null,
136
+ projectLsp: Record<string, unknown> | null,
137
+ ): LegacyExclusionPath | null {
138
+ if (globalLsp && Object.hasOwn(globalLsp, "exclude")) {
139
+ return { scope: "global", path: getSupiConfigPath("global", cwd, options) };
140
+ }
141
+ if (projectLsp && Object.hasOwn(projectLsp, "exclude")) {
142
+ return { scope: "project", path: getSupiConfigPath("project", cwd) };
143
+ }
144
+ return null;
145
+ }
146
+
147
+ function findExclusionSource(
148
+ cwd: string,
149
+ options: AutomaticExclusionOptions,
150
+ sections: {
151
+ projectTrusted: boolean;
152
+ globalCodeIntelligence: Record<string, unknown> | null;
153
+ projectCodeIntelligence: Record<string, unknown> | null;
154
+ },
155
+ ): ExclusionSource | null {
156
+ const { projectTrusted, globalCodeIntelligence, projectCodeIntelligence } = sections;
157
+ if (
158
+ projectTrusted &&
159
+ projectCodeIntelligence &&
160
+ Object.hasOwn(projectCodeIntelligence, "exclude")
161
+ ) {
162
+ return { value: projectCodeIntelligence.exclude, path: getSupiConfigPath("project", cwd) };
163
+ }
164
+ if (globalCodeIntelligence && Object.hasOwn(globalCodeIntelligence, "exclude")) {
165
+ return {
166
+ value: globalCodeIntelligence.exclude,
167
+ path: getSupiConfigPath("global", cwd, options),
168
+ };
169
+ }
170
+ return null;
171
+ }
172
+
173
+ function validateExclusionSource(source: ExclusionSource | null): readonly string[] {
174
+ if (!source) return Object.freeze([]);
175
+ if (!Array.isArray(source.value) || !source.value.every((entry) => typeof entry === "string")) {
176
+ throw new Error(
177
+ `Invalid "code-intelligence.exclude" in ${source.path}: expected an array of gitignore-style strings. Automatic LSP and broad AST work did not start.`,
178
+ );
179
+ }
180
+ return Object.freeze([...source.value]);
181
+ }
182
+
73
183
  /**
74
184
  * Load and merge config for a given extension section.
75
185
  *
@@ -1,7 +1,12 @@
1
1
  // supi-core config domain — config loading.
2
- export type { SupiConfigLocation, SupiConfigOptions } from "./config/config.ts";
2
+ export type {
3
+ AutomaticExclusionOptions,
4
+ SupiConfigLocation,
5
+ SupiConfigOptions,
6
+ } from "./config/config.ts";
3
7
  export {
4
8
  getSupiConfigPath,
9
+ loadAutomaticExclusionPatterns,
5
10
  loadSupiConfig,
6
11
  loadSupiConfigForScope,
7
12
  loadSupiConfigSectionForScope,
@@ -151,6 +151,7 @@ export interface CustomField extends BaseField {
151
151
  cwd: string,
152
152
  action: SettingsAction,
153
153
  helpers: ConfigHelpers,
154
+ ctx?: ExtensionContext,
154
155
  ) => void | Promise<void>;
155
156
  }
156
157
 
@@ -404,7 +405,7 @@ async function applyConfigAction(
404
405
  const helpers = createConfigHelpers(options.section, scope, cwd, options.homeDir);
405
406
  let storedValue: unknown;
406
407
  if (field.kind === "custom") {
407
- await field.persist(scope, cwd, action, helpers);
408
+ await field.persist(scope, cwd, action, helpers, ctx);
408
409
  storedValue = action.kind === "set" ? action.value : undefined;
409
410
  } else if (action.kind === "set") {
410
411
  storedValue = parseTypedValue(action.value, field);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-tree-sitter",
3
- "version": "7.4.0",
3
+ "version": "8.0.0",
4
4
  "description": "Structural AST analysis for SuPi code intelligence",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -36,8 +36,8 @@
36
36
  "dependencies": {
37
37
  "jiti": "^2.7.0",
38
38
  "web-tree-sitter": "^0.27.0",
39
- "@mrclrchtr/supi-core": "7.4.0",
40
- "@mrclrchtr/supi-code-runtime": "7.4.0"
39
+ "@mrclrchtr/supi-code-runtime": "8.0.0",
40
+ "@mrclrchtr/supi-core": "8.0.0"
41
41
  },
42
42
  "bundledDependencies": [
43
43
  "@mrclrchtr/supi-code-runtime",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-code-intelligence",
3
- "version": "7.4.0",
3
+ "version": "8.0.0",
4
4
  "description": "LSP and AST navigation, search, diagnostics, and refactoring",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -35,10 +35,10 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "yaml": "^2.9.0",
38
- "@mrclrchtr/supi-code-runtime": "7.4.0",
39
- "@mrclrchtr/supi-lsp": "7.4.0",
40
- "@mrclrchtr/supi-core": "7.4.0",
41
- "@mrclrchtr/supi-tree-sitter": "7.4.0"
38
+ "@mrclrchtr/supi-code-runtime": "8.0.0",
39
+ "@mrclrchtr/supi-lsp": "8.0.0",
40
+ "@mrclrchtr/supi-core": "8.0.0",
41
+ "@mrclrchtr/supi-tree-sitter": "8.0.0"
42
42
  },
43
43
  "bundledDependencies": [
44
44
  "@mrclrchtr/supi-code-runtime",
@@ -7,12 +7,17 @@
7
7
  */
8
8
 
9
9
  import { getDefaultWorkspaceRuntime } from "@mrclrchtr/supi-code-runtime/api";
10
- import { loadSupiConfigForScope } from "@mrclrchtr/supi-core/config";
11
- import { loadConfig, scanMissingServers } from "@mrclrchtr/supi-lsp/api";
10
+ import {
11
+ type AutomaticLspPathPolicy,
12
+ createDefaultAutomaticLspPathPolicy,
13
+ getExplicitlyDisabledLanguages,
14
+ loadConfig,
15
+ scanMissingServers,
16
+ } from "@mrclrchtr/supi-lsp/api";
12
17
 
13
18
  /** One actionable warning about reduced Code intelligence capability. */
14
19
  export interface CapabilityWarning {
15
- type: "language-disabled" | "missing-server" | "structural-unavailable";
20
+ type: "language-disabled" | "missing-server" | "structural-unavailable" | "configuration-error";
16
21
  message: string;
17
22
  language?: string;
18
23
  detail?: string;
@@ -27,6 +32,10 @@ export interface CapabilityWarningReport {
27
32
  /** Minimal LSP-controller surface needed to discover missing servers. */
28
33
  export interface CapabilityWarningMissingServerSource {
29
34
  getMissingServers(): Array<{ name: string; command: string; foundExtensions?: string[] }>;
35
+ /** Explicit disablement captured with the active LSP configuration snapshot. */
36
+ getExplicitlyDisabledLanguages?(): readonly string[];
37
+ /** Configuration validation failure that prevented automatic startup. */
38
+ getConfigurationError?(): string | null;
30
39
  }
31
40
 
32
41
  /** Current runtime/config facts needed to evaluate Capability Warnings. */
@@ -34,12 +43,21 @@ export interface CapabilityWarningInput {
34
43
  explicitlyDisabledLanguages: string[];
35
44
  missingServers: Array<{ name: string; command: string; foundExtensions: string[] }>;
36
45
  structuralState: { kind: string; reason?: string };
46
+ /** Configuration could not be validated for automatic capability work. */
47
+ configurationError?: string;
37
48
  }
38
49
 
39
50
  /** Evaluate current capability/configuration facts into a structured warning report. */
40
51
  export function evaluateCapabilityWarnings(input: CapabilityWarningInput): CapabilityWarningReport {
41
52
  const warnings: CapabilityWarning[] = [];
42
53
 
54
+ if (input.configurationError) {
55
+ warnings.push({
56
+ type: "configuration-error",
57
+ message: `Code intelligence configuration failed: ${input.configurationError}`,
58
+ });
59
+ }
60
+
43
61
  for (const language of input.explicitlyDisabledLanguages) {
44
62
  warnings.push({
45
63
  type: "language-disabled",
@@ -122,21 +140,60 @@ export class CapabilityWarningState {
122
140
  }
123
141
  }
124
142
 
143
+ /** Options for trust-aware capability configuration reads. */
144
+ export interface CapabilityWarningConfigOptions {
145
+ readonly projectTrusted?: boolean;
146
+ readonly homeDir?: string;
147
+ /** Reuse the active automatic policy instead of reading a new snapshot. */
148
+ readonly automaticPathPolicy?: AutomaticLspPathPolicy;
149
+ }
150
+
125
151
  /** Gather current runtime/config facts for Capability Warning evaluation. */
126
152
  export function gatherCapabilityWarningInput(
127
153
  cwd: string,
128
154
  lspController: CapabilityWarningMissingServerSource | null,
155
+ options: CapabilityWarningConfigOptions = {},
129
156
  ): CapabilityWarningInput {
157
+ const projectTrusted = options.projectTrusted !== false;
130
158
  const structuralState = getDefaultWorkspaceRuntime().getWorkspace(cwd).structural.state;
131
- const explicitlyDisabledLanguages = detectExplicitlyDisabledLanguages(cwd);
132
- const missingServers = lspController
133
- ? normalizeMissingServers(lspController.getMissingServers())
134
- : scanMissingServers(loadConfig(cwd), cwd);
159
+ let explicitlyDisabledLanguages: string[] = [];
160
+ let missingServers: Array<{
161
+ name: string;
162
+ command: string;
163
+ foundExtensions: string[];
164
+ }> = [];
165
+ let configurationError: string | undefined;
166
+
167
+ try {
168
+ if (lspController) {
169
+ explicitlyDisabledLanguages = [...(lspController.getExplicitlyDisabledLanguages?.() ?? [])];
170
+ missingServers = normalizeMissingServers(lspController.getMissingServers());
171
+ configurationError = lspController.getConfigurationError?.() ?? undefined;
172
+ } else {
173
+ // Build and validate the policy before scanning. A failed policy must
174
+ // not fall through to an unprotected workspace scan.
175
+ const automaticPathPolicy =
176
+ options.automaticPathPolicy ??
177
+ createDefaultAutomaticLspPathPolicy(cwd, {
178
+ projectTrusted,
179
+ homeDir: options.homeDir,
180
+ });
181
+ const config = loadConfig(cwd, { projectTrusted, homeDir: options.homeDir });
182
+ explicitlyDisabledLanguages = getExplicitlyDisabledLanguages(cwd, {
183
+ projectTrusted,
184
+ homeDir: options.homeDir,
185
+ });
186
+ missingServers = scanMissingServers(config, cwd, undefined, automaticPathPolicy);
187
+ }
188
+ } catch (error: unknown) {
189
+ configurationError = error instanceof Error ? error.message : String(error);
190
+ }
135
191
 
136
192
  return {
137
193
  explicitlyDisabledLanguages,
138
194
  missingServers,
139
195
  structuralState,
196
+ ...(configurationError ? { configurationError } : {}),
140
197
  };
141
198
  }
142
199
 
@@ -149,21 +206,3 @@ function normalizeMissingServers(
149
206
  foundExtensions: entry.foundExtensions ?? [],
150
207
  }));
151
208
  }
152
-
153
- function detectExplicitlyDisabledLanguages(cwd: string): string[] {
154
- const disabled = new Set<string>();
155
- for (const scope of ["project", "global"] as const) {
156
- const raw = loadSupiConfigForScope(
157
- "lsp",
158
- cwd,
159
- { servers: {} as Record<string, { enabled?: boolean }> },
160
- { scope },
161
- );
162
- const servers = (raw as { servers?: Record<string, { enabled?: boolean }> }).servers;
163
- if (!servers) continue;
164
- for (const [name, server] of Object.entries(servers)) {
165
- if (server.enabled === false) disabled.add(name);
166
- }
167
- }
168
- return [...disabled].sort();
169
- }
@@ -1,5 +1,9 @@
1
1
  import * as path from "node:path";
2
- import type { ProjectServerInfo, ProjectServerStatusReason } from "@mrclrchtr/supi-lsp/api";
2
+ import type {
3
+ ProjectServerInfo,
4
+ ProjectServerStatusReason,
5
+ ServerOperationSupportMap,
6
+ } from "@mrclrchtr/supi-lsp/api";
3
7
 
4
8
  /** Workspace-wide counts for non-running LSP routes. */
5
9
  export interface ProjectServerRouteStatusCounts {
@@ -62,3 +66,21 @@ export function formatProjectServerStatusReason(
62
66
  return null;
63
67
  }
64
68
  }
69
+
70
+ /** Render operation support without hiding server limits or SuPi limits. */
71
+ export function formatProjectServerOperationSupport(
72
+ support: ServerOperationSupportMap | undefined,
73
+ ): string | null {
74
+ if (!support) return null;
75
+ const entries = Object.entries(support).flatMap(([operation, value]) => {
76
+ const details: string[] = [];
77
+ if (value.server === "not-advertised") details.push("server unsupported");
78
+ if (value.server === "unknown") details.push("not negotiated");
79
+ if (value.supi === "limited") {
80
+ details.push(`SuPi limitation${value.reason ? `: ${value.reason}` : ""}`);
81
+ }
82
+ if (value.supi === "unsupported") details.push("SuPi unsupported");
83
+ return details.length > 0 ? [`${operation}: ${details.join("; ")}`] : [];
84
+ });
85
+ return entries.length > 0 ? `operation support: ${entries.join(", ")}` : null;
86
+ }
@@ -17,5 +17,6 @@ export function collectServers(
17
17
  status: server.status,
18
18
  ...(server.statusReason ? { statusReason: server.statusReason } : {}),
19
19
  ready: server.ready,
20
+ ...(server.operationSupport ? { operationSupport: server.operationSupport } : {}),
20
21
  }));
21
22
  }
@@ -1,5 +1,7 @@
1
+ // biome-ignore-all lint/style/noExcessiveLinesPerFile: enumeration policy and traversal stay one cohesive internal module.
1
2
  import { type Dirent, promises as fs, type Stats } from "node:fs";
2
3
  import * as path from "node:path";
4
+ import type { AutomaticLspPathPolicy } from "@mrclrchtr/supi-lsp/api";
3
5
  import {
4
6
  getStructuralSearchSupportedExtensions,
5
7
  getSupportedExtensions,
@@ -34,6 +36,7 @@ export const DEFAULT_AST_SCAN_TIMEOUT_MS = 10_000;
34
36
  export type AstScanExclusionReason =
35
37
  | "hidden-entry"
36
38
  | "excluded-directory"
39
+ | "configured-exclusion"
37
40
  | "unsupported-extension"
38
41
  | "unsupported-operation"
39
42
  | "symlink"
@@ -60,6 +63,8 @@ export interface AstScanPolicy {
60
63
  readonly operation: StructuralSearchOperation;
61
64
  readonly supportedExtensions: readonly string[];
62
65
  readonly excludedDirectories: readonly string[];
66
+ /** Patterns captured from code-intelligence.exclude for this scan. */
67
+ readonly configuredExclusions: readonly string[];
63
68
  readonly hiddenEntries: "excluded";
64
69
  readonly ignoreFiles: false;
65
70
  readonly symlinks: "explicit-roots-only";
@@ -86,6 +91,8 @@ export interface EnumerateAstFilesOptions {
86
91
  /** Timer seam for deterministic deadline tests; defaults to wall-clock timers. */
87
92
  readonly schedule?: ScheduleDeadline;
88
93
  readonly operations?: AstScanOperations;
94
+ /** Session-owned automatic path policy for configured exclusions. */
95
+ readonly automaticPathPolicy?: AutomaticLspPathPolicy;
89
96
  }
90
97
 
91
98
  export type AstFileEnumeration =
@@ -107,6 +114,7 @@ export function astScanPolicy(
107
114
  operation: StructuralSearchOperation,
108
115
  maxFiles: number,
109
116
  timeoutMs: number,
117
+ automaticPathPolicy?: AutomaticLspPathPolicy,
110
118
  ): AstScanPolicy {
111
119
  return {
112
120
  operation,
@@ -114,6 +122,7 @@ export function astScanPolicy(
114
122
  a.localeCompare(b),
115
123
  ),
116
124
  excludedDirectories: [...AST_SCAN_EXCLUDED_DIRECTORIES],
125
+ configuredExclusions: [...(automaticPathPolicy?.configuredPatterns ?? [])],
117
126
  hiddenEntries: "excluded",
118
127
  ignoreFiles: false,
119
128
  symlinks: "explicit-roots-only",
@@ -215,7 +224,10 @@ class AstFileEnumerator {
215
224
 
216
225
  if (rootStat.isFile()) return this.#processFileRoot(canonicalRoot);
217
226
  if (rootStat.isDirectory()) {
218
- await this.#walk(canonicalRoot);
227
+ const bypassConfiguredExclusions =
228
+ this.options.automaticPathPolicy?.isConfiguredExcluded?.(canonicalRoot, "directory") ??
229
+ false;
230
+ await this.#walk(canonicalRoot, bypassConfiguredExclusions);
219
231
  return null;
220
232
  }
221
233
  return {
@@ -243,7 +255,7 @@ class AstFileEnumerator {
243
255
  };
244
256
  }
245
257
 
246
- async #walk(directory: string): Promise<void> {
258
+ async #walk(directory: string, bypassConfiguredExclusions = false): Promise<void> {
247
259
  if (!this.#checkControl() || this.#visitedDirectories.has(directory)) return;
248
260
  this.#visitedDirectories.add(directory);
249
261
  const entries = await this.#readDirectory(directory);
@@ -251,7 +263,7 @@ class AstFileEnumerator {
251
263
  entries.sort((a, b) => a.name.localeCompare(b.name));
252
264
  for (const entry of entries) {
253
265
  if (!this.#checkControl()) return;
254
- await this.#processEntry(directory, entry);
266
+ await this.#processEntry(directory, entry, bypassConfiguredExclusions);
255
267
  }
256
268
  }
257
269
 
@@ -267,27 +279,48 @@ class AstFileEnumerator {
267
279
  }
268
280
  }
269
281
 
270
- async #processEntry(directory: string, entry: Dirent): Promise<void> {
282
+ async #processEntry(
283
+ directory: string,
284
+ entry: Dirent,
285
+ bypassConfiguredExclusions: boolean,
286
+ ): Promise<void> {
271
287
  const entryPath = path.join(directory, entry.name);
272
- const exclusion = this.#entryExclusion(entry);
288
+ const exclusion = this.#entryExclusion(entryPath, entry, bypassConfiguredExclusions);
273
289
  if (exclusion) {
274
290
  this.#record(this.#exclusions, exclusion, entryPath);
275
291
  return;
276
292
  }
277
293
  if (entry.isDirectory()) {
278
- await this.#walk(entryPath);
294
+ await this.#walk(entryPath, bypassConfiguredExclusions);
279
295
  return;
280
296
  }
281
297
  if (entry.isFile()) this.#addFile(entryPath);
282
298
  }
283
299
 
284
- #entryExclusion(entry: Dirent): AstScanExclusionReason | null {
300
+ #entryExclusion(
301
+ entryPath: string,
302
+ entry: Dirent,
303
+ bypassConfiguredExclusions: boolean,
304
+ ): AstScanExclusionReason | null {
285
305
  if (entry.name.startsWith(".")) return "hidden-entry";
286
306
  if (entry.isSymbolicLink()) return "symlink";
287
307
  if (entry.isDirectory()) {
288
- return EXCLUDED_DIRECTORY_SET.has(entry.name) ? "excluded-directory" : null;
308
+ if (EXCLUDED_DIRECTORY_SET.has(entry.name)) return "excluded-directory";
309
+ if (
310
+ !bypassConfiguredExclusions &&
311
+ this.options.automaticPathPolicy?.isConfiguredExcluded?.(entryPath, "directory")
312
+ ) {
313
+ return "configured-exclusion";
314
+ }
315
+ return null;
289
316
  }
290
317
  if (!entry.isFile()) return "non-regular";
318
+ if (
319
+ !bypassConfiguredExclusions &&
320
+ this.options.automaticPathPolicy?.isConfiguredExcluded?.(entryPath, "file")
321
+ ) {
322
+ return "configured-exclusion";
323
+ }
291
324
  return this.#fileExclusion(entry.name);
292
325
  }
293
326
 
@@ -367,6 +400,7 @@ class AstFileEnumerator {
367
400
  this.options.operation,
368
401
  this.options.maxFiles,
369
402
  this.options.timeoutMs ?? DEFAULT_AST_SCAN_TIMEOUT_MS,
403
+ this.options.automaticPathPolicy,
370
404
  ),
371
405
  exclusions: [...this.#exclusions.values()],
372
406
  limitations: [...this.#limitations.values()].map((entry) => ({