@saluzi/codegraph 0.1.0 → 0.2.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 (246) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +885 -0
  3. package/package.json +42 -10
  4. package/scripts/add-lang/bench.sh +60 -0
  5. package/scripts/add-lang/check-grammar.mjs +75 -0
  6. package/scripts/add-lang/dump-ast.mjs +103 -0
  7. package/scripts/add-lang/verify-extraction.mjs +70 -0
  8. package/scripts/agent-eval/ab-adoption.sh +91 -0
  9. package/scripts/agent-eval/ab-hook.sh +86 -0
  10. package/scripts/agent-eval/ab-impl.sh +78 -0
  11. package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -0
  12. package/scripts/agent-eval/ab-sufficiency.sh +78 -0
  13. package/scripts/agent-eval/arms-F.sh +21 -0
  14. package/scripts/agent-eval/arms-matrix.sh +37 -0
  15. package/scripts/agent-eval/audit.sh +68 -0
  16. package/scripts/agent-eval/bench-readme.sh +28 -0
  17. package/scripts/agent-eval/bench-why-repo.sh +22 -0
  18. package/scripts/agent-eval/block-read-hook.sh +19 -0
  19. package/scripts/agent-eval/hook-settings.json +15 -0
  20. package/scripts/agent-eval/itrun.sh +120 -0
  21. package/scripts/agent-eval/offload-eval-3arm.sh +72 -0
  22. package/scripts/agent-eval/offload-eval-cost.mjs +133 -0
  23. package/scripts/agent-eval/offload-eval-effort.mjs +108 -0
  24. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -0
  25. package/scripts/agent-eval/offload-eval-frontload.sh +47 -0
  26. package/scripts/agent-eval/offload-eval-ground-truth.json +18 -0
  27. package/scripts/agent-eval/offload-eval-hook.mjs +84 -0
  28. package/scripts/agent-eval/offload-eval-judge.mjs +103 -0
  29. package/scripts/agent-eval/offload-eval-matrix.sh +20 -0
  30. package/scripts/agent-eval/offload-eval-metrics.mjs +94 -0
  31. package/scripts/agent-eval/offload-eval-refs1.sh +50 -0
  32. package/scripts/agent-eval/offload-eval-setup.sh +24 -0
  33. package/scripts/agent-eval/offload-eval-styles.sh +72 -0
  34. package/scripts/agent-eval/offload-eval-summarize.mjs +68 -0
  35. package/scripts/agent-eval/offload-eval.md +76 -0
  36. package/scripts/agent-eval/parse-arms.mjs +116 -0
  37. package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
  38. package/scripts/agent-eval/parse-run.mjs +45 -0
  39. package/scripts/agent-eval/parse-session.mjs +93 -0
  40. package/scripts/agent-eval/probe-context.mjs +21 -0
  41. package/scripts/agent-eval/probe-explore.mjs +40 -0
  42. package/scripts/agent-eval/probe-node.mjs +20 -0
  43. package/scripts/agent-eval/probe-sweep.mjs +119 -0
  44. package/scripts/agent-eval/probe-trace.mjs +20 -0
  45. package/scripts/agent-eval/redirect-read-hook.sh +38 -0
  46. package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
  47. package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
  48. package/scripts/agent-eval/run-agent.sh +34 -0
  49. package/scripts/agent-eval/run-all.sh +75 -0
  50. package/scripts/agent-eval/run-arms.sh +56 -0
  51. package/scripts/agent-eval/seq-matrix.mjs +137 -0
  52. package/scripts/build-bundle.sh +123 -0
  53. package/scripts/extract-release-notes.mjs +130 -0
  54. package/scripts/local-install.sh +41 -0
  55. package/scripts/npm-sdk.js +75 -0
  56. package/scripts/npm-shim.js +275 -0
  57. package/scripts/pack-npm.sh +119 -0
  58. package/scripts/prepare-release.mjs +270 -0
  59. package/dist/bin/codegraph.d.ts +0 -25
  60. package/dist/bin/node-version-check.d.ts +0 -37
  61. package/dist/bin/uninstall.d.ts +0 -14
  62. package/dist/context/formatter.d.ts +0 -33
  63. package/dist/context/formatter.js +0 -244
  64. package/dist/context/index.d.ts +0 -117
  65. package/dist/context/index.js +0 -1050
  66. package/dist/db/index.d.ts +0 -101
  67. package/dist/db/index.js +0 -250
  68. package/dist/db/migrations.d.ts +0 -47
  69. package/dist/db/migrations.js +0 -131
  70. package/dist/db/queries.d.ts +0 -291
  71. package/dist/db/queries.js +0 -1349
  72. package/dist/db/schema.sql +0 -151
  73. package/dist/db/sqlite-adapter.d.ts +0 -49
  74. package/dist/db/sqlite-adapter.js +0 -141
  75. package/dist/directory.d.ts +0 -62
  76. package/dist/directory.js +0 -264
  77. package/dist/errors.d.ts +0 -149
  78. package/dist/errors.js +0 -219
  79. package/dist/extraction/dfm-extractor.d.ts +0 -31
  80. package/dist/extraction/dfm-extractor.js +0 -151
  81. package/dist/extraction/grammars.d.ts +0 -94
  82. package/dist/extraction/grammars.js +0 -357
  83. package/dist/extraction/index.d.ts +0 -148
  84. package/dist/extraction/index.js +0 -1286
  85. package/dist/extraction/languages/c-cpp.d.ts +0 -4
  86. package/dist/extraction/languages/c-cpp.js +0 -126
  87. package/dist/extraction/languages/csharp.d.ts +0 -3
  88. package/dist/extraction/languages/csharp.js +0 -72
  89. package/dist/extraction/languages/dart.d.ts +0 -3
  90. package/dist/extraction/languages/dart.js +0 -192
  91. package/dist/extraction/languages/go.d.ts +0 -3
  92. package/dist/extraction/languages/go.js +0 -58
  93. package/dist/extraction/languages/index.d.ts +0 -10
  94. package/dist/extraction/languages/index.js +0 -49
  95. package/dist/extraction/languages/java.d.ts +0 -3
  96. package/dist/extraction/languages/java.js +0 -64
  97. package/dist/extraction/languages/javascript.d.ts +0 -3
  98. package/dist/extraction/languages/javascript.js +0 -90
  99. package/dist/extraction/languages/kotlin.d.ts +0 -3
  100. package/dist/extraction/languages/kotlin.js +0 -253
  101. package/dist/extraction/languages/lua.d.ts +0 -3
  102. package/dist/extraction/languages/lua.js +0 -150
  103. package/dist/extraction/languages/luau.d.ts +0 -3
  104. package/dist/extraction/languages/luau.js +0 -37
  105. package/dist/extraction/languages/pascal.d.ts +0 -3
  106. package/dist/extraction/languages/pascal.js +0 -66
  107. package/dist/extraction/languages/php.d.ts +0 -3
  108. package/dist/extraction/languages/php.js +0 -107
  109. package/dist/extraction/languages/python.d.ts +0 -3
  110. package/dist/extraction/languages/python.js +0 -56
  111. package/dist/extraction/languages/ruby.d.ts +0 -3
  112. package/dist/extraction/languages/ruby.js +0 -114
  113. package/dist/extraction/languages/rust.d.ts +0 -3
  114. package/dist/extraction/languages/rust.js +0 -109
  115. package/dist/extraction/languages/scala.d.ts +0 -3
  116. package/dist/extraction/languages/scala.js +0 -139
  117. package/dist/extraction/languages/swift.d.ts +0 -3
  118. package/dist/extraction/languages/swift.js +0 -91
  119. package/dist/extraction/languages/typescript.d.ts +0 -3
  120. package/dist/extraction/languages/typescript.js +0 -129
  121. package/dist/extraction/liquid-extractor.d.ts +0 -52
  122. package/dist/extraction/liquid-extractor.js +0 -313
  123. package/dist/extraction/parse-worker.d.ts +0 -8
  124. package/dist/extraction/parse-worker.js +0 -94
  125. package/dist/extraction/svelte-extractor.d.ts +0 -56
  126. package/dist/extraction/svelte-extractor.js +0 -272
  127. package/dist/extraction/tree-sitter-helpers.d.ts +0 -39
  128. package/dist/extraction/tree-sitter-helpers.js +0 -103
  129. package/dist/extraction/tree-sitter-types.d.ts +0 -191
  130. package/dist/extraction/tree-sitter-types.js +0 -10
  131. package/dist/extraction/tree-sitter.d.ts +0 -238
  132. package/dist/extraction/tree-sitter.js +0 -2430
  133. package/dist/extraction/vue-extractor.d.ts +0 -36
  134. package/dist/extraction/vue-extractor.js +0 -163
  135. package/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
  136. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  137. package/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
  138. package/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
  139. package/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
  140. package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  141. package/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
  142. package/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  143. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  144. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  145. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  146. package/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
  147. package/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
  148. package/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
  149. package/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
  150. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  151. package/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
  152. package/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
  153. package/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
  154. package/dist/extraction/wasm-runtime-flags.d.ts +0 -46
  155. package/dist/extraction/wasm-runtime-flags.js +0 -105
  156. package/dist/graph/index.d.ts +0 -8
  157. package/dist/graph/index.js +0 -13
  158. package/dist/graph/queries.d.ts +0 -109
  159. package/dist/graph/queries.js +0 -366
  160. package/dist/graph/traversal.d.ts +0 -137
  161. package/dist/graph/traversal.js +0 -528
  162. package/dist/index.d.ts +0 -509
  163. package/dist/index.js +0 -800
  164. package/dist/installer/claude-md-template.d.ts +0 -19
  165. package/dist/installer/config-writer.d.ts +0 -29
  166. package/dist/installer/index.d.ts +0 -140
  167. package/dist/installer/instructions-template.d.ts +0 -30
  168. package/dist/installer/targets/claude.d.ts +0 -55
  169. package/dist/installer/targets/codex.d.ts +0 -18
  170. package/dist/installer/targets/cursor.d.ts +0 -35
  171. package/dist/installer/targets/hermes.d.ts +0 -18
  172. package/dist/installer/targets/opencode.d.ts +0 -30
  173. package/dist/installer/targets/registry.d.ts +0 -38
  174. package/dist/installer/targets/shared.d.ts +0 -92
  175. package/dist/installer/targets/toml.d.ts +0 -64
  176. package/dist/installer/targets/types.d.ts +0 -122
  177. package/dist/mcp/index.d.ts +0 -98
  178. package/dist/mcp/server-instructions.d.ts +0 -20
  179. package/dist/mcp/tools.d.ts +0 -269
  180. package/dist/mcp/transport.d.ts +0 -117
  181. package/dist/resolution/frameworks/cargo-workspace.d.ts +0 -20
  182. package/dist/resolution/frameworks/cargo-workspace.js +0 -225
  183. package/dist/resolution/frameworks/csharp.d.ts +0 -8
  184. package/dist/resolution/frameworks/csharp.js +0 -213
  185. package/dist/resolution/frameworks/drupal.d.ts +0 -51
  186. package/dist/resolution/frameworks/drupal.js +0 -335
  187. package/dist/resolution/frameworks/express.d.ts +0 -8
  188. package/dist/resolution/frameworks/express.js +0 -225
  189. package/dist/resolution/frameworks/go.d.ts +0 -8
  190. package/dist/resolution/frameworks/go.js +0 -158
  191. package/dist/resolution/frameworks/index.d.ts +0 -52
  192. package/dist/resolution/frameworks/index.js +0 -137
  193. package/dist/resolution/frameworks/java.d.ts +0 -8
  194. package/dist/resolution/frameworks/java.js +0 -177
  195. package/dist/resolution/frameworks/laravel.d.ts +0 -13
  196. package/dist/resolution/frameworks/laravel.js +0 -248
  197. package/dist/resolution/frameworks/nestjs.d.ts +0 -26
  198. package/dist/resolution/frameworks/nestjs.js +0 -374
  199. package/dist/resolution/frameworks/python.d.ts +0 -10
  200. package/dist/resolution/frameworks/python.js +0 -278
  201. package/dist/resolution/frameworks/react.d.ts +0 -8
  202. package/dist/resolution/frameworks/react.js +0 -272
  203. package/dist/resolution/frameworks/ruby.d.ts +0 -8
  204. package/dist/resolution/frameworks/ruby.js +0 -198
  205. package/dist/resolution/frameworks/rust.d.ts +0 -8
  206. package/dist/resolution/frameworks/rust.js +0 -207
  207. package/dist/resolution/frameworks/svelte.d.ts +0 -9
  208. package/dist/resolution/frameworks/svelte.js +0 -249
  209. package/dist/resolution/frameworks/swift.d.ts +0 -10
  210. package/dist/resolution/frameworks/swift.js +0 -376
  211. package/dist/resolution/frameworks/vue.d.ts +0 -9
  212. package/dist/resolution/frameworks/vue.js +0 -306
  213. package/dist/resolution/import-resolver.d.ts +0 -61
  214. package/dist/resolution/import-resolver.js +0 -663
  215. package/dist/resolution/index.d.ts +0 -118
  216. package/dist/resolution/index.js +0 -744
  217. package/dist/resolution/lru-cache.d.ts +0 -24
  218. package/dist/resolution/lru-cache.js +0 -62
  219. package/dist/resolution/name-matcher.d.ts +0 -50
  220. package/dist/resolution/name-matcher.js +0 -384
  221. package/dist/resolution/path-aliases.d.ts +0 -72
  222. package/dist/resolution/path-aliases.js +0 -238
  223. package/dist/resolution/strip-comments.d.ts +0 -40
  224. package/dist/resolution/strip-comments.js +0 -441
  225. package/dist/resolution/types.d.ts +0 -181
  226. package/dist/resolution/types.js +0 -8
  227. package/dist/search/query-parser.d.ts +0 -61
  228. package/dist/search/query-parser.js +0 -177
  229. package/dist/search/query-utils.d.ts +0 -59
  230. package/dist/search/query-utils.js +0 -383
  231. package/dist/sync/git-hooks.d.ts +0 -54
  232. package/dist/sync/git-hooks.js +0 -223
  233. package/dist/sync/index.d.ts +0 -25
  234. package/dist/sync/index.js +0 -28
  235. package/dist/sync/watch-policy.d.ts +0 -51
  236. package/dist/sync/watch-policy.js +0 -124
  237. package/dist/sync/watcher.d.ts +0 -83
  238. package/dist/sync/watcher.js +0 -192
  239. package/dist/types.d.ts +0 -433
  240. package/dist/types.js +0 -75
  241. package/dist/ui/glyphs.d.ts +0 -42
  242. package/dist/ui/shimmer-progress.d.ts +0 -11
  243. package/dist/ui/shimmer-worker.d.ts +0 -2
  244. package/dist/ui/types.d.ts +0 -20
  245. package/dist/utils.d.ts +0 -231
  246. package/dist/utils.js +0 -549
