@fabersep/atlas 0.0.0-stage → 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 (143) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/LICENSE +202 -0
  3. package/README.md +139 -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 +201 -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 +186 -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 +371 -0
  48. package/dist/src/graph/build.d.ts +17 -0
  49. package/dist/src/graph/build.js +41 -0
  50. package/dist/src/graph/metrics.d.ts +12 -0
  51. package/dist/src/graph/metrics.js +75 -0
  52. package/dist/src/graph/topology.d.ts +5 -0
  53. package/dist/src/graph/topology.js +54 -0
  54. package/dist/src/health/compare.d.ts +2 -0
  55. package/dist/src/health/compare.js +38 -0
  56. package/dist/src/health/duplicates.d.ts +11 -0
  57. package/dist/src/health/duplicates.js +66 -0
  58. package/dist/src/health/health.d.ts +12 -0
  59. package/dist/src/health/health.js +94 -0
  60. package/dist/src/health/types.d.ts +101 -0
  61. package/dist/src/health/types.js +5 -0
  62. package/dist/src/index.d.ts +23 -0
  63. package/dist/src/index.js +20 -0
  64. package/dist/src/init/init.d.ts +73 -0
  65. package/dist/src/init/init.js +305 -0
  66. package/dist/src/init/scout.d.ts +45 -0
  67. package/dist/src/init/scout.js +208 -0
  68. package/dist/src/jsonc.d.ts +5 -0
  69. package/dist/src/jsonc.js +34 -0
  70. package/dist/src/mcp/server.d.ts +266 -0
  71. package/dist/src/mcp/server.js +414 -0
  72. package/dist/src/metrics/doctor.d.ts +15 -0
  73. package/dist/src/metrics/doctor.js +125 -0
  74. package/dist/src/metrics/log.d.ts +43 -0
  75. package/dist/src/metrics/log.js +101 -0
  76. package/dist/src/metrics/stats.d.ts +43 -0
  77. package/dist/src/metrics/stats.js +172 -0
  78. package/dist/src/model.d.ts +178 -0
  79. package/dist/src/model.js +2 -0
  80. package/dist/src/outputs.d.ts +16 -0
  81. package/dist/src/outputs.js +48 -0
  82. package/dist/src/packs/calls.d.ts +9 -0
  83. package/dist/src/packs/calls.js +119 -0
  84. package/dist/src/packs/dataShape.d.ts +6 -0
  85. package/dist/src/packs/dataShape.js +54 -0
  86. package/dist/src/packs/pack.d.ts +51 -0
  87. package/dist/src/packs/pack.js +3 -0
  88. package/dist/src/packs/packFiles.d.ts +5 -0
  89. package/dist/src/packs/packFiles.js +12 -0
  90. package/dist/src/packs/symbols.d.ts +39 -0
  91. package/dist/src/packs/symbols.js +98 -0
  92. package/dist/src/packs/treeSitter.d.ts +8 -0
  93. package/dist/src/packs/treeSitter.js +107 -0
  94. package/dist/src/queries/flow.d.ts +42 -0
  95. package/dist/src/queries/flow.js +391 -0
  96. package/dist/src/queries/map.d.ts +28 -0
  97. package/dist/src/queries/map.js +102 -0
  98. package/dist/src/queries/neighborhood.d.ts +35 -0
  99. package/dist/src/queries/neighborhood.js +60 -0
  100. package/dist/src/scan/audit.d.ts +2 -0
  101. package/dist/src/scan/audit.js +41 -0
  102. package/dist/src/scan/records.d.ts +12 -0
  103. package/dist/src/scan/records.js +42 -0
  104. package/dist/src/scan/resolveImports.d.ts +3 -0
  105. package/dist/src/scan/resolveImports.js +47 -0
  106. package/dist/src/scan/roles.d.ts +5 -0
  107. package/dist/src/scan/roles.js +87 -0
  108. package/dist/src/scan/scan.d.ts +24 -0
  109. package/dist/src/scan/scan.js +72 -0
  110. package/dist/src/text/briefs.d.ts +13 -0
  111. package/dist/src/text/briefs.js +43 -0
  112. package/dist/src/text/collapse.d.ts +10 -0
  113. package/dist/src/text/collapse.js +58 -0
  114. package/dist/src/text/declarations.d.ts +12 -0
  115. package/dist/src/text/declarations.js +120 -0
  116. package/dist/src/text/structure.d.ts +2 -0
  117. package/dist/src/text/structure.js +15 -0
  118. package/dist/src/text/tree.d.ts +20 -0
  119. package/dist/src/text/tree.js +49 -0
  120. package/dist/src/tokens.d.ts +4 -0
  121. package/dist/src/tokens.js +9 -0
  122. package/dist/src/version.d.ts +10 -0
  123. package/dist/src/version.js +11 -0
  124. package/dist/src/walk/ignoreRules.d.ts +17 -0
  125. package/dist/src/walk/ignoreRules.js +72 -0
  126. package/dist/src/walk/walk.d.ts +11 -0
  127. package/dist/src/walk/walk.js +29 -0
  128. package/grammars/LICENSE-tree-sitter-dart +20 -0
  129. package/grammars/README.md +11 -0
  130. package/grammars/tree-sitter-dart.wasm +0 -0
  131. package/package.json +68 -4
  132. package/packs/csharp/README.md +9 -0
  133. package/packs/csharp/imports.scm +3 -0
  134. package/packs/csharp/symbols.scm +17 -0
  135. package/packs/dart/imports.scm +5 -0
  136. package/packs/dart/symbols.scm +13 -0
  137. package/packs/msbuild/README.md +11 -0
  138. package/packs/typescript/exports.scm +16 -0
  139. package/packs/typescript/imports.scm +9 -0
  140. package/packs/typescript/symbols.scm +19 -0
  141. package/schema/ast_code_map.schema.json +144 -0
  142. package/schema/schema-lock.json +7 -0
  143. package/schema/topology.schema.json +87 -0
