@mrclrchtr/supi-code-intelligence 6.1.0 → 6.3.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 (141) hide show
  1. package/README.md +3 -1
  2. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  3. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-core/src/debug-identity.ts +11 -0
  5. package/node_modules/@mrclrchtr/supi-core/src/debug.ts +5 -0
  6. package/node_modules/@mrclrchtr/supi-lsp/README.md +23 -3
  7. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  8. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  9. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-identity.ts +11 -0
  10. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug.ts +5 -0
  11. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/README.md +52 -0
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/index.js +785 -129
  13. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/legacy.js +660 -98
  14. package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/package.json +10 -4
  15. package/node_modules/@mrclrchtr/supi-lsp/package.json +4 -5
  16. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +16 -7
  17. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +1 -1
  18. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +0 -5
  19. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-publication.ts +6 -3
  20. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +2 -1
  21. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +5 -2
  22. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +2 -1
  23. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +17 -5
  24. package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +40 -18
  25. package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +164 -30
  26. package/node_modules/@mrclrchtr/supi-lsp/src/config/lsp-settings.ts +9 -87
  27. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +0 -1
  28. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +4 -5
  29. package/node_modules/@mrclrchtr/supi-lsp/src/config/types.ts +0 -29
  30. package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +7 -21
  31. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostic-severity.ts +6 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/diagnostic-summary.ts +11 -14
  33. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +0 -5
  34. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/stale-diagnostics.ts +0 -1
  35. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/workspace-sentinels.ts +29 -49
  36. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +1 -1
  37. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-diagnostics.ts +4 -8
  38. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-helpers.ts +1 -9
  39. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-process-crash-report.ts +106 -0
  40. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +6 -3
  41. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-recovery.ts +9 -1
  42. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +26 -41
  43. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +577 -152
  44. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +4 -1
  45. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +59 -28
  46. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +27 -19
  47. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +54 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registration.ts +0 -17
  49. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +74 -19
  50. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +5 -2
  51. package/node_modules/@mrclrchtr/supi-lsp/src/session/scanner.ts +24 -21
  52. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +29 -3
  53. package/node_modules/@mrclrchtr/supi-lsp/src/summary.ts +19 -40
  54. package/node_modules/@mrclrchtr/supi-lsp/src/utils.ts +13 -19
  55. package/node_modules/@mrclrchtr/supi-lsp/src/workspace-path-policy.ts +296 -0
  56. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +6 -18
  57. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  58. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  59. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-identity.ts +11 -0
  60. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug.ts +5 -0
  61. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/README.md +29 -1
  62. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs +99 -19
  63. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.cjs.map +4 -4
  64. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js +94 -18
  65. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.js.map +4 -4
  66. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
  67. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +14 -14
  68. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +13 -8
  69. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs +97 -19
  70. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.cjs.map +4 -4
  71. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts +28 -8
  72. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.cts.map +1 -1
  73. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts +28 -8
  74. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.d.ts.map +1 -1
  75. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js +92 -18
  76. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.js.map +4 -4
  77. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
  78. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +17 -17
  79. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +7 -6
  80. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm +0 -0
  81. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +2 -2
  82. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm +0 -0
  83. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +2 -2
  84. package/node_modules/@mrclrchtr/supi-tree-sitter/src/api.ts +1 -11
  85. package/node_modules/@mrclrchtr/supi-tree-sitter/src/coordinates.ts +19 -0
  86. package/node_modules/@mrclrchtr/supi-tree-sitter/src/language.ts +5 -23
  87. package/node_modules/@mrclrchtr/supi-tree-sitter/src/operation-support.ts +3 -21
  88. package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +5 -9
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +10 -20
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +7 -1
  91. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +9 -5
  92. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +134 -9
  93. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-name.ts +96 -0
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +11 -12
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +39 -56
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +9 -7
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/js-binding-pattern.ts +26 -0
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/node-at.ts +2 -21
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-html-sql.ts +144 -12
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline.ts +50 -37
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/scope.ts +138 -0
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +0 -7
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store.ts +1 -14
  104. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +0 -10
  105. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/service.ts +6 -8
  106. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/worker-main.ts +34 -10
  107. package/package.json +5 -5
  108. package/src/analysis/capability/capability-warnings.ts +4 -22
  109. package/src/analysis/search/ast-scan-timing.ts +4 -2
  110. package/src/analysis/search/ast-scan.ts +1 -1
  111. package/src/api.ts +1 -0
  112. package/src/extension.ts +4 -2
  113. package/src/session/health-refresh.ts +26 -2
  114. package/src/session/health-types.ts +19 -0
  115. package/src/session/input/health-refactor.ts +16 -14
  116. package/src/session/refactor-types.ts +14 -1
  117. package/src/session/refactor-workflow.ts +21 -16
  118. package/src/substrate/lsp/lifecycle.ts +0 -3
  119. package/src/substrate/lsp/maintenance.ts +4 -5
  120. package/src/substrate/lsp/settings.ts +7 -9
  121. package/src/substrate/lsp/state.ts +0 -2
  122. package/src/substrate/workspace-provider-host.ts +2 -2
  123. package/src/tool/code_health/file-scope-markdown.ts +43 -0
  124. package/src/tool/code_health/markdown.ts +66 -66
  125. package/src/tool/code_health/refresh-outcome.ts +76 -0
  126. package/src/tool/code_health/refresh-status.ts +212 -23
  127. package/src/tool/code_health/result.ts +1 -0
  128. package/src/tool/code_health/tui.ts +18 -5
  129. package/src/tool/code_refactor_apply/guidance.ts +3 -2
  130. package/src/tool/code_refactor_plan/guidance.ts +1 -1
  131. package/src/tool/register.ts +5 -2
  132. package/src/tool/schemas.ts +21 -11
  133. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-actions.ts +0 -59
  134. package/node_modules/@mrclrchtr/supi-lsp/src/pattern-matcher.ts +0 -24
  135. package/node_modules/@mrclrchtr/supi-tree-sitter/scripts/generate-kotlin-wasm.mjs +0 -132
  136. package/node_modules/@mrclrchtr/supi-tree-sitter/scripts/generate-sql-wasm.mjs +0 -158
  137. package/node_modules/@mrclrchtr/supi-tree-sitter/scripts/vendor-wasm.mjs +0 -167
  138. package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +0 -42
  139. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-registration.ts +0 -37
  140. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/service-registry.ts +0 -30
  141. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/structure.ts +0 -8