@@ -1,107 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.phpExtractor = void 0;
4
- const tree_sitter_helpers_1 = require("../tree-sitter-helpers");
5
- exports.phpExtractor = {
6
- functionTypes: ['function_definition'],
7
- classTypes: ['class_declaration', 'trait_declaration'],
8
- methodTypes: ['method_declaration'],
9
- interfaceTypes: ['interface_declaration'],
10
- structTypes: [],
11
- enumTypes: ['enum_declaration'],
12
- enumMemberTypes: ['enum_case'],
13
- typeAliasTypes: [],
14
- importTypes: ['namespace_use_declaration'],
15
- callTypes: ['function_call_expression', 'member_call_expression', 'scoped_call_expression'],
16
- variableTypes: ['const_declaration'],
17
- fieldTypes: ['property_declaration'],
18
- nameField: 'name',
19
- bodyField: 'body',
20
- paramsField: 'parameters',
21
- returnField: 'return_type',
22
- classifyClassNode: (node) => {
23
- return node.type === 'trait_declaration' ? 'trait' : 'class';
24
- },
25
- getVisibility: (node) => {
26
- for (let i = 0; i < node.childCount; i++) {
27
- const child = node.child(i);
28
- if (child?.type === 'visibility_modifier') {
29
- const text = child.text;
30
- if (text === 'public')
31
- return 'public';
32
- if (text === 'private')
33
- return 'private';
34
- if (text === 'protected')
35
- return 'protected';
36
- }
37
- }
38
- return 'public'; // PHP defaults to public
39
- },
40
- isStatic: (node) => {
41
- for (let i = 0; i < node.childCount; i++) {
42
- const child = node.child(i);
43
- if (child?.type === 'static_modifier')
44
- return true;
45
- }
46
- return false;
47
- },
48
- visitNode: (node, ctx) => {
49
- // Handle class constants: const_declaration inside classes
50
- // These are skipped by the main visitor because variableTypes check excludes class-like contexts
51
- if (node.type === 'const_declaration') {
52
- const constElements = node.namedChildren.filter((c) => c.type === 'const_element');
53
- for (const elem of constElements) {
54
- const nameNode = elem.namedChildren.find((c) => c.type === 'name');
55
- if (!nameNode)
56
- continue;
57
- const name = (0, tree_sitter_helpers_1.getNodeText)(nameNode, ctx.source);
58
- ctx.createNode('constant', name, elem, {});
59
- }
60
- return true; // handled
61
- }
62
- // Handle trait usage: use TraitName, OtherTrait; inside classes
63
- // Creates unresolved references that will be resolved to 'implements' edges
64
- if (node.type === 'use_declaration') {
65
- const names = node.namedChildren.filter((c) => c.type === 'name' || c.type === 'qualified_name');
66
- const parentId = ctx.nodeStack.length > 0 ? ctx.nodeStack[ctx.nodeStack.length - 1] : undefined;
67
- if (parentId) {
68
- for (const nameNode of names) {
69
- const traitName = (0, tree_sitter_helpers_1.getNodeText)(nameNode, ctx.source);
70
- ctx.addUnresolvedReference({
71
- fromNodeId: parentId,
72
- referenceName: traitName,
73
- referenceKind: 'implements',
74
- filePath: ctx.filePath,
75
- line: node.startPosition.row + 1,
76
- column: node.startPosition.column,
77
- });
78
- }
79
- }
80
- return true; // handled
81
- }
82
- return false;
83
- },
84
- extractImport: (node, source) => {
85
- const importText = source.substring(node.startIndex, node.endIndex).trim();
86
- // Check for grouped imports: use X\{A, B} - return null for core fallback
87
- const namespacePrefix = node.namedChildren.find((c) => c.type === 'namespace_name');
88
- const useGroup = node.namedChildren.find((c) => c.type === 'namespace_use_group');
89
- if (namespacePrefix && useGroup) {
90
- return null; // Grouped imports create multiple nodes - let core handle
91
- }
92
- // Single import - find namespace_use_clause
93
- const useClause = node.namedChildren.find((c) => c.type === 'namespace_use_clause');
94
- if (useClause) {
95
- const qualifiedName = useClause.namedChildren.find((c) => c.type === 'qualified_name');
96
- if (qualifiedName) {
97
- return { moduleName: (0, tree_sitter_helpers_1.getNodeText)(qualifiedName, source), signature: importText };
98
- }
99
- const name = useClause.namedChildren.find((c) => c.type === 'name');
100
- if (name) {
101
- return { moduleName: (0, tree_sitter_helpers_1.getNodeText)(name, source), signature: importText };
102
- }
103
- }
104
- return null;
105
- },
106
- };
107
- //# sourceMappingURL=php.js.map
@@ -1,3 +0,0 @@
1
- import type { LanguageExtractor } from '../tree-sitter-types'
2
- export declare const pythonExtractor: LanguageExtractor
3
- //# sourceMappingURL=python.d.ts.map
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pythonExtractor = void 0;
4
- const tree_sitter_helpers_1 = require("../tree-sitter-helpers");
5
- exports.pythonExtractor = {
6
- functionTypes: ['function_definition'],
7
- classTypes: ['class_definition'],
8
- methodTypes: ['function_definition'], // Methods are functions inside classes
9
- interfaceTypes: [],
10
- structTypes: [],
11
- enumTypes: [],
12
- typeAliasTypes: [],
13
- importTypes: ['import_statement', 'import_from_statement'],
14
- callTypes: ['call'],
15
- variableTypes: ['assignment'], // Python uses assignment for variable declarations
16
- nameField: 'name',
17
- bodyField: 'body',
18
- paramsField: 'parameters',
19
- returnField: 'return_type',
20
- getSignature: (node, source) => {
21
- const params = (0, tree_sitter_helpers_1.getChildByField)(node, 'parameters');
22
- const returnType = (0, tree_sitter_helpers_1.getChildByField)(node, 'return_type');
23
- if (!params)
24
- return undefined;
25
- let sig = (0, tree_sitter_helpers_1.getNodeText)(params, source);
26
- if (returnType) {
27
- sig += ' -> ' + (0, tree_sitter_helpers_1.getNodeText)(returnType, source);
28
- }
29
- return sig;
30
- },
31
- isAsync: (node) => {
32
- const prev = node.previousSibling;
33
- return prev?.type === 'async';
34
- },
35
- isStatic: (node) => {
36
- // Check for @staticmethod decorator
37
- const prev = node.previousNamedSibling;
38
- if (prev?.type === 'decorator') {
39
- const text = prev.text;
40
- return text.includes('staticmethod');
41
- }
42
- return false;
43
- },
44
- extractImport: (node, source) => {
45
- const importText = source.substring(node.startIndex, node.endIndex).trim();
46
- if (node.type === 'import_from_statement') {
47
- const moduleNode = node.childForFieldName('module_name');
48
- if (moduleNode) {
49
- return { moduleName: source.substring(moduleNode.startIndex, moduleNode.endIndex), signature: importText };
50
- }
51
- }
52
- // import_statement creates multiple imports - return null for core fallback
53
- return null;
54
- },
55
- };
56
- //# sourceMappingURL=python.js.map
@@ -1,3 +0,0 @@
1
- import type { LanguageExtractor } from '../tree-sitter-types'
2
- export declare const rubyExtractor: LanguageExtractor
3
- //# sourceMappingURL=ruby.d.ts.map
@@ -1,114 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rubyExtractor = void 0;
4
- const tree_sitter_helpers_1 = require("../tree-sitter-helpers");
5
- exports.rubyExtractor = {
6
- functionTypes: ['method'],
7
- classTypes: ['class'],
8
- methodTypes: ['method', 'singleton_method'],
9
- interfaceTypes: [], // Ruby uses modules (handled via visitNode hook)
10
- structTypes: [],
11
- enumTypes: [],
12
- typeAliasTypes: [],
13
- importTypes: ['call'], // require/require_relative
14
- callTypes: ['call', 'method_call'],
15
- variableTypes: ['assignment'], // Ruby uses assignment like Python
16
- nameField: 'name',
17
- bodyField: 'body',
18
- paramsField: 'parameters',
19
- visitNode: (node, ctx) => {
20
- if (node.type !== 'module')
21
- return false;
22
- const nameNode = node.childForFieldName('name');
23
- if (!nameNode)
24
- return false;
25
- const name = nameNode.text;
26
- const moduleNode = ctx.createNode('module', name, node);
27
- if (!moduleNode)
28
- return false;
29
- // Push module onto scope stack so children get proper qualified names
30
- ctx.pushScope(moduleNode.id);
31
- const body = node.childForFieldName('body');
32
- if (body) {
33
- for (let i = 0; i < body.namedChildCount; i++) {
34
- const child = body.namedChild(i);
35
- if (child)
36
- ctx.visitNode(child);
37
- }
38
- }
39
- ctx.popScope();
40
- return true; // handled
41
- },
42
- extractBareCall: (node, _source) => {
43
- // Ruby bare method calls (no parens, no receiver) parse as plain identifiers.
44
- // e.g., `reset` in a method body is `identifier "reset"` not a `call` node.
45
- if (node.type !== 'identifier')
46
- return undefined;
47
- const parent = node.parent;
48
- if (!parent)
49
- return undefined;
50
- // Only statement-level identifiers — direct children of block/body nodes
51
- const BLOCK_PARENTS = new Set([
52
- 'body_statement', 'then', 'else', 'do', 'begin',
53
- 'rescue', 'ensure', 'when',
54
- ]);
55
- if (!BLOCK_PARENTS.has(parent.type))
56
- return undefined;
57
- const name = node.text;
58
- // Skip Ruby keywords/literals
59
- const SKIP = new Set([
60
- 'true', 'false', 'nil', 'self', 'super',
61
- '__FILE__', '__LINE__', '__dir__',
62
- ]);
63
- if (SKIP.has(name))
64
- return undefined;
65
- // Skip constants (uppercase start) — these are class/module refs, not calls
66
- if (name.length > 0 && name.charCodeAt(0) >= 65 && name.charCodeAt(0) <= 90)
67
- return undefined;
68
- return name;
69
- },
70
- getVisibility: (node) => {
71
- // Ruby visibility is based on preceding visibility modifiers
72
- let sibling = node.previousNamedSibling;
73
- while (sibling) {
74
- if (sibling.type === 'call') {
75
- const methodName = (0, tree_sitter_helpers_1.getChildByField)(sibling, 'method');
76
- if (methodName) {
77
- const text = methodName.text;
78
- if (text === 'private')
79
- return 'private';
80
- if (text === 'protected')
81
- return 'protected';
82
- if (text === 'public')
83
- return 'public';
84
- }
85
- }
86
- sibling = sibling.previousNamedSibling;
87
- }
88
- return 'public';
89
- },
90
- extractImport: (node, source) => {
91
- const importText = source.substring(node.startIndex, node.endIndex).trim();
92
- // Check if this is a require/require_relative call
93
- const identifier = node.namedChildren.find((c) => c.type === 'identifier');
94
- if (!identifier)
95
- return null;
96
- const methodName = (0, tree_sitter_helpers_1.getNodeText)(identifier, source);
97
- if (methodName !== 'require' && methodName !== 'require_relative') {
98
- return null; // Not an import, skip
99
- }
100
- // Find the argument (string)
101
- const argList = node.namedChildren.find((c) => c.type === 'argument_list');
102
- if (argList) {
103
- const stringNode = argList.namedChildren.find((c) => c.type === 'string');
104
- if (stringNode) {
105
- const stringContent = stringNode.namedChildren.find((c) => c.type === 'string_content');
106
- if (stringContent) {
107
- return { moduleName: (0, tree_sitter_helpers_1.getNodeText)(stringContent, source), signature: importText };
108
- }
109
- }
110
- }
111
- return null;
112
- },
113
- };
114
- //# sourceMappingURL=ruby.js.map
@@ -1,3 +0,0 @@
1
- import type { LanguageExtractor } from '../tree-sitter-types'
2
- export declare const rustExtractor: LanguageExtractor
3
- //# sourceMappingURL=rust.d.ts.map
@@ -1,109 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rustExtractor = void 0;
4
- const tree_sitter_helpers_1 = require("../tree-sitter-helpers");
5
- exports.rustExtractor = {
6
- functionTypes: ['function_item'],
7
- classTypes: [], // Rust has impl blocks
8
- methodTypes: ['function_item'], // Methods are functions in impl blocks
9
- interfaceTypes: ['trait_item'],
10
- structTypes: ['struct_item'],
11
- enumTypes: ['enum_item'],
12
- enumMemberTypes: ['enum_variant'],
13
- typeAliasTypes: ['type_item'], // Rust type aliases
14
- importTypes: ['use_declaration'],
15
- callTypes: ['call_expression'],
16
- variableTypes: ['let_declaration', 'const_item', 'static_item'],
17
- interfaceKind: 'trait',
18
- nameField: 'name',
19
- bodyField: 'body',
20
- paramsField: 'parameters',
21
- returnField: 'return_type',
22
- getSignature: (node, source) => {
23
- const params = (0, tree_sitter_helpers_1.getChildByField)(node, 'parameters');
24
- const returnType = (0, tree_sitter_helpers_1.getChildByField)(node, 'return_type');
25
- if (!params)
26
- return undefined;
27
- let sig = (0, tree_sitter_helpers_1.getNodeText)(params, source);
28
- if (returnType) {
29
- sig += ' -> ' + (0, tree_sitter_helpers_1.getNodeText)(returnType, source);
30
- }
31
- return sig;
32
- },
33
- isAsync: (node) => {
34
- for (let i = 0; i < node.childCount; i++) {
35
- const child = node.child(i);
36
- if (child?.type === 'async')
37
- return true;
38
- }
39
- return false;
40
- },
41
- getVisibility: (node) => {
42
- for (let i = 0; i < node.childCount; i++) {
43
- const child = node.child(i);
44
- if (child?.type === 'visibility_modifier') {
45
- return child.text.includes('pub') ? 'public' : 'private';
46
- }
47
- }
48
- return 'private'; // Rust defaults to private
49
- },
50
- getReceiverType: (node, source) => {
51
- // Walk up the tree-sitter AST to find a parent impl_item
52
- let parent = node.parent;
53
- while (parent) {
54
- if (parent.type === 'impl_item') {
55
- // For `impl Type { ... }` — the type is a direct type_identifier child
56
- // For `impl Trait for Type { ... }` — the type is the LAST type_identifier
57
- // (the first is part of the trait path)
58
- const children = parent.namedChildren;
59
- // Find all direct type_identifier children (not nested in scoped paths)
60
- const typeIdents = children.filter((c) => c.type === 'type_identifier');
61
- if (typeIdents.length > 0) {
62
- // Last type_identifier is always the implementing type
63
- const typeNode = typeIdents[typeIdents.length - 1];
64
- return source.substring(typeNode.startIndex, typeNode.endIndex);
65
- }
66
- // Handle generic types: impl<T> MyStruct<T> { ... }
67
- const genericType = children.find((c) => c.type === 'generic_type');
68
- if (genericType) {
69
- const innerType = genericType.namedChildren.find((c) => c.type === 'type_identifier');
70
- if (innerType) {
71
- return source.substring(innerType.startIndex, innerType.endIndex);
72
- }
73
- }
74
- return undefined;
75
- }
76
- parent = parent.parent;
77
- }
78
- return undefined;
79
- },
80
- extractImport: (node, source) => {
81
- const importText = source.substring(node.startIndex, node.endIndex).trim();
82
- // Helper to get the root crate/module from a scoped path
83
- const getRootModule = (scopedNode) => {
84
- const firstChild = scopedNode.namedChild(0);
85
- if (!firstChild)
86
- return source.substring(scopedNode.startIndex, scopedNode.endIndex);
87
- if (firstChild.type === 'identifier' ||
88
- firstChild.type === 'crate' ||
89
- firstChild.type === 'super' ||
90
- firstChild.type === 'self') {
91
- return source.substring(firstChild.startIndex, firstChild.endIndex);
92
- }
93
- else if (firstChild.type === 'scoped_identifier') {
94
- return getRootModule(firstChild);
95
- }
96
- return source.substring(firstChild.startIndex, firstChild.endIndex);
97
- };
98
- // Find the use argument (scoped_use_list or scoped_identifier)
99
- const useArg = node.namedChildren.find((c) => c.type === 'scoped_use_list' ||
100
- c.type === 'scoped_identifier' ||
101
- c.type === 'use_list' ||
102
- c.type === 'identifier');
103
- if (useArg) {
104
- return { moduleName: getRootModule(useArg), signature: importText };
105
- }
106
- return null;
107
- },
108
- };
109
- //# sourceMappingURL=rust.js.map
@@ -1,3 +0,0 @@
1
- import type { LanguageExtractor } from '../tree-sitter-types'
2
- export declare const scalaExtractor: LanguageExtractor
3
- //# sourceMappingURL=scala.d.ts.map
@@ -1,139 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.scalaExtractor = void 0;
4
- const tree_sitter_helpers_1 = require("../tree-sitter-helpers");
5
- function getValVarName(node, source) {
6
- const patternNode = node.childForFieldName('pattern');
7
- if (!patternNode)
8
- return null;
9
- if (patternNode.type === 'identifier')
10
- return (0, tree_sitter_helpers_1.getNodeText)(patternNode, source);
11
- const identChild = patternNode.namedChildren.find((c) => c.type === 'identifier');
12
- return identChild ? (0, tree_sitter_helpers_1.getNodeText)(identChild, source) : null;
13
- }
14
- function extractVisibility(node) {
15
- for (let i = 0; i < node.namedChildCount; i++) {
16
- const child = node.namedChild(i);
17
- if (!child)
18
- continue;
19
- if (child.type === 'modifiers' || child.type === 'access_modifier') {
20
- const text = child.text;
21
- if (text.includes('private'))
22
- return 'private';
23
- if (text.includes('protected'))
24
- return 'protected';
25
- }
26
- }
27
- return 'public';
28
- }
29
- exports.scalaExtractor = {
30
- // top-level function_definition is handled via methodTypes (same pattern as Kotlin)
31
- functionTypes: [],
32
- classTypes: ['class_definition', 'object_definition', 'trait_definition'],
33
- methodTypes: ['function_definition', 'function_declaration'],
34
- interfaceTypes: [],
35
- structTypes: [],
36
- enumTypes: ['enum_definition'],
37
- enumMemberTypes: [], // handled in visitNode — enum_case_definitions wraps the cases
38
- typeAliasTypes: ['type_definition'],
39
- importTypes: ['import_declaration'],
40
- callTypes: ['call_expression'],
41
- variableTypes: [], // val/var handled in visitNode (use `pattern` field, not `name`)
42
- fieldTypes: [],
43
- extraClassNodeTypes: [],
44
- nameField: 'name',
45
- bodyField: 'body',
46
- paramsField: 'parameters',
47
- returnField: 'return_type',
48
- interfaceKind: 'trait',
49
- classifyClassNode: (node) => {
50
- if (node.type === 'trait_definition')
51
- return 'trait';
52
- return 'class';
53
- },
54
- getSignature: (node, source) => {
55
- const params = node.childForFieldName('parameters');
56
- const returnType = node.childForFieldName('return_type');
57
- if (!params && !returnType)
58
- return undefined;
59
- let sig = params ? (0, tree_sitter_helpers_1.getNodeText)(params, source) : '';
60
- if (returnType)
61
- sig += ': ' + (0, tree_sitter_helpers_1.getNodeText)(returnType, source);
62
- return sig || undefined;
63
- },
64
- getVisibility: (node) => extractVisibility(node),
65
- isAsync: () => false,
66
- isStatic: (node) => {
67
- for (let i = 0; i < node.namedChildCount; i++) {
68
- const child = node.namedChild(i);
69
- if (child?.type === 'modifiers' && child.text.includes('static'))
70
- return true;
71
- }
72
- return false;
73
- },
74
- visitNode: (node, ctx) => {
75
- const t = node.type;
76
- // val/var: name is in `pattern` field (identifier), not `name`
77
- if (t === 'val_definition' || t === 'var_definition') {
78
- const name = getValVarName(node, ctx.source);
79
- if (!name)
80
- return false;
81
- const isInClass = ctx.nodeStack.length > 0 &&
82
- (() => {
83
- const parentId = ctx.nodeStack[ctx.nodeStack.length - 1];
84
- const parentNode = ctx.nodes.find((n) => n.id === parentId);
85
- return parentNode != null && (parentNode.kind === 'class' || parentNode.kind === 'trait' ||
86
- parentNode.kind === 'interface' || parentNode.kind === 'struct' ||
87
- parentNode.kind === 'enum' || parentNode.kind === 'module');
88
- })();
89
- const kind = isInClass ? 'field' : (t === 'val_definition' ? 'constant' : 'variable');
90
- const typeNode = node.childForFieldName('type');
91
- const sig = typeNode
92
- ? `${t === 'val_definition' ? 'val' : 'var'} ${name}: ${(0, tree_sitter_helpers_1.getNodeText)(typeNode, ctx.source)}`
93
- : undefined;
94
- ctx.createNode(kind, name, node, { signature: sig, visibility: extractVisibility(node) });
95
- return true;
96
- }
97
- // enum_case_definitions wraps simple_enum_case / full_enum_case children
98
- if (t === 'enum_case_definitions') {
99
- for (let i = 0; i < node.namedChildCount; i++) {
100
- const child = node.namedChild(i);
101
- if (!child)
102
- continue;
103
- if (child.type === 'simple_enum_case' || child.type === 'full_enum_case') {
104
- const nameNode = child.childForFieldName('name');
105
- if (nameNode)
106
- ctx.createNode('enum_member', (0, tree_sitter_helpers_1.getNodeText)(nameNode, ctx.source), child);
107
- }
108
- }
109
- return true;
110
- }
111
- // extension_definition: visit body children directly, no container node
112
- if (t === 'extension_definition') {
113
- const body = node.childForFieldName('body');
114
- if (body) {
115
- for (let i = 0; i < body.namedChildCount; i++) {
116
- const child = body.namedChild(i);
117
- if (child)
118
- ctx.visitNode(child);
119
- }
120
- }
121
- return true;
122
- }
123
- return false;
124
- },
125
- extractImport: (node, source) => {
126
- const importText = (0, tree_sitter_helpers_1.getNodeText)(node, source).trim();
127
- const pathNode = node.childForFieldName('path');
128
- if (pathNode)
129
- return { moduleName: (0, tree_sitter_helpers_1.getNodeText)(pathNode, source), signature: importText };
130
- for (let i = 0; i < node.namedChildCount; i++) {
131
- const child = node.namedChild(i);
132
- if (child?.type === 'identifier' || child?.type === 'stable_identifier') {
133
- return { moduleName: (0, tree_sitter_helpers_1.getNodeText)(child, source), signature: importText };
134
- }
135
- }
136
- return null;
137
- },
138
- };
139
- //# sourceMappingURL=scala.js.map
@@ -1,3 +0,0 @@
1
- import type { LanguageExtractor } from '../tree-sitter-types'
2
- export declare const swiftExtractor: LanguageExtractor
3
- //# sourceMappingURL=swift.d.ts.map
@@ -1,91 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.swiftExtractor = void 0;
4
- const tree_sitter_helpers_1 = require("../tree-sitter-helpers");
5
- exports.swiftExtractor = {
6
- functionTypes: ['function_declaration'],
7
- classTypes: ['class_declaration'],
8
- methodTypes: ['function_declaration'], // Methods are functions inside classes
9
- interfaceTypes: ['protocol_declaration'],
10
- structTypes: ['struct_declaration'],
11
- enumTypes: ['enum_declaration'],
12
- enumMemberTypes: ['enum_entry'],
13
- typeAliasTypes: ['typealias_declaration'],
14
- importTypes: ['import_declaration'],
15
- callTypes: ['call_expression'],
16
- variableTypes: ['property_declaration', 'constant_declaration'],
17
- nameField: 'name',
18
- bodyField: 'body',
19
- paramsField: 'parameter',
20
- returnField: 'return_type',
21
- getSignature: (node, source) => {
22
- // Swift function signature: func name(params) -> ReturnType
23
- const params = (0, tree_sitter_helpers_1.getChildByField)(node, 'parameter');
24
- const returnType = (0, tree_sitter_helpers_1.getChildByField)(node, 'return_type');
25
- if (!params)
26
- return undefined;
27
- let sig = (0, tree_sitter_helpers_1.getNodeText)(params, source);
28
- if (returnType) {
29
- sig += ' -> ' + (0, tree_sitter_helpers_1.getNodeText)(returnType, source);
30
- }
31
- return sig;
32
- },
33
- getVisibility: (node) => {
34
- // Check for visibility modifiers in Swift
35
- for (let i = 0; i < node.childCount; i++) {
36
- const child = node.child(i);
37
- if (child?.type === 'modifiers') {
38
- const text = child.text;
39
- if (text.includes('public'))
40
- return 'public';
41
- if (text.includes('private'))
42
- return 'private';
43
- if (text.includes('internal'))
44
- return 'internal';
45
- if (text.includes('fileprivate'))
46
- return 'private';
47
- }
48
- }
49
- return 'internal'; // Swift defaults to internal
50
- },
51
- isStatic: (node) => {
52
- for (let i = 0; i < node.childCount; i++) {
53
- const child = node.child(i);
54
- if (child?.type === 'modifiers') {
55
- if (child.text.includes('static') || child.text.includes('class')) {
56
- return true;
57
- }
58
- }
59
- }
60
- return false;
61
- },
62
- classifyClassNode: (node) => {
63
- // Swift uses class_declaration for classes, structs, and enums
64
- for (let i = 0; i < node.childCount; i++) {
65
- const child = node.child(i);
66
- if (child?.type === 'struct')
67
- return 'struct';
68
- if (child?.type === 'enum')
69
- return 'enum';
70
- }
71
- return 'class';
72
- },
73
- isAsync: (node) => {
74
- for (let i = 0; i < node.childCount; i++) {
75
- const child = node.child(i);
76
- if (child?.type === 'modifiers' && child.text.includes('async')) {
77
- return true;
78
- }
79
- }
80
- return false;
81
- },
82
- extractImport: (node, source) => {
83
- const importText = source.substring(node.startIndex, node.endIndex).trim();
84
- const identifier = node.namedChildren.find((c) => c.type === 'identifier');
85
- if (identifier) {
86
- return { moduleName: source.substring(identifier.startIndex, identifier.endIndex), signature: importText };
87
- }
88
- return null;
89
- },
90
- };
91
- //# sourceMappingURL=swift.js.map
@@ -1,3 +0,0 @@
1
- import type { LanguageExtractor } from '../tree-sitter-types'
2
- export declare const typescriptExtractor: LanguageExtractor
3
- //# sourceMappingURL=typescript.d.ts.map