universal-physics-tensor 10.0.0 → 12.0.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 (835) hide show
  1. package/README.md +39 -36
  2. package/bin/upt.mjs +13 -1
  3. package/data/applied-cases.json +1892 -0
  4. package/data/applied-cases.schema.json +194 -0
  5. package/data/atlas/atlas.json +25 -25
  6. package/data/atlas/atlas.jsonld +1 -1
  7. package/data/atlas/diffusion.json +6 -6
  8. package/data/atlas/oscillators.json +7 -7
  9. package/data/atlas/waves.json +14 -14
  10. package/data/atlas/witness-results.json +11 -11
  11. package/data/bridge-catalog.json +389 -230
  12. package/data/bridge-catalog.schema.json +45 -7
  13. package/data/units.json +6 -25
  14. package/dist/atlas/applicability.d.ts.map +1 -1
  15. package/dist/atlas/applicability.js +21 -15
  16. package/dist/atlas/applicability.js.map +1 -1
  17. package/dist/atlas/benchmark/hybrid-retrieval.d.ts +9 -1
  18. package/dist/atlas/benchmark/hybrid-retrieval.d.ts.map +1 -1
  19. package/dist/atlas/benchmark/hybrid-retrieval.js +15 -13
  20. package/dist/atlas/benchmark/hybrid-retrieval.js.map +1 -1
  21. package/dist/atlas/benchmark/loader.js +2 -2
  22. package/dist/atlas/benchmark/loader.js.map +1 -1
  23. package/dist/atlas/benchmark/stats.d.ts +2 -2
  24. package/dist/atlas/benchmark/stats.d.ts.map +1 -1
  25. package/dist/atlas/benchmark/stats.js +9 -15
  26. package/dist/atlas/benchmark/stats.js.map +1 -1
  27. package/dist/atlas/catalog-formal-ref.d.ts +26 -3
  28. package/dist/atlas/catalog-formal-ref.d.ts.map +1 -1
  29. package/dist/atlas/catalog-formal-ref.js +52 -5
  30. package/dist/atlas/catalog-formal-ref.js.map +1 -1
  31. package/dist/atlas/chain-pipeline.d.ts.map +1 -1
  32. package/dist/atlas/chain-pipeline.js +7 -8
  33. package/dist/atlas/chain-pipeline.js.map +1 -1
  34. package/dist/atlas/diffusion/bridges-closure.d.ts +0 -4
  35. package/dist/atlas/diffusion/bridges-closure.d.ts.map +1 -1
  36. package/dist/atlas/diffusion/bridges-closure.js +8 -12
  37. package/dist/atlas/diffusion/bridges-closure.js.map +1 -1
  38. package/dist/atlas/diffusion/bridges.d.ts.map +1 -1
  39. package/dist/atlas/diffusion/bridges.js +27 -39
  40. package/dist/atlas/diffusion/bridges.js.map +1 -1
  41. package/dist/atlas/diffusion/dimensions.d.ts +6 -14
  42. package/dist/atlas/diffusion/dimensions.d.ts.map +1 -1
  43. package/dist/atlas/diffusion/dimensions.js +8 -16
  44. package/dist/atlas/diffusion/dimensions.js.map +1 -1
  45. package/dist/atlas/diffusion/models.d.ts +3 -3
  46. package/dist/atlas/diffusion/models.d.ts.map +1 -1
  47. package/dist/atlas/diffusion/models.js +5 -10
  48. package/dist/atlas/diffusion/models.js.map +1 -1
  49. package/dist/atlas/diffusion/numerics.d.ts +16 -4
  50. package/dist/atlas/diffusion/numerics.d.ts.map +1 -1
  51. package/dist/atlas/diffusion/numerics.js +38 -24
  52. package/dist/atlas/diffusion/numerics.js.map +1 -1
  53. package/dist/atlas/link-prediction.d.ts +106 -3
  54. package/dist/atlas/link-prediction.d.ts.map +1 -1
  55. package/dist/atlas/link-prediction.js +212 -66
  56. package/dist/atlas/link-prediction.js.map +1 -1
  57. package/dist/atlas/oscillators/bridges-coarse.d.ts.map +1 -1
  58. package/dist/atlas/oscillators/bridges-coarse.js +7 -11
  59. package/dist/atlas/oscillators/bridges-coarse.js.map +1 -1
  60. package/dist/atlas/oscillators/bridges-exact.d.ts.map +1 -1
  61. package/dist/atlas/oscillators/bridges-exact.js +6 -7
  62. package/dist/atlas/oscillators/bridges-exact.js.map +1 -1
  63. package/dist/atlas/oscillators/bridges-limits.d.ts +3 -16
  64. package/dist/atlas/oscillators/bridges-limits.d.ts.map +1 -1
  65. package/dist/atlas/oscillators/bridges-limits.js +23 -34
  66. package/dist/atlas/oscillators/bridges-limits.js.map +1 -1
  67. package/dist/atlas/oscillators/dimensions.d.ts +9 -21
  68. package/dist/atlas/oscillators/dimensions.d.ts.map +1 -1
  69. package/dist/atlas/oscillators/dimensions.js +9 -21
  70. package/dist/atlas/oscillators/dimensions.js.map +1 -1
  71. package/dist/atlas/oscillators/limit-witnesses.d.ts +2 -2
  72. package/dist/atlas/oscillators/limit-witnesses.d.ts.map +1 -1
  73. package/dist/atlas/oscillators/limit-witnesses.js +17 -15
  74. package/dist/atlas/oscillators/limit-witnesses.js.map +1 -1
  75. package/dist/atlas/oscillators/models.d.ts.map +1 -1
  76. package/dist/atlas/oscillators/models.js +2 -6
  77. package/dist/atlas/oscillators/models.js.map +1 -1
  78. package/dist/atlas/oscillators/pendulum-motion.d.ts +29 -6
  79. package/dist/atlas/oscillators/pendulum-motion.d.ts.map +1 -1
  80. package/dist/atlas/oscillators/pendulum-motion.js +60 -40
  81. package/dist/atlas/oscillators/pendulum-motion.js.map +1 -1
  82. package/dist/atlas/oscillators/phase-translation.d.ts +0 -11
  83. package/dist/atlas/oscillators/phase-translation.d.ts.map +1 -1
  84. package/dist/atlas/oscillators/phase-translation.js +3 -4
  85. package/dist/atlas/oscillators/phase-translation.js.map +1 -1
  86. package/dist/atlas/oscillators/position-translation.d.ts +68 -7
  87. package/dist/atlas/oscillators/position-translation.d.ts.map +1 -1
  88. package/dist/atlas/oscillators/position-translation.js +123 -12
  89. package/dist/atlas/oscillators/position-translation.js.map +1 -1
  90. package/dist/atlas/oscillators/rejections.d.ts +0 -2
  91. package/dist/atlas/oscillators/rejections.d.ts.map +1 -1
  92. package/dist/atlas/oscillators/rejections.js +0 -7
  93. package/dist/atlas/oscillators/rejections.js.map +1 -1
  94. package/dist/atlas/physjs-entries.generated.d.ts +35 -25
  95. package/dist/atlas/physjs-entries.generated.d.ts.map +1 -1
  96. package/dist/atlas/physjs-entries.generated.js +37 -25
  97. package/dist/atlas/physjs-entries.generated.js.map +1 -1
  98. package/dist/atlas/physjs-ref.d.ts +34 -31
  99. package/dist/atlas/physjs-ref.d.ts.map +1 -1
  100. package/dist/atlas/physjs-ref.js +55 -53
  101. package/dist/atlas/physjs-ref.js.map +1 -1
  102. package/dist/atlas/physjs-reviewed.d.ts +1 -1
  103. package/dist/atlas/physjs-reviewed.js +15 -15
  104. package/dist/atlas/physjs-reviewed.js.map +1 -1
  105. package/dist/atlas/poster/statements.d.ts +0 -19
  106. package/dist/atlas/poster/statements.d.ts.map +1 -1
  107. package/dist/atlas/poster/statements.js +1 -1
  108. package/dist/atlas/poster/statements.js.map +1 -1
  109. package/dist/atlas/proof-target.d.ts +1 -1
  110. package/dist/atlas/proof-target.js +1 -1
  111. package/dist/atlas/proof-target.js.map +1 -1
  112. package/dist/atlas/regime.d.ts +1 -1
  113. package/dist/atlas/regime.d.ts.map +1 -1
  114. package/dist/atlas/regime.js +1 -1
  115. package/dist/atlas/regime.js.map +1 -1
  116. package/dist/atlas/text-overlap.d.ts +23 -0
  117. package/dist/atlas/text-overlap.d.ts.map +1 -0
  118. package/dist/atlas/text-overlap.js +41 -0
  119. package/dist/atlas/text-overlap.js.map +1 -0
  120. package/dist/atlas/waves/bridges-closure.d.ts.map +1 -1
  121. package/dist/atlas/waves/bridges-closure.js +2 -6
  122. package/dist/atlas/waves/bridges-closure.js.map +1 -1
  123. package/dist/atlas/waves/bridges.d.ts.map +1 -1
  124. package/dist/atlas/waves/bridges.js +32 -48
  125. package/dist/atlas/waves/bridges.js.map +1 -1
  126. package/dist/atlas/waves/models.d.ts +5 -6
  127. package/dist/atlas/waves/models.d.ts.map +1 -1
  128. package/dist/atlas/waves/models.js +7 -13
  129. package/dist/atlas/waves/models.js.map +1 -1
  130. package/dist/atlas/waves/numerics.d.ts.map +1 -1
  131. package/dist/atlas/waves/numerics.js +10 -3
  132. package/dist/atlas/waves/numerics.js.map +1 -1
  133. package/dist/atlas/witness-numeric.d.ts +30 -0
  134. package/dist/atlas/witness-numeric.d.ts.map +1 -1
  135. package/dist/atlas/witness-numeric.js +53 -0
  136. package/dist/atlas/witness-numeric.js.map +1 -1
  137. package/dist/atlas/witness-specs.d.ts.map +1 -1
  138. package/dist/atlas/witness-specs.js +19 -0
  139. package/dist/atlas/witness-specs.js.map +1 -1
  140. package/dist/atlas/witness-symbolic.d.ts +75 -3
  141. package/dist/atlas/witness-symbolic.d.ts.map +1 -1
  142. package/dist/atlas/witness-symbolic.js +116 -10
  143. package/dist/atlas/witness-symbolic.js.map +1 -1
  144. package/dist/bridges/catalog-load.d.ts.map +1 -1
  145. package/dist/bridges/catalog-load.js +13 -8
  146. package/dist/bridges/catalog-load.js.map +1 -1
  147. package/dist/bridges/catalog-types.d.ts +26 -2
  148. package/dist/bridges/catalog-types.d.ts.map +1 -1
  149. package/dist/bridges/catalog-types.js +11 -1
  150. package/dist/bridges/catalog-types.js.map +1 -1
  151. package/dist/bridges/evaluation-errors.d.ts +31 -1
  152. package/dist/bridges/evaluation-errors.d.ts.map +1 -1
  153. package/dist/bridges/evaluation-errors.js +20 -2
  154. package/dist/bridges/evaluation-errors.js.map +1 -1
  155. package/dist/bridges/evaluator-inputs.d.ts.map +1 -1
  156. package/dist/bridges/evaluator-inputs.js +7 -5
  157. package/dist/bridges/evaluator-inputs.js.map +1 -1
  158. package/dist/bridges/evaluators.d.ts.map +1 -1
  159. package/dist/bridges/evaluators.js +27 -12
  160. package/dist/bridges/evaluators.js.map +1 -1
  161. package/dist/bridges/expr-parse.d.ts +11 -0
  162. package/dist/bridges/expr-parse.d.ts.map +1 -1
  163. package/dist/bridges/expr-parse.js +14 -5
  164. package/dist/bridges/expr-parse.js.map +1 -1
  165. package/dist/bridges/holds.d.ts +35 -3
  166. package/dist/bridges/holds.d.ts.map +1 -1
  167. package/dist/bridges/holds.js +117 -23
  168. package/dist/bridges/holds.js.map +1 -1
  169. package/dist/bridges/notices.d.ts.map +1 -1
  170. package/dist/bridges/notices.js +5 -5
  171. package/dist/bridges/notices.js.map +1 -1
  172. package/dist/bridges/relation-eval.d.ts +4 -4
  173. package/dist/bridges/relation-eval.d.ts.map +1 -1
  174. package/dist/bridges/relation-eval.js +15 -16
  175. package/dist/bridges/relation-eval.js.map +1 -1
  176. package/dist/bridges/sensitivity.d.ts.map +1 -1
  177. package/dist/bridges/sensitivity.js +3 -3
  178. package/dist/bridges/sensitivity.js.map +1 -1
  179. package/dist/bridges/validity.d.ts +33 -0
  180. package/dist/bridges/validity.d.ts.map +1 -0
  181. package/dist/bridges/validity.js +67 -0
  182. package/dist/bridges/validity.js.map +1 -0
  183. package/dist/canonical/entries/atomic.js +1 -3
  184. package/dist/canonical/entries/atomic.js.map +1 -1
  185. package/dist/canonical/entries/condensed-matter.d.ts.map +1 -1
  186. package/dist/canonical/entries/condensed-matter.js +4 -5
  187. package/dist/canonical/entries/condensed-matter.js.map +1 -1
  188. package/dist/canonical/entries/dimensional-classics.d.ts.map +1 -1
  189. package/dist/canonical/entries/dimensional-classics.js +3 -4
  190. package/dist/canonical/entries/dimensional-classics.js.map +1 -1
  191. package/dist/canonical/entries/electromagnetism.d.ts.map +1 -1
  192. package/dist/canonical/entries/electromagnetism.js +4 -10
  193. package/dist/canonical/entries/electromagnetism.js.map +1 -1
  194. package/dist/canonical/entries/fluids-waves.d.ts.map +1 -1
  195. package/dist/canonical/entries/fluids-waves.js +3 -7
  196. package/dist/canonical/entries/fluids-waves.js.map +1 -1
  197. package/dist/canonical/entries/mechanics.d.ts.map +1 -1
  198. package/dist/canonical/entries/mechanics.js +4 -6
  199. package/dist/canonical/entries/mechanics.js.map +1 -1
  200. package/dist/canonical/entries/nonmonomial.d.ts.map +1 -1
  201. package/dist/canonical/entries/nonmonomial.js +9 -17
  202. package/dist/canonical/entries/nonmonomial.js.map +1 -1
  203. package/dist/canonical/entries/relativity.d.ts.map +1 -1
  204. package/dist/canonical/entries/relativity.js +6 -6
  205. package/dist/canonical/entries/relativity.js.map +1 -1
  206. package/dist/canonical/entries/thermo-nuclear-cosmo.d.ts.map +1 -1
  207. package/dist/canonical/entries/thermo-nuclear-cosmo.js +6 -10
  208. package/dist/canonical/entries/thermo-nuclear-cosmo.js.map +1 -1
  209. package/dist/canonical/fixed-points.d.ts +94 -0
  210. package/dist/canonical/fixed-points.d.ts.map +1 -0
  211. package/dist/canonical/fixed-points.js +81 -0
  212. package/dist/canonical/fixed-points.js.map +1 -0
  213. package/dist/canonical/linkage.d.ts.map +1 -1
  214. package/dist/canonical/linkage.js +25 -44
  215. package/dist/canonical/linkage.js.map +1 -1
  216. package/dist/canonical/normal-form.d.ts.map +1 -1
  217. package/dist/canonical/normal-form.js +5 -11
  218. package/dist/canonical/normal-form.js.map +1 -1
  219. package/dist/canonical/structural.d.ts +21 -21
  220. package/dist/canonical/structural.d.ts.map +1 -1
  221. package/dist/canonical/structural.js +40 -19
  222. package/dist/canonical/structural.js.map +1 -1
  223. package/dist/cases/catalog-checks.d.ts +10 -0
  224. package/dist/cases/catalog-checks.d.ts.map +1 -0
  225. package/dist/cases/catalog-checks.js +241 -0
  226. package/dist/cases/catalog-checks.js.map +1 -0
  227. package/dist/cases/catalog.d.ts +83 -0
  228. package/dist/cases/catalog.d.ts.map +1 -0
  229. package/dist/cases/catalog.js +118 -0
  230. package/dist/cases/catalog.js.map +1 -0
  231. package/dist/cases/engine.d.ts +13 -0
  232. package/dist/cases/engine.d.ts.map +1 -0
  233. package/dist/cases/engine.js +179 -0
  234. package/dist/cases/engine.js.map +1 -0
  235. package/dist/cases/index.d.ts.map +1 -1
  236. package/dist/cases/index.js +5 -7
  237. package/dist/cases/index.js.map +1 -1
  238. package/dist/cases/methods.d.ts +215 -0
  239. package/dist/cases/methods.d.ts.map +1 -0
  240. package/dist/cases/methods.js +743 -0
  241. package/dist/cases/methods.js.map +1 -0
  242. package/dist/cases/quadrature.d.ts +7 -9
  243. package/dist/cases/quadrature.d.ts.map +1 -1
  244. package/dist/cases/quadrature.js +28 -32
  245. package/dist/cases/quadrature.js.map +1 -1
  246. package/dist/cases/types.d.ts +12 -0
  247. package/dist/cases/types.d.ts.map +1 -1
  248. package/dist/cases/types.js.map +1 -1
  249. package/dist/cli/args.d.ts +25 -1
  250. package/dist/cli/args.d.ts.map +1 -1
  251. package/dist/cli/args.js +30 -8
  252. package/dist/cli/args.js.map +1 -1
  253. package/dist/cli/bindings.d.ts.map +1 -1
  254. package/dist/cli/bindings.js +5 -4
  255. package/dist/cli/bindings.js.map +1 -1
  256. package/dist/cli/command.d.ts +11 -1
  257. package/dist/cli/command.d.ts.map +1 -1
  258. package/dist/cli/command.js.map +1 -1
  259. package/dist/cli/commands/_atlas-map.d.ts +0 -9
  260. package/dist/cli/commands/_atlas-map.d.ts.map +1 -1
  261. package/dist/cli/commands/_atlas-map.js +8 -18
  262. package/dist/cli/commands/_atlas-map.js.map +1 -1
  263. package/dist/cli/commands/_atlas-route.d.ts.map +1 -1
  264. package/dist/cli/commands/_atlas-route.js +6 -2
  265. package/dist/cli/commands/_atlas-route.js.map +1 -1
  266. package/dist/cli/commands/_discovery-opts.d.ts +1 -0
  267. package/dist/cli/commands/_discovery-opts.d.ts.map +1 -1
  268. package/dist/cli/commands/_discovery-opts.js +9 -9
  269. package/dist/cli/commands/_discovery-opts.js.map +1 -1
  270. package/dist/cli/commands/atlas.d.ts.map +1 -1
  271. package/dist/cli/commands/atlas.js +8 -5
  272. package/dist/cli/commands/atlas.js.map +1 -1
  273. package/dist/cli/commands/audit.d.ts.map +1 -1
  274. package/dist/cli/commands/audit.js +8 -1
  275. package/dist/cli/commands/audit.js.map +1 -1
  276. package/dist/cli/commands/axes.d.ts.map +1 -1
  277. package/dist/cli/commands/axes.js +20 -1
  278. package/dist/cli/commands/axes.js.map +1 -1
  279. package/dist/cli/commands/confront.d.ts.map +1 -1
  280. package/dist/cli/commands/confront.js +8 -14
  281. package/dist/cli/commands/confront.js.map +1 -1
  282. package/dist/cli/commands/derive.d.ts.map +1 -1
  283. package/dist/cli/commands/derive.js +22 -22
  284. package/dist/cli/commands/derive.js.map +1 -1
  285. package/dist/cli/commands/discover.d.ts.map +1 -1
  286. package/dist/cli/commands/discover.js +122 -73
  287. package/dist/cli/commands/discover.js.map +1 -1
  288. package/dist/cli/commands/eval.d.ts.map +1 -1
  289. package/dist/cli/commands/eval.js +1 -0
  290. package/dist/cli/commands/eval.js.map +1 -1
  291. package/dist/cli/commands/evaluate.d.ts.map +1 -1
  292. package/dist/cli/commands/evaluate.js +67 -39
  293. package/dist/cli/commands/evaluate.js.map +1 -1
  294. package/dist/cli/commands/explain.d.ts.map +1 -1
  295. package/dist/cli/commands/explain.js +24 -3
  296. package/dist/cli/commands/explain.js.map +1 -1
  297. package/dist/cli/commands/ground.d.ts.map +1 -1
  298. package/dist/cli/commands/ground.js +7 -1
  299. package/dist/cli/commands/ground.js.map +1 -1
  300. package/dist/cli/commands/map.d.ts.map +1 -1
  301. package/dist/cli/commands/map.js +84 -11
  302. package/dist/cli/commands/map.js.map +1 -1
  303. package/dist/cli/commands/metric.d.ts.map +1 -1
  304. package/dist/cli/commands/metric.js +12 -9
  305. package/dist/cli/commands/metric.js.map +1 -1
  306. package/dist/cli/commands/path.d.ts +10 -0
  307. package/dist/cli/commands/path.d.ts.map +1 -1
  308. package/dist/cli/commands/path.js +25 -3
  309. package/dist/cli/commands/path.js.map +1 -1
  310. package/dist/cli/commands/probe.d.ts.map +1 -1
  311. package/dist/cli/commands/probe.js +59 -16
  312. package/dist/cli/commands/probe.js.map +1 -1
  313. package/dist/cli/commands/regime.d.ts.map +1 -1
  314. package/dist/cli/commands/regime.js +1 -0
  315. package/dist/cli/commands/regime.js.map +1 -1
  316. package/dist/cli/commands/retrieve.d.ts.map +1 -1
  317. package/dist/cli/commands/retrieve.js +1 -0
  318. package/dist/cli/commands/retrieve.js.map +1 -1
  319. package/dist/cli/commands/search.d.ts.map +1 -1
  320. package/dist/cli/commands/search.js +1 -0
  321. package/dist/cli/commands/search.js.map +1 -1
  322. package/dist/cli/commands/symbolic.d.ts.map +1 -1
  323. package/dist/cli/commands/symbolic.js +19 -28
  324. package/dist/cli/commands/symbolic.js.map +1 -1
  325. package/dist/cli/commands/testplan.d.ts.map +1 -1
  326. package/dist/cli/commands/testplan.js +4 -2
  327. package/dist/cli/commands/testplan.js.map +1 -1
  328. package/dist/cli/determination.d.ts +1 -0
  329. package/dist/cli/determination.d.ts.map +1 -1
  330. package/dist/cli/determination.js.map +1 -1
  331. package/dist/cli/expr-print.d.ts +0 -2
  332. package/dist/cli/expr-print.d.ts.map +1 -1
  333. package/dist/cli/expr-print.js +7 -31
  334. package/dist/cli/expr-print.js.map +1 -1
  335. package/dist/cli/flag-help.d.ts +1 -0
  336. package/dist/cli/flag-help.d.ts.map +1 -1
  337. package/dist/cli/flag-help.js +1 -0
  338. package/dist/cli/flag-help.js.map +1 -1
  339. package/dist/cli/graphs.d.ts +2 -0
  340. package/dist/cli/graphs.d.ts.map +1 -1
  341. package/dist/cli/graphs.js +1 -0
  342. package/dist/cli/graphs.js.map +1 -1
  343. package/dist/cli/main.d.ts +8 -0
  344. package/dist/cli/main.d.ts.map +1 -1
  345. package/dist/cli/main.js +19 -3
  346. package/dist/cli/main.js.map +1 -1
  347. package/dist/cli/numeric-flag.d.ts +12 -0
  348. package/dist/cli/numeric-flag.d.ts.map +1 -0
  349. package/dist/cli/numeric-flag.js +44 -0
  350. package/dist/cli/numeric-flag.js.map +1 -0
  351. package/dist/cli/output.d.ts +28 -0
  352. package/dist/cli/output.d.ts.map +1 -1
  353. package/dist/cli/output.js +23 -0
  354. package/dist/cli/output.js.map +1 -1
  355. package/dist/cli/record-reach.js +2 -2
  356. package/dist/cli/record-reach.js.map +1 -1
  357. package/dist/cli/record-tables.d.ts.map +1 -1
  358. package/dist/cli/record-tables.js +6 -5
  359. package/dist/cli/record-tables.js.map +1 -1
  360. package/dist/cli/record.d.ts +1 -5
  361. package/dist/cli/record.d.ts.map +1 -1
  362. package/dist/cli/record.js +9 -8
  363. package/dist/cli/record.js.map +1 -1
  364. package/dist/cli/search-index.d.ts.map +1 -1
  365. package/dist/cli/search-index.js +7 -6
  366. package/dist/cli/search-index.js.map +1 -1
  367. package/dist/cli/statuses.d.ts +0 -2
  368. package/dist/cli/statuses.d.ts.map +1 -1
  369. package/dist/cli/statuses.js +12 -9
  370. package/dist/cli/statuses.js.map +1 -1
  371. package/dist/cli/stored-results.d.ts +7 -0
  372. package/dist/cli/stored-results.d.ts.map +1 -0
  373. package/dist/cli/stored-results.js +23 -0
  374. package/dist/cli/stored-results.js.map +1 -0
  375. package/dist/cli/version.d.ts +1 -0
  376. package/dist/cli/version.d.ts.map +1 -1
  377. package/dist/cli/version.js +8 -5
  378. package/dist/cli/version.js.map +1 -1
  379. package/dist/cli-api.d.ts +36 -5
  380. package/dist/cli-api.d.ts.map +1 -1
  381. package/dist/cli-api.js +30 -4
  382. package/dist/cli-api.js.map +1 -1
  383. package/dist/composition/algebraic-equivalence.d.ts +43 -0
  384. package/dist/composition/algebraic-equivalence.d.ts.map +1 -0
  385. package/dist/composition/algebraic-equivalence.js +115 -0
  386. package/dist/composition/algebraic-equivalence.js.map +1 -0
  387. package/dist/composition/axes.d.ts +0 -6
  388. package/dist/composition/axes.d.ts.map +1 -1
  389. package/dist/composition/axes.js +6 -6
  390. package/dist/composition/axes.js.map +1 -1
  391. package/dist/composition/axis-audit.d.ts +47 -20
  392. package/dist/composition/axis-audit.d.ts.map +1 -1
  393. package/dist/composition/axis-audit.js +82 -9
  394. package/dist/composition/axis-audit.js.map +1 -1
  395. package/dist/composition/bridge-analysis.d.ts +17 -0
  396. package/dist/composition/bridge-analysis.d.ts.map +1 -1
  397. package/dist/composition/bridge-analysis.js +102 -55
  398. package/dist/composition/bridge-analysis.js.map +1 -1
  399. package/dist/composition/canonical-compare.d.ts +40 -0
  400. package/dist/composition/canonical-compare.d.ts.map +1 -1
  401. package/dist/composition/canonical-compare.js +122 -24
  402. package/dist/composition/canonical-compare.js.map +1 -1
  403. package/dist/composition/canonical-graph.d.ts +3 -3
  404. package/dist/composition/canonical-graph.d.ts.map +1 -1
  405. package/dist/composition/canonical-graph.js +11 -38
  406. package/dist/composition/canonical-graph.js.map +1 -1
  407. package/dist/composition/canonical-json.js +2 -2
  408. package/dist/composition/canonical-json.js.map +1 -1
  409. package/dist/composition/catalog-graph.d.ts.map +1 -1
  410. package/dist/composition/catalog-graph.js +2 -5
  411. package/dist/composition/catalog-graph.js.map +1 -1
  412. package/dist/composition/chain-candidate.d.ts +8 -0
  413. package/dist/composition/chain-candidate.d.ts.map +1 -1
  414. package/dist/composition/chain-candidate.js +9 -2
  415. package/dist/composition/chain-candidate.js.map +1 -1
  416. package/dist/composition/chain-match.d.ts +6 -3
  417. package/dist/composition/chain-match.d.ts.map +1 -1
  418. package/dist/composition/chain-match.js +4 -1
  419. package/dist/composition/chain-match.js.map +1 -1
  420. package/dist/composition/chain-result.d.ts.map +1 -1
  421. package/dist/composition/chain-result.js +2 -14
  422. package/dist/composition/chain-result.js.map +1 -1
  423. package/dist/composition/compose-symbolic.d.ts.map +1 -1
  424. package/dist/composition/compose-symbolic.js +3 -2
  425. package/dist/composition/compose-symbolic.js.map +1 -1
  426. package/dist/composition/compose.d.ts.map +1 -1
  427. package/dist/composition/compose.js +13 -5
  428. package/dist/composition/compose.js.map +1 -1
  429. package/dist/composition/composition-recovery.d.ts.map +1 -1
  430. package/dist/composition/composition-recovery.js +4 -7
  431. package/dist/composition/composition-recovery.js.map +1 -1
  432. package/dist/composition/consequence.d.ts +15 -5
  433. package/dist/composition/consequence.d.ts.map +1 -1
  434. package/dist/composition/consequence.js +6 -4
  435. package/dist/composition/consequence.js.map +1 -1
  436. package/dist/composition/discovery.d.ts +129 -9
  437. package/dist/composition/discovery.d.ts.map +1 -1
  438. package/dist/composition/discovery.js +171 -67
  439. package/dist/composition/discovery.js.map +1 -1
  440. package/dist/composition/edge.d.ts +21 -2
  441. package/dist/composition/edge.d.ts.map +1 -1
  442. package/dist/composition/edge.js +23 -1
  443. package/dist/composition/edge.js.map +1 -1
  444. package/dist/composition/enumerate.d.ts.map +1 -1
  445. package/dist/composition/enumerate.js +18 -3
  446. package/dist/composition/enumerate.js.map +1 -1
  447. package/dist/composition/evaluate-relation.d.ts +35 -11
  448. package/dist/composition/evaluate-relation.d.ts.map +1 -1
  449. package/dist/composition/evaluate-relation.js +60 -39
  450. package/dist/composition/evaluate-relation.js.map +1 -1
  451. package/dist/composition/explain.d.ts +3 -12
  452. package/dist/composition/explain.d.ts.map +1 -1
  453. package/dist/composition/explain.js +7 -20
  454. package/dist/composition/explain.js.map +1 -1
  455. package/dist/composition/expr-eval.d.ts +1 -1
  456. package/dist/composition/expr-eval.d.ts.map +1 -1
  457. package/dist/composition/expr-eval.js +6 -15
  458. package/dist/composition/expr-eval.js.map +1 -1
  459. package/dist/composition/expr-simplify.d.ts +26 -14
  460. package/dist/composition/expr-simplify.d.ts.map +1 -1
  461. package/dist/composition/expr-simplify.js +64 -72
  462. package/dist/composition/expr-simplify.js.map +1 -1
  463. package/dist/composition/formula-shape.d.ts +23 -4
  464. package/dist/composition/formula-shape.d.ts.map +1 -1
  465. package/dist/composition/formula-shape.js +57 -17
  466. package/dist/composition/formula-shape.js.map +1 -1
  467. package/dist/composition/graph-structure.d.ts +98 -0
  468. package/dist/composition/graph-structure.d.ts.map +1 -0
  469. package/dist/composition/graph-structure.js +167 -0
  470. package/dist/composition/graph-structure.js.map +1 -0
  471. package/dist/composition/graph-viz-svg.d.ts.map +1 -1
  472. package/dist/composition/graph-viz-svg.js +1 -1
  473. package/dist/composition/graph-viz-svg.js.map +1 -1
  474. package/dist/composition/graph-viz.d.ts.map +1 -1
  475. package/dist/composition/graph-viz.js +8 -37
  476. package/dist/composition/graph-viz.js.map +1 -1
  477. package/dist/composition/grounding.d.ts.map +1 -1
  478. package/dist/composition/grounding.js +19 -7
  479. package/dist/composition/grounding.js.map +1 -1
  480. package/dist/composition/identifiability.d.ts +91 -4
  481. package/dist/composition/identifiability.d.ts.map +1 -1
  482. package/dist/composition/identifiability.js +363 -6
  483. package/dist/composition/identifiability.js.map +1 -1
  484. package/dist/composition/index.d.ts +8 -4
  485. package/dist/composition/index.d.ts.map +1 -1
  486. package/dist/composition/index.js +3 -2
  487. package/dist/composition/index.js.map +1 -1
  488. package/dist/composition/mathts-quiet.d.ts +7 -8
  489. package/dist/composition/mathts-quiet.d.ts.map +1 -1
  490. package/dist/composition/mathts-quiet.js +7 -16
  491. package/dist/composition/mathts-quiet.js.map +1 -1
  492. package/dist/composition/mathts-scalar-symbols.d.ts.map +1 -1
  493. package/dist/composition/mathts-scalar-symbols.js +2 -1
  494. package/dist/composition/mathts-scalar-symbols.js.map +1 -1
  495. package/dist/composition/own-equation-magnitude.d.ts +95 -0
  496. package/dist/composition/own-equation-magnitude.d.ts.map +1 -0
  497. package/dist/composition/own-equation-magnitude.js +270 -0
  498. package/dist/composition/own-equation-magnitude.js.map +1 -0
  499. package/dist/composition/probe/backend-protocol.d.ts +3 -0
  500. package/dist/composition/probe/backend-protocol.d.ts.map +1 -1
  501. package/dist/composition/probe/backend-protocol.js.map +1 -1
  502. package/dist/composition/probe/candidate-store.d.ts +1 -0
  503. package/dist/composition/probe/candidate-store.d.ts.map +1 -1
  504. package/dist/composition/probe/candidate-store.js +1 -0
  505. package/dist/composition/probe/candidate-store.js.map +1 -1
  506. package/dist/composition/probe/corpus.d.ts +8 -4
  507. package/dist/composition/probe/corpus.d.ts.map +1 -1
  508. package/dist/composition/probe/corpus.js +23 -12
  509. package/dist/composition/probe/corpus.js.map +1 -1
  510. package/dist/composition/probe/dataset.d.ts +18 -0
  511. package/dist/composition/probe/dataset.d.ts.map +1 -1
  512. package/dist/composition/probe/dataset.js +95 -50
  513. package/dist/composition/probe/dataset.js.map +1 -1
  514. package/dist/composition/probe/experiment-design.d.ts +7 -1
  515. package/dist/composition/probe/experiment-design.d.ts.map +1 -1
  516. package/dist/composition/probe/experiment-design.js +44 -24
  517. package/dist/composition/probe/experiment-design.js.map +1 -1
  518. package/dist/composition/probe/falsify.d.ts +2 -0
  519. package/dist/composition/probe/falsify.d.ts.map +1 -1
  520. package/dist/composition/probe/falsify.js +2 -0
  521. package/dist/composition/probe/falsify.js.map +1 -1
  522. package/dist/composition/probe/fit.d.ts +7 -0
  523. package/dist/composition/probe/fit.d.ts.map +1 -1
  524. package/dist/composition/probe/fit.js +46 -22
  525. package/dist/composition/probe/fit.js.map +1 -1
  526. package/dist/composition/probe/frontier.d.ts.map +1 -1
  527. package/dist/composition/probe/frontier.js +33 -15
  528. package/dist/composition/probe/frontier.js.map +1 -1
  529. package/dist/composition/probe/generator.d.ts +30 -1
  530. package/dist/composition/probe/generator.d.ts.map +1 -1
  531. package/dist/composition/probe/generator.js +58 -36
  532. package/dist/composition/probe/generator.js.map +1 -1
  533. package/dist/composition/probe/index.d.ts +14 -0
  534. package/dist/composition/probe/index.d.ts.map +1 -1
  535. package/dist/composition/probe/index.js +6 -0
  536. package/dist/composition/probe/index.js.map +1 -1
  537. package/dist/composition/probe/limits.d.ts +25 -1
  538. package/dist/composition/probe/limits.d.ts.map +1 -1
  539. package/dist/composition/probe/limits.js +53 -11
  540. package/dist/composition/probe/limits.js.map +1 -1
  541. package/dist/composition/probe/pipeline.d.ts +5 -0
  542. package/dist/composition/probe/pipeline.d.ts.map +1 -1
  543. package/dist/composition/probe/pipeline.js +73 -24
  544. package/dist/composition/probe/pipeline.js.map +1 -1
  545. package/dist/composition/probe/power-law.d.ts +121 -0
  546. package/dist/composition/probe/power-law.d.ts.map +1 -0
  547. package/dist/composition/probe/power-law.js +251 -0
  548. package/dist/composition/probe/power-law.js.map +1 -0
  549. package/dist/composition/probe/problem.d.ts +8 -4
  550. package/dist/composition/probe/problem.d.ts.map +1 -1
  551. package/dist/composition/probe/problem.js +177 -49
  552. package/dist/composition/probe/problem.js.map +1 -1
  553. package/dist/composition/probe/report.js +1 -1
  554. package/dist/composition/probe/report.js.map +1 -1
  555. package/dist/composition/probe/residual.d.ts +7 -1
  556. package/dist/composition/probe/residual.d.ts.map +1 -1
  557. package/dist/composition/probe/residual.js +10 -7
  558. package/dist/composition/probe/residual.js.map +1 -1
  559. package/dist/composition/probe/run-manifest.d.ts +1 -0
  560. package/dist/composition/probe/run-manifest.d.ts.map +1 -1
  561. package/dist/composition/probe/run-manifest.js.map +1 -1
  562. package/dist/composition/probe/scalar-search.d.ts +50 -0
  563. package/dist/composition/probe/scalar-search.d.ts.map +1 -0
  564. package/dist/composition/probe/scalar-search.js +169 -0
  565. package/dist/composition/probe/scalar-search.js.map +1 -0
  566. package/dist/composition/probe/scoring.d.ts +1 -0
  567. package/dist/composition/probe/scoring.d.ts.map +1 -1
  568. package/dist/composition/probe/scoring.js.map +1 -1
  569. package/dist/composition/probe/structure.d.ts +82 -17
  570. package/dist/composition/probe/structure.d.ts.map +1 -1
  571. package/dist/composition/probe/structure.js +129 -55
  572. package/dist/composition/probe/structure.js.map +1 -1
  573. package/dist/composition/probe/study.d.ts +31 -9
  574. package/dist/composition/probe/study.d.ts.map +1 -1
  575. package/dist/composition/probe/study.js +235 -184
  576. package/dist/composition/probe/study.js.map +1 -1
  577. package/dist/composition/probe/t-tail.d.ts +16 -0
  578. package/dist/composition/probe/t-tail.d.ts.map +1 -0
  579. package/dist/composition/probe/t-tail.js +29 -0
  580. package/dist/composition/probe/t-tail.js.map +1 -0
  581. package/dist/composition/probe/types.d.ts +3 -0
  582. package/dist/composition/probe/types.d.ts.map +1 -1
  583. package/dist/composition/probe/types.js.map +1 -1
  584. package/dist/composition/proposed-bridges.d.ts +52 -12
  585. package/dist/composition/proposed-bridges.d.ts.map +1 -1
  586. package/dist/composition/proposed-bridges.js +107 -60
  587. package/dist/composition/proposed-bridges.js.map +1 -1
  588. package/dist/composition/quantity-clusters.d.ts +48 -0
  589. package/dist/composition/quantity-clusters.d.ts.map +1 -0
  590. package/dist/composition/quantity-clusters.js +98 -0
  591. package/dist/composition/quantity-clusters.js.map +1 -0
  592. package/dist/composition/rational-exponent.d.ts +40 -0
  593. package/dist/composition/rational-exponent.d.ts.map +1 -0
  594. package/dist/composition/rational-exponent.js +65 -0
  595. package/dist/composition/rational-exponent.js.map +1 -0
  596. package/dist/composition/representative-values.d.ts +22 -0
  597. package/dist/composition/representative-values.d.ts.map +1 -1
  598. package/dist/composition/representative-values.js +29 -0
  599. package/dist/composition/representative-values.js.map +1 -1
  600. package/dist/composition/retrodiction.d.ts +15 -0
  601. package/dist/composition/retrodiction.d.ts.map +1 -1
  602. package/dist/composition/retrodiction.js +12 -4
  603. package/dist/composition/retrodiction.js.map +1 -1
  604. package/dist/composition/user-equation.d.ts +1 -0
  605. package/dist/composition/user-equation.d.ts.map +1 -1
  606. package/dist/composition/user-equation.js +3 -2
  607. package/dist/composition/user-equation.js.map +1 -1
  608. package/dist/core/assignment.d.ts +19 -0
  609. package/dist/core/assignment.d.ts.map +1 -0
  610. package/dist/core/assignment.js +19 -0
  611. package/dist/core/assignment.js.map +1 -0
  612. package/dist/core/compare.d.ts +32 -0
  613. package/dist/core/compare.d.ts.map +1 -0
  614. package/dist/core/compare.js +46 -0
  615. package/dist/core/compare.js.map +1 -0
  616. package/dist/core/constants.d.ts +42 -41
  617. package/dist/core/constants.d.ts.map +1 -1
  618. package/dist/core/constants.js +71 -51
  619. package/dist/core/constants.js.map +1 -1
  620. package/dist/core/data-file.d.ts +7 -0
  621. package/dist/core/data-file.d.ts.map +1 -1
  622. package/dist/core/data-file.js +17 -0
  623. package/dist/core/data-file.js.map +1 -1
  624. package/dist/core/format.d.ts +36 -0
  625. package/dist/core/format.d.ts.map +1 -0
  626. package/dist/core/format.js +39 -0
  627. package/dist/core/format.js.map +1 -0
  628. package/dist/core/hash.d.ts +14 -0
  629. package/dist/core/hash.d.ts.map +1 -0
  630. package/dist/core/hash.js +17 -0
  631. package/dist/core/hash.js.map +1 -0
  632. package/dist/core/json-schema.d.ts +2 -0
  633. package/dist/core/json-schema.d.ts.map +1 -1
  634. package/dist/core/json-schema.js +14 -13
  635. package/dist/core/json-schema.js.map +1 -1
  636. package/dist/core/labeled-tensor.d.ts.map +1 -1
  637. package/dist/core/labeled-tensor.js +0 -8
  638. package/dist/core/labeled-tensor.js.map +1 -1
  639. package/dist/core/mathts-read.d.ts +25 -0
  640. package/dist/core/mathts-read.d.ts.map +1 -0
  641. package/dist/core/mathts-read.js +51 -0
  642. package/dist/core/mathts-read.js.map +1 -0
  643. package/dist/core/tensor.d.ts.map +1 -1
  644. package/dist/core/tensor.js +24 -0
  645. package/dist/core/tensor.js.map +1 -1
  646. package/dist/core/types.d.ts +5 -5
  647. package/dist/diff/bridge-ast-gradient.d.ts +27 -23
  648. package/dist/diff/bridge-ast-gradient.d.ts.map +1 -1
  649. package/dist/diff/bridge-ast-gradient.js +75 -173
  650. package/dist/diff/bridge-ast-gradient.js.map +1 -1
  651. package/dist/diff/bridge-gradient.d.ts +19 -6
  652. package/dist/diff/bridge-gradient.d.ts.map +1 -1
  653. package/dist/diff/bridge-gradient.js +19 -11
  654. package/dist/diff/bridge-gradient.js.map +1 -1
  655. package/dist/diff/bridge-specs.d.ts.map +1 -1
  656. package/dist/diff/bridge-specs.js +3 -0
  657. package/dist/diff/bridge-specs.js.map +1 -1
  658. package/dist/dimensional/algebra.d.ts +18 -0
  659. package/dist/dimensional/algebra.d.ts.map +1 -1
  660. package/dist/dimensional/algebra.js +41 -1
  661. package/dist/dimensional/algebra.js.map +1 -1
  662. package/dist/dimensional/ast-builders.d.ts +7 -0
  663. package/dist/dimensional/ast-builders.d.ts.map +1 -1
  664. package/dist/dimensional/ast-builders.js +11 -0
  665. package/dist/dimensional/ast-builders.js.map +1 -1
  666. package/dist/dimensional/ast-leaves.d.ts +81 -0
  667. package/dist/dimensional/ast-leaves.d.ts.map +1 -0
  668. package/dist/dimensional/ast-leaves.js +146 -0
  669. package/dist/dimensional/ast-leaves.js.map +1 -0
  670. package/dist/dimensional/ast-types.d.ts +15 -0
  671. package/dist/dimensional/ast-types.d.ts.map +1 -1
  672. package/dist/dimensional/ast-types.js.map +1 -1
  673. package/dist/dimensional/buckingham.d.ts.map +1 -1
  674. package/dist/dimensional/buckingham.js +15 -27
  675. package/dist/dimensional/buckingham.js.map +1 -1
  676. package/dist/dimensional/constant-rows.js +9 -9
  677. package/dist/dimensional/constant-rows.js.map +1 -1
  678. package/dist/dimensional/curvature-composite.d.ts +1 -1
  679. package/dist/dimensional/curvature-composite.js.map +1 -1
  680. package/dist/dimensional/dimension-inference.d.ts.map +1 -1
  681. package/dist/dimensional/dimension-inference.js +1 -2
  682. package/dist/dimensional/dimension-inference.js.map +1 -1
  683. package/dist/dimensional/errors.d.ts +1 -1
  684. package/dist/dimensional/errors.d.ts.map +1 -1
  685. package/dist/dimensional/errors.js +1 -15
  686. package/dist/dimensional/errors.js.map +1 -1
  687. package/dist/dimensional/exact-scale.d.ts +24 -11
  688. package/dist/dimensional/exact-scale.d.ts.map +1 -1
  689. package/dist/dimensional/exact-scale.js +122 -130
  690. package/dist/dimensional/exact-scale.js.map +1 -1
  691. package/dist/dimensional/gauge-field.d.ts.map +1 -1
  692. package/dist/dimensional/gauge-field.js +2 -2
  693. package/dist/dimensional/gauge-field.js.map +1 -1
  694. package/dist/dimensional/hyphen-names.d.ts +12 -2
  695. package/dist/dimensional/hyphen-names.d.ts.map +1 -1
  696. package/dist/dimensional/hyphen-names.js +44 -19
  697. package/dist/dimensional/hyphen-names.js.map +1 -1
  698. package/dist/dimensional/mathts-unit-delegation.d.ts +29 -0
  699. package/dist/dimensional/mathts-unit-delegation.d.ts.map +1 -0
  700. package/dist/dimensional/mathts-unit-delegation.js +187 -0
  701. package/dist/dimensional/mathts-unit-delegation.js.map +1 -0
  702. package/dist/dimensional/mathts-unit-wrapper.d.ts +33 -0
  703. package/dist/dimensional/mathts-unit-wrapper.d.ts.map +1 -0
  704. package/dist/dimensional/mathts-unit-wrapper.js +190 -0
  705. package/dist/dimensional/mathts-unit-wrapper.js.map +1 -0
  706. package/dist/dimensional/metric.d.ts.map +1 -1
  707. package/dist/dimensional/metric.js +0 -1
  708. package/dist/dimensional/metric.js.map +1 -1
  709. package/dist/dimensional/scalar-lowering.d.ts +21 -0
  710. package/dist/dimensional/scalar-lowering.d.ts.map +1 -0
  711. package/dist/dimensional/scalar-lowering.js +45 -0
  712. package/dist/dimensional/scalar-lowering.js.map +1 -0
  713. package/dist/dimensional/symbolic-constants.d.ts +9 -0
  714. package/dist/dimensional/symbolic-constants.d.ts.map +1 -1
  715. package/dist/dimensional/symbolic-constants.js +13 -1
  716. package/dist/dimensional/symbolic-constants.js.map +1 -1
  717. package/dist/dimensional/types.d.ts +36 -0
  718. package/dist/dimensional/types.d.ts.map +1 -1
  719. package/dist/dimensional/types.js +45 -7
  720. package/dist/dimensional/types.js.map +1 -1
  721. package/dist/dimensional/unit-data.d.ts +5 -1
  722. package/dist/dimensional/unit-data.d.ts.map +1 -1
  723. package/dist/dimensional/unit-data.js +30 -6
  724. package/dist/dimensional/unit-data.js.map +1 -1
  725. package/dist/dimensional/units.d.ts +2 -0
  726. package/dist/dimensional/units.d.ts.map +1 -1
  727. package/dist/dimensional/units.js +59 -3
  728. package/dist/dimensional/units.js.map +1 -1
  729. package/dist/dimensional/validator.d.ts +2 -0
  730. package/dist/dimensional/validator.d.ts.map +1 -1
  731. package/dist/dimensional/validator.js.map +1 -1
  732. package/dist/index.d.ts +9 -3
  733. package/dist/index.d.ts.map +1 -1
  734. package/dist/index.js +10 -4
  735. package/dist/index.js.map +1 -1
  736. package/dist/numerical/christoffel-flat.d.ts.map +1 -1
  737. package/dist/numerical/christoffel-flat.js +3 -2
  738. package/dist/numerical/christoffel-flat.js.map +1 -1
  739. package/dist/numerical/connection-lowering-helpers.d.ts +3 -1
  740. package/dist/numerical/connection-lowering-helpers.d.ts.map +1 -1
  741. package/dist/numerical/connection-lowering-helpers.js +11 -15
  742. package/dist/numerical/connection-lowering-helpers.js.map +1 -1
  743. package/dist/numerical/covariant-eikonal.d.ts.map +1 -1
  744. package/dist/numerical/covariant-eikonal.js +34 -11
  745. package/dist/numerical/covariant-eikonal.js.map +1 -1
  746. package/dist/numerical/curvature-lowering-helpers.js +3 -2
  747. package/dist/numerical/curvature-lowering-helpers.js.map +1 -1
  748. package/dist/numerical/errors.d.ts.map +1 -1
  749. package/dist/numerical/errors.js +0 -3
  750. package/dist/numerical/errors.js.map +1 -1
  751. package/dist/numerical/finite-difference.d.ts +22 -0
  752. package/dist/numerical/finite-difference.d.ts.map +1 -0
  753. package/dist/numerical/finite-difference.js +27 -0
  754. package/dist/numerical/finite-difference.js.map +1 -0
  755. package/dist/numerical/geodesic-integrator.d.ts.map +1 -1
  756. package/dist/numerical/geodesic-integrator.js +22 -14
  757. package/dist/numerical/geodesic-integrator.js.map +1 -1
  758. package/dist/numerical/geometrized.d.ts.map +1 -1
  759. package/dist/numerical/geometrized.js +0 -1
  760. package/dist/numerical/geometrized.js.map +1 -1
  761. package/dist/numerical/mathts-engine.d.ts.map +1 -1
  762. package/dist/numerical/mathts-engine.js +10 -24
  763. package/dist/numerical/mathts-engine.js.map +1 -1
  764. package/dist/numerical/metric-inverse.d.ts.map +1 -1
  765. package/dist/numerical/metric-inverse.js +83 -46
  766. package/dist/numerical/metric-inverse.js.map +1 -1
  767. package/dist/numerical/null-ray-integrator.d.ts +2 -1
  768. package/dist/numerical/null-ray-integrator.d.ts.map +1 -1
  769. package/dist/numerical/null-ray-integrator.js +12 -12
  770. package/dist/numerical/null-ray-integrator.js.map +1 -1
  771. package/dist/numerical/painleve-gullstrand-metric.js +2 -2
  772. package/dist/numerical/painleve-gullstrand-metric.js.map +1 -1
  773. package/dist/numerical/pderiv.d.ts.map +1 -1
  774. package/dist/numerical/pderiv.js +2 -6
  775. package/dist/numerical/pderiv.js.map +1 -1
  776. package/dist/numerical/perihelion-finder.d.ts +0 -36
  777. package/dist/numerical/perihelion-finder.d.ts.map +1 -1
  778. package/dist/numerical/perihelion-finder.js +41 -87
  779. package/dist/numerical/perihelion-finder.js.map +1 -1
  780. package/dist/numerical/quadrature.d.ts.map +1 -1
  781. package/dist/numerical/quadrature.js +11 -13
  782. package/dist/numerical/quadrature.js.map +1 -1
  783. package/dist/numerical/rk4-trajectory.d.ts +10 -0
  784. package/dist/numerical/rk4-trajectory.d.ts.map +1 -0
  785. package/dist/numerical/rk4-trajectory.js +37 -0
  786. package/dist/numerical/rk4-trajectory.js.map +1 -0
  787. package/dist/numerical/schwarzschild.d.ts +14 -0
  788. package/dist/numerical/schwarzschild.d.ts.map +1 -0
  789. package/dist/numerical/schwarzschild.js +17 -0
  790. package/dist/numerical/schwarzschild.js.map +1 -0
  791. package/dist/numerical/spacetime-metrics.d.ts +12 -0
  792. package/dist/numerical/spacetime-metrics.d.ts.map +1 -1
  793. package/dist/numerical/spacetime-metrics.js +72 -56
  794. package/dist/numerical/spacetime-metrics.js.map +1 -1
  795. package/dist/numerical/statistics.d.ts +24 -0
  796. package/dist/numerical/statistics.d.ts.map +1 -0
  797. package/dist/numerical/statistics.js +52 -0
  798. package/dist/numerical/statistics.js.map +1 -0
  799. package/dist/numerical/strides.d.ts +3 -2
  800. package/dist/numerical/strides.d.ts.map +1 -1
  801. package/dist/numerical/strides.js +3 -10
  802. package/dist/numerical/strides.js.map +1 -1
  803. package/dist/numerical/tensor-engine.d.ts +21 -0
  804. package/dist/numerical/tensor-engine.d.ts.map +1 -1
  805. package/dist/numerical/tensor-engine.js +12 -0
  806. package/dist/numerical/tensor-engine.js.map +1 -1
  807. package/dist/relations/regime.d.ts +10 -0
  808. package/dist/relations/regime.d.ts.map +1 -1
  809. package/dist/relations/regime.js +18 -1
  810. package/dist/relations/regime.js.map +1 -1
  811. package/package.json +9 -12
  812. package/dist/cases/brownian-sphere.d.ts +0 -68
  813. package/dist/cases/brownian-sphere.d.ts.map +0 -1
  814. package/dist/cases/brownian-sphere.js +0 -354
  815. package/dist/cases/brownian-sphere.js.map +0 -1
  816. package/dist/cases/damped-resonator.d.ts +0 -23
  817. package/dist/cases/damped-resonator.d.ts.map +0 -1
  818. package/dist/cases/damped-resonator.js +0 -224
  819. package/dist/cases/damped-resonator.js.map +0 -1
  820. package/dist/cases/kepler-rv.d.ts +0 -13
  821. package/dist/cases/kepler-rv.d.ts.map +0 -1
  822. package/dist/cases/kepler-rv.js +0 -172
  823. package/dist/cases/kepler-rv.js.map +0 -1
  824. package/dist/cases/lumped-cooling.d.ts +0 -46
  825. package/dist/cases/lumped-cooling.d.ts.map +0 -1
  826. package/dist/cases/lumped-cooling.js +0 -261
  827. package/dist/cases/lumped-cooling.js.map +0 -1
  828. package/dist/cases/resistor-noise.d.ts +0 -14
  829. package/dist/cases/resistor-noise.d.ts.map +0 -1
  830. package/dist/cases/resistor-noise.js +0 -215
  831. package/dist/cases/resistor-noise.js.map +0 -1
  832. package/dist/cases/skin-depth.d.ts +0 -21
  833. package/dist/cases/skin-depth.d.ts.map +0 -1
  834. package/dist/cases/skin-depth.js +0 -174
  835. package/dist/cases/skin-depth.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"expr-print.js","sourceRoot":"","sources":["../../src/cli/expr-print.ts"],"names":[],"mappings":"AAkBA,MAAM,OAAO,GAAe,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;AAElF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAqC;IAC1D,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,QAAQ;IACf,GAAG,EAAE,OAAO;CACb,CAAC;AACF,MAAM,IAAI,GAAe,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;AAEjG;;;;GAIG;AACH,SAAS,UAAU,CAAC,CAAW,EAAE,KAAiB;IAChD,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACrD,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI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,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpF,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACrD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9G,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3C,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;AAChF,CAAC","sourcesContent":["/**\n * The three printed forms of a scalar composed AST (`upt symbolic`, audit F12 and I10):\n *\n * - DISPLAY: plain text for the reader, `·` for a product.\n * - EVAL: a formula `upt eval` parses, every named factor spelled so it evaluates (`8pi` → `(8*pi)`).\n * - LATEX: `\\frac` for every division, `\\cdot` for a product, braces for every exponent.\n *\n * Only `symbol` and `op` nodes are printed; any other node gives `null`, never a guess.\n */\nimport type { ExprNode } from '../dimensional/validator.js';\nimport type { Dimension } from '../dimensional/types.js';\n\ninterface PrintStyle {\n readonly times: string;\n readonly divide: string;\n readonly symbol: (name: string) => string;\n}\n\nconst DISPLAY: PrintStyle = { times: '·', divide: ' / ', symbol: (name) => name };\n\n/** Named numeric stubs spelled so `upt eval` parses them. */\nexport const EVAL_STUBS: Readonly<Record<string, string>> = {\n '8pi': '(8*pi)',\n '4pi': '(4*pi)',\n '2pi': '(2*pi)',\n ln2: 'ln(2)',\n};\nconst EVAL: PrintStyle = { times: '*', divide: '/', symbol: (name) => EVAL_STUBS[name] ?? name };\n\n/**\n * Precedence-aware printing. Every divisor that is not a bare power is\n * grouped, so `a / (b·c)` never prints as `a / b·c` (audit F12); a quotient\n * inside a product or as a dividend is grouped too, for the reader.\n */\nfunction printInfix(n: ExprNode, style: PrintStyle): string | null {\n if (n.kind === 'symbol') return style.symbol(n.name);\n if (n.kind !== 'op') return null;\n const parts: string[] = [];\n for (let i = 0; i < n.args.length; i++) {\n const a = n.args[i]!;\n const s = printInfix(a, style);\n if (s === null) return null;\n const aOp = a.kind === 'op' ? a.op : null;\n const group =\n aOp !== null &&\n (n.op === '^'\n ? true\n : n.op === '/'\n ? i === 0\n ? aOp === '+' || aOp === '-' || aOp === '/'\n : aOp !== '^'\n : n.op === '*'\n ? aOp === '+' || aOp === '-' || aOp === '/'\n : n.op === '-' && i > 0 && (aOp === '+' || aOp === '-'));\n parts.push(group ? `(${s})` : s);\n }\n const sep = n.op === '*' ? style.times : n.op === '/' ? style.divide : n.op === '^' ? '^' : ` ${n.op} `;\n return parts.join(sep);\n}\n\nexport const printDisplay = (n: ExprNode): string | null => printInfix(n, DISPLAY);\nexport const printEval = (n: ExprNode): string | null => printInfix(n, EVAL);\n\n/** LaTeX for the constant and stub names; any other name is spelled by {@link latexName}. */\nconst LATEX_NAMES: Readonly<Record<string, string>> = {\n hbar: '\\\\hbar',\n k_B: 'k_{\\\\mathrm{B}}',\n '8pi': '8\\\\pi',\n '4pi': '4\\\\pi',\n '2pi': '2\\\\pi',\n ln2: '\\\\ln 2',\n pi: '\\\\pi',\n epsilon_0: '\\\\varepsilon_{0}',\n sigma_sb: '\\\\sigma_{\\\\mathrm{SB}}',\n};\n\n/** A name in LaTeX: one letter or a number as is, a hyphenated name as text, otherwise upright. */\nexport function latexName(name: string): string {\n const known = LATEX_NAMES[name];\n if (known !== undefined) return known;\n if (/^[A-Za-z]$/.test(name) || Number.isFinite(Number(name))) return name;\n return name.includes('-') ? `\\\\text{${name}}` : `\\\\mathrm{${name.replace(/_/g, '\\\\_')}}`;\n}\n\n/** The AST in LaTeX; `null` for a node other than `symbol` or `op`. */\nexport function printLatex(n: ExprNode): string | null {\n if (n.kind === 'symbol') return latexName(n.name);\n if (n.kind !== 'op') return null;\n const args: string[] = [];\n for (const a of n.args) {\n const s = printLatex(a);\n if (s === null) return null;\n args.push(s);\n }\n const isOp = (a: ExprNode, ...ops: string[]): boolean => a.kind === 'op' && ops.includes(a.op);\n const paren = (s: string): string => `\\\\left(${s}\\\\right)`;\n switch (n.op) {\n case '/':\n return args.slice(1).reduce((num, den) => `\\\\frac{${num}}{${den}}`, args[0]!);\n case '*':\n return args.map((s, i) => (isOp(n.args[i]!, '+', '-') ? paren(s) : s)).join(' \\\\cdot ');\n case '^': {\n // The validator's arity guard makes `^` binary; a base that is not a symbol is grouped.\n const base = n.args[0]!.kind === 'symbol' ? args[0]! : paren(args[0]!);\n return `{${base}}^{${args[1]}}`;\n }\n case '+':\n return args.join(' + ');\n case '-':\n return args.length === 1\n ? `-${isOp(n.args[0]!, '+', '-') ? paren(args[0]!) : args[0]}`\n : args.map((s, i) => (i > 0 && isOp(n.args[i]!, '+', '-') ? paren(s) : s)).join(' - ');\n }\n}\n\nconst SI_BASE: readonly (readonly [keyof Dimension, string])[] = [\n ['M', 'kg'],\n ['L', 'm'],\n ['T', 's'],\n ['I', 'A'],\n ['Theta', 'K'],\n ['N', 'mol'],\n ['J', 'cd'],\n];\n\nconst DIM_KEYS: readonly (keyof Dimension)[] = ['L', 'M', 'T', 'I', 'Theta', 'N', 'J'];\nconst dimEqual = (a: Dimension, b: Dimension): boolean => DIM_KEYS.every((k) => (a[k] ?? 0) === (b[k] ?? 0));\nconst dimPow = (a: Dimension, n: number): Dimension =>\n Object.fromEntries(DIM_KEYS.map((k) => [k, (a[k] ?? 0) * n])) as unknown as Dimension;\nconst dimMul = (a: Dimension, b: Dimension): Dimension =>\n Object.fromEntries(DIM_KEYS.map((k) => [k, (a[k] ?? 0) + (b[k] ?? 0)])) as unknown as Dimension;\nconst isDimensionless = (d: Dimension): boolean => DIM_KEYS.every((k) => (d[k] ?? 0) === 0);\n\n/** One coherent SI unit of the table: a scale of exactly 1 and a dimension. */\nexport interface CoherentUnit {\n readonly name: string;\n readonly dim: Dimension;\n}\n\n/**\n * The coherent named SI units of a unit table (`unitRows()`): scale exactly 1,\n * not dimensionless, the first spelling the table gives for each dimension\n * (`ohm` before `Ω`). The seven base units are added so a label can mix them.\n * A cycle-counting unit (`Hz`, `rpm`; the table's `cycles` flag) is never a\n * label: a 1/s output may be an angular frequency, and `Hz` would say it\n * counts cycles. Such an output reads `1/s`, which is its dimension.\n */\nexport function coherentUnits(\n rows: ReadonlyMap<\n string,\n { readonly scale: { readonly num: bigint; readonly den: bigint; readonly irrational: number }; readonly dim: Dimension; readonly cycles?: true }\n >,\n): CoherentUnit[] {\n const out: CoherentUnit[] = [];\n const seen: Dimension[] = [];\n const add = (name: string, dim: Dimension): void => {\n if (isDimensionless(dim) || seen.some((d) => dimEqual(d, dim))) return;\n seen.push(dim);\n out.push({ name, dim });\n };\n for (const [name, row] of rows) {\n if (row.cycles === true) continue;\n if (row.scale.num === 1n && row.scale.den === 1n && row.scale.irrational === 1) add(name, row.dim);\n }\n for (const [k, u] of SI_BASE) {\n add(u, Object.fromEntries(DIM_KEYS.map((key) => [key, key === k ? 1 : 0])) as unknown as Dimension);\n }\n return out;\n}\n\n/**\n * A dimension's label: the one coherent named unit whose dimension it is (`Pa`, `J`, `V`,\n * `ohm`, `T`), else the SI base form (`m/s`, `kg^2*m^4/(s^5*A^2)`). A product of two\n * named units is never chosen: a search over pairs once labelled a velocity `W/N` and a\n * voltage-noise density `J*ohm`, readings that are dimensionally right and physically\n * unreadable. Presentation only: the dimension is the fact, the label is a reading of it.\n */\nexport function derivedUnitOf(dim: Dimension, units: readonly CoherentUnit[]): string {\n if (isDimensionless(dim)) return '1';\n const base = new Set(SI_BASE.map(([, u]) => u));\n const named = units.find((u) => !base.has(u.name) && dimEqual(u.dim, dim));\n return named === undefined ? siUnitOf(dim) : named.name;\n}\n\n/** The SI base-unit form of a dimension (`m/s`, `kg*m^2/(s^3*A)`), `1` when dimensionless. */\nexport function siUnitOf(dim: Dimension): string {\n const factor = (u: string, e: number): string => (e === 1 ? u : `${u}^${e}`);\n const num = SI_BASE.filter(([k]) => dim[k] > 0).map(([k, u]) => factor(u, dim[k]));\n const den = SI_BASE.filter(([k]) => dim[k] < 0).map(([k, u]) => factor(u, -dim[k]));\n if (num.length === 0 && den.length === 0) return '1';\n if (num.length === 0) return SI_BASE.filter(([k]) => dim[k] < 0).map(([k, u]) => factor(u, dim[k])).join('*');\n if (den.length === 0) return num.join('*');\n return `${num.join('*')}/${den.length === 1 ? den[0] : `(${den.join('*')})`}`;\n}\n"]}