@@ -3,6 +3,7 @@
3
3
  import { nodeToRange } from "../coordinates.ts";
4
4
  import type { SyntaxNodeLike } from "../syntax-node.ts";
5
5
  import type { OutlineItem } from "../types.ts";
6
+ import { extractBindingIdentifiers } from "./js-binding-pattern.ts";
6
7
  import { extractPolyglotOutlineItems } from "./outline-polyglot.ts";
7
8
 
8
9
  /** Node types that can be extracted directly as outline items. */
@@ -18,6 +19,7 @@ const OUTLINE_DECLARATION_NODE_TYPES = new Set([
18
19
  "method_definition",
19
20
  "public_field_definition",
20
21
  "variable_declarator",
22
+ "lexical_declaration",
21
23
  "ambient_declaration",
22
24
  "internal_module",
23
25
  "module",
@@ -39,20 +41,27 @@ function collectItems(node: SyntaxNodeLike, source: string): OutlineItem[] {
39
41
  continue;
40
42
  }
41
43
 
42
- const item = extractItem(child, source);
43
- if (item) items.push(item);
44
+ const extractedItems = extractItems(child, source);
45
+ if (extractedItems) items.push(...extractedItems);
44
46
  else items.push(...collectItems(child, source));
45
47
  }
46
48
 
47
49
  return items;
48
50
  }
49
51
 
