@smeltjs/core 0.2.0 → 0.4.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 (348) hide show
  1. package/README.md +3 -3
  2. package/dist/agents/guide.d.ts +68 -0
  3. package/dist/agents/guide.d.ts.map +1 -0
  4. package/dist/agents/guide.js +72 -0
  5. package/dist/agents/guide.js.map +1 -0
  6. package/dist/agents/instructions.d.ts +133 -0
  7. package/dist/agents/instructions.d.ts.map +1 -0
  8. package/dist/agents/instructions.js +212 -0
  9. package/dist/agents/instructions.js.map +1 -0
  10. package/dist/agents/lint.d.ts +154 -0
  11. package/dist/agents/lint.d.ts.map +1 -0
  12. package/dist/agents/lint.js +761 -0
  13. package/dist/agents/lint.js.map +1 -0
  14. package/dist/agents/split.d.ts +113 -0
  15. package/dist/agents/split.d.ts.map +1 -0
  16. package/dist/agents/split.js +234 -0
  17. package/dist/agents/split.js.map +1 -0
  18. package/dist/apply.d.ts.map +1 -1
  19. package/dist/apply.js.map +1 -1
  20. package/dist/cache/prefix.d.ts.map +1 -1
  21. package/dist/cache/prefix.js.map +1 -1
  22. package/dist/cli/agents.d.ts +39 -0
  23. package/dist/cli/agents.d.ts.map +1 -0
  24. package/dist/cli/agents.js +121 -0
  25. package/dist/cli/agents.js.map +1 -0
  26. package/dist/cli/args.d.ts +17 -70
  27. package/dist/cli/args.d.ts.map +1 -1
  28. package/dist/cli/args.js +18 -338
  29. package/dist/cli/args.js.map +1 -1
  30. package/dist/cli/bin.d.ts.map +1 -1
  31. package/dist/cli/bin.js.map +1 -1
  32. package/dist/cli/config.d.ts +60 -0
  33. package/dist/cli/config.d.ts.map +1 -1
  34. package/dist/cli/config.js +89 -2
  35. package/dist/cli/config.js.map +1 -1
  36. package/dist/cli/hooks.d.ts +55 -51
  37. package/dist/cli/hooks.d.ts.map +1 -1
  38. package/dist/cli/hooks.js +206 -658
  39. package/dist/cli/hooks.js.map +1 -1
  40. package/dist/cli/init.d.ts +30 -15
  41. package/dist/cli/init.d.ts.map +1 -1
  42. package/dist/cli/init.js +167 -38
  43. package/dist/cli/init.js.map +1 -1
  44. package/dist/cli/report.d.ts +23 -0
  45. package/dist/cli/report.d.ts.map +1 -1
  46. package/dist/cli/report.js +142 -4
  47. package/dist/cli/report.js.map +1 -1
  48. package/dist/cli/run.d.ts +29 -90
  49. package/dist/cli/run.d.ts.map +1 -1
  50. package/dist/cli/run.js +34 -342
  51. package/dist/cli/run.js.map +1 -1
  52. package/dist/cli/shell.d.ts +106 -0
  53. package/dist/cli/shell.d.ts.map +1 -0
  54. package/dist/cli/shell.js +100 -0
  55. package/dist/cli/shell.js.map +1 -0
  56. package/dist/cli/subcommands/agents.d.ts +72 -0
  57. package/dist/cli/subcommands/agents.d.ts.map +1 -0
  58. package/dist/cli/subcommands/agents.js +162 -0
  59. package/dist/cli/subcommands/agents.js.map +1 -0
  60. package/dist/cli/subcommands/flags.d.ts +144 -0
  61. package/dist/cli/subcommands/flags.d.ts.map +1 -0
  62. package/dist/cli/subcommands/flags.js +220 -0
  63. package/dist/cli/subcommands/flags.js.map +1 -0
  64. package/dist/cli/subcommands/hooks.d.ts +18 -0
  65. package/dist/cli/subcommands/hooks.d.ts.map +1 -0
  66. package/dist/cli/subcommands/hooks.js +80 -0
  67. package/dist/cli/subcommands/hooks.js.map +1 -0
  68. package/dist/cli/subcommands/init.d.ts +19 -0
  69. package/dist/cli/subcommands/init.d.ts.map +1 -0
  70. package/dist/cli/subcommands/init.js +44 -0
  71. package/dist/cli/subcommands/init.js.map +1 -0
  72. package/dist/cli/subcommands/map.d.ts +75 -0
  73. package/dist/cli/subcommands/map.d.ts.map +1 -0
  74. package/dist/cli/subcommands/map.js +132 -0
  75. package/dist/cli/subcommands/map.js.map +1 -0
  76. package/dist/cli/subcommands/registry.d.ts +81 -0
  77. package/dist/cli/subcommands/registry.d.ts.map +1 -0
  78. package/dist/cli/subcommands/registry.js +141 -0
  79. package/dist/cli/subcommands/registry.js.map +1 -0
  80. package/dist/cli/subcommands/retrieve.d.ts +74 -0
  81. package/dist/cli/subcommands/retrieve.d.ts.map +1 -0
  82. package/dist/cli/subcommands/retrieve.js +84 -0
  83. package/dist/cli/subcommands/retrieve.js.map +1 -0
  84. package/dist/cli/subcommands/smelt.d.ts +107 -0
  85. package/dist/cli/subcommands/smelt.d.ts.map +1 -0
  86. package/dist/cli/subcommands/smelt.js +304 -0
  87. package/dist/cli/subcommands/smelt.js.map +1 -0
  88. package/dist/cli/subcommands/stats.d.ts +43 -0
  89. package/dist/cli/subcommands/stats.d.ts.map +1 -0
  90. package/dist/cli/subcommands/stats.js +62 -0
  91. package/dist/cli/subcommands/stats.js.map +1 -0
  92. package/dist/cli/subcommands/subcommand.d.ts +113 -0
  93. package/dist/cli/subcommands/subcommand.d.ts.map +1 -0
  94. package/dist/cli/subcommands/subcommand.js +3 -0
  95. package/dist/cli/subcommands/subcommand.js.map +1 -0
  96. package/dist/cli/usage.d.ts +3 -0
  97. package/dist/cli/usage.d.ts.map +1 -0
  98. package/dist/cli/usage.js +95 -0
  99. package/dist/cli/usage.js.map +1 -0
  100. package/dist/detect.d.ts.map +1 -1
  101. package/dist/detect.js.map +1 -1
  102. package/dist/errors.d.ts +21 -1
  103. package/dist/errors.d.ts.map +1 -1
  104. package/dist/errors.js +33 -1
  105. package/dist/errors.js.map +1 -1
  106. package/dist/harness/aider.d.ts +10 -0
  107. package/dist/harness/aider.d.ts.map +1 -0
  108. package/dist/harness/aider.js +21 -0
  109. package/dist/harness/aider.js.map +1 -0
  110. package/dist/harness/claude-code.d.ts +3 -0
  111. package/dist/harness/claude-code.d.ts.map +1 -0
  112. package/dist/harness/claude-code.js +68 -0
  113. package/dist/harness/claude-code.js.map +1 -0
  114. package/dist/harness/cline.d.ts +3 -0
  115. package/dist/harness/cline.d.ts.map +1 -0
  116. package/dist/harness/cline.js +54 -0
  117. package/dist/harness/cline.js.map +1 -0
  118. package/dist/harness/codex.d.ts +3 -0
  119. package/dist/harness/codex.d.ts.map +1 -0
  120. package/dist/harness/codex.js +92 -0
  121. package/dist/harness/codex.js.map +1 -0
  122. package/dist/harness/cursor.d.ts +3 -0
  123. package/dist/harness/cursor.d.ts.map +1 -0
  124. package/dist/harness/cursor.js +54 -0
  125. package/dist/harness/cursor.js.map +1 -0
  126. package/dist/harness/gemini.d.ts +3 -0
  127. package/dist/harness/gemini.d.ts.map +1 -0
  128. package/dist/harness/gemini.js +60 -0
  129. package/dist/harness/gemini.js.map +1 -0
  130. package/dist/harness/grok.d.ts +3 -0
  131. package/dist/harness/grok.d.ts.map +1 -0
  132. package/dist/harness/grok.js +47 -0
  133. package/dist/harness/grok.js.map +1 -0
  134. package/dist/harness/hermes.d.ts +3 -0
  135. package/dist/harness/hermes.d.ts.map +1 -0
  136. package/dist/harness/hermes.js +72 -0
  137. package/dist/harness/hermes.js.map +1 -0
  138. package/dist/harness/kilocode.d.ts +3 -0
  139. package/dist/harness/kilocode.d.ts.map +1 -0
  140. package/dist/harness/kilocode.js +35 -0
  141. package/dist/harness/kilocode.js.map +1 -0
  142. package/dist/harness/opencode.d.ts +3 -0
  143. package/dist/harness/opencode.d.ts.map +1 -0
  144. package/dist/harness/opencode.js +97 -0
  145. package/dist/harness/opencode.js.map +1 -0
  146. package/dist/harness/paths.d.ts +17 -0
  147. package/dist/harness/paths.d.ts.map +1 -0
  148. package/dist/harness/paths.js +45 -0
  149. package/dist/harness/paths.js.map +1 -0
  150. package/dist/harness/profile.d.ts +209 -0
  151. package/dist/harness/profile.d.ts.map +1 -0
  152. package/dist/harness/profile.js +41 -0
  153. package/dist/harness/profile.js.map +1 -0
  154. package/dist/harness/registry.d.ts +100 -0
  155. package/dist/harness/registry.d.ts.map +1 -0
  156. package/dist/harness/registry.js +144 -0
  157. package/dist/harness/registry.js.map +1 -0
  158. package/dist/harness/snippet.d.ts +19 -0
  159. package/dist/harness/snippet.d.ts.map +1 -0
  160. package/dist/harness/snippet.js +41 -0
  161. package/dist/harness/snippet.js.map +1 -0
  162. package/dist/hash.d.ts.map +1 -1
  163. package/dist/hash.js.map +1 -1
  164. package/dist/hooks/guard-core.d.ts +14 -14
  165. package/dist/hooks/guard-core.d.ts.map +1 -1
  166. package/dist/hooks/guard-core.js +15 -37
  167. package/dist/hooks/guard-core.js.map +1 -1
  168. package/dist/hooks/shim.d.ts +95 -4
  169. package/dist/hooks/shim.d.ts.map +1 -1
  170. package/dist/hooks/shim.js +87 -2
  171. package/dist/hooks/shim.js.map +1 -1
  172. package/dist/hooks/shims/claude-code.d.ts +5 -18
  173. package/dist/hooks/shims/claude-code.d.ts.map +1 -1
  174. package/dist/hooks/shims/claude-code.js +9 -56
  175. package/dist/hooks/shims/claude-code.js.map +1 -1
  176. package/dist/hooks/shims/cline.d.ts +5 -12
  177. package/dist/hooks/shims/cline.d.ts.map +1 -1
  178. package/dist/hooks/shims/cline.js +9 -34
  179. package/dist/hooks/shims/cline.js.map +1 -1
  180. package/dist/hooks/shims/codex.d.ts +5 -18
  181. package/dist/hooks/shims/codex.d.ts.map +1 -1
  182. package/dist/hooks/shims/codex.js +9 -51
  183. package/dist/hooks/shims/codex.js.map +1 -1
  184. package/dist/hooks/shims/cursor.d.ts +5 -14
  185. package/dist/hooks/shims/cursor.d.ts.map +1 -1
  186. package/dist/hooks/shims/cursor.js +9 -42
  187. package/dist/hooks/shims/cursor.js.map +1 -1
  188. package/dist/hooks/shims/gemini.d.ts +5 -18
  189. package/dist/hooks/shims/gemini.d.ts.map +1 -1
  190. package/dist/hooks/shims/gemini.js +9 -48
  191. package/dist/hooks/shims/gemini.js.map +1 -1
  192. package/dist/hooks/shims/grok.d.ts +5 -13
  193. package/dist/hooks/shims/grok.d.ts.map +1 -1
  194. package/dist/hooks/shims/grok.js +9 -32
  195. package/dist/hooks/shims/grok.js.map +1 -1
  196. package/dist/hooks/shims/hermes.d.ts +5 -17
  197. package/dist/hooks/shims/hermes.d.ts.map +1 -1
  198. package/dist/hooks/shims/hermes.js +9 -45
  199. package/dist/hooks/shims/hermes.js.map +1 -1
  200. package/dist/index.d.ts +43 -76
  201. package/dist/index.d.ts.map +1 -1
  202. package/dist/index.js +21 -67
  203. package/dist/index.js.map +1 -1
  204. package/dist/lang/bash.d.ts.map +1 -1
  205. package/dist/lang/bash.js.map +1 -1
  206. package/dist/lang/c.d.ts.map +1 -1
  207. package/dist/lang/c.js.map +1 -1
  208. package/dist/lang/c_sharp.d.ts.map +1 -1
  209. package/dist/lang/c_sharp.js.map +1 -1
  210. package/dist/lang/cpp.d.ts.map +1 -1
  211. package/dist/lang/cpp.js.map +1 -1
  212. package/dist/lang/go.d.ts.map +1 -1
  213. package/dist/lang/go.js.map +1 -1
  214. package/dist/lang/java.d.ts.map +1 -1
  215. package/dist/lang/java.js.map +1 -1
  216. package/dist/lang/javascript.d.ts.map +1 -1
  217. package/dist/lang/javascript.js.map +1 -1
  218. package/dist/lang/kotlin.d.ts.map +1 -1
  219. package/dist/lang/kotlin.js.map +1 -1
  220. package/dist/lang/php.d.ts.map +1 -1
  221. package/dist/lang/php.js.map +1 -1
  222. package/dist/lang/profile.d.ts.map +1 -1
  223. package/dist/lang/profile.js.map +1 -1
  224. package/dist/lang/python.d.ts.map +1 -1
  225. package/dist/lang/python.js.map +1 -1
  226. package/dist/lang/registry.d.ts.map +1 -1
  227. package/dist/lang/registry.js.map +1 -1
  228. package/dist/lang/ruby.d.ts.map +1 -1
  229. package/dist/lang/ruby.js.map +1 -1
  230. package/dist/lang/rust.d.ts.map +1 -1
  231. package/dist/lang/rust.js.map +1 -1
  232. package/dist/lang/swift.d.ts.map +1 -1
  233. package/dist/lang/swift.js.map +1 -1
  234. package/dist/lang/tsx.d.ts.map +1 -1
  235. package/dist/lang/tsx.js.map +1 -1
  236. package/dist/lang/typescript.d.ts.map +1 -1
  237. package/dist/lang/typescript.js.map +1 -1
  238. package/dist/net/policy.d.ts +18 -1
  239. package/dist/net/policy.d.ts.map +1 -1
  240. package/dist/net/policy.js +6 -4
  241. package/dist/net/policy.js.map +1 -1
  242. package/dist/ops/index.d.ts +39 -0
  243. package/dist/ops/index.d.ts.map +1 -0
  244. package/dist/ops/index.js +37 -0
  245. package/dist/ops/index.js.map +1 -0
  246. package/dist/ops/inputs.d.ts +170 -0
  247. package/dist/ops/inputs.d.ts.map +1 -0
  248. package/dist/ops/inputs.js +142 -0
  249. package/dist/ops/inputs.js.map +1 -0
  250. package/dist/ops/verbs.d.ts +136 -0
  251. package/dist/ops/verbs.d.ts.map +1 -0
  252. package/dist/ops/verbs.js +76 -0
  253. package/dist/ops/verbs.js.map +1 -0
  254. package/dist/plan/auto.d.ts +69 -0
  255. package/dist/plan/auto.d.ts.map +1 -0
  256. package/dist/plan/auto.js +70 -0
  257. package/dist/plan/auto.js.map +1 -0
  258. package/dist/plan/budget.d.ts +21 -0
  259. package/dist/plan/budget.d.ts.map +1 -0
  260. package/dist/plan/budget.js +26 -0
  261. package/dist/plan/budget.js.map +1 -0
  262. package/dist/plan/grammar.d.ts +14 -0
  263. package/dist/plan/grammar.d.ts.map +1 -1
  264. package/dist/plan/grammar.js +47 -6
  265. package/dist/plan/grammar.js.map +1 -1
  266. package/dist/plan/lexical.d.ts.map +1 -1
  267. package/dist/plan/lexical.js +1 -7
  268. package/dist/plan/lexical.js.map +1 -1
  269. package/dist/plan/planners.d.ts +35 -2
  270. package/dist/plan/planners.d.ts.map +1 -1
  271. package/dist/plan/planners.js +35 -2
  272. package/dist/plan/planners.js.map +1 -1
  273. package/dist/plan/structural.d.ts +19 -5
  274. package/dist/plan/structural.d.ts.map +1 -1
  275. package/dist/plan/structural.js +180 -33
  276. package/dist/plan/structural.js.map +1 -1
  277. package/dist/repomap/cache.d.ts +48 -0
  278. package/dist/repomap/cache.d.ts.map +1 -1
  279. package/dist/repomap/cache.js +112 -13
  280. package/dist/repomap/cache.js.map +1 -1
  281. package/dist/repomap/io.d.ts +24 -0
  282. package/dist/repomap/io.d.ts.map +1 -0
  283. package/dist/repomap/io.js +34 -0
  284. package/dist/repomap/io.js.map +1 -0
  285. package/dist/repomap/map.d.ts +69 -6
  286. package/dist/repomap/map.d.ts.map +1 -1
  287. package/dist/repomap/map.js +104 -22
  288. package/dist/repomap/map.js.map +1 -1
  289. package/dist/repomap/rank.d.ts +26 -2
  290. package/dist/repomap/rank.d.ts.map +1 -1
  291. package/dist/repomap/rank.js +20 -0
  292. package/dist/repomap/rank.js.map +1 -1
  293. package/dist/repomap/reader.d.ts +73 -0
  294. package/dist/repomap/reader.d.ts.map +1 -0
  295. package/dist/repomap/reader.js +30 -0
  296. package/dist/repomap/reader.js.map +1 -0
  297. package/dist/repomap/tags.d.ts.map +1 -1
  298. package/dist/repomap/tags.js.map +1 -1
  299. package/dist/retrieve.d.ts +8 -0
  300. package/dist/retrieve.d.ts.map +1 -1
  301. package/dist/retrieve.js +12 -1
  302. package/dist/retrieve.js.map +1 -1
  303. package/dist/smelter.d.ts +79 -0
  304. package/dist/smelter.d.ts.map +1 -0
  305. package/dist/smelter.js +65 -0
  306. package/dist/smelter.js.map +1 -0
  307. package/dist/stages.d.ts.map +1 -1
  308. package/dist/stages.js +2 -2
  309. package/dist/stages.js.map +1 -1
  310. package/dist/stats.d.ts +2 -1
  311. package/dist/stats.d.ts.map +1 -1
  312. package/dist/stats.js +2 -1
  313. package/dist/stats.js.map +1 -1
  314. package/dist/store-dir.d.ts +43 -4
  315. package/dist/store-dir.d.ts.map +1 -1
  316. package/dist/store-dir.js +48 -5
  317. package/dist/store-dir.js.map +1 -1
  318. package/dist/store.d.ts +6 -0
  319. package/dist/store.d.ts.map +1 -1
  320. package/dist/store.js +6 -0
  321. package/dist/store.js.map +1 -1
  322. package/dist/text/json-edit.d.ts +71 -0
  323. package/dist/text/json-edit.d.ts.map +1 -0
  324. package/dist/text/json-edit.js +219 -0
  325. package/dist/text/json-edit.js.map +1 -0
  326. package/dist/types.d.ts +35 -14
  327. package/dist/types.d.ts.map +1 -1
  328. package/dist/types.js.map +1 -1
  329. package/grammars/tree-sitter-bash.wasm +0 -0
  330. package/grammars/tree-sitter-c.wasm +0 -0
  331. package/grammars/tree-sitter-c_sharp.wasm +0 -0
  332. package/grammars/tree-sitter-cpp.wasm +0 -0
  333. package/grammars/tree-sitter-go.wasm +0 -0
  334. package/grammars/tree-sitter-java.wasm +0 -0
  335. package/grammars/tree-sitter-javascript.wasm +0 -0
  336. package/grammars/tree-sitter-kotlin.wasm +0 -0
  337. package/grammars/tree-sitter-php.wasm +0 -0
  338. package/grammars/tree-sitter-python.wasm +0 -0
  339. package/grammars/tree-sitter-ruby.wasm +0 -0
  340. package/grammars/tree-sitter-rust.wasm +0 -0
  341. package/grammars/tree-sitter-swift.wasm +0 -0
  342. package/grammars/tree-sitter-tsx.wasm +0 -0
  343. package/grammars/tree-sitter-typescript.wasm +0 -0
  344. package/package.json +11 -11
  345. package/dist/cli/resolve.d.ts +0 -103
  346. package/dist/cli/resolve.d.ts.map +0 -1
  347. package/dist/cli/resolve.js +0 -106
  348. package/dist/cli/resolve.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,MAAM,MAAM,UAAU,GAClB,YAAY,GACZ,KAAK,GACL,YAAY,GACZ,MAAM,GACN,QAAQ,GACR,IAAI,GACJ,MAAM,GACN,GAAG,GACH,KAAK,GACL,SAAS,GACT,MAAM,GACN,KAAK,GACL,QAAQ,GACR,OAAO,GACP,MAAM,CAAC;AAEX,2FAA2F;AAC3F,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,SAAS,CAAC;AAEtD,+EAA+E;AAC/E,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,QAAQ,CAA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C;IACpB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7D","sourcesContent":["/** Languages smelt can parse structurally. Everything else falls back to the lexical planner. */\nexport type LanguageId =\n | 'typescript'\n | 'tsx'\n | 'javascript'\n | 'rust'\n | 'python'\n | 'go'\n | 'java'\n | 'c'\n | 'cpp'\n | 'c_sharp'\n | 'ruby'\n | 'php'\n | 'kotlin'\n | 'swift'\n | 'bash';\n\n/** `'unknown'` is a first-class outcome, not a failure: it selects the lexical planner. */\nexport type DetectedLanguage = LanguageId | 'unknown';\n\n/** A half-open byte range `[start, end)` into the UTF-8 bytes of the input. */\nexport interface ByteRange {\n readonly start: number;\n readonly end: number;\n}\n\n/**\n * Why a range was elided, in two registers: a stable id for counters, and a sentence\n * a human can read in a diff. Law 2 — every elision is explainable — lives here:\n * if you cannot write the sentence, the rule does not ship.\n */\nexport interface ElisionReason {\n /** Stable machine id, e.g. `'sibling-collapse'`, `'line-window'`. */\n readonly rule: string;\n /** e.g. `'collapsed 3 sibling functions'`. Present tense, no trailing period. */\n readonly explanation: string;\n}\n\n/** One range a planner proposes to remove. Plans are pure data — inspectable and testable. */\nexport interface PlannedElision {\n readonly range: ByteRange;\n readonly reason: ElisionReason;\n}\n\n/**\n * The complete output of a planner: the whole decision, before anything is mutated.\n * A plan can be logged, diffed, snapshot-tested, and rejected without touching the text.\n */\nexport interface ElisionPlan {\n readonly planner: string;\n readonly language: DetectedLanguage;\n readonly elisions: readonly PlannedElision[];\n}\n\n/**\n * The seam through which a planner asks what a marker will cost, in UTF-8 bytes.\n *\n * Marker cost is `apply.ts`'s fact — the applier renders the marker, so only the\n * applier knows its price. Planners need that price for two decisions (profitability:\n * a marker that costs more than it removes grows the output; and budget prediction:\n * which ladder rung actually fits), and before this seam each planner rebuilt the\n * marker machinery privately to measure it — correct, but an inversion. Now\n * `markerPricing()` in `apply.ts` builds the one adapter from the exact builder\n * `applyPlan` will use, and planners ask it. They never guess, and they never render\n * a marker of their own.\n *\n * The price is exact, not an estimate: the cost of the marker this elision would\n * earn, comment leader and all, with a stand-in hash of the real hash's length —\n * marker cost depends on the hash's *length*, never its value.\n */\nexport interface MarkerPricing {\n /** The exact UTF-8 byte cost of the marker an elision with this reason and size would earn. */\n costBytes(reason: ElisionReason, elidedBytes: number): number;\n}\n\n/**\n * What the caller hands a planner.\n *\n * Constructed centrally: `createSmelter` (and through it, the CLI) builds the one\n * `PlanInput` per call, including its {@link MarkerPricing} — a caller invoking\n * `planLexical`/`planStructural` directly builds `pricing` with `markerPricing()`\n * from `apply.ts`. A JS caller who omits it gets {@link MissingMarkerPricingError}\n * at plan time, not a guessed cost.\n */\nexport interface PlanInput {\n readonly text: string;\n readonly language: DetectedLanguage;\n /** Soft ceiling for the emitted output, in UTF-8 bytes. Planners aim under it. */\n readonly budgetBytes: number;\n /**\n * What the caller was actually looking for — grep pattern, symbol name, error string.\n * Planners keep matching regions and collapse around them.\n */\n readonly focus?: readonly string[];\n /**\n * What a marker costs. Required: a planner that guesses marker cost can plan an\n * elision that grows the output. See {@link MarkerPricing}; built by\n * `markerPricing()` in `apply.ts` from the exact builder `applyPlan` will use.\n */\n readonly pricing: MarkerPricing;\n}\n\n/**\n * A planner decides *what* to remove. It never removes anything itself; `applyPlan`\n * does that. Keeping the decision and the mutation apart is what makes the decision\n * testable in isolation.\n */\nexport interface Planner {\n readonly id: string;\n plan(input: PlanInput): Promise<ElisionPlan>;\n}\n\n/** One elision that actually happened, with the receipt needed to undo it. */\nexport interface AppliedElision {\n /** Content hash of the removed bytes — the key `retrieve()` takes. */\n readonly hash: string;\n /** Where the removed bytes were in the *input*. */\n readonly range: ByteRange;\n /**\n * Where the marker sits in the *output*. Law 3 — every elision is reversible — needs\n * this: {@link Reconstructor} splices stored bytes back over these ranges. Without it,\n * \"reversible\" would mean parsing markers back out of the text, which is a guess.\n * This is a fact recorded at the moment of the cut.\n */\n readonly outputRange: ByteRange;\n /** Size of the removed content, in UTF-8 bytes. */\n readonly bytes: number;\n readonly reason: ElisionReason;\n /** The exact marker text substituted into the output. */\n readonly marker: string;\n}\n\n/**\n * A consumer-supplied counter, so a caller who bills in tokens can *see* tokens.\n *\n * Budgets in smelt's core are UTF-8 bytes, permanently — bytes are the only unit that\n * is computable locally for every model, and they mean the same thing in five years.\n * See `docs/ARCHITECTURE.md` § \"Decision 1\". This hook does not change that: it adds a\n * second, labelled number to the result. The plan is still made in bytes.\n *\n * Both `id` and `unit` are required, and that is a Law 4 decision rather than\n * bookkeeping: a token count is meaningless without naming the tokenizer that produced\n * it. Anthropic's own docs record that Claude 4.7 and later use a newer tokenizer where\n * the same text yields roughly 30% more tokens than on earlier models — so `1,204\n * tokens` is not a fact, and `1,204 tokens (claude-4.7/count_tokens)` is.\n *\n * **This hook does not relax Law 1.** smelt imports no transport and the guard proves\n * that about smelt's own modules; it cannot prove it about a function you hand in. A\n * `count()` that calls an API makes *your* process call an API, from a line in *your*\n * source — exactly the arrangement {@link RerankStage} already describes. `count` is\n * synchronous on purpose: local tokenizers are synchronous, and network clients are not.\n */\nexport interface Measure {\n /** Names the counter, e.g. `'tiktoken/o200k_base'` or `'claude-4.7/count_tokens'`. */\n readonly id: string;\n /** The unit `count()` returns, e.g. `'tokens'`. Printed next to the number. */\n readonly unit: string;\n /** Local, synchronous count over the whole string. */\n count(text: string): number;\n}\n\n/** A second size for a result, in someone else's unit, with the counter named. */\nexport interface MeasuredSize {\n /** {@link Measure.id} of the counter that produced these numbers. */\n readonly measure: string;\n /** {@link Measure.unit}. */\n readonly unit: string;\n readonly input: number;\n readonly output: number;\n}\n\n/** The result of smelting one blob of text. */\nexport interface SmeltResult {\n readonly text: string;\n readonly inputBytes: number;\n readonly outputBytes: number;\n readonly planner: string;\n readonly language: DetectedLanguage;\n readonly elisions: readonly AppliedElision[];\n /** Present only when the caller supplied a {@link Measure}. Never invented. */\n readonly measured?: MeasuredSize;\n}\n\n/**\n * Reversibility, as a callable. Takes a {@link SmeltResult} and the store that holds its\n * elided bytes, and returns the original text — byte for byte.\n */\nexport type Reconstructor = (result: SmeltResult, store: ElisionStore) => string;\n\n// ---------------------------------------------------------------------------\n// The store, and the counters that make over-pruning visible\n// ---------------------------------------------------------------------------\n\n/**\n * The numbers that keep smelt honest about itself.\n *\n * Law 3 says elisions are reversible. That is cheap to satisfy and easy to abuse: a\n * compressor that cuts everything is \"reversible\" and useless. The *retrieve rate* is\n * the tell. If the model keeps calling `smelt_retrieve`, smelt cut material the task\n * needed, and the round trip cost more tokens than the elision saved.\n *\n * So: `expansionRate` is not telemetry. It is the metric a caller tunes budgets\n * against, and the only number smelt is willing to have an opinion about — because it\n * measures it locally, per session, on the caller's own traffic.\n */\nexport interface RetrieveStats {\n /** Distinct blobs put into the store. */\n readonly elisionsStored: number;\n /** Total bytes held by the store. */\n readonly bytesStored: number;\n /** Every `retrieve()` call, including repeats and misses. */\n readonly retrieveCalls: number;\n /** Distinct hashes successfully retrieved at least once. */\n readonly uniqueRetrieved: number;\n /** Calls for a hash the store does not hold. Non-zero means a bug, not over-pruning. */\n readonly misses: number;\n /**\n * `uniqueRetrieved / elisionsStored`, or `0` when nothing has been stored.\n *\n * Read it as: *what fraction of what smelt hid did the model have to ask for back?*\n * There is no universally right value, and smelt does not ship a threshold it has\n * not measured. Rising across a workload is the signal.\n */\n readonly expansionRate: number;\n /**\n * The one degenerate outcome smelt is willing to name: **every distinct blob it hid\n * was asked for again.**\n *\n * smelt ships no expansion-rate threshold, because a threshold is a policy claim it\n * has no basis for and the right rate depends on how aggressive a budget the caller\n * chose — and a library printing warnings into someone else's process is bad manners.\n * This is not a threshold. At `uniqueRetrieved === elisionsStored` the elision\n * achieved nothing and cost a round trip: an arithmetic fact, not a preference. What\n * to do about it is the caller's call.\n *\n * `false` for an empty store — nothing was hidden, so nothing was defeated.\n */\n readonly allElisionsRetrieved: boolean;\n}\n\n/**\n * Local, content-addressed storage for elided bytes. No network, no eviction in v1 —\n * evicting is how \"reversible\" quietly becomes \"reversible for a while\".\n */\nexport interface ElisionStore {\n /** Store content, returning its hash. Idempotent for identical content. */\n put(content: string): string;\n /** The stored content, or `undefined` if this store never held that hash. */\n peek(hash: string): string | undefined;\n /**\n * The stored content, *counted* as a retrieval. This is what the model's tool calls.\n *\n * @throws {UnknownHashError} when the hash is unknown.\n * @throws {StoreCorruptionError} — {@link DirectoryElisionStore} only — when the\n * bytes on disk no longer hash to their own name. Distinct from\n * `UnknownHashError` on purpose: \"we hold damaged bytes\" and \"it never existed\"\n * are different answers, and a caller that conflates them will report the wrong\n * one to its user.\n *\n * A {@link DirectoryElisionStore} whose journal cannot be written (a read-only\n * store directory, a full disk) still returns the bytes — verified bytes are never\n * withheld over a bookkeeping failure — and surfaces the lost count as a\n * `process.emitWarning` named `SmeltCounterWriteFailure` instead of throwing. Its\n * stats go quiet from that point; the retrieval itself succeeded.\n */\n retrieve(hash: string): string;\n /**\n * Whether this hash can be retrieved — **not** merely whether a slot bearing it\n * exists. `true` must mean the very next `retrieve(hash)` returns bytes, so a store\n * that verifies content on read verifies here too and raises its corruption error\n * rather than answering `true` for bytes it would then refuse. Uncounted: a check is\n * not the model asking for material back.\n */\n has(hash: string): boolean;\n /** A snapshot of the counters. See {@link RetrieveStats}. */\n stats(): RetrieveStats;\n}\n\n/**\n * The retrieval tool a consumer exposes to its model. Deliberately not an MCP or\n * provider-specific shape — smelt does not know which SDK you use. The consumer adapts\n * this into its own tool schema; the contract is `hash in, exact bytes out`.\n */\nexport interface RetrieveTool {\n /** `'smelt_retrieve'`. Stable — consumers hard-code it in prompts. */\n readonly name: string;\n /** Prose the consumer can put straight into a tool description. */\n readonly description: string;\n /**\n * JSON-Schema-shaped parameter description, for consumers that want one.\n *\n * Strict-mode shaped: `additionalProperties: false` and a `required` naming every\n * property, so a consumer registering this under OpenAI's structured-outputs strict\n * mode is not refused at registration. See {@link createRetrieveTool}.\n */\n readonly inputSchema: {\n readonly type: 'object';\n readonly properties: {\n readonly hash: { readonly type: 'string'; readonly description: string };\n };\n readonly required: readonly ['hash'];\n readonly additionalProperties: false;\n };\n /**\n * @throws {UnknownHashError} when the hash is unknown.\n * @throws {StoreCorruptionError} when the backing store holds damaged bytes for\n * that hash — see {@link ElisionStore.retrieve}, whose contract this forwards\n * verbatim. Surface either to the model as a tool error, never as empty text.\n */\n invoke(input: { readonly hash: string }): string;\n}\n\n// ---------------------------------------------------------------------------\n// Pluggable stages — interfaces in v1, nothing more\n// ---------------------------------------------------------------------------\n\n/** A candidate handed to a {@link RerankStage}: an opaque id plus the text to judge. */\nexport interface RerankCandidate {\n readonly id: string;\n readonly text: string;\n}\n\n/** A reranked candidate, most relevant first. `score` is the stage's own scale. */\nexport interface RerankedCandidate extends RerankCandidate {\n readonly score: number;\n}\n\n/**\n * Relevance reranking — a *seam*, not a feature.\n *\n * Hosted rerankers are good and smelt will never bundle one, because bundling would\n * break Law 1: the moment smelt ships a default reranker, `smelt()` can make a network\n * call that the caller did not ask for and cannot see. A consumer that wants one\n * implements this interface, wires its own key, and owns the fact that its context now\n * leaves the machine. That decision must be legible in the consumer's own source.\n */\nexport interface RerankStage {\n readonly id: string;\n /** May make network calls — that is the consumer's choice, made in the consumer's code. */\n rerank(\n candidates: readonly RerankCandidate[],\n query: string,\n ): Promise<readonly RerankedCandidate[]>;\n}\n\n/**\n * Learned distillation — rewriting content with a model instead of cutting it.\n *\n * Out of v1 for a reason beyond the network: a distilled paragraph cannot satisfy\n * Law 2. \"The model summarised this\" is not an explanation of what was removed, and\n * the removed material is no longer recoverable from the output. If this ever ships,\n * it ships as a stage that stores the original and explains itself in the same terms\n * every other rule does.\n */\nexport interface DistillStage {\n readonly id: string;\n distill(text: string, budgetBytes: number): Promise<string>;\n}\n"]}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/** Languages smelt can parse structurally. Everything else falls back to the lexical planner. */\nexport type LanguageId =\n | 'typescript'\n | 'tsx'\n | 'javascript'\n | 'rust'\n | 'python'\n | 'go'\n | 'java'\n | 'c'\n | 'cpp'\n | 'c_sharp'\n | 'ruby'\n | 'php'\n | 'kotlin'\n | 'swift'\n | 'bash';\n\n/** `'unknown'` is a first-class outcome, not a failure: it selects the lexical planner. */\nexport type DetectedLanguage = LanguageId | 'unknown';\n\n/** A half-open byte range `[start, end)` into the UTF-8 bytes of the input. */\nexport interface ByteRange {\n readonly start: number;\n readonly end: number;\n}\n\n/**\n * Why a range was elided, in two registers: a stable id for counters, and a sentence\n * a human can read in a diff. Law 2 — every elision is explainable — lives here:\n * if you cannot write the sentence, the rule does not ship.\n */\nexport interface ElisionReason {\n /** Stable machine id, e.g. `'sibling-collapse'`, `'line-window'`. */\n readonly rule: string;\n /** e.g. `'collapsed 3 sibling functions'`. Present tense, no trailing period. */\n readonly explanation: string;\n}\n\n/** One range a planner proposes to remove. Plans are pure data — inspectable and testable. */\nexport interface PlannedElision {\n readonly range: ByteRange;\n readonly reason: ElisionReason;\n}\n\n/**\n * The complete output of a planner: the whole decision, before anything is mutated.\n * A plan can be logged, diffed, snapshot-tested, and rejected without touching the text.\n */\nexport interface ElisionPlan {\n readonly planner: string;\n readonly language: DetectedLanguage;\n readonly elisions: readonly PlannedElision[];\n}\n\n/**\n * The seam through which a planner asks what a marker will cost, in UTF-8 bytes.\n *\n * Marker cost is `apply.ts`'s fact — the applier renders the marker, so only the\n * applier knows its price. Planners need that price for two decisions (profitability:\n * a marker that costs more than it removes grows the output; and budget prediction:\n * which ladder rung actually fits), and before this seam each planner rebuilt the\n * marker machinery privately to measure it — correct, but an inversion. Now\n * `markerPricing()` in `apply.ts` builds the one adapter from the exact builder\n * `applyPlan` will use, and planners ask it. They never guess, and they never render\n * a marker of their own.\n *\n * The price is exact, not an estimate: the cost of the marker this elision would\n * earn, comment leader and all, with a stand-in hash of the real hash's length —\n * marker cost depends on the hash's *length*, never its value.\n */\nexport interface MarkerPricing {\n /** The exact UTF-8 byte cost of the marker an elision with this reason and size would earn. */\n costBytes(reason: ElisionReason, elidedBytes: number): number;\n}\n\n/**\n * What the caller hands a planner.\n *\n * Constructed centrally: `createSmelter` (and through it, the CLI) builds the one\n * `PlanInput` per call, including its {@link MarkerPricing} — a caller invoking\n * `planLexical`/`planStructural` directly builds `pricing` with `markerPricing()`\n * from `apply.ts`. A JS caller who omits it gets {@link MissingMarkerPricingError}\n * at plan time, not a guessed cost.\n */\nexport interface PlanInput {\n readonly text: string;\n readonly language: DetectedLanguage;\n /** Soft ceiling for the emitted output, in UTF-8 bytes. Planners aim under it. */\n readonly budgetBytes: number;\n /**\n * What the caller was actually looking for — grep pattern, symbol name, error string.\n * Planners keep matching regions and collapse around them.\n */\n readonly focus?: readonly string[];\n /**\n * What a marker costs. Required: a planner that guesses marker cost can plan an\n * elision that grows the output. See {@link MarkerPricing}; built by\n * `markerPricing()` in `apply.ts` from the exact builder `applyPlan` will use.\n */\n readonly pricing: MarkerPricing;\n}\n\n/**\n * A planner decides *what* to remove. It never removes anything itself; `applyPlan`\n * does that. Keeping the decision and the mutation apart is what makes the decision\n * testable in isolation.\n */\nexport interface Planner {\n readonly id: string;\n plan(input: PlanInput): Promise<ElisionPlan>;\n}\n\n/** One elision that actually happened, with the receipt needed to undo it. */\nexport interface AppliedElision {\n /** Content hash of the removed bytes — the key `retrieve()` takes. */\n readonly hash: string;\n /** Where the removed bytes were in the *input*. */\n readonly range: ByteRange;\n /**\n * Where the marker sits in the *output*. Law 3 — every elision is reversible — needs\n * this: {@link Reconstructor} splices stored bytes back over these ranges. Without it,\n * \"reversible\" would mean parsing markers back out of the text, which is a guess.\n * This is a fact recorded at the moment of the cut.\n */\n readonly outputRange: ByteRange;\n /** Size of the removed content, in UTF-8 bytes. */\n readonly bytes: number;\n readonly reason: ElisionReason;\n /** The exact marker text substituted into the output. */\n readonly marker: string;\n}\n\n/**\n * A consumer-supplied counter, so a caller who bills in tokens can *see* tokens.\n *\n * Budgets in smelt's core are UTF-8 bytes, permanently — bytes are the only unit that\n * is computable locally for every model, and they mean the same thing in five years.\n * See `docs/ARCHITECTURE.md` § \"Decision 1\". This hook does not change that: it adds a\n * second, labelled number to the result. The plan is still made in bytes.\n *\n * Both `id` and `unit` are required, and that is a Law 4 decision rather than\n * bookkeeping: a token count is meaningless without naming the tokenizer that produced\n * it. Anthropic's own docs record that Claude 4.7 and later use a newer tokenizer where\n * the same text yields roughly 30% more tokens than on earlier models — so `1,204\n * tokens` is not a fact, and `1,204 tokens (claude-4.7/count_tokens)` is.\n *\n * **This hook does not relax Law 1.** smelt imports no transport and the guard proves\n * that about smelt's own modules; it cannot prove it about a function you hand in. A\n * `count()` that calls an API makes *your* process call an API, from a line in *your*\n * source — exactly the arrangement {@link RerankStage} already describes. `count` is\n * synchronous on purpose: local tokenizers are synchronous, and network clients are not.\n */\nexport interface Measure {\n /** Names the counter, e.g. `'tiktoken/o200k_base'` or `'claude-4.7/count_tokens'`. */\n readonly id: string;\n /** The unit `count()` returns, e.g. `'tokens'`. Printed next to the number. */\n readonly unit: string;\n /** Local, synchronous count over the whole string. */\n count(text: string): number;\n}\n\n/** A second size for a result, in someone else's unit, with the counter named. */\nexport interface MeasuredSize {\n /** {@link Measure.id} of the counter that produced these numbers. */\n readonly measure: string;\n /** {@link Measure.unit}. */\n readonly unit: string;\n readonly input: number;\n readonly output: number;\n}\n\n/** The result of smelting one blob of text. */\nexport interface SmeltResult {\n readonly text: string;\n readonly inputBytes: number;\n readonly outputBytes: number;\n readonly planner: string;\n readonly language: DetectedLanguage;\n readonly elisions: readonly AppliedElision[];\n /** Present only when the caller supplied a {@link Measure}. Never invented. */\n readonly measured?: MeasuredSize;\n}\n\n/**\n * Reversibility, as a callable. Takes a {@link SmeltResult} and the store that holds its\n * elided bytes, and returns the original text — byte for byte.\n */\nexport type Reconstructor = (result: SmeltResult, store: ElisionStore) => string;\n\n// ---------------------------------------------------------------------------\n// The store, and the counters that make over-pruning visible\n// ---------------------------------------------------------------------------\n\n/**\n * The numbers that keep smelt honest about itself.\n *\n * Law 3 says elisions are reversible. That is cheap to satisfy and easy to abuse: a\n * compressor that cuts everything is \"reversible\" and useless. The *retrieve rate* is\n * the tell. If the model keeps calling `smelt_retrieve`, smelt cut material the task\n * needed, and the round trip cost more tokens than the elision saved.\n *\n * So: `expansionRate` is not telemetry. It is the metric a caller tunes budgets\n * against, and the only number smelt is willing to have an opinion about — because it\n * measures it locally, per session, on the caller's own traffic.\n */\nexport interface RetrieveStats {\n /** Distinct blobs put into the store. */\n readonly elisionsStored: number;\n /** Total bytes held by the store. */\n readonly bytesStored: number;\n /** Every `retrieve()` call, including repeats and misses. */\n readonly retrieveCalls: number;\n /** Distinct hashes successfully retrieved at least once. */\n readonly uniqueRetrieved: number;\n /** Calls for a hash the store does not hold. Non-zero means a bug, not over-pruning. */\n readonly misses: number;\n /**\n * `uniqueRetrieved / elisionsStored`, or `0` when nothing has been stored.\n *\n * Read it as: *what fraction of what smelt hid did the model have to ask for back?*\n * There is no universally right value, and smelt does not ship a threshold it has\n * not measured. Rising across a workload is the signal.\n */\n readonly expansionRate: number;\n /**\n * The one degenerate outcome smelt is willing to name: **every distinct blob it hid\n * was asked for again.**\n *\n * smelt ships no expansion-rate threshold, because a threshold is a policy claim it\n * has no basis for and the right rate depends on how aggressive a budget the caller\n * chose — and a library printing warnings into someone else's process is bad manners.\n * This is not a threshold. At `uniqueRetrieved === elisionsStored` the elision\n * achieved nothing and cost a round trip: an arithmetic fact, not a preference. What\n * to do about it is the caller's call.\n *\n * `false` for an empty store — nothing was hidden, so nothing was defeated.\n */\n readonly allElisionsRetrieved: boolean;\n}\n\n/**\n * Local, content-addressed storage for elided bytes. No network, no eviction in v1 —\n * evicting is how \"reversible\" quietly becomes \"reversible for a while\".\n */\nexport interface ElisionStore {\n /** Store content, returning its hash. Idempotent for identical content. */\n put(content: string): string;\n /** The stored content, or `undefined` if this store never held that hash. */\n peek(hash: string): string | undefined;\n /**\n * The stored content, *counted* as a retrieval. This is what the model's tool calls.\n *\n * @throws {UnknownHashError} when the hash is unknown.\n * @throws {StoreCorruptionError} — {@link DirectoryElisionStore} only — when the\n * bytes on disk no longer hash to their own name. Distinct from\n * `UnknownHashError` on purpose: \"we hold damaged bytes\" and \"it never existed\"\n * are different answers, and a caller that conflates them will report the wrong\n * one to its user.\n *\n * A {@link DirectoryElisionStore} whose journal cannot be written (a read-only\n * store directory, a full disk) still returns the bytes — verified bytes are never\n * withheld over a bookkeeping failure — and surfaces the lost count as a\n * `process.emitWarning` named `SmeltCounterWriteFailure` instead of throwing. Its\n * stats go quiet from that point; the retrieval itself succeeded.\n */\n retrieve(hash: string): string;\n /**\n * Whether this hash can be retrieved — **not** merely whether a slot bearing it\n * exists. `true` must mean the very next `retrieve(hash)` returns bytes, so a store\n * that verifies content on read verifies here too and raises its corruption error\n * rather than answering `true` for bytes it would then refuse. Uncounted: a check is\n * not the model asking for material back.\n */\n has(hash: string): boolean;\n /** A snapshot of the counters. See {@link RetrieveStats}. */\n stats(): RetrieveStats;\n}\n\n/**\n * The retrieval tool a consumer exposes to its model. Deliberately not an MCP or\n * provider-specific shape — smelt does not know which SDK you use. The consumer adapts\n * this into its own tool schema; the contract is `hash in, exact bytes out`.\n */\nexport interface RetrieveTool {\n /** `'smelt_retrieve'`. Stable — consumers hard-code it in prompts. */\n readonly name: string;\n /** Prose the consumer can put straight into a tool description. */\n readonly description: string;\n /**\n * JSON-Schema-shaped parameter description, for consumers that want one.\n *\n * Strict-mode shaped: `additionalProperties: false` and a `required` naming every\n * property, so a consumer registering this under OpenAI's structured-outputs strict\n * mode is not refused at registration. See {@link createRetrieveTool}.\n */\n readonly inputSchema: {\n readonly type: 'object';\n readonly properties: {\n readonly hash: { readonly type: 'string'; readonly description: string };\n };\n readonly required: readonly ['hash'];\n readonly additionalProperties: false;\n };\n /**\n * @throws {UnknownHashError} when the hash is unknown.\n * @throws {StoreCorruptionError} when the backing store holds damaged bytes for\n * that hash — see {@link ElisionStore.retrieve}, whose contract this forwards\n * verbatim. Surface either to the model as a tool error, never as empty text.\n */\n invoke(input: { readonly hash: string }): string;\n}\n\n// ---------------------------------------------------------------------------\n// Pluggable stages — interfaces in v1, nothing more\n// ---------------------------------------------------------------------------\n\n/** A candidate handed to a {@link RerankStage}: an opaque id plus the text to judge. */\nexport interface RerankCandidate {\n readonly id: string;\n readonly text: string;\n}\n\n/** A reranked candidate, most relevant first. `score` is the stage's own scale. */\nexport interface RerankedCandidate extends RerankCandidate {\n readonly score: number;\n}\n\n/**\n * Relevance reranking — a *seam*, not a feature.\n *\n * Hosted rerankers are good and smelt will never bundle one, because bundling would\n * break Law 1: the moment smelt ships a default reranker, `smelt()` can make a network\n * call that the caller did not ask for and cannot see. A consumer that wants one\n * implements this interface, wires its own key, and owns the fact that its context now\n * leaves the machine. That decision must be legible in the consumer's own source.\n */\nexport interface RerankStage {\n readonly id: string;\n /** May make network calls — that is the consumer's choice, made in the consumer's code. */\n rerank(\n candidates: readonly RerankCandidate[],\n query: string,\n ): Promise<readonly RerankedCandidate[]>;\n}\n\n/**\n * Learned distillation — rewriting content with a model instead of cutting it.\n *\n * Out of v1 for a reason beyond the network: a distilled paragraph cannot satisfy\n * Law 2. \"The model summarised this\" is not an explanation of what was removed, and\n * the removed material is no longer recoverable from the output. If this ever ships,\n * it ships as a stage that stores the original and explains itself in the same terms\n * every other rule does.\n */\nexport interface DistillStage {\n readonly id: string;\n distill(text: string, budgetBytes: number): Promise<string>;\n}\n"]}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smeltjs/core",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Structure-aware, reversible, offline context optimization for AI coding agents.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "mong-x",
