@mka-rainmaker/ama 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 (211) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +149 -0
  3. package/dist/analyzers/baseline/analyzer.d.ts +47 -0
  4. package/dist/analyzers/baseline/analyzer.d.ts.map +1 -0
  5. package/dist/analyzers/baseline/analyzer.js +84 -0
  6. package/dist/analyzers/baseline/analyzer.js.map +1 -0
  7. package/dist/analyzers/baseline/c.d.ts +12 -0
  8. package/dist/analyzers/baseline/c.d.ts.map +1 -0
  9. package/dist/analyzers/baseline/c.js +56 -0
  10. package/dist/analyzers/baseline/c.js.map +1 -0
  11. package/dist/analyzers/baseline/config.d.ts +21 -0
  12. package/dist/analyzers/baseline/config.d.ts.map +1 -0
  13. package/dist/analyzers/baseline/config.js +32 -0
  14. package/dist/analyzers/baseline/config.js.map +1 -0
  15. package/dist/analyzers/baseline/csharp.d.ts +9 -0
  16. package/dist/analyzers/baseline/csharp.d.ts.map +1 -0
  17. package/dist/analyzers/baseline/csharp.js +107 -0
  18. package/dist/analyzers/baseline/csharp.js.map +1 -0
  19. package/dist/analyzers/baseline/go.d.ts +11 -0
  20. package/dist/analyzers/baseline/go.d.ts.map +1 -0
  21. package/dist/analyzers/baseline/go.js +66 -0
  22. package/dist/analyzers/baseline/go.js.map +1 -0
  23. package/dist/analyzers/baseline/java.d.ts +9 -0
  24. package/dist/analyzers/baseline/java.d.ts.map +1 -0
  25. package/dist/analyzers/baseline/java.js +50 -0
  26. package/dist/analyzers/baseline/java.js.map +1 -0
  27. package/dist/analyzers/baseline/javascript.d.ts +10 -0
  28. package/dist/analyzers/baseline/javascript.d.ts.map +1 -0
  29. package/dist/analyzers/baseline/javascript.js +55 -0
  30. package/dist/analyzers/baseline/javascript.js.map +1 -0
  31. package/dist/analyzers/baseline/kotlin.d.ts +11 -0
  32. package/dist/analyzers/baseline/kotlin.d.ts.map +1 -0
  33. package/dist/analyzers/baseline/kotlin.js +67 -0
  34. package/dist/analyzers/baseline/kotlin.js.map +1 -0
  35. package/dist/analyzers/baseline/paths.d.ts +6 -0
  36. package/dist/analyzers/baseline/paths.d.ts.map +1 -0
  37. package/dist/analyzers/baseline/paths.js +17 -0
  38. package/dist/analyzers/baseline/paths.js.map +1 -0
  39. package/dist/analyzers/baseline/php.d.ts +11 -0
  40. package/dist/analyzers/baseline/php.d.ts.map +1 -0
  41. package/dist/analyzers/baseline/php.js +76 -0
  42. package/dist/analyzers/baseline/php.js.map +1 -0
  43. package/dist/analyzers/baseline/python.d.ts +10 -0
  44. package/dist/analyzers/baseline/python.d.ts.map +1 -0
  45. package/dist/analyzers/baseline/python.js +63 -0
  46. package/dist/analyzers/baseline/python.js.map +1 -0
  47. package/dist/analyzers/baseline/rust.d.ts +10 -0
  48. package/dist/analyzers/baseline/rust.d.ts.map +1 -0
  49. package/dist/analyzers/baseline/rust.js +45 -0
  50. package/dist/analyzers/baseline/rust.js.map +1 -0
  51. package/dist/analyzers/baseline/swift.d.ts +11 -0
  52. package/dist/analyzers/baseline/swift.d.ts.map +1 -0
  53. package/dist/analyzers/baseline/swift.js +19 -0
  54. package/dist/analyzers/baseline/swift.js.map +1 -0
  55. package/dist/analyzers/baseline/treesitter.d.ts +11 -0
  56. package/dist/analyzers/baseline/treesitter.d.ts.map +1 -0
  57. package/dist/analyzers/baseline/treesitter.js +87 -0
  58. package/dist/analyzers/baseline/treesitter.js.map +1 -0
  59. package/dist/analyzers/baseline/walk.d.ts +26 -0
  60. package/dist/analyzers/baseline/walk.d.ts.map +1 -0
  61. package/dist/analyzers/baseline/walk.js +76 -0
  62. package/dist/analyzers/baseline/walk.js.map +1 -0
  63. package/dist/analyzers/registry.d.ts +19 -0
  64. package/dist/analyzers/registry.d.ts.map +1 -0
  65. package/dist/analyzers/registry.js +43 -0
  66. package/dist/analyzers/registry.js.map +1 -0
  67. package/dist/analyzers/sfc/analyzer.d.ts +17 -0
  68. package/dist/analyzers/sfc/analyzer.d.ts.map +1 -0
  69. package/dist/analyzers/sfc/analyzer.js +141 -0
  70. package/dist/analyzers/sfc/analyzer.js.map +1 -0
  71. package/dist/analyzers/sidecar/analyzer.d.ts +29 -0
  72. package/dist/analyzers/sidecar/analyzer.d.ts.map +1 -0
  73. package/dist/analyzers/sidecar/analyzer.js +114 -0
  74. package/dist/analyzers/sidecar/analyzer.js.map +1 -0
  75. package/dist/analyzers/sidecar/protocol.d.ts +508 -0
  76. package/dist/analyzers/sidecar/protocol.d.ts.map +1 -0
  77. package/dist/analyzers/sidecar/protocol.js +102 -0
  78. package/dist/analyzers/sidecar/protocol.js.map +1 -0
  79. package/dist/analyzers/types.d.ts +46 -0
  80. package/dist/analyzers/types.d.ts.map +1 -0
  81. package/dist/analyzers/types.js +2 -0
  82. package/dist/analyzers/types.js.map +1 -0
  83. package/dist/analyzers/typescript/analyzer.d.ts +126 -0
  84. package/dist/analyzers/typescript/analyzer.d.ts.map +1 -0
  85. package/dist/analyzers/typescript/analyzer.js +1600 -0
  86. package/dist/analyzers/typescript/analyzer.js.map +1 -0
  87. package/dist/cli/commands/cycles.d.ts +6 -0
  88. package/dist/cli/commands/cycles.d.ts.map +1 -0
  89. package/dist/cli/commands/cycles.js +27 -0
  90. package/dist/cli/commands/cycles.js.map +1 -0
  91. package/dist/cli/commands/files.d.ts +6 -0
  92. package/dist/cli/commands/files.d.ts.map +1 -0
  93. package/dist/cli/commands/files.js +33 -0
  94. package/dist/cli/commands/files.js.map +1 -0
  95. package/dist/cli/commands/impact.d.ts +18 -0
  96. package/dist/cli/commands/impact.d.ts.map +1 -0
  97. package/dist/cli/commands/impact.js +113 -0
  98. package/dist/cli/commands/impact.js.map +1 -0
  99. package/dist/cli/commands/lifecycle.d.ts +5 -0
  100. package/dist/cli/commands/lifecycle.d.ts.map +1 -0
  101. package/dist/cli/commands/lifecycle.js +83 -0
  102. package/dist/cli/commands/lifecycle.js.map +1 -0
  103. package/dist/cli/commands/query.d.ts +31 -0
  104. package/dist/cli/commands/query.d.ts.map +1 -0
  105. package/dist/cli/commands/query.js +187 -0
  106. package/dist/cli/commands/query.js.map +1 -0
  107. package/dist/cli/commands/search.d.ts +21 -0
  108. package/dist/cli/commands/search.d.ts.map +1 -0
  109. package/dist/cli/commands/search.js +160 -0
  110. package/dist/cli/commands/search.js.map +1 -0
  111. package/dist/cli/commands/status.d.ts +6 -0
  112. package/dist/cli/commands/status.d.ts.map +1 -0
  113. package/dist/cli/commands/status.js +63 -0
  114. package/dist/cli/commands/status.js.map +1 -0
  115. package/dist/cli/commands/sync.d.ts +6 -0
  116. package/dist/cli/commands/sync.d.ts.map +1 -0
  117. package/dist/cli/commands/sync.js +57 -0
  118. package/dist/cli/commands/sync.js.map +1 -0
  119. package/dist/cli/emit.d.ts +9 -0
  120. package/dist/cli/emit.d.ts.map +1 -0
  121. package/dist/cli/emit.js +10 -0
  122. package/dist/cli/emit.js.map +1 -0
  123. package/dist/cli/index.d.ts +37 -0
  124. package/dist/cli/index.d.ts.map +1 -0
  125. package/dist/cli/index.js +128 -0
  126. package/dist/cli/index.js.map +1 -0
  127. package/dist/cli/paths.d.ts +7 -0
  128. package/dist/cli/paths.d.ts.map +1 -0
  129. package/dist/cli/paths.js +10 -0
  130. package/dist/cli/paths.js.map +1 -0
  131. package/dist/cli/query-runner.d.ts +13 -0
  132. package/dist/cli/query-runner.d.ts.map +1 -0
  133. package/dist/cli/query-runner.js +33 -0
  134. package/dist/cli/query-runner.js.map +1 -0
  135. package/dist/graph/dispatch.d.ts +17 -0
  136. package/dist/graph/dispatch.d.ts.map +1 -0
  137. package/dist/graph/dispatch.js +82 -0
  138. package/dist/graph/dispatch.js.map +1 -0
  139. package/dist/graph/id.d.ts +19 -0
  140. package/dist/graph/id.d.ts.map +1 -0
  141. package/dist/graph/id.js +17 -0
  142. package/dist/graph/id.js.map +1 -0
  143. package/dist/graph/index.d.ts +6 -0
  144. package/dist/graph/index.d.ts.map +1 -0
  145. package/dist/graph/index.js +4 -0
  146. package/dist/graph/index.js.map +1 -0
  147. package/dist/graph/types.d.ts +71 -0
  148. package/dist/graph/types.d.ts.map +1 -0
  149. package/dist/graph/types.js +52 -0
  150. package/dist/graph/types.js.map +1 -0
  151. package/dist/indexer/debouncer.d.ts +32 -0
  152. package/dist/indexer/debouncer.d.ts.map +1 -0
  153. package/dist/indexer/debouncer.js +81 -0
  154. package/dist/indexer/debouncer.js.map +1 -0
  155. package/dist/indexer/ignore.d.ts +55 -0
  156. package/dist/indexer/ignore.d.ts.map +1 -0
  157. package/dist/indexer/ignore.js +170 -0
  158. package/dist/indexer/ignore.js.map +1 -0
  159. package/dist/indexer/indexer.d.ts +112 -0
  160. package/dist/indexer/indexer.d.ts.map +1 -0
  161. package/dist/indexer/indexer.js +392 -0
  162. package/dist/indexer/indexer.js.map +1 -0
  163. package/dist/indexer/watcher.d.ts +50 -0
  164. package/dist/indexer/watcher.d.ts.map +1 -0
  165. package/dist/indexer/watcher.js +86 -0
  166. package/dist/indexer/watcher.js.map +1 -0
  167. package/dist/mcp/build-info.d.ts +16 -0
  168. package/dist/mcp/build-info.d.ts.map +1 -0
  169. package/dist/mcp/build-info.js +54 -0
  170. package/dist/mcp/build-info.js.map +1 -0
  171. package/dist/mcp/http.d.ts +18 -0
  172. package/dist/mcp/http.d.ts.map +1 -0
  173. package/dist/mcp/http.js +145 -0
  174. package/dist/mcp/http.js.map +1 -0
  175. package/dist/mcp/server.d.ts +22 -0
  176. package/dist/mcp/server.d.ts.map +1 -0
  177. package/dist/mcp/server.js +401 -0
  178. package/dist/mcp/server.js.map +1 -0
  179. package/dist/mcp/session.d.ts +155 -0
  180. package/dist/mcp/session.d.ts.map +1 -0
  181. package/dist/mcp/session.js +319 -0
  182. package/dist/mcp/session.js.map +1 -0
  183. package/dist/query/service.d.ts +329 -0
  184. package/dist/query/service.d.ts.map +1 -0
  185. package/dist/query/service.js +959 -0
  186. package/dist/query/service.js.map +1 -0
  187. package/dist/runtime/entrypoint.d.ts +11 -0
  188. package/dist/runtime/entrypoint.d.ts.map +1 -0
  189. package/dist/runtime/entrypoint.js +22 -0
  190. package/dist/runtime/entrypoint.js.map +1 -0
  191. package/dist/runtime/quiet-sqlite-warning.d.ts +14 -0
  192. package/dist/runtime/quiet-sqlite-warning.d.ts.map +1 -0
  193. package/dist/runtime/quiet-sqlite-warning.js +26 -0
  194. package/dist/runtime/quiet-sqlite-warning.js.map +1 -0
  195. package/dist/runtime/wasm-tier.d.ts +2 -0
  196. package/dist/runtime/wasm-tier.d.ts.map +1 -0
  197. package/dist/runtime/wasm-tier.js +54 -0
  198. package/dist/runtime/wasm-tier.js.map +1 -0
  199. package/dist/store/memory.d.ts +54 -0
  200. package/dist/store/memory.d.ts.map +1 -0
  201. package/dist/store/memory.js +210 -0
  202. package/dist/store/memory.js.map +1 -0
  203. package/dist/store/sqlite.d.ts +38 -0
  204. package/dist/store/sqlite.d.ts.map +1 -0
  205. package/dist/store/sqlite.js +298 -0
  206. package/dist/store/sqlite.js.map +1 -0
  207. package/dist/store/types.d.ts +76 -0
  208. package/dist/store/types.d.ts.map +1 -0
  209. package/dist/store/types.js +2 -0
  210. package/dist/store/types.js.map +1 -0
  211. package/package.json +59 -0