52
+ function extractItems(node: SyntaxNodeLike, source: string): OutlineItem[] | null {
53
+ if (node.type === "lexical_declaration") return extractLexicalDeclarationItems(node, source);
54
+ if (node.type === "ambient_declaration") return extractAmbientDeclarationItems(node, source);
55
+ if (node.type === "export_statement") return extractExportStatement(node, source);
56
+
57
+ const item = extractItem(node, source);
58
+ return item ? [item] : null;
59
+ }
60
+
50
61
  function extractItem(node: SyntaxNodeLike, source: string): OutlineItem | null {
51
62
  switch (node.type) {
52
- case "export_statement":
53
- return extractExportStatement(node, source);
54
63
  case "lexical_declaration":
55
- return extractLexicalDeclaration(node, source);
64
+ return extractLexicalDeclarationItems(node, source)[0] ?? null;
56
65
  case "function_declaration":
57
66
  case "generator_function_declaration":
58
67
  case "function_signature":
@@ -72,7 +81,7 @@ function extractItem(node: SyntaxNodeLike, source: string): OutlineItem | null {
72
81
  case "public_field_definition":
73
82
  return extractFieldDefinition(node, source);
74
83
  case "variable_declarator":
75
- return extractVariableDeclarator(node, source);
84
+ return extractVariableDeclaratorItems(node, source)[0] ?? null;
76
85
  case "ambient_declaration":
77
86
  return extractAmbientDeclaration(node, source);
78
87
  case "internal_module":
@@ -83,38 +92,36 @@ function extractItem(node: SyntaxNodeLike, source: string): OutlineItem | null {
83
92
  }
84
93
  }
85
94
 
86
- /** Extract an outline item from an export wrapper without exposing non-extractable syntax nodes. */
87
- function extractExportStatement(node: SyntaxNodeLike, source: string): OutlineItem | null {
95
+ /** Extract outline items from an export wrapper without exposing local syntax nodes. */
96
+ function extractExportStatement(node: SyntaxNodeLike, source: string): OutlineItem[] {
88
97
  const decl = node.children.find((child) => OUTLINE_DECLARATION_NODE_TYPES.has(child.type));
89
98
  if (decl) {
99
+ if (decl.type === "lexical_declaration") return extractLexicalDeclarationItems(decl, source);
100
+ if (decl.type === "ambient_declaration") return extractAmbientDeclarationItems(decl, source);
90
101
  const item = extractItem(decl, source);
91
- if (item) return item;
102
+ if (item) return [item];
92
103
  }
93
104
 
94
105
  if (hasDefaultKeyword(node)) {
95
- return {
96
- name: "default",
97
- kind: "export",
98
- range: nodeToRange(node, source),
99
- };
106
+ return [{ name: "default", kind: "export", range: nodeToRange(node, source) }];
100
107
  }
101
108
 
102
109
  const exportClause = node.children.find((child) => child.type === "export_clause");
103
- if (exportClause) {
104
- return {
105
- name: node.text.replace(/^export\s+/, "").substring(0, 60),
106
- kind: "export",
107
- range: nodeToRange(node, source),
108
- };
109
- }
110
-
111
- return null;
110
+ return exportClause
111
+ ? [
112
+ {
113
+ name: node.text.replace(/^export\s+/, "").substring(0, 60),
114
+ kind: "export",
115
+ range: nodeToRange(node, source),
116
+ },
117
+ ]
118
+ : [];
112
119
  }
113
120
 
114
- function extractLexicalDeclaration(node: SyntaxNodeLike, source: string): OutlineItem | null {
115
- const declarators = node.children.filter((child) => child.type === "variable_declarator");
116
- if (declarators.length !== 1) return null;
117
- return extractVariableDeclarator(declarators[0] as SyntaxNodeLike, source);
121
+ function extractLexicalDeclarationItems(node: SyntaxNodeLike, source: string): OutlineItem[] {
122
+ return node.children
123
+ .filter((child) => child.type === "variable_declarator")
124
+ .flatMap((declarator) => extractVariableDeclaratorItems(declarator, source));
118
125
  }
119
126
 
120
127
  function extractNamedDeclaration(
@@ -154,14 +161,11 @@ function extractEnumDeclaration(node: SyntaxNodeLike, source: string): OutlineIt
154
161
  return { ...item, children: collectEnumMembers(node, source) };
155
162
  }
156
163
 
157
- function extractVariableDeclarator(node: SyntaxNodeLike, source: string): OutlineItem | null {
158
- const nameNode = findNameNode(node);
159
- if (!nameNode) return null;
160
- return {
161
- name: nameNode.text,
162
- kind: detectKind(node),
163
- range: nodeToRange(node, source),
164
- };
164
+ function extractVariableDeclaratorItems(node: SyntaxNodeLike, source: string): OutlineItem[] {
165
+ const names = extractBindingIdentifiers(node.childForFieldName("name"));
166
+ const kind = detectKind(node);
167
+ const range = nodeToRange(node, source);
168
+ return names.map((name) => ({ name, kind, range }));
165
169
  }
166
170
 
167
171
  function extractFieldDefinition(node: SyntaxNodeLike, source: string): OutlineItem | null {
@@ -174,9 +178,18 @@ function extractFieldDefinition(node: SyntaxNodeLike, source: string): OutlineIt
174
178
  };
175
179
  }
176
180
 
177
- function extractAmbientDeclaration(node: SyntaxNodeLike, source: string): OutlineItem | null {
181
+ function extractAmbientDeclarationItems(node: SyntaxNodeLike, source: string): OutlineItem[] {
178
182
  const declaration = node.children.find((child) => OUTLINE_DECLARATION_NODE_TYPES.has(child.type));
179
- return declaration ? extractItem(declaration, source) : null;
183
+ if (!declaration) return [];
184
+ if (declaration.type === "lexical_declaration") {
185
+ return extractLexicalDeclarationItems(declaration, source);
186
+ }
187
+ const item = extractItem(declaration, source);
188
+ return item ? [item] : [];
189
+ }
190
+
191
+ function extractAmbientDeclaration(node: SyntaxNodeLike, source: string): OutlineItem | null {
192
+ return extractAmbientDeclarationItems(node, source)[0] ?? null;
180
193
  }
181
194
 
182
195
  function extractModuleDeclaration(node: SyntaxNodeLike, source: string): OutlineItem | null {
@@ -0,0 +1,138 @@
1
+ import type { SyntaxNodeLike } from "../syntax-node.ts";
2
+ import { extractBindingIdentifiers } from "./js-binding-pattern.ts";
3
+
4
+ /** Return the declared name for one executable syntax scope. */
5
+ export function extractScopeName(node: SyntaxNodeLike): string {
6
+ const declaredName = findDeclaredName(node);
7
+ if (declaredName) return declaredName;
8
+
9
+ if (node.type === "arrow_function" || node.type === "function_expression") {
10
+ const binding = findNearestJavaScriptBinding(node);
11
+ if (binding) return binding;
12
+ }
13
+
14
+ if (node.type === "function_definition") {
15
+ const binding = findNearestRBinding(node);
16
+ if (binding) return binding;
17
+ }
18
+
19
+ return "anonymous";
20
+ }
21
+
22
+ function findDeclaredName(node: SyntaxNodeLike): string | null {
23
+ const name = node.childForFieldName("name");
24
+ if (name && isNameNode(name)) return name.text;
25
+
26
+ const declarator = node.childForFieldName("declarator");
27
+ return declarator ? findDeclaratorName(declarator) : null;
28
+ }
29
+
30
+ function findDeclaratorName(node: SyntaxNodeLike): string | null {
31
+ const namedChild = node.childForFieldName("name");
32
+ if (namedChild && isNameNode(namedChild)) return namedChild.text;
33
+ if (isNameNode(node)) return node.text;
34
+ const nested = node.childForFieldName("declarator");
35
+ if (nested) {
36
+ const name = findDeclaratorName(nested);
37
+ if (name) return name;
38
+ }
39
+ for (const child of node.children) {
40
+ const name = findDeclaratorName(child);
41
+ if (name) return name;
42
+ }
43
+ return null;
44
+ }
45
+
46
+ function findNearestJavaScriptBinding(node: SyntaxNodeLike): string | null {
47
+ for (let current = node.parent; current; current = current.parent) {
48
+ const binding = bindingForJavaScriptAncestor(current, node);
49
+ if (binding) return binding;
50
+ }
51
+ return null;
52
+ }
53
+
54
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: binding lookup covers the grammar's distinct assignment and object-pattern forms
55
+ function bindingForJavaScriptAncestor(node: SyntaxNodeLike, target: SyntaxNodeLike): string | null {
56
+ if (node.type === "variable_declarator") {
57
+ return isDirectValue(node, target)
58
+ ? (extractBindingIdentifiers(node.childForFieldName("name"))[0] ?? null)
59
+ : null;
60
+ }
61
+ if (node.type === "pair_pattern") {
62
+ return isDirectValue(node, target)
63
+ ? (extractBindingIdentifiers(node.childForFieldName("value"))[0] ??
64
+ node.childForFieldName("key")?.text ??
65
+ null)
66
+ : null;
67
+ }
68
+ if (node.type === "pair") {
69
+ return isDirectValue(node, target) ? (node.childForFieldName("key")?.text ?? null) : null;
70
+ }
71
+ if (node.type === "assignment_expression") {
72
+ const right = node.childForFieldName("right");
73
+ if (!sameNode(right, target)) return null;
74
+ const left = node.childForFieldName("left");
75
+ return left
76
+ ? (extractBindingIdentifiers(left)[0] ??
77
+ (left.type === "member_expression" || left.type === "subscript_expression"
78
+ ? left.text
79
+ : null))
80
+ : null;
81
+ }
82
+ if (node.type === "public_field_definition") {
83
+ return isDirectValue(node, target)
84
+ ? ((node.childForFieldName("name") ?? node.childForFieldName("key"))?.text ?? null)
85
+ : null;
86
+ }
87
+ return null;
88
+ }
89
+
90
+ function isDirectValue(node: SyntaxNodeLike, target: SyntaxNodeLike): boolean {
91
+ return sameNode(node.childForFieldName("value"), target);
92
+ }
93
+
94
+ function findNearestRBinding(node: SyntaxNodeLike): string | null {
95
+ for (let current = node.parent; current; current = current.parent) {
96
+ const binding = bindingForRAncestor(current, node);
97
+ if (binding) return binding;
98
+ }
99
+ return null;
100
+ }
101
+
102
+ function bindingForRAncestor(node: SyntaxNodeLike, target: SyntaxNodeLike): string | null {
103
+ if (node.type !== "binary_operator") return null;
104
+ const right = node.childForFieldName("rhs") ?? node.childForFieldName("right");
105
+ const left = node.childForFieldName("lhs") ?? node.childForFieldName("left");
106
+ return right && left && sameNode(right, target) && left.type === "identifier" ? left.text : null;
107
+ }
108
+
109
+ function sameNode(left: SyntaxNodeLike | null, right: SyntaxNodeLike): boolean {
110
+ if (!left) return false;
111
+ return (
112
+ left.type === right.type &&
113
+ left.startPosition.row === right.startPosition.row &&
114
+ left.startPosition.column === right.startPosition.column &&
115
+ left.endPosition.row === right.endPosition.row &&
116
+ left.endPosition.column === right.endPosition.column
117
+ );
118
+ }
119
+
120
+ const NAME_NODE_TYPES = new Set([
121
+ "identifier",
122
+ "type_identifier",
123
+ "field_identifier",
124
+ "property_identifier",
125
+ "private_property_identifier",
126
+ "simple_identifier",
127
+ "word",
128
+ "constant",
129
+ "scope_resolution",
130
+ "qualified_identifier",
131
+ "template_function",
132
+ "operator_name",
133
+ "destructor_name",
134
+ ]);
135
+
136
+ function isNameNode(node: SyntaxNodeLike): boolean {
137
+ return NAME_NODE_TYPES.has(node.type);
138
+ }
@@ -128,13 +128,6 @@ export interface TreeSitterSession extends TreeSitterService {
128
128
  dispose(): Promise<void>;
129
129
  }
130
130
 
131
- /** Session-scoped shared structural service published by the extension runtime. */
132
- export type SessionTreeSitterService = TreeSitterService;
133
-
134
- export type SessionTreeSitterServiceState =
135
- | { kind: "ready"; service: SessionTreeSitterService }
136
- | { kind: "unavailable"; reason: string };
137
-
138
131
  /** Supported grammar identifiers. */
139
132
  export type GrammarId =
140
133
  | "javascript"
@@ -196,10 +196,8 @@ export class ParsedFileStore {
196
196
  withQuery<T>(
197
197
  grammarId: GrammarId,
198
198
  queryText: string,
199
- compileOrExecution: (() => Query) | QueryExecution<T>,
200
- legacyExecute?: (query: Pick<Query, "matches">, cache: StructuralCacheObservation) => T,
199
+ execution: QueryExecution<T>,
201
200
  ): { readonly data: T; readonly cache: StructuralCacheObservation } {
202
- const execution = normalizeQueryExecution(compileOrExecution, legacyExecute);
203
201
  this.#assertActive();
204
202
  throwIfStructuralRequestInterrupted(execution.control);
205
203
  const key = queryKey(grammarId, queryText);
@@ -365,17 +363,6 @@ export class ParsedFileStore {
365
363
  }
366
364
  }
367
365
 
368
- function normalizeQueryExecution<T>(
369
- compileOrExecution: (() => Query) | QueryExecution<T>,
370
- legacyExecute:
371
- | ((query: Pick<Query, "matches">, cache: StructuralCacheObservation) => T)
372
- | undefined,
373
- ): QueryExecution<T> {
374
- if (typeof compileOrExecution !== "function") return compileOrExecution;
375
- if (!legacyExecute) throw new Error("Query execution callback is required");
376
- return { compile: compileOrExecution, execute: legacyExecute };
377
- }
378
-
379
366
  function fileReadMessage(error: unknown): string {
380
367
  return error instanceof Error ? error.message : "File could not be read";
381
368
  }
@@ -372,16 +372,6 @@ export class TreeSitterRuntime {
372
372
  }
373
373
  }
374
374
 
375
- /** Get the grammar ID for a file, or undefined if unsupported. */
376
- getGrammarId(filePath: string): GrammarId | undefined {
377
- return detectGrammar(filePath);
378
- }
379
-
380
- /** Resolve a file path from cwd. */
381
- resolvePath(filePath: string): string {
382
- return resolveToolPath(this.cwd, filePath);
383
- }
384
-
385
375
  /** Dispose all held tree, query, and parser resources. */
386
376
  dispose(): void {
387
377
  if (this.disposed) return;
@@ -1,14 +1,12 @@
1
1
  import { detectGrammar } from "../language.ts";
2
2
  import { supportsGrammarOperation } from "../operation-support.ts";
3
3
  import type { StructuralWorkerOperation } from "../session/structural-worker-protocol.ts";
4
- import {
5
- extractCallSites,
6
- extractExports,
7
- extractImports,
8
- extractOutline,
9
- lookupCalleesAt,
10
- lookupNodeAt,
11
- } from "../tool/structure.ts";
4
+ import { extractCallSites } from "../tool/call-sites.ts";
5
+ import { lookupCalleesAt } from "../tool/callees.ts";
6
+ import { extractExports } from "../tool/exports.ts";
7
+ import { extractImports } from "../tool/imports.ts";
8
+ import { lookupNodeAt } from "../tool/node-at.ts";
9
+ import { collectOutline as extractOutline } from "../tool/outline.ts";
12
10
  import type { TreeSitterResult } from "../types.ts";
13
11
  import {
14
12
  type StructuralRequestControl,
@@ -4,11 +4,11 @@ import type { StructuralTimingEvent } from "../session/structural-timing.ts";
4
4
  import { assertStructuralProtocolMessageSize } from "../session/structural-worker-message-size.ts";
5
5
  import {
6
6
  encodeStructuralResult,
7
- type ParentToStructuralWorkerMessage,
7
+ getStructuralWorkerMessageGeneration,
8
8
  STRUCTURAL_WORKER_PROTOCOL_VERSION,
9
9
  type StructuralWorkerChunkAckMessage,
10
10
  type StructuralWorkerRequestMessage,
11
- validateStructuralWorkerRequest,
11
+ validateParentToStructuralWorkerMessage,
12
12
  } from "../session/structural-worker-protocol.ts";
13
13
  import type { TreeSitterResult } from "../types.ts";
14
14
  import type { StructuralRequestControl } from "./request-control.ts";
@@ -56,21 +56,37 @@ export async function runStructuralWorker(
56
56
  };
57
57
 
58
58
  // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: protocol dispatch keeps request, cancel, and acknowledgement validation together
59
- parentPort.on("message", (message: ParentToStructuralWorkerMessage) => {
60
- if (message.version !== STRUCTURAL_WORKER_PROTOCOL_VERSION) return;
59
+ parentPort.on("message", (value: unknown) => {
60
+ const validation = validateParentToStructuralWorkerMessage(value);
61
+ if (validation.kind === "invalid") {
62
+ const generation = getStructuralWorkerMessageGeneration(value);
63
+ if (generation !== undefined && generation !== workerData.generation) return;
64
+ throw new Error(`Structural Worker protocol violation: ${validation.reason}`);
65
+ }
66
+
67
+ const message = validation.message;
61
68
  if (message.generation !== workerData.generation) return;
62
69
  if (message.kind === "cancel") {
63
- if (active?.message.requestId === message.requestId) active.abortController.abort();
70
+ if (!active) return;
71
+ assertActiveRequestOwner(active, message.requestId);
72
+ active.abortController.abort();
64
73
  return;
65
74
  }
66
75
  if (message.kind === "chunk-ack") {
67
- if (active?.message.requestId === message.requestId) sendNextChunk(message);
76
+ if (!active) return;
77
+ assertActiveRequestOwner(active, message.requestId);
78
+ if (!active.awaitingAck || message.sequence !== active.nextSequence - 1) {
79
+ throw new Error(
80
+ "Structural Worker protocol violation: Invalid chunk acknowledgement state",
81
+ );
82
+ }
83
+ sendNextChunk(message);
68
84
  return;
69
85
  }
70
- if (message.kind !== "request" || active) return;
71
- const validation = validateStructuralWorkerRequest(message);
72
- if (validation.kind === "invalid") return;
73
- void execute(validation.message);
86
+ if (active) {
87
+ throw new Error("Structural Worker protocol violation: Structural Worker request is busy");
88
+ }
89
+ void execute(message);
74
90
  });
75
91
 
76
92
  try {
@@ -187,6 +203,14 @@ export async function runStructuralWorker(
187
203
  active = null;
188
204
  }
189
205
 
206
+ function assertActiveRequestOwner(request: ActiveWorkerRequest, requestId: string): void {
207
+ if (request.message.requestId !== requestId) {
208
+ throw new Error(
209
+ "Structural Worker protocol violation: Message does not own the active request",
210
+ );
211
+ }
212
+ }
213
+
190
214
  function updateInterruptionOutcome(request: ActiveWorkerRequest): void {
191
215
  if (request.message.deadline !== undefined && Date.now() >= request.message.deadline) {
192
216
  request.outcome = "timeout";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-code-intelligence",
3
- "version": "6.1.0",
3
+ "version": "6.3.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-lsp": "6.1.0",
39
- "@mrclrchtr/supi-core": "6.1.0",
40
- "@mrclrchtr/supi-code-runtime": "6.1.0",
41
- "@mrclrchtr/supi-tree-sitter": "6.1.0"
38
+ "@mrclrchtr/supi-code-runtime": "6.3.0",
39
+ "@mrclrchtr/supi-core": "6.3.0",
40
+ "@mrclrchtr/supi-tree-sitter": "6.3.0",
41
+ "@mrclrchtr/supi-lsp": "6.3.0"
42
42
  },
43
43
  "bundledDependencies": [
44
44
  "@mrclrchtr/supi-code-runtime",
@@ -1,18 +1,18 @@
1
1
  /**
2
2
  * Capability Warning evaluation for reduced semantic and structural analysis.
3
3
  *
4
- * Normalizes LSP startup state, Tree-sitter health, and deprecated config keys
5
- * into a structured report consumed by the startup notice, /supi-ci-status,
4
+ * Normalizes LSP startup state and Tree-sitter health into a structured report
5
+ * consumed by the startup notice, /supi-ci-status,
6
6
  * and code_health.
7
7
  */
8
8
 
9
9
  import { getDefaultWorkspaceRuntime } from "@mrclrchtr/supi-code-runtime/api";
10
10
  import { loadSupiConfigForScope } from "@mrclrchtr/supi-core/config";
11
- import { getDeprecatedLspKeys, loadConfig, scanMissingServers } from "@mrclrchtr/supi-lsp/api";
11
+ import { loadConfig, scanMissingServers } from "@mrclrchtr/supi-lsp/api";
12
12
 
13
13
  /** One actionable warning about reduced Code intelligence capability. */
14
14
  export interface CapabilityWarning {
15
- type: "deprecated-key" | "language-disabled" | "missing-server" | "structural-unavailable";
15
+ type: "language-disabled" | "missing-server" | "structural-unavailable";
16
16
  message: string;
17
17
  language?: string;
18
18
  detail?: string;
@@ -31,7 +31,6 @@ export interface CapabilityWarningMissingServerSource {
31
31
 
32
32
  /** Current runtime/config facts needed to evaluate Capability Warnings. */
33
33
  export interface CapabilityWarningInput {
34
- deprecatedKeys: ReturnType<typeof getDeprecatedLspKeys>;
35
34
  explicitlyDisabledLanguages: string[];
36
35
  missingServers: Array<{ name: string; command: string; foundExtensions: string[] }>;
37
36
  structuralState: { kind: string; reason?: string };
@@ -41,21 +40,6 @@ export interface CapabilityWarningInput {
41
40
  export function evaluateCapabilityWarnings(input: CapabilityWarningInput): CapabilityWarningReport {
42
41
  const warnings: CapabilityWarning[] = [];
43
42
 
44
- if (input.deprecatedKeys.projectEnabled || input.deprecatedKeys.globalEnabled) {
45
- warnings.push({
46
- type: "deprecated-key",
47
- message:
48
- "lsp.enabled is deprecated and ignored. Use lsp.servers.<language>.enabled: false for per-language disable.",
49
- });
50
- }
51
- if (input.deprecatedKeys.projectActive || input.deprecatedKeys.globalActive) {
52
- warnings.push({
53
- type: "deprecated-key",
54
- message:
55
- "lsp.active is deprecated and ignored. All detected servers are attempted unless explicitly disabled.",
56
- });
57
- }
58
-
59
43
  for (const language of input.explicitlyDisabledLanguages) {
60
44
  warnings.push({
61
45
  type: "language-disabled",
@@ -143,7 +127,6 @@ export function gatherCapabilityWarningInput(
143
127
  cwd: string,
144
128
  lspController: CapabilityWarningMissingServerSource | null,
145
129
  ): CapabilityWarningInput {
146
- const deprecatedKeys = getDeprecatedLspKeys(cwd);
147
130
  const structuralState = getDefaultWorkspaceRuntime().getWorkspace(cwd).structural.state;
148
131
  const explicitlyDisabledLanguages = detectExplicitlyDisabledLanguages(cwd);
149
132
  const missingServers = lspController
@@ -151,7 +134,6 @@ export function gatherCapabilityWarningInput(
151
134
  : scanMissingServers(loadConfig(cwd), cwd);
152
135
 
153
136
  return {
154
- deprecatedKeys,
155
137
  explicitlyDisabledLanguages,
156
138
  missingServers,
157
139
  structuralState,
@@ -1,6 +1,8 @@
1
1
  import type { CodeRequestControl } from "@mrclrchtr/supi-code-runtime/api";
2
- import { startDebugTimer } from "@mrclrchtr/supi-core/debug";
3
- import { truncateIdentity } from "@mrclrchtr/supi-lsp/debug-telemetry";
2
+ import {
3
+ startDebugTimer,
4
+ truncateDebugIdentity as truncateIdentity,
5
+ } from "@mrclrchtr/supi-core/debug";
4
6
  import type { StructuralSearchOperation } from "@mrclrchtr/supi-tree-sitter/api";
5
7
  import type { StructuredFileAnalysis, StructuredPatternParams } from "./pattern-analysis.ts";
6
8
 
@@ -150,7 +150,7 @@ export async function enumerateAstFiles(
150
150
  class AstFileEnumerator {
151
151
  readonly #operations: AstScanOperations;
152
152
  readonly #now: () => number;
153
- readonly #grammarExtensions = new Set(getSupportedExtensions());
153
+ readonly #grammarExtensions: ReadonlySet<string> = new Set(getSupportedExtensions());
154
154
  readonly #operationExtensions: ReadonlySet<string>;
155
155
  readonly #files = new Set<string>();
156
156
  readonly #visitedDirectories = new Set<string>();
package/src/api.ts CHANGED
@@ -48,6 +48,7 @@ export type {
48
48
  export type {
49
49
  HealthDiagnosticObservation,
50
50
  HealthDiagnosticScope,
51
+ HealthFileReadiness,
51
52
  HealthRefreshAttempt,
52
53
  HealthRefreshState,
53
54
  HealthStaleAssessment,
package/src/extension.ts CHANGED
@@ -6,8 +6,10 @@ import type {
6
6
  ExtensionAPI,
7
7
  ExtensionContext,
8
8
  } from "@earendil-works/pi-coding-agent";
9
- import { recordDebugEvent } from "@mrclrchtr/supi-core/debug";
10
- import { truncateIdentity } from "@mrclrchtr/supi-lsp/debug-telemetry";
9
+ import {
10
+ recordDebugEvent,
11
+ truncateDebugIdentity as truncateIdentity,
12
+ } from "@mrclrchtr/supi-core/debug";
11
13
  import { buildArchitectureModel } from "./analysis/architecture/discovery.ts";
12
14
  import { createCodeIntelligenceApp } from "./app/app.ts";
13
15
  import { registerCodeIntelligenceSettings, resolveOverviewEnabled } from "./config.ts";