@fabersep/atlas 0.0.0-stage → 0.1.1

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 (155) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/LICENSE +202 -0
  3. package/README.md +175 -2
  4. package/dist/packs/csharp/calls.d.ts +4 -0
  5. package/dist/packs/csharp/calls.js +167 -0
  6. package/dist/packs/csharp/declarations.d.ts +4 -0
  7. package/dist/packs/csharp/declarations.js +142 -0
  8. package/dist/packs/csharp/pack.d.ts +2 -0
  9. package/dist/packs/csharp/pack.js +39 -0
  10. package/dist/packs/csharp/resolve.d.ts +2 -0
  11. package/dist/packs/csharp/resolve.js +35 -0
  12. package/dist/packs/csharp/signals.d.ts +7 -0
  13. package/dist/packs/csharp/signals.js +143 -0
  14. package/dist/packs/dart/calls.d.ts +4 -0
  15. package/dist/packs/dart/calls.js +130 -0
  16. package/dist/packs/dart/declarations.d.ts +11 -0
  17. package/dist/packs/dart/declarations.js +79 -0
  18. package/dist/packs/dart/members.d.ts +4 -0
  19. package/dist/packs/dart/members.js +62 -0
  20. package/dist/packs/dart/pack.d.ts +2 -0
  21. package/dist/packs/dart/pack.js +37 -0
  22. package/dist/packs/dart/resolve.d.ts +2 -0
  23. package/dist/packs/dart/resolve.js +32 -0
  24. package/dist/packs/index.d.ts +3 -0
  25. package/dist/packs/index.js +8 -0
  26. package/dist/packs/json/pack.d.ts +2 -0
  27. package/dist/packs/json/pack.js +27 -0
  28. package/dist/packs/msbuild/pack.d.ts +2 -0
  29. package/dist/packs/msbuild/pack.js +75 -0
  30. package/dist/packs/msbuild/xml.d.ts +16 -0
  31. package/dist/packs/msbuild/xml.js +123 -0
  32. package/dist/packs/typescript/calls.d.ts +4 -0
  33. package/dist/packs/typescript/calls.js +208 -0
  34. package/dist/packs/typescript/declarations.d.ts +9 -0
  35. package/dist/packs/typescript/declarations.js +74 -0
  36. package/dist/packs/typescript/members.d.ts +4 -0
  37. package/dist/packs/typescript/members.js +92 -0
  38. package/dist/packs/typescript/pack.d.ts +2 -0
  39. package/dist/packs/typescript/pack.js +53 -0
  40. package/dist/packs/typescript/resolve.d.ts +2 -0
  41. package/dist/packs/typescript/resolve.js +68 -0
  42. package/dist/packs/typescript/signals.d.ts +7 -0
  43. package/dist/packs/typescript/signals.js +310 -0
  44. package/dist/packs/yaml/pack.d.ts +2 -0
  45. package/dist/packs/yaml/pack.js +35 -0
  46. package/dist/src/cli.d.ts +2 -0
  47. package/dist/src/cli.js +477 -0
  48. package/dist/src/context/pre-grep.d.ts +15 -0
  49. package/dist/src/context/pre-grep.js +79 -0
  50. package/dist/src/context/pre-invoke.d.ts +20 -0
  51. package/dist/src/context/pre-invoke.js +127 -0
  52. package/dist/src/context/pre-prompt.d.ts +16 -0
  53. package/dist/src/context/pre-prompt.js +66 -0
  54. package/dist/src/context/session.d.ts +17 -0
  55. package/dist/src/context/session.js +57 -0
  56. package/dist/src/graph/build.d.ts +17 -0
  57. package/dist/src/graph/build.js +41 -0
  58. package/dist/src/graph/metrics.d.ts +12 -0
  59. package/dist/src/graph/metrics.js +75 -0
  60. package/dist/src/graph/topology.d.ts +5 -0
  61. package/dist/src/graph/topology.js +54 -0
  62. package/dist/src/health/compare.d.ts +2 -0
  63. package/dist/src/health/compare.js +38 -0
  64. package/dist/src/health/duplicates.d.ts +11 -0
  65. package/dist/src/health/duplicates.js +66 -0
  66. package/dist/src/health/health.d.ts +12 -0
  67. package/dist/src/health/health.js +94 -0
  68. package/dist/src/health/types.d.ts +101 -0
  69. package/dist/src/health/types.js +5 -0
  70. package/dist/src/index.d.ts +25 -0
  71. package/dist/src/index.js +22 -0
  72. package/dist/src/init/init.d.ts +104 -0
  73. package/dist/src/init/init.js +499 -0
  74. package/dist/src/init/scout.d.ts +45 -0
  75. package/dist/src/init/scout.js +217 -0
  76. package/dist/src/jsonc.d.ts +5 -0
  77. package/dist/src/jsonc.js +34 -0
  78. package/dist/src/mcp/server.d.ts +398 -0
  79. package/dist/src/mcp/server.js +543 -0
  80. package/dist/src/metrics/doctor.d.ts +15 -0
  81. package/dist/src/metrics/doctor.js +125 -0
  82. package/dist/src/metrics/log.d.ts +43 -0
  83. package/dist/src/metrics/log.js +101 -0
  84. package/dist/src/metrics/stats.d.ts +43 -0
  85. package/dist/src/metrics/stats.js +172 -0
  86. package/dist/src/model.d.ts +178 -0
  87. package/dist/src/model.js +2 -0
  88. package/dist/src/outputs.d.ts +16 -0
  89. package/dist/src/outputs.js +48 -0
  90. package/dist/src/packs/calls.d.ts +9 -0
  91. package/dist/src/packs/calls.js +119 -0
  92. package/dist/src/packs/dataShape.d.ts +6 -0
  93. package/dist/src/packs/dataShape.js +54 -0
  94. package/dist/src/packs/pack.d.ts +51 -0
  95. package/dist/src/packs/pack.js +3 -0
  96. package/dist/src/packs/packFiles.d.ts +5 -0
  97. package/dist/src/packs/packFiles.js +12 -0
  98. package/dist/src/packs/symbols.d.ts +39 -0
  99. package/dist/src/packs/symbols.js +98 -0
  100. package/dist/src/packs/treeSitter.d.ts +8 -0
  101. package/dist/src/packs/treeSitter.js +107 -0
  102. package/dist/src/queries/flow.d.ts +42 -0
  103. package/dist/src/queries/flow.js +398 -0
  104. package/dist/src/queries/investigate.d.ts +43 -0
  105. package/dist/src/queries/investigate.js +216 -0
  106. package/dist/src/queries/map.d.ts +28 -0
  107. package/dist/src/queries/map.js +102 -0
  108. package/dist/src/queries/neighborhood.d.ts +35 -0
  109. package/dist/src/queries/neighborhood.js +60 -0
  110. package/dist/src/queries/search.d.ts +37 -0
  111. package/dist/src/queries/search.js +279 -0
  112. package/dist/src/scan/audit.d.ts +2 -0
  113. package/dist/src/scan/audit.js +41 -0
  114. package/dist/src/scan/records.d.ts +12 -0
  115. package/dist/src/scan/records.js +42 -0
  116. package/dist/src/scan/resolveImports.d.ts +3 -0
  117. package/dist/src/scan/resolveImports.js +47 -0
  118. package/dist/src/scan/roles.d.ts +5 -0
  119. package/dist/src/scan/roles.js +87 -0
  120. package/dist/src/scan/scan.d.ts +24 -0
  121. package/dist/src/scan/scan.js +72 -0
  122. package/dist/src/text/briefs.d.ts +13 -0
  123. package/dist/src/text/briefs.js +43 -0
  124. package/dist/src/text/collapse.d.ts +10 -0
  125. package/dist/src/text/collapse.js +58 -0
  126. package/dist/src/text/declarations.d.ts +12 -0
  127. package/dist/src/text/declarations.js +120 -0
  128. package/dist/src/text/structure.d.ts +2 -0
  129. package/dist/src/text/structure.js +15 -0
  130. package/dist/src/text/tree.d.ts +20 -0
  131. package/dist/src/text/tree.js +49 -0
  132. package/dist/src/tokens.d.ts +4 -0
  133. package/dist/src/tokens.js +9 -0
  134. package/dist/src/version.d.ts +10 -0
  135. package/dist/src/version.js +11 -0
  136. package/dist/src/walk/ignoreRules.d.ts +17 -0
  137. package/dist/src/walk/ignoreRules.js +72 -0
  138. package/dist/src/walk/walk.d.ts +11 -0
  139. package/dist/src/walk/walk.js +29 -0
  140. package/grammars/LICENSE-tree-sitter-dart +20 -0
  141. package/grammars/README.md +11 -0
  142. package/grammars/tree-sitter-dart.wasm +0 -0
  143. package/package.json +68 -4
  144. package/packs/csharp/README.md +9 -0
  145. package/packs/csharp/imports.scm +3 -0
  146. package/packs/csharp/symbols.scm +17 -0
  147. package/packs/dart/imports.scm +5 -0
  148. package/packs/dart/symbols.scm +13 -0
  149. package/packs/msbuild/README.md +11 -0
  150. package/packs/typescript/exports.scm +16 -0
  151. package/packs/typescript/imports.scm +9 -0
  152. package/packs/typescript/symbols.scm +19 -0
  153. package/schema/ast_code_map.schema.json +144 -0
  154. package/schema/schema-lock.json +7 -0
  155. package/schema/topology.schema.json +87 -0
