@mrclrchtr/supi-code-intelligence 10.0.0 → 11.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 (133) hide show
  1. package/README.md +77 -21
  2. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/LICENSE +21 -0
  3. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/README.md +743 -0
  4. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/index.js +17 -0
  5. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/constants.js +184 -0
  6. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/parse.js +1425 -0
  7. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/picomatch.js +361 -0
  8. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/scan.js +403 -0
  9. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/utils.js +72 -0
  10. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/package.json +83 -0
  11. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/posix.js +3 -0
  12. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +4 -1
  13. package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +11 -0
  14. package/node_modules/@mrclrchtr/supi-code-runtime/src/file-associations.ts +190 -0
  15. package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +22 -0
  16. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  17. package/node_modules/@mrclrchtr/supi-lsp/README.md +88 -2
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/LICENSE +21 -0
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/README.md +743 -0
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/index.js +17 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/constants.js +184 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/parse.js +1425 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/picomatch.js +361 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/scan.js +403 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/utils.js +72 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/package.json +83 -0
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/posix.js +3 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +4 -1
  29. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +11 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/file-associations.ts +190 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +22 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  33. package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  34. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +1 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +3 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +6 -4
  37. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-request-enrollment.ts +66 -22
  38. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-semantic-input-barrier.ts +37 -5
  39. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +136 -43
  40. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +261 -22
  41. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +13 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-discovery.ts +151 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +97 -129
  44. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-protocol.ts +132 -0
  45. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +8 -1
  46. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +7 -20
  47. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +172 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +14 -0
  49. package/node_modules/@mrclrchtr/supi-lsp/src/utils.ts +12 -11
  50. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +63 -17
  51. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/LICENSE +21 -0
  52. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/README.md +743 -0
  53. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/index.js +17 -0
  54. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/constants.js +184 -0
  55. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/parse.js +1425 -0
  56. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/picomatch.js +361 -0
  57. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/scan.js +403 -0
  58. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/utils.js +72 -0
  59. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/package.json +83 -0
  60. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/posix.js +3 -0
  61. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +4 -1
  62. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +11 -0
  63. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/file-associations.ts +190 -0
  64. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +22 -0
  65. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  66. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  67. package/node_modules/@mrclrchtr/supi-tree-sitter/src/language.ts +16 -10
  68. package/node_modules/@mrclrchtr/supi-tree-sitter/src/operation-support.ts +13 -6
  69. package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +19 -1
  70. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +18 -4
  71. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +10 -3
  72. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +17 -2
  73. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-process.ts +22 -5
  74. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +36 -1
  75. package/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-errors.ts +73 -0
  76. package/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-node.ts +4 -0
  77. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +15 -9
  78. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +24 -15
  79. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +8 -1
  80. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/imports.ts +233 -7
  81. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/node-at.ts +7 -3
  82. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-expansion.ts +78 -0
  83. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-jvm.ts +25 -4
  84. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-nested.ts +390 -0
  85. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline.ts +49 -28
  86. package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +16 -0
  87. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/process-host.mjs +61 -24
  88. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +44 -10
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/service.ts +13 -9
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/worker-main.ts +15 -2
  91. package/package.json +5 -5
  92. package/src/analysis/refactor/apply.ts +35 -14
  93. package/src/analysis/relations/callees.ts +9 -2
  94. package/src/analysis/relations/implementations.ts +7 -2
  95. package/src/analysis/search/pattern-analysis.ts +90 -12
  96. package/src/analysis/search/pattern.ts +1 -0
  97. package/src/analysis/target/anchored-structural.ts +1 -0
  98. package/src/analysis/target/discovery.ts +29 -0
  99. package/src/analysis/target/file.ts +19 -9
  100. package/src/analysis/target/types.ts +5 -0
  101. package/src/config.ts +46 -7
  102. package/src/session/graph/collect.ts +2 -2
  103. package/src/session/graph-types.ts +6 -0
  104. package/src/session/inspect/collect.ts +35 -20
  105. package/src/session/inspect-types.ts +9 -2
  106. package/src/session/orientation/collect.ts +90 -18
  107. package/src/session/orientation/context-sections.ts +22 -1
  108. package/src/session/orientation/gather.ts +46 -6
  109. package/src/session/orientation-types.ts +7 -1
  110. package/src/session/refactor-plans.ts +17 -0
  111. package/src/session/refactor-workflow.ts +13 -6
  112. package/src/session/target-store.ts +5 -0
  113. package/src/session/target-workflow.ts +3 -0
  114. package/src/substrate/workspace-provider-host.ts +22 -2
  115. package/src/tool/code_find/markdown.ts +17 -4
  116. package/src/tool/code_find/result.ts +17 -3
  117. package/src/tool/code_graph/details.ts +2 -0
  118. package/src/tool/code_graph/display.ts +1 -0
  119. package/src/tool/code_graph/format.ts +1 -0
  120. package/src/tool/code_graph/result.ts +32 -6
  121. package/src/tool/code_inspect/markdown.ts +15 -1
  122. package/src/tool/code_inspect/result.ts +11 -0
  123. package/src/tool/code_orientation/result.ts +4 -2
  124. package/src/tool/code_resolve/markdown.ts +34 -14
  125. package/src/tool/code_resolve/result.ts +7 -3
  126. package/src/tool/result/types.ts +20 -2
  127. package/src/ui/tui/display.ts +2 -1
  128. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/LICENSE-MIT +0 -21
  129. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/README.md +0 -501
  130. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/index.d.ts +0 -81
  131. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/index.js +0 -1566
  132. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/legacy.js +0 -1346
  133. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/package.json +0 -93
