@saluzi/codegraph 0.1.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 (189) hide show
  1. package/dist/bin/codegraph.d.ts +25 -0
  2. package/dist/bin/node-version-check.d.ts +37 -0
  3. package/dist/bin/uninstall.d.ts +14 -0
  4. package/dist/context/formatter.d.ts +33 -0
  5. package/dist/context/formatter.js +244 -0
  6. package/dist/context/index.d.ts +117 -0
  7. package/dist/context/index.js +1050 -0
  8. package/dist/db/index.d.ts +101 -0
  9. package/dist/db/index.js +250 -0
  10. package/dist/db/migrations.d.ts +47 -0
  11. package/dist/db/migrations.js +131 -0
  12. package/dist/db/queries.d.ts +291 -0
  13. package/dist/db/queries.js +1349 -0
  14. package/dist/db/schema.sql +151 -0
  15. package/dist/db/sqlite-adapter.d.ts +49 -0
  16. package/dist/db/sqlite-adapter.js +141 -0
  17. package/dist/directory.d.ts +62 -0
  18. package/dist/directory.js +264 -0
  19. package/dist/errors.d.ts +149 -0
  20. package/dist/errors.js +219 -0
  21. package/dist/extraction/dfm-extractor.d.ts +31 -0
  22. package/dist/extraction/dfm-extractor.js +151 -0
  23. package/dist/extraction/grammars.d.ts +94 -0
  24. package/dist/extraction/grammars.js +357 -0
  25. package/dist/extraction/index.d.ts +148 -0
  26. package/dist/extraction/index.js +1286 -0
  27. package/dist/extraction/languages/c-cpp.d.ts +4 -0
  28. package/dist/extraction/languages/c-cpp.js +126 -0
  29. package/dist/extraction/languages/csharp.d.ts +3 -0
  30. package/dist/extraction/languages/csharp.js +72 -0
  31. package/dist/extraction/languages/dart.d.ts +3 -0
  32. package/dist/extraction/languages/dart.js +192 -0
  33. package/dist/extraction/languages/go.d.ts +3 -0
  34. package/dist/extraction/languages/go.js +58 -0
  35. package/dist/extraction/languages/index.d.ts +10 -0
  36. package/dist/extraction/languages/index.js +49 -0
  37. package/dist/extraction/languages/java.d.ts +3 -0
  38. package/dist/extraction/languages/java.js +64 -0
  39. package/dist/extraction/languages/javascript.d.ts +3 -0
  40. package/dist/extraction/languages/javascript.js +90 -0
  41. package/dist/extraction/languages/kotlin.d.ts +3 -0
  42. package/dist/extraction/languages/kotlin.js +253 -0
  43. package/dist/extraction/languages/lua.d.ts +3 -0
  44. package/dist/extraction/languages/lua.js +150 -0
  45. package/dist/extraction/languages/luau.d.ts +3 -0
  46. package/dist/extraction/languages/luau.js +37 -0
  47. package/dist/extraction/languages/pascal.d.ts +3 -0
  48. package/dist/extraction/languages/pascal.js +66 -0
  49. package/dist/extraction/languages/php.d.ts +3 -0
  50. package/dist/extraction/languages/php.js +107 -0
  51. package/dist/extraction/languages/python.d.ts +3 -0
  52. package/dist/extraction/languages/python.js +56 -0
  53. package/dist/extraction/languages/ruby.d.ts +3 -0
  54. package/dist/extraction/languages/ruby.js +114 -0
  55. package/dist/extraction/languages/rust.d.ts +3 -0
  56. package/dist/extraction/languages/rust.js +109 -0
  57. package/dist/extraction/languages/scala.d.ts +3 -0
  58. package/dist/extraction/languages/scala.js +139 -0
  59. package/dist/extraction/languages/swift.d.ts +3 -0
  60. package/dist/extraction/languages/swift.js +91 -0
  61. package/dist/extraction/languages/typescript.d.ts +3 -0
  62. package/dist/extraction/languages/typescript.js +129 -0
  63. package/dist/extraction/liquid-extractor.d.ts +52 -0
  64. package/dist/extraction/liquid-extractor.js +313 -0
  65. package/dist/extraction/parse-worker.d.ts +8 -0
  66. package/dist/extraction/parse-worker.js +94 -0
  67. package/dist/extraction/svelte-extractor.d.ts +56 -0
  68. package/dist/extraction/svelte-extractor.js +272 -0
  69. package/dist/extraction/tree-sitter-helpers.d.ts +39 -0
  70. package/dist/extraction/tree-sitter-helpers.js +103 -0
  71. package/dist/extraction/tree-sitter-types.d.ts +191 -0
  72. package/dist/extraction/tree-sitter-types.js +10 -0
  73. package/dist/extraction/tree-sitter.d.ts +238 -0
  74. package/dist/extraction/tree-sitter.js +2430 -0
  75. package/dist/extraction/vue-extractor.d.ts +36 -0
  76. package/dist/extraction/vue-extractor.js +163 -0
  77. package/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
  78. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  79. package/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
  80. package/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
  81. package/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
  82. package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  83. package/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
  84. package/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  85. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  86. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  87. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  88. package/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
  89. package/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
  90. package/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
  91. package/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
  92. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  93. package/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
  94. package/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
  95. package/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
  96. package/dist/extraction/wasm-runtime-flags.d.ts +46 -0
  97. package/dist/extraction/wasm-runtime-flags.js +105 -0
  98. package/dist/graph/index.d.ts +8 -0
  99. package/dist/graph/index.js +13 -0
  100. package/dist/graph/queries.d.ts +109 -0
  101. package/dist/graph/queries.js +366 -0
  102. package/dist/graph/traversal.d.ts +137 -0
  103. package/dist/graph/traversal.js +528 -0
  104. package/dist/index.d.ts +509 -0
  105. package/dist/index.js +800 -0
  106. package/dist/installer/claude-md-template.d.ts +19 -0
  107. package/dist/installer/config-writer.d.ts +29 -0
  108. package/dist/installer/index.d.ts +140 -0
  109. package/dist/installer/instructions-template.d.ts +30 -0
  110. package/dist/installer/targets/claude.d.ts +55 -0
  111. package/dist/installer/targets/codex.d.ts +18 -0
  112. package/dist/installer/targets/cursor.d.ts +35 -0
  113. package/dist/installer/targets/hermes.d.ts +18 -0
  114. package/dist/installer/targets/opencode.d.ts +30 -0
  115. package/dist/installer/targets/registry.d.ts +38 -0
  116. package/dist/installer/targets/shared.d.ts +92 -0
  117. package/dist/installer/targets/toml.d.ts +64 -0
  118. package/dist/installer/targets/types.d.ts +122 -0
  119. package/dist/mcp/index.d.ts +98 -0
  120. package/dist/mcp/server-instructions.d.ts +20 -0
  121. package/dist/mcp/tools.d.ts +269 -0
  122. package/dist/mcp/transport.d.ts +117 -0
  123. package/dist/resolution/frameworks/cargo-workspace.d.ts +20 -0
  124. package/dist/resolution/frameworks/cargo-workspace.js +225 -0
  125. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  126. package/dist/resolution/frameworks/csharp.js +213 -0
  127. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  128. package/dist/resolution/frameworks/drupal.js +335 -0
  129. package/dist/resolution/frameworks/express.d.ts +8 -0
  130. package/dist/resolution/frameworks/express.js +225 -0
  131. package/dist/resolution/frameworks/go.d.ts +8 -0
  132. package/dist/resolution/frameworks/go.js +158 -0
  133. package/dist/resolution/frameworks/index.d.ts +52 -0
  134. package/dist/resolution/frameworks/index.js +137 -0
  135. package/dist/resolution/frameworks/java.d.ts +8 -0
  136. package/dist/resolution/frameworks/java.js +177 -0
  137. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  138. package/dist/resolution/frameworks/laravel.js +248 -0
  139. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  140. package/dist/resolution/frameworks/nestjs.js +374 -0
  141. package/dist/resolution/frameworks/python.d.ts +10 -0
  142. package/dist/resolution/frameworks/python.js +278 -0
  143. package/dist/resolution/frameworks/react.d.ts +8 -0
  144. package/dist/resolution/frameworks/react.js +272 -0
  145. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  146. package/dist/resolution/frameworks/ruby.js +198 -0
  147. package/dist/resolution/frameworks/rust.d.ts +8 -0
  148. package/dist/resolution/frameworks/rust.js +207 -0
  149. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  150. package/dist/resolution/frameworks/svelte.js +249 -0
  151. package/dist/resolution/frameworks/swift.d.ts +10 -0
  152. package/dist/resolution/frameworks/swift.js +376 -0
  153. package/dist/resolution/frameworks/vue.d.ts +9 -0
  154. package/dist/resolution/frameworks/vue.js +306 -0
  155. package/dist/resolution/import-resolver.d.ts +61 -0
  156. package/dist/resolution/import-resolver.js +663 -0
  157. package/dist/resolution/index.d.ts +118 -0
  158. package/dist/resolution/index.js +744 -0
  159. package/dist/resolution/lru-cache.d.ts +24 -0
  160. package/dist/resolution/lru-cache.js +62 -0
  161. package/dist/resolution/name-matcher.d.ts +50 -0
  162. package/dist/resolution/name-matcher.js +384 -0
  163. package/dist/resolution/path-aliases.d.ts +72 -0
  164. package/dist/resolution/path-aliases.js +238 -0
  165. package/dist/resolution/strip-comments.d.ts +40 -0
  166. package/dist/resolution/strip-comments.js +441 -0
  167. package/dist/resolution/types.d.ts +181 -0
  168. package/dist/resolution/types.js +8 -0
  169. package/dist/search/query-parser.d.ts +61 -0
  170. package/dist/search/query-parser.js +177 -0
  171. package/dist/search/query-utils.d.ts +59 -0
  172. package/dist/search/query-utils.js +383 -0
  173. package/dist/sync/git-hooks.d.ts +54 -0
  174. package/dist/sync/git-hooks.js +223 -0
  175. package/dist/sync/index.d.ts +25 -0
  176. package/dist/sync/index.js +28 -0
  177. package/dist/sync/watch-policy.d.ts +51 -0
  178. package/dist/sync/watch-policy.js +124 -0
  179. package/dist/sync/watcher.d.ts +83 -0
  180. package/dist/sync/watcher.js +192 -0
  181. package/dist/types.d.ts +433 -0
  182. package/dist/types.js +75 -0
  183. package/dist/ui/glyphs.d.ts +42 -0
  184. package/dist/ui/shimmer-progress.d.ts +11 -0
  185. package/dist/ui/shimmer-worker.d.ts +2 -0
  186. package/dist/ui/types.d.ts +20 -0
  187. package/dist/utils.d.ts +231 -0
  188. package/dist/utils.js +549 -0
  189. package/package.json +24 -0
