@smeltjs/core 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 (199) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +55 -0
  3. package/THIRD-PARTY.md +140 -0
  4. package/dist/apply.d.ts +145 -0
  5. package/dist/apply.d.ts.map +1 -0
  6. package/dist/apply.js +244 -0
  7. package/dist/apply.js.map +1 -0
  8. package/dist/cache/prefix.d.ts +164 -0
  9. package/dist/cache/prefix.d.ts.map +1 -0
  10. package/dist/cache/prefix.js +361 -0
  11. package/dist/cache/prefix.js.map +1 -0
  12. package/dist/cli/args.d.ts +71 -0
  13. package/dist/cli/args.d.ts.map +1 -0
  14. package/dist/cli/args.js +308 -0
  15. package/dist/cli/args.js.map +1 -0
  16. package/dist/cli/bin.d.ts +3 -0
  17. package/dist/cli/bin.d.ts.map +1 -0
  18. package/dist/cli/bin.js +161 -0
  19. package/dist/cli/bin.js.map +1 -0
  20. package/dist/cli/config.d.ts +73 -0
  21. package/dist/cli/config.d.ts.map +1 -0
  22. package/dist/cli/config.js +144 -0
  23. package/dist/cli/config.js.map +1 -0
  24. package/dist/cli/init.d.ts +56 -0
  25. package/dist/cli/init.d.ts.map +1 -0
  26. package/dist/cli/init.js +449 -0
  27. package/dist/cli/init.js.map +1 -0
  28. package/dist/cli/report.d.ts +44 -0
  29. package/dist/cli/report.d.ts.map +1 -0
  30. package/dist/cli/report.js +113 -0
  31. package/dist/cli/report.js.map +1 -0
  32. package/dist/cli/resolve.d.ts +103 -0
  33. package/dist/cli/resolve.d.ts.map +1 -0
  34. package/dist/cli/resolve.js +106 -0
  35. package/dist/cli/resolve.js.map +1 -0
  36. package/dist/cli/run.d.ts +99 -0
  37. package/dist/cli/run.d.ts.map +1 -0
  38. package/dist/cli/run.js +351 -0
  39. package/dist/cli/run.js.map +1 -0
  40. package/dist/detect.d.ts +16 -0
  41. package/dist/detect.d.ts.map +1 -0
  42. package/dist/detect.js +18 -0
  43. package/dist/detect.js.map +1 -0
  44. package/dist/errors.d.ts +88 -0
  45. package/dist/errors.d.ts.map +1 -0
  46. package/dist/errors.js +107 -0
  47. package/dist/errors.js.map +1 -0
  48. package/dist/hash.d.ts +13 -0
  49. package/dist/hash.d.ts.map +1 -0
  50. package/dist/hash.js +16 -0
  51. package/dist/hash.js.map +1 -0
  52. package/dist/index.d.ts +121 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/dist/index.js +93 -0
  55. package/dist/index.js.map +1 -0
  56. package/dist/lang/bash.d.ts +3 -0
  57. package/dist/lang/bash.d.ts.map +1 -0
  58. package/dist/lang/bash.js +28 -0
  59. package/dist/lang/bash.js.map +1 -0
  60. package/dist/lang/c.d.ts +3 -0
  61. package/dist/lang/c.d.ts.map +1 -0
  62. package/dist/lang/c.js +39 -0
  63. package/dist/lang/c.js.map +1 -0
  64. package/dist/lang/c_sharp.d.ts +3 -0
  65. package/dist/lang/c_sharp.d.ts.map +1 -0
  66. package/dist/lang/c_sharp.js +37 -0
  67. package/dist/lang/c_sharp.js.map +1 -0
  68. package/dist/lang/cpp.d.ts +3 -0
  69. package/dist/lang/cpp.d.ts.map +1 -0
  70. package/dist/lang/cpp.js +46 -0
  71. package/dist/lang/cpp.js.map +1 -0
  72. package/dist/lang/go.d.ts +3 -0
  73. package/dist/lang/go.d.ts.map +1 -0
  74. package/dist/lang/go.js +31 -0
  75. package/dist/lang/go.js.map +1 -0
  76. package/dist/lang/java.d.ts +3 -0
  77. package/dist/lang/java.d.ts.map +1 -0
  78. package/dist/lang/java.js +34 -0
  79. package/dist/lang/java.js.map +1 -0
  80. package/dist/lang/javascript.d.ts +3 -0
  81. package/dist/lang/javascript.d.ts.map +1 -0
  82. package/dist/lang/javascript.js +28 -0
  83. package/dist/lang/javascript.js.map +1 -0
  84. package/dist/lang/kotlin.d.ts +3 -0
  85. package/dist/lang/kotlin.d.ts.map +1 -0
  86. package/dist/lang/kotlin.js +37 -0
  87. package/dist/lang/kotlin.js.map +1 -0
  88. package/dist/lang/php.d.ts +3 -0
  89. package/dist/lang/php.d.ts.map +1 -0
  90. package/dist/lang/php.js +37 -0
  91. package/dist/lang/php.js.map +1 -0
  92. package/dist/lang/profile.d.ts +130 -0
  93. package/dist/lang/profile.d.ts.map +1 -0
  94. package/dist/lang/profile.js +2 -0
  95. package/dist/lang/profile.js.map +1 -0
  96. package/dist/lang/python.d.ts +3 -0
  97. package/dist/lang/python.d.ts.map +1 -0
  98. package/dist/lang/python.js +33 -0
  99. package/dist/lang/python.js.map +1 -0
  100. package/dist/lang/registry.d.ts +31 -0
  101. package/dist/lang/registry.d.ts.map +1 -0
  102. package/dist/lang/registry.js +89 -0
  103. package/dist/lang/registry.js.map +1 -0
  104. package/dist/lang/ruby.d.ts +3 -0
  105. package/dist/lang/ruby.d.ts.map +1 -0
  106. package/dist/lang/ruby.js +47 -0
  107. package/dist/lang/ruby.js.map +1 -0
  108. package/dist/lang/rust.d.ts +3 -0
  109. package/dist/lang/rust.d.ts.map +1 -0
  110. package/dist/lang/rust.js +45 -0
  111. package/dist/lang/rust.js.map +1 -0
  112. package/dist/lang/swift.d.ts +3 -0
  113. package/dist/lang/swift.d.ts.map +1 -0
  114. package/dist/lang/swift.js +34 -0
  115. package/dist/lang/swift.js.map +1 -0
  116. package/dist/lang/tsx.d.ts +4 -0
  117. package/dist/lang/tsx.d.ts.map +1 -0
  118. package/dist/lang/tsx.js +11 -0
  119. package/dist/lang/tsx.js.map +1 -0
  120. package/dist/lang/typescript.d.ts +18 -0
  121. package/dist/lang/typescript.d.ts.map +1 -0
  122. package/dist/lang/typescript.js +61 -0
  123. package/dist/lang/typescript.js.map +1 -0
  124. package/dist/net/policy.d.ts +49 -0
  125. package/dist/net/policy.d.ts.map +1 -0
  126. package/dist/net/policy.js +120 -0
  127. package/dist/net/policy.js.map +1 -0
  128. package/dist/plan/grammar.d.ts +38 -0
  129. package/dist/plan/grammar.d.ts.map +1 -0
  130. package/dist/plan/grammar.js +85 -0
  131. package/dist/plan/grammar.js.map +1 -0
  132. package/dist/plan/lexical.d.ts +51 -0
  133. package/dist/plan/lexical.d.ts.map +1 -0
  134. package/dist/plan/lexical.js +167 -0
  135. package/dist/plan/lexical.js.map +1 -0
  136. package/dist/plan/planners.d.ts +35 -0
  137. package/dist/plan/planners.d.ts.map +1 -0
  138. package/dist/plan/planners.js +26 -0
  139. package/dist/plan/planners.js.map +1 -0
  140. package/dist/plan/structural.d.ts +68 -0
  141. package/dist/plan/structural.d.ts.map +1 -0
  142. package/dist/plan/structural.js +458 -0
  143. package/dist/plan/structural.js.map +1 -0
  144. package/dist/repomap/cache.d.ts +53 -0
  145. package/dist/repomap/cache.d.ts.map +1 -0
  146. package/dist/repomap/cache.js +139 -0
  147. package/dist/repomap/cache.js.map +1 -0
  148. package/dist/repomap/map.d.ts +161 -0
  149. package/dist/repomap/map.d.ts.map +1 -0
  150. package/dist/repomap/map.js +302 -0
  151. package/dist/repomap/map.js.map +1 -0
  152. package/dist/repomap/rank.d.ts +52 -0
  153. package/dist/repomap/rank.d.ts.map +1 -0
  154. package/dist/repomap/rank.js +155 -0
  155. package/dist/repomap/rank.js.map +1 -0
  156. package/dist/repomap/tags.d.ts +47 -0
  157. package/dist/repomap/tags.d.ts.map +1 -0
  158. package/dist/repomap/tags.js +101 -0
  159. package/dist/repomap/tags.js.map +1 -0
  160. package/dist/retrieve.d.ts +14 -0
  161. package/dist/retrieve.d.ts.map +1 -0
  162. package/dist/retrieve.js +44 -0
  163. package/dist/retrieve.js.map +1 -0
  164. package/dist/stages.d.ts +22 -0
  165. package/dist/stages.d.ts.map +1 -0
  166. package/dist/stages.js +33 -0
  167. package/dist/stages.js.map +1 -0
  168. package/dist/stats.d.ts +40 -0
  169. package/dist/stats.d.ts.map +1 -0
  170. package/dist/stats.js +37 -0
  171. package/dist/stats.js.map +1 -0
  172. package/dist/store-dir.d.ts +98 -0
  173. package/dist/store-dir.d.ts.map +1 -0
  174. package/dist/store-dir.js +379 -0
  175. package/dist/store-dir.js.map +1 -0
  176. package/dist/store.d.ts +36 -0
  177. package/dist/store.d.ts.map +1 -0
  178. package/dist/store.js +56 -0
  179. package/dist/store.js.map +1 -0
  180. package/dist/types.d.ts +298 -0
  181. package/dist/types.d.ts.map +1 -0
  182. package/dist/types.js +2 -0
  183. package/dist/types.js.map +1 -0
  184. package/grammars/tree-sitter-bash.wasm +0 -0
  185. package/grammars/tree-sitter-c.wasm +0 -0
  186. package/grammars/tree-sitter-c_sharp.wasm +0 -0
  187. package/grammars/tree-sitter-cpp.wasm +0 -0
  188. package/grammars/tree-sitter-go.wasm +0 -0
  189. package/grammars/tree-sitter-java.wasm +0 -0
  190. package/grammars/tree-sitter-javascript.wasm +0 -0
  191. package/grammars/tree-sitter-kotlin.wasm +0 -0
  192. package/grammars/tree-sitter-php.wasm +0 -0
  193. package/grammars/tree-sitter-python.wasm +0 -0
  194. package/grammars/tree-sitter-ruby.wasm +0 -0
  195. package/grammars/tree-sitter-rust.wasm +0 -0
  196. package/grammars/tree-sitter-swift.wasm +0 -0
  197. package/grammars/tree-sitter-tsx.wasm +0 -0
  198. package/grammars/tree-sitter-typescript.wasm +0 -0
  199. package/package.json +68 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,M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AmF;AACnF,sFAAsF;AACtF,sFAAsF;AACtF,gCAAgC;AAChC,8EAA8E;AAE9E,kFAAkF;AAClF,MAAM,UAAU,iBAAiB;IAC/B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BR,CAAC;AACF,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,gBAAgB;IAC9B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DR,CAAC;AACF,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { RepoMap } from '../repomap/map.ts';