@@ -0,0 +1,72 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import ignore from 'ignore';
4
+ /**
5
+ * Folders no scan enters: dependencies, build output, caches, and the platform shells of app frameworks (they hold
6
+ * generated or vendor code). Dot folders and dot files are always left out as well.
7
+ */
8
+ export const DEFAULT_IGNORED_DIRS = new Set([
9
+ 'node_modules', 'bower_components', 'vendor', 'build', 'dist', 'out', 'coverage', 'bin', 'obj', 'target',
10
+ 'pods', 'deriveddata', '__pycache__', 'venv',
11
+ 'ios', 'android', 'windows', 'macos', 'linux', 'web', 'public', 'assets', 'static',
12
+ ]);
13
+ /** Files that hold secrets: never read, never listed (dot files such as `.env` are left out already). */
14
+ const SECRET_FILES = ignore().add(['*.pem', '*.key', '*.p12', '*.pfx', 'id_rsa', 'id_rsa.*', 'id_ed25519', 'id_ed25519.*', 'credentials.json', 'secrets.json', '*serviceAccountKey*.json']);
15
+ const IGNORE_FILES = ['.gitignore', '.contextignore'];
16
+ function readRules(dir) {
17
+ const texts = IGNORE_FILES.map((f) => path.join(dir, f)).filter((f) => fs.existsSync(f)).map((f) => fs.readFileSync(f, 'utf8'));
18
+ return texts.length ? ignore().add(texts.join('\n')) : undefined;
19
+ }
20
+ /** The folders from the scan root up to the repository root (the first one holding `.git`), nearest first. */
21
+ function ancestors(root) {
22
+ const found = [];
23
+ let dir = path.dirname(root);
24
+ let current = root;
25
+ while (!fs.existsSync(path.join(current, '.git')) && dir !== current) {
26
+ found.push(dir);
27
+ current = dir;
28
+ dir = path.dirname(dir);
29
+ }
30
+ return found;
31
+ }
32
+ /** Ignore rules of one scan: the defaults, every `.gitignore` and `.contextignore` that applies, and the caller's excluded paths. */
33
+ export class IgnoreRules {
34
+ root;
35
+ anchored = [];
36
+ excluded;
37
+ constructor(root, excludedPaths = []) {
38
+ this.root = root;
39
+ this.excluded = excludedPaths.map((p) => p.replace(/\\/g, '/').replace(/^\.?\/+/, '').replace(/\/+$/, '')).filter(Boolean);
40
+ for (const dir of ancestors(root))
41
+ this.addFolder(dir);
42
+ this.addFolder(root);
43
+ }
44
+ /** Reads the ignore files of a folder the walk enters. */
45
+ addFolder(absDir) {
46
+ const rules = readRules(absDir);
47
+ if (!rules)
48
+ return;
49
+ const above = !absDir.startsWith(this.root);
50
+ const posix = (p) => p.replace(/\\/g, '/');
51
+ this.anchored.push({ scope: above ? '' : posix(path.relative(this.root, absDir)), prefix: above ? posix(path.relative(absDir, this.root)) : '', rules });
52
+ }
53
+ /** Whether a path relative to the scan root is left out. */
54
+ ignores(relPath, isDir) {
55
+ const name = relPath.split('/').pop();
56
+ if (name.startsWith('.'))
57
+ return true;
58
+ if (isDir && DEFAULT_IGNORED_DIRS.has(name.toLowerCase()))
59
+ return true;
60
+ if (!isDir && SECRET_FILES.ignores(name))
61
+ return true;
62
+ if (this.excluded.some((ex) => relPath === ex || relPath.startsWith(`${ex}/`)))
63
+ return true;
64
+ return this.anchored.some((a) => this.matches(a, relPath, isDir));
65
+ }
66
+ matches(a, relPath, isDir) {
67
+ if (a.scope && !relPath.startsWith(`${a.scope}/`))
68
+ return false;
69
+ const local = a.scope ? relPath.slice(a.scope.length + 1) : a.prefix ? `${a.prefix}/${relPath}` : relPath;
70
+ return a.rules.ignores(isDir ? `${local}/` : local);
71
+ }
72
+ }
@@ -0,0 +1,11 @@
1
+ export interface WalkedFile {
2
+ /** Relative to the scan root, with forward slashes. */
3
+ path: string;
4
+ sizeBytes: number;
5
+ mtimeMs: number;
6
+ }
7
+ /**
8
+ * Every file under `root` that the ignore rules keep, sorted by path. Symbolic links are not followed, so a link
9
+ * can never lead the scan outside the folder.
10
+ */
11
+ export declare function walk(root: string, excludedPaths?: string[]): WalkedFile[];
@@ -0,0 +1,29 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { IgnoreRules } from './ignoreRules.js';
4
+ /**
5
+ * Every file under `root` that the ignore rules keep, sorted by path. Symbolic links are not followed, so a link
6
+ * can never lead the scan outside the folder.
7
+ */
8
+ export function walk(root, excludedPaths = []) {
9
+ const rules = new IgnoreRules(root, excludedPaths);
10
+ const found = [];
11
+ const visit = (absDir, relDir) => {
12
+ if (relDir)
13
+ rules.addFolder(absDir);
14
+ for (const entry of fs.readdirSync(absDir, { withFileTypes: true })) {
15
+ const rel = relDir ? `${relDir}/${entry.name}` : entry.name;
16
+ const abs = path.join(absDir, entry.name);
17
+ if (entry.isDirectory()) {
18
+ if (!rules.ignores(rel, true))
19
+ visit(abs, rel);
20
+ }
21
+ else if (entry.isFile() && !rules.ignores(rel, false)) {
22
+ const stat = fs.statSync(abs);
23
+ found.push({ path: rel, sizeBytes: stat.size, mtimeMs: stat.mtimeMs });
24
+ }
25
+ }
26
+ };
27
+ visit(root, '');
28
+ return found.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
29
+ }
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2020-2023 UserNobody14 and others
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,11 @@
1
+ # Grammars built by this project
2
+
3
+ Most grammars come from npm packages (`tree-sitter-wasms`, `tree-sitter-typescript`, `tree-sitter-c-sharp`), pinned in `package.json`. A grammar is built here only when no package ships a current one as WebAssembly.
4
+
5
+ | File | Source | Commit | Built with | SHA-256 | License |
6
+ | :--- | :--- | :--- | :--- | :--- | :--- |
7
+ | `tree-sitter-dart.wasm` | [UserNobody14/tree-sitter-dart](https://github.com/UserNobody14/tree-sitter-dart) | `0038280b774b65c1b89ba7fec50624d8baed9fe1` (2026-10-17) | tree-sitter CLI 0.25.10, emscripten 4.0.4 | `69be3d03b4b1e405ce984dc4ba40704a9c50ff81e120b55144499c81986da1f8` | MIT ([LICENSE-tree-sitter-dart](LICENSE-tree-sitter-dart)) |
8
+
9
+ The npm package `tree-sitter-dart` (1.0.0, February 2023) and the build in `tree-sitter-wasms` predate Dart 3, so they cannot read records, patterns or switch expressions, which freezed output uses.
10
+
11
+ Rebuild with `scripts/build-dart-grammar.sh` (needs Docker), then run `npm run golden:update` and review the diff. The tree-sitter CLI version must match `web-tree-sitter` in `package.json`.
Binary file
package/package.json CHANGED
@@ -1,6 +1,70 @@
1
1
  {
2
2
  "name": "@fabersep/atlas",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "private": false,
5
+ "description": "Deterministic codebase map, execution flow/impact graph, and token-budgeted context MCP server for AI coding agents.",
6
+ "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/fabersep/atlas.git"
10
+ },
11
+ "homepage": "https://github.com/fabersep/atlas#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/fabersep/atlas/issues"
14
+ },
15
+ "keywords": [
16
+ "fabersep",
17
+ "atlas",
18
+ "tree-sitter",
19
+ "ai-agents",
20
+ "code-context",
21
+ "code-map",
22
+ "dependency-graph",
23
+ "static-analysis",
24
+ "llm",
25
+ "mcp"
26
+ ],
27
+ "type": "module",
28
+ "bin": {
29
+ "faber-atlas": "dist/src/cli.js"
30
+ },
31
+ "exports": {
32
+ ".": "./dist/src/index.js"
33
+ },
34
+ "files": [
35
+ "dist/src",
36
+ "dist/packs",
37
+ "packs/*/*.scm",
38
+ "grammars",
39
+ "schema",
40
+ "LICENSE",
41
+ "README.md",
42
+ "CHANGELOG.md"
43
+ ],
44
+ "engines": {
45
+ "node": ">=20"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "scripts": {
51
+ "build": "tsc -p tsconfig.json",
52
+ "prepublishOnly": "npm run build",
53
+ "test": "npm run build && node --test dist/test/*.test.js",
54
+ "golden:update": "npm run build && node dist/test/updateGolden.js",
55
+ "faber-atlas": "node dist/src/cli.js"
56
+ },
57
+ "dependencies": {
58
+ "ignore": "7.0.12",
59
+ "tree-sitter-c-sharp": "0.23.5",
60
+ "tree-sitter-typescript": "0.23.2",
61
+ "tree-sitter-wasms": "0.1.13",
62
+ "web-tree-sitter": "0.25.10",
63
+ "yaml": "2.9.1"
64
+ },
65
+ "devDependencies": {
66
+ "@types/node": "22.10.2",
67
+ "ajv": "8.20.0",
68
+ "typescript": "5.8.3"
69
+ }
70
+ }
@@ -0,0 +1,9 @@
1
+ # C# pack
2
+
3
+ Files: `.cs`. Grammar: `tree-sitter-c-sharp` 0.23.5 (C# 12 and later).
4
+
5
+ **Declarations.** Classes, structs, records (positional parameters as properties), interfaces, enums and delegates, with nested types, methods, constructors, operators, indexers, properties (with their accessors) and fields. `public` and `internal` count as public. Base types named `I` + capital are interfaces.
6
+
7
+ **Imports.** A `using` resolves to every project file that declares the namespace; for `using static` and aliases, also the namespace the type sits in. Any other namespace is a package.
8
+
9
+ The sample project and its expected outputs are in [fixtures/](fixtures/). Solution and project references are read by the [msbuild pack](../msbuild/README.md).
@@ -0,0 +1,3 @@
1
+ ; using directives, including `global using`, `using static` and aliases (`using A = X.Y;`).
2
+
3
+ (using_directive) @using
@@ -0,0 +1,17 @@
1
+ ; Declarations the C# pack reads. A file-scoped namespace is a sibling of its types, a block namespace holds them in
2
+ ; its declaration_list; neither is captured, so types are top level. Types nested in a type become its members.
3
+
4
+ (compilation_unit
5
+ [(class_declaration) (struct_declaration) (record_declaration) (interface_declaration) (enum_declaration)
6
+ (delegate_declaration)] @symbol)
7
+
8
+ (declaration_list
9
+ [(class_declaration) (struct_declaration) (record_declaration) (interface_declaration) (enum_declaration)
10
+ (delegate_declaration)
11
+ (method_declaration) (constructor_declaration) (destructor_declaration) (operator_declaration)
12
+ (conversion_operator_declaration) (indexer_declaration) (property_declaration) (field_declaration)
13
+ (event_field_declaration) (event_declaration)] @symbol)
14
+
15
+ (enum_member_declaration_list (enum_member_declaration) @symbol)
16
+
17
+ (record_declaration (parameter_list (parameter) @symbol))
@@ -0,0 +1,5 @@
1
+ ; Library directives: import, export and part.
2
+
3
+ (import_specification (configurable_uri (uri (string_literal) @source)))
4
+ (library_export (configurable_uri (uri (string_literal) @source)))
5
+ (part_directive (uri (string_literal) @source))
@@ -0,0 +1,13 @@
1
+ ; Declarations the Dart pack reads. Dart keeps a function's body as the next sibling of its signature, and a top-level
2
+ ; variable's modifiers and type as siblings of its name list; the pack's describe module reads both.
3
+
4
+ (program
5
+ [(class_definition) (mixin_declaration) (extension_declaration) (enum_declaration) (type_alias)
6
+ (function_signature) (getter_signature) (setter_signature)] @symbol)
7
+
8
+ (program (static_final_declaration_list (static_final_declaration) @symbol))
9
+ (program (initialized_identifier_list (initialized_identifier) @symbol))
10
+
11
+ (class_body [(declaration) (method_signature)] @symbol)
12
+ (extension_body [(declaration) (method_signature)] @symbol)
13
+ (enum_body [(enum_constant) (declaration) (method_signature)] @symbol)
@@ -0,0 +1,11 @@
1
+ # MSBuild pack
2
+
3
+ Files: `.csproj .props .targets .sln .slnx`.
4
+
5
+ **Dependencies.** `PackageReference` entries are dependencies. `PrivateAssets="all"` marks a development dependency. The version is empty with central package management.
6
+
7
+ **Imports.** `ProjectReference` entries and the projects of a solution are imports, so project references are edges of the dependency graph.
8
+
9
+ **Parsing.** A small strict XML reader. A malformed file is recorded with its error and the scan goes on.
10
+
11
+ The sample project and its expected outputs are in [fixtures/](fixtures/).
@@ -0,0 +1,16 @@
1
+ ; Names a file exports without an `export` keyword on the declaration: export lists, export default <name>,
2
+ ; and CommonJS (module.exports = { a, b }, module.exports.a = ..., exports.a = ...).
3
+
4
+ (export_statement (export_clause (export_specifier name: (identifier) @name)) !source)
5
+ (export_statement value: (identifier) @name)
6
+ ((assignment_expression
7
+ left: (member_expression object: (identifier) @_m property: (property_identifier) @_e)
8
+ right: (object [(shorthand_property_identifier) @name (pair value: (identifier) @name)]))
9
+ (#eq? @_m "module") (#eq? @_e "exports"))
10
+ ((assignment_expression
11
+ left: (member_expression
12
+ object: (member_expression object: (identifier) @_m property: (property_identifier) @_e)
13
+ property: (property_identifier) @name))
14
+ (#eq? @_m "module") (#eq? @_e "exports"))
15
+ ((assignment_expression left: (member_expression object: (identifier) @_e property: (property_identifier) @name))
16
+ (#eq? @_e "exports"))
@@ -0,0 +1,9 @@
1
+ ; Module specifiers: static imports, re-exports, require() and dynamic import().
2
+
3
+ (import_statement source: (string (string_fragment) @source))
4
+ (export_statement source: (string (string_fragment) @source))
5
+ ((call_expression
6
+ function: (identifier) @_fn
7
+ arguments: (arguments . (string (string_fragment) @source)))
8
+ (#eq? @_fn "require"))
9
+ (call_expression function: (import) arguments: (arguments . (string (string_fragment) @source)))
@@ -0,0 +1,19 @@
1
+ ; Declarations the TypeScript and JavaScript pack reads. Each capture is one declaration; the pack's describe module
2
+ ; reads its name, signature and modifiers, and the core nests members into their containers by source range.
3
+
4
+ (program
5
+ [(class_declaration) (abstract_class_declaration) (interface_declaration) (enum_declaration)
6
+ (type_alias_declaration) (function_declaration) (generator_function_declaration)] @symbol)
7
+
8
+ (program
9
+ (export_statement
10
+ declaration: [(class_declaration) (abstract_class_declaration) (interface_declaration) (enum_declaration)
11
+ (type_alias_declaration) (function_declaration) (generator_function_declaration)] @symbol))
12
+
13
+ (program (lexical_declaration (variable_declarator) @symbol))
14
+ (program (variable_declaration (variable_declarator) @symbol))
15
+ (program (export_statement declaration: (lexical_declaration (variable_declarator) @symbol)))
16
+
17
+ (class_body [(method_definition) (public_field_definition) (abstract_method_signature)] @symbol)
18
+ (interface_body [(property_signature) (method_signature)] @symbol)
19
+ (enum_body [(property_identifier) (enum_assignment)] @symbol)
@@ -0,0 +1,144 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "ast_code_map.json",
4
+ "description": "Every scanned file with its declarations, imports, skeleton and token estimates, plus the dependency audit.",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "generatorVersion", "generatedAt", "rootName", "summary", "files", "audit"],
8
+ "properties": {
9
+ "schemaVersion": { "const": 1 },
10
+ "generatorVersion": { "type": "string" },
11
+ "generatedAt": { "type": "string" },
12
+ "rootName": { "type": "string" },
13
+ "summary": { "$ref": "#/$defs/summary" },
14
+ "files": { "type": "array", "items": { "$ref": "#/$defs/file" } },
15
+ "audit": { "type": "array", "items": { "$ref": "#/$defs/auditEntry" } }
16
+ },
17
+ "$defs": {
18
+ "count": { "type": "integer", "minimum": 0 },
19
+ "summary": {
20
+ "type": "object",
21
+ "additionalProperties": false,
22
+ "required": ["files", "parsed", "reused", "failed", "unsupported", "languages", "symbols", "rawTokens", "skeletonTokens", "durationMs"],
23
+ "properties": {
24
+ "files": { "$ref": "#/$defs/count" },
25
+ "parsed": { "$ref": "#/$defs/count" },
26
+ "reused": { "$ref": "#/$defs/count" },
27
+ "failed": {
28
+ "type": "array",
29
+ "items": {
30
+ "type": "object", "additionalProperties": false, "required": ["path", "error"],
31
+ "properties": { "path": { "type": "string" }, "error": { "type": "string" } }
32
+ }
33
+ },
34
+ "unsupported": { "type": "object", "additionalProperties": { "$ref": "#/$defs/count" } },
35
+ "languages": { "type": "object", "additionalProperties": { "$ref": "#/$defs/count" } },
36
+ "symbols": { "$ref": "#/$defs/count" },
37
+ "rawTokens": { "$ref": "#/$defs/count" },
38
+ "skeletonTokens": { "$ref": "#/$defs/count" },
39
+ "durationMs": { "type": "number", "minimum": 0 }
40
+ }
41
+ },
42
+ "file": {
43
+ "type": "object",
44
+ "additionalProperties": false,
45
+ "required": ["path", "language", "sizeBytes", "mtimeMs", "symbols", "imports", "skeleton", "rawTokens", "skeletonTokens"],
46
+ "properties": {
47
+ "path": { "type": "string", "description": "Relative to the scanned folder, with forward slashes." },
48
+ "language": { "type": "string", "description": "The pack's id, or other when no pack claims the file." },
49
+ "sizeBytes": { "$ref": "#/$defs/count" },
50
+ "mtimeMs": { "type": "number" },
51
+ "symbols": { "type": "array", "items": { "$ref": "#/$defs/symbol" } },
52
+ "imports": { "type": "array", "items": { "$ref": "#/$defs/import" } },
53
+ "skeleton": { "type": "string" },
54
+ "rawTokens": { "$ref": "#/$defs/count" },
55
+ "skeletonTokens": { "$ref": "#/$defs/count" },
56
+ "error": { "type": "string", "description": "The parse error; the file then has no declarations." },
57
+ "skipped": { "type": "string", "description": "Why the file was not parsed." },
58
+ "declares": { "type": "array", "items": { "$ref": "#/$defs/declared" } },
59
+ "roles": {
60
+ "type": "array",
61
+ "items": { "enum": ["http", "event", "job", "db", "auth", "ui", "io"] }
62
+ }
63
+ }
64
+ },
65
+ "symbol": {
66
+ "type": "object",
67
+ "additionalProperties": false,
68
+ "required": ["kind", "name", "signature", "lineStart", "lineEnd", "exported", "visibility"],
69
+ "properties": {
70
+ "kind": { "enum": ["class", "interface", "enum", "mixin", "extension", "type", "function", "variable", "method", "constructor", "field", "getter", "setter", "enumMember"] },
71
+ "name": { "type": "string" },
72
+ "signature": { "type": "string" },
73
+ "type": { "type": "string" },
74
+ "lineStart": { "type": "integer", "minimum": 1 },
75
+ "lineEnd": { "type": "integer", "minimum": 1 },
76
+ "nesting": { "type": "integer", "minimum": 0, "description": "A function, method, constructor, getter or setter: its deepest nesting of control-flow blocks (if, loops, switch, try); an else if stays on its if's level." },
77
+ "exported": { "type": "boolean" },
78
+ "visibility": { "enum": ["public", "protected", "private"] },
79
+ "static": { "const": true },
80
+ "lifecycle": { "const": true },
81
+ "entrypoints": { "type": "array", "items": { "type": "string" } },
82
+ "throws": { "type": "array", "items": { "type": "string" } },
83
+ "calls": { "type": "array", "items": { "$ref": "#/$defs/callSite" } },
84
+ "extends": { "type": "array", "items": { "type": "string" } },
85
+ "implements": { "type": "array", "items": { "type": "string" } },
86
+ "mixins": { "type": "array", "items": { "type": "string" } },
87
+ "members": { "type": "array", "items": { "$ref": "#/$defs/symbol" } }
88
+ }
89
+ },
90
+ "callSite": {
91
+ "type": "object",
92
+ "additionalProperties": false,
93
+ "required": ["callee", "method", "line", "kind"],
94
+ "properties": {
95
+ "callee": { "type": "string" },
96
+ "receiver": { "type": "string" },
97
+ "receiverType": { "type": "string" },
98
+ "method": { "type": "string" },
99
+ "line": { "type": "integer", "minimum": 1 },
100
+ "kind": { "enum": ["calls", "emits", "queues", "sends"] },
101
+ "targetKey": { "type": "string" },
102
+ "boundary": { "enum": ["db", "http", "queue", "fs"] }
103
+ }
104
+ },
105
+ "import": {
106
+ "type": "object",
107
+ "additionalProperties": false,
108
+ "required": ["specifier", "line", "kind"],
109
+ "properties": {
110
+ "specifier": { "type": "string" },
111
+ "line": { "type": "integer", "minimum": 1 },
112
+ "typeOnly": { "const": true },
113
+ "kind": { "enum": ["file", "package", "builtin", "unresolved"] },
114
+ "target": { "type": "string" },
115
+ "package": { "type": "string" }
116
+ }
117
+ },
118
+ "declared": {
119
+ "type": "object",
120
+ "additionalProperties": false,
121
+ "required": ["name", "version", "dev"],
122
+ "properties": {
123
+ "name": { "type": "string" },
124
+ "version": { "type": "string" },
125
+ "dev": { "type": "boolean" },
126
+ "sdk": { "const": true }
127
+ }
128
+ },
129
+ "auditEntry": {
130
+ "type": "object",
131
+ "additionalProperties": false,
132
+ "required": ["name", "manifest", "version", "dev", "dormant", "importCount", "files"],
133
+ "properties": {
134
+ "name": { "type": "string" },
135
+ "manifest": { "type": "string" },
136
+ "version": { "type": "string" },
137
+ "dev": { "type": "boolean" },
138
+ "dormant": { "type": "boolean" },
139
+ "importCount": { "$ref": "#/$defs/count" },
140
+ "files": { "type": "array", "items": { "type": "string" } }
141
+ }
142
+ }
143
+ }
144
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "sha256": {
4
+ "ast_code_map.schema.json": "eb2f6ae5fd353b6145c88fce28704c0c8916b97775f6764f95d2f5f51cb6a501",
5
+ "topology.schema.json": "92b8aa2367f3e512051b7ceb154f96bf250dd70eb141846ed9ba05fecc470c2f"
6
+ }
7
+ }
@@ -0,0 +1,87 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "topology.json",
4
+ "description": "The dependency graph: files and their top-level declarations, import, defines, extends and implements edges, degrees, centrality, PageRank, cycles, clusters and hubs.",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "generatorVersion", "generatedAt", "summary", "nodes", "edges"],
8
+ "properties": {
9
+ "schemaVersion": { "const": 1 },
10
+ "generatorVersion": { "type": "string" },
11
+ "generatedAt": { "type": "string" },
12
+ "summary": {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "required": ["totalFiles", "totalSymbols", "totalNodes", "totalEdges", "density", "circularDependencies", "clusters", "topHubs"],
16
+ "properties": {
17
+ "totalFiles": { "$ref": "#/$defs/count" },
18
+ "totalSymbols": { "$ref": "#/$defs/count" },
19
+ "totalNodes": { "$ref": "#/$defs/count" },
20
+ "totalEdges": { "$ref": "#/$defs/count" },
21
+ "density": { "type": "number", "minimum": 0 },
22
+ "circularDependencies": {
23
+ "type": "array",
24
+ "items": {
25
+ "type": "object", "additionalProperties": false, "required": ["cycle"],
26
+ "properties": { "cycle": { "type": "array", "items": { "type": "string" }, "minItems": 2 } }
27
+ }
28
+ },
29
+ "clusters": {
30
+ "type": "array",
31
+ "items": {
32
+ "type": "object", "additionalProperties": false, "required": ["name", "nodeCount"],
33
+ "properties": { "name": { "type": "string" }, "nodeCount": { "$ref": "#/$defs/count" } }
34
+ }
35
+ },
36
+ "topHubs": { "type": "array", "items": { "$ref": "#/$defs/hub" } }
37
+ }
38
+ },
39
+ "nodes": { "type": "array", "items": { "$ref": "#/$defs/node" } },
40
+ "edges": { "type": "array", "items": { "$ref": "#/$defs/edge" } }
41
+ },
42
+ "$defs": {
43
+ "count": { "type": "integer", "minimum": 0 },
44
+ "node": {
45
+ "type": "object",
46
+ "additionalProperties": false,
47
+ "required": ["id", "label", "path", "type", "inDegree", "outDegree", "centralityScore", "pageRank", "cluster"],
48
+ "properties": {
49
+ "id": { "type": "string", "description": "file:<path> or symbol:<path>#<name>" },
50
+ "label": { "type": "string" },
51
+ "path": { "type": "string" },
52
+ "type": { "enum": ["file", "class", "interface", "enum", "mixin", "extension", "type", "function"] },
53
+ "language": { "type": "string" },
54
+ "line": { "type": "integer", "minimum": 1 },
55
+ "tokenEstimate": { "$ref": "#/$defs/count" },
56
+ "inDegree": { "$ref": "#/$defs/count" },
57
+ "outDegree": { "$ref": "#/$defs/count" },
58
+ "centralityScore": { "$ref": "#/$defs/count" },
59
+ "pageRank": { "type": "number", "minimum": 0 },
60
+ "cluster": { "type": "string" }
61
+ }
62
+ },
63
+ "edge": {
64
+ "type": "object",
65
+ "additionalProperties": false,
66
+ "required": ["source", "target", "type"],
67
+ "properties": {
68
+ "source": { "type": "string" },
69
+ "target": { "type": "string" },
70
+ "type": { "enum": ["imports", "defines", "extends", "implements"] }
71
+ }
72
+ },
73
+ "hub": {
74
+ "type": "object",
75
+ "additionalProperties": false,
76
+ "required": ["id", "path", "inDegree", "outDegree", "centralityScore", "pageRank"],
77
+ "properties": {
78
+ "id": { "type": "string" },
79
+ "path": { "type": "string" },
80
+ "inDegree": { "$ref": "#/$defs/count" },
81
+ "outDegree": { "$ref": "#/$defs/count" },
82
+ "centralityScore": { "$ref": "#/$defs/count" },
83
+ "pageRank": { "type": "number", "minimum": 0 }
84
+ }
85
+ }
86
+ }
87
+ }