@@ -0,0 +1,66 @@
1
+ import crypto from 'node:crypto';
2
+ const TRIVIAL = /^[\s{}()[\];,]*$/;
3
+ function significantLines(content) {
4
+ return content.split('\n').flatMap((raw, i) => {
5
+ const text = raw.trim().replace(/\s+/g, ' ');
6
+ return TRIVIAL.test(text) ? [] : [{ text, number: i + 1 }];
7
+ });
8
+ }
9
+ const hashOf = (lines) => crypto.createHash('sha1').update(lines.map((l) => l.text).join('\n')).digest('hex').slice(0, 12);
10
+ function windowsOf(file, minLines) {
11
+ const lines = significantLines(file.content);
12
+ return Array.from({ length: Math.max(0, lines.length - minLines + 1) }, (_, i) => hashOf(lines.slice(i, i + minLines)));
13
+ }
14
+ /** Where each window hash starts; a hash is duplicated when it starts in two files or twice without overlapping. */
15
+ function duplicatedHashes(windows, minLines) {
16
+ const starts = new Map();
17
+ for (const [path, hashes] of windows)
18
+ hashes.forEach((h, index) => starts.set(h, [...(starts.get(h) ?? []), { path, index }]));
19
+ const duplicated = new Set();
20
+ for (const [hash, at] of starts) {
21
+ const apart = at.some((a, i) => at.slice(i + 1).some((b) => b.path !== a.path || Math.abs(b.index - a.index) >= minLines));
22
+ if (apart)
23
+ duplicated.add(hash);
24
+ }
25
+ return duplicated;
26
+ }
27
+ /** Runs of consecutive duplicated windows in one file, as blocks with their line range. */
28
+ function blocksOf(file, hashes, duplicated, minLines) {
29
+ const lines = significantLines(file.content);
30
+ const blocks = [];
31
+ let open = null;
32
+ const close = (last) => {
33
+ if (open)
34
+ blocks.push({ path: file.path, lineStart: lines[open.first].number, lineEnd: lines[last + minLines - 1].number, keys: open.keys });
35
+ open = null;
36
+ };
37
+ hashes.forEach((h, i) => {
38
+ if (!duplicated.has(h))
39
+ return close(i - 1);
40
+ open = open ?? { first: i, keys: [] };
41
+ open.keys.push(h);
42
+ });
43
+ close(hashes.length - 1);
44
+ return blocks;
45
+ }
46
+ /** Blocks that share a window are copies of each other (union of the blocks by shared keys). */
47
+ function groupCopies(blocks) {
48
+ const groups = [];
49
+ for (const block of blocks) {
50
+ const keys = new Set(block.keys);
51
+ const joined = groups.filter((g) => g.some((b) => b.keys.some((k) => keys.has(k))));
52
+ const merged = [...joined.flat(), block];
53
+ groups.splice(0, groups.length, ...groups.filter((g) => !joined.includes(g)), merged);
54
+ }
55
+ return groups.filter((g) => g.length > 1).map((g) => ({
56
+ keys: [...new Set(g.flatMap((b) => b.keys))].sort(),
57
+ lines: Math.max(...g.map((b) => b.lineEnd - b.lineStart + 1)),
58
+ locations: g.map(({ path, lineStart, lineEnd }) => ({ path, lineStart, lineEnd })).sort((a, b) => a.path.localeCompare(b.path) || a.lineStart - b.lineStart),
59
+ }));
60
+ }
61
+ export function findDuplicates(files, minLines) {
62
+ const windows = new Map(files.map((f) => [f.path, windowsOf(f, minLines)]));
63
+ const duplicated = duplicatedHashes(windows, minLines);
64
+ const blocks = files.flatMap((f) => blocksOf(f, windows.get(f.path), duplicated, minLines));
65
+ return groupCopies(blocks).sort((a, b) => a.locations[0].path.localeCompare(b.locations[0].path) || a.locations[0].lineStart - b.locations[0].lineStart);
66
+ }
@@ -0,0 +1,12 @@
1
+ import type { CodeMap, Topology } from '../model.js';
2
+ import type { LanguagePack } from '../packs/pack.js';
3
+ import { type HealthLimits, type HealthReport } from './types.js';
4
+ /**
5
+ * The code health of a scanned folder (FR-07, CIN-18): files over the line limit, functions over the soft and hard
6
+ * limits and over the nesting limit, duplicated blocks and import cycles, from the scan's outputs and the files themselves. Only files a code pack
7
+ * declares are measured; data files (JSON, YAML) are left out, and files no pack reads are listed as not measured.
8
+ */
9
+ /** Checks that every limit was passed as a positive whole number; no limit is ever assumed. */
10
+ export declare function checkLimits(input: Partial<Record<keyof HealthLimits, unknown>>): HealthLimits;
11
+ /** The health report of `root`, whose scan outputs are `map` and `topology`. */
12
+ export declare function health(map: CodeMap, topology: Topology, root: string, limits: HealthLimits, packs: LanguagePack[]): HealthReport;
@@ -0,0 +1,94 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { FUNCTION_KINDS } from '../packs/symbols.js';
4
+ import { GENERATOR_VERSION } from '../version.js';
5
+ import { findDuplicates } from './duplicates.js';
6
+ import { LIMIT_NAMES, HealthLimitsError, } from './types.js';
7
+ /**
8
+ * The code health of a scanned folder (FR-07, CIN-18): files over the line limit, functions over the soft and hard
9
+ * limits and over the nesting limit, duplicated blocks and import cycles, from the scan's outputs and the files themselves. Only files a code pack
10
+ * declares are measured; data files (JSON, YAML) are left out, and files no pack reads are listed as not measured.
11
+ */
12
+ /** Checks that every limit was passed as a positive whole number; no limit is ever assumed. */
13
+ export function checkLimits(input) {
14
+ const missing = LIMIT_NAMES.filter((name) => input[name] === undefined);
15
+ if (missing.length)
16
+ throw new HealthLimitsError(`Missing limit(s): ${missing.join(', ')}. Health needs every limit; none is assumed.`);
17
+ const invalid = LIMIT_NAMES.filter((name) => !Number.isInteger(input[name]) || input[name] < 1);
18
+ if (invalid.length)
19
+ throw new HealthLimitsError(`Limit(s) must be positive whole numbers: ${invalid.join(', ')}.`);
20
+ return Object.fromEntries(LIMIT_NAMES.map((name) => [name, input[name]]));
21
+ }
22
+ const lineCount = (content) => (content === '' ? 0 : content.replace(/\n$/, '').split('\n').length);
23
+ /** Every function-like declaration of a file, members named `Class.member`. */
24
+ function functionSymbols(file) {
25
+ const walk = (nodes, owner) => nodes.flatMap((node) => {
26
+ const name = owner ? `${owner}.${node.name}` : node.name;
27
+ const inner = node.members ? walk(node.members, node.name) : [];
28
+ return FUNCTION_KINDS.has(node.kind) ? [{ path: file.path, name, node }, ...inner] : inner;
29
+ });
30
+ return walk(file.symbols);
31
+ }
32
+ function overLength({ path: p, name, node }, limits) {
33
+ const lines = node.lineEnd - node.lineStart + 1;
34
+ if (lines <= limits.maxFunctionLines)
35
+ return [];
36
+ const limit = lines > limits.hardFunctionLines ? 'hard' : 'soft';
37
+ return [{ path: p, name, kind: node.kind, lineStart: node.lineStart, lineEnd: node.lineEnd, lines, limit }];
38
+ }
39
+ /** The nesting depth the scan recorded; outputs of a version before 0.4.0 have none and must be scanned again. */
40
+ function nestingOf({ path: p, name, node }) {
41
+ if (node.nesting === undefined)
42
+ throw new Error(`${p}: ${name} has no nesting depth; the scan outputs predate it, scan again.`);
43
+ return node.nesting;
44
+ }
45
+ function overNesting(fn, limits) {
46
+ const nesting = nestingOf(fn);
47
+ if (nesting <= limits.maxNestingDepth)
48
+ return [];
49
+ return [{ path: fn.path, name: fn.name, kind: fn.node.kind, lineStart: fn.node.lineStart, lineEnd: fn.node.lineEnd, nesting }];
50
+ }
51
+ function notMeasuredReason(file) {
52
+ if (file.language === 'other')
53
+ return 'no language pack';
54
+ if (file.skipped)
55
+ return `not parsed: ${file.skipped}`;
56
+ if (file.error)
57
+ return `parse error: ${file.error}`;
58
+ return null;
59
+ }
60
+ function measure(map, root, dataLanguages) {
61
+ const result = { code: [], notMeasured: [] };
62
+ for (const file of map.files) {
63
+ if (dataLanguages.has(file.language))
64
+ continue;
65
+ const content = fs.readFileSync(path.join(root, file.path), 'utf8');
66
+ const reason = notMeasuredReason(file);
67
+ if (reason)
68
+ result.notMeasured.push({ path: file.path, reason, lines: lineCount(content) });
69
+ else
70
+ result.code.push({ ...file, lines: lineCount(content), content });
71
+ }
72
+ return result;
73
+ }
74
+ /** The health report of `root`, whose scan outputs are `map` and `topology`. */
75
+ export function health(map, topology, root, limits, packs) {
76
+ checkLimits(limits);
77
+ const { code, notMeasured } = measure(map, root, new Set(packs.filter((p) => p.data).map((p) => p.id)));
78
+ const files = code.filter((f) => f.lines > limits.maxFileLines).map(({ path: p, language, lines }) => ({ path: p, language, lines }));
79
+ const symbols = code.flatMap(functionSymbols);
80
+ const functions = symbols.flatMap((f) => overLength(f, limits));
81
+ const nesting = symbols.flatMap((f) => overNesting(f, limits));
82
+ const duplicates = findDuplicates(code.map((f) => ({ path: f.path, content: f.content })), limits.minDuplicateLines);
83
+ const cycles = topology.summary.circularDependencies.map((c) => c.cycle);
84
+ return {
85
+ generatorVersion: GENERATOR_VERSION, limits, files, functions, nesting, duplicates, cycles, notMeasured,
86
+ totals: {
87
+ files: code.length, lines: code.reduce((n, f) => n + f.lines, 0), filesOverLimit: files.length, functions: symbols.length,
88
+ functionsOverSoft: functions.filter((f) => f.limit === 'soft').length, functionsOverHard: functions.filter((f) => f.limit === 'hard').length,
89
+ functionsOverNesting: nesting.length, deepestNesting: symbols.reduce((n, f) => Math.max(n, nestingOf(f)), 0),
90
+ duplicateBlocks: duplicates.length, duplicatedLines: duplicates.reduce((n, d) => n + d.lines * (d.locations.length - 1), 0),
91
+ cycles: cycles.length, notMeasured: notMeasured.length,
92
+ },
93
+ };
94
+ }
@@ -0,0 +1,101 @@
1
+ /** The shapes of the `health` and `health-compare` results (FR-07, CIN-18). Every limit is an input, never built in. */
2
+ export interface HealthLimits {
3
+ /** A file longer than this many lines is over the limit. */
4
+ maxFileLines: number;
5
+ /** A function longer than this many lines is over the soft limit. */
6
+ maxFunctionLines: number;
7
+ /** A function longer than this many lines is over the hard limit. */
8
+ hardFunctionLines: number;
9
+ /** A function whose control-flow blocks nest deeper than this is over the limit. */
10
+ maxNestingDepth: number;
11
+ /** The shortest run of significant lines counted as a duplicated block. */
12
+ minDuplicateLines: number;
13
+ }
14
+ export declare const LIMIT_NAMES: Array<keyof HealthLimits>;
15
+ export interface FileOverLimit {
16
+ path: string;
17
+ language: string;
18
+ lines: number;
19
+ }
20
+ export interface FunctionOverLimit {
21
+ path: string;
22
+ /** `Class.method` for a member, the plain name at the top level. */
23
+ name: string;
24
+ kind: string;
25
+ lineStart: number;
26
+ lineEnd: number;
27
+ lines: number;
28
+ limit: 'soft' | 'hard';
29
+ }
30
+ /** A function whose control-flow blocks nest deeper than `maxNestingDepth`. */
31
+ export interface DeepFunction {
32
+ path: string;
33
+ name: string;
34
+ kind: string;
35
+ lineStart: number;
36
+ lineEnd: number;
37
+ nesting: number;
38
+ }
39
+ export interface DuplicateLocation {
40
+ path: string;
41
+ lineStart: number;
42
+ lineEnd: number;
43
+ }
44
+ export interface DuplicateBlock {
45
+ /** Hashes of the windows the copies share; a later report's block is new when it shares none of them. */
46
+ keys: string[];
47
+ lines: number;
48
+ locations: DuplicateLocation[];
49
+ }
50
+ /** A file the report could not measure: no language pack, too large, or a parse error. It is never counted as healthy. */
51
+ export interface NotMeasured {
52
+ path: string;
53
+ reason: string;
54
+ lines: number;
55
+ }
56
+ export interface HealthTotals {
57
+ files: number;
58
+ lines: number;
59
+ filesOverLimit: number;
60
+ functions: number;
61
+ functionsOverSoft: number;
62
+ functionsOverHard: number;
63
+ functionsOverNesting: number;
64
+ /** The deepest nesting of any measured function. */
65
+ deepestNesting: number;
66
+ duplicateBlocks: number;
67
+ duplicatedLines: number;
68
+ cycles: number;
69
+ notMeasured: number;
70
+ }
71
+ export interface HealthReport {
72
+ generatorVersion: string;
73
+ limits: HealthLimits;
74
+ files: FileOverLimit[];
75
+ functions: FunctionOverLimit[];
76
+ nesting: DeepFunction[];
77
+ duplicates: DuplicateBlock[];
78
+ cycles: string[][];
79
+ notMeasured: NotMeasured[];
80
+ totals: HealthTotals;
81
+ }
82
+ export interface HealthComparison {
83
+ limits: HealthLimits;
84
+ /** Files over the line limit in `after` that were not over it in `before`. */
85
+ files: FileOverLimit[];
86
+ /** Functions over a limit in `after` that were not over that limit in `before`. */
87
+ functions: FunctionOverLimit[];
88
+ /** Functions over the nesting limit in `after` that were not over it in `before`. */
89
+ nesting: DeepFunction[];
90
+ duplicates: DuplicateBlock[];
91
+ cycles: string[][];
92
+ /** Files in `after` that could not be measured and are new or changed in length. */
93
+ notMeasured: NotMeasured[];
94
+ totals: {
95
+ before: HealthTotals;
96
+ after: HealthTotals;
97
+ };
98
+ }
99
+ /** A limit was not passed, or is not a positive whole number; the message names each one. */
100
+ export declare class HealthLimitsError extends Error {
101
+ }
@@ -0,0 +1,5 @@
1
+ /** The shapes of the `health` and `health-compare` results (FR-07, CIN-18). Every limit is an input, never built in. */
2
+ export const LIMIT_NAMES = ['maxFileLines', 'maxFunctionLines', 'hardFunctionLines', 'maxNestingDepth', 'minDuplicateLines'];
3
+ /** A limit was not passed, or is not a positive whole number; the message names each one. */
4
+ export class HealthLimitsError extends Error {
5
+ }
@@ -0,0 +1,23 @@
1
+ /** The library API: the same functions the `faber-atlas` command runs. */
2
+ export { scan, type ScanOptions, type ScanResult } from './scan/scan.js';
3
+ export { renderMap, isTestFile, type MapOptions, type ZoomLevel } from './queries/map.js';
4
+ export { flow, impact, renderFlow, UnknownSymbolError, type FlowEdgeKind, type FlowNode, type FlowOptions, type FlowResult } from './queries/flow.js';
5
+ export { inferFileRoles, ROLE_TAGS } from './scan/roles.js';
6
+ export { neighborhood, UnknownFileError, type Neighborhood, type NeighborhoodEntry, type NeighborhoodOptions } from './queries/neighborhood.js';
7
+ export { rankHubs as hubs } from './graph/topology.js';
8
+ export { ensureFreshIndex, McpHandler, MCP_TOOLS, serveMcp, type McpServerOptions } from './mcp/server.js';
9
+ export { planOrApplyInit, formatInitPlan, detectTargetEngines, type EngineName, type InitOptions, type InitResult } from './init/init.js';
10
+ export { readCurrentScoutConfigs, setScoutConfig, formatScoutStatus, discoverLiveAgyModels, CLAUDE_SCOUT_TIERS, ANTIGRAVITY_SCOUT_TIERS, type EffortLevel, type ScoutConfig, type ScoutEngine, } from './init/scout.js';
11
+ export { computeStats, formatStats, formatShareCard, type AtlasStats } from './metrics/stats.js';
12
+ export { runDoctor, formatDoctor, type DoctorCheck, type DoctorReport } from './metrics/doctor.js';
13
+ export { readMetrics, type MetricEvent, type ScanMetricEvent, type McpCallMetricEvent } from './metrics/log.js';
14
+ export { readCodeMap, readTopology, OutputMissingError, OutputVersionError } from './outputs.js';
15
+ export { PACKS } from '../packs/index.js';
16
+ export { health, checkLimits } from './health/health.js';
17
+ export { compareHealth } from './health/compare.js';
18
+ export { HealthLimitsError } from './health/types.js';
19
+ export type * from './health/types.js';
20
+ export type { LanguagePack, ParsedFile, ParseInput, RawImport, ResolveInput, Resolution, ProjectView } from './packs/pack.js';
21
+ export { ParseError } from './packs/pack.js';
22
+ export { GENERATOR_VERSION, SCHEMA_VERSION, OUTPUT_FILES } from './version.js';
23
+ export type * from './model.js';
@@ -0,0 +1,20 @@
1
+ /** The library API: the same functions the `faber-atlas` command runs. */
2
+ export { scan } from './scan/scan.js';
3
+ export { renderMap, isTestFile } from './queries/map.js';
4
+ export { flow, impact, renderFlow, UnknownSymbolError } from './queries/flow.js';
5
+ export { inferFileRoles, ROLE_TAGS } from './scan/roles.js';
6
+ export { neighborhood, UnknownFileError } from './queries/neighborhood.js';
7
+ export { rankHubs as hubs } from './graph/topology.js';
8
+ export { ensureFreshIndex, McpHandler, MCP_TOOLS, serveMcp } from './mcp/server.js';
9
+ export { planOrApplyInit, formatInitPlan, detectTargetEngines } from './init/init.js';
10
+ export { readCurrentScoutConfigs, setScoutConfig, formatScoutStatus, discoverLiveAgyModels, CLAUDE_SCOUT_TIERS, ANTIGRAVITY_SCOUT_TIERS, } from './init/scout.js';
11
+ export { computeStats, formatStats, formatShareCard } from './metrics/stats.js';
12
+ export { runDoctor, formatDoctor } from './metrics/doctor.js';
13
+ export { readMetrics } from './metrics/log.js';
14
+ export { readCodeMap, readTopology, OutputMissingError, OutputVersionError } from './outputs.js';
15
+ export { PACKS } from '../packs/index.js';
16
+ export { health, checkLimits } from './health/health.js';
17
+ export { compareHealth } from './health/compare.js';
18
+ export { HealthLimitsError } from './health/types.js';
19
+ export { ParseError } from './packs/pack.js';
20
+ export { GENERATOR_VERSION, SCHEMA_VERSION, OUTPUT_FILES } from './version.js';
@@ -0,0 +1,73 @@
1
+ import { type EffortLevel } from './scout.js';
2
+ export declare const BLOCK_START = "<!-- faber-atlas:start -->";
3
+ export declare const BLOCK_END = "<!-- faber-atlas:end -->";
4
+ export type EngineName = 'claude-code' | 'claude-desktop' | 'antigravity' | 'cursor' | 'codex';
5
+ export interface EngineSpec {
6
+ name: EngineName;
7
+ gap: boolean;
8
+ /** The tool's one MCP config file, shared by every project. */
9
+ mcpConfigFile?: (userHome: string) => string;
10
+ /**
11
+ * Claude Desktop has no project folder, so its entry needs `--root`. Every other tool starts the server in the
12
+ * project the user has open, and the server finds the project itself (02/AC-18).
13
+ */
14
+ needsRoot?: boolean;
15
+ }
16
+ export interface FilePlan {
17
+ filePath: string;
18
+ kind: 'mcp-config' | 'agents-md' | 'scout-agent' | 'scout-rules';
19
+ engine: EngineName | 'project';
20
+ before: string | null;
21
+ after: string;
22
+ changed: boolean;
23
+ deleted?: boolean;
24
+ backupPath?: string;
25
+ }
26
+ export interface InitOptions {
27
+ /** Only for Claude Desktop (which has no project folder) and `--agents-md`; default: the current folder. */
28
+ root?: string;
29
+ /** Preview changes without writing files (default: false — init applies directly). */
30
+ preview?: boolean;
31
+ /** Backwards-compatible alias; ignored when preview is true. */
32
+ apply?: boolean;
33
+ undo?: boolean;
34
+ engines?: EngineName[];
35
+ /** Include optional general AGENTS.md navigation block. */
36
+ agentsMd?: boolean;
37
+ /** Install default Scout subagent/instructions for supported engines (default: true). */
38
+ scout?: boolean;
39
+ /** Override default Scout model alias. */
40
+ scoutModel?: string;
41
+ /** Override default Scout effort for engines that support it (default: low). */
42
+ scoutEffort?: EffortLevel;
43
+ userHome?: string;
44
+ }
45
+ export interface InitResult {
46
+ root: string;
47
+ applied: boolean;
48
+ preview: boolean;
49
+ undo: boolean;
50
+ plans: FilePlan[];
51
+ backups: string[];
52
+ notes: string[];
53
+ }
54
+ export declare function getEngineSpecs(): Record<EngineName, EngineSpec>;
55
+ export declare function detectTargetEngines(userHome: string, requested?: EngineName[]): EngineName[];
56
+ export declare function renderAgentsBlock(): string;
57
+ export declare function upsertManagedBlock(existing: string, block: string): string;
58
+ export declare function removeManagedBlock(existing: string): string;
59
+ type JsonObject = Record<string, unknown>;
60
+ /** Parses a config file; `null` when it is not a JSON object (comments, a half-written file), so it is never rewritten. */
61
+ export declare function parseConfig(raw: string | null): JsonObject | null;
62
+ /** The project root an existing `faber-atlas` entry is pinned to, if any. */
63
+ export declare function entryRoot(entry: unknown): string | undefined;
64
+ export declare function atlasEntry(engine: EngineSpec, root: string): JsonObject;
65
+ /** Backups get Atlas's own suffix, so they never collide with another tool's `.bak`, and keep the original's permissions. */
66
+ export declare const BACKUP_SUFFIX = ".faber-atlas.bak";
67
+ /**
68
+ * One-time setup (FR-01): every tool gets one global entry, the Scout goes to the user's own folders, and nothing is
69
+ * written into a project unless `--agents-md` asks for it. Running it again in any folder changes nothing.
70
+ */
71
+ export declare function planOrApplyInit(options?: InitOptions): InitResult;
72
+ export declare function formatInitPlan(result: InitResult): string;
73
+ export {};