@@ -56,14 +56,6 @@
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  },
59
- "scripts": {
60
- "build": "tsc -p tsconfig.build.json && node ../../scripts/bundle-grammars.mjs",
61
- "typecheck": "tsc -p tsconfig.json --noEmit",
62
- "test": "vitest run",
63
- "test:watch": "vitest",
64
- "prepack": "pnpm run build && node ../../scripts/generate-third-party.mjs",
65
- "bench": "node bench/run.mjs"
66
- },
67
59
  "dependencies": {
68
60
  "web-tree-sitter": "~0.25.10"
69
61
  },
@@ -71,6 +63,14 @@
71
63
  "@types/node": "^26.4.0",
72
64
  "tree-sitter-wasms": "^0.1.13",
73
65
  "typescript": "^7.0.2",
74
- "vitest": "^4.1.11"
66
+ "vitest": "^4.1.11",
67
+ "@smelt/guard-kit": "0.0.0"
68
+ },
69
+ "scripts": {
70
+ "build": "node ../../scripts/clean-dist.mjs && tsc -p tsconfig.build.json && node ../../scripts/inline-declaration-map-sources.mjs && node ../../scripts/bundle-grammars.mjs",
71
+ "typecheck": "tsc -p tsconfig.json --noEmit",
72
+ "test": "vitest run",
73
+ "test:watch": "vitest",
74
+ "bench": "node bench/run.mjs"
75
75
  }
76
- }
76
+ }
@@ -1,103 +0,0 @@
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
@@ -1 +0,0 @@
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;;;;;;;;;GAS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AE,OAAO,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,aAAa,EACzB,MAAM,EAAE,YAAY,GAAG,SAAS,GAC/B,cAAc,CAqBhB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,UAAU,GAAG,OAAO,EAC7B,MAAM,EAAE,YAAY,GAAG,SAAS,GAC/B,gBAAgB,CAgBlB"}
@@ -1,106 +0,0 @@
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
@@ -1 +0,0 @@
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,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