@@ -4,6 +4,7 @@ import {
4
4
  isCodeRequestDeadlineError,
5
5
  isCodeRequestInterruption,
6
6
  type OutlineData,
7
+ type SourceRange,
7
8
  type StructuralProvider as StructuralSubstrate,
8
9
  } from "@mrclrchtr/supi-code-runtime/api";
9
10
  import type { CodeFindAstKind } from "../../tool/code_find/ast-kinds.ts";
@@ -20,8 +21,14 @@ export interface StructuredPatternParams {
20
21
  export interface StructuredMatch {
21
22
  readonly file: string;
22
23
  readonly name: string;
24
+ /** Display kind: native kind when available, otherwise common structural kind. */
23
25
  readonly kind: string;
24
26
  readonly line: number;
27
+ readonly startCharacter: number;
28
+ readonly endLine: number;
29
+ readonly endCharacter: number;
30
+ readonly commonKind?: string;
31
+ readonly nativeKind?: string;
25
32
  }
26
33
 
27
34
  export type StructuredFailureKind = Exclude<CodeResult<never>, { kind: "success" }>["kind"];
@@ -30,9 +37,13 @@ export interface StructuredFailure {
30
37
  readonly file: string;
31
38
  readonly kind: StructuredFailureKind;
32
39
  readonly reason: string;
40
+ readonly errorRanges?: readonly SourceRange[];
33
41
  }
34
42
 
35
- export type StructuredScanLimitation = AstScanLimitation | ProviderScanLimitation;
43
+ export type StructuredScanLimitation =
44
+ | AstScanLimitation
45
+ | ProviderScanLimitation
46
+ | SyntaxRecoveryScanLimitation;
36
47
 
37
48
  export interface ProviderScanLimitation {
38
49
  readonly reason: "provider-failure";
@@ -40,6 +51,13 @@ export interface ProviderScanLimitation {
40
51
  readonly examples: readonly string[];
41
52
  }
42
53
 
54
+ /** Recovered syntax files that limit the scan without losing collected matches. */
55
+ export interface SyntaxRecoveryScanLimitation {
56
+ readonly reason: "syntax-recovery";
57
+ readonly pathCount: number;
58
+ readonly examples: readonly string[];
59
+ }
60
+
43
61
  export interface StructuredFileAnalysis {
44
62
  readonly matches: StructuredMatch[];
45
63
  readonly failures: StructuredFailure[];
@@ -125,11 +143,20 @@ export async function analyzeStructuredFiles(
125
143
  if (fileFailures.length === 0) analyzedFileCount += 1;
126
144
  }
127
145
 
128
- if (failures.length > 0) {
146
+ const recoveredFiles = failures.filter((failure) => failure.kind === "partial");
147
+ if (recoveredFiles.length > 0) {
148
+ limitations.push({
149
+ reason: "syntax-recovery",
150
+ pathCount: recoveredFiles.length,
151
+ examples: recoveredFiles.slice(0, 5).map((failure) => failure.file),
152
+ });
153
+ }
154
+ const failedFiles = failures.filter((failure) => failure.kind !== "partial");
155
+ if (failedFiles.length > 0) {
129
156
  limitations.push({
130
157
  reason: "provider-failure",
131
- pathCount: failures.length,
132
- examples: failures.slice(0, 5).map((failure) => failure.file),
158
+ pathCount: failedFiles.length,
159
+ examples: failedFiles.slice(0, 5).map((failure) => failure.file),
133
160
  });
134
161
  }
135
162
  return { matches, failures, limitations, analyzedFileCount };
@@ -159,8 +186,17 @@ async function collectMatchesForFile(
159
186
  matcher: (value: string) => boolean,
160
187
  requestControl: CodeRequestControl,
161
188
  ): Promise<void> {
162
- const recordFailure = (kind: StructuredFailureKind, reason: string) => {
163
- failures.push({ file: relFile, kind, reason });
189
+ const recordFailure = (
190
+ failureKind: StructuredFailureKind,
191
+ reason: string,
192
+ errorRanges?: readonly SourceRange[],
193
+ ) => {
194
+ failures.push({
195
+ file: relFile,
196
+ kind: failureKind,
197
+ reason,
198
+ ...(errorRanges ? { errorRanges } : {}),
199
+ });
164
200
  };
165
201
 
166
202
  if (kind === "definition") {
@@ -168,7 +204,7 @@ async function collectMatchesForFile(
168
204
  if (!handleStructuralResult(outline, recordFailure)) return;
169
205
  for (const item of flattenOutlineItems(outline.data)) {
170
206
  if (!matcher(item.name)) continue;
171
- matches.push({ file: relFile, name: item.name, kind: item.kind, line: item.startLine });
207
+ matches.push(outlineMatch(relFile, item));
172
208
  }
173
209
  return;
174
210
  }
@@ -178,7 +214,15 @@ async function collectMatchesForFile(
178
214
  if (!handleStructuralResult(exportsResult, recordFailure)) return;
179
215
  for (const item of exportsResult.data) {
180
216
  if (!matcher(item.name)) continue;
181
- matches.push({ file: relFile, name: item.name, kind: item.kind, line: item.startLine });
217
+ matches.push({
218
+ file: relFile,
219
+ name: item.name,
220
+ kind: item.kind,
221
+ line: item.startLine,
222
+ startCharacter: item.startCharacter,
223
+ endLine: item.endLine,
224
+ endCharacter: item.endCharacter,
225
+ });
182
226
  }
183
227
  return;
184
228
  }
@@ -193,6 +237,9 @@ async function collectMatchesForFile(
193
237
  name: item.moduleSpecifier,
194
238
  kind: "import",
195
239
  line: item.startLine,
240
+ startCharacter: item.startCharacter,
241
+ endLine: item.endLine,
242
+ endCharacter: item.endCharacter,
196
243
  });
197
244
  }
198
245
  return;
@@ -203,7 +250,15 @@ async function collectMatchesForFile(
203
250
  if (!handleStructuralResult(callResult, recordFailure)) return;
204
251
  for (const call of callResult.data) {
205
252
  if (!matcher(callableExpressionForMatching(call.name))) continue;
206
- matches.push({ file: relFile, name: call.name, kind: "call", line: call.startLine });
253
+ matches.push({
254
+ file: relFile,
255
+ name: call.name,
256
+ kind: "call",
257
+ line: call.startLine,
258
+ startCharacter: call.startCharacter,
259
+ endLine: call.endLine,
260
+ endCharacter: call.endCharacter,
261
+ });
207
262
  }
208
263
  return;
209
264
  }
@@ -217,20 +272,43 @@ async function collectMatchesForFile(
217
272
  if (kind === "method" && item.kind.toLowerCase() !== "method") continue;
218
273
  if (kind === "enum" && item.kind.toLowerCase() !== "enum") continue;
219
274
  if (!matcher(item.name)) continue;
220
- matches.push({ file: relFile, name: item.name, kind: item.kind, line: item.startLine });
275
+ matches.push(outlineMatch(relFile, item));
221
276
  }
222
277
  }
223
278
 
224
279
  /** Flatten provider outlines so nested class/interface/enum declarations remain searchable. */
280
+ function outlineMatch(file: string, item: OutlineData): StructuredMatch {
281
+ return {
282
+ file,
283
+ name: item.name,
284
+ kind: item.nativeKind ?? item.kind,
285
+ ...(item.nativeKind ? { commonKind: item.kind, nativeKind: item.nativeKind } : {}),
286
+ line: item.startLine,
287
+ startCharacter: item.startCharacter,
288
+ endLine: item.endLine,
289
+ endCharacter: item.endCharacter,
290
+ };
291
+ }
292
+
225
293
  function flattenOutlineItems(items: readonly OutlineData[]): OutlineData[] {
226
294
  return items.flatMap((item) => [item, ...flattenOutlineItems(item.children ?? [])]);
227
295
  }
228
296
 
297
+ type StructuralDataResult<T> = Extract<CodeResult<T>, { kind: "success" | "partial" }>;
298
+
229
299
  function handleStructuralResult<T>(
230
300
  result: CodeResult<T>,
231
- recordFailure: (kind: StructuredFailureKind, reason: string) => void,
232
- ): result is { kind: "success"; data: T } {
301
+ recordFailure: (
302
+ kind: StructuredFailureKind,
303
+ reason: string,
304
+ errorRanges?: readonly SourceRange[],
305
+ ) => void,
306
+ ): result is StructuralDataResult<T> {
233
307
  if (result.kind === "success") return true;
308
+ if (result.kind === "partial") {
309
+ recordFailure("partial", result.reason, result.errorRanges);
310
+ return true;
311
+ }
234
312
  recordFailure(result.kind, result.message);
235
313
  return false;
236
314
  }
@@ -29,6 +29,7 @@ export type {
29
29
  StructuredMatch,
30
30
  StructuredPatternParams,
31
31
  StructuredScanLimitation,
32
+ SyntaxRecoveryScanLimitation,
32
33
  } from "./pattern-analysis.ts";
33
34
 
34
35
  /** Structured completeness state for the AST source-file scan. */
@@ -17,6 +17,7 @@ const DECLARATION_NODE_TYPES = new Set([
17
17
  "function_declaration",
18
18
  "generator_function_declaration",
19
19
  "function_signature",
20
+ "function_item",
20
21
  "method_definition",
21
22
  "method_declaration",
22
23
  "method_signature",
@@ -0,0 +1,29 @@
1
+ import type { SourceRange } from "@mrclrchtr/supi-code-runtime/api";
2
+
3
+ export interface TargetDiscoveryResult<T> {
4
+ readonly available: boolean;
5
+ readonly targets: readonly T[];
6
+ readonly partial?: { readonly reason: string; readonly errorRanges: readonly SourceRange[] };
7
+ }
8
+
9
+ /** Combine provider recovery without discarding structurally usable targets. */
10
+ export function mergeDiscoveryPartial(
11
+ semantic: TargetDiscoveryResult<unknown>,
12
+ structural: TargetDiscoveryResult<unknown>,
13
+ ): { partial?: { reason: string; errorRanges: readonly SourceRange[] } } {
14
+ const partials = [semantic.partial, structural.partial].filter(
15
+ (partial): partial is NonNullable<TargetDiscoveryResult<unknown>["partial"]> =>
16
+ partial !== undefined,
17
+ );
18
+ if (partials.length === 0) return {};
19
+ const ranges = new Map<string, SourceRange>();
20
+ for (const partial of partials) {
21
+ for (const range of partial.errorRanges) ranges.set(JSON.stringify(range), range);
22
+ }
23
+ return {
24
+ partial: {
25
+ reason: partials.map((partial) => partial.reason).join(" "),
26
+ errorRanges: [...ranges.values()],
27
+ },
28
+ };
29
+ }
@@ -20,6 +20,7 @@ import {
20
20
  } from "@mrclrchtr/supi-code-runtime/api";
21
21
  import type { AnchorKind } from "../../session/target-store.ts";
22
22
  import { normalizePath } from "../search/paths.ts";
23
+ import { mergeDiscoveryPartial, type TargetDiscoveryResult } from "./discovery.ts";
23
24
  import {
24
25
  reconcileContainer,
25
26
  reconcileNesting,
@@ -61,16 +62,13 @@ const BINARY_EXTENSIONS = new Set([
61
62
  ".node",
62
63
  ]);
63
64
 
65
+ type DiscoveryResult = TargetDiscoveryResult<DiscoveredTargetData>;
66
+
64
67
  export interface DiscoveredTargetData extends ResolvedTargetData {
65
68
  /** Provider-backed hierarchy used only for file-result presentation ranking. */
66
69
  readonly nesting: DeclarationNesting;
67
70
  }
68
71
 
69
- interface DiscoveryResult {
70
- readonly available: boolean;
71
- readonly targets: DiscoveredTargetData[];
72
- }
73
-
74
72
  /** Validated file-discovery input with its normalized absolute path. */
75
73
  export type FileDiscoveryValidation =
76
74
  | { kind: "valid"; file: string }
@@ -130,6 +128,7 @@ export async function resolveFileTargetGroup(
130
128
  discoveryProvenance,
131
129
  confidence: targetGroupConfidence(targets, discoveryProvenance),
132
130
  unknownNestingCount,
131
+ ...mergeDiscoveryPartial(semantic, structural),
133
132
  },
134
133
  };
135
134
  }
@@ -166,7 +165,7 @@ async function discoverSemantic(
166
165
  ): Promise<DiscoveryResult> {
167
166
  if (!semantic) return { available: false, targets: [] };
168
167
  try {
169
- const result = await semantic.documentSymbols(file);
168
+ const result = await semantic.documentSymbols(file, control);
170
169
  if (result.kind === "unavailable") return { available: false, targets: [] };
171
170
  return {
172
171
  available: true,
@@ -177,6 +176,7 @@ async function discoverSemantic(
177
176
  return { ...refined, nesting: target.nesting };
178
177
  }),
179
178
  ),
179
+ ...(result.kind === "partial" ? { partial: { reason: result.reason, errorRanges: [] } } : {}),
180
180
  };
181
181
  } catch (error) {
182
182
  if (isCodeRequestInterruption(error, control)) throw error;
@@ -218,9 +218,17 @@ async function discoverStructural(
218
218
  ): Promise<DiscoveryResult> {
219
219
  if (!structural) return { available: false, targets: [] };
220
220
  try {
221
- const result = await structural.outline(file);
222
- if (result.kind !== "success") return { available: false, targets: [] };
223
- return { available: true, targets: flattenOutline(file, result.data) };
221
+ const result = await structural.outline(file, control);
222
+ if (result.kind !== "success" && result.kind !== "partial") {
223
+ return { available: false, targets: [] };
224
+ }
225
+ return {
226
+ available: true,
227
+ targets: flattenOutline(file, result.data),
228
+ ...(result.kind === "partial"
229
+ ? { partial: { reason: result.reason, errorRanges: result.errorRanges } }
230
+ : {}),
231
+ };
224
232
  } catch (error) {
225
233
  if (isCodeRequestInterruption(error, control)) throw error;
226
234
  return { available: false, targets: [] };
@@ -247,6 +255,7 @@ function flattenOutline(
247
255
  declarationOccurrence: 0,
248
256
  name: item.name,
249
257
  kind: item.kind,
258
+ ...(item.nativeKind ? { nativeKind: item.nativeKind } : {}),
250
259
  identityKind:
251
260
  canonicalFileDeclarationKind(file, item.kind, item.name) ??
252
261
  canonicalDeclarationKind(item.kind),
@@ -279,6 +288,7 @@ function mergeDiscoveries(
279
288
  {
280
289
  ...refinedSemantic,
281
290
  provenance: ["semantic", "structural"] as const,
291
+ nativeKind: structuralTarget.nativeKind ?? semanticTarget.nativeKind,
282
292
  container: reconcileContainer(semanticTarget, structuralTarget),
283
293
  nesting: reconcileNesting(semanticTarget.nesting, structuralTarget.nesting),
284
294
  },
@@ -8,6 +8,7 @@
8
8
 
9
9
  import type {
10
10
  SemanticProvider as SemanticSubstrate,
11
+ SourceRange,
11
12
  StructuralProvider as StructuralSubstrate,
12
13
  } from "@mrclrchtr/supi-code-runtime/api";
13
14
  import type { TargetSymbolKind } from "../../session/target-input.ts";
@@ -81,6 +82,8 @@ export interface ResolvedTargetData {
81
82
  declarationOccurrence: number;
82
83
  name: string | null;
83
84
  kind: string | null;
85
+ /** Structural source-language declaration kind, separate from common identity kind. */
86
+ nativeKind?: string;
84
87
  /** Evidence-backed provider-independent kind used for matching and handle identity. */
85
88
  identityKind?: string;
86
89
  confidence: "semantic" | "structural" | "heuristic" | "unavailable";
@@ -111,6 +114,8 @@ export interface ResolvedTargetGroupData {
111
114
  confidence: "semantic" | "structural" | "heuristic" | "unavailable";
112
115
  /** Complete-group declarations whose provider observations could not establish hierarchy. */
113
116
  unknownNestingCount: number;
117
+ /** Partial provider collection; targets remain usable and exact absence is not claimed. */
118
+ partial?: { reason: string; errorRanges: readonly SourceRange[] };
114
119
  }
115
120
 
116
121
  /**
package/src/config.ts CHANGED
@@ -2,9 +2,15 @@
2
2
 
3
3
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
4
4
  import {
5
+ type CFamilyFileAssociationResolver,
6
+ createCFamilyFileAssociationResolver,
7
+ } from "@mrclrchtr/supi-code-runtime/api";
8
+ import {
9
+ getSupiConfigPath,
5
10
  loadAutomaticExclusionPatterns,
6
11
  loadSupiConfig,
7
12
  loadSupiConfigForScope,
13
+ loadSupiConfigSectionForScope,
8
14
  } from "@mrclrchtr/supi-core/config";
9
15
  import {
10
16
  defineConfigSettings,
@@ -46,16 +52,49 @@ export function loadCodeIntelligenceConfig(
46
52
  return loaded;
47
53
  }
48
54
 
55
+ /**
56
+ * Load C-family associations from trusted project configuration only.
57
+ *
58
+ * `fileAssociations` is an ordered array of `{ pattern, language }` rules.
59
+ * Patterns are case-sensitive globs. Use `*`, `?`, `**`, character classes,
60
+ * and brace alternatives. Patterns
61
+ * match POSIX-style paths relative to the workspace root. The first match
62
+ * wins. A rule accepts
63
+ * only `c` or `cpp` and only changes an existing C-family suffix. Global
64
+ * values do not apply. An untrusted project returns the default mapping
65
+ * without reading its configuration. The workspace host keeps this resolver
66
+ * until its last provider lease ends.
67
+ *
68
+ * @throws If a trusted project rule is invalid.
69
+ */
70
+ export function loadProjectFileAssociations(
71
+ cwd: string,
72
+ projectTrusted: boolean,
73
+ ): CFamilyFileAssociationResolver {
74
+ if (!projectTrusted) return createCFamilyFileAssociationResolver(cwd);
75
+ const section = loadSupiConfigSectionForScope("code-intelligence", cwd, {
76
+ scope: "project",
77
+ });
78
+ if (!section || !Object.hasOwn(section, "fileAssociations")) {
79
+ return createCFamilyFileAssociationResolver(cwd);
80
+ }
81
+ try {
82
+ return createCFamilyFileAssociationResolver(cwd, section.fileAssociations);
83
+ } catch (error) {
84
+ const detail = error instanceof Error ? error.message : String(error);
85
+ throw new Error(
86
+ `Invalid trusted project configuration in ${getSupiConfigPath("project", cwd)}: ${detail}`,
87
+ { cause: error },
88
+ );
89
+ }
90
+ }
91
+
49
92
  /**
50
93
  * Resolve the overview setting for one session boundary.
51
94
  *
52
- * Project-scoped values apply only when the project is trusted (ADR 0002's
53
- * global/trusted-project scope precedence). Only a strict boolean `true`
54
- * enables injection; any other value, including malformed non-boolean
55
- * values, fails closed. Unreadable or invalid config files and non-object
56
- * sections fall back to defaults through the shared supi-core loader, the
57
- * same semantics every other SuPi setting uses; fail-closed covers values
58
- * inside a well-formed section.
95
+ * Project-scoped values apply only when the project is trusted. Only a strict
96
+ * boolean `true` enables injection; malformed values fail closed. Unreadable
97
+ * files and non-object sections use the shared config-loader defaults.
59
98
  */
60
99
  export function resolveOverviewEnabled(
61
100
  cwd: string,
@@ -156,7 +156,7 @@ async function collectCalleesRelation(options: CollectRelationOptions): Promise<
156
156
  return {
157
157
  kind: "ok",
158
158
  rel: "callees",
159
- data: { enclosingScope, calls, depth: result.depth },
159
+ data: { enclosingScope, calls, depth: result.depth, recovery: result.partial },
160
160
  readNext: [
161
161
  readNextEnclosingScope(
162
162
  toDisplayPath(options.cwd, options.file),
@@ -187,7 +187,7 @@ async function collectImplementationsRelation(
187
187
  },
188
188
  });
189
189
  if (result.confidence === "unavailable") {
190
- return { kind: "unavailable", rel: "implements", message: "Implementations unavailable" };
190
+ return { kind: "unavailable", rel: "implements", message: result.message };
191
191
  }
192
192
 
193
193
  return {
@@ -1,3 +1,4 @@
1
+ import type { SourceRange } from "@mrclrchtr/supi-code-runtime/api";
1
2
  import type { ReadNextItem } from "../analysis/read-next.ts";
2
3
  import type { RelationLocationPartialReason } from "../analysis/relations/provider-locations.ts";
3
4
  import type {
@@ -42,6 +43,11 @@ export type GraphSection =
42
43
  readonly enclosingScope: CalleeScope;
43
44
  readonly calls: readonly CallEntry[];
44
45
  readonly depth: "direct" | "deep";
46
+ readonly recovery: {
47
+ readonly file: string;
48
+ readonly reason: string;
49
+ readonly errorRanges: readonly SourceRange[];
50
+ } | null;
45
51
  };
46
52
  readonly readNext: readonly ReadNextItem[];
47
53
  }
@@ -59,19 +59,26 @@ async function collectNode(
59
59
  input.character,
60
60
  input.requestControl,
61
61
  );
62
- if (result.kind !== "success") return unavailableCodeQuery(result.message);
63
- return {
64
- kind: "completed",
65
- data: {
66
- type: result.data.type,
67
- text: result.data.text,
68
- startLine: result.data.startLine,
69
- startCharacter: result.data.startCharacter,
70
- endLine: result.data.endLine,
71
- endCharacter: result.data.endCharacter,
72
- ancestry: result.data.ancestry ?? [],
73
- },
62
+ if (result.kind !== "success" && result.kind !== "partial") {
63
+ return unavailableCodeQuery(result.message);
64
+ }
65
+ const data: InspectNode = {
66
+ type: result.data.type,
67
+ text: result.data.text,
68
+ startLine: result.data.startLine,
69
+ startCharacter: result.data.startCharacter,
70
+ endLine: result.data.endLine,
71
+ endCharacter: result.data.endCharacter,
72
+ ancestry: result.data.ancestry ?? [],
74
73
  };
74
+ return result.kind === "partial"
75
+ ? {
76
+ kind: "partial",
77
+ data,
78
+ reason: result.reason,
79
+ recovery: { file: result.file, errorRanges: result.errorRanges },
80
+ }
81
+ : { kind: "completed", data };
75
82
  } catch (error) {
76
83
  if (isCodeRequestInterruption(error, input.requestControl)) throw error;
77
84
  return unavailableCodeQuery(failureReason("Structural node lookup", error));
@@ -84,14 +91,21 @@ async function collectEnclosingSymbol(
84
91
  if (!input.structural) return unavailableCodeQuery("No structural outline provider is active.");
85
92
  try {
86
93
  const result = await input.structural.outline(input.file, input.requestControl);
87
- if (result.kind !== "success") return unavailableCodeQuery(result.message);
88
- return {
89
- kind: "completed",
90
- data: narrowestEnclosingSymbol(result.data, {
91
- line: input.line,
92
- character: input.character,
93
- }),
94
- };
94
+ if (result.kind !== "success" && result.kind !== "partial") {
95
+ return unavailableCodeQuery(result.message);
96
+ }
97
+ const symbol = narrowestEnclosingSymbol(result.data, {
98
+ line: input.line,
99
+ character: input.character,
100
+ });
101
+ return result.kind === "partial"
102
+ ? {
103
+ kind: "partial",
104
+ data: symbol,
105
+ reason: result.reason,
106
+ recovery: { file: result.file, errorRanges: result.errorRanges },
107
+ }
108
+ : { kind: "completed", data: symbol };
95
109
  } catch (error) {
96
110
  if (isCodeRequestInterruption(error, input.requestControl)) throw error;
97
111
  return unavailableCodeQuery(failureReason("Structural outline lookup", error));
@@ -209,6 +223,7 @@ function flattenOutline(
209
223
  const candidate: OutlineCandidate = {
210
224
  name: item.name,
211
225
  kind: item.kind,
226
+ ...(item.nativeKind ? { nativeKind: item.nativeKind } : {}),
212
227
  startLine: item.startLine,
213
228
  startCharacter: item.startCharacter,
214
229
  endLine: item.endLine,
@@ -1,4 +1,8 @@
1
- import type { CodeQueryResult, ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
1
+ import type {
2
+ CodeQueryResult,
3
+ ConfidenceMode,
4
+ SourceRange,
5
+ } from "@mrclrchtr/supi-code-runtime/api";
2
6
  import type { SourcePointInput } from "./target-input.ts";
3
7
 
4
8
  /** Canonical code_inspect workflow input. */
@@ -7,7 +11,9 @@ export interface InspectWorkflowInput {
7
11
  readonly maxResults?: number;
8
12
  }
9
13
 
10
- export type InspectObservation<T> = CodeQueryResult<T>;
14
+ export type InspectObservation<T> = CodeQueryResult<T> & {
15
+ readonly recovery?: { readonly file: string; readonly errorRanges: readonly SourceRange[] };
16
+ };
11
17
 
12
18
  export interface InspectNode {
13
19
  readonly type: string;
@@ -28,6 +34,7 @@ export interface InspectNode {
28
34
  export interface InspectEnclosingSymbol {
29
35
  readonly name: string;
30
36
  readonly kind: string;
37
+ readonly nativeKind?: string;
31
38
  readonly startLine: number;
32
39
  readonly startCharacter: number;
33
40
  readonly endLine: number;