2
+ import type { SmeltResult } from '../types.ts';
3
+ export interface ReportInput {
4
+ readonly result: SmeltResult;
5
+ /** What to call the input in the header: a path, or `'<stdin>'`. */
6
+ readonly source: string;
7
+ /** The budget the caller asked for, so the report can say when it was missed. */
8
+ readonly budgetBytes: number;
9
+ /** The exact text that was smelted. Used only to count lines inside each range. */
10
+ readonly inputText: string;
11
+ }
12
+ /**
13
+ * The report, for stderr.
14
+ *
15
+ * Every total here is read straight off the {@link SmeltResult} — `inputBytes`,
16
+ * `outputBytes`, `elisions.length`. The CLI keeps no counters of its own, because two
17
+ * pieces of code counting the same bytes is how a report ends up disagreeing with the
18
+ * library it is reporting on, and the report is the thing a human believes.
19
+ * `test/cli.test.ts` asserts the printed numbers equal the result's fields.
20
+ */
21
+ export declare function formatReport({ result, source, budgetBytes, inputText }: ReportInput): string;
22
+ /** What `smelt map` prints to stderr. */
23
+ export interface MapReportInput {
24
+ readonly map: RepoMap;
25
+ /** The directory named on the command line, exactly as the user wrote it. */
26
+ readonly source: string;
27
+ /**
28
+ * Where the budget came from — the `ResolvedMapRun.budgetSource` receipt, printed
29
+ * beside the budget so a surprising number can be traced to the flag or the config
30
+ * file that set it without re-deriving the precedence by hand.
31
+ */
32
+ readonly budgetSource: 'flag' | 'config';
33
+ }
34
+ /**
35
+ * The map report, for stderr — same law as {@link formatReport}: every number is
36
+ * read straight off the {@link RepoMap} the library returned. In particular the
37
+ * "bytes used" figure is `map.outputBytes`, which the library measured off the
38
+ * rendered text — the CLI counts nothing itself, because a report that keeps its
39
+ * own tally is a report that can disagree with the map it describes.
40
+ * `test/guards/repo-map.test.ts` asserts the printed figure equals the actual byte
41
+ * length of what landed on stdout, and a mutation proves the assertion can go red.
42
+ */
43
+ export declare function formatMapReport({ map, source, budgetSource }: MapReportInput): string;
44
+ //# sourceMappingURL=report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/cli/report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,iFAAiF;IACjF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,mFAAmF;IACnF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAKD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,WAAW,GAAG,MAAM,CAsE5F;AAED,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,CAAC;CAC1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,cAAc,GAAG,MAAM,CA+BrF"}
@@ -0,0 +1,113 @@
1
+ import { CLI_NAME } from './args.js';
2
+ /** Longest explanation printed in full before it gets an ellipsis. */
3
+ const EXPLANATION_WIDTH = 46;
4
+ /**
5
+ * The report, for stderr.
6
+ *
7
+ * Every total here is read straight off the {@link SmeltResult} — `inputBytes`,
8
+ * `outputBytes`, `elisions.length`. The CLI keeps no counters of its own, because two
9
+ * pieces of code counting the same bytes is how a report ends up disagreeing with the
10
+ * library it is reporting on, and the report is the thing a human believes.
11
+ * `test/cli.test.ts` asserts the printed numbers equal the result's fields.
12
+ */
13
+ export function formatReport({ result, source, budgetBytes, inputText }) {
14
+ const lines = [];
15
+ lines.push([CLI_NAME, source, result.language, result.planner].join(' '));
16
+ lines.push(`in ${group(result.inputBytes)} B → out ${group(result.outputBytes)} B ` +
17
+ `(${delta(result.inputBytes, result.outputBytes)}, ${count(result.elisions.length, 'elision')})`);
18
+ if (result.measured !== undefined) {
19
+ const { input, output, unit, measure } = result.measured;
20
+ lines.push(`in ${group(input)} → out ${group(output)} ${unit} (${measure})`);
21
+ }
22
+ if (result.outputBytes > budgetBytes) {
23
+ lines.push('');
24
+ lines.push(`OVER BUDGET ${group(result.outputBytes)} B against a ${group(budgetBytes)} B budget ` +
25
+ `— over by ${group(result.outputBytes - budgetBytes)} B.`);
26
+ lines.push(' The plan is reported as it came back. smelt did not cut the regions');
27
+ lines.push(' you asked to keep in order to make a number look right.');
28
+ }
29
+ if (result.elisions.length === 0) {
30
+ lines.push('');
31
+ lines.push(' nothing elided — the input already fits, or every run was too small to');
32
+ lines.push(' be worth a marker (a marker that costs more than the lines it replaces');
33
+ lines.push(' makes the output bigger).');
34
+ return `${lines.join('\n')}\n`;
35
+ }
36
+ const rows = result.elisions.map((elision) => ({
37
+ rule: elision.reason.rule,
38
+ lines: String(lineSpan(inputText, elision.range.start, elision.range.end)),
39
+ bytes: group(elision.bytes),
40
+ hash: elision.hash,
41
+ explanation: clip(elision.reason.explanation, EXPLANATION_WIDTH),
42
+ }));
43
+ const ruleWidth = width('rule', rows.map((row) => row.rule));
44
+ const linesWidth = width('lines', rows.map((row) => row.lines));
45
+ const bytesWidth = width('bytes', rows.map((row) => row.bytes));
46
+ const hashWidth = width('hash', rows.map((row) => row.hash));
47
+ lines.push('');
48
+ lines.push(` ${'rule'.padEnd(ruleWidth)} ${'lines'.padStart(linesWidth)} ` +
49
+ `${'bytes'.padStart(bytesWidth)} ${'hash'.padEnd(hashWidth)} explanation`);
50
+ for (const row of rows) {
51
+ lines.push(` ${row.rule.padEnd(ruleWidth)} ${row.lines.padStart(linesWidth)} ` +
52
+ `${row.bytes.padStart(bytesWidth)} ${row.hash.padEnd(hashWidth)} ${row.explanation}`);
53
+ }
54
+ return `${lines.join('\n')}\n`;
55
+ }
56
+ /**
57
+ * The map report, for stderr — same law as {@link formatReport}: every number is
58
+ * read straight off the {@link RepoMap} the library returned. In particular the
59
+ * "bytes used" figure is `map.outputBytes`, which the library measured off the
60
+ * rendered text — the CLI counts nothing itself, because a report that keeps its
61
+ * own tally is a report that can disagree with the map it describes.
62
+ * `test/guards/repo-map.test.ts` asserts the printed figure equals the actual byte
63
+ * length of what landed on stdout, and a mutation proves the assertion can go red.
64
+ */
65
+ export function formatMapReport({ map, source, budgetSource }) {
66
+ const lines = [];
67
+ lines.push([`${CLI_NAME} map`, source, map.id].join(' '));
68
+ lines.push(`files scanned ${group(map.filesScanned)}` +
69
+ (map.binarySkipped === 0 ? '' : ` (${count(map.binarySkipped, 'binary file')} skipped)`) +
70
+ ` symbols ranked ${group(map.definitionsTotal)}`);
71
+ lines.push(`included ${group(map.entries.length)} of ${group(map.definitionsTotal)} symbols` +
72
+ (map.pathOnlyTotal === 0
73
+ ? ''
74
+ : ` + ${group(map.pathOnly.length)} of ${group(map.pathOnlyTotal)} path-only files`));
75
+ lines.push(`bytes used ${group(map.outputBytes)} of ${group(map.budgetBytes)} budget (${budgetSource}) ` +
76
+ `— the map fits itself to the budget by construction, so there is no over-budget exit`);
77
+ if (map.cache !== undefined) {
78
+ lines.push(`cache ${count(map.cache.hits, 'hit')}, ${count(map.cache.misses, 'miss', 'es')}, ` +
79
+ `${group(map.cache.discarded)} discarded`);
80
+ }
81
+ for (const warning of map.warnings) {
82
+ lines.push(`warning ${warning.rule}: ${warning.explanation}`);
83
+ }
84
+ return `${lines.join('\n')}\n`;
85
+ }
86
+ /** How many lines a byte range covers in the input. Derived, never tallied separately. */
87
+ function lineSpan(text, start, end) {
88
+ const slice = Buffer.from(text, 'utf8').subarray(start, end).toString('utf8');
89
+ return slice.split('\n').length;
90
+ }
91
+ function width(header, values) {
92
+ return values.reduce((widest, value) => Math.max(widest, value.length), header.length);
93
+ }
94
+ /** Thousands separators without pulling in ICU, so the output is identical everywhere. */
95
+ function group(n) {
96
+ const digits = String(Math.abs(Math.trunc(n)));
97
+ const grouped = digits.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
98
+ return n < 0 ? `-${grouped}` : grouped;
99
+ }
100
+ function delta(inputBytes, outputBytes) {
101
+ if (inputBytes === 0)
102
+ return 'empty input';
103
+ const percent = ((outputBytes - inputBytes) / inputBytes) * 100;
104
+ const sign = percent > 0 ? '+' : '';
105
+ return `${sign}${percent.toFixed(1)}%`;
106
+ }
107
+ function count(n, noun, pluralSuffix = 's') {
108
+ return `${group(n)} ${noun}${n === 1 ? '' : pluralSuffix}`;
109
+ }
110
+ function clip(text, max) {
111
+ return text.length <= max ? text : `${text.slice(0, max - 1)}…`;
112
+ }
113
+ //# sourceMappingURL=report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/cli/report.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAYrC,sEAAsE;AACtE,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAe;IAClF,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,K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EAAE,YAAY,GAAG,GAAG;IACxD,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;AAC7D,CAAC;AAED,SAAS,IAAI,CAAC,IAAY,EAAE,GAAW;IACrC,OAAO,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;AAClE,CAAC"}
@@ -0,0 +1,103 @@
1
+ import type { Strategy } from '../plan/planners.ts';
2
+ import type { DetectedLanguage } from '../types.ts';
3
+ import type { MapInvocation, SmeltInvocation } from './args.ts';
4
+ import type { LoadedConfig } from './config.ts';
5
+ /**
6
+ * Everything one smelt run needs, fully merged — with a receipt for where each
7
+ * merged value came from.
8
+ *
9
+ * This is the CLI's single merge of flags + config + built-ins. Precedence lives
10
+ * here and nowhere else: `resolveRun` is the only code that may look at a flag and a
11
+ * config default side by side, so a precedence question is always answered by one
12
+ * function instead of by reading two files. `runSmelt` executes this object
13
+ * straight-line, without a `??` of its own.
14
+ */
15
+ export interface ResolvedRun {
16
+ readonly budgetBytes: number;
17
+ /** Where the budget came from. A missing budget never gets here — it throws. */
18
+ readonly budgetSource: 'flag' | 'config';
19
+ readonly strategy: Strategy;
20
+ readonly strategySource: 'flag' | 'config' | 'builtin';
21
+ /**
22
+ * The store decision, with `path` already resolved against the config file's
23
+ * directory. `'memory'` is the built-in default — a fresh in-memory store per run.
24
+ */
25
+ readonly store: {
26
+ readonly kind: 'memory';
27
+ } | {
28
+ readonly kind: 'directory';
29
+ readonly path: string;
30
+ };
31
+ /** Path to read. `undefined` means stdin. Flags only; the config has no say. */
32
+ readonly file?: string;
33
+ readonly focus: readonly string[];
34
+ readonly language?: DetectedLanguage;
35
+ readonly json: boolean;
36
+ }
37
+ /**
38
+ * Merge one `'smelt'`-mode invocation with the loaded config (or `undefined` when no
39
+ * `smelt.config.json` exists) and the built-in defaults.
40
+ *
41
+ * The precedence is strict and one-directional: an explicit flag always wins over the
42
+ * config, and the config only fills what the flags left unsaid. Built-ins fill last,
43
+ * and only where a built-in exists at all — the budget deliberately has none, so a run
44
+ * with no budget from either source is refused here, in the one module that owns that
45
+ * error.
46
+ *
47
+ * @throws {CliUsageError} when neither `--budget` nor the config names a budget.
48
+ */
49
+ export declare function resolveRun(invocation: SmeltInvocation, config: LoadedConfig | undefined): ResolvedRun;
50
+ /**
51
+ * Everything one `smelt map` run needs, fully merged — {@link ResolvedRun}'s sibling,
52
+ * not a contortion of it. The two commands share exactly one merged value (the
53
+ * budget), so they share the *module* that owns precedence and the budget-required
54
+ * refusal, not a struct whose fields would mostly be lies for one of them: a map has
55
+ * no store, no strategy, no stdin, and its ignore/cache legs mean nothing to a
56
+ * single-blob run.
57
+ */
58
+ export interface ResolvedMapRun {
59
+ readonly budgetBytes: number;
60
+ /** Where the budget came from. A missing budget never gets here — it throws. */
61
+ readonly budgetSource: 'flag' | 'config';
62
+ readonly dir: string;
63
+ readonly focus: readonly string[];
64
+ /** `undefined` means "use the library's default ignore list". Flags only. */
65
+ readonly ignore?: readonly string[];
66
+ /** Only when present does the map write to disk. Flags only; the config has no say. */
67
+ readonly cacheDir?: string;
68
+ readonly json: boolean;
69
+ }
70
+ /**
71
+ * Merge one `'map'`-mode invocation with the loaded config and the built-ins. The
72
+ * config contributes exactly what it contributes to a smelt run — `defaultBudgetBytes`,
73
+ * a default the user chose explicitly — and nothing else: the store and strategy legs
74
+ * are single-blob concerns, and the map ignores them rather than reinterpreting them.
75
+ *
76
+ * @throws {CliUsageError} when neither `--budget` nor the config names a budget.
77
+ */
78
+ export declare function resolveMapRun(invocation: MapInvocation, config: LoadedConfig | undefined): ResolvedMapRun;
79
+ /**
80
+ * Everything `smelt retrieve` and `smelt stats` need, fully merged: the persistent
81
+ * store's directory, already resolved against the config file. A third sibling in
82
+ * this module for the same reason {@link ResolvedMapRun} is one — these commands
83
+ * share the *module* that owns precedence, not a struct: they have no budget, no
84
+ * strategy, no file leg at all, only the store leg, which is config-only.
85
+ */
86
+ export interface ResolvedStoreRun {
87
+ /** Absolute path of the directory store, resolved against the config file. */
88
+ readonly storePath: string;
89
+ }
90
+ /**
91
+ * The store leg alone, for the two commands whose entire job is the store between
92
+ * runs. The refusal is the point: `retrieve` exists so the marker's
93
+ * `retrieve("hash")` works from a later shell — cross-run retrieval — and a memory
94
+ * store dies with the process that filled it, so with a memory store (or no config
95
+ * at all) there is nothing those commands could honestly read. Answering with
96
+ * `UnknownHashError` or all-zero stats instead would be the quiet wrong answer this
97
+ * project refuses everywhere: the hash *was* elided, the counters *did* move — in a
98
+ * store that no longer exists.
99
+ *
100
+ * @throws {CliUsageError} when no config exists, or the configured store is memory.
101
+ */
102
+ export declare function resolveStoreRun(command: 'retrieve' | 'stats', config: LoadedConfig | undefined): ResolvedStoreRun;
103
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/cli/resolve.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,gFAAgF;IAChF,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,G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AAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,UAAU,GAAG,OAAO,EAC7B,MAAM,EAAE,YAAY,GAAG,SAAS,GAC/B,gBAAgB,CAgBlB"}
@@ -0,0 +1,106 @@
1
+ import { CliUsageError } from '../errors.js';
2
+ import { CLI_NAME } from './args.js';
3
+ import { CONFIG_FILE_NAME, resolveStorePath } from './config.js';
4
+ /**
5
+ * Merge one `'smelt'`-mode invocation with the loaded config (or `undefined` when no
6
+ * `smelt.config.json` exists) and the built-in defaults.
7
+ *
8
+ * The precedence is strict and one-directional: an explicit flag always wins over the
9
+ * config, and the config only fills what the flags left unsaid. Built-ins fill last,
10
+ * and only where a built-in exists at all — the budget deliberately has none, so a run
11
+ * with no budget from either source is refused here, in the one module that owns that
12
+ * error.
13
+ *
14
+ * @throws {CliUsageError} when neither `--budget` nor the config names a budget.
15
+ */
16
+ export function resolveRun(invocation, config) {
17
+ const budgetBytes = invocation.budgetBytes ?? config?.config.defaultBudgetBytes;
18
+ if (budgetBytes === undefined) {
19
+ throw new CliUsageError(`${CLI_NAME}: --budget is required, in UTF-8 bytes. There is no default, because ` +
20
+ `a budget smelt invented would silently decide how much of your context to ` +
21
+ `throw away. Pass --budget, or set defaultBudgetBytes in ${CONFIG_FILE_NAME} ` +
22
+ `(\`${CLI_NAME} init\` writes one).\n` +
23
+ ` ${CLI_NAME} src/server.ts --budget 4000 --focus handleRequest`);
24
+ }
25
+ const strategy = invocation.strategy ?? config?.config.strategy ?? 'lexical';
26
+ return {
27
+ budgetBytes,
28
+ budgetSource: invocation.budgetBytes !== undefined ? 'flag' : 'config',
29
+ strategy,
30
+ strategySource: invocation.strategy !== undefined
31
+ ? 'flag'
32
+ : config?.config.strategy !== undefined
33
+ ? 'config'
34
+ : 'builtin',
35
+ store: resolveStore(config),
36
+ ...(invocation.file === undefined ? {} : { file: invocation.file }),
37
+ focus: invocation.focus,
38
+ ...(invocation.language === undefined ? {} : { language: invocation.language }),
39
+ json: invocation.json,
40
+ };
41
+ }
42
+ /**
43
+ * The store the config asks for, with `path` resolved relative to the config file —
44
+ * one config serves every subdirectory it covers without scattering store roots.
45
+ * There is no store flag, so this leg of the merge is config-or-built-in only.
46
+ */
47
+ function resolveStore(config) {
48
+ if (config?.config.store === undefined || config.config.store.kind === 'memory') {
49
+ return { kind: 'memory' };
50
+ }
51
+ return { kind: 'directory', path: resolveStorePath(config, config.config.store.path) };
52
+ }
53
+ /**
54
+ * Merge one `'map'`-mode invocation with the loaded config and the built-ins. The
55
+ * config contributes exactly what it contributes to a smelt run — `defaultBudgetBytes`,
56
+ * a default the user chose explicitly — and nothing else: the store and strategy legs
57
+ * are single-blob concerns, and the map ignores them rather than reinterpreting them.
58
+ *
59
+ * @throws {CliUsageError} when neither `--budget` nor the config names a budget.
60
+ */
61
+ export function resolveMapRun(invocation, config) {
62
+ const budgetBytes = invocation.budgetBytes ?? config?.config.defaultBudgetBytes;
63
+ if (budgetBytes === undefined) {
64
+ throw new CliUsageError(`${CLI_NAME}: --budget is required, in UTF-8 bytes. There is no default, because ` +
65
+ `a budget ${CLI_NAME} invented would silently decide how much of the map to ` +
66
+ `leave out. Pass --budget, or set defaultBudgetBytes in ${CONFIG_FILE_NAME} ` +
67
+ `(\`${CLI_NAME} init\` writes one).\n` +
68
+ ` ${CLI_NAME} map src --budget 4000 --focus handleRequest`);
69
+ }
70
+ return {
71
+ budgetBytes,
72
+ budgetSource: invocation.budgetBytes !== undefined ? 'flag' : 'config',
73
+ dir: invocation.dir,
74
+ focus: invocation.focus,
75
+ ...(invocation.ignore.length === 0 ? {} : { ignore: invocation.ignore }),
76
+ ...(invocation.cacheDir === undefined ? {} : { cacheDir: invocation.cacheDir }),
77
+ json: invocation.json,
78
+ };
79
+ }
80
+ /**
81
+ * The store leg alone, for the two commands whose entire job is the store between
82
+ * runs. The refusal is the point: `retrieve` exists so the marker's
83
+ * `retrieve("hash")` works from a later shell — cross-run retrieval — and a memory
84
+ * store dies with the process that filled it, so with a memory store (or no config
85
+ * at all) there is nothing those commands could honestly read. Answering with
86
+ * `UnknownHashError` or all-zero stats instead would be the quiet wrong answer this
87
+ * project refuses everywhere: the hash *was* elided, the counters *did* move — in a
88
+ * store that no longer exists.
89
+ *
90
+ * @throws {CliUsageError} when no config exists, or the configured store is memory.
91
+ */
92
+ export function resolveStoreRun(command, config) {
93
+ const store = resolveStore(config);
94
+ if (store.kind !== 'directory') {
95
+ const state = config === undefined
96
+ ? `there is no ${CONFIG_FILE_NAME} here`
97
+ : `the ${CONFIG_FILE_NAME} at ${config.path} uses a memory store`;
98
+ throw new CliUsageError(`${CLI_NAME}: ${command} needs a persistent store, and ${state}. Cross-run ` +
99
+ `retrieval is the point of the store: a memory store dies with the process ` +
100
+ `that made it, so a marker's hash from an earlier run names bytes this run ` +
101
+ `never held. Configure {"store": {"kind": "directory", "path": …}} in ` +
102
+ `${CONFIG_FILE_NAME} — \`${CLI_NAME} init\` writes one.`);
103
+ }
104
+ return { storePath: store.path };
105
+ }
106
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/cli/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAgCjE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CACxB,UAA2B,EAC3B,MAAgC;IAEhC,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,IAAI,MAAM,EAAE,MAAM,CAAC,kBAAkB,CAAC;IAChF,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,aAAa,CACrB,GAAG,QAAQ,uEAAuE;YAChF,4EAA4E;YAC5E,2DAA2D,gBAAgB,G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AK,SAAS;YAClB,CAAC,CAAC,eAAe,gBAAgB,OAAO;YACxC,CAAC,CAAC,OAAO,gBAAgB,OAAO,MAAM,CAAC,IAAI,sBAAsB,CAAC;QACtE,MAAM,IAAI,aAAa,CACrB,GAAG,QAAQ,KAAK,OAAO,kCAAkC,KAAK,cAAc;YAC1E,4EAA4E;YAC5E,4EAA4E;YAC5E,uEAAuE;YACvE,GAAG,gBAAgB,QAAQ,QAAQ,qBAAqB,CAC3D,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,99 @@
1
+ import type { RepoMap } from '../repomap/map.ts';
2
+ import type { RetrieveStats, SmeltResult } from '../types.ts';
3
+ export { CLI_NAME, cliUsage, parseSmeltArgs } from './args.ts';
4
+ export type { CliInvocation, MapInvocation, RetrieveInvocation, SmeltInvocation, StatsInvocation, } from './args.ts';
5
+ export { formatMapReport, formatReport } from './report.ts';
6
+ export type { MapReportInput, ReportInput } from './report.ts';
7
+ export { resolveMapRun, resolveRun, resolveStoreRun } from './resolve.ts';
8
+ export type { ResolvedMapRun, ResolvedRun, ResolvedStoreRun } from './resolve.ts';
9
+ /**
10
+ * Exit codes, and why there are five of them.
11
+ *
12
+ * A CLI that returns 0 whatever happens is the shell-level version of a stub that
13
+ * returns `[]`: the caller cannot tell success from failure, so a pipeline built on it
14
+ * fails silently. **`overBudget` is the load-bearing one.** A plan that did not fit is
15
+ * not an error — smelt refused to cut the regions the caller asked to keep, which is
16
+ * correct — but it is also not success, and a script must be able to see the
17
+ * difference without parsing prose.
18
+ */
19
+ export declare const EXIT: {
20
+ readonly ok: 0;
21
+ readonly overBudget: 1;
22
+ readonly usage: 2;
23
+ readonly refused: 3;
24
+ readonly unexpected: 4;
25
+ };
26
+ /**
27
+ * The `--json` envelope format, versioned like the marker for the same reason: this is
28
+ * a surface other programs parse, so a change to it has to be identifiable rather than
29
+ * silent.
30
+ */
31
+ export declare const CLI_JSON_FORMAT = "smelt-cli/v1";
32
+ /**
33
+ * The `smelt map --json` envelope format. Its own version line, because the two
34
+ * envelopes carry different structures and must be able to move independently —
35
+ * a map envelope has no elided bytes to carry, since a map elides nothing.
36
+ */
37
+ export declare const CLI_MAP_JSON_FORMAT = "smelt-map-cli/v1";
38
+ /**
39
+ * The `smelt stats --json` envelope format. Its own version line for the same reason
40
+ * `smelt map` has one: the two envelopes carry different structures and must move
41
+ * independently.
42
+ */
43
+ export declare const CLI_STATS_JSON_FORMAT = "smelt-stats-cli/v1";
44
+ /** What `smelt stats --json` prints: the {@link RetrieveStats} verbatim, versioned. */
45
+ export interface CliStatsJsonEnvelope {
46
+ readonly format: string;
47
+ /** The {@link RetrieveStats} exactly as the store's `stats()` returned them. */
48
+ readonly stats: RetrieveStats;
49
+ }
50
+ /** What `smelt map --json` prints: the {@link RepoMap} verbatim, versioned. */
51
+ export interface CliMapJsonEnvelope {
52
+ readonly format: string;
53
+ /** The {@link RepoMap} exactly as `buildRepoMap` returned it. */
54
+ readonly map: RepoMap;
55
+ }
56
+ /**
57
+ * What `--json` prints, and what `--reconstruct` reads back.
58
+ *
59
+ * `result` is the {@link SmeltResult} **verbatim** — nothing renamed, nothing dropped —
60
+ * so it can be diffed in a test. `elided` is the other half, and it is here because a
61
+ * result on its own is *not* reconstructible: Law 3 is a property of the result plus
62
+ * the store that holds its bytes, and a file claiming to prove the round trip while
63
+ * carrying only half of it would prove nothing.
64
+ */
65
+ export interface CliJsonEnvelope {
66
+ readonly format: string;
67
+ readonly result: SmeltResult;
68
+ /** hash → the exact elided bytes. Keys match `result.elisions[].hash`. */
69
+ readonly elided: Readonly<Record<string, string>>;
70
+ }
71
+ /** Where the CLI's bytes come from and go. Injected so `runCli` is testable in-process. */
72
+ export interface CliIo {
73
+ readonly stdout: (text: string) => void;
74
+ readonly stderr: (text: string) => void;
75
+ /** All of stdin, as UTF-8. @throws {CliUsageError} when nothing is piped. */
76
+ readonly stdin: () => string;
77
+ /** The package version, for `--version`. */
78
+ readonly version: string;
79
+ /**
80
+ * Where `smelt.config.json` discovery starts, and where `init` writes. Defaults to
81
+ * the process working directory; tests pass a temp directory to stay hermetic.
82
+ */
83
+ readonly cwd?: string;
84
+ /**
85
+ * Interactive input for `smelt init` — the wizard reads answers line by line, which
86
+ * the one-shot `stdin()` above cannot provide. `bin.ts` passes the real stdin
87
+ * stream; tests pass a scripted one. Absent means `init` is a usage error.
88
+ */
89
+ readonly initInput?: NodeJS.ReadableStream;
90
+ }
91
+ /**
92
+ * The whole CLI, as a function that returns an exit code instead of calling `exit`.
93
+ *
94
+ * Smelted text goes to stdout and the report goes to stderr, so `smelt big.log
95
+ * --budget 4000 > small.log` leaves the human-readable part on the terminal and the
96
+ * payload in the file.
97
+ */
98
+ export declare function runCli(argv: readonly string[], io: CliIo): Promise<number>;
99
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,KAAK,EAAgB,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAe5E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC/D,YAAY,EACV,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,eAAe,GAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5D,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1E,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAElF;;;;;;;;;GASG;AAC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