@optave/codegraph 3.11.2 → 3.13.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 (236) hide show
  1. package/README.md +73 -37
  2. package/dist/cli/commands/audit.d.ts.map +1 -1
  3. package/dist/cli/commands/audit.js +2 -1
  4. package/dist/cli/commands/audit.js.map +1 -1
  5. package/dist/cli/commands/batch.d.ts.map +1 -1
  6. package/dist/cli/commands/batch.js +1 -0
  7. package/dist/cli/commands/batch.js.map +1 -1
  8. package/dist/cli/commands/build.d.ts.map +1 -1
  9. package/dist/cli/commands/build.js +6 -1
  10. package/dist/cli/commands/build.js.map +1 -1
  11. package/dist/cli/commands/config.d.ts +3 -0
  12. package/dist/cli/commands/config.d.ts.map +1 -0
  13. package/dist/cli/commands/config.js +272 -0
  14. package/dist/cli/commands/config.js.map +1 -0
  15. package/dist/cli/commands/triage.js +1 -1
  16. package/dist/cli/commands/triage.js.map +1 -1
  17. package/dist/cli/index.d.ts.map +1 -1
  18. package/dist/cli/index.js +10 -0
  19. package/dist/cli/index.js.map +1 -1
  20. package/dist/cli/shared/options.d.ts +2 -1
  21. package/dist/cli/shared/options.d.ts.map +1 -1
  22. package/dist/cli/shared/options.js +11 -1
  23. package/dist/cli/shared/options.js.map +1 -1
  24. package/dist/cli/types.d.ts +2 -0
  25. package/dist/cli/types.d.ts.map +1 -1
  26. package/dist/db/migrations.d.ts.map +1 -1
  27. package/dist/db/migrations.js +8 -1
  28. package/dist/db/migrations.js.map +1 -1
  29. package/dist/domain/analysis/module-map.d.ts +2 -0
  30. package/dist/domain/analysis/module-map.d.ts.map +1 -1
  31. package/dist/domain/analysis/module-map.js +24 -2
  32. package/dist/domain/analysis/module-map.js.map +1 -1
  33. package/dist/domain/graph/builder/call-resolver.d.ts +16 -10
  34. package/dist/domain/graph/builder/call-resolver.d.ts.map +1 -1
  35. package/dist/domain/graph/builder/call-resolver.js +251 -34
  36. package/dist/domain/graph/builder/call-resolver.js.map +1 -1
  37. package/dist/domain/graph/builder/cha.d.ts +69 -0
  38. package/dist/domain/graph/builder/cha.d.ts.map +1 -0
  39. package/dist/domain/graph/builder/cha.js +158 -0
  40. package/dist/domain/graph/builder/cha.js.map +1 -0
  41. package/dist/domain/graph/builder/context.d.ts +3 -0
  42. package/dist/domain/graph/builder/context.d.ts.map +1 -1
  43. package/dist/domain/graph/builder/context.js +2 -0
  44. package/dist/domain/graph/builder/context.js.map +1 -1
  45. package/dist/domain/graph/builder/helpers.d.ts +25 -1
  46. package/dist/domain/graph/builder/helpers.d.ts.map +1 -1
  47. package/dist/domain/graph/builder/helpers.js +178 -5
  48. package/dist/domain/graph/builder/helpers.js.map +1 -1
  49. package/dist/domain/graph/builder/incremental.d.ts.map +1 -1
  50. package/dist/domain/graph/builder/incremental.js +74 -2
  51. package/dist/domain/graph/builder/incremental.js.map +1 -1
  52. package/dist/domain/graph/builder/pipeline.d.ts.map +1 -1
  53. package/dist/domain/graph/builder/pipeline.js +37 -2
  54. package/dist/domain/graph/builder/pipeline.js.map +1 -1
  55. package/dist/domain/graph/builder/stages/build-edges.d.ts.map +1 -1
  56. package/dist/domain/graph/builder/stages/build-edges.js +704 -34
  57. package/dist/domain/graph/builder/stages/build-edges.js.map +1 -1
  58. package/dist/domain/graph/builder/stages/detect-changes.d.ts.map +1 -1
  59. package/dist/domain/graph/builder/stages/detect-changes.js +3 -2
  60. package/dist/domain/graph/builder/stages/detect-changes.js.map +1 -1
  61. package/dist/domain/graph/builder/stages/finalize.d.ts.map +1 -1
  62. package/dist/domain/graph/builder/stages/finalize.js +4 -0
  63. package/dist/domain/graph/builder/stages/finalize.js.map +1 -1
  64. package/dist/domain/graph/builder/stages/native-orchestrator.d.ts.map +1 -1
  65. package/dist/domain/graph/builder/stages/native-orchestrator.js +783 -37
  66. package/dist/domain/graph/builder/stages/native-orchestrator.js.map +1 -1
  67. package/dist/domain/graph/builder/stages/resolve-imports.d.ts +1 -0
  68. package/dist/domain/graph/builder/stages/resolve-imports.d.ts.map +1 -1
  69. package/dist/domain/graph/builder/stages/resolve-imports.js +10 -1
  70. package/dist/domain/graph/builder/stages/resolve-imports.js.map +1 -1
  71. package/dist/domain/graph/journal.js +1 -1
  72. package/dist/domain/graph/journal.js.map +1 -1
  73. package/dist/domain/graph/resolver/points-to.d.ts +53 -0
  74. package/dist/domain/graph/resolver/points-to.d.ts.map +1 -0
  75. package/dist/domain/graph/resolver/points-to.js +213 -0
  76. package/dist/domain/graph/resolver/points-to.js.map +1 -0
  77. package/dist/domain/graph/resolver/ts-resolver.d.ts +9 -0
  78. package/dist/domain/graph/resolver/ts-resolver.d.ts.map +1 -0
  79. package/dist/domain/graph/resolver/ts-resolver.js +476 -0
  80. package/dist/domain/graph/resolver/ts-resolver.js.map +1 -0
  81. package/dist/domain/parser.d.ts +12 -4
  82. package/dist/domain/parser.d.ts.map +1 -1
  83. package/dist/domain/parser.js +83 -20
  84. package/dist/domain/parser.js.map +1 -1
  85. package/dist/domain/wasm-worker-entry.js +35 -2
  86. package/dist/domain/wasm-worker-entry.js.map +1 -1
  87. package/dist/domain/wasm-worker-pool.d.ts.map +1 -1
  88. package/dist/domain/wasm-worker-pool.js +34 -0
  89. package/dist/domain/wasm-worker-pool.js.map +1 -1
  90. package/dist/domain/wasm-worker-protocol.d.ts +15 -1
  91. package/dist/domain/wasm-worker-protocol.d.ts.map +1 -1
  92. package/dist/extractors/c.js +3 -3
  93. package/dist/extractors/c.js.map +1 -1
  94. package/dist/extractors/clojure.js +1 -1
  95. package/dist/extractors/clojure.js.map +1 -1
  96. package/dist/extractors/cpp.d.ts.map +1 -1
  97. package/dist/extractors/cpp.js +45 -4
  98. package/dist/extractors/cpp.js.map +1 -1
  99. package/dist/extractors/csharp.d.ts.map +1 -1
  100. package/dist/extractors/csharp.js +37 -8
  101. package/dist/extractors/csharp.js.map +1 -1
  102. package/dist/extractors/cuda.d.ts.map +1 -1
  103. package/dist/extractors/cuda.js +45 -4
  104. package/dist/extractors/cuda.js.map +1 -1
  105. package/dist/extractors/elixir.js +6 -6
  106. package/dist/extractors/elixir.js.map +1 -1
  107. package/dist/extractors/fsharp.js +1 -1
  108. package/dist/extractors/fsharp.js.map +1 -1
  109. package/dist/extractors/go.js +5 -5
  110. package/dist/extractors/go.js.map +1 -1
  111. package/dist/extractors/haskell.js +1 -1
  112. package/dist/extractors/haskell.js.map +1 -1
  113. package/dist/extractors/helpers.d.ts +11 -0
  114. package/dist/extractors/helpers.d.ts.map +1 -1
  115. package/dist/extractors/helpers.js +40 -0
  116. package/dist/extractors/helpers.js.map +1 -1
  117. package/dist/extractors/java.d.ts.map +1 -1
  118. package/dist/extractors/java.js +10 -9
  119. package/dist/extractors/java.js.map +1 -1
  120. package/dist/extractors/javascript.d.ts +2 -0
  121. package/dist/extractors/javascript.d.ts.map +1 -1
  122. package/dist/extractors/javascript.js +1812 -71
  123. package/dist/extractors/javascript.js.map +1 -1
  124. package/dist/extractors/kotlin.js +5 -5
  125. package/dist/extractors/kotlin.js.map +1 -1
  126. package/dist/extractors/lua.js +1 -1
  127. package/dist/extractors/lua.js.map +1 -1
  128. package/dist/extractors/objc.js +3 -3
  129. package/dist/extractors/objc.js.map +1 -1
  130. package/dist/extractors/ocaml.js +1 -1
  131. package/dist/extractors/ocaml.js.map +1 -1
  132. package/dist/extractors/php.js +2 -2
  133. package/dist/extractors/php.js.map +1 -1
  134. package/dist/extractors/python.js +7 -7
  135. package/dist/extractors/python.js.map +1 -1
  136. package/dist/extractors/ruby.js +2 -2
  137. package/dist/extractors/ruby.js.map +1 -1
  138. package/dist/extractors/scala.js +1 -1
  139. package/dist/extractors/scala.js.map +1 -1
  140. package/dist/extractors/solidity.js +1 -1
  141. package/dist/extractors/solidity.js.map +1 -1
  142. package/dist/extractors/swift.js +4 -4
  143. package/dist/extractors/swift.js.map +1 -1
  144. package/dist/extractors/zig.js +4 -4
  145. package/dist/extractors/zig.js.map +1 -1
  146. package/dist/features/structure-query.d.ts +1 -1
  147. package/dist/features/structure-query.d.ts.map +1 -1
  148. package/dist/features/structure-query.js +6 -6
  149. package/dist/features/structure-query.js.map +1 -1
  150. package/dist/index.d.ts +1 -1
  151. package/dist/index.d.ts.map +1 -1
  152. package/dist/index.js +1 -1
  153. package/dist/index.js.map +1 -1
  154. package/dist/infrastructure/config.d.ts +85 -2
  155. package/dist/infrastructure/config.d.ts.map +1 -1
  156. package/dist/infrastructure/config.js +408 -19
  157. package/dist/infrastructure/config.js.map +1 -1
  158. package/dist/infrastructure/native.d.ts +11 -0
  159. package/dist/infrastructure/native.d.ts.map +1 -1
  160. package/dist/infrastructure/native.js +78 -5
  161. package/dist/infrastructure/native.js.map +1 -1
  162. package/dist/infrastructure/registry.d.ts +27 -0
  163. package/dist/infrastructure/registry.d.ts.map +1 -1
  164. package/dist/infrastructure/registry.js +59 -1
  165. package/dist/infrastructure/registry.js.map +1 -1
  166. package/dist/presentation/queries-cli/overview.d.ts.map +1 -1
  167. package/dist/presentation/queries-cli/overview.js +5 -0
  168. package/dist/presentation/queries-cli/overview.js.map +1 -1
  169. package/dist/presentation/structure.d.ts +1 -1
  170. package/dist/presentation/structure.d.ts.map +1 -1
  171. package/dist/presentation/structure.js +2 -2
  172. package/dist/presentation/structure.js.map +1 -1
  173. package/dist/types.d.ts +221 -0
  174. package/dist/types.d.ts.map +1 -1
  175. package/grammars/tree-sitter-gleam.wasm +0 -0
  176. package/package.json +7 -8
  177. package/src/cli/commands/audit.ts +2 -1
  178. package/src/cli/commands/batch.ts +1 -0
  179. package/src/cli/commands/build.ts +6 -1
  180. package/src/cli/commands/config.ts +353 -0
  181. package/src/cli/commands/triage.ts +1 -1
  182. package/src/cli/index.ts +10 -0
  183. package/src/cli/shared/options.ts +11 -1
  184. package/src/cli/types.ts +2 -0
  185. package/src/db/migrations.ts +8 -1
  186. package/src/domain/analysis/module-map.ts +29 -1
  187. package/src/domain/graph/builder/call-resolver.ts +263 -35
  188. package/src/domain/graph/builder/cha.ts +192 -0
  189. package/src/domain/graph/builder/context.ts +3 -0
  190. package/src/domain/graph/builder/helpers.ts +195 -5
  191. package/src/domain/graph/builder/incremental.ts +80 -1
  192. package/src/domain/graph/builder/pipeline.ts +49 -2
  193. package/src/domain/graph/builder/stages/build-edges.ts +867 -32
  194. package/src/domain/graph/builder/stages/detect-changes.ts +4 -2
  195. package/src/domain/graph/builder/stages/finalize.ts +4 -0
  196. package/src/domain/graph/builder/stages/native-orchestrator.ts +910 -43
  197. package/src/domain/graph/builder/stages/resolve-imports.ts +15 -1
  198. package/src/domain/graph/journal.ts +1 -1
  199. package/src/domain/graph/resolver/points-to.ts +254 -0
  200. package/src/domain/graph/resolver/ts-resolver.ts +536 -0
  201. package/src/domain/parser.ts +86 -17
  202. package/src/domain/wasm-worker-entry.ts +35 -2
  203. package/src/domain/wasm-worker-pool.ts +22 -0
  204. package/src/domain/wasm-worker-protocol.ts +15 -0
  205. package/src/extractors/c.ts +3 -3
  206. package/src/extractors/clojure.ts +1 -1
  207. package/src/extractors/cpp.ts +47 -4
  208. package/src/extractors/csharp.ts +33 -9
  209. package/src/extractors/cuda.ts +47 -4
  210. package/src/extractors/elixir.ts +6 -6
  211. package/src/extractors/fsharp.ts +1 -1
  212. package/src/extractors/go.ts +5 -5
  213. package/src/extractors/haskell.ts +1 -1
  214. package/src/extractors/helpers.ts +43 -0
  215. package/src/extractors/java.ts +10 -9
  216. package/src/extractors/javascript.ts +1929 -72
  217. package/src/extractors/kotlin.ts +5 -5
  218. package/src/extractors/lua.ts +1 -1
  219. package/src/extractors/objc.ts +3 -3
  220. package/src/extractors/ocaml.ts +1 -1
  221. package/src/extractors/php.ts +2 -2
  222. package/src/extractors/python.ts +7 -7
  223. package/src/extractors/ruby.ts +2 -2
  224. package/src/extractors/scala.ts +1 -1
  225. package/src/extractors/solidity.ts +1 -1
  226. package/src/extractors/swift.ts +4 -4
  227. package/src/extractors/zig.ts +4 -4
  228. package/src/features/structure-query.ts +7 -7
  229. package/src/index.ts +5 -1
  230. package/src/infrastructure/config.ts +494 -20
  231. package/src/infrastructure/native.ts +87 -5
  232. package/src/infrastructure/registry.ts +82 -1
  233. package/src/presentation/queries-cli/overview.ts +15 -1
  234. package/src/presentation/structure.ts +3 -3
  235. package/src/types.ts +235 -0
  236. package/grammars/tree-sitter-erlang.wasm +0 -0