1
+ {"version":3,"file":"expr-print.js","sourceRoot":"","sources":["../../src/cli/expr-print.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAQhE,MAAM,OAAO,GAAe,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;AAElF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,UAAU,GAAqC;IAC1D,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,QAAQ;IACf,GAAG,EAAE,OAAO;CACb,CAAC;AACF,MAAM,IAAI,GAAe,EAAE,KAAK,EAAE,GAAG,EAAE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AAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAyB,CAAC,CAAC;IACnG,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAAc,EAAE,KAA8B;IAC1E,IAAI,eAAe,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAChF,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;AAC1D,CAAC","sourcesContent":["/**\n * The three printed forms of a scalar composed AST (`upt symbolic`, audit F12 and I10):\n *\n * - DISPLAY: plain text for the reader, `·` for a product.\n * - EVAL: a formula `upt eval` parses, every named factor spelled so it evaluates (`8pi` → `(8*pi)`).\n * - LATEX: `\\frac` for every division, `\\cdot` for a product, braces for every exponent.\n *\n * Only `symbol` and `op` nodes are printed; any other node gives `null`, never a guess.\n */\nimport type { ExprNode } from '../dimensional/validator.js';\nimport type { Dimension } from '../dimensional/types.js';\nimport { BASES, exactlyEquals, isDimensionless, SI_BASE, siUnitOf } from '../dimensional/algebra.js';\nimport { isDecimalLiteral } from '../dimensional/ast-leaves.js';\n\ninterface PrintStyle {\n readonly times: string;\n readonly divide: string;\n readonly symbol: (name: string) => string;\n}\n\nconst DISPLAY: PrintStyle = { times: '·', divide: ' / ', symbol: (name) => name };\n\n/** Named numeric stubs spelled so `upt eval` parses them. */\nexport const EVAL_STUBS: Readonly<Record<string, string>> = {\n '8pi': '(8*pi)',\n '4pi': '(4*pi)',\n '2pi': '(2*pi)',\n ln2: 'ln(2)',\n};\nconst EVAL: PrintStyle = { times: '*', divide: '/', symbol: (name) => EVAL_STUBS[name] ?? name };\n\n/**\n * Precedence-aware printing. Every divisor that is not a bare power is\n * grouped, so `a / (b·c)` never prints as `a / b·c` (audit F12); a quotient\n * inside a product or as a dividend is grouped too, for the reader.\n */\nfunction printInfix(n: ExprNode, style: PrintStyle): string | null {\n if (n.kind === 'symbol') return style.symbol(n.name);\n if (n.kind !== 'op') return null;\n const parts: string[] = [];\n for (let i = 0; i < n.args.length; i++) {\n const a = n.args[i]!;\n const s = printInfix(a, style);\n if (s === null) return null;\n const aOp = a.kind === 'op' ? a.op : null;\n const group =\n aOp !== null &&\n (n.op === '^'\n ? true\n : n.op === '/'\n ? i === 0\n ? aOp === '+' || aOp === '-' || aOp === '/'\n : aOp !== '^'\n : n.op === '*'\n ? aOp === '+' || aOp === '-' || aOp === '/'\n : n.op === '-' && i > 0 && (aOp === '+' || aOp === '-'));\n parts.push(group ? `(${s})` : s);\n }\n const sep = n.op === '*' ? style.times : n.op === '/' ? style.divide : n.op === '^' ? '^' : ` ${n.op} `;\n return parts.join(sep);\n}\n\nexport const printDisplay = (n: ExprNode): string | null => printInfix(n, DISPLAY);\nexport const printEval = (n: ExprNode): string | null => printInfix(n, EVAL);\n\n/** LaTeX for the constant and stub names; any other name is spelled by {@link latexName}. */\nconst LATEX_NAMES: Readonly<Record<string, string>> = {\n hbar: '\\\\hbar',\n k_B: 'k_{\\\\mathrm{B}}',\n '8pi': '8\\\\pi',\n '4pi': '4\\\\pi',\n '2pi': '2\\\\pi',\n ln2: '\\\\ln 2',\n pi: '\\\\pi',\n epsilon_0: '\\\\varepsilon_{0}',\n sigma_sb: '\\\\sigma_{\\\\mathrm{SB}}',\n};\n\n/** A name in LaTeX: one letter or a number as is, a hyphenated name as text, otherwise upright. */\nexport function latexName(name: string): string {\n const known = LATEX_NAMES[name];\n if (known !== undefined) return known;\n // A decimal literal prints as is; `Number()` also read '' and '0x10' as numbers.\n if (/^[A-Za-z]$/.test(name) || isDecimalLiteral(name)) return name;\n return name.includes('-') ? `\\\\text{${name}}` : `\\\\mathrm{${name.replace(/_/g, '\\\\_')}}`;\n}\n\n/** The AST in LaTeX; `null` for a node other than `symbol` or `op`. */\nexport function printLatex(n: ExprNode): string | null {\n if (n.kind === 'symbol') return latexName(n.name);\n if (n.kind !== 'op') return null;\n const args: string[] = [];\n for (const a of n.args) {\n const s = printLatex(a);\n if (s === null) return null;\n args.push(s);\n }\n const isOp = (a: ExprNode, ...ops: string[]): boolean => a.kind === 'op' && ops.includes(a.op);\n const paren = (s: string): string => `\\\\left(${s}\\\\right)`;\n switch (n.op) {\n case '/':\n return args.slice(1).reduce((num, den) => `\\\\frac{${num}}{${den}}`, args[0]!);\n case '*':\n return args.map((s, i) => (isOp(n.args[i]!, '+', '-') ? paren(s) : s)).join(' \\\\cdot ');\n case '^': {\n // The validator's arity guard makes `^` binary; a base that is not a symbol is grouped.\n const base = n.args[0]!.kind === 'symbol' ? args[0]! : paren(args[0]!);\n return `{${base}}^{${args[1]}}`;\n }\n case '+':\n return args.join(' + ');\n case '-':\n return args.length === 1\n ? `-${isOp(n.args[0]!, '+', '-') ? paren(args[0]!) : args[0]}`\n : args.map((s, i) => (i > 0 && isOp(n.args[i]!, '+', '-') ? paren(s) : s)).join(' - ');\n }\n}\n\n\n/** One coherent SI unit of the table: a scale of exactly 1 and a dimension. */\nexport interface CoherentUnit {\n readonly name: string;\n readonly dim: Dimension;\n}\n\n/**\n * The coherent named SI units of a unit table (`unitRows()`): scale exactly 1,\n * not dimensionless, the first spelling the table gives for each dimension\n * (`ohm` before `Ω`). The seven base units are added so a label can mix them.\n * A cycle-counting unit (`Hz`, `rpm`; the table's `cycles` flag) is never a\n * label: a 1/s output may be an angular frequency, and `Hz` would say it\n * counts cycles. Such an output reads `1/s`, which is its dimension.\n */\nexport function coherentUnits(\n rows: ReadonlyMap<\n string,\n { readonly scale: { readonly num: bigint; readonly den: bigint; readonly irrational: number }; readonly dim: Dimension; readonly cycles?: true }\n >,\n): CoherentUnit[] {\n const out: CoherentUnit[] = [];\n const seen: Dimension[] = [];\n const add = (name: string, dim: Dimension): void => {\n if (isDimensionless(dim) || seen.some((d) => exactlyEquals(d, dim))) return;\n seen.push(dim);\n out.push({ name, dim });\n };\n for (const [name, row] of rows) {\n if (row.cycles === true) continue;\n if (row.scale.num === 1n && row.scale.den === 1n && row.scale.irrational === 1) add(name, row.dim);\n }\n for (const [k, u] of SI_BASE) {\n add(u, Object.fromEntries(BASES.map((key) => [key, key === k ? 1 : 0])) as unknown as Dimension);\n }\n return out;\n}\n\n/**\n * A dimension's label: the one coherent named unit whose dimension it is (`Pa`, `J`, `V`,\n * `ohm`, `T`), else the SI base form (`m/s`, `kg^2*m^4/(s^5*A^2)`). A product of two\n * named units is never chosen: a search over pairs once labelled a velocity `W/N` and a\n * voltage-noise density `J*ohm`, readings that are dimensionally right and physically\n * unreadable. Presentation only: the dimension is the fact, the label is a reading of it.\n */\nexport function derivedUnitOf(dim: Dimension, units: readonly CoherentUnit[]): string {\n if (isDimensionless(dim)) return '1';\n const base = new Set(SI_BASE.map(([, u]) => u));\n const named = units.find((u) => !base.has(u.name) && exactlyEquals(u.dim, dim));\n return named === undefined ? siUnitOf(dim) : named.name;\n}\n"]}
@@ -21,6 +21,7 @@ export declare const BUILTIN_VERBS: readonly {
21
21
  example: string;
22
22
  group: 'utilities';
23
23
  }[];
24
+ /** The usage heading of one flag, showing how its value is written. */
24
25
  export declare function flagHeading(flag: FlagSpec): string;
25
26
  /** The Flags block a command's help string ends with. Empty when the command takes no flags. */
26
27
  export declare function renderFlagCatalog(flags: readonly FlagSpec[], heading?: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"flag-help.d.ts","sourceRoot":"","sources":["../../src/cli/flag-help.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AA2E;AAC3E,eAAO,MAAM,YAAY,EAAE,SAAS,QAAQ,EA8B3C,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,SAAS;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,WAAW,CAAC;CACpB,EAaA,CAAC;AAEF,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAgBlD;AAED,gGAAgG;AAChG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,EAAE,OAAO,SAAW,GAAG,MAAM,CAYxF;AAED,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,CAG7E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,EAAE,CAEpF"}
@@ -66,6 +66,7 @@ export const BUILTIN_VERBS = [
66
66
  group: 'utilities',
67
67
  },
68
68
  ];
69
+ /** The usage heading of one flag, showing how its value is written. */
69
70
  export function flagHeading(flag) {
70
71
  const repeat = flag.repeatable ? ' (repeatable)' : '';
71
72
  switch (flag.valueStyle) {
@@ -1 +1 @@
1
- {"version":3,"file":"flag-help.js","sourceRoot":"","sources":["../../src/cli/flag-help.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,gFAAgF;AAChF,MAAM,CAAC,MAAM,SAAS,GAAa;IACjC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,MAAM;IAClB,WAAW,EAAE,6DAA6D;CAC3E,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,YAAoB,EAAE,MAAc;IAC7D,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,UAAU,EAAE,UAAU;QACtB,WAAW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AO,EAAE,CAAC;AACzD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,KAA0B;IACxE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7H,CAAC","sourcesContent":["/**\n * Flag text for `upt help` and for `docs/CLI.md`.\n *\n * The parser reads `FlagSpec` (`args.ts`). This module renders the same\n * objects. A command's help string is `commandHelp(prose, flags)`, so the\n * Flags section cannot list a different set than the parser accepts.\n */\n\nimport type { FlagSpec } from './args.js';\n\n/** `--json` on a data-bearing command. The same object is the global option. */\nexport const JSON_FLAG: FlagSpec = {\n name: '--json',\n valueStyle: 'none',\n description: 'Write a JSON envelope to stdout instead of the text report.',\n};\n\n/**\n * `--source=VALUE` for a graph command.\n * `detail` is the sentence; `defaultValue` is what the command uses when the flag is absent.\n */\nexport function sourceFlag(defaultValue: string, detail: string): FlagSpec {\n return {\n name: '--source',\n valueStyle: 'attached',\n description: detail,\n defaultValue,\n };\n}\n\n/** Dispatcher options. `main.ts` accepts these before the command name. */\nexport const GLOBAL_FLAGS: readonly FlagSpec[] = [\n {\n name: '--help',\n valueStyle: 'none',\n description:\n 'Show this command list, or `upt help <command>` for one command. `-h` is the same. `upt <command> --help` prints that command.',\n },\n {\n name: '--version',\n valueStyle: 'none',\n description: 'Print the package version as one semver line and exit. `-v` and `upt version` are the same. Neither takes --json.',\n },\n JSON_FLAG,\n {\n name: '--record',\n valueStyle: 'attached',\n description:\n 'Run the following command unchanged and append one JSONL entry to FILE: arguments, stdout, stderr, exit code, versions, and hashes. A failed run is recorded too.',\n },\n {\n name: '--replay',\n valueStyle: 'attached',\n description:\n 'Re-run every entry of FILE and report reproduced, differs, or not replayable. Takes no command. `--json` after it selects the JSON report. Exit 0 when every entry is reproduced and unchanged, 3 when any differs, 1 otherwise.',\n },\n {\n name: '--show-record',\n valueStyle: 'attached',\n description: 'Print FILE as a transcript and run nothing. Takes no command. `--json` after it selects the JSON report.',\n },\n];\n\nexport const BUILTIN_VERBS: readonly {\n name: string;\n summary: string;\n example: string;\n group: 'utilities';\n}[] = [\n {\n name: 'help',\n summary: 'Show every command, or one command\\'s usage and flags. `upt help statuses` defines the status words.',\n example: 'upt help eval',\n group: 'utilities',\n },\n {\n name: 'version',\n summary: 'Print the installed package version as one semver line.',\n example: 'upt version',\n group: 'utilities',\n },\n];\n\nexport function flagHeading(flag: FlagSpec): string {\n const repeat = flag.repeatable ? ' (repeatable)' : '';\n switch (flag.valueStyle) {\n case 'none':\n return `${flag.name}${repeat}`;\n case 'attached':\n return `${flag.name}=VALUE${repeat}`;\n case 'next':\n return `${flag.name} VALUE${repeat}`;\n case 'either':\n return `${flag.name}=VALUE${repeat} (or ${flag.name} VALUE)`;\n default: {\n const _never: never = flag.valueStyle;\n return _never;\n }\n }\n}\n\n/** The Flags block a command's help string ends with. Empty when the command takes no flags. */\nexport function renderFlagCatalog(flags: readonly FlagSpec[], heading = 'Flags:'): string {\n if (flags.length === 0) return '';\n const lines = [heading];\n for (const flag of flags) {\n if (flag.description === undefined || flag.description.trim() === '') {\n throw new Error(`flag ${flag.name} has no description`);\n }\n lines.push(` ${flagHeading(flag)}`);\n const def = flag.defaultValue === undefined ? '' : ` Default: ${flag.defaultValue}.`;\n lines.push(` ${flag.description}${def}`);\n }\n return lines.join('\\n');\n}\n\n/** Prose plus the flag catalog. The catalog is the spec; the prose is the narrative. */\nexport function commandHelp(prose: string, flags: readonly FlagSpec[]): string {\n const catalog = renderFlagCatalog(flags);\n return catalog === '' ? prose : `${prose}\\n${catalog}`;\n}\n\n/**\n * Flags whose description is missing from `help`.\n * A command that forgot `commandHelp` fails here. A description that is present does not.\n */\nexport function undocumentedFlags(help: string, flags: readonly FlagSpec[]): string[] {\n return flags.filter((flag) => flag.description === undefined || !help.includes(flag.description)).map((flag) => flag.name);\n}\n"]}
1
+ {"version":3,"file":"flag-help.js","sourceRoot":"","sources":["../../src/cli/flag-help.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,gFAAgF;AAChF,MAAM,CAAC,MAAM,SAAS,GAAa;IACjC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,MAAM;IAClB,WAAW,EAAE,6DAA6D;CAC3E,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,YAAoB,EAAE,MAAc;IAC7D,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,UAAU,EAAE,UAAU;QACtB,WAAW,EAAE,MAAM;QACnB,YAAY;KACb,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,MAAM,YAAY,GAAwB;IAC/C;QACE,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,MAAM;QAClB,WAAW,EACT,gIAAgI;KACnI;IACD;QACE,IAAI,EAAE,WAAW;QACjB,UAAU,EAAE,MAAM;QAClB,WAAW,EAAE,mHAAmH;KACjI;IACD,SAAS;IACT;QACE,IAAI,EAAE,UAAU;QAChB,UAAU,EAAE,UAAU;QACtB,WAAW,EACT,mKAAmK;KACtK;IACD;QACE,IAAI,EAAE,UAAU;QAChB,UAAU,EAAE,UAAU;QACtB,WAAW,EACT,kOAAkO;KACrO;IACD;QACE,IAAI,EAAE,eAAe;QACrB,UAAU,EAAE,UAAU;QACtB,WAAW,EAAE,0GAA0G;KACxH;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAKpB;IACJ;QACE,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,sGAAsG;QAC/G,OAAO,EAAE,eAAe;QACxB,KAAK,EAAE,WAAW;KACnB;IACD;QACE,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,yDAAyD;QAClE,OAAO,EAAE,aAAa;QAC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,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,YAAY,GAAG,CAAC;QACrF,KAAK,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,GAAG,GAAG,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,KAA0B;IACnE,MAAM,OAAO,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,OAAO,EAAE,CAAC;AACzD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,KAA0B;IACxE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7H,CAAC","sourcesContent":["/**\n * Flag text for `upt help` and for `docs/CLI.md`.\n *\n * The parser reads `FlagSpec` (`args.ts`). This module renders the same\n * objects. A command's help string is `commandHelp(prose, flags)`, so the\n * Flags section cannot list a different set than the parser accepts.\n */\n\nimport type { FlagSpec } from './args.js';\n\n/** `--json` on a data-bearing command. The same object is the global option. */\nexport const JSON_FLAG: FlagSpec = {\n name: '--json',\n valueStyle: 'none',\n description: 'Write a JSON envelope to stdout instead of the text report.',\n};\n\n/**\n * `--source=VALUE` for a graph command.\n * `detail` is the sentence; `defaultValue` is what the command uses when the flag is absent.\n */\nexport function sourceFlag(defaultValue: string, detail: string): FlagSpec {\n return {\n name: '--source',\n valueStyle: 'attached',\n description: detail,\n defaultValue,\n };\n}\n\n/** Dispatcher options. `main.ts` accepts these before the command name. */\nexport const GLOBAL_FLAGS: readonly FlagSpec[] = [\n {\n name: '--help',\n valueStyle: 'none',\n description:\n 'Show this command list, or `upt help <command>` for one command. `-h` is the same. `upt <command> --help` prints that command.',\n },\n {\n name: '--version',\n valueStyle: 'none',\n description: 'Print the package version as one semver line and exit. `-v` and `upt version` are the same. Neither takes --json.',\n },\n JSON_FLAG,\n {\n name: '--record',\n valueStyle: 'attached',\n description:\n 'Run the following command unchanged and append one JSONL entry to FILE: arguments, stdout, stderr, exit code, versions, and hashes. A failed run is recorded too.',\n },\n {\n name: '--replay',\n valueStyle: 'attached',\n description:\n 'Re-run every entry of FILE and report reproduced, differs, or not replayable. Takes no command. `--json` after it selects the JSON report. Exit 0 when every entry is reproduced and unchanged, 3 when any differs, 1 otherwise.',\n },\n {\n name: '--show-record',\n valueStyle: 'attached',\n description: 'Print FILE as a transcript and run nothing. Takes no command. `--json` after it selects the JSON report.',\n },\n];\n\nexport const BUILTIN_VERBS: readonly {\n name: string;\n summary: string;\n example: string;\n group: 'utilities';\n}[] = [\n {\n name: 'help',\n summary: 'Show every command, or one command\\'s usage and flags. `upt help statuses` defines the status words.',\n example: 'upt help eval',\n group: 'utilities',\n },\n {\n name: 'version',\n summary: 'Print the installed package version as one semver line.',\n example: 'upt version',\n group: 'utilities',\n },\n];\n\n/** The usage heading of one flag, showing how its value is written. */\nexport function flagHeading(flag: FlagSpec): string {\n const repeat = flag.repeatable ? ' (repeatable)' : '';\n switch (flag.valueStyle) {\n case 'none':\n return `${flag.name}${repeat}`;\n case 'attached':\n return `${flag.name}=VALUE${repeat}`;\n case 'next':\n return `${flag.name} VALUE${repeat}`;\n case 'either':\n return `${flag.name}=VALUE${repeat} (or ${flag.name} VALUE)`;\n default: {\n const _never: never = flag.valueStyle;\n return _never;\n }\n }\n}\n\n/** The Flags block a command's help string ends with. Empty when the command takes no flags. */\nexport function renderFlagCatalog(flags: readonly FlagSpec[], heading = 'Flags:'): string {\n if (flags.length === 0) return '';\n const lines = [heading];\n for (const flag of flags) {\n if (flag.description === undefined || flag.description.trim() === '') {\n throw new Error(`flag ${flag.name} has no description`);\n }\n lines.push(` ${flagHeading(flag)}`);\n const def = flag.defaultValue === undefined ? '' : ` Default: ${flag.defaultValue}.`;\n lines.push(` ${flag.description}${def}`);\n }\n return lines.join('\\n');\n}\n\n/** Prose plus the flag catalog. The catalog is the spec; the prose is the narrative. */\nexport function commandHelp(prose: string, flags: readonly FlagSpec[]): string {\n const catalog = renderFlagCatalog(flags);\n return catalog === '' ? prose : `${prose}\\n${catalog}`;\n}\n\n/**\n * Flags whose description is missing from `help`.\n * A command that forgot `commandHelp` fails here. A description that is present does not.\n */\nexport function undocumentedFlags(help: string, flags: readonly FlagSpec[]): string[] {\n return flags.filter((flag) => flag.description === undefined || !help.includes(flag.description)).map((flag) => flag.name);\n}\n"]}
@@ -7,7 +7,9 @@
7
7
  import type { BridgeEdge } from '../composition/edge.js';
8
8
  import type { ParsedArgs } from './args.js';
9
9
  import type { CommandCtx } from './command.js';
10
+ /** The graph that a command reads, as chosen by its `--source` flag. */
10
11
  export type SourceName = 'catalog' | 'canonical' | 'both';
12
+ /** Resolve the `--source` flag to graph edges, a banner label and the source name. */
11
13
  export declare function resolveGraph(api: CommandCtx['api'], flags: ParsedArgs['flags']): {
12
14
  graph: BridgeEdge[];
13
15
  label: string;
@@ -1 +1 @@
1
- {"version":3,"file":"graphs.d.ts","sourceRoot":"","sources":["../../src/cli/graphs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,WAA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,UAAU,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAEzF;AAED,kFAAkF;AAClF,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,GAAG,MAAM,CAGlF;AAED,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAEpE"}
@@ -5,6 +5,7 @@
5
5
  * this once to get the graph + a human-readable label for its banner.
6
6
  */
7
7
  import { CliError } from './errors.js';
8
+ /** Resolve the `--source` flag to graph edges, a banner label and the source name. */
8
9
  export function resolveGraph(api, flags) {
9
10
  const values = flags.get('source');
10
11
  const src = values && values.length > 0 ? values[values.length - 1] : 'catalog';
@@ -1 +1 @@
1
- {"version":3,"file":"graphs.js","sourceRoot":"","sources":["../../src/cli/graphs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIvC,MAAM,UAAU,YAAY,CAC1B,GAAsB,EACtB,KAA0B;IAE1B,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAEhF,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,SAAS;YACZ,OAAO;gBACL,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC;gBAC7B,KAAK,EAAE,YAAY,GAAG,CAAC,gBAAgB,CAAC,MAAM,UAAU;gBACxD,MAAM,EAAE,SAAS;aAClB,CAAC;QACJ,KAAK,WAAW;YACd,OAAO;gBACL,KAAK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;IAChF,OAAO,WAAW,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC;AAC7G,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,QAAQ,CAAC,CAAmC;IAC1D,OAAO,2DAA2D,CAAC,CAAC,gBAAgB,0CAA0C,CAAC,CAAC,KAAK,gBAAgB,CAAC;AACxJ,CAAC","sourcesContent":["/**\n * Shared `--source=catalog|canonical|both` graph resolution — replaces\n * `bin/upt.mjs`'s `resolveGraph` (lines 53-67). Every analysis command\n * (`discover` / `candidates` / `map` / ...) that accepts `--source` calls\n * this once to get the graph + a human-readable label for its banner.\n */\n\nimport type { BridgeEdge } from '../composition/edge.js';\nimport type { ParsedArgs } from './args.js';\nimport type { CommandCtx } from './command.js';\nimport { CliError } from './errors.js';\n\nexport type SourceName = 'catalog' | 'canonical' | 'both';\n\nexport function resolveGraph(\n api: CommandCtx['api'],\n flags: ParsedArgs['flags']\n): { graph: BridgeEdge[]; label: string; source: SourceName } {\n const values = flags.get('source');\n const src = values && values.length > 0 ? values[values.length - 1] : 'catalog';\n\n switch (src) {\n case 'catalog':\n return {\n graph: [...api.CATALOG_GRAPH],\n label: `catalog (${api.BRIDGE_EQUATIONS.length}-bridge)`,\n source: 'catalog',\n };\n case 'canonical':\n return {\n graph: [...api.CANONICAL_GRAPH],\n label: 'canonical (standard-physics L-layer, bridges excluded)',\n source: 'canonical',\n };\n case 'both':\n return {\n graph: [...api.CATALOG_GRAPH, ...api.CANONICAL_GRAPH],\n label: 'catalog + canonical',\n source: 'both',\n };\n default:\n throw new CliError(`upt: unknown --source='${src}' (expected: catalog | canonical | both)`);\n }\n}\n\n/**\n * What a result is anchored to (audit I3), printed beside the source in text and carried as the\n * envelope's `anchor` in `--json`. Two different anchors exist and are never merged:\n * `groundTruth` is the discovery funnel's known values (`--anchor=k=v`, default one solar mass);\n * `core` is the set of established-confidence edges that \"anchored\" means in a linkage view.\n */\nexport interface AnchorScope {\n readonly groundTruth?: { readonly values: Readonly<Record<string, number>>; readonly isDefault: boolean };\n readonly core?: { readonly establishedEdges: number; readonly edges: number };\n}\n\n/** The discovery ground truth a result is relative to: the `--anchor` values when given, else the default. */\nexport function groundTruthAnchor(\n api: CommandCtx['api'],\n opts: { readonly groundTruth?: Readonly<Record<string, number>> },\n): NonNullable<AnchorScope['groundTruth']> {\n return opts.groundTruth === undefined\n ? { values: { ...api.ANCHOR_DEFAULT }, isDefault: true }\n : { values: { ...opts.groundTruth }, isDefault: false };\n}\n\n/** The established core of `graph`: its established-confidence edge count beside its edge count. */\nexport function coreAnchor(graph: readonly BridgeEdge[]): NonNullable<AnchorScope['core']> {\n return { establishedEdges: graph.filter((e) => e.confidence === 'established').length, edges: graph.length };\n}\n\n/** The text line naming the ground-truth anchor and whether it is the default. */\nexport function groundTruthLine(a: NonNullable<AnchorScope['groundTruth']>): string {\n const values = Object.entries(a.values).map(([k, v]) => `${k}=${v}`).join(', ');\n return `anchor: ${values}${a.isDefault ? ' (the default; --anchor=k=v replaces it)' : ' (from --anchor)'}`;\n}\n\n/** The text line stating what \"anchored\" means for a graph's established core. */\nexport function coreLine(a: NonNullable<AnchorScope['core']>): string {\n return `anchored core: the clusters holding at least one of the ${a.establishedEdges} established-confidence edge(s) of the ${a.edges} in this graph`;\n}"]}
1
+ {"version":3,"file":"graphs.js","sourceRoot":"","sources":["../../src/cli/graphs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAKvC,sFAAsF;AACtF,MAAM,UAAU,YAAY,CAC1B,GAAsB,EACtB,KAA0B;IAE1B,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG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AAC,MAAM,EAAE,CAAC;AAC/G,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,eAAe,CAAC,CAA0C;IACxE,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChF,OAAO,WAAW,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC;AAC7G,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,QAAQ,CAAC,CAAmC;IAC1D,OAAO,2DAA2D,CAAC,CAAC,gBAAgB,0CAA0C,CAAC,CAAC,KAAK,gBAAgB,CAAC;AACxJ,CAAC","sourcesContent":["/**\n * Shared `--source=catalog|canonical|both` graph resolution — replaces\n * `bin/upt.mjs`'s `resolveGraph` (lines 53-67). Every analysis command\n * (`discover` / `candidates` / `map` / ...) that accepts `--source` calls\n * this once to get the graph + a human-readable label for its banner.\n */\n\nimport type { BridgeEdge } from '../composition/edge.js';\nimport type { ParsedArgs } from './args.js';\nimport type { CommandCtx } from './command.js';\nimport { CliError } from './errors.js';\n\n/** The graph that a command reads, as chosen by its `--source` flag. */\nexport type SourceName = 'catalog' | 'canonical' | 'both';\n\n/** Resolve the `--source` flag to graph edges, a banner label and the source name. */\nexport function resolveGraph(\n api: CommandCtx['api'],\n flags: ParsedArgs['flags']\n): { graph: BridgeEdge[]; label: string; source: SourceName } {\n const values = flags.get('source');\n const src = values && values.length > 0 ? values[values.length - 1] : 'catalog';\n\n switch (src) {\n case 'catalog':\n return {\n graph: [...api.CATALOG_GRAPH],\n label: `catalog (${api.BRIDGE_EQUATIONS.length}-bridge)`,\n source: 'catalog',\n };\n case 'canonical':\n return {\n graph: [...api.CANONICAL_GRAPH],\n label: 'canonical (standard-physics L-layer, bridges excluded)',\n source: 'canonical',\n };\n case 'both':\n return {\n graph: [...api.CATALOG_GRAPH, ...api.CANONICAL_GRAPH],\n label: 'catalog + canonical',\n source: 'both',\n };\n default:\n throw new CliError(`upt: unknown --source='${src}' (expected: catalog | canonical | both)`);\n }\n}\n\n/**\n * What a result is anchored to (audit I3), printed beside the source in text and carried as the\n * envelope's `anchor` in `--json`. Two different anchors exist and are never merged:\n * `groundTruth` is the discovery funnel's known values (`--anchor=k=v`, default one solar mass);\n * `core` is the set of established-confidence edges that \"anchored\" means in a linkage view.\n */\nexport interface AnchorScope {\n readonly groundTruth?: { readonly values: Readonly<Record<string, number>>; readonly isDefault: boolean };\n readonly core?: { readonly establishedEdges: number; readonly edges: number };\n}\n\n/** The discovery ground truth a result is relative to: the `--anchor` values when given, else the default. */\nexport function groundTruthAnchor(\n api: CommandCtx['api'],\n opts: { readonly groundTruth?: Readonly<Record<string, number>> },\n): NonNullable<AnchorScope['groundTruth']> {\n return opts.groundTruth === undefined\n ? { values: { ...api.ANCHOR_DEFAULT }, isDefault: true }\n : { values: { ...opts.groundTruth }, isDefault: false };\n}\n\n/** The established core of `graph`: its established-confidence edge count beside its edge count. */\nexport function coreAnchor(graph: readonly BridgeEdge[]): NonNullable<AnchorScope['core']> {\n return { establishedEdges: graph.filter((e) => e.confidence === 'established').length, edges: graph.length };\n}\n\n/** The text line naming the ground-truth anchor and whether it is the default. */\nexport function groundTruthLine(a: NonNullable<AnchorScope['groundTruth']>): string {\n const values = Object.entries(a.values).map(([k, v]) => `${k}=${v}`).join(', ');\n return `anchor: ${values}${a.isDefault ? ' (the default; --anchor=k=v replaces it)' : ' (from --anchor)'}`;\n}\n\n/** The text line stating what \"anchored\" means for a graph's established core. */\nexport function coreLine(a: NonNullable<AnchorScope['core']>): string {\n return `anchored core: the clusters holding at least one of the ${a.establishedEdges} established-confidence edge(s) of the ${a.edges} in this graph`;\n}"]}
@@ -15,5 +15,13 @@
15
15
  */
16
16
  import { type Io } from './record.js';
17
17
  import './commands/index.js';
18
+ /**
19
+ * The last-resort handler `bin/upt.mjs` calls when `runCli` rethrows: a defect, since every
20
+ * usage error and value refusal was mapped to an exit code inside `runCli`. Prints one line,
21
+ * `upt: internal error: <message>` (the message, not the stack), and returns 70 (EX_SOFTWARE).
22
+ * A thrown value that is not an Error, or an Error with no message, prints as its string.
23
+ */
24
+ export declare function reportInternalError(error: unknown, io?: Pick<Io, 'err'>): number;
25
+ /** Run one `upt` invocation and return its exit code. */
18
26
  export declare function runCli(argv: string[], io?: Io): Promise<number>;
19
27
  //# sourceMappingURL=main.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,OAAO,EAA8C,KAAK,EAAE,EAAE,MAAM,aAAa,CAAC;AAElF,OAAO,qBAAqB,CAAC;AAmC7B,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,GAAE,EAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAoDhF"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,OAAO,EAA8C,KAAK,EAAE,EAAE,MAAM,aAAa,CAAC;AAElF,OAAO,qBAAqB,CAAC;AAuB7B;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,GAAE,IAAI,CAAC,EAAE,EAAE,KAAK,CAAa,GAAG,MAAM,CAI3F;AAiBD,yDAAyD;AACzD,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,GAAE,EAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAoDhF"}
package/dist/cli/main.js CHANGED
@@ -37,6 +37,19 @@ function stdoutRaw(s) {
37
37
  process.stdout.write(s);
38
38
  }
39
39
  const defaultIo = { out: stdoutLine, err: stderrLine, write: stdoutRaw };
40
+ /** EX_SOFTWARE (sysexits.h): the exit code of a defect, an error `runCli` did not map. */
41
+ const EX_SOFTWARE = 70;
42
+ /**
43
+ * The last-resort handler `bin/upt.mjs` calls when `runCli` rethrows: a defect, since every
44
+ * usage error and value refusal was mapped to an exit code inside `runCli`. Prints one line,
45
+ * `upt: internal error: <message>` (the message, not the stack), and returns 70 (EX_SOFTWARE).
46
+ * A thrown value that is not an Error, or an Error with no message, prints as its string.
47
+ */
48
+ export function reportInternalError(error, io = defaultIo) {
49
+ const message = error instanceof Error && error.message !== '' ? error.message : String(error);
50
+ io.err(`upt: internal error: ${message}`);
51
+ return EX_SOFTWARE;
52
+ }
40
53
  const unknownCommandMessage = (name) => `Unknown command '${name}'. See \`upt help\`.`;
41
54
  const GLOBAL_FILE_OPTION = /^--(record|replay|show-record)(?:=(.*))?$/;
42
55
  /**
@@ -49,6 +62,7 @@ const GLOBAL_FILE_OPTION = /^--(record|replay|show-record)(?:=(.*))?$/;
49
62
  * own flag spec parses it. `upt <command> --help` prints that command.
50
63
  */
51
64
  const NO_JSON_VERBS = new Set(['help', '--help', '-h', 'version', '--version', '-v']);
65
+ /** Run one `upt` invocation and return its exit code. */
52
66
  export async function runCli(argv, io = defaultIo) {
53
67
  const files = {};
54
68
  let json = false;
@@ -127,7 +141,7 @@ async function dispatch(argv, io) {
127
141
  if (!explainCmd) {
128
142
  throw new CliError("upt: the demo needs the 'explain' command, which is not registered yet");
129
143
  }
130
- const explainArgs = parseArgs('explain', ['hawking-temperature', 'mass=1.989e30'], explainCmd.flags);
144
+ const explainArgs = parseArgs('explain', ['hawking-temperature', 'mass=1.989e30'], explainCmd.flags, explainCmd.positionals);
131
145
  const explainCtx = { args: explainArgs, api, out, err, write };
132
146
  const explainStatus = await explainCmd.run(explainCtx);
133
147
  if (explainStatus !== 0)
@@ -136,7 +150,7 @@ async function dispatch(argv, io) {
136
150
  if (!priorityCmd) {
137
151
  throw new CliError("upt: the demo needs the 'priority' command, which is not registered yet");
138
152
  }
139
- const priorityArgs = parseArgs('priority', [], priorityCmd.flags);
153
+ const priorityArgs = parseArgs('priority', [], priorityCmd.flags, priorityCmd.positionals);
140
154
  const priorityCtx = { args: priorityArgs, api, out, err, write };
141
155
  return await priorityCmd.run(priorityCtx);
142
156
  }
@@ -183,7 +197,9 @@ async function dispatch(argv, io) {
183
197
  out(command.help);
184
198
  return 0;
185
199
  }
186
- const parsed = parseArgs(command.name, rest, command.flags);
200
+ // The parser refuses a positional past the command's declared arity (none when it
201
+ // declares none), so a token the command would not read never reaches `run`.
202
+ const parsed = parseArgs(command.name, rest, command.flags, command.positionals);
187
203
  const ctx = { args: parsed, api, out, err, write };
188
204
  return await command.run(ctx);
189
205
  }
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAiC,MAAM,cAAc,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAW,MAAM,aAAa,CAAC;AAClF,8EAA8E;AAC9E,OAAO,qBAAqB,CAAC;AAE7B,sEAAsE;AACtE,6EAA6E;AAC7E,8EAA8E;AAE9E,SAAS,UAAU,CAAC,IAAa;IA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f,OAAO,CAAC,CAAC;QACX,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC","sourcesContent":["/**\n * Verb-first dispatcher for the UPT CLI — `upt <command> [args...]`.\n *\n * Owns: top-level `help`/`version` handling, the no-args demo, unknown-verb\n * exit-2 contract, and per-command dispatch (parse -> run -> map thrown\n * UsageError/CliError to the documented exit codes). Individual commands are\n * plain data (see `command.ts`) registered via `registerCommand`; this file\n * never special-cases a command by name, so later tasks add commands without\n * touching `runCli`'s body.\n *\n * `main.ts` is the one place that imports the real `cli-api.js` barrel and\n * wires `out`/`err`/`write` to real stdio — every `Command.run` receives\n * those as an injected `CommandCtx`, never reaching for `process.*` itself,\n * which is what makes commands testable in-process against `dist/cli/*.js`.\n */\n\nimport * as api from '../cli-api.js';\nimport { UsageError, CliError } from './errors.js';\nimport { optionTokens, parseArgs } from './args.js';\nimport { packageVersion } from './version.js';\nimport { glossaryText } from './statuses.js';\nimport { listCommandNames, resolveCommand, type Command, type CommandCtx } from './command.js';\nimport { GLOBAL_FLAGS } from './flag-help.js';\nimport { renderTopLevelHelp } from './top-level-help.js';\nimport { recordInvocation, replayRecord, showRecord, type Io } from './record.js';\n// Side-effect import: registers every ported command (see commands/index.ts).\nimport './commands/index.js';\n\n// `Io` is the writer surface `runCli` needs. In production these wrap\n// `process.stdout`/`process.stderr` with exact `console.log`/`console.error`\n// semantics; tests pass a capturing stand-in as the optional second argument.\n\nfunction stdoutLine(line?: string): void {\n process.stdout.write((line ?? '') + '\\n');\n}\n\nfunction stderrLine(line?: string): void {\n process.stderr.write((line ?? '') + '\\n');\n}\n\nfunction stdoutRaw(s: string): void {\n process.stdout.write(s);\n}\n\nconst defaultIo: Io = { out: stdoutLine, err: stderrLine, write: stdoutRaw };\n\nconst unknownCommandMessage = (name: string): string => `Unknown command '${name}'. See \\`upt help\\`.`;\n\nconst GLOBAL_FILE_OPTION = /^--(record|replay|show-record)(?:=(.*))?$/;\n\n/**\n * Verb-first CLI entry point. `argv` is the command + its arguments (NOT\n * `process.argv` — callers slice off the node/script prefix themselves, as\n * `bin/upt.mjs` did with `process.argv.slice(2)`).\n *\n * Leading `--record=FILE` / `--replay=FILE` / `--show-record=FILE` / `--json`\n * are global options. `--json` is moved onto the command so the command's\n * own flag spec parses it. `upt <command> --help` prints that command.\n */\nconst NO_JSON_VERBS = new Set(['help', '--help', '-h', 'version', '--version', '-v']);\n\nexport async function runCli(argv: string[], io: Io = defaultIo): Promise<number> {\n const files: Partial<Record<'record' | 'replay' | 'show-record', string>> = {};\n let json = false;\n let i = 0;\n try {\n for (; i < argv.length; i++) {\n const m = GLOBAL_FILE_OPTION.exec(argv[i]);\n if (m) {\n const name = m[1] as keyof typeof files;\n if (!m[2]) throw new UsageError(`upt: '--${name}' requires '--${name}=FILE'`);\n if (files[name] !== undefined) throw new UsageError(`upt: '--${name}' given more than once`);\n files[name] = m[2];\n } else if (argv[i] === '--json') {\n if (json) throw new UsageError(`upt: '--json' given more than once`);\n json = true;\n } else {\n break;\n }\n }\n let rest = argv.slice(i);\n if (json && (files.replay !== undefined || files['show-record'] !== undefined)) {\n // `--replay` / `--show-record` consume --json themselves and take no command.\n } else if (json) {\n if (rest.length === 0) throw new UsageError(`upt: '--json' requires a command`);\n const verb = rest[0]!;\n if (NO_JSON_VERBS.has(verb)) throw new UsageError(`upt: '${verb}' does not take --json`);\n rest = [verb, '--json', ...rest.slice(1)];\n }\n if (i === 0 && !json) return await dispatch(argv, io);\n if (Object.keys(files).length > 1) {\n throw new UsageError('upt: use one of --record, --replay and --show-record at a time');\n }\n if (files.record !== undefined) return await recordInvocation(files.record, rest, dispatch, io, api);\n if (files.replay !== undefined || files['show-record'] !== undefined) {\n if (rest.length > 0) {\n throw new UsageError(`upt: '--${files.replay !== undefined ? 'replay' : 'show-record'}' takes no command (got '${rest[0]}')`);\n }\n if (files.replay !== undefined) return await replayRecord(files.replay, json, dispatch, io, api);\n return showRecord(files['show-record']!, json, io);\n }\n return await dispatch(rest, io);\n } catch (e) {\n if (e instanceof UsageError) {\n io.err(e.message);\n return 2;\n }\n if (e instanceof CliError) {\n io.err(e.message);\n return 1;\n }\n throw e;\n }\n}\n\nasync function dispatch(argv: string[], io: Io): Promise<number> {\n const { out, err, write } = io;\n\n try {\n const [cmd, ...rest] = argv;\n\n if (cmd === undefined) {\n // Byte-identical to bin/upt.mjs's `case undefined` (lines 861-865): a\n // banner line, then dispatch to the registered `explain` + `priority`\n // commands with their historical demo arguments.\n out('upt — bridge-inference CLI. Demo (run `upt help` for usage):');\n\n const explainCmd = resolveCommand('explain');\n if (!explainCmd) {\n throw new CliError(\"upt: the demo needs the 'explain' command, which is not registered yet\");\n }\n const explainArgs = parseArgs('explain', ['hawking-temperature', 'mass=1.989e30'], explainCmd.flags);\n const explainCtx: CommandCtx = { args: explainArgs, api, out, err, write };\n const explainStatus = await explainCmd.run(explainCtx);\n if (explainStatus !== 0) return explainStatus;\n\n const priorityCmd = resolveCommand('priority');\n if (!priorityCmd) {\n throw new CliError(\"upt: the demo needs the 'priority' command, which is not registered yet\");\n }\n const priorityArgs = parseArgs('priority', [], priorityCmd.flags);\n const priorityCtx: CommandCtx = { args: priorityArgs, api, out, err, write };\n return await priorityCmd.run(priorityCtx);\n }\n\n if (cmd === 'help' || cmd === '--help' || cmd === '-h') {\n if (rest.length > 1) throw new UsageError('upt help takes at most one command name');\n // `upt help -h` and `upt help --help` ask for the command list, as `upt help` does.\n const target = rest[0] === '--help' || rest[0] === '-h' ? undefined : rest[0];\n if (target === 'statuses') {\n out(glossaryText());\n return 0;\n }\n if (target !== undefined) {\n const command = resolveCommand(target);\n if (!command) throw new UsageError(unknownCommandMessage(target));\n out(command.help);\n return 0;\n }\n const commands: Command[] = [];\n for (const name of listCommandNames()) {\n const command = resolveCommand(name);\n if (command !== undefined) commands.push(command);\n }\n out(renderTopLevelHelp(commands, GLOBAL_FLAGS));\n return 0;\n }\n\n if (cmd === 'version' || cmd === '--version' || cmd === '-v') {\n if (rest.length > 0) throw new UsageError('upt version takes no arguments');\n out(packageVersion());\n return 0;\n }\n\n const command = resolveCommand(cmd);\n if (!command) {\n err(unknownCommandMessage(cmd));\n return 2;\n }\n\n // `-h` is `--help` on every command, as the global help says. A token after a\n // bare `--` is a positional, so it is not read as the help request.\n const options = optionTokens(rest);\n if (options.includes('--help') || options.includes('-h')) {\n out(command.help);\n return 0;\n }\n\n const parsed = parseArgs(command.name, rest, command.flags);\n const ctx: CommandCtx = { args: parsed, api, out, err, write };\n return await command.run(ctx);\n } catch (e) {\n if (e instanceof UsageError) {\n err(e.message);\n return 2;\n }\n if (e instanceof CliError) {\n err(e.message);\n return 1;\n }\n throw e;\n }\n}\n"]}
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAiC,MAAM,cAAc,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAW,MAAM,aAAa,CAAC;AAClF,8EAA8E;AAC9E,OAAO,qBAAqB,CAAC;AAE7B,sEAAsE;AACtE,6EAA6E;AAC7E,8EAA8E;AAE9E,SAAS,UAAU,CAAC,IAAa;IAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,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MAAM,GAAG,GAAe,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;QAC/D,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,UAAU,EAAE,CAAC;YAC5B,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACf,OAAO,CAAC,CAAC;QACX,CAAC;QACD,IAAI,CAAC,YAAY,QAAQ,EAAE,CAAC;YAC1B,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACf,OAAO,CAAC,CAAC;QACX,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC","sourcesContent":["/**\n * Verb-first dispatcher for the UPT CLI — `upt <command> [args...]`.\n *\n * Owns: top-level `help`/`version` handling, the no-args demo, unknown-verb\n * exit-2 contract, and per-command dispatch (parse -> run -> map thrown\n * UsageError/CliError to the documented exit codes). Individual commands are\n * plain data (see `command.ts`) registered via `registerCommand`; this file\n * never special-cases a command by name, so later tasks add commands without\n * touching `runCli`'s body.\n *\n * `main.ts` is the one place that imports the real `cli-api.js` barrel and\n * wires `out`/`err`/`write` to real stdio — every `Command.run` receives\n * those as an injected `CommandCtx`, never reaching for `process.*` itself,\n * which is what makes commands testable in-process against `dist/cli/*.js`.\n */\n\nimport * as api from '../cli-api.js';\nimport { UsageError, CliError } from './errors.js';\nimport { optionTokens, parseArgs } from './args.js';\nimport { packageVersion } from './version.js';\nimport { glossaryText } from './statuses.js';\nimport { listCommandNames, resolveCommand, type Command, type CommandCtx } from './command.js';\nimport { GLOBAL_FLAGS } from './flag-help.js';\nimport { renderTopLevelHelp } from './top-level-help.js';\nimport { recordInvocation, replayRecord, showRecord, type Io } from './record.js';\n// Side-effect import: registers every ported command (see commands/index.ts).\nimport './commands/index.js';\n\n// `Io` is the writer surface `runCli` needs. In production these wrap\n// `process.stdout`/`process.stderr` with exact `console.log`/`console.error`\n// semantics; tests pass a capturing stand-in as the optional second argument.\n\nfunction stdoutLine(line?: string): void {\n process.stdout.write((line ?? '') + '\\n');\n}\n\nfunction stderrLine(line?: string): void {\n process.stderr.write((line ?? '') + '\\n');\n}\n\nfunction stdoutRaw(s: string): void {\n process.stdout.write(s);\n}\n\nconst defaultIo: Io = { out: stdoutLine, err: stderrLine, write: stdoutRaw };\n\n/** EX_SOFTWARE (sysexits.h): the exit code of a defect, an error `runCli` did not map. */\nconst EX_SOFTWARE = 70;\n\n/**\n * The last-resort handler `bin/upt.mjs` calls when `runCli` rethrows: a defect, since every\n * usage error and value refusal was mapped to an exit code inside `runCli`. Prints one line,\n * `upt: internal error: <message>` (the message, not the stack), and returns 70 (EX_SOFTWARE).\n * A thrown value that is not an Error, or an Error with no message, prints as its string.\n */\nexport function reportInternalError(error: unknown, io: Pick<Io, 'err'> = defaultIo): number {\n const message = error instanceof Error && error.message !== '' ? error.message : String(error);\n io.err(`upt: internal error: ${message}`);\n return EX_SOFTWARE;\n}\n\nconst unknownCommandMessage = (name: string): string => `Unknown command '${name}'. See \\`upt help\\`.`;\n\nconst GLOBAL_FILE_OPTION = /^--(record|replay|show-record)(?:=(.*))?$/;\n\n/**\n * Verb-first CLI entry point. `argv` is the command + its arguments (NOT\n * `process.argv` — callers slice off the node/script prefix themselves, as\n * `bin/upt.mjs` did with `process.argv.slice(2)`).\n *\n * Leading `--record=FILE` / `--replay=FILE` / `--show-record=FILE` / `--json`\n * are global options. `--json` is moved onto the command so the command's\n * own flag spec parses it. `upt <command> --help` prints that command.\n */\nconst NO_JSON_VERBS = new Set(['help', '--help', '-h', 'version', '--version', '-v']);\n\n/** Run one `upt` invocation and return its exit code. */\nexport async function runCli(argv: string[], io: Io = defaultIo): Promise<number> {\n const files: Partial<Record<'record' | 'replay' | 'show-record', string>> = {};\n let json = false;\n let i = 0;\n try {\n for (; i < argv.length; i++) {\n const m = GLOBAL_FILE_OPTION.exec(argv[i]);\n if (m) {\n const name = m[1] as keyof typeof files;\n if (!m[2]) throw new UsageError(`upt: '--${name}' requires '--${name}=FILE'`);\n if (files[name] !== undefined) throw new UsageError(`upt: '--${name}' given more than once`);\n files[name] = m[2];\n } else if (argv[i] === '--json') {\n if (json) throw new UsageError(`upt: '--json' given more than once`);\n json = true;\n } else {\n break;\n }\n }\n let rest = argv.slice(i);\n if (json && (files.replay !== undefined || files['show-record'] !== undefined)) {\n // `--replay` / `--show-record` consume --json themselves and take no command.\n } else if (json) {\n if (rest.length === 0) throw new UsageError(`upt: '--json' requires a command`);\n const verb = rest[0]!;\n if (NO_JSON_VERBS.has(verb)) throw new UsageError(`upt: '${verb}' does not take --json`);\n rest = [verb, '--json', ...rest.slice(1)];\n }\n if (i === 0 && !json) return await dispatch(argv, io);\n if (Object.keys(files).length > 1) {\n throw new UsageError('upt: use one of --record, --replay and --show-record at a time');\n }\n if (files.record !== undefined) return await recordInvocation(files.record, rest, dispatch, io, api);\n if (files.replay !== undefined || files['show-record'] !== undefined) {\n if (rest.length > 0) {\n throw new UsageError(`upt: '--${files.replay !== undefined ? 'replay' : 'show-record'}' takes no command (got '${rest[0]}')`);\n }\n if (files.replay !== undefined) return await replayRecord(files.replay, json, dispatch, io, api);\n return showRecord(files['show-record']!, json, io);\n }\n return await dispatch(rest, io);\n } catch (e) {\n if (e instanceof UsageError) {\n io.err(e.message);\n return 2;\n }\n if (e instanceof CliError) {\n io.err(e.message);\n return 1;\n }\n throw e;\n }\n}\n\nasync function dispatch(argv: string[], io: Io): Promise<number> {\n const { out, err, write } = io;\n\n try {\n const [cmd, ...rest] = argv;\n\n if (cmd === undefined) {\n // Byte-identical to bin/upt.mjs's `case undefined` (lines 861-865): a\n // banner line, then dispatch to the registered `explain` + `priority`\n // commands with their historical demo arguments.\n out('upt — bridge-inference CLI. Demo (run `upt help` for usage):');\n\n const explainCmd = resolveCommand('explain');\n if (!explainCmd) {\n throw new CliError(\"upt: the demo needs the 'explain' command, which is not registered yet\");\n }\n const explainArgs = parseArgs('explain', ['hawking-temperature', 'mass=1.989e30'], explainCmd.flags, explainCmd.positionals);\n const explainCtx: CommandCtx = { args: explainArgs, api, out, err, write };\n const explainStatus = await explainCmd.run(explainCtx);\n if (explainStatus !== 0) return explainStatus;\n\n const priorityCmd = resolveCommand('priority');\n if (!priorityCmd) {\n throw new CliError(\"upt: the demo needs the 'priority' command, which is not registered yet\");\n }\n const priorityArgs = parseArgs('priority', [], priorityCmd.flags, priorityCmd.positionals);\n const priorityCtx: CommandCtx = { args: priorityArgs, api, out, err, write };\n return await priorityCmd.run(priorityCtx);\n }\n\n if (cmd === 'help' || cmd === '--help' || cmd === '-h') {\n if (rest.length > 1) throw new UsageError('upt help takes at most one command name');\n // `upt help -h` and `upt help --help` ask for the command list, as `upt help` does.\n const target = rest[0] === '--help' || rest[0] === '-h' ? undefined : rest[0];\n if (target === 'statuses') {\n out(glossaryText());\n return 0;\n }\n if (target !== undefined) {\n const command = resolveCommand(target);\n if (!command) throw new UsageError(unknownCommandMessage(target));\n out(command.help);\n return 0;\n }\n const commands: Command[] = [];\n for (const name of listCommandNames()) {\n const command = resolveCommand(name);\n if (command !== undefined) commands.push(command);\n }\n out(renderTopLevelHelp(commands, GLOBAL_FLAGS));\n return 0;\n }\n\n if (cmd === 'version' || cmd === '--version' || cmd === '-v') {\n if (rest.length > 0) throw new UsageError('upt version takes no arguments');\n out(packageVersion());\n return 0;\n }\n\n const command = resolveCommand(cmd);\n if (!command) {\n err(unknownCommandMessage(cmd));\n return 2;\n }\n\n // `-h` is `--help` on every command, as the global help says. A token after a\n // bare `--` is a positional, so it is not read as the help request.\n const options = optionTokens(rest);\n if (options.includes('--help') || options.includes('-h')) {\n out(command.help);\n return 0;\n }\n\n // The parser refuses a positional past the command's declared arity (none when it\n // declares none), so a token the command would not read never reaches `run`.\n const parsed = parseArgs(command.name, rest, command.flags, command.positionals);\n const ctx: CommandCtx = { args: parsed, api, out, err, write };\n return await command.run(ctx);\n } catch (e) {\n if (e instanceof UsageError) {\n err(e.message);\n return 2;\n }\n if (e instanceof CliError) {\n err(e.message);\n return 1;\n }\n throw e;\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The integer a flag was given, or a `UsageError` naming the flag and the token.
3
+ * `command` is the command word for the message (`''` for an option of upt itself);
4
+ * `label` names the flag (`--max-routes`, or `--sweep sample count` for one field of a value).
5
+ */
6
+ export declare function integerFlag(command: string, label: string, raw: string): number;
7
+ /**
8
+ * The real number a flag was given, or a `UsageError` naming the flag and the token. The
9
+ * arguments are {@link integerFlag}'s. An exponent is a decimal form (`1e-3`); hex is not.
10
+ */
11
+ export declare function realFlag(command: string, label: string, raw: string): number;
12
+ //# sourceMappingURL=numeric-flag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numeric-flag.d.ts","sourceRoot":"","sources":["../../src/cli/numeric-flag.ts"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAO/E;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAO5E"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The one reader of a numeric flag value for the UPT CLI.
3
+ *
4
+ * `Number()` accepts hex (`0x10`), binary, octal, an exponent on an integer (`1e1`), and reads
5
+ * `''` and whitespace as 0, so a flag read through it took a value the user did not type
6
+ * (`upt map --max-routes=0x10` ran with 16). An integer flag is digits with an optional sign; a
7
+ * real flag is a decimal with an optional fraction and exponent, the AST's one literal rule
8
+ * (`DECIMAL_LITERAL`, `src/dimensional/ast-leaves.ts`). A token outside the grammar is
9
+ * a malformed invocation (`UsageError`, exit 2) naming the flag and the token; a well-formed
10
+ * value outside the flag's range is the command's own value refusal (exit 1), judged after.
11
+ *
12
+ * @module cli/numeric-flag
13
+ * @internal
14
+ */
15
+ import { DECIMAL_LITERAL } from '../dimensional/ast-leaves.js';
16
+ import { UsageError } from './errors.js';
17
+ /** `3`, `-2`, `+7`, `010`: digits with an optional sign, nothing else. */
18
+ const INTEGER = /^[+-]?\d+$/;
19
+ /** The help pointer, worded as the parser's unknown-flag message words it. */
20
+ function hint(command) {
21
+ return command === '' ? 'see upt help' : `see upt help ${command.split(' ')[0]}`;
22
+ }
23
+ /**
24
+ * The integer a flag was given, or a `UsageError` naming the flag and the token.
25
+ * `command` is the command word for the message (`''` for an option of upt itself);
26
+ * `label` names the flag (`--max-routes`, or `--sweep sample count` for one field of a value).
27
+ */
28
+ export function integerFlag(command, label, raw) {
29
+ if (!INTEGER.test(raw)) {
30
+ throw new UsageError(`upt${command === '' ? '' : ` ${command}`}: ${label} '${raw}' is not an integer (digits only, such as 3 or -2; ${hint(command)})`);
31
+ }
32
+ return Number(raw);
33
+ }
34
+ /**
35
+ * The real number a flag was given, or a `UsageError` naming the flag and the token. The
36
+ * arguments are {@link integerFlag}'s. An exponent is a decimal form (`1e-3`); hex is not.
37
+ */
38
+ export function realFlag(command, label, raw) {
39
+ if (!DECIMAL_LITERAL.test(raw)) {
40
+ throw new UsageError(`upt${command === '' ? '' : ` ${command}`}: ${label} '${raw}' is not a number (a decimal such as 2, 0.5 or 1e-3; ${hint(command)})`);
41
+ }
42
+ return Number(raw);
43
+ }
44
+ //# sourceMappingURL=numeric-flag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numeric-flag.js","sourceRoot":"","sources":["../../src/cli/numeric-flag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,0EAA0E;AAC1E,MAAM,OAAO,GAAG,YAAY,CAAC;AAE7B,8EAA8E;AAC9E,SAAS,IAAI,CAAC,OAAe;IAC3B,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,gBAAgB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,KAAa,EAAE,GAAW;IACrE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,UAAU,CAClB,MAAM,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,KAAK,KAAK,KAAK,GAAG,sDAAsD,IAAI,CAAC,OAAO,CAAC,GAAG,CAClI,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,KAAa,EAAE,GAAW;IAClE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,UAAU,CAClB,MAAM,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,KAAK,KAAK,KAAK,GAAG,wDAAwD,IAAI,CAAC,OAAO,CAAC,GAAG,CACpI,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC","sourcesContent":["/**\n * The one reader of a numeric flag value for the UPT CLI.\n *\n * `Number()` accepts hex (`0x10`), binary, octal, an exponent on an integer (`1e1`), and reads\n * `''` and whitespace as 0, so a flag read through it took a value the user did not type\n * (`upt map --max-routes=0x10` ran with 16). An integer flag is digits with an optional sign; a\n * real flag is a decimal with an optional fraction and exponent, the AST's one literal rule\n * (`DECIMAL_LITERAL`, `src/dimensional/ast-leaves.ts`). A token outside the grammar is\n * a malformed invocation (`UsageError`, exit 2) naming the flag and the token; a well-formed\n * value outside the flag's range is the command's own value refusal (exit 1), judged after.\n *\n * @module cli/numeric-flag\n * @internal\n */\nimport { DECIMAL_LITERAL } from '../dimensional/ast-leaves.js';\nimport { UsageError } from './errors.js';\n\n/** `3`, `-2`, `+7`, `010`: digits with an optional sign, nothing else. */\nconst INTEGER = /^[+-]?\\d+$/;\n\n/** The help pointer, worded as the parser's unknown-flag message words it. */\nfunction hint(command: string): string {\n return command === '' ? 'see upt help' : `see upt help ${command.split(' ')[0]}`;\n}\n\n/**\n * The integer a flag was given, or a `UsageError` naming the flag and the token.\n * `command` is the command word for the message (`''` for an option of upt itself);\n * `label` names the flag (`--max-routes`, or `--sweep sample count` for one field of a value).\n */\nexport function integerFlag(command: string, label: string, raw: string): number {\n if (!INTEGER.test(raw)) {\n throw new UsageError(\n `upt${command === '' ? '' : ` ${command}`}: ${label} '${raw}' is not an integer (digits only, such as 3 or -2; ${hint(command)})`,\n );\n }\n return Number(raw);\n}\n\n/**\n * The real number a flag was given, or a `UsageError` naming the flag and the token. The\n * arguments are {@link integerFlag}'s. An exponent is a decimal form (`1e-3`); hex is not.\n */\nexport function realFlag(command: string, label: string, raw: string): number {\n if (!DECIMAL_LITERAL.test(raw)) {\n throw new UsageError(\n `upt${command === '' ? '' : ` ${command}`}: ${label} '${raw}' is not a number (a decimal such as 2, 0.5 or 1e-3; ${hint(command)})`,\n );\n }\n return Number(raw);\n}\n"]}
@@ -7,7 +7,27 @@
7
7
  * deep-copies a value into a JSON-safe shape first, encoding NaN/Infinity
8
8
  * as explicit strings so round-tripping through JSON preserves them.
9
9
  */
10
+ import { UsageError, type CliError } from './errors.js';
10
11
  import type { AnchorScope } from './graphs.js';
12
+ /**
13
+ * The `--json` form of a refusal: no `result`; the error's kind (`usage` for a malformed
14
+ * invocation, `value` for a value the command refuses), the exit code the process returns,
15
+ * and the message the text mode prints on stderr.
16
+ */
17
+ export interface JsonErrorEnvelope {
18
+ command: string;
19
+ error: {
20
+ kind: 'usage' | 'value';
21
+ exitCode: 1 | 2;
22
+ message: string;
23
+ };
24
+ }
25
+ /**
26
+ * Write a refusal as a JSON envelope on stdout and return the exit code it stands for: 2 for a
27
+ * `UsageError`, 1 for a `CliError`. A command that answers in JSON calls this instead of
28
+ * letting the dispatcher print the message on stderr, so a JSON consumer reads one stream.
29
+ */
30
+ export declare function emitJsonError(command: string, e: UsageError | CliError, write?: (s: string) => void): 1 | 2;
11
31
  /** The shape of every `--json` output: the command, what it read, and its result. */
12
32
  export interface JsonEnvelope {
13
33
  command: string;
@@ -38,6 +58,14 @@ export interface JsonEnvelope {
38
58
  */
39
59
  compositionRecovery?: unknown;
40
60
  }
61
+ /**
62
+ * Make a value JSON-safe. NaN and infinite numbers become strings.
63
+ * A function is omitted from an object and becomes null in an array.
64
+ */
41
65
  export declare function sanitize(v: unknown): unknown;
66
+ /**
67
+ * Write the `--json` envelope of one command to `write`.
68
+ * The status definitions of the command are added when it has any.
69
+ */
42
70
  export declare function emitJson(env: JsonEnvelope, write?: (s: string) => void): void;
43
71
  //# sourceMappingURL=output.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,qFAAqF;AACrF,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC;IACpD,4GAA4G;IAC5G,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,iBAAiB,CAAC,EAA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rF,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC;IACpD,4GAA4G;IAC5G,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,gHAAgH;IAChH,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,4GAA4G;IAC5G,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClE;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CA2C5C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,GAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAqC,GAAG,IAAI,CAK7G"}
@@ -8,6 +8,25 @@
8
8
  * as explicit strings so round-tripping through JSON preserves them.
9
9
  */
10
10
  import { definitionsFor } from './statuses.js';
11
+ import { UsageError } from './errors.js';
12
+ /**
13
+ * Write a refusal as a JSON envelope on stdout and return the exit code it stands for: 2 for a
14
+ * `UsageError`, 1 for a `CliError`. A command that answers in JSON calls this instead of
15
+ * letting the dispatcher print the message on stderr, so a JSON consumer reads one stream.
16
+ */
17
+ export function emitJsonError(command, e, write = (s) => process.stdout.write(s)) {
18
+ const usage = e instanceof UsageError;
19
+ const envelope = {
20
+ command,
21
+ error: { kind: usage ? 'usage' : 'value', exitCode: usage ? 2 : 1, message: e.message },
22
+ };
23
+ write(JSON.stringify(envelope, null, 2) + '\n');
24
+ return envelope.error.exitCode;
25
+ }
26
+ /**
27
+ * Make a value JSON-safe. NaN and infinite numbers become strings.
28
+ * A function is omitted from an object and becomes null in an array.
29
+ */
11
30
  export function sanitize(v) {
12
31
  if (typeof v === 'number') {
13
32
  if (Number.isNaN(v))
@@ -52,6 +71,10 @@ export function sanitize(v) {
52
71
  }
53
72
  return v;
54
73
  }
74
+ /**
75
+ * Write the `--json` envelope of one command to `write`.
76
+ * The status definitions of the command are added when it has any.
77
+ */
55
78
  export function emitJson(env, write = (s) => process.stdout.write(s)) {
56
79
  const definitions = definitionsFor(env.command);
57
80
  const { result, ...head } = env;
@@ -1 +1 @@
1
- {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAkC/C,MAAM,UAAU,QAAQ,CAAC,CAAU;IACjC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QAClC,IAAI,CAAC,KAAK,QAAQ;YAAE,OAAO,UAAU,CAAC;QACtC,IAAI,CAAC,KAAK,CAAC,QAAQ;YAAE,OAAO,WAAW,CAAC;QACxC,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,OAAO,CAAC,KAAK,UAAU,EAAE,CAAC;QAC5B,wEAAwE;QACxE,uEAAuE;QACvE,6CAA6C;QAC7C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACrB,MAAM,GAAG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AC,OAAO,CAAC,CAAC;IAChD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,CAAC;IAChC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IAC1F,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/**\n * JSON output envelope for the UPT CLI.\n *\n * Physics results genuinely contain non-finite numbers (e.g. `anchoring:\n * Infinity` in the priority board). `JSON.stringify` silently turns those\n * into `null`, which is indistinguishable from an absent value. `sanitize`\n * deep-copies a value into a JSON-safe shape first, encoding NaN/Infinity\n * as explicit strings so round-tripping through JSON preserves them.\n */\n\nimport { definitionsFor } from './statuses.js';\nimport type { AnchorScope } from './graphs.js';\n\n/** The shape of every `--json` output: the command, what it read, and its result. */\nexport interface JsonEnvelope {\n command: string;\n /**\n * The graph a command read. `'atlas'` is `upt map --route` / `--family`,\n * which read the atlas families rather than an equation graph.\n */\n source?: 'catalog' | 'canonical' | 'both' | 'atlas';\n /** What the result is anchored to (audit I3): the discovery ground truth, the established core, or both. */\n anchor?: AnchorScope;\n options?: Record<string, unknown>;\n epistemics?: string;\n /** `upt confront` — count of confrontations by rigor tier (stringent/moderate/loose). */\n rigorDistribution?: Record<string, number>;\n /** `upt confront` — count of confrontations by statistical object (σ-test, limit, consistency ratio, table). */\n statisticDistribution?: Record<string, number>;\n /** `upt confront` — preprocessing and independence counts, recorded vs not recorded, each counted apart. */\n dataHandlingDistribution?: Record<string, Record<string, number>>;\n /**\n * The meaning of each status the command can emit, from STATUS_GLOSSARY (audit I13). `emitJson`\n * fills it in; a command never sets it.\n */\n definitions?: Record<string, string>;\n result: unknown;\n /**\n * `upt recover` — two-edge symbolic chains examined against the canonical\n * registry, and the structural matches. A chain is never restates-canonical.\n */\n compositionRecovery?: unknown;\n}\n\nexport function sanitize(v: unknown): unknown {\n if (typeof v === 'number') {\n if (Number.isNaN(v)) return 'NaN';\n if (v === Infinity) return 'Infinity';\n if (v === -Infinity) return '-Infinity';\n return v;\n }\n\n if (typeof v === 'function') {\n // Caller decides how to represent \"no value here\" (omit vs. null) based\n // on context (object key vs. array slot); signal via undefined and let\n // the array/object branches below handle it.\n return undefined;\n }\n\n if (Array.isArray(v)) {\n const out: unknown[] = [];\n for (const item of v) {\n const sanitized = sanitize(item);\n out.push(typeof item === 'function' ? null : sanitized);\n }\n return out;\n }\n\n if (v instanceof Map) {\n const out: Record<string, unknown> = {};\n for (const [key, value] of v) {\n if (typeof value === 'function') continue;\n out[String(key)] = sanitize(value);\n }\n return out;\n }\n\n if (v !== null && typeof v === 'object') {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(v)) {\n if (value === undefined || typeof value === 'function') continue;\n out[key] = sanitize(value);\n }\n return out;\n }\n\n return v;\n}\n\nexport function emitJson(env: JsonEnvelope, write: (s: string) => void = (s) => process.stdout.write(s)): void {\n const definitions = definitionsFor(env.command);\n const { result, ...head } = env;\n const full = Object.keys(definitions).length > 0 ? { ...head, definitions, result } : env;\n write(JSON.stringify(sanitize(full), null, 2) + '\\n');\n}\n"]}
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAiB,MAAM,aAAa,CAAC;AAaxD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAe,EACf,CAAwB,EACxB,KAAK,GAAwB,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAA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AW,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IAC1F,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/**\n * JSON output envelope for the UPT CLI.\n *\n * Physics results genuinely contain non-finite numbers (e.g. `anchoring:\n * Infinity` in the priority board). `JSON.stringify` silently turns those\n * into `null`, which is indistinguishable from an absent value. `sanitize`\n * deep-copies a value into a JSON-safe shape first, encoding NaN/Infinity\n * as explicit strings so round-tripping through JSON preserves them.\n */\n\nimport { definitionsFor } from './statuses.js';\nimport { UsageError, type CliError } from './errors.js';\nimport type { AnchorScope } from './graphs.js';\n\n/**\n * The `--json` form of a refusal: no `result`; the error's kind (`usage` for a malformed\n * invocation, `value` for a value the command refuses), the exit code the process returns,\n * and the message the text mode prints on stderr.\n */\nexport interface JsonErrorEnvelope {\n command: string;\n error: { kind: 'usage' | 'value'; exitCode: 1 | 2; message: string };\n}\n\n/**\n * Write a refusal as a JSON envelope on stdout and return the exit code it stands for: 2 for a\n * `UsageError`, 1 for a `CliError`. A command that answers in JSON calls this instead of\n * letting the dispatcher print the message on stderr, so a JSON consumer reads one stream.\n */\nexport function emitJsonError(\n command: string,\n e: UsageError | CliError,\n write: (s: string) => void = (s) => process.stdout.write(s),\n): 1 | 2 {\n const usage = e instanceof UsageError;\n const envelope: JsonErrorEnvelope = {\n command,\n error: { kind: usage ? 'usage' : 'value', exitCode: usage ? 2 : 1, message: e.message },\n };\n write(JSON.stringify(envelope, null, 2) + '\\n');\n return envelope.error.exitCode;\n}\n\n/** The shape of every `--json` output: the command, what it read, and its result. */\nexport interface JsonEnvelope {\n command: string;\n /**\n * The graph a command read. `'atlas'` is `upt map --route` / `--family`,\n * which read the atlas families rather than an equation graph.\n */\n source?: 'catalog' | 'canonical' | 'both' | 'atlas';\n /** What the result is anchored to (audit I3): the discovery ground truth, the established core, or both. */\n anchor?: AnchorScope;\n options?: Record<string, unknown>;\n epistemics?: string;\n /** `upt confront` — count of confrontations by rigor tier (stringent/moderate/loose). */\n rigorDistribution?: Record<string, number>;\n /** `upt confront` — count of confrontations by statistical object (σ-test, limit, consistency ratio, table). */\n statisticDistribution?: Record<string, number>;\n /** `upt confront` — preprocessing and independence counts, recorded vs not recorded, each counted apart. */\n dataHandlingDistribution?: Record<string, Record<string, number>>;\n /**\n * The meaning of each status the command can emit, from STATUS_GLOSSARY (audit I13). `emitJson`\n * fills it in; a command never sets it.\n */\n definitions?: Record<string, string>;\n result: unknown;\n /**\n * `upt recover` — two-edge symbolic chains examined against the canonical\n * registry, and the structural matches. A chain is never restates-canonical.\n */\n compositionRecovery?: unknown;\n}\n\n/**\n * Make a value JSON-safe. NaN and infinite numbers become strings.\n * A function is omitted from an object and becomes null in an array.\n */\nexport function sanitize(v: unknown): unknown {\n if (typeof v === 'number') {\n if (Number.isNaN(v)) return 'NaN';\n if (v === Infinity) return 'Infinity';\n if (v === -Infinity) return '-Infinity';\n return v;\n }\n\n if (typeof v === 'function') {\n // Caller decides how to represent \"no value here\" (omit vs. null) based\n // on context (object key vs. array slot); signal via undefined and let\n // the array/object branches below handle it.\n return undefined;\n }\n\n if (Array.isArray(v)) {\n const out: unknown[] = [];\n for (const item of v) {\n const sanitized = sanitize(item);\n out.push(typeof item === 'function' ? null : sanitized);\n }\n return out;\n }\n\n if (v instanceof Map) {\n const out: Record<string, unknown> = {};\n for (const [key, value] of v) {\n if (typeof value === 'function') continue;\n out[String(key)] = sanitize(value);\n }\n return out;\n }\n\n if (v !== null && typeof v === 'object') {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(v)) {\n if (value === undefined || typeof value === 'function') continue;\n out[key] = sanitize(value);\n }\n return out;\n }\n\n return v;\n}\n\n/**\n * Write the `--json` envelope of one command to `write`.\n * The status definitions of the command are added when it has any.\n */\nexport function emitJson(env: JsonEnvelope, write: (s: string) => void = (s) => process.stdout.write(s)): void {\n const definitions = definitionsFor(env.command);\n const { result, ...head } = env;\n const full = Object.keys(definitions).length > 0 ? { ...head, definitions, result } : env;\n write(JSON.stringify(sanitize(full), null, 2) + '\\n');\n}\n"]}
@@ -18,7 +18,7 @@
18
18
  * The same import graph gives the modules the command loads. Each one's source is hashed, so a
19
19
  * change to a literal a module keeps private, which no constant table holds, is still named.
20
20
  */
21
- import { createHash } from 'node:crypto';
21
+ import { sha256Hex } from '../core/hash.js';
22
22
  import { existsSync, readFileSync } from 'node:fs';
23
23
  import { dirname, join, resolve, sep } from 'node:path';
24
24
  import { MODULE_EXT, SOURCE_ROOT, tableName } from './record-tables.js';
@@ -157,7 +157,7 @@ function loadedModules(command) {
157
157
  */
158
158
  export function sourceHash(file) {
159
159
  try {
160
- return createHash('sha256').update(readFileSync(file)).digest('hex');
160
+ return sha256Hex(readFileSync(file));
161
161
  }
162
162
  catch (e) {
163
163
  const code = e instanceof Error && 'code' in e && typeof e.code === 'string' ? e.code : 'error';