@@ -0,0 +1,66 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { nearestConfig, parentDir } from "./config.js";
4
+ /** Cache for the nearest `go.mod`'s declared module path, by importer directory. */
5
+ const goModuleCache = new Map();
6
+ /** The `module` path declared by a `go.mod` in `absDir`, or undefined if there's none. */
7
+ function readGoModule(absDir) {
8
+ try {
9
+ return fs.readFileSync(path.join(absDir, "go.mod"), "utf8").match(/^module\s+(\S+)/m)?.[1];
10
+ }
11
+ catch {
12
+ return undefined; // no go.mod here — nearestConfig walks to the parent
13
+ }
14
+ }
15
+ /** Resolve a Go import to the `.go` files of its package directory. Go imports a
16
+ * *package* (a directory), so the import links to every non-test `.go` file in it.
17
+ * The import path is module-qualified (`<module>/<pkg>`); strip the module prefix
18
+ * (from the nearest `go.mod`) to get the directory, relative to that `go.mod`.
19
+ * Stdlib and third-party imports don't match the module, so they resolve to
20
+ * nothing. (ama-9yu) */
21
+ function goImports(node, importerRel, root) {
22
+ if (node.type !== "import_spec")
23
+ return undefined;
24
+ const str = node.namedChildren.find((c) => c.type === "interpreted_string_literal");
25
+ if (!str)
26
+ return [];
27
+ const importPath = str.text.replace(/^["`]|["`]$/g, "");
28
+ const mod = nearestConfig(root, parentDir(importerRel), readGoModule, goModuleCache);
29
+ if (!mod || (importPath !== mod.value && !importPath.startsWith(`${mod.value}/`)))
30
+ return [];
31
+ const sub = importPath === mod.value ? "" : importPath.slice(mod.value.length + 1);
32
+ const pkgDir = [mod.dir, sub].filter(Boolean).join("/");
33
+ let entries;
34
+ try {
35
+ entries = fs.readdirSync(path.join(root, pkgDir));
36
+ }
37
+ catch {
38
+ return [];
39
+ }
40
+ return entries
41
+ .filter((f) => f.endsWith(".go") && !f.endsWith("_test.go"))
42
+ .map((f) => [pkgDir ? `${pkgDir}/${f}` : f]);
43
+ }
44
+ /**
45
+ * Baseline (syntactic) spec for Go. Go declares named types with a single
46
+ * `type_spec` node regardless of whether the body is a struct, interface, or
47
+ * alias — so it uses {@link SymbolRule.kindByChild} to refine: a `struct_type`
48
+ * child → Class, an `interface_type` child → Interface, else a TypeAlias.
49
+ * Methods are top-level `method_declaration`s (the receiver isn't a container),
50
+ * so they surface as Methods named for the function, not qualified by the type.
51
+ */
52
+ export const goSpec = {
53
+ language: "go",
54
+ extensions: [".go"],
55
+ grammar: "go",
56
+ symbols: {
57
+ function_declaration: { kind: "Function" },
58
+ method_declaration: { kind: "Method" },
59
+ type_spec: {
60
+ kind: "TypeAlias",
61
+ kindByChild: { struct_type: "Class", interface_type: "Interface" },
62
+ },
63
+ },
64
+ resolveImports: goImports,
65
+ };
66
+ //# sourceMappingURL=go.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"go.js","sourceRoot":"","sources":["../../../src/analyzers/baseline/go.ts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cAAc,EAAE,SAAS;CAC1B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { LanguageSpec } from "./analyzer.js";
2
+ /**
3
+ * Baseline (syntactic) spec for Java. Java gives every kind its own CST node
4
+ * type — class/interface/enum declarations and methods — so each maps directly
5
+ * to the right graph kind, and methods (inside a class/interface body) qualify
6
+ * cleanly under their type (e.g. `Sample.square`).
7
+ */
8
+ export declare const javaSpec: LanguageSpec;
9
+ //# sourceMappingURL=java.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"java.d.ts","sourceRoot":"","sources":["../../../src/analyzers/baseline/java.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAiClD;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,YAWtB,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { ancestorDirs } from "./paths.js";
2
+ /** Try a repo-relative file under every ancestor directory of the importer. A
3
+ * package import gives a *source-root-relative* path (`com/example/Foo.java`)
4
+ * but not the source root itself (`src/main/java`), which varies by build tool —
5
+ * so the correct root is simply whichever ancestor makes the file exist. Disk-
6
+ * based (via the analyzer's existsSync), so it's single-file-reindex-safe. */
7
+ function ancestorCandidates(importerRel, file) {
8
+ return ancestorDirs(importerRel).map((d) => (d ? `${d}/${file}` : file));
9
+ }
10
+ /** Resolve a Java `import a.b.C;` to its class file. Java's convention (lowercase
11
+ * packages, PascalCase types) lets one rule cover regular, `static`, and nested
12
+ * imports: the class file is the dotted name up to and including the first
13
+ * PascalCase segment — trailing segments are a static member or a nested type,
14
+ * which live in that same file. `import a.b.*;` (wildcard) targets a package, not
15
+ * a file, and is skipped; an unresolved (JDK/dependency) import simply matches no
16
+ * file on disk. (ama-bsj) */
17
+ function javaImports(node, importerRel) {
18
+ if (node.type !== "import_declaration")
19
+ return undefined;
20
+ if (node.namedChildren.some((c) => c.type === "asterisk"))
21
+ return []; // wildcard import
22
+ const scoped = node.namedChildren.find((c) => c.type === "scoped_identifier" || c.type === "identifier");
23
+ if (!scoped)
24
+ return [];
25
+ const segments = scoped.text.split(".");
26
+ const classEnd = segments.findIndex((s) => /^[A-Z]/.test(s));
27
+ if (classEnd < 0)
28
+ return []; // no PascalCase (type) segment — nothing to resolve
29
+ const file = `${segments.slice(0, classEnd + 1).join("/")}.java`;
30
+ return [ancestorCandidates(importerRel, file)];
31
+ }
32
+ /**
33
+ * Baseline (syntactic) spec for Java. Java gives every kind its own CST node
34
+ * type — class/interface/enum declarations and methods — so each maps directly
35
+ * to the right graph kind, and methods (inside a class/interface body) qualify
36
+ * cleanly under their type (e.g. `Sample.square`).
37
+ */
38
+ export const javaSpec = {
39
+ language: "java",
40
+ extensions: [".java"],
41
+ grammar: "java",
42
+ symbols: {
43
+ class_declaration: { kind: "Class" },
44
+ interface_declaration: { kind: "Interface" },
45
+ enum_declaration: { kind: "Enum" },
46
+ method_declaration: { kind: "Method" },
47
+ },
48
+ resolveImports: javaImports,
49
+ };
50
+ //# sourceMappingURL=java.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"java.js","sourceRoot":"","sources":["../../../src/analyzers/baseline/java.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;+EAI+E;AAC/E,SAAS,kBAAkB,CAAC,WAAmB,EAAE,IAAY;IAC3D,OAAO,YAAY,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;;8BAM8B;AAC9B,SAAS,WAAW,CAAC,IAAuB,EAAE,WAAmB;IAC/D,IAAI,IAAI,CAAC,IAAI,KAAK,oBAAoB;QAAE,OAAO,SAAS,CAAC;IACzD,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CA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1
+ import type { LanguageSpec } from "./analyzer.js";
2
+ /**
3
+ * Baseline (syntactic) spec for JavaScript (and JSX — tree-sitter-javascript
4
+ * parses JSX too). Unlike Python, JS distinguishes methods syntactically
5
+ * (`method_definition`), so class methods surface as Method nodes qualified
6
+ * under their class. The `.ts`/`.tsx` extensions stay with the deep TypeScript
7
+ * analyzer; this claims the plain-JS variants.
8
+ */
9
+ export declare const javascriptSpec: LanguageSpec;
10
+ //# sourceMappingURL=javascript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"javascript.d.ts","sourceRoot":"","sources":["../../../src/analyzers/baseline/javascript.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAoClD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,EAAE,YAW5B,CAAC"}
@@ -0,0 +1,55 @@
1
+ import * as path from "node:path";
2
+ const JS_EXTENSIONS = [".js", ".mjs", ".cjs", ".jsx"];
3
+ /** Candidate repo-relative files for a relative JS specifier, resolved against the
4
+ * importer's directory. An explicit extension is used as-is; otherwise each JS
5
+ * extension and an `/index.*` variant is tried. A bare/package specifier (not
6
+ * `./` or `../`) is external and yields no candidates. (ama-2dn) */
7
+ function jsCandidates(specifier, importerRel) {
8
+ if (!specifier.startsWith("./") && !specifier.startsWith("../"))
9
+ return [];
10
+ const base = path.posix.join(path.posix.dirname(importerRel), specifier);
11
+ if (/\.(?:js|mjs|cjs|jsx)$/.test(specifier))
12
+ return [base];
13
+ return [...JS_EXTENSIONS.map((e) => base + e), ...JS_EXTENSIONS.map((e) => `${base}/index${e}`)];
14
+ }
15
+ /** Resolve a JS module dependency to candidate files: an ES `import`/`export … from`
16
+ * (its `source` field) or a CommonJS `require("…")` call. (ama-2dn) */
17
+ function jsImports(node, importerRel) {
18
+ let str = null;
19
+ if (node.type === "import_statement" || node.type === "export_statement") {
20
+ str = node.childForFieldName("source");
21
+ }
22
+ else if (node.type === "call_expression") {
23
+ const callee = node.childForFieldName("function");
24
+ if (callee?.type === "identifier" && callee.text === "require") {
25
+ str =
26
+ node.childForFieldName("arguments")?.namedChildren.find((c) => c.type === "string") ?? null;
27
+ }
28
+ }
29
+ if (!str)
30
+ return undefined;
31
+ const specifier = str.namedChildren.find((c) => c.type === "string_fragment")?.text ??
32
+ str.text.replace(/^['"`]|['"`]$/g, "");
33
+ const candidates = jsCandidates(specifier, importerRel);
34
+ return candidates.length > 0 ? [candidates] : [];
35
+ }
36
+ /**
37
+ * Baseline (syntactic) spec for JavaScript (and JSX — tree-sitter-javascript
38
+ * parses JSX too). Unlike Python, JS distinguishes methods syntactically
39
+ * (`method_definition`), so class methods surface as Method nodes qualified
40
+ * under their class. The `.ts`/`.tsx` extensions stay with the deep TypeScript
41
+ * analyzer; this claims the plain-JS variants.
42
+ */
43
+ export const javascriptSpec = {
44
+ language: "javascript",
45
+ extensions: [".js", ".jsx", ".mjs", ".cjs"],
46
+ grammar: "javascript",
47
+ symbols: {
48
+ function_declaration: { kind: "Function" },
49
+ generator_function_declaration: { kind: "Function" },
50
+ class_declaration: { kind: "Class" },
51
+ method_definition: { kind: "Method" },
52
+ },
53
+ resolveImports: jsImports,
54
+ };
55
+ //# sourceMappingURL=javascript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../src/analyzers/baseline/javascript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAIlC,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEtD;;;qEAGqE;AACrE,SAAS,YAAY,CAAC,SAAiB,EAAE,WAAmB;IAC1D,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAC3E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,I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,KAAK,iBAAiB,CAAC,EAAE,IAAI;QACjE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACzC,MAAM,UAAU,GAAG,YAAY,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IACxD,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,QAAQ,EAAE,YAAY;IACtB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IAC3C,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE;QACP,oBAAoB,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;QAC1C,8BAA8B,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;QACpD,iBAAiB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;QACpC,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KACtC;IACD,cAAc,EAAE,SAAS;CAC1B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { LanguageSpec } from "./analyzer.js";
2
+ /**
3
+ * Baseline (syntactic) spec for Kotlin. tree-sitter-kotlin uses one
4
+ * `class_declaration` for class / interface / enum class (refined to Enum by its
5
+ * `enum_class_body`; interfaces stay Class at this tier), `object_declaration`
6
+ * for singletons, and `function_declaration` for functions — methods nest under
7
+ * their class (e.g. `Sample.square`). None carry a `name` field, so the analyzer
8
+ * reads the name from the first identifier child. (ama-0ze)
9
+ */
10
+ export declare const kotlinSpec: LanguageSpec;
11
+ //# sourceMappingURL=kotlin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kotlin.d.ts","sourceRoot":"","sources":["../../../src/analyzers/baseline/kotlin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA+ClD;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,EAAE,YAUxB,CAAC"}
@@ -0,0 +1,67 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { ancestorDirs } from "./paths.js";
4
+ /** Resolve a Kotlin `import a.b.C` to the source files of its package. Kotlin file
5
+ * naming is free-form (a file holds any number of declarations and need not be named
6
+ * after a class), so — like Go's "package = directory" — a `import` links to every
7
+ * `.kt` file in the package's directory rather than to one file. The package is the
8
+ * dotted name with its trailing symbol dropped: segments before the first PascalCase
9
+ * one (Java's class-boundary heuristic), or all-but-last for an all-lowercase member
10
+ * import; a `*` wildcard imports the package itself, so nothing is dropped. The
11
+ * directory lives under a source root (e.g. `src/main/kotlin`), found by ancestor-scan;
12
+ * a framework/stdlib package matches nothing on disk. (ama-e23) */
13
+ function kotlinImports(node, importerRel, root) {
14
+ if (node.type !== "import_header")
15
+ return undefined;
16
+ const id = node.namedChildren.find((c) => c.type === "identifier");
17
+ if (!id)
18
+ return [];
19
+ const segments = id.text.split(".");
20
+ const wildcard = node.namedChildren.some((c) => c.type === "wildcard_import");
21
+ const pascal = segments.findIndex((s) => /^[A-Z]/.test(s));
22
+ const pkg = wildcard
23
+ ? segments // `import a.b.*` → the package is a.b
24
+ : pascal >= 0
25
+ ? segments.slice(0, pascal) // `import a.b.C` → package a.b (C is the type)
26
+ : segments.slice(0, -1); // `import a.b.foo` → package a.b (foo is a member)
27
+ if (pkg.length === 0)
28
+ return [];
29
+ const pkgPath = pkg.join("/");
30
+ for (const ancestor of ancestorDirs(importerRel)) {
31
+ const rel = ancestor ? `${ancestor}/${pkgPath}` : pkgPath;
32
+ let entries;
33
+ try {
34
+ entries = fs.readdirSync(path.join(root, rel), { withFileTypes: true });
35
+ }
36
+ catch {
37
+ continue; // not a directory under this ancestor
38
+ }
39
+ const files = entries
40
+ .filter((e) => e.isFile() && (e.name.endsWith(".kt") || e.name.endsWith(".kts")))
41
+ .map((e) => `${rel}/${e.name}`)
42
+ .filter((f) => f !== importerRel);
43
+ if (files.length > 0)
44
+ return files.map((f) => [f]); // one File→File edge per .kt file
45
+ }
46
+ return []; // a stdlib/framework package, or none on disk
47
+ }
48
+ /**
49
+ * Baseline (syntactic) spec for Kotlin. tree-sitter-kotlin uses one
50
+ * `class_declaration` for class / interface / enum class (refined to Enum by its
51
+ * `enum_class_body`; interfaces stay Class at this tier), `object_declaration`
52
+ * for singletons, and `function_declaration` for functions — methods nest under
53
+ * their class (e.g. `Sample.square`). None carry a `name` field, so the analyzer
54
+ * reads the name from the first identifier child. (ama-0ze)
55
+ */
56
+ export const kotlinSpec = {
57
+ language: "kotlin",
58
+ extensions: [".kt", ".kts"],
59
+ grammar: "kotlin",
60
+ symbols: {
61
+ class_declaration: { kind: "Class", kindByChild: { enum_class_body: "Enum" } },
62
+ object_declaration: { kind: "Class" },
63
+ function_declaration: { kind: "Function" },
64
+ },
65
+ resolveImports: kotlinImports,
66
+ };
67
+ //# sourceMappingURL=kotlin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kotlin.js","sourceRoot":"","sources":["../../../src/analyzers/baseline/kotlin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;;oEAQoE;AACpE,SAAS,aAAa,CACpB,IAAuB,EACvB,WAAmB,EACnB,IAAY;IAEZ,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe;QAAE,OAAO,SAAS,CAAC;IACpD,MAAM,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;IACnE,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC;IACnB,MAAM,QAAQ,GAAG,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AAE,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;aAChF,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;aAC9B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC;QACpC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,kCAAkC;IACxF,CAAC;IACD,OAAO,EAAE,CAAC,CAAC,8CAA8C;AAC3D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAiB;IACtC,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE;QACP,iBAAiB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE;QAC9E,kBAAkB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;QACrC,oBAAoB,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;KAC3C;IACD,cAAc,EAAE,aAAa;CAC9B,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** Ancestor directories of a repo-relative file, closest first, ending at the repo
2
+ * root (""). The importer's own directory is first. Shared by the baseline import
3
+ * resolvers that locate a package/namespace directory or a source root relative to
4
+ * the importing file rather than the index root (Java, C#, Kotlin). (ama-mgn) */
5
+ export declare function ancestorDirs(rel: string): string[];
6
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/analyzers/baseline/paths.ts"],"names":[],"mappings":"AAEA;;;kFAGkF;AAClF,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CASlD"}
@@ -0,0 +1,17 @@
1
+ import * as path from "node:path";
2
+ /** Ancestor directories of a repo-relative file, closest first, ending at the repo
3
+ * root (""). The importer's own directory is first. Shared by the baseline import
4
+ * resolvers that locate a package/namespace directory or a source root relative to
5
+ * the importing file rather than the index root (Java, C#, Kotlin). (ama-mgn) */
6
+ export function ancestorDirs(rel) {
7
+ const dirs = [];
8
+ let dir = path.posix.dirname(rel);
9
+ while (true) {
10
+ dirs.push(dir === "." ? "" : dir);
11
+ if (dir === "." || dir === "")
12
+ break;
13
+ dir = path.posix.dirname(dir);
14
+ }
15
+ return dirs;
16
+ }
17
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/analyzers/baseline/paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC;;;kFAGkF;AAClF,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,EAAE;YAAE,MAAM;QACrC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { LanguageSpec } from "./analyzer.js";
2
+ /**
3
+ * Baseline (syntactic) spec for PHP. Each top-level construct has its own CST
4
+ * node type — class/interface/trait/enum declarations, free functions, and
5
+ * methods inside a class body — so each maps directly to a graph kind, and
6
+ * methods qualify under their type (e.g. `Sample.square`). A trait is a set of
7
+ * reusable method implementations, so it's modelled as a Class (the closest
8
+ * kind); there's no dedicated Trait kind.
9
+ */
10
+ export declare const phpSpec: LanguageSpec;
11
+ //# sourceMappingURL=php.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"php.d.ts","sourceRoot":"","sources":["../../../src/analyzers/baseline/php.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAqDlD;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,EAAE,YAarB,CAAC"}
@@ -0,0 +1,76 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { nearestConfig, parentDir } from "./config.js";
4
+ /** Cache for the nearest composer.json's PSR-4 `[prefix, baseDir]` map, by directory. */
5
+ const composerCache = new Map();
6
+ /** The PSR-4 autoload prefix→directory map declared by a composer.json in `absDir`, or
7
+ * undefined if there's none (or no `autoload.psr-4`). */
8
+ function readComposerPsr4(absDir) {
9
+ try {
10
+ const json = JSON.parse(fs.readFileSync(path.join(absDir, "composer.json"), "utf8"));
11
+ const map = json?.autoload?.["psr-4"];
12
+ if (!map || typeof map !== "object")
13
+ return undefined;
14
+ const psr4 = [];
15
+ for (const [prefix, base] of Object.entries(map)) {
16
+ const dir = Array.isArray(base) ? base[0] : base; // a prefix may map to one dir or a list
17
+ if (typeof dir === "string")
18
+ psr4.push([prefix, dir.replace(/\/+$/, "")]);
19
+ }
20
+ return psr4;
21
+ }
22
+ catch {
23
+ return undefined; // no/invalid composer.json — nearestConfig walks to the parent
24
+ }
25
+ }
26
+ /** Resolve a PHP `use Vendor\Pkg\Klass;` to its class file via PSR-4. The class is
27
+ * the whole fully-qualified name (one class = one file); the namespace→directory
28
+ * mapping lives in composer.json's `autoload.psr-4`, so strip the longest matching
29
+ * prefix and map the rest to a path under its base directory. A `use` whose
30
+ * namespace matches no PSR-4 prefix (a third-party/global class) resolves to
31
+ * nothing. (ama-x96) */
32
+ function phpImports(node, importerRel, root) {
33
+ if (node.type !== "namespace_use_clause")
34
+ return undefined;
35
+ const qn = node.namedChildren.find((c) => c.type === "qualified_name");
36
+ if (!qn)
37
+ return [];
38
+ const fqn = qn.text.replace(/^\\/, ""); // a leading `\` just marks the FQN as absolute
39
+ const composer = nearestConfig(root, parentDir(importerRel), readComposerPsr4, composerCache);
40
+ if (!composer)
41
+ return [];
42
+ let best;
43
+ for (const [prefix, base] of composer.value) {
44
+ if (fqn.startsWith(prefix) && (!best || prefix.length > best.prefix.length)) {
45
+ best = { prefix, base };
46
+ }
47
+ }
48
+ if (!best)
49
+ return [];
50
+ const relPath = fqn.slice(best.prefix.length).replace(/\\/g, "/");
51
+ const file = [composer.dir, best.base, `${relPath}.php`].filter(Boolean).join("/");
52
+ return [[file]];
53
+ }
54
+ /**
55
+ * Baseline (syntactic) spec for PHP. Each top-level construct has its own CST
56
+ * node type — class/interface/trait/enum declarations, free functions, and
57
+ * methods inside a class body — so each maps directly to a graph kind, and
58
+ * methods qualify under their type (e.g. `Sample.square`). A trait is a set of
59
+ * reusable method implementations, so it's modelled as a Class (the closest
60
+ * kind); there's no dedicated Trait kind.
61
+ */
62
+ export const phpSpec = {
63
+ language: "php",
64
+ extensions: [".php"],
65
+ grammar: "php",
66
+ symbols: {
67
+ class_declaration: { kind: "Class" },
68
+ interface_declaration: { kind: "Interface" },
69
+ trait_declaration: { kind: "Class" },
70
+ enum_declaration: { kind: "Enum" },
71
+ function_definition: { kind: "Function" },
72
+ method_declaration: { kind: "Method" },
73
+ },
74
+ resolveImports: phpImports,
75
+ };
76
+ //# sourceMappingURL=php.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"php.js","sourceRoot":"","sources":["../../../src/analyzers/baseline/php.ts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C,CAAC,IAAI,CAAC,CAAC,CAAC;AAClB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAiB;IACnC,QAAQ,EAAE,KAAK;IACf,UAAU,EAAE,CAAC,MAAM,CAAC;IACpB,OAAO,EAAE,KAAK;IACd,OAAO,EAAE;QACP,iBAAiB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;QACpC,qBAAqB,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;QAC5C,iBAAiB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;QACpC,gBAAgB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QAClC,mBAAmB,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;QACzC,kBAAkB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KACvC;IACD,cAAc,EAAE,UAAU;CAC3B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { LanguageSpec } from "./analyzer.js";
2
+ /**
3
+ * Baseline (syntactic) spec for Python. Functions and classes are the symbols
4
+ * worth a node; methods are `function_definition` too (Python doesn't
5
+ * distinguish them syntactically), so they surface as Functions qualified under
6
+ * their class (e.g. `Greeter.hello`). Decorated defs nest a `function_definition`
7
+ * inside a `decorated_definition`, which the analyzer's recursion already reaches.
8
+ */
9
+ export declare const pythonSpec: LanguageSpec;
10
+ //# sourceMappingURL=python.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../../src/analyzers/baseline/python.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAwClD;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,YASxB,CAAC"}
@@ -0,0 +1,63 @@
1
+ import * as path from "node:path";
2
+ /**
3
+ * Resolve a Python relative import (`from .x import y`, `from . import m`,
4
+ * `from ..pkg import z`) to candidate repo-relative module files. The leading
5
+ * dots count up from the importer's own package (one dot = its directory). An
6
+ * absolute import (`import os`, `from pkg import x`) resolves via `sys.path` — too
7
+ * ambiguous to back with a node — so it emits nothing. (ama-8nr)
8
+ */
9
+ function pythonImports(node, importerRel) {
10
+ if (node.type !== "import_from_statement")
11
+ return undefined;
12
+ const relative = node.namedChildren.find((c) => c.type === "relative_import");
13
+ if (!relative)
14
+ return []; // `from pkg import x` — absolute, unresolvable here
15
+ const prefix = relative.namedChildren.find((c) => c.type === "import_prefix");
16
+ const dots = prefix ? prefix.text.length : 1;
17
+ // One dot = the importer's own package (its directory); each extra dot goes up.
18
+ let base = path.posix.dirname(importerRel);
19
+ for (let i = 1; i < dots; i++)
20
+ base = path.posix.dirname(base);
21
+ if (base === ".")
22
+ base = "";
23
+ const candidates = (segments) => {
24
+ const p = [base, ...segments].filter(Boolean).join("/");
25
+ return [`${p}.py`, `${p}/__init__.py`];
26
+ };
27
+ const segsOf = (dotted) => dotted.namedChildren.filter((c) => c.type === "identifier").map((c) => c.text);
28
+ const module = relative.namedChildren.find((c) => c.type === "dotted_name");
29
+ if (module)
30
+ return [candidates(segsOf(module))]; // `from .pkg.sub import x` → pkg/sub
31
+ // `from . import a, b` — each imported name is a submodule of the base package.
32
+ const groups = [];
33
+ for (const child of node.namedChildren) {
34
+ if (child === relative)
35
+ continue;
36
+ if (child.type === "dotted_name")
37
+ groups.push(candidates(segsOf(child)));
38
+ else if (child.type === "aliased_import") {
39
+ const dn = child.namedChildren.find((c) => c.type === "dotted_name");
40
+ if (dn)
41
+ groups.push(candidates(segsOf(dn)));
42
+ }
43
+ }
44
+ return groups;
45
+ }
46
+ /**
47
+ * Baseline (syntactic) spec for Python. Functions and classes are the symbols
48
+ * worth a node; methods are `function_definition` too (Python doesn't
49
+ * distinguish them syntactically), so they surface as Functions qualified under
50
+ * their class (e.g. `Greeter.hello`). Decorated defs nest a `function_definition`
51
+ * inside a `decorated_definition`, which the analyzer's recursion already reaches.
52
+ */
53
+ export const pythonSpec = {
54
+ language: "python",
55
+ extensions: [".py"],
56
+ grammar: "python",
57
+ symbols: {
58
+ function_definition: { kind: "Function" },
59
+ class_definition: { kind: "Class" },
60
+ },
61
+ resolveImports: pythonImports,
62
+ };
63
+ //# sourceMappingURL=python.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"python.js","sourceRoot":"","sources":["../../../src/analyzers/baseline/python.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAIlC;;;;;;GAMG;AACH,SAAS,aAAa,CAAC,IAAuB,EAAE,WAAmB;IACjE,IAAI,IAAI,CAAC,IAAI,KAAK,uBAAuB;QAAE,OAAO,SAAS,CAAC;IAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,iBAAiB,CAAC,CAAC;IAC9E,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,CAAC,CAAC,oDAAoD;IAC9E,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC;IAC9E,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,gFAAgF;IAChF,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE;QAAE,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,IAAI,IAAI,KAAK,GAAG;QAAE,IAAI,GAAG,EAAE,CAAC;IAC5B,MAAM,UAAU,GAAG,CAAC,QAAkB,EAAY,EAAE;QAClD,MAAM,CAAC,GAAG,CAAC,IA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;QAC9C,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAiB;IACtC,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,CAAC,KAAK,CAAC;IACnB,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE;QACP,mBAAmB,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;QACzC,gBAAgB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;KACpC;IACD,cAAc,EAAE,aAAa;CAC9B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { LanguageSpec } from "./analyzer.js";
2
+ /**
3
+ * Baseline (syntactic) spec for Rust. Rust gives each kind its own node type, so
4
+ * the plain map suffices: struct → Class, enum → Enum, trait → Interface, fn →
5
+ * Function. Trait methods nest under the trait (`Shape.area`); methods defined
6
+ * in separate `impl` blocks are top-level `function_item`s (the impl isn't a
7
+ * container), so they surface unqualified — acceptable for a syntactic tier.
8
+ */
9
+ export declare const rustSpec: LanguageSpec;
10
+ //# sourceMappingURL=rust.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rust.d.ts","sourceRoot":"","sources":["../../../src/analyzers/baseline/rust.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAuBlD;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,EAAE,YAatB,CAAC"}
@@ -0,0 +1,45 @@
1
+ import * as path from "node:path";
2
+ /** Files whose `mod foo;` submodules live in the *same* directory (a crate root
3
+ * or a `mod.rs`); any other `foo.rs` owns a `foo/` directory for its submodules. */
4
+ const RUST_DIR_MODULES = new Set(["mod", "lib", "main"]);
5
+ /** Resolve a Rust `mod foo;` file-module declaration to candidate files. An inline
6
+ * `mod foo { … }` has a `declaration_list` body and declares no file. A submodule
7
+ * sits beside the declaring file, except a non-`mod.rs`/`lib.rs`/`main.rs` file
8
+ * owns a directory named after its stem (Rust 2018) — so `mod bar;` in `a/foo.rs`
9
+ * is `a/foo/bar.rs`. `use` imports items, not files, and is skipped. (ama-90x) */
10
+ function rustImports(node, importerRel) {
11
+ if (node.type !== "mod_item")
12
+ return undefined;
13
+ if (node.namedChildren.some((c) => c.type === "declaration_list"))
14
+ return []; // inline module
15
+ const name = node.childForFieldName("name")?.text;
16
+ if (!name)
17
+ return undefined;
18
+ const stem = path.posix.basename(importerRel, ".rs");
19
+ const dir = path.posix.dirname(importerRel);
20
+ const baseDir = RUST_DIR_MODULES.has(stem) ? dir : path.posix.join(dir, stem);
21
+ const base = baseDir === "." ? name : `${baseDir}/${name}`;
22
+ return [[`${base}.rs`, `${base}/mod.rs`]];
23
+ }
24
+ /**
25
+ * Baseline (syntactic) spec for Rust. Rust gives each kind its own node type, so
26
+ * the plain map suffices: struct → Class, enum → Enum, trait → Interface, fn →
27
+ * Function. Trait methods nest under the trait (`Shape.area`); methods defined
28
+ * in separate `impl` blocks are top-level `function_item`s (the impl isn't a
29
+ * container), so they surface unqualified — acceptable for a syntactic tier.
30
+ */
31
+ export const rustSpec = {
32
+ language: "rust",
33
+ extensions: [".rs"],
34
+ grammar: "rust",
35
+ symbols: {
36
+ function_item: { kind: "Function" },
37
+ // A bodyless fn (trait method declaration, extern block) is a signature item.
38
+ function_signature_item: { kind: "Function" },
39
+ struct_item: { kind: "Class" },
40
+ enum_item: { kind: "Enum" },
41
+ trait_item: { kind: "Interface" },
42
+ },
43
+ resolveImports: rustImports,
44
+ };
45
+ //# sourceMappingURL=rust.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rust.js","sourceRoot":"","sources":["../../../src/analyzers/baseline/rust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAIlC;qFACqF;AACrF,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAEzD;;;;mFAImF;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AC7C,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;QAC9B,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QAC3B,UAAU,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;KAClC;IACD,cAAc,EAAE,WAAW;CAC5B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { LanguageSpec } from "./analyzer.js";
2
+ /**
3
+ * Baseline (syntactic) spec for Swift. tree-sitter-swift carries a `name` field,
4
+ * so no special extraction is needed. `class`, `struct`, and `enum` share one
5
+ * `class_declaration` (an enum is refined to Enum by its `enum_class_body`;
6
+ * structs stay Class at this tier); `protocol_declaration` is an Interface; and
7
+ * `function_declaration` covers free functions and methods, which nest under
8
+ * their type (e.g. `Sample.square`). (ama-p3a)
9
+ */
10
+ export declare const swiftSpec: LanguageSpec;
11
+ //# sourceMappingURL=swift.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swift.d.ts","sourceRoot":"","sources":["../../../src/analyzers/baseline/swift.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,EAAE,YASvB,CAAC"}