@mrclrchtr/supi-code-intelligence 11.3.0 → 11.4.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 (66) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +3 -3
  3. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +2 -1
  5. package/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
  6. package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -5
  7. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  8. package/node_modules/@mrclrchtr/supi-lsp/README.md +1 -1
  9. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  10. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +2 -1
  11. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -5
  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/semver/classes/range.js +2 -2
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +30 -0
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +1 -1
  18. package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  19. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +10 -0
  20. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-typescript-coverage.ts +118 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +64 -2
  22. package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +87 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +22 -17
  24. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +49 -4
  25. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +1 -1
  26. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  27. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +2 -1
  28. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
  29. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -5
  30. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  31. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  32. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
  33. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +5 -1
  34. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
  35. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +5 -1
  36. package/package.json +5 -5
  37. package/src/analysis/helpers.ts +0 -7
  38. package/src/analysis/relations/implementations.ts +5 -0
  39. package/src/analysis/relations/references.ts +5 -0
  40. package/src/analysis/target/file-merge.ts +162 -0
  41. package/src/analysis/target/file-outline-omissions.ts +146 -0
  42. package/src/analysis/target/file-refinement.ts +7 -7
  43. package/src/analysis/target/file.ts +44 -156
  44. package/src/analysis/target/symbol.ts +5 -1
  45. package/src/analysis/target/types.ts +32 -6
  46. package/src/api.ts +1 -1
  47. package/src/app/app.ts +9 -3
  48. package/src/session/graph/collect.ts +2 -0
  49. package/src/session/graph-types.ts +3 -1
  50. package/src/session/graph-workflow.ts +5 -4
  51. package/src/session/orientation/workspace-context.ts +3 -0
  52. package/src/session/orientation-workflow.ts +6 -3
  53. package/src/session/refactor-workflow.ts +3 -2
  54. package/src/session/session.ts +87 -12
  55. package/src/session/target-workflow.ts +23 -21
  56. package/src/tool/code_graph/section.ts +4 -0
  57. package/src/tool/code_orientation/directory-navigation.ts +20 -31
  58. package/src/tool/code_orientation/workspace-output.ts +40 -13
  59. package/src/tool/code_orientation/workspace-sections.ts +45 -2
  60. package/src/tool/code_resolve/guidance.ts +1 -1
  61. package/src/tool/code_resolve/markdown.ts +121 -34
  62. package/src/tool/code_resolve/result.ts +18 -15
  63. package/src/tool/code_resolve/structured.ts +43 -10
  64. package/src/tool/result/model-budget.ts +2 -2
  65. package/src/tool/result/types.ts +13 -10
  66. package/src/ui/tui/common.ts +10 -10
@@ -128,6 +128,13 @@ import type {
128
128
  OutstandingDiagnosticSummaryEntry,
129
129
  ServerStatus,
130
130
  } from "./manager-types.ts";