@@ -0,0 +1,107 @@
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
@@ -0,0 +1,3 @@
1
+ import type { LanguageExtractor } from '../tree-sitter-types'
2
+ export declare const pythonExtractor: LanguageExtractor
3
+ //# sourceMappingURL=python.d.ts.map
@@ -0,0 +1,56 @@
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
@@ -0,0 +1,3 @@
1
+ import type { LanguageExtractor } from '../tree-sitter-types'
2
+ export declare const rubyExtractor: LanguageExtractor
3
+ //# sourceMappingURL=ruby.d.ts.map
@@ -0,0 +1,114 @@
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
@@ -0,0 +1,3 @@
1
+ import type { LanguageExtractor } from '../tree-sitter-types'
2
+ export declare const rustExtractor: LanguageExtractor
3
+ //# sourceMappingURL=rust.d.ts.map
@@ -0,0 +1,109 @@
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
@@ -0,0 +1,3 @@
1
+ import type { LanguageExtractor } from '../tree-sitter-types'
2
+ export declare const scalaExtractor: LanguageExtractor
3
+ //# sourceMappingURL=scala.d.ts.map
@@ -0,0 +1,139 @@
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
@@ -0,0 +1,3 @@
1
+ import type { LanguageExtractor } from '../tree-sitter-types'
2
+ export declare const swiftExtractor: LanguageExtractor
3
+ //# sourceMappingURL=swift.d.ts.map
@@ -0,0 +1,91 @@
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
@@ -0,0 +1,3 @@
1
+ import type { LanguageExtractor } from '../tree-sitter-types'
2
+ export declare const typescriptExtractor: LanguageExtractor
3
+ //# sourceMappingURL=typescript.d.ts.map