@@ -102,7 +102,7 @@ function collectKotlinEnumEntries(node: TreeSitterNode): SubDeclaration[] {
102
102
  if (!body) return entries;
103
103
  for (let i = 0; i < body.childCount; i++) {
104
104
  const child = body.child(i);
105
- if (!child || child.type !== 'enum_entry') continue;
105
+ if (child?.type !== 'enum_entry') continue;
106
106
  const entryName = findChild(child, 'simple_identifier');
107
107
  if (entryName) {
108
108
  entries.push({
@@ -122,7 +122,7 @@ function collectKotlinProperties(node: TreeSitterNode): SubDeclaration[] {
122
122
  if (!body) return props;
123
123
  for (let i = 0; i < body.childCount; i++) {
124
124
  const child = body.child(i);
125
- if (!child || child.type !== 'property_declaration') continue;
125
+ if (child?.type !== 'property_declaration') continue;
126
126
  const varDecl = findChild(child, 'variable_declaration');
127
127
  if (!varDecl) continue;
128
128
  const id = findChild(varDecl, 'simple_identifier');
@@ -144,7 +144,7 @@ function collectKotlinMethods(node: TreeSitterNode, className: string, ctx: Extr
144
144
  if (!body) return;
145
145
  for (let i = 0; i < body.childCount; i++) {
146
146
  const child = body.child(i);
147
- if (!child || child.type !== 'function_declaration') continue;
147
+ if (child?.type !== 'function_declaration') continue;
148
148
  const methName = findChild(child, 'simple_identifier');
149
149
  if (methName) {
150
150
  const params = extractKotlinParameters(child);
@@ -168,7 +168,7 @@ function collectKotlinInheritance(
168
168
  ): void {
169
169
  for (let i = 0; i < node.childCount; i++) {
170
170
  const child = node.child(i);
171
- if (!child || child.type !== 'delegation_specifier') continue;
171
+ if (child?.type !== 'delegation_specifier') continue;
172
172
 
173
173
  // constructor_invocation > user_type > type_identifier (extends)
174
174
  const ctorInvocation = findChild(child, 'constructor_invocation');
@@ -294,7 +294,7 @@ function extractKotlinParameters(funcNode: TreeSitterNode): SubDeclaration[] {
294
294
  if (!paramList) return params;
295
295
  for (let i = 0; i < paramList.childCount; i++) {
296
296
  const param = paramList.child(i);
297
- if (!param || param.type !== 'parameter') continue;
297
+ if (param?.type !== 'parameter') continue;
298
298
  const nameNode = findChild(param, 'simple_identifier');
299
299
  if (nameNode) {
300
300
  params.push({ name: nameNode.text, kind: 'parameter', line: param.startPosition.row + 1 });
@@ -90,7 +90,7 @@ function extractLuaParams(funcNode: TreeSitterNode): SubDeclaration[] {
90
90
 
91
91
  for (let i = 0; i < paramList.childCount; i++) {
92
92
  const param = paramList.child(i);
93
- if (!param || param.type !== 'identifier') continue;
93
+ if (param?.type !== 'identifier') continue;
94
94
  params.push({ name: param.text, kind: 'parameter', line: param.startPosition.row + 1 });
95
95
  }
96
96
  return params;
@@ -468,7 +468,7 @@ function extractPropertyName(propNode: TreeSitterNode): string | null {
468
468
  if (!structDecl) return null;
469
469
  for (let i = 0; i < structDecl.childCount; i++) {
470
470
  const child = structDecl.child(i);
471
- if (!child || child.type !== 'struct_declarator') continue;
471
+ if (child?.type !== 'struct_declarator') continue;
472
472
  const id = findIdentifierDeep(child);
473
473
  if (id) return id.text;
474
474
  }
@@ -494,7 +494,7 @@ function extractMethodParams(methodNode: TreeSitterNode): SubDeclaration[] {
494
494
  const params: SubDeclaration[] = [];
495
495
  for (let i = 0; i < methodNode.childCount; i++) {
496
496
  const child = methodNode.child(i);
497
- if (!child || child.type !== 'method_parameter') continue;
497
+ if (child?.type !== 'method_parameter') continue;
498
498
  let nameNode: TreeSitterNode | null = null;
499
499
  for (let j = 0; j < child.childCount; j++) {
500
500
  const inner = child.child(j);
@@ -516,7 +516,7 @@ function extractCParams(paramListNode: TreeSitterNode | null): SubDeclaration[]
516
516
  if (!paramListNode) return params;
517
517
  for (let i = 0; i < paramListNode.childCount; i++) {
518
518
  const param = paramListNode.child(i);
519
- if (!param || param.type !== 'parameter_declaration') continue;
519
+ if (param?.type !== 'parameter_declaration') continue;
520
520
  const nameNode = param.childForFieldName('declarator');
521
521
  if (nameNode) {
522
522
  const name = unwrapObjCDeclaratorName(nameNode);
@@ -168,7 +168,7 @@ function handleOCamlTypeDef(node: TreeSitterNode, ctx: ExtractorOutput): void {
168
168
  // type_definition contains one or more type_bindings
169
169
  for (let i = 0; i < node.childCount; i++) {
170
170
  const child = node.child(i);
171
- if (!child || child.type !== 'type_binding') continue;
171
+ if (child?.type !== 'type_binding') continue;
172
172
 
173
173
  const nameNode =
174
174
  child.childForFieldName('name') ||
@@ -36,7 +36,7 @@ function extractPhpParameters(fnNode: TreeSitterNode): SubDeclaration[] {
36
36
  function extractPhpProperties(member: TreeSitterNode, children: SubDeclaration[]): void {
37
37
  for (let j = 0; j < member.childCount; j++) {
38
38
  const el = member.child(j);
39
- if (!el || el.type !== 'property_element') continue;
39
+ if (el?.type !== 'property_element') continue;
40
40
  const varNode = findChild(el, 'variable_name');
41
41
  if (varNode) {
42
42
  children.push({
@@ -53,7 +53,7 @@ function extractPhpProperties(member: TreeSitterNode, children: SubDeclaration[]
53
53
  function extractPhpConstants(member: TreeSitterNode, children: SubDeclaration[]): void {
54
54
  for (let j = 0; j < member.childCount; j++) {
55
55
  const el = member.child(j);
56
- if (!el || el.type !== 'const_element') continue;
56
+ if (el?.type !== 'const_element') continue;
57
57
  const nameNode = el.childForFieldName('name') || findChild(el, 'name');
58
58
  if (nameNode) {
59
59
  children.push({
@@ -291,7 +291,7 @@ function extractClassAssignment(
291
291
  const assignment = findChild(child, 'assignment');
292
292
  if (!assignment) return;
293
293
  const left = assignment.childForFieldName('left');
294
- if (!left || left.type !== 'identifier' || seen.has(left.text)) return;
294
+ if (left?.type !== 'identifier' || seen.has(left.text)) return;
295
295
  seen.add(left.text);
296
296
  props.push({
297
297
  name: left.text,
@@ -308,7 +308,7 @@ function extractInitProperties(
308
308
  props: SubDeclaration[],
309
309
  ): void {
310
310
  const fnName = node.childForFieldName('name');
311
- if (!fnName || fnName.text !== '__init__') return;
311
+ if (fnName?.text !== '__init__') return;
312
312
  const initBody = node.childForFieldName('body') || findChild(node, 'block');
313
313
  if (initBody) walkInitBody(initBody, seen, props);
314
314
  }
@@ -342,11 +342,11 @@ function extractPythonClassProperties(classNode: TreeSitterNode): SubDeclaration
342
342
  function walkInitBody(bodyNode: TreeSitterNode, seen: Set<string>, props: SubDeclaration[]): void {
343
343
  for (let i = 0; i < bodyNode.childCount; i++) {
344
344
  const stmt = bodyNode.child(i);
345
- if (!stmt || stmt.type !== 'expression_statement') continue;
345
+ if (stmt?.type !== 'expression_statement') continue;
346
346
  const assignment = findChild(stmt, 'assignment');
347
347
  if (!assignment) continue;
348
348
  const left = assignment.childForFieldName('left');
349
- if (!left || left.type !== 'attribute') continue;
349
+ if (left?.type !== 'attribute') continue;
350
350
  const obj = left.childForFieldName('object');
351
351
  const attr = left.childForFieldName('attribute');
352
352
  if (obj && obj.text === 'self' && attr && attr.type === 'identifier' && !seen.has(attr.text)) {
@@ -370,7 +370,7 @@ function handlePyTypedParam(node: TreeSitterNode, ctx: ExtractorOutput): void {
370
370
  const isDefault = node.type === 'typed_default_parameter';
371
371
  const nameNode = isDefault ? node.childForFieldName('name') : node.child(0);
372
372
  const typeNode = node.childForFieldName('type');
373
- if (!nameNode || nameNode.type !== 'identifier' || !typeNode) return;
373
+ if (nameNode?.type !== 'identifier' || !typeNode) return;
374
374
  if (nameNode.text === 'self' || nameNode.text === 'cls') return;
375
375
  const typeName = extractPythonTypeName(typeNode);
376
376
  if (typeName && ctx.typeMap) setTypeMapEntry(ctx.typeMap, nameNode.text, typeName, 0.9);
@@ -380,7 +380,7 @@ function handlePyTypedParam(node: TreeSitterNode, ctx: ExtractorOutput): void {
380
380
  function handlePyAssignmentType(node: TreeSitterNode, ctx: ExtractorOutput): void {
381
381
  const left = node.childForFieldName('left');
382
382
  const right = node.childForFieldName('right');
383
- if (!left || left.type !== 'identifier' || !right || right.type !== 'call') return;
383
+ if (left?.type !== 'identifier' || !right || right.type !== 'call') return;
384
384
 
385
385
  const fn = right.childForFieldName('function');
386
386
  if (!fn) return;
@@ -391,7 +391,7 @@ function handlePyAssignmentType(node: TreeSitterNode, ctx: ExtractorOutput): voi
391
391
  }
392
392
  } else if (fn.type === 'attribute') {
393
393
  const obj = fn.childForFieldName('object');
394
- if (!obj || obj.type !== 'identifier') return;
394
+ if (obj?.type !== 'identifier') return;
395
395
  const objName = obj.text;
396
396
  if (objName[0] && objName[0] !== objName[0].toLowerCase() && !BUILTIN_GLOBALS_PY.has(objName)) {
397
397
  if (ctx.typeMap) setTypeMapEntry(ctx.typeMap, left.text, objName, 0.7);
@@ -264,7 +264,7 @@ function extractRubyBodyConstants(containerNode: TreeSitterNode): SubDeclaration
264
264
  if (!body) return children;
265
265
  for (let i = 0; i < body.childCount; i++) {
266
266
  const child = body.child(i);
267
- if (!child || child.type !== 'assignment') continue;
267
+ if (child?.type !== 'assignment') continue;
268
268
  const left = child.childForFieldName('left');
269
269
  if (left && left.type === 'constant') {
270
270
  children.push({ name: left.text, kind: 'constant', line: child.startPosition.row + 1 });
@@ -279,7 +279,7 @@ function extractRubyClassChildren(classNode: TreeSitterNode): SubDeclaration[] {
279
279
  if (!body) return children;
280
280
  for (let i = 0; i < body.childCount; i++) {
281
281
  const child = body.child(i);
282
- if (!child || child.type !== 'assignment') continue;
282
+ if (child?.type !== 'assignment') continue;
283
283
  const left = child.childForFieldName('left');
284
284
  if (!left) continue;
285
285
  if (left.type === 'instance_variable') {
@@ -263,7 +263,7 @@ function extractScalaParameters(funcNode: TreeSitterNode): SubDeclaration[] {
263
263
  if (!paramList) return params;
264
264
  for (let i = 0; i < paramList.childCount; i++) {
265
265
  const param = paramList.child(i);
266
- if (!param || param.type !== 'parameter') continue;
266
+ if (param?.type !== 'parameter') continue;
267
267
  const nameNode = findChild(param, 'identifier');
268
268
  if (nameNode) {
269
269
  params.push({ name: nameNode.text, kind: 'parameter', line: param.startPosition.row + 1 });
@@ -166,7 +166,7 @@ function extractContractMember(child: TreeSitterNode): SubDeclaration | null {
166
166
  function extractInheritance(node: TreeSitterNode, name: string, ctx: ExtractorOutput): void {
167
167
  for (let i = 0; i < node.childCount; i++) {
168
168
  const inheritance = node.child(i);
169
- if (!inheritance || inheritance.type !== 'inheritance_specifier') continue;
169
+ if (inheritance?.type !== 'inheritance_specifier') continue;
170
170
  for (let j = 0; j < inheritance.childCount; j++) {
171
171
  const child = inheritance.child(j);
172
172
  if (!child) continue;
@@ -94,7 +94,7 @@ function collectSwiftEnumEntries(node: TreeSitterNode): SubDeclaration[] {
94
94
  if (!body) return entries;
95
95
  for (let i = 0; i < body.childCount; i++) {
96
96
  const child = body.child(i);
97
- if (!child || child.type !== 'enum_entry') continue;
97
+ if (child?.type !== 'enum_entry') continue;
98
98
  const entryName = findChild(child, 'simple_identifier');
99
99
  if (entryName) {
100
100
  entries.push({
@@ -114,7 +114,7 @@ function collectSwiftProperties(node: TreeSitterNode): SubDeclaration[] {
114
114
  if (!body) return props;
115
115
  for (let i = 0; i < body.childCount; i++) {
116
116
  const child = body.child(i);
117
- if (!child || child.type !== 'property_declaration') continue;
117
+ if (child?.type !== 'property_declaration') continue;
118
118
  const pattern = findChild(child, 'pattern');
119
119
  if (!pattern) continue;
120
120
  const propName = findChild(pattern, 'simple_identifier');
@@ -136,7 +136,7 @@ function collectSwiftMethods(node: TreeSitterNode, className: string, ctx: Extra
136
136
  if (!body) return;
137
137
  for (let i = 0; i < body.childCount; i++) {
138
138
  const child = body.child(i);
139
- if (!child || child.type !== 'function_declaration') continue;
139
+ if (child?.type !== 'function_declaration') continue;
140
140
  const methName = findChild(child, 'simple_identifier');
141
141
  if (methName) {
142
142
  ctx.definitions.push({
@@ -159,7 +159,7 @@ function collectSwiftInheritance(
159
159
  let first = true;
160
160
  for (let i = 0; i < node.childCount; i++) {
161
161
  const child = node.child(i);
162
- if (!child || child.type !== 'inheritance_specifier') continue;
162
+ if (child?.type !== 'inheritance_specifier') continue;
163
163
  const userType = findChild(child, 'user_type');
164
164
  const typeId = userType ? findChild(userType, 'type_identifier') : null;
165
165
  if (!typeId) continue;
@@ -86,7 +86,7 @@ function extractZigParams(funcNode: TreeSitterNode): SubDeclaration[] {
86
86
 
87
87
  for (let i = 0; i < paramList.childCount; i++) {
88
88
  const param = paramList.child(i);
89
- if (!param || param.type !== 'parameter') continue;
89
+ if (param?.type !== 'parameter') continue;
90
90
  const nameNode = findChild(param, 'identifier');
91
91
  if (nameNode) {
92
92
  params.push({ name: nameNode.text, kind: 'parameter', line: param.startPosition.row + 1 });
@@ -151,7 +151,7 @@ function zigContainerKind(nodeType: string): 'struct' | 'enum' | undefined {
151
151
  function tryHandleZigImportDecl(node: TreeSitterNode, name: string, ctx: ExtractorOutput): boolean {
152
152
  for (let i = 0; i < node.childCount; i++) {
153
153
  const child = node.child(i);
154
- if (!child || child.type !== 'builtin_function') continue;
154
+ if (child?.type !== 'builtin_function') continue;
155
155
  const source = extractZigImportSource(child);
156
156
  if (source) {
157
157
  ctx.imports.push({ source, names: [name], line: node.startPosition.row + 1 });
@@ -175,7 +175,7 @@ function extractZigContainerFields(container: TreeSitterNode): SubDeclaration[]
175
175
  const fields: SubDeclaration[] = [];
176
176
  for (let i = 0; i < container.childCount; i++) {
177
177
  const child = container.child(i);
178
- if (!child || child.type !== 'container_field') continue;
178
+ if (child?.type !== 'container_field') continue;
179
179
  const nameNode = child.childForFieldName('name') || findChild(child, 'identifier');
180
180
  if (nameNode) {
181
181
  fields.push({ name: nameNode.text, kind: 'property', line: child.startPosition.row + 1 });
@@ -191,7 +191,7 @@ function extractZigContainerMethods(
191
191
  ): void {
192
192
  for (let i = 0; i < container.childCount; i++) {
193
193
  const child = container.child(i);
194
- if (!child || child.type !== 'function_declaration') continue;
194
+ if (child?.type !== 'function_declaration') continue;
195
195
  const nameNode = child.childForFieldName('name');
196
196
  if (nameNode) {
197
197
  ctx.definitions.push({
@@ -324,7 +324,7 @@ export function hotspotsData(
324
324
  metric: string;
325
325
  level: string;
326
326
  limit: number;
327
- hotspots: unknown[];
327
+ items: unknown[];
328
328
  } {
329
329
  const { db, nativeDb, close } = openReadonlyWithNative(customDbPath);
330
330
  try {
@@ -337,19 +337,19 @@ export function hotspotsData(
337
337
  // ── Native fast path: single query instead of 4 eagerly prepared ──
338
338
  if (nativeDb?.getHotspots) {
339
339
  const rows = nativeDb.getHotspots(kind, metric, noTests, limit);
340
- const hotspots = rows.map(mapNativeHotspotRow);
341
- const base = { metric, level, limit, hotspots };
342
- return paginateResult(base, 'hotspots', { limit: opts.limit, offset: opts.offset });
340
+ const items = rows.map(mapNativeHotspotRow);
341
+ const base = { metric, level, limit, items };
342
+ return paginateResult(base, 'items', { limit: opts.limit, offset: opts.offset });
343
343
  }
344
344
 
345
345
  // ── JS fallback ───────────────────────────────────────────────────
346
346
  const testFilter = testFilterSQL('n.name', noTests && kind === 'file');
347
347
  const stmt = db.prepare(buildHotspotQuery(metric, testFilter));
348
348
  const rows = stmt.all(kind, limit) as HotspotRow[];
349
- const hotspots = rows.map(mapJsHotspotRow);
349
+ const items = rows.map(mapJsHotspotRow);
350
350
 
351
- const base = { metric, level, limit, hotspots };
352
- return paginateResult(base, 'hotspots', { limit: opts.limit, offset: opts.offset });
351
+ const base = { metric, level, limit, items };
352
+ return paginateResult(base, 'items', { limit: opts.limit, offset: opts.offset });
353
353
  } finally {
354
354
  close();
355
355
  }
package/src/index.ts CHANGED
@@ -52,7 +52,11 @@ export { ownersData } from './features/owners.js';
52
52
  export { sequenceData } from './features/sequence.js';
53
53
  export { hotspotsData, moduleBoundariesData, structureData } from './features/structure.js';
54
54
  export { triageData } from './features/triage.js';
55
- export { loadConfig } from './infrastructure/config.js';
55
+ export {
56
+ loadConfig,
57
+ loadConfigWithProvenance,
58
+ resolveUserConfigPath,
59
+ } from './infrastructure/config.js';
56
60
  export type { ArrayCompatSet } from './shared/constants.js';
57
61
  export { EXTENSIONS, IGNORE_DIRS } from './shared/constants.js';
58
62
  export {