131
+ import {
132
+ discoverTypeScriptProjectConfigs,
133
+ findSkippedImplementationProjects,
134
+ findUnloadedTypeScriptProjects,
135
+ singleProjectImplementationReason,
136
+ typeScriptCoverageGapReason,
137
+ } from "./manager-typescript-coverage.ts";
131
138
  import {
132
139
  recoverWorkspaceDiagnostics as recoverWorkspaceDiagnosticsImpl,
133
140
  type WorkspaceRecoveryResult,
@@ -141,6 +148,7 @@ import {
141
148
  workspaceSymbolCollectionResult,
142
149
  workspaceSymbolCoverageGap,
143
150
  } from "./manager-workspace-symbol.ts";
151
+ import { isFileLocalTopLevelDeclaration } from "./typescript-file-local.ts";
144
152
 
145
153
  type UnavailableReason = "missing-command" | "start-failed" | "runtime-error";
146
154
 
@@ -412,6 +420,8 @@ export class LspManager {
412
420
  private warmedSemanticProjects = new Set<string>();
413
421
  /** In-flight warm-up probes keyed by project key so concurrent callers share one probe. */
414
422
  private pendingWarmProbes = new Map<string, Promise<void>>();
423
+ /** Loadable TypeScript project configs per route root; cleared when a config changes. */
424
+ private typeScriptProjectConfigs = new Map<string, string[]>();
415
425
  /** One process-crash recovery budget and shared replacement per route. */
416
426
  private processCrashRecoveries = new Map<string, ProcessCrashRecoveryState>();
417
427
  /** Client generations that completed the initialize handshake. */
@@ -572,6 +582,53 @@ export class LspManager {
572
582
  );
573
583
  }
574
584
 
585
+ /**
586
+ * Coverage gap for a project-wide TypeScript request answered by `client`.
587
+ *
588
+ * Returns a partial-result reason when a TypeScript project that includes
589
+ * `filePath` owns neither an open file nor a file in `resultFiles`, so
590
+ * tsserver may not have searched it; otherwise null. Non-TypeScript routes
591
+ * always return null.
592
+ *
593
+ * Implementation requests not known to use the native backend report every
594
+ * other project instead: tsserver searches only the file's own project.
595
+ *
596
+ * No gap applies when `position` (zero-based) names a top-level declaration
597
+ * its module does not export: no other project can reference it.
598
+ */
599
+ typeScriptProjectCoverageGap(
600
+ client: LspClient,
601
+ filePath: string,
602
+ request: "references" | "implementation",
603
+ evidence: {
604
+ readonly resultFiles?: readonly string[];
605
+ readonly position?: { readonly line: number; readonly character: number };
606
+ } = {},
607
+ ): string | null {
608
+ const { resultFiles = [], position } = evidence;
609
+ if (client.name !== "typescript") return null;
610
+ const rootKey = path.resolve(client.root);
611
+ let configs = this.typeScriptProjectConfigs.get(rootKey);
612
+ if (!configs) {
613
+ configs = discoverTypeScriptProjectConfigs(rootKey, this.automaticPathPolicy);
614
+ this.typeScriptProjectConfigs.set(rootKey, configs);
615
+ }
616
+ const file = resolveSessionPath(this.cwd, filePath);
617
+ if (position && isFileLocalTopLevelDeclaration(file, position)) return null;
618
+ if (request === "implementation" && client.typescriptSelection?.backend !== "native") {
619
+ const skipped = findSkippedImplementationProjects({ file, cwd: this.cwd, configs });
620
+ return skipped.length > 0 ? singleProjectImplementationReason(skipped) : null;
621
+ }
622
+ const unloaded = findUnloadedTypeScriptProjects({
623
+ file,
624
+ cwd: this.cwd,
625
+ openFiles: client.openFiles,
626
+ resultFiles,
627
+ configs,
628
+ });
629
+ return unloaded.length > 0 ? typeScriptCoverageGapReason(unloaded, this.cwd) : null;
630
+ }
631
+
575
632
  /** Get or create an LSP client for the given file. */
576
633
  async getClientForFile(
577
634
  filePath: string,
@@ -2397,7 +2454,7 @@ export class LspManager {
2397
2454
  */
2398
2455
  noteWorkspaceChanges(changes: FileEvent[]): void {
2399
2456
  if (changes.length > 0) this.invalidationEpoch++;
2400
- invalidateProjectConfigCaches(changes);
2457
+ if (invalidateProjectConfigCaches(changes)) this.typeScriptProjectConfigs.clear();
2401
2458
  this.notifyWorkspaceFileChanges(changes);
2402
2459
  }
2403
2460
 
@@ -2586,6 +2643,7 @@ export class LspManager {
2586
2643
  this.warmedWorkspaceSymbolFiles.clear();
2587
2644
  this.warmedSemanticProjects.clear();
2588
2645
  this.pendingWarmProbes.clear();
2646
+ this.typeScriptProjectConfigs.clear();
2589
2647
  this.pendingRestarts.clear();
2590
2648
  }
2591
2649
  /** Get status of all servers. */
@@ -3437,15 +3495,19 @@ export class LspManager {
3437
3495
  }
3438
3496
  }
3439
3497
 
3440
- function invalidateProjectConfigCaches(changes: readonly FileEvent[]): void {
3498
+ /** Invalidate parsed project configs; returns whether any config changed. */
3499
+ function invalidateProjectConfigCaches(changes: readonly FileEvent[]): boolean {
3500
+ let changed = false;
3441
3501
  for (const change of changes) {
3442
3502
  const configPath = uriToFile(change.uri);
3443
3503
  if (!isProjectConfigFileName(path.basename(configPath))) continue;
3504
+ changed = true;
3444
3505
  invalidateTsconfigCacheForConfig(configPath);
3445
3506
  if (change.type === FileChangeType.Created) {
3446
3507
  invalidateTsconfigCacheForConfigDir(path.dirname(configPath));
3447
3508
  }
3448
3509
  }
3510
+ return changed;
3449
3511
  }
3450
3512
 
3451
3513
  function collectClientDiagnosticEvidenceDocuments(
@@ -0,0 +1,87 @@
1
+ import * as fs from "node:fs";
2
+ import ts from "typescript";
3
+
4
+ /**
5
+ * Whether the identifier at `position` names a top-level declaration that only
6
+ * its own file can reference: the file is an ES module and the declaration is
7
+ * neither exported by a modifier nor by an export clause or assignment.
8
+ *
9
+ * Other TypeScript projects can then hold no references or implementations,
10
+ * so a project coverage gap cannot apply. Script files (no import or export),
11
+ * members, unreadable files, and non-declaration positions return false.
12
+ *
13
+ * @param position Zero-based LSP position.
14
+ */
15
+ export function isFileLocalTopLevelDeclaration(
16
+ filePath: string,
17
+ position: { readonly line: number; readonly character: number },
18
+ ): boolean {
19
+ let text: string;
20
+ try {
21
+ text = fs.readFileSync(filePath, "utf8");
22
+ } catch {
23
+ return false;
24
+ }
25
+ const sourceFile = ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true);
26
+ if (!ts.isExternalModule(sourceFile)) return false;
27
+ let offset: number;
28
+ try {
29
+ offset = ts.getPositionOfLineAndCharacter(sourceFile, position.line, position.character);
30
+ } catch {
31
+ return false;
32
+ }
33
+ const statement = sourceFile.statements.find(
34
+ (candidate) => candidate.getStart(sourceFile) <= offset && offset < candidate.end,
35
+ );
36
+ if (!statement) return false;
37
+ const name = topLevelDeclarationNameAt(statement, offset, sourceFile);
38
+ return name !== null && !hasExportModifier(statement) && !exportedByName(sourceFile, name);
39
+ }
40
+
41
+ /** Name of the declaration `statement` declares at `offset`, or null. */
42
+ function topLevelDeclarationNameAt(
43
+ statement: ts.Statement,
44
+ offset: number,
45
+ sourceFile: ts.SourceFile,
46
+ ): string | null {
47
+ const names: ts.Identifier[] = [];
48
+ if (
49
+ ts.isFunctionDeclaration(statement) ||
50
+ ts.isClassDeclaration(statement) ||
51
+ ts.isInterfaceDeclaration(statement) ||
52
+ ts.isTypeAliasDeclaration(statement) ||
53
+ ts.isEnumDeclaration(statement)
54
+ ) {
55
+ if (statement.name) names.push(statement.name);
56
+ } else if (ts.isVariableStatement(statement)) {
57
+ for (const declaration of statement.declarationList.declarations) {
58
+ if (ts.isIdentifier(declaration.name)) names.push(declaration.name);
59
+ }
60
+ }
61
+ const hit = names.find((name) => name.getStart(sourceFile) <= offset && offset <= name.end);
62
+ return hit ? hit.text : null;
63
+ }
64
+
65
+ function hasExportModifier(statement: ts.Statement): boolean {
66
+ return (
67
+ ts.canHaveModifiers(statement) &&
68
+ (ts.getModifiers(statement) ?? []).some(
69
+ (modifier) =>
70
+ modifier.kind === ts.SyntaxKind.ExportKeyword ||
71
+ modifier.kind === ts.SyntaxKind.DeclareKeyword,
72
+ )
73
+ );
74
+ }
75
+
76
+ /** `export { name }`, `export default name`, or `export = name` in this file. */
77
+ function exportedByName(sourceFile: ts.SourceFile, name: string): boolean {
78
+ return sourceFile.statements.some((statement) => {
79
+ if (ts.isExportAssignment(statement)) {
80
+ return ts.isIdentifier(statement.expression) && statement.expression.text === name;
81
+ }
82
+ if (!ts.isExportDeclaration(statement) || statement.moduleSpecifier) return false;
83
+ const clause = statement.exportClause;
84
+ if (!clause || !ts.isNamedExports(clause)) return false;
85
+ return clause.elements.some((element) => (element.propertyName ?? element.name).text === name);
86
+ });
87
+ }
@@ -2,10 +2,11 @@ import { readFile } from "node:fs/promises";
2
2
  import type {
3
3
  CodeLocation,
4
4
  CodeSymbol,
5
- DeclarationNesting,
5
+ DeclarationLevel,
6
6
  DocumentCodeSymbol,
7
7
  SourceRange,
8
8
  } from "@mrclrchtr/supi-code-runtime/api";
9
+ import { childDeclarationLevel } from "@mrclrchtr/supi-code-runtime/api";
9
10
  import { uriToFile } from "@mrclrchtr/supi-core/path";
10
11
  import type {
11
12
  DocumentSymbol,
@@ -100,15 +101,26 @@ export async function mapDocumentSymbols(
100
101
  ): Promise<DocumentCodeSymbol[]> {
101
102
  return flattenDocumentSymbols(symbols, filePath, null, {
102
103
  sourceLines: await readSourceLines(filePath),
103
- nesting: "top-level",
104
+ parent: null,
104
105
  });
105
106
  }
106
107
 
108
+ /** Level of a symbol reported inside `parent`, or top-level without one. */
109
+ function levelWithin(
110
+ parent: { readonly kind: string; readonly level: DeclarationLevel } | null,
111
+ kind: string,
112
+ ): DeclarationLevel {
113
+ return parent ? childDeclarationLevel(parent, kind) : "top-level";
114
+ }
115
+
107
116
  function flattenDocumentSymbols(
108
117
  symbols: DocumentSymbol[] | SymbolInformation[],
109
118
  filePath: string,
110
119
  container: string | null,
111
- context: { sourceLines: readonly string[] | null; nesting: DeclarationNesting },
120
+ context: {
121
+ sourceLines: readonly string[] | null;
122
+ parent: { readonly kind: string; readonly level: DeclarationLevel } | null;
123
+ },
112
124
  ): DocumentCodeSymbol[] {
113
125
  const result: DocumentCodeSymbol[] = [];
114
126
  for (const sym of symbols) {
@@ -116,15 +128,13 @@ function flattenDocumentSymbols(
116
128
  let document: DocumentSymbol | null = null;
117
129
  if (isSymbolInformation(sym)) information = sym;
118
130
  else document = sym;
131
+ const kind = symbolKindName(sym.kind);
132
+ const level = information ? "unknown" : levelWithin(context.parent, kind);
133
+ const childContext = { sourceLines: context.sourceLines, parent: { kind, level } };
119
134
  const declarationRange = toValidRange(document?.range ?? information?.location.range);
120
135
  if (!declarationRange) {
121
136
  if (document?.children?.length) {
122
- result.push(
123
- ...flattenDocumentSymbols(document.children, filePath, sym.name, {
124
- sourceLines: context.sourceLines,
125
- nesting: "nested",
126
- }),
127
- );
137
+ result.push(...flattenDocumentSymbols(document.children, filePath, sym.name, childContext));
128
138
  }
129
139
  continue;
130
140
  }
@@ -134,23 +144,18 @@ function flattenDocumentSymbols(
134
144
  : null;
135
145
  const symbol: DocumentCodeSymbol = {
136
146
  name: sym.name,
137
- kind: symbolKindName(sym.kind),
147
+ kind,
138
148
  file: filePath,
139
149
  declarationAnchor: { line: declStart.line + 1, character: declStart.character + 1 },
140
150
  container: information?.containerName ?? container,
141
- nesting: information ? "unknown" : context.nesting,
151
+ level,
142
152
  };
143
153
  if (nameStart) {
144
154
  symbol.nameAnchor = { line: nameStart.line + 1, character: nameStart.character + 1 };
145
155
  }
146
156
  result.push(symbol);
147
157
  if (document?.children?.length) {
148
- result.push(
149
- ...flattenDocumentSymbols(document.children, filePath, sym.name, {
150
- sourceLines: context.sourceLines,
151
- nesting: "nested",
152
- }),
153
- );
158
+ result.push(...flattenDocumentSymbols(document.children, filePath, sym.name, childContext));
154
159
  }
155
160
  }
156
161
  return result;
@@ -1,11 +1,13 @@
1
1
  // Shared session-scoped LSP service registry reused by peer extensions.
2
2
 
3
3
  // biome-ignore lint/style/noExcessiveLinesPerFile: session registry, runtime recovery, and telemetry stay in one file; splitting would hide the recovery contract.
4
+ import { fileURLToPath } from "node:url";
4
5
  import {
5
6
  type CodeQueryResult,
6
7
  type CodeRequestControl,
7
8
  isCodeRequestInterruption,
8
9
  mapCodeQueryResult,
10
+ partialCodeQuery,
9
11
  throwIfCodeRequestInterrupted,
10
12
  unavailableCodeQuery,
11
13
  } from "@mrclrchtr/supi-code-runtime/api";
@@ -193,9 +195,14 @@ class DefaultWorkspaceLspRuntime implements WorkspaceLspRuntime {
193
195
  control,
194
196
  });
195
197
  if (!client) return unavailableFileQuery("references", resolvedPath);
196
- return mapCodeQueryResult(
197
- await client.references(resolvedPath, position, control),
198
- (data) => data ?? [],
198
+ return this.withProjectCoverage(
199
+ client,
200
+ { file: resolvedPath, position },
201
+ "references",
202
+ mapCodeQueryResult(
203
+ await client.references(resolvedPath, position, control),
204
+ (data) => data ?? [],
205
+ ),
199
206
  );
200
207
  }
201
208
 
@@ -211,7 +218,30 @@ class DefaultWorkspaceLspRuntime implements WorkspaceLspRuntime {
211
218
  control,
212
219
  });
213
220
  if (!client) return unavailableFileQuery("implementation", resolvedPath);
214
- return client.implementation(resolvedPath, position, control);
221
+ return this.withProjectCoverage(
222
+ client,
223
+ { file: resolvedPath, position },
224
+ "implementation",
225
+ await client.implementation(resolvedPath, position, control),
226
+ );
227
+ }
228
+
229
+ /**
230
+ * Downgrade a completed project-wide answer to partial when the TypeScript
231
+ * server may not have searched every relevant project.
232
+ */
233
+ private withProjectCoverage<T extends Location[] | Location | LocationLink[] | null>(
234
+ client: NonNullable<Awaited<ReturnType<LspManager["ensureFileOpen"]>>>,
235
+ target: { readonly file: string; readonly position: Position },
236
+ request: "references" | "implementation",
237
+ result: CodeQueryResult<T>,
238
+ ): CodeQueryResult<T> {
239
+ if (result.kind !== "completed") return result;
240
+ const gap = this.manager.typeScriptProjectCoverageGap(client, target.file, request, {
241
+ resultFiles: locationFiles(result.data),
242
+ position: target.position,
243
+ });
244
+ return gap ? partialCodeQuery(result.data, gap) : result;
215
245
  }
216
246
 
217
247
  async documentSymbols(
@@ -605,6 +635,21 @@ export async function waitForWorkspaceLspRuntime(
605
635
  return state;
606
636
  }
607
637
 
638
+ /** Local file paths of LSP locations or location links; non-file URIs are skipped. */
639
+ function locationFiles(data: Location[] | Location | LocationLink[] | null): string[] {
640
+ const items: (Location | LocationLink)[] =
641
+ data === null ? [] : Array.isArray(data) ? data : [data];
642
+ return items.flatMap((item) => {
643
+ const uri = "targetUri" in item ? item.targetUri : item.uri;
644
+ if (!uri.startsWith("file:")) return [];
645
+ try {
646
+ return [fileURLToPath(uri)];
647
+ } catch {
648
+ return [];
649
+ }
650
+ });
651
+ }
652
+
608
653
  /** Remove the LSP service state for a session cwd. */
609
654
  export function clearWorkspaceLspRuntime(cwd: string): void {
610
655
  registry.clear(cwd);
@@ -82,7 +82,7 @@ The `type` filter accepts `class`, `interface`, `type`, `enum`, `struct`, `union
82
82
  ### Extraction limits
83
83
 
84
84
  - TS/JS, Python, Java, Go, Rust, and C/C++ outlines include nested named declarations and members. They are not complete indexes of local variables, parameters, or anonymous expressions. Other languages retain their existing extraction depth. HTML outlines list only elements with non-empty `id` attributes. SQL outlines list supported `CREATE` declarations and first-level table/type members. LaTeX outlines list section headings and selected command, environment, label, acronym, glossary-entry, and color definitions.
85
- - TypeScript and TSX use [checked build-time grammar patches](scripts/generate-typescript-wasm.mjs) for type-only star re-exports, arrays of qualified import types such as `import("node:fs").Dirent[]`, and import types in generic calls such as `read<import("./api").Value>()` or `read<typeof import("./api")>()`. Runtime parsing retains the original source and coordinates; other grammar gaps still report recovered syntax.
85
+ - TypeScript and TSX use [checked build-time grammar patches](scripts/generate-typescript-wasm.mjs) for type-only star re-exports, arrays of qualified import types such as `import("node:fs").Dirent[]`, import types in generic calls such as `read<import("./api").Value>()` or `read<typeof import("./api")>()`, and import types with type arguments such as `import("typebox").Static<T>`. Runtime parsing retains the original source and coordinates; other grammar gaps still report recovered syntax.
86
86
  - JavaScript-family imports collect `import` statements, not CommonJS `require()` calls. Exports collect file-level `export` statements, including TypeScript `export =`; they do not collect `module.exports` assignments or nested namespace exports. An eligible `.cjs` file can therefore return no imports or exports.
87
87
  - Python imports retain `import`/`from` module targets, including relative prefixes. Java imports retain ordinary/static targets. Go imports retain single/grouped paths. Rust imports retain explicit `use` paths, `extern crate`, and external `mod` names; inline module bodies are not imports. C/C++ imports retain literal quoted and angle-bracket include targets. Grouped paths use explicit syntax only; no files or bindings are resolved. Conditional directives are written evidence, not proof of active dependencies. Dynamic loaders, computed targets, and C++20 module imports remain outside extraction support.
88
88
  - LaTeX imports include package, class, source, and bibliography directives. Bibliography directives can refer to `.bib` files, but the grammar does not parse those files.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-code-runtime",
3
- "version": "11.3.0",
3
+ "version": "11.4.0",
4
4
  "description": "Shared workspace context and capability contracts for code intelligence",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,6 +14,7 @@ export type {
14
14
  StructuralProvider,
15
15
  StructuralResult,
16
16
  } from "./capability/types.ts";
17
+ export { childDeclarationLevel } from "./declaration-level.ts";
17
18
  export type {
18
19
  CFamilyExtension,
19
20
  CFamilyFileAssociationResolver,
@@ -50,7 +51,7 @@ export type {
50
51
  CodeResult,
51
52
  CodeSymbol,
52
53
  ConfidenceMode,
53
- DeclarationNesting,
54
+ DeclarationLevel,
54
55
  DisambiguationCandidate,
55
56
  DocumentCodeSymbol,
56
57
  DocumentEditPrecondition,
@@ -0,0 +1,34 @@
1
+ import type { DeclarationLevel } from "./types.ts";
2
+
3
+ /** Declarations whose body holds statements, so nested declarations are local to it. */
4
+ const FUNCTION_LIKE_KINDS = new Set(["function", "method", "constructor"]);
5
+ /** Bindings whose value may be a function (locals) or an object literal (members). */
6
+ const VALUE_BINDING_KINDS = new Set(["variable", "constant", "property", "field"]);
7
+ /** Kinds that name an entry of an object, type, or enum rather than a statement-level binding. */
8
+ const MEMBER_ENTRY_KINDS = new Set(["property", "field", "method", "enummember", "key", "event"]);
9
+
10
+ /**
11
+ * Level of a declaration reported directly inside `parent`.
12
+ *
13
+ * Inside a local declaration everything stays local. A function, method, or
14
+ * constructor makes its nested declarations local. A variable, constant,
15
+ * property, or field holds either a function body (nested bindings are local)
16
+ * or an object literal (nested properties and methods are members). Every
17
+ * other container — class, interface, enum, struct, namespace, module, or a
18
+ * document section — makes its nested declarations members.
19
+ *
20
+ * Kinds compare case-insensitively, so LSP SymbolKind names and Tree-sitter
21
+ * outline kinds share one rule.
22
+ */
23
+ export function childDeclarationLevel(
24
+ parent: { readonly kind: string | null; readonly level: DeclarationLevel },
25
+ childKind: string | null,
26
+ ): Exclude<DeclarationLevel, "top-level" | "unknown"> {
27
+ if (parent.level === "local") return "local";
28
+ const parentKind = parent.kind?.toLowerCase() ?? "";
29
+ if (FUNCTION_LIKE_KINDS.has(parentKind)) return "local";
30
+ if (VALUE_BINDING_KINDS.has(parentKind)) {
31
+ return MEMBER_ENTRY_KINDS.has(childKind?.toLowerCase() ?? "") ? "member" : "local";
32
+ }
33
+ return "member";
34
+ }
@@ -34,8 +34,16 @@ export interface SymbolAnchor {
34
34
  character: number;
35
35
  }
36
36
 
37
- /** Provider-backed nesting evidence for a declaration reported within one document. */
38
- export type DeclarationNesting = "top-level" | "nested" | "unknown";
37
+ /**
38
+ * Where a declaration sits within its file, as reported by a provider.
39
+ *
40
+ * - `top-level`: directly in the file, not inside another declaration.
41
+ * - `member`: directly inside a class, interface, enum, struct, namespace,
42
+ * module, or object literal (methods, fields, properties, enum members).
43
+ * - `local`: inside the body of a function, method, or constructor.
44
+ * - `unknown`: the provider reported a flat symbol list without hierarchy.
45
+ */
46
+ export type DeclarationLevel = "top-level" | "member" | "local" | "unknown";
39
47
 
40
48
  /**
41
49
  * A discovered symbol / declaration.
@@ -54,7 +62,7 @@ export interface CodeSymbol {
54
62
  file: string;
55
63
  declarationAnchor: SymbolAnchor;
56
64
  nameAnchor?: SymbolAnchor;
57
- /** Named symbolic container when reported; absence does not prove top-level nesting. */
65
+ /** Named enclosing declaration when reported; absence does not prove a top-level declaration. */
58
66
  container?: string | null;
59
67
  }
60
68
 
@@ -63,10 +71,10 @@ export interface CodeSymbol {
63
71
  *
64
72
  * `unknown` means the provider returned a flat observation without an actual
65
73
  * hierarchy. A reported container name remains metadata and does not promote
66
- * a flat observation to known nesting.
74
+ * a flat observation to a known level.
67
75
  */
68
76
  export interface DocumentCodeSymbol extends CodeSymbol {
69
- nesting: DeclarationNesting;
77
+ level: DeclarationLevel;
70
78
  }
71
79
 
72
80
  // ── Result types ───────────────────────────────────────────────────────
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "11.3.0",
3
+ "version": "11.4.0",
4
4
  "description": "Shared settings, configuration, reporting, and session infrastructure",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-tree-sitter",
3
- "version": "11.3.0",
3
+ "version": "11.4.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-code-runtime": "11.3.0",
40
- "@mrclrchtr/supi-core": "11.3.0"
39
+ "@mrclrchtr/supi-code-runtime": "11.4.0",
40
+ "@mrclrchtr/supi-core": "11.4.0"
41
41
  },
42
42
  "bundledDependencies": [
43
43
  "@mrclrchtr/supi-code-runtime",
@@ -22,7 +22,11 @@
22
22
  {
23
23
  "id": "import-type-generic-calls-v1",
24
24
  "file": "common/define-grammar.js"
25
+ },
26
+ {
27
+ "id": "import-type-member-type-arguments-v1",
28
+ "file": "common/define-grammar.js"
25
29
  }
26
30
  ],
27
- "sha256": "aaa2904a00000d8e058708845172bd3ce7836566c7e16e9ee594c43f4ba4f451"
31
+ "sha256": "7c7552ea30a3a6785826e26c12c9dd33410ac577d9cb09a4fa5cf5701665abd8"
28
32
  }
@@ -22,7 +22,11 @@
22
22
  {
23
23
  "id": "import-type-generic-calls-v1",
24
24
  "file": "common/define-grammar.js"
25
+ },
26
+ {
27
+ "id": "import-type-member-type-arguments-v1",
28
+ "file": "common/define-grammar.js"
25
29
  }
26
30
  ],
27
- "sha256": "86ba3af6f8214c90f32af1ea82214a0c1da87c9e2f5ea47c19577ba5b6c78bfb"
31
+ "sha256": "d9e67877e2da665b26ab837bccd036e267cf1b5f521073e76352ec4af22ded4c"
28
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-code-intelligence",
3
- "version": "11.3.0",
3
+ "version": "11.4.0",
4
4
  "description": "LSP and AST navigation, search, diagnostics, and refactoring",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,10 +43,10 @@
43
43
  "ignore": "^7.0.12",
44
44
  "smol-toml": "^1.9.1",
45
45
  "yaml": "^2.9.0",
46
- "@mrclrchtr/supi-code-runtime": "11.3.0",
47
- "@mrclrchtr/supi-lsp": "11.3.0",
48
- "@mrclrchtr/supi-tree-sitter": "11.3.0",
49
- "@mrclrchtr/supi-core": "11.3.0"
46
+ "@mrclrchtr/supi-lsp": "11.4.0",
47
+ "@mrclrchtr/supi-tree-sitter": "11.4.0",
48
+ "@mrclrchtr/supi-core": "11.4.0",
49
+ "@mrclrchtr/supi-code-runtime": "11.4.0"
50
50
  },
51
51
  "bundledDependencies": [
52
52
  "@mrclrchtr/supi-code-runtime",
@@ -1,17 +1,10 @@
1
1
  import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
2
- import type { ResolvedTargetData, ResolvedTargetGroupData } from "./target/types.ts";
3
2
 
4
3
  interface FileLineRef {
5
4
  file: string;
6
5
  line: number;
7
6
  }
8
7
 
9
- export function isResolvedTargetGroup(
10
- target: ResolvedTargetData | ResolvedTargetGroupData,
11
- ): target is ResolvedTargetGroupData {
12
- return "targets" in target;
13
- }
14
-
15
8
  export function highestConfidence(confidences: ConfidenceMode[]): ConfidenceMode {
16
9
  if (confidences.includes("semantic")) return "semantic";
17
10
  if (confidences.includes("structural")) return "structural";
@@ -18,6 +18,8 @@ interface ImplementationsResultBase {
18
18
  /** Provider locations omitted because their URI or position was unusable. */
19
19
  invalidLocationCount: number;
20
20
  partialReason: RelationLocationPartialReason | null;
21
+ /** Provider explanation when the provider reported partial collection. */
22
+ partialMessage: string | null;
21
23
  }
22
24
 
23
25
  /** An implementation lookup result with a reason on every unavailable outcome. */
@@ -43,6 +45,7 @@ export async function collectImplementations(
43
45
  externalCount: 0,
44
46
  invalidLocationCount: 0,
45
47
  partialReason: null,
48
+ partialMessage: null,
46
49
  confidence: "unavailable",
47
50
  message: "No semantic implementations provider",
48
51
  };
@@ -57,6 +60,7 @@ export async function collectImplementations(
57
60
  externalCount: 0,
58
61
  invalidLocationCount: 0,
59
62
  partialReason: null,
63
+ partialMessage: null,
60
64
  confidence: "unavailable",
61
65
  message: result.reason,
62
66
  };
@@ -79,6 +83,7 @@ export async function collectImplementations(
79
83
  externalCount: normalized.external.length,
80
84
  invalidLocationCount: normalized.invalidLocationCount,
81
85
  partialReason: result.kind === "partial" ? "provider-limited" : normalized.partialReason,
86
+ partialMessage: result.kind === "partial" ? result.reason : null,
82
87
  confidence: "semantic",
83
88
  };
84
89
  }
@@ -21,6 +21,8 @@ interface CallerEvidenceData {
21
21
  /** Provider locations omitted because their URI or position was unusable. */
22
22
  invalidLocationCount: number;
23
23
  partialReason: RelationLocationPartialReason | null;
24
+ /** Provider explanation when the provider reported partial collection. */
25
+ partialMessage: string | null;
24
26
  evidence: CallerEvidence;
25
27
  }
26
28
 
@@ -47,6 +49,7 @@ export async function collectCallers(
47
49
  externalCount: 0,
48
50
  invalidLocationCount: 0,
49
51
  partialReason: null,
52
+ partialMessage: null,
50
53
  evidence: "semantic-references",
51
54
  confidence: "unavailable",
52
55
  message: "No semantic references provider",
@@ -62,6 +65,7 @@ export async function collectCallers(
62
65
  externalCount: 0,
63
66
  invalidLocationCount: 0,
64
67
  partialReason: null,
68
+ partialMessage: null,
65
69
  evidence: "semantic-references",
66
70
  confidence: "unavailable",
67
71
  message: result.reason,
@@ -83,6 +87,7 @@ export async function collectCallers(
83
87
  externalCount: normalized.external.length,
84
88
  invalidLocationCount: normalized.invalidLocationCount,
85
89
  partialReason: result.kind === "partial" ? "provider-limited" : normalized.partialReason,
90
+ partialMessage: result.kind === "partial" ? result.reason : null,
86
91
  evidence: "semantic-references",
87
92
  confidence: "semantic",
88
93
  };