progmune-runtime 2.1.6 → 3.2.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 (356) hide show
  1. package/README.md +108 -468
  2. package/dist/ablation-study.js +144 -0
  3. package/dist/ablation-study.test.js +18 -0
  4. package/dist/action-runtime.js +3 -1
  5. package/dist/active-learning.js +211 -0
  6. package/dist/analytics.js +139 -0
  7. package/dist/asset-factory.js +309 -0
  8. package/dist/asset-growth.js +244 -0
  9. package/dist/asset-promotion.js +382 -0
  10. package/dist/asset-quality.js +550 -0
  11. package/dist/audit/business-translator.js +285 -0
  12. package/dist/audit/cli.js +66 -0
  13. package/dist/audit/formatters/html.js +379 -0
  14. package/dist/audit/formatters/json.js +11 -0
  15. package/dist/audit/formatters/markdown.js +192 -0
  16. package/dist/audit/formatters/terminal.js +189 -0
  17. package/dist/audit/index.js +25 -0
  18. package/dist/audit/report-builder.js +318 -0
  19. package/dist/audit/types.js +8 -0
  20. package/dist/audit.js +3 -3
  21. package/dist/auto-benchmark-generator.js +137 -0
  22. package/dist/auto-benchmark-generator.test.js +45 -0
  23. package/dist/auto-protocol-synthesizer.js +362 -0
  24. package/dist/auto-protocol-synthesizer.test.js +82 -0
  25. package/dist/autonomous-patch.js +175 -0
  26. package/dist/autonomous-patch.test.js +128 -0
  27. package/dist/badge/badge-server.js +98 -0
  28. package/dist/behavior-miner.js +442 -0
  29. package/dist/belief-layer.js +475 -0
  30. package/dist/benchmark-count.js +5 -0
  31. package/dist/benchmark-generator.js +211 -0
  32. package/dist/benchmark-harness.js +201 -0
  33. package/dist/benchmark-pass-rate.js +7 -0
  34. package/dist/benchmark-report.js +8 -3
  35. package/dist/benchmark-save.js +14 -1
  36. package/dist/bootstrap-validation.js +197 -0
  37. package/dist/bootstrap-validation.test.js +51 -0
  38. package/dist/branch-ledger.js +1 -1
  39. package/dist/capability-gap.js +130 -0
  40. package/dist/certify-html.js +351 -0
  41. package/dist/certify.js +326 -0
  42. package/dist/check.js +4 -4
  43. package/dist/compliance-miner.js +447 -0
  44. package/dist/continuous-benchmark.js +194 -0
  45. package/dist/continuous-benchmark.test.js +116 -0
  46. package/dist/corpus-stats.js +173 -0
  47. package/dist/counterfactual-engine.js +288 -0
  48. package/dist/coverage-dashboard.js +109 -0
  49. package/dist/coverage-system.test.js +205 -0
  50. package/dist/cross-repo-precision.js +352 -0
  51. package/dist/cve-benchmark.js +180 -0
  52. package/dist/cve-benchmark.test.js +28 -0
  53. package/dist/cve-collector.js +73 -0
  54. package/dist/data-quality.js +141 -0
  55. package/dist/decision-engine.js +388 -0
  56. package/dist/derive-metadata.js +250 -0
  57. package/dist/difficulty-active.test.js +198 -0
  58. package/dist/difficulty-map.js +244 -0
  59. package/dist/discovery-analytics.js +125 -0
  60. package/dist/discovery-model.js +149 -0
  61. package/dist/discovery-optimize.test.js +199 -0
  62. package/dist/discovery-trace.js +276 -0
  63. package/dist/discovery-trace.test.js +97 -0
  64. package/dist/emitter.js +83 -1
  65. package/dist/enterprise-dashboard.js +405 -0
  66. package/dist/eval-hardening.js +297 -0
  67. package/dist/eval-hardening.test.js +85 -0
  68. package/dist/evaluation-campaign.js +359 -0
  69. package/dist/evaluation-campaign.test.js +181 -0
  70. package/dist/evidence-growth.js +143 -0
  71. package/dist/evidence-repository.js +209 -0
  72. package/dist/evidence-system.js +441 -0
  73. package/dist/execute.js +15 -7
  74. package/dist/experimental/software-physics.js +291 -0
  75. package/dist/experimental/state-inference.js +516 -0
  76. package/dist/experimental/unsupervised-physics.js +230 -0
  77. package/dist/extract-ir-python.js +54 -7
  78. package/dist/extract-ir.js +376 -12
  79. package/dist/failure-collector.js +2 -2
  80. package/dist/failure-corpus.js +322 -9
  81. package/dist/feedback.js +16 -5
  82. package/dist/feedback.test.js +49 -0
  83. package/dist/file-lock.js +1 -1
  84. package/dist/flywheel-batch.js +292 -0
  85. package/dist/frameworks/express-cli.js +237 -0
  86. package/dist/frameworks/express-detector.js +445 -0
  87. package/dist/frameworks/express-detector.test.js +206 -0
  88. package/dist/frameworks/index.js +30 -0
  89. package/dist/frameworks/nestjs-detector.js +302 -0
  90. package/dist/frameworks/trpc-detector.js +161 -0
  91. package/dist/frameworks/version-awareness.js +179 -0
  92. package/dist/function-synonyms.js +164 -0
  93. package/dist/function-synonyms.test.js +68 -0
  94. package/dist/generalization.test.js +352 -0
  95. package/dist/goal-annotator.js +113 -0
  96. package/dist/goal-planner.js +563 -0
  97. package/dist/gold-cve.js +164 -0
  98. package/dist/gold-cve.test.js +104 -0
  99. package/dist/gold-quality.js +206 -0
  100. package/dist/gold-tiers.js +241 -0
  101. package/dist/governance-dashboard.js +327 -0
  102. package/dist/graph-viz.js +240 -0
  103. package/dist/guided-frontier.js +195 -0
  104. package/dist/hierarchical-planner.js +148 -0
  105. package/dist/identifier-parser.js +260 -0
  106. package/dist/immune-metrics.js +93 -0
  107. package/dist/immune-receiver.js +158 -0
  108. package/dist/immune-reporter.js +1 -1
  109. package/dist/improvement-orchestrator.js +206 -0
  110. package/dist/inject-p0-vocabulary.js +300 -0
  111. package/dist/intent-parser.js +218 -0
  112. package/dist/invariant-algebra.js +476 -0
  113. package/dist/invariant-calculus.js +533 -0
  114. package/dist/ir-utils.js +70 -0
  115. package/dist/ir-utils.test.js +50 -0
  116. package/dist/knowledge-api.js +312 -0
  117. package/dist/knowledge-evolution.js +452 -0
  118. package/dist/knowledge-explorer.js +506 -0
  119. package/dist/knowledge-flywheel.js +274 -0
  120. package/dist/knowledge-governance.js +338 -0
  121. package/dist/knowledge-governance.test.js +150 -0
  122. package/dist/knowledge-graph.js +181 -0
  123. package/dist/knowledge-guided-synth.js +246 -0
  124. package/dist/knowledge-loop.test.js +77 -0
  125. package/dist/knowledge-object.js +316 -0
  126. package/dist/knowledge-package.js +98 -0
  127. package/dist/kpi-dashboard.js +561 -0
  128. package/dist/l3-cross-function.js +280 -0
  129. package/dist/learning-ranker.js +148 -0
  130. package/dist/learning-ranker.test.js +291 -0
  131. package/dist/ledger/accountability.js +322 -0
  132. package/dist/ledger/chain-builder.js +185 -0
  133. package/dist/ledger/cli.js +222 -0
  134. package/dist/ledger/index.js +13 -0
  135. package/dist/ledger/signatures.js +193 -0
  136. package/dist/ledger/types.js +9 -0
  137. package/dist/llm.js +74 -3
  138. package/dist/load-benchmarks.js +8 -3
  139. package/dist/logger.js +66 -0
  140. package/dist/logger.test.js +37 -0
  141. package/dist/logistic-reward.js +339 -0
  142. package/dist/logistic-reward.test.js +180 -0
  143. package/dist/macro-graph.js +193 -0
  144. package/dist/macro-repair.js +183 -0
  145. package/dist/mcp-server.mjs +1202 -483
  146. package/dist/memory-layer.js +42 -5
  147. package/dist/multi-repo-precision.js +422 -0
  148. package/dist/name-free-protocol.js +425 -0
  149. package/dist/name-free-protocol.test.js +170 -0
  150. package/dist/name-scrambling.js +138 -0
  151. package/dist/name-scrambling.test.js +16 -0
  152. package/dist/p3-observability.test.js +281 -0
  153. package/dist/p5-orchestrator.test.js +225 -0
  154. package/dist/pairwise-preference.js +294 -0
  155. package/dist/pairwise-preference.test.js +140 -0
  156. package/dist/planner-constraints.js +104 -0
  157. package/dist/planner-prompts.js +155 -0
  158. package/dist/planner-telemetry.js +415 -0
  159. package/dist/planner-trace.js +214 -0
  160. package/dist/planner.js +162 -167
  161. package/dist/plsb/artifact.js +116 -0
  162. package/dist/plsb/cli.js +71 -0
  163. package/dist/plsb/index.js +19 -0
  164. package/dist/plsb/leaderboard.js +249 -0
  165. package/dist/plsb/report-md.js +156 -0
  166. package/dist/plsb/schema.js +179 -0
  167. package/dist/plsb-benchmark.js +284 -0
  168. package/dist/plsb-benchmark.test.js +119 -0
  169. package/dist/policy/cli.js +134 -0
  170. package/dist/policy/engine.js +333 -0
  171. package/dist/policy/index.js +12 -0
  172. package/dist/policy/types.js +59 -0
  173. package/dist/policy-miner.js +505 -0
  174. package/dist/precision-analyze.js +229 -0
  175. package/dist/precision-benchmark.js +147 -0
  176. package/dist/precision-label-c.js +134 -0
  177. package/dist/precision-label.js +193 -0
  178. package/dist/precision-report-c.js +149 -0
  179. package/dist/precision-report.js +246 -0
  180. package/dist/progmune-status.js +108 -0
  181. package/dist/proof-engine.js +479 -0
  182. package/dist/proof-provenance.js +315 -0
  183. package/dist/protocol-coverage.js +294 -0
  184. package/dist/protocol-detector.js +1189 -0
  185. package/dist/protocol-embedding-expanded.js +297 -0
  186. package/dist/protocol-embedding-expanded.test.js +97 -0
  187. package/dist/protocol-embedding.js +195 -0
  188. package/dist/protocol-embedding.test.js +82 -0
  189. package/dist/protocol-extractor-v2.js +354 -0
  190. package/dist/protocol-extractor-v2.test.js +140 -0
  191. package/dist/protocol-extractor.js +310 -0
  192. package/dist/protocol-extractor.test.js +113 -0
  193. package/dist/protocol-foundation.js +322 -0
  194. package/dist/protocol-foundation.test.js +163 -0
  195. package/dist/protocol-frontier.js +243 -0
  196. package/dist/protocol-frontier.test.js +92 -0
  197. package/dist/protocol-gap-analyzer.js +228 -0
  198. package/dist/protocol-gap-analyzer.test.js +49 -0
  199. package/dist/protocol-invariants.js +276 -0
  200. package/dist/protocol-invariants.test.js +111 -0
  201. package/dist/protocol-knowledge.js +464 -0
  202. package/dist/protocol-miner.js +343 -0
  203. package/dist/protocol-mining.js +207 -0
  204. package/dist/protocol-mining.test.js +37 -0
  205. package/dist/protocol-registry.js +1 -1
  206. package/dist/protocol-security-benchmark.js +222 -0
  207. package/dist/protocol-vulnerability.js +257 -0
  208. package/dist/protocol-vulnerability.test.js +60 -0
  209. package/dist/python-benchmark.js +120 -0
  210. package/dist/python-emitter.js +163 -45
  211. package/dist/python-protocol-extractor.js +187 -0
  212. package/dist/python-protocol-extractor.test.js +116 -0
  213. package/dist/realworld-benchmark.js +646 -0
  214. package/dist/realworld-benchmark.test.js +36 -0
  215. package/dist/repair-arch.test.js +411 -0
  216. package/dist/repair-evolution.test.js +454 -0
  217. package/dist/repair-executor.js +719 -0
  218. package/dist/repair-proposal.js +4 -4
  219. package/dist/repair-ranker.js +141 -0
  220. package/dist/repair-strategies.js +419 -0
  221. package/dist/repair-taxonomy.js +234 -0
  222. package/dist/repair-types.js +12 -0
  223. package/dist/repo-evaluator.js +250 -0
  224. package/dist/repo-evaluator.test.js +128 -0
  225. package/dist/resource-abstraction.js +242 -0
  226. package/dist/resource-detector.js +211 -0
  227. package/dist/result.test.js +43 -0
  228. package/dist/reward-system.js +411 -0
  229. package/dist/reward-system.test.js +175 -0
  230. package/dist/risk-model.js +215 -0
  231. package/dist/rule-miner.js +234 -7
  232. package/dist/rule-specificity.js +254 -0
  233. package/dist/runtime-types.js +27 -0
  234. package/dist/scaffold.js +208 -0
  235. package/dist/scale-collector.test.js +101 -0
  236. package/dist/scale-trajectory-collector.js +128 -0
  237. package/dist/sdk.js +250 -0
  238. package/dist/search-planner.js +4 -41
  239. package/dist/semantic-snapshot.js +1 -1
  240. package/dist/semantic-topology.js +121 -0
  241. package/dist/semantic-trace.js +310 -317
  242. package/dist/sequence-extractor.js +343 -0
  243. package/dist/skill-library.js +245 -0
  244. package/dist/skill-planner.test.js +189 -0
  245. package/dist/software-physics.js +291 -0
  246. package/dist/software-physics.test.js +81 -0
  247. package/dist/ssg-precision.js +478 -0
  248. package/dist/ssg-validator.js +71 -21
  249. package/dist/state-inference-doubleblind.test.js +160 -0
  250. package/dist/state-inference.js +516 -0
  251. package/dist/state-inference.test.js +115 -0
  252. package/dist/state-machine-fingerprint.js +345 -0
  253. package/dist/state-machine-fingerprint.test.js +120 -0
  254. package/dist/state-miner.js +386 -0
  255. package/dist/state-name-inference.js +213 -0
  256. package/dist/state-name-inference.test.js +69 -0
  257. package/dist/strategy-planner.js +262 -96
  258. package/dist/strategy-planner.test.js +135 -0
  259. package/dist/telemetry-analytics.test.js +402 -0
  260. package/dist/terminal-format.js +68 -0
  261. package/dist/terminal-format.test.js +83 -0
  262. package/dist/topology-factory.js +196 -0
  263. package/dist/topology-representation.js +242 -0
  264. package/dist/topology-representation.test.js +27 -0
  265. package/dist/trajectory-augmentation.js +254 -0
  266. package/dist/trajectory-augmentation.test.js +63 -0
  267. package/dist/trajectory-corpus.js +440 -0
  268. package/dist/trajectory-corpus.test.js +32 -0
  269. package/dist/trajectory-feedback.test.js +116 -0
  270. package/dist/transition-synthesizer.js +286 -0
  271. package/dist/transition-synthesizer.test.js +123 -0
  272. package/dist/trust/api-semantic-mapper.js +809 -0
  273. package/dist/trust/call-graph-propagator.js +225 -0
  274. package/dist/trust/cli.js +122 -0
  275. package/dist/trust/compliance-scorer.js +283 -0
  276. package/dist/trust/confidence-calculator.js +261 -0
  277. package/dist/trust/engine.js +1145 -0
  278. package/dist/trust/explainability.js +85 -0
  279. package/dist/trust/formatters/ci.js +42 -0
  280. package/dist/trust/formatters/json.js +11 -0
  281. package/dist/trust/formatters/terminal.js +152 -0
  282. package/dist/trust/index.js +39 -0
  283. package/dist/trust/phase1-verify.js +171 -0
  284. package/dist/trust/protocol-domain-validator.js +697 -0
  285. package/dist/trust/score-calculator.js +282 -0
  286. package/dist/trust/ssg-bridge.js +641 -0
  287. package/dist/trust/ssg-bridge.test.js +269 -0
  288. package/dist/trust/types.js +67 -0
  289. package/dist/trust/violation-trace.js +335 -0
  290. package/dist/trust-api.js +179 -0
  291. package/dist/trust-calibration.js +279 -0
  292. package/dist/unknown-protocol-discovery.js +339 -0
  293. package/dist/unknown-protocol-discovery.test.js +102 -0
  294. package/dist/unsupervised-physics.js +230 -0
  295. package/dist/unsupervised-physics.test.js +95 -0
  296. package/dist/utils.test.js +37 -0
  297. package/dist/validator.js +187 -10
  298. package/dist/verification-intelligence.js +475 -0
  299. package/dist/verify-api.js +432 -0
  300. package/dist/vi-impact-report.js +293 -0
  301. package/dist/wl-fingerprint.js +162 -0
  302. package/dist/wl-fingerprint.test.js +130 -0
  303. package/dist/zeroshot-strategy.js +139 -0
  304. package/docs/Progmune_/346/212/225/350/265/204/344/272/272/347/231/275/347/232/256/344/271/246_v2.0.html +576 -0
  305. package/docs/Progmune_/351/241/271/347/233/256/345/205/250/350/247/243.html +710 -0
  306. package/package.json +74 -7
  307. package/protocols.json +1956 -50
  308. package/.dockerignore +0 -14
  309. package/.mcp.json +0 -11
  310. package/.progmune_allowlist +0 -50
  311. package/.test_report/test_report.md +0 -87
  312. package/Dockerfile +0 -9
  313. package/FAQ.md +0 -167
  314. package/WHITEPAPER.md +0 -540
  315. package/demo-project/auth.ts +0 -55
  316. package/demo-project/tsconfig.json +0 -8
  317. package/dist/acl-breakdown.js +0 -13
  318. package/dist/all-sessions.js +0 -11
  319. package/dist/antibody-stats.js +0 -11
  320. package/dist/branch-tree-count.js +0 -14
  321. package/dist/common-fixpath.js +0 -12
  322. package/dist/constraint-types.js +0 -12
  323. package/dist/exec-metrics.js +0 -11
  324. package/dist/failure-report.js +0 -11
  325. package/dist/fast-path-hits.js +0 -13
  326. package/dist/fingerprint-list.js +0 -15
  327. package/dist/gen-history-log.js +0 -13
  328. package/dist/heatmap-data.js +0 -11
  329. package/dist/recent-session.js +0 -12
  330. package/dist/svl-distribution.js +0 -11
  331. package/dist/terminal-status.js +0 -11
  332. package/dist/token-savings.js +0 -11
  333. package/dist/total-repairs.js +0 -12
  334. package/dist/unresolved-count.js +0 -12
  335. package/dist/valid-fingerprints.js +0 -13
  336. package/dist/verify-ledgers.js +0 -11
  337. package/docs/whitepaper-style.css +0 -77
  338. package/docs/whitepaper-v2.1.md +0 -609
  339. package/docs/whitepaper-v2.2.md +0 -1064
  340. package/docs/whitepaper-v2.2.pdf +0 -0
  341. package/fly.toml +0 -31
  342. package/public/dashboard.html +0 -119
  343. package/server/hub.js +0 -116
  344. package/test/replay-golden/sess_1780063202050_mgeld.json +0 -9
  345. package/test/replay-golden/sess_1780064032560_gocld.json +0 -354
  346. package/test/replay-golden/sess_1780064413331_s2709.json +0 -606
  347. package/test/replay-golden/sess_1780064792710_y3avo.json +0 -614
  348. package/test/replay-golden.ts +0 -84
  349. package/test_benchmark.js +0 -165
  350. package/test_comprehensive.mjs +0 -638
  351. package/test_concurrency.js +0 -129
  352. package/test_ir_robustness.js +0 -85
  353. package/test_semantic_contracts.js +0 -269
  354. package/test_ssg_stress.js +0 -156
  355. package/test_svl3.js +0 -58
  356. package/tsconfig.json +0 -17
@@ -50,30 +50,28 @@ var __importStar = (this && this.__importStar) || (function () {
50
50
  })();
51
51
  Object.defineProperty(exports, "__esModule", { value: true });
52
52
  const failure_corpus_1 = require("./failure-corpus");
53
- // ── ANSI colors ──
54
- const C = { reset: "\x1b[0m", green: "\x1b[32m", red: "\x1b[31m", yellow: "\x1b[33m", cyan: "\x1b[36m", gray: "\x1b[90m", bold: "\x1b[1m", dim: "\x1b[2m" };
55
- const G = (s) => `${C.green}${s}${C.reset}`;
56
- const R = (s) => `${C.red}${s}${C.reset}`;
57
- const Y = (s) => `${C.yellow}${s}${C.reset}`;
58
- const C_ = (s) => `${C.cyan}${s}${C.reset}`;
59
- const D = (s) => `${C.gray}${s}${C.reset}`;
60
- const B = (s) => `${C.bold}${s}${C.reset}`;
53
+ const terminal_format_1 = require("./terminal-format");
54
+ const ssg_validator_1 = require("./ssg-validator");
55
+ const semantic_snapshot_1 = require("./semantic-snapshot");
56
+ const fs = __importStar(require("fs"));
57
+ const path = __importStar(require("path"));
58
+ // ── Narrative translation ──
61
59
  function narrateRejection(v) {
62
60
  const svlStr = `SVL-${v.svl}`;
63
61
  const missing = v.missingStates?.length ? v.missingStates.join(", ") : null;
64
62
  const blocked = v.description.match(/(\w+)\s*(要求|requires|blocked|不允许|不合法)/)?.[1] || "unknown";
65
63
  switch (svlStr) {
66
64
  case "SVL-1":
67
- return `Planner referenced a function that does not exist in the project.\n ${D("→ " + v.description)}`;
65
+ return `Planner referenced a function that does not exist in the project.\n ${(0, terminal_format_1.D)("→ " + v.description)}`;
68
66
  case "SVL-2":
69
- return `Planner called a function with incorrect argument types.\n ${D("→ " + v.description)}`;
67
+ return `Planner called a function with incorrect argument types.\n ${(0, terminal_format_1.D)("→ " + v.description)}`;
70
68
  case "SVL-3":
71
- return `Planner used a variable before it was defined or referenced it circularly.\n ${D("→ " + v.description)}`;
69
+ return `Planner used a variable before it was defined or referenced it circularly.\n ${(0, terminal_format_1.D)("→ " + v.description)}`;
72
70
  case "SVL-4":
73
71
  if (missing) {
74
- return `Planner attempted to call ${R(blocked)} before ${C_(missing)} was established.`;
72
+ return `Planner attempted to call ${(0, terminal_format_1.R)(blocked)} before ${(0, terminal_format_1.C_)(missing)} was established.`;
75
73
  }
76
- return `Planner violated the protocol contract for ${R(blocked)}.\n ${D("→ " + v.description)}`;
74
+ return `Planner violated the protocol contract for ${(0, terminal_format_1.R)(blocked)}.\n ${(0, terminal_format_1.D)("→ " + v.description)}`;
77
75
  default:
78
76
  return v.description;
79
77
  }
@@ -83,23 +81,23 @@ function narrateSuccess(actions) {
83
81
  .filter(a => a.kind === "call" && a.function)
84
82
  .map(a => a.function)
85
83
  .join(" → ");
86
- return `Successfully completed: ${G(names)}.`;
84
+ return `Successfully completed: ${(0, terminal_format_1.G)(names)}.`;
87
85
  }
88
86
  // ── Timeline rendering ──
89
87
  function formatActionSequence(actions) {
90
88
  return actions
91
89
  .filter(a => a.kind === "call" && a.function)
92
- .map(a => C_(a.function + "()"))
93
- .join(` ${D("→")} `);
90
+ .map(a => (0, terminal_format_1.C_)(a.function + "()"))
91
+ .join(` ${(0, terminal_format_1.D)("→")} `);
94
92
  }
95
93
  function formatSessionTimeline(session) {
96
94
  const width = 66;
97
95
  const title = `Intent: ${session.intent}`;
98
- const header = `┌─ ${B(title)} ${"─".repeat(Math.max(2, width - title.length - 5))}┐`;
96
+ const header = `┌─ ${(0, terminal_format_1.B)(title)} ${"─".repeat(Math.max(2, width - title.length - 5))}┐`;
99
97
  const failedCount = session.attempts.filter(a => a.outcome !== "success").length;
100
- const resolvedIcon = session.resolved ? G("✔") : R("✖");
101
- const snapTag = session.snapshotId ? ` │ ${D("Snapshot:")} ${D(session.snapshotId.slice(-16))}` : "";
102
- const info = `│ Session: ${D(session.sessionId)} │ Retries: ${failedCount} │ Resolved: ${resolvedIcon} ${" ".repeat(Math.max(1, 15))}│`;
98
+ const resolvedIcon = session.resolved ? (0, terminal_format_1.G)("✔") : (0, terminal_format_1.R)("✖");
99
+ const snapTag = session.snapshotId ? ` │ ${(0, terminal_format_1.D)("Snapshot:")} ${(0, terminal_format_1.D)(session.snapshotId.slice(-16))}` : "";
100
+ const info = `│ Session: ${(0, terminal_format_1.D)(session.sessionId)} │ Retries: ${failedCount} │ Resolved: ${resolvedIcon} ${" ".repeat(Math.max(1, 15))}│`;
103
101
  const footer = `└${"─".repeat(width - 2)}┘`;
104
102
  const lines = [header, info];
105
103
  if (snapTag)
@@ -113,13 +111,13 @@ function formatSessionTimeline(session) {
113
111
  const actions = a.generatedActions || [];
114
112
  const actionDisplay = formatActionSequence(actions);
115
113
  lines.push(` Attempt ${num} ${"─".repeat(62)}`);
116
- lines.push(` │ ${actionDisplay || D("(no actions)")}`);
114
+ lines.push(` │ ${actionDisplay || (0, terminal_format_1.D)("(no actions)")}`);
117
115
  lines.push(` │`);
118
116
  // Render each violation in the attempt
119
117
  for (const v of a.violations) {
120
118
  const narration = narrateRejection(v);
121
119
  const lines_narration = narration.split("\n");
122
- lines.push(` ${R("✖")} ${lines_narration[0]}`);
120
+ lines.push(` ${(0, terminal_format_1.R)("✖")} ${lines_narration[0]}`);
123
121
  for (let j = 1; j < lines_narration.length; j++) {
124
122
  lines.push(` ${lines_narration[j]}`);
125
123
  }
@@ -127,49 +125,49 @@ function formatSessionTimeline(session) {
127
125
  if (v.svl === 4) {
128
126
  if (v.missingStates?.length) {
129
127
  const missingList = v.missingStates.join(", ");
130
- lines.push(` ${D("→")} Missing: ${C_(missingList)}`);
128
+ lines.push(` ${(0, terminal_format_1.D)("→")} Missing: ${(0, terminal_format_1.C_)(missingList)}`);
131
129
  }
132
130
  if (v.fixPath?.length) {
133
131
  const fixList = v.fixPath.join(" → ");
134
- lines.push(` ${D("→")} Repair: ${Y(fixList)}`);
132
+ lines.push(` ${(0, terminal_format_1.D)("→")} Repair: ${(0, terminal_format_1.Y)(fixList)}`);
135
133
  }
136
134
  if (v.namespace && v.namespace !== "_global") {
137
- lines.push(` ${D("→")} Namespace: ${D(v.namespace)}`);
135
+ lines.push(` ${(0, terminal_format_1.D)("→")} Namespace: ${(0, terminal_format_1.D)(v.namespace)}`);
138
136
  }
139
137
  }
140
138
  }
141
- lines.push(` ${D(`(attempt ${num}/${session.attempts.length})`)}`);
139
+ lines.push(` ${(0, terminal_format_1.D)(`(attempt ${num}/${session.attempts.length})`)}`);
142
140
  lines.push("");
143
141
  }
144
142
  // Final resolution
145
143
  if (session.resolved && session.successfulAttempt) {
146
144
  const actions = session.successfulAttempt.generatedActions || [];
147
145
  const actionDisplay = formatActionSequence(actions);
148
- lines.push(` ${G("✔")} Resolution ${"─".repeat(51)}`);
146
+ lines.push(` ${(0, terminal_format_1.G)("✔")} Resolution ${"─".repeat(51)}`);
149
147
  lines.push(` │ ${actionDisplay}`);
150
148
  lines.push(` │`);
151
149
  const narration = narrateSuccess(actions);
152
- lines.push(` ${G("✔")} ${narration}`);
153
- lines.push(` ${D(`Resolved after ${failedCount} retries.`)}`);
150
+ lines.push(` ${(0, terminal_format_1.G)("✔")} ${narration}`);
151
+ lines.push(` ${(0, terminal_format_1.D)(`Resolved after ${failedCount} retries.`)}`);
154
152
  // Phase 3: Ledger consistency check
155
153
  if (session.successfulAttempt.transitions.length > 0) {
156
154
  const nsInit = new Map([["_global", "INIT"]]);
157
155
  const consistency = (0, ssg_validator_1.checkLedgerConsistency)(session.successfulAttempt.transitions, nsInit);
158
156
  if (consistency.consistent) {
159
- lines.push(` ${G("Ledger: consistent")}`);
157
+ lines.push(` ${(0, terminal_format_1.G)("Ledger: consistent")}`);
160
158
  }
161
159
  else {
162
- lines.push(` ${R(`Ledger: ${consistency.violations.length} violation(s)`)}`);
160
+ lines.push(` ${(0, terminal_format_1.R)(`Ledger: ${consistency.violations.length} violation(s)`)}`);
163
161
  for (const v of consistency.violations) {
164
- lines.push(` ${D(`[${v.invariant}] index=${v.index}`)}`);
162
+ lines.push(` ${(0, terminal_format_1.D)(`[${v.invariant}] index=${v.index}`)}`);
165
163
  }
166
164
  }
167
165
  }
168
166
  lines.push("");
169
167
  }
170
168
  else if (!session.resolved) {
171
- lines.push(` ${R("✖")} ${B("Unresolved")} ${"─".repeat(50)}`);
172
- lines.push(` ${D(`Failed after ${failedCount} retries with no successful path.`)}`);
169
+ lines.push(` ${(0, terminal_format_1.R)("✖")} ${(0, terminal_format_1.B)("Unresolved")} ${"─".repeat(50)}`);
170
+ lines.push(` ${(0, terminal_format_1.D)(`Failed after ${failedCount} retries with no successful path.`)}`);
173
171
  lines.push("");
174
172
  }
175
173
  return lines.join("\n");
@@ -181,7 +179,7 @@ function pad(s, w) {
181
179
  }
182
180
  function formatSessionSummary(sessions) {
183
181
  if (sessions.length === 0) {
184
- return `${D("No sessions recorded yet.")}\nRun the planner to generate semantic traces.`;
182
+ return `${(0, terminal_format_1.D)("No sessions recorded yet.")}\nRun the planner to generate semantic traces.`;
185
183
  }
186
184
  const header = `Sessions in failure corpus (${sessions.length} total):\n`;
187
185
  const colW = { session: 16, intent: 28, attempts: 10, resolved: 10 };
@@ -195,27 +193,27 @@ function formatSessionSummary(sessions) {
195
193
  for (const s of sessions) {
196
194
  const shortId = s.sessionId.length > 14 ? s.sessionId.slice(0, 13) + "…" : s.sessionId;
197
195
  const shortIntent = s.intent.length > 26 ? s.intent.slice(0, 25) + "…" : s.intent;
198
- const resolved = s.resolved ? G("✔ resolved") : R("✖ unresolved");
199
- lines.push(`│ ${pad(D(shortId), colW.session)}│ ${pad(shortIntent, colW.intent)}│ ${pad(String(s.attempts.length), colW.attempts)}│ ${pad(resolved, colW.resolved)}│`);
196
+ const resolved = s.resolved ? (0, terminal_format_1.G)("✔ resolved") : (0, terminal_format_1.R)("✖ unresolved");
197
+ lines.push(`│ ${pad((0, terminal_format_1.D)(shortId), colW.session)}│ ${pad(shortIntent, colW.intent)}│ ${pad(String(s.attempts.length), colW.attempts)}│ ${pad(resolved, colW.resolved)}│`);
200
198
  }
201
199
  lines.push(`└${sep}┘`);
202
200
  lines.push("");
203
- lines.push(`${D("Commands:")} timeline | replay | --states | --genome | --learned | --antibodies | --heatmap`);
201
+ lines.push(`${(0, terminal_format_1.D)("Commands:")} timeline | replay | --states | --genome | --learned | --antibodies | --heatmap`);
204
202
  return lines.join("\n");
205
203
  }
206
204
  // ── Genome summary ──
207
205
  function formatGenomeSummary() {
208
206
  const g = (0, failure_corpus_1.getFailureGenome)();
209
207
  if (g.totalFailures === 0) {
210
- return `${D("No failures recorded yet.")}`;
208
+ return `${(0, terminal_format_1.D)("No failures recorded yet.")}`;
211
209
  }
212
210
  const bar = "─".repeat(56);
213
211
  const lines = [
214
- `┌─ ${B("Failure Genome")} ${bar.slice(0, 40)}┐`,
215
- `│ Total failures: ${R(String(g.totalFailures))}${" ".repeat(39)}│`,
216
- `│ Average retries: ${Y(String(g.averageRetriesToSuccess))}${" ".repeat(38)}│`,
212
+ `┌─ ${(0, terminal_format_1.B)("Failure Genome")} ${bar.slice(0, 40)}┐`,
213
+ `│ Total failures: ${(0, terminal_format_1.R)(String(g.totalFailures))}${" ".repeat(39)}│`,
214
+ `│ Average retries: ${(0, terminal_format_1.Y)(String(g.averageRetriesToSuccess))}${" ".repeat(38)}│`,
217
215
  `├${bar}┤`,
218
- `│ ${B("By SVL Level")}${" ".repeat(44)}│`,
216
+ `│ ${(0, terminal_format_1.B)("By SVL Level")}${" ".repeat(44)}│`,
219
217
  `│ SVL-1 (Symbol): ${barChart(g.bySVL["SVL-1"], g.totalFailures)} ${g.bySVL["SVL-1"]} │`,
220
218
  `│ SVL-2 (Type): ${barChart(g.bySVL["SVL-2"], g.totalFailures)} ${g.bySVL["SVL-2"]} │`,
221
219
  `│ SVL-3 (Dataflow): ${barChart(g.bySVL["SVL-3"], g.totalFailures)} ${g.bySVL["SVL-3"]} │`,
@@ -223,7 +221,7 @@ function formatGenomeSummary() {
223
221
  `├${bar}┤`,
224
222
  ];
225
223
  if (g.topPatterns.length > 0) {
226
- lines.push(`│ ${B("Top Failure Patterns")}${" ".repeat(37)}│`);
224
+ lines.push(`│ ${(0, terminal_format_1.B)("Top Failure Patterns")}${" ".repeat(37)}│`);
227
225
  for (const p of g.topPatterns) {
228
226
  const label = `${p.pattern}: ${p.count}x`;
229
227
  lines.push(`│ ${label}${" ".repeat(Math.max(1, 52 - label.length))}│`);
@@ -231,7 +229,7 @@ function formatGenomeSummary() {
231
229
  lines.push(`├${bar}┤`);
232
230
  }
233
231
  if (g.commonFixPaths.length > 0) {
234
- lines.push(`│ ${B("Common Repair Paths")}${" ".repeat(36)}│`);
232
+ lines.push(`│ ${(0, terminal_format_1.B)("Common Repair Paths")}${" ".repeat(36)}│`);
235
233
  for (const fp of g.commonFixPaths.slice(0, 4)) {
236
234
  const path = fp.fixPath.join(" → ");
237
235
  const label = ` ${path} (${fp.count}x)`;
@@ -243,7 +241,7 @@ function formatGenomeSummary() {
243
241
  // By constraint type
244
242
  const constraints = Object.entries(g.byConstraintType).sort((a, b) => b[1] - a[1]);
245
243
  if (constraints.length > 0) {
246
- lines.push(`│ ${B("By Constraint Type")}${" ".repeat(37)}│`);
244
+ lines.push(`│ ${(0, terminal_format_1.B)("By Constraint Type")}${" ".repeat(37)}│`);
247
245
  for (const [k, v] of constraints) {
248
246
  lines.push(`│ ${k}: ${v}${" ".repeat(Math.max(1, 51 - k.length - String(v).length))}│`);
249
247
  }
@@ -253,33 +251,33 @@ function formatGenomeSummary() {
253
251
  }
254
252
  function barChart(count, total) {
255
253
  if (total === 0)
256
- return D("▏".repeat(0));
254
+ return (0, terminal_format_1.D)("▏".repeat(0));
257
255
  const maxBars = 20;
258
256
  const n = Math.round((count / total) * maxBars);
259
257
  if (n === 0 && count > 0)
260
- return Y("▏");
258
+ return (0, terminal_format_1.Y)("▏");
261
259
  if (n === 0)
262
- return D("▏".repeat(0));
263
- return Y("█".repeat(n)) + D("░".repeat(maxBars - n));
260
+ return (0, terminal_format_1.D)("▏".repeat(0));
261
+ return (0, terminal_format_1.Y)("█".repeat(n)) + (0, terminal_format_1.D)("░".repeat(maxBars - n));
264
262
  }
265
263
  // ── Learned patterns ──
266
264
  function aclBadge(level) {
267
265
  switch (level) {
268
- case "ACL-4": return G(`◆ ${level} (globally stable)`);
269
- case "ACL-3": return C_(`◈ ${level} (cross-task validated)`);
270
- case "ACL-2": return Y(`◇ ${level} (repeated observation)`);
271
- case "ACL-1": return D(`◌ ${level} (single case)`);
272
- default: return D(level);
266
+ case "ACL-4": return (0, terminal_format_1.G)(`◆ ${level} (globally stable)`);
267
+ case "ACL-3": return (0, terminal_format_1.C_)(`◈ ${level} (cross-task validated)`);
268
+ case "ACL-2": return (0, terminal_format_1.Y)(`◇ ${level} (repeated observation)`);
269
+ case "ACL-1": return (0, terminal_format_1.D)(`◌ ${level} (single case)`);
270
+ default: return (0, terminal_format_1.D)(level);
273
271
  }
274
272
  }
275
273
  function formatLearnedPatterns() {
276
274
  const learned = (0, failure_corpus_1.getLearnedPatterns)();
277
275
  const patterns = learned.failureToFix;
278
276
  if (patterns.length === 0) {
279
- return `${D("No learned patterns yet.")}\nPatterns emerge when sessions capture failures with repair paths.`;
277
+ return `${(0, terminal_format_1.D)("No learned patterns yet.")}\nPatterns emerge when sessions capture failures with repair paths.`;
280
278
  }
281
279
  const lines = [
282
- `${B("Antibody Registry")} (${patterns.length} patterns)`,
280
+ `${(0, terminal_format_1.B)("Antibody Registry")} (${patterns.length} patterns)`,
283
281
  "─".repeat(72),
284
282
  ];
285
283
  for (const p of patterns) {
@@ -287,10 +285,10 @@ function formatLearnedPatterns() {
287
285
  const intents = p.distinctIntents.slice(0, 3).join(", ");
288
286
  const moreIntents = p.distinctIntents.length > 3 ? ` +${p.distinctIntents.length - 3} more` : "";
289
287
  const ratePct = Math.round(p.resolvedRate * 100);
290
- lines.push(` ${B("Signature:")} ${R(p.violation)}`);
291
- lines.push(` ${D("Repair:")} ${Y(path)}`);
292
- lines.push(` ${D("Confidence:")} ${aclBadge(p.antibodyLevel)}`);
293
- lines.push(` ${D("Occurrences:")} ${p.occurrenceCount}x │ ${D("Resolved:")} ${ratePct}% │ ${D("Intents:")} ${intents}${moreIntents}`);
288
+ lines.push(` ${(0, terminal_format_1.B)("Signature:")} ${(0, terminal_format_1.R)(p.violation)}`);
289
+ lines.push(` ${(0, terminal_format_1.D)("Repair:")} ${(0, terminal_format_1.Y)(path)}`);
290
+ lines.push(` ${(0, terminal_format_1.D)("Confidence:")} ${aclBadge(p.antibodyLevel)}`);
291
+ lines.push(` ${(0, terminal_format_1.D)("Occurrences:")} ${p.occurrenceCount}x │ ${(0, terminal_format_1.D)("Resolved:")} ${ratePct}% │ ${(0, terminal_format_1.D)("Intents:")} ${intents}${moreIntents}`);
294
292
  lines.push("");
295
293
  }
296
294
  return lines.join("\n");
@@ -299,39 +297,39 @@ function formatLearnedPatterns() {
299
297
  function formatAntibodyStats() {
300
298
  const stats = (0, failure_corpus_1.getAntibodyStats)();
301
299
  if (stats.totalHits === 0) {
302
- return `${D("No antibody hits recorded yet.")}\nAntibodies are recorded when the immune system accelerates planning via learned fix paths.`;
300
+ return `${(0, terminal_format_1.D)("No antibody hits recorded yet.")}\nAntibodies are recorded when the immune system accelerates planning via learned fix paths.`;
303
301
  }
304
302
  const lines = [];
305
- lines.push(`${B("Antibody Efficacy Report")}`);
303
+ lines.push(`${(0, terminal_format_1.B)("Antibody Efficacy Report")}`);
306
304
  lines.push("═".repeat(68));
307
305
  lines.push("");
308
306
  // Summary
309
- lines.push(` ${B("Immune Acceleration Summary")}`);
310
- lines.push(` ${D("─".repeat(44))}`);
311
- lines.push(` Total antibody hits: ${C_(String(stats.totalHits))}`);
312
- lines.push(` ACL-4 fast-path (0 LLM): ${G(String(stats.fastPathHits))}`);
313
- lines.push(` ACL-3 injected hints: ${Y(String(stats.injectedHintHits))}`);
314
- lines.push(` LLM calls saved: ${G(String(stats.totalLLMCallsSaved))}`);
315
- lines.push(` Est. tokens saved: ${G(stats.totalTokensSaved.toLocaleString())}`);
307
+ lines.push(` ${(0, terminal_format_1.B)("Immune Acceleration Summary")}`);
308
+ lines.push(` ${(0, terminal_format_1.D)("─".repeat(44))}`);
309
+ lines.push(` Total antibody hits: ${(0, terminal_format_1.C_)(String(stats.totalHits))}`);
310
+ lines.push(` ACL-4 fast-path (0 LLM): ${(0, terminal_format_1.G)(String(stats.fastPathHits))}`);
311
+ lines.push(` ACL-3 injected hints: ${(0, terminal_format_1.Y)(String(stats.injectedHintHits))}`);
312
+ lines.push(` LLM calls saved: ${(0, terminal_format_1.G)(String(stats.totalLLMCallsSaved))}`);
313
+ lines.push(` Est. tokens saved: ${(0, terminal_format_1.G)(stats.totalTokensSaved.toLocaleString())}`);
316
314
  lines.push("");
317
315
  // By Level
318
316
  if (Object.keys(stats.byLevel).length > 0) {
319
- lines.push(` ${B("By Antibody Level")}`);
320
- lines.push(` ${D("─".repeat(34))}`);
317
+ lines.push(` ${(0, terminal_format_1.B)("By Antibody Level")}`);
318
+ lines.push(` ${(0, terminal_format_1.D)("─".repeat(34))}`);
321
319
  const levels = ["ACL-4", "ACL-3", "ACL-2", "ACL-1"];
322
320
  for (const lvl of levels) {
323
321
  const d = stats.byLevel[lvl];
324
322
  if (!d)
325
323
  continue;
326
- const icon = lvl === "ACL-4" ? G("◆") : lvl === "ACL-3" ? C_("◈") : lvl === "ACL-2" ? Y("◇") : D("◌");
324
+ const icon = lvl === "ACL-4" ? (0, terminal_format_1.G)("◆") : lvl === "ACL-3" ? (0, terminal_format_1.C_)("◈") : lvl === "ACL-2" ? (0, terminal_format_1.Y)("◇") : (0, terminal_format_1.D)("◌");
327
325
  lines.push(` ${icon} ${lvl}: ${d.hits} hits, ${d.llmSaved} LLM saved, ${d.tokensSaved.toLocaleString()} tokens`);
328
326
  }
329
327
  lines.push("");
330
328
  }
331
329
  // Top signatures
332
330
  if (stats.topSignatures.length > 0) {
333
- lines.push(` ${B("Top Antibody Signatures")}`);
334
- lines.push(` ${D("─".repeat(40))}`);
331
+ lines.push(` ${(0, terminal_format_1.B)("Top Antibody Signatures")}`);
332
+ lines.push(` ${(0, terminal_format_1.D)("─".repeat(40))}`);
335
333
  for (const s of stats.topSignatures.slice(0, 5)) {
336
334
  const sig = s.signature.length > 42 ? s.signature.slice(0, 39) + "..." : s.signature;
337
335
  lines.push(` ${s.hits}x ${sig.padEnd(44)} ~${s.avgSimilarity}`);
@@ -341,34 +339,29 @@ function formatAntibodyStats() {
341
339
  // Efficiency note
342
340
  if (stats.fastPathHits > 0) {
343
341
  const pct = Math.round((stats.fastPathHits / stats.totalHits) * 100);
344
- lines.push(` ${G(`Immune efficiency: ${pct}% of hits bypassed LLM entirely`)}`);
342
+ lines.push(` ${(0, terminal_format_1.G)(`Immune efficiency: ${pct}% of hits bypassed LLM entirely`)}`);
345
343
  }
346
344
  return lines.join("\n");
347
345
  }
348
346
  // ── Semantic heatmap ──
349
- const failure_corpus_2 = require("./failure-corpus");
350
- const ssg_validator_1 = require("./ssg-validator");
351
- const semantic_snapshot_1 = require("./semantic-snapshot");
352
- const fs = __importStar(require("fs"));
353
- const path = __importStar(require("path"));
354
347
  function formatHeatmap() {
355
- const h = (0, failure_corpus_2.getSemanticHeatmap)();
348
+ const h = (0, failure_corpus_1.getSemanticHeatmap)();
356
349
  if (h.fragileProtocols.length === 0 && h.svlHotspots.length === 0) {
357
- return `${D("No heatmap data yet.")}`;
350
+ return `${(0, terminal_format_1.D)("No heatmap data yet.")}`;
358
351
  }
359
352
  const lines = [];
360
- lines.push(`${B("Semantic Heatmap")}`);
353
+ lines.push(`${(0, terminal_format_1.B)("Semantic Heatmap")}`);
361
354
  lines.push("═".repeat(72));
362
355
  lines.push("");
363
356
  // SVL hotspots as horizontal bars
364
357
  if (h.svlHotspots.length > 0) {
365
- lines.push(` ${B("Immune Layer Activity")}`);
366
- lines.push(` ${D("─".repeat(44))}`);
358
+ lines.push(` ${(0, terminal_format_1.B)("Immune Layer Activity")}`);
359
+ lines.push(` ${(0, terminal_format_1.D)("─".repeat(44))}`);
367
360
  const maxCount = Math.max(...h.svlHotspots.map(s => s.count), 1);
368
361
  const maxBar = 30;
369
362
  for (const s of h.svlHotspots) {
370
363
  const n = Math.round((s.count / maxCount) * maxBar) || (s.count > 0 ? 1 : 0);
371
- const bar = R("█".repeat(n)) + D("░".repeat(maxBar - n));
364
+ const bar = (0, terminal_format_1.R)("█".repeat(n)) + (0, terminal_format_1.D)("░".repeat(maxBar - n));
372
365
  const pct = `${s.percentage}%`.padStart(4);
373
366
  lines.push(` ${s.svl.padEnd(8)} ${bar} ${String(s.count).padStart(2)} (${pct})`);
374
367
  }
@@ -376,33 +369,33 @@ function formatHeatmap() {
376
369
  }
377
370
  // Fragile protocols
378
371
  if (h.fragileProtocols.length > 0) {
379
- lines.push(` ${B("Fragile Protocols (most blocked functions)")}`);
380
- lines.push(` ${D("─".repeat(52))}`);
372
+ lines.push(` ${(0, terminal_format_1.B)("Fragile Protocols (most blocked functions)")}`);
373
+ lines.push(` ${(0, terminal_format_1.D)("─".repeat(52))}`);
381
374
  for (const fp of h.fragileProtocols.slice(0, 6)) {
382
- const heat = fp.violationCount >= 5 ? R("●●●") : fp.violationCount >= 3 ? Y("●●") : Y("●");
383
- lines.push(` ${heat} ${C_(fp.function + "()")} ${D(`— ${fp.violationCount}x, ${fp.svl}`)}`);
375
+ const heat = fp.violationCount >= 5 ? (0, terminal_format_1.R)("●●●") : fp.violationCount >= 3 ? (0, terminal_format_1.Y)("●●") : (0, terminal_format_1.Y)("●");
376
+ lines.push(` ${heat} ${(0, terminal_format_1.C_)(fp.function + "()")} ${(0, terminal_format_1.D)(`— ${fp.violationCount}x, ${fp.svl}`)}`);
384
377
  }
385
378
  lines.push("");
386
379
  }
387
380
  // Constraint clusters
388
381
  if (h.constraintClusters.length > 0) {
389
- lines.push(` ${B("Constraint Co-occurrence")}`);
390
- lines.push(` ${D("─".repeat(40))}`);
382
+ lines.push(` ${(0, terminal_format_1.B)("Constraint Co-occurrence")}`);
383
+ lines.push(` ${(0, terminal_format_1.D)("─".repeat(40))}`);
391
384
  for (const cc of h.constraintClusters.slice(0, 4)) {
392
- const cluster = cc.constraints.map(c => Y(c)).join(" + ");
385
+ const cluster = cc.constraints.map(c => (0, terminal_format_1.Y)(c)).join(" + ");
393
386
  lines.push(` ${cluster}`);
394
- lines.push(` ${D(` ↳ ${cc.count} anomalies in "${cc.intent.slice(0, 40)}"`)}`);
387
+ lines.push(` ${(0, terminal_format_1.D)(` ↳ ${cc.count} anomalies in "${cc.intent.slice(0, 40)}"`)}`);
395
388
  }
396
389
  lines.push("");
397
390
  }
398
391
  // High friction intents
399
392
  if (h.highFrictionIntents.length > 0) {
400
- lines.push(` ${B("High Friction Intents (most adaptations required)")}`);
401
- lines.push(` ${D("─".repeat(52))}`);
393
+ lines.push(` ${(0, terminal_format_1.B)("High Friction Intents (most adaptations required)")}`);
394
+ lines.push(` ${(0, terminal_format_1.D)("─".repeat(52))}`);
402
395
  for (const fi of h.highFrictionIntents.slice(0, 5)) {
403
- const friction = fi.adaptationCount >= 4 ? R("■■■") : fi.adaptationCount >= 2 ? Y("■■") : Y("■");
396
+ const friction = fi.adaptationCount >= 4 ? (0, terminal_format_1.R)("■■■") : fi.adaptationCount >= 2 ? (0, terminal_format_1.Y)("■■") : (0, terminal_format_1.Y)("■");
404
397
  const types = fi.anomalyTypes.join(", ");
405
- lines.push(` ${friction} ${fi.intent.slice(0, 40).padEnd(42)} ${D(`${fi.adaptationCount} adapts, ${types}`)}`);
398
+ lines.push(` ${friction} ${fi.intent.slice(0, 40).padEnd(42)} ${(0, terminal_format_1.D)(`${fi.adaptationCount} adapts, ${types}`)}`);
406
399
  }
407
400
  lines.push("");
408
401
  }
@@ -431,7 +424,7 @@ function loadProtocols() {
431
424
  }
432
425
  function formatStateTransitionPathFromLedger(transitions) {
433
426
  if (transitions.length === 0) {
434
- return `${D("No protocol-governed transitions in this sequence.")}`;
427
+ return `${(0, terminal_format_1.D)("No protocol-governed transitions in this sequence.")}`;
435
428
  }
436
429
  const lines = [];
437
430
  // Initial state from first transition
@@ -444,11 +437,11 @@ function formatStateTransitionPathFromLedger(transitions) {
444
437
  }
445
438
  return all;
446
439
  };
447
- lines.push(` ${D([...mergeStates(initState)].join(", ") || "—")}`);
440
+ lines.push(` ${(0, terminal_format_1.D)([...mergeStates(initState)].join(", ") || "—")}`);
448
441
  for (const t of transitions) {
449
442
  if (!t.valid)
450
443
  continue;
451
- const fnLabel = C_(t.function + "()");
444
+ const fnLabel = (0, terminal_format_1.C_)(t.function + "()");
452
445
  const beforeAll = mergeStates(t.statesBefore);
453
446
  const afterAll = mergeStates(t.statesAfter);
454
447
  const beforeStr = [...beforeAll].join(", ");
@@ -457,12 +450,12 @@ function formatStateTransitionPathFromLedger(transitions) {
457
450
  const lost = t.invalidated || [];
458
451
  let delta = "";
459
452
  if (gained.length > 0)
460
- delta += ` ${G("+" + gained.join(",+"))}`;
453
+ delta += ` ${(0, terminal_format_1.G)("+" + gained.join(",+"))}`;
461
454
  if (lost.length > 0)
462
- delta += ` ${R("-" + lost.join(",-"))}`;
455
+ delta += ` ${(0, terminal_format_1.R)("-" + lost.join(",-"))}`;
463
456
  lines.push(` │`);
464
457
  lines.push(` ├─ ${fnLabel}`);
465
- lines.push(` │ ${D(beforeStr || "—")} ${D("──▶")} ${afterStr || "—"}${delta}`);
458
+ lines.push(` │ ${(0, terminal_format_1.D)(beforeStr || "—")} ${(0, terminal_format_1.D)("──▶")} ${afterStr || "—"}${delta}`);
466
459
  lines.push(` │`);
467
460
  }
468
461
  return lines.join("\n");
@@ -470,13 +463,13 @@ function formatStateTransitionPathFromLedger(transitions) {
470
463
  function formatStateTransitions(session) {
471
464
  const width = 66;
472
465
  const title = `State Transitions: ${session.intent}`;
473
- const header = `┌─ ${B(title)} ${"─".repeat(Math.max(2, width - title.length - 5))}┐`;
474
- const resolvedIcon = session.resolved ? G("✔") : R("✖");
475
- const info = `│ Session: ${D(session.sessionId)} │ Resolved: ${resolvedIcon} ${" ".repeat(Math.max(1, 15))}│`;
466
+ const header = `┌─ ${(0, terminal_format_1.B)(title)} ${"─".repeat(Math.max(2, width - title.length - 5))}┐`;
467
+ const resolvedIcon = session.resolved ? (0, terminal_format_1.G)("✔") : (0, terminal_format_1.R)("✖");
468
+ const info = `│ Session: ${(0, terminal_format_1.D)(session.sessionId)} │ Resolved: ${resolvedIcon} ${" ".repeat(Math.max(1, 15))}│`;
476
469
  const footer = `└${"─".repeat(width - 2)}┘`;
477
470
  const lines = [header, info, footer, ""];
478
471
  if (session.successfulAttempt) {
479
- lines.push(` ${B("Successful Path State Machine:")}`);
472
+ lines.push(` ${(0, terminal_format_1.B)("Successful Path State Machine:")}`);
480
473
  lines.push("");
481
474
  lines.push(formatStateTransitionPathFromLedger(session.successfulAttempt.transitions));
482
475
  lines.push("");
@@ -484,10 +477,10 @@ function formatStateTransitions(session) {
484
477
  for (const a of session.attempts) {
485
478
  for (const v of a.violations) {
486
479
  if (v.svl === 4 && v.fixPath?.length) {
487
- lines.push(` ${D("─".repeat(50))}`);
480
+ lines.push(` ${(0, terminal_format_1.D)("─".repeat(50))}`);
488
481
  const actions = a.generatedActions.filter((x) => x.kind === "call" && x.function).map((x) => x.function).join(" → ");
489
- lines.push(` ${R("Blocked at:")} ${actions}`);
490
- lines.push(` ${D("Repair:")} ${Y(v.fixPath.join(" → "))}`);
482
+ lines.push(` ${(0, terminal_format_1.R)("Blocked at:")} ${actions}`);
483
+ lines.push(` ${(0, terminal_format_1.D)("Repair:")} ${(0, terminal_format_1.Y)(v.fixPath.join(" → "))}`);
491
484
  lines.push("");
492
485
  }
493
486
  }
@@ -524,24 +517,24 @@ function formatReplayHeader(session) {
524
517
  const w = 62;
525
518
  const totalRetries = session.attempts.filter(a => a.outcome !== "success").length;
526
519
  lines.push("");
527
- lines.push(` ${B("Semantic Observatory — Cognitive Session Replay")}`);
528
- lines.push(` ${D("─".repeat(w))}`);
520
+ lines.push(` ${(0, terminal_format_1.B)("Semantic Observatory — Cognitive Session Replay")}`);
521
+ lines.push(` ${(0, terminal_format_1.D)("─".repeat(w))}`);
529
522
  lines.push("");
530
- lines.push(` ${D("Intent:")} ${C_(session.intent)}`);
531
- lines.push(` ${D("Session:")} ${session.sessionId}`);
532
- lines.push(` ${D("Adaptations:")} ${totalRetries}`);
533
- lines.push(` ${D("Outcome:")} ${session.resolved ? G("cognitive adaptation successful") : R("cognitive adaptation incomplete")}`);
523
+ lines.push(` ${(0, terminal_format_1.D)("Intent:")} ${(0, terminal_format_1.C_)(session.intent)}`);
524
+ lines.push(` ${(0, terminal_format_1.D)("Session:")} ${session.sessionId}`);
525
+ lines.push(` ${(0, terminal_format_1.D)("Adaptations:")} ${totalRetries}`);
526
+ lines.push(` ${(0, terminal_format_1.D)("Outcome:")} ${session.resolved ? (0, terminal_format_1.G)("cognitive adaptation successful") : (0, terminal_format_1.R)("cognitive adaptation incomplete")}`);
534
527
  lines.push("");
535
- lines.push(` ${D("─".repeat(w))}`);
528
+ lines.push(` ${(0, terminal_format_1.D)("─".repeat(w))}`);
536
529
  lines.push("");
537
530
  return lines.join("\n");
538
531
  }
539
532
  function formatActionList(actions) {
540
533
  if (!actions || actions.length === 0)
541
- return D("(empty sequence)");
534
+ return (0, terminal_format_1.D)("(empty sequence)");
542
535
  return actions
543
536
  .filter(a => a.kind === "call" && a.function)
544
- .map(a => ` ${C_(a.function + "()")}`)
537
+ .map(a => ` ${(0, terminal_format_1.C_)(a.function + "()")}`)
545
538
  .join("\n");
546
539
  }
547
540
  function formatAdaptationDiff(prev, current) {
@@ -551,15 +544,15 @@ function formatAdaptationDiff(prev, current) {
551
544
  const removed = prevFns.filter(f => !currFns.includes(f));
552
545
  const kept = currFns.filter(f => prevFns.includes(f));
553
546
  const lines = [];
554
- lines.push(` ${B("Adaptation shift:")}`);
547
+ lines.push(` ${(0, terminal_format_1.B)("Adaptation shift:")}`);
555
548
  if (kept.length > 0) {
556
- lines.push(` ${D("persisted")} ${kept.map(f => C_(f + "()")).join(" → ")}`);
549
+ lines.push(` ${(0, terminal_format_1.D)("persisted")} ${kept.map(f => (0, terminal_format_1.C_)(f + "()")).join(" → ")}`);
557
550
  }
558
551
  if (removed.length > 0) {
559
- lines.push(` ${R("dropped")} ${removed.map(f => R(f + "()")).join(" → ")}`);
552
+ lines.push(` ${(0, terminal_format_1.R)("dropped")} ${removed.map(f => (0, terminal_format_1.R)(f + "()")).join(" → ")}`);
560
553
  }
561
554
  if (added.length > 0) {
562
- lines.push(` ${G("acquired")} ${added.map(f => G(f + "()")).join(" → ")}`);
555
+ lines.push(` ${(0, terminal_format_1.G)("acquired")} ${added.map(f => (0, terminal_format_1.G)(f + "()")).join(" → ")}`);
563
556
  }
564
557
  return lines.join("\n");
565
558
  }
@@ -567,28 +560,28 @@ function formatAnomalyReport(a) {
567
560
  const lines = [];
568
561
  const primary = a.violations[0];
569
562
  if (!primary) {
570
- lines.push(` ${B("Semantic anomaly:")} ${R("unknown")}`);
563
+ lines.push(` ${(0, terminal_format_1.B)("Semantic anomaly:")} ${(0, terminal_format_1.R)("unknown")}`);
571
564
  return lines.join("\n");
572
565
  }
573
566
  const svl = `SVL-${primary.svl}`;
574
- lines.push(` ${B("Semantic anomaly:")} ${R(svlLabel(svl))}`);
575
- lines.push(` ${D("Layer:")} ${describeSVLLayer(svl)}`);
567
+ lines.push(` ${(0, terminal_format_1.B)("Semantic anomaly:")} ${(0, terminal_format_1.R)(svlLabel(svl))}`);
568
+ lines.push(` ${(0, terminal_format_1.D)("Layer:")} ${describeSVLLayer(svl)}`);
576
569
  if (primary.svl === 4) {
577
570
  const blockedMatch = primary.description.match(/(\w+)\s*(要求|requires|blocked|不允许|不合法)/);
578
571
  const blocked = blockedMatch ? blockedMatch[1] : a.generatedActions.find(x => x.kind === "call")?.function || "unknown";
579
- lines.push(` ${D("Blocked:")} ${R(blocked + "()")}`);
572
+ lines.push(` ${(0, terminal_format_1.D)("Blocked:")} ${(0, terminal_format_1.R)(blocked + "()")}`);
580
573
  if (primary.missingStates?.length) {
581
574
  const missing = primary.missingStates.join(", ");
582
- lines.push(` ${D("Missing:")} ${C_(missing)}`);
575
+ lines.push(` ${(0, terminal_format_1.D)("Missing:")} ${(0, terminal_format_1.C_)(missing)}`);
583
576
  }
584
577
  if (primary.fixPath?.length) {
585
578
  const fixPath = primary.fixPath.join(" → ");
586
- lines.push(` ${D("Required:")} ${C_(fixPath)}`);
579
+ lines.push(` ${(0, terminal_format_1.D)("Required:")} ${(0, terminal_format_1.C_)(fixPath)}`);
587
580
  }
588
581
  }
589
582
  else {
590
583
  const detail = primary.description.length > 80 ? primary.description.slice(0, 77) + "..." : primary.description;
591
- lines.push(` ${D("Detail:")} ${detail}`);
584
+ lines.push(` ${(0, terminal_format_1.D)("Detail:")} ${detail}`);
592
585
  }
593
586
  return lines.join("\n");
594
587
  }
@@ -597,21 +590,21 @@ function formatImmuneResponse(a) {
597
590
  const primary = a.violations[0];
598
591
  if (primary?.fixPath?.length) {
599
592
  const path = primary.fixPath.join(" → ");
600
- lines.push(` ${B("Immune response:")} ${Y("repair path activated")}`);
601
- lines.push(` ${D("Repair:")} ${Y(path)}`);
593
+ lines.push(` ${(0, terminal_format_1.B)("Immune response:")} ${(0, terminal_format_1.Y)("repair path activated")}`);
594
+ lines.push(` ${(0, terminal_format_1.D)("Repair:")} ${(0, terminal_format_1.Y)(path)}`);
602
595
  }
603
596
  else if (a.llmCallCount > 1) {
604
- lines.push(` ${B("Immune response:")} ${Y("adaptation requested")}`);
597
+ lines.push(` ${(0, terminal_format_1.B)("Immune response:")} ${(0, terminal_format_1.Y)("adaptation requested")}`);
605
598
  }
606
599
  else {
607
- lines.push(` ${B("Immune response:")} ${Y("constraint violation recorded")}`);
600
+ lines.push(` ${(0, terminal_format_1.B)("Immune response:")} ${(0, terminal_format_1.Y)("constraint violation recorded")}`);
608
601
  }
609
602
  return lines.join("\n");
610
603
  }
611
604
  function formatReplayProgress(current, total) {
612
605
  const filled = "█".repeat(current);
613
606
  const empty = "░".repeat(total - current);
614
- return ` ${D("[" + filled + empty + "]")} ${current}/${total}`;
607
+ return ` ${(0, terminal_format_1.D)("[" + filled + empty + "]")} ${current}/${total}`;
615
608
  }
616
609
  async function replaySession(session) {
617
610
  clearScreen();
@@ -623,11 +616,11 @@ async function replaySession(session) {
623
616
  const a = attempts[i];
624
617
  const prev = i > 0 ? attempts[i - 1] : null;
625
618
  // ── Step header ──
626
- console.log(` ${B("━━━ Adaptation " + (i + 1) + " of " + totalAdaptations + " ━━━")}`);
619
+ console.log(` ${(0, terminal_format_1.B)("━━━ Adaptation " + (i + 1) + " of " + totalAdaptations + " ━━━")}`);
627
620
  console.log("");
628
621
  await sleep(300);
629
622
  // ── What the cognitive planner attempted ──
630
- console.log(` ${D("Cognitive planner action:")}`);
623
+ console.log(` ${(0, terminal_format_1.D)("Cognitive planner action:")}`);
631
624
  console.log(formatActionList(a.generatedActions));
632
625
  console.log("");
633
626
  await sleep(400);
@@ -650,44 +643,44 @@ async function replaySession(session) {
650
643
  console.log("");
651
644
  // ── Inter-adaptation pause ──
652
645
  if (i < attempts.length - 1) {
653
- console.log(` ${D("⏳ Cognitive planner re-evaluating...")}`);
646
+ console.log(` ${(0, terminal_format_1.D)("⏳ Cognitive planner re-evaluating...")}`);
654
647
  console.log("");
655
648
  await sleep(1200);
656
649
  }
657
650
  }
658
651
  // ── Resolution ──
659
652
  await sleep(600);
660
- console.log(` ${B("━━━ Cognitive Adaptation Complete ━━━")}`);
653
+ console.log(` ${(0, terminal_format_1.B)("━━━ Cognitive Adaptation Complete ━━━")}`);
661
654
  console.log("");
662
655
  if (session.resolved && session.successfulAttempt) {
663
656
  const actions = session.successfulAttempt.generatedActions || [];
664
- console.log(` ${G("✔")} ${B("Successful cognitive path established:")}`);
657
+ console.log(` ${(0, terminal_format_1.G)("✔")} ${(0, terminal_format_1.B)("Successful cognitive path established:")}`);
665
658
  console.log(formatActionList(actions));
666
659
  console.log("");
667
660
  const names = actions.filter(a => a.kind === "call").map(a => a.function).join(" → ");
668
- console.log(` ${G("✔")} ${names}`);
661
+ console.log(` ${(0, terminal_format_1.G)("✔")} ${names}`);
669
662
  console.log("");
670
663
  // State machine trace (from Semantic Ledger)
671
664
  const transitions = session.successfulAttempt.transitions;
672
665
  if (transitions.length > 0) {
673
- console.log(` ${B("State machine trace (from Ledger):")}`);
666
+ console.log(` ${(0, terminal_format_1.B)("State machine trace (from Ledger):")}`);
674
667
  console.log(formatStateTransitionPathFromLedger(transitions));
675
668
  console.log("");
676
669
  }
677
670
  const totalRetries = session.attempts.filter(a => a.outcome !== "success").length;
678
- console.log(` ${D(`Total adaptations: ${totalRetries}`)}`);
679
- console.log(` ${D(`Session: ${session.sessionId}`)}`);
671
+ console.log(` ${(0, terminal_format_1.D)(`Total adaptations: ${totalRetries}`)}`);
672
+ console.log(` ${(0, terminal_format_1.D)(`Session: ${session.sessionId}`)}`);
680
673
  }
681
674
  else {
682
- console.log(` ${R("✖")} ${B("Cognitive adaptation incomplete")}`);
675
+ console.log(` ${(0, terminal_format_1.R)("✖")} ${(0, terminal_format_1.B)("Cognitive adaptation incomplete")}`);
683
676
  console.log("");
684
- console.log(` ${D("The planner was unable to find a valid path within the constraint space.")}`);
677
+ console.log(` ${(0, terminal_format_1.D)("The planner was unable to find a valid path within the constraint space.")}`);
685
678
  const totalRetries = session.attempts.length;
686
- console.log(` ${D(`Total adaptations attempted: ${totalRetries}`)}`);
679
+ console.log(` ${(0, terminal_format_1.D)(`Total adaptations attempted: ${totalRetries}`)}`);
687
680
  }
688
681
  console.log("");
689
- console.log(` ${D("─".repeat(62))}`);
690
- console.log(` ${D("Semantic Observatory — replay complete")}`);
682
+ console.log(` ${(0, terminal_format_1.D)("─".repeat(62))}`);
683
+ console.log(` ${(0, terminal_format_1.D)("Semantic Observatory — replay complete")}`);
691
684
  console.log("");
692
685
  // Ledger replay validation
693
686
  console.log(formatLedgerReplayValidation(session));
@@ -696,10 +689,10 @@ async function replaySession(session) {
696
689
  function formatLedgerReplayValidation(session) {
697
690
  const lines = [];
698
691
  lines.push("");
699
- lines.push(`${C_("Ledger Replay Validation")}`);
700
- lines.push(`${D("═".repeat(62))}`);
692
+ lines.push(`${(0, terminal_format_1.C_)("Ledger Replay Validation")}`);
693
+ lines.push(`${(0, terminal_format_1.D)("═".repeat(62))}`);
701
694
  if (!session.attempts || session.attempts.length === 0) {
702
- lines.push(` ${D("No attempts to replay.")}`);
695
+ lines.push(` ${(0, terminal_format_1.D)("No attempts to replay.")}`);
703
696
  return lines.join("\n");
704
697
  }
705
698
  // Load current protocols for ruleHash comparison
@@ -715,7 +708,7 @@ function formatLedgerReplayValidation(session) {
715
708
  currentRuleHash = (0, ssg_validator_1.hashRules)(rules);
716
709
  }
717
710
  }
718
- catch { }
711
+ catch { /* trace step — best-effort */ }
719
712
  const nsInit = new Map();
720
713
  nsInit.set("_global", "UNAUTHENTICATED");
721
714
  try {
@@ -729,7 +722,7 @@ function formatLedgerReplayValidation(session) {
729
722
  }
730
723
  }
731
724
  }
732
- catch { }
725
+ catch { /* trace step — best-effort */ }
733
726
  let totalLedgers = 0;
734
727
  let consistentLedgers = 0;
735
728
  let stateMatchLedgers = 0;
@@ -743,12 +736,12 @@ function formatLedgerReplayValidation(session) {
743
736
  const consistency = (0, ssg_validator_1.checkLedgerConsistency)(transitions, nsInit);
744
737
  if (consistency.consistent) {
745
738
  consistentLedgers++;
746
- lines.push(` ${G("✔")} ${attemptLabel}: Invariants clean`);
739
+ lines.push(` ${(0, terminal_format_1.G)("✔")} ${attemptLabel}: Invariants clean`);
747
740
  }
748
741
  else {
749
- lines.push(` ${R("✖")} ${attemptLabel}: ${consistency.violations.length} invariant violation(s)`);
742
+ lines.push(` ${(0, terminal_format_1.R)("✖")} ${attemptLabel}: ${consistency.violations.length} invariant violation(s)`);
750
743
  for (const v of consistency.violations.slice(0, 2)) {
751
- lines.push(` ${D(`[${v.invariant}] index=${v.index}: ${v.detail || ""}`)}`);
744
+ lines.push(` ${(0, terminal_format_1.D)(`[${v.invariant}] index=${v.index}: ${v.detail || ""}`)}`);
752
745
  }
753
746
  }
754
747
  // 2. rebuildState matches recorded statesAfter (normalized)
@@ -768,36 +761,36 @@ function formatLedgerReplayValidation(session) {
768
761
  const recordedNorm = JSON.stringify(norm(recorded));
769
762
  if (rebuiltNorm === recordedNorm) {
770
763
  stateMatchLedgers++;
771
- lines.push(` ${G("rebuildState === recorded")}`);
764
+ lines.push(` ${(0, terminal_format_1.G)("rebuildState === recorded")}`);
772
765
  }
773
766
  else {
774
- lines.push(` ${R("rebuildState !== recorded")}`);
775
- lines.push(` ${D(" rebuilt: " + rebuiltNorm)}`);
776
- lines.push(` ${D(" recorded: " + recordedNorm)}`);
767
+ lines.push(` ${(0, terminal_format_1.R)("rebuildState !== recorded")}`);
768
+ lines.push(` ${(0, terminal_format_1.D)(" rebuilt: " + rebuiltNorm)}`);
769
+ lines.push(` ${(0, terminal_format_1.D)(" recorded: " + recordedNorm)}`);
777
770
  }
778
771
  // 3. ruleHash comparison
779
772
  if (attempt.ruleHash && currentRuleHash) {
780
773
  if (attempt.ruleHash === currentRuleHash) {
781
- lines.push(` ${G("ruleHash match")} ${D(attempt.ruleHash)}`);
774
+ lines.push(` ${(0, terminal_format_1.G)("ruleHash match")} ${(0, terminal_format_1.D)(attempt.ruleHash)}`);
782
775
  }
783
776
  else {
784
- lines.push(` ${Y("ruleHash mismatch")} ${D("attempt: " + attempt.ruleHash + " | current: " + currentRuleHash)}`);
777
+ lines.push(` ${(0, terminal_format_1.Y)("ruleHash mismatch")} ${(0, terminal_format_1.D)("attempt: " + attempt.ruleHash + " | current: " + currentRuleHash)}`);
785
778
  }
786
779
  }
787
780
  else if (attempt.ruleHash && !currentRuleHash) {
788
- lines.push(` ${D("ruleHash: " + attempt.ruleHash + " (no current protocols to compare)")}`);
781
+ lines.push(` ${(0, terminal_format_1.D)("ruleHash: " + attempt.ruleHash + " (no current protocols to compare)")}`);
789
782
  }
790
783
  }
791
784
  // Session-level ruleHash
792
785
  if (session.ruleHash) {
793
786
  lines.push("");
794
- lines.push(` ${D("Session ruleHash:")} ${session.ruleHash}`);
787
+ lines.push(` ${(0, terminal_format_1.D)("Session ruleHash:")} ${session.ruleHash}`);
795
788
  if (currentRuleHash) {
796
789
  if (session.ruleHash === currentRuleHash) {
797
- lines.push(` ${G("Session ruleHash matches current protocols.")}`);
790
+ lines.push(` ${(0, terminal_format_1.G)("Session ruleHash matches current protocols.")}`);
798
791
  }
799
792
  else {
800
- lines.push(` ${Y("Session ruleHash differs from current protocols.")} ${D("Replay may yield different results.")}`);
793
+ lines.push(` ${(0, terminal_format_1.Y)("Session ruleHash differs from current protocols.")} ${(0, terminal_format_1.D)("Replay may yield different results.")}`);
801
794
  }
802
795
  }
803
796
  }
@@ -806,20 +799,20 @@ function formatLedgerReplayValidation(session) {
806
799
  const allTransitions = session.attempts.flatMap(a => a.transitions || []);
807
800
  if (allTransitions.length > 0) {
808
801
  const ledgerHash = (0, ssg_validator_1.hashLedger)(allTransitions);
809
- lines.push(` ${D("Ledger hash:")} ${ledgerHash} ${D("(tamper-evident integrity)")}`);
802
+ lines.push(` ${(0, terminal_format_1.D)("Ledger hash:")} ${ledgerHash} ${(0, terminal_format_1.D)("(tamper-evident integrity)")}`);
810
803
  }
811
804
  }
812
805
  lines.push("");
813
806
  if (totalLedgers === 0) {
814
- lines.push(` ${D("No ledger data in this session.")}`);
807
+ lines.push(` ${(0, terminal_format_1.D)("No ledger data in this session.")}`);
815
808
  }
816
809
  else {
817
810
  const allOk = consistentLedgers === totalLedgers && stateMatchLedgers === totalLedgers;
818
811
  if (allOk) {
819
- lines.push(` ${G("✦")} ${B(`Ledger Replay: ${totalLedgers}/${totalLedgers} consistent, all states match`)}`);
812
+ lines.push(` ${(0, terminal_format_1.G)("✦")} ${(0, terminal_format_1.B)(`Ledger Replay: ${totalLedgers}/${totalLedgers} consistent, all states match`)}`);
820
813
  }
821
814
  else {
822
- lines.push(` ${Y("◇")} ${B(`Ledger Replay: ${consistentLedgers}/${totalLedgers} consistent, ${stateMatchLedgers}/${totalLedgers} state-match`)}`);
815
+ lines.push(` ${(0, terminal_format_1.Y)("◇")} ${(0, terminal_format_1.B)(`Ledger Replay: ${consistentLedgers}/${totalLedgers} consistent, ${stateMatchLedgers}/${totalLedgers} state-match`)}`);
823
816
  }
824
817
  }
825
818
  return lines.join("\n");
@@ -828,8 +821,8 @@ function formatLedgerReplayValidation(session) {
828
821
  function formatLedgerStats() {
829
822
  const sessions = (0, failure_corpus_1.getAllSessions)();
830
823
  const lines = [];
831
- lines.push(`${C_("Ledger Corpus Statistics")}`);
832
- lines.push(`${D("═".repeat(62))}`);
824
+ lines.push(`${(0, terminal_format_1.C_)("Ledger Corpus Statistics")}`);
825
+ lines.push(`${(0, terminal_format_1.D)("═".repeat(62))}`);
833
826
  lines.push("");
834
827
  let totalSessions = 0;
835
828
  let totalLedgers = 0;
@@ -867,22 +860,22 @@ function formatLedgerStats() {
867
860
  }
868
861
  }
869
862
  if (totalSessions === 0) {
870
- lines.push(` ${D("No sessions with ledger data.")}`);
863
+ lines.push(` ${(0, terminal_format_1.D)("No sessions with ledger data.")}`);
871
864
  return lines.join("\n");
872
865
  }
873
- lines.push(` ${B("Sessions:")} ${totalSessions} (${D(`${sessions.length} total`)})`);
874
- lines.push(` ${B("Ledgers:")} ${totalLedgers}`);
875
- lines.push(` ${B("Transitions:")} ${totalTransitions} (${G(`${validTransitions} valid`)}, ${R(`${invalidTransitions} invalid`)})`);
866
+ lines.push(` ${(0, terminal_format_1.B)("Sessions:")} ${totalSessions} (${(0, terminal_format_1.D)(`${sessions.length} total`)})`);
867
+ lines.push(` ${(0, terminal_format_1.B)("Ledgers:")} ${totalLedgers}`);
868
+ lines.push(` ${(0, terminal_format_1.B)("Transitions:")} ${totalTransitions} (${(0, terminal_format_1.G)(`${validTransitions} valid`)}, ${(0, terminal_format_1.R)(`${invalidTransitions} invalid`)})`);
876
869
  const validPct = totalTransitions > 0 ? Math.round((validTransitions / totalTransitions) * 100) : 0;
877
- lines.push(` ${B("Validity rate:")} ${validPct >= 90 ? G(`${validPct}%`) : Y(`${validPct}%`)}`);
878
- lines.push(` ${B("Rule hashes:")} ${allRuleHashes.size} unique (${sessionsWithRuleHash}/${totalSessions} sessions have ruleHash)`);
870
+ lines.push(` ${(0, terminal_format_1.B)("Validity rate:")} ${validPct >= 90 ? (0, terminal_format_1.G)(`${validPct}%`) : (0, terminal_format_1.Y)(`${validPct}%`)}`);
871
+ lines.push(` ${(0, terminal_format_1.B)("Rule hashes:")} ${allRuleHashes.size} unique (${sessionsWithRuleHash}/${totalSessions} sessions have ruleHash)`);
879
872
  // Top producers
880
873
  const topProducers = [...stateProducers.entries()].sort((a, b) => b[1] - a[1]).slice(0, 5);
881
874
  if (topProducers.length > 0) {
882
875
  lines.push("");
883
- lines.push(` ${B("Top produced states:")}`);
876
+ lines.push(` ${(0, terminal_format_1.B)("Top produced states:")}`);
884
877
  for (const [state, count] of topProducers) {
885
- lines.push(` ${G("+" + state)}: ${count}x`);
878
+ lines.push(` ${(0, terminal_format_1.G)("+" + state)}: ${count}x`);
886
879
  }
887
880
  }
888
881
  // Top consumers
@@ -891,22 +884,22 @@ function formatLedgerStats() {
891
884
  .sort((a, b) => b[1] - a[1]).slice(0, 5);
892
885
  if (topConsumers.length > 0) {
893
886
  lines.push("");
894
- lines.push(` ${B("Top consumed states:")}`);
887
+ lines.push(` ${(0, terminal_format_1.B)("Top consumed states:")}`);
895
888
  for (const [state, count] of topConsumers) {
896
- lines.push(` ${Y("←" + state)}: ${count}x`);
889
+ lines.push(` ${(0, terminal_format_1.Y)("←" + state)}: ${count}x`);
897
890
  }
898
891
  }
899
892
  // Per-session detail
900
893
  lines.push("");
901
- lines.push(` ${B("Per-session breakdown:")}`);
894
+ lines.push(` ${(0, terminal_format_1.B)("Per-session breakdown:")}`);
902
895
  for (const session of sessions) {
903
896
  const allTransitions = session.attempts.flatMap(a => a.transitions || []);
904
897
  if (allTransitions.length === 0)
905
898
  continue;
906
899
  const validCount = allTransitions.filter(t => t.valid).length;
907
- const hashTag = session.ruleHash ? ` [${D(session.ruleHash.slice(0, 8))}]` : "";
900
+ const hashTag = session.ruleHash ? ` [${(0, terminal_format_1.D)(session.ruleHash.slice(0, 8))}]` : "";
908
901
  const intentShort = session.intent.length > 40 ? session.intent.slice(0, 37) + "..." : session.intent;
909
- lines.push(` ${D(session.sessionId.slice(-8))} ${validCount}/${allTransitions.length} valid ${D("·")} ${intentShort}${hashTag}`);
902
+ lines.push(` ${(0, terminal_format_1.D)(session.sessionId.slice(-8))} ${validCount}/${allTransitions.length} valid ${(0, terminal_format_1.D)("·")} ${intentShort}${hashTag}`);
910
903
  }
911
904
  return lines.join("\n");
912
905
  }
@@ -915,8 +908,8 @@ function formatCrossSessionQuery(operation, state) {
915
908
  const sessions = (0, failure_corpus_1.getAllSessions)();
916
909
  const lines = [];
917
910
  const label = operation === "producer" ? `Producers of "${state}"` : `Consumers of "${state}"`;
918
- lines.push(`${C_(`Cross-session: ${label}`)}`);
919
- lines.push(`${D("═".repeat(62))}`);
911
+ lines.push(`${(0, terminal_format_1.C_)(`Cross-session: ${label}`)}`);
912
+ lines.push(`${(0, terminal_format_1.D)("═".repeat(62))}`);
920
913
  lines.push("");
921
914
  let found = 0;
922
915
  for (const session of sessions) {
@@ -936,16 +929,16 @@ function formatCrossSessionQuery(operation, state) {
936
929
  const intentShort = session.intent.length > 50 ? session.intent.slice(0, 47) + "..." : session.intent;
937
930
  const funcs = [...new Set(results.map(r => r.transition.function))].join(", ");
938
931
  const validCount = allTransitions.filter(t => t.valid).length;
939
- const hashTag = session.ruleHash ? ` ${D(session.ruleHash.slice(0, 8))}` : "";
940
- lines.push(` ${D(session.sessionId.slice(-8))} ${G(`${results.length}x`)} via ${C_(funcs)} ${D(`(${validCount}/${allTransitions.length} valid)${hashTag}`)}`);
941
- lines.push(` ${D(intentShort)}`);
932
+ const hashTag = session.ruleHash ? ` ${(0, terminal_format_1.D)(session.ruleHash.slice(0, 8))}` : "";
933
+ lines.push(` ${(0, terminal_format_1.D)(session.sessionId.slice(-8))} ${(0, terminal_format_1.G)(`${results.length}x`)} via ${(0, terminal_format_1.C_)(funcs)} ${(0, terminal_format_1.D)(`(${validCount}/${allTransitions.length} valid)${hashTag}`)}`);
934
+ lines.push(` ${(0, terminal_format_1.D)(intentShort)}`);
942
935
  }
943
936
  if (found === 0) {
944
- lines.push(` ${D(`No sessions found with ${operation} for "${state}".`)}`);
937
+ lines.push(` ${(0, terminal_format_1.D)(`No sessions found with ${operation} for "${state}".`)}`);
945
938
  }
946
939
  else {
947
940
  lines.push("");
948
- lines.push(` ${B(`Found in ${found} session(s).`)}`);
941
+ lines.push(` ${(0, terminal_format_1.B)(`Found in ${found} session(s).`)}`);
949
942
  }
950
943
  return lines.join("\n");
951
944
  }
@@ -954,76 +947,76 @@ function formatCrossSessionQuery(operation, state) {
954
947
  function formatSnapshotList() {
955
948
  const snapshots = (0, semantic_snapshot_1.listSnapshots)();
956
949
  if (snapshots.length === 0) {
957
- return `${D("No IR snapshots recorded yet. Run the planner to capture the first snapshot.")}`;
950
+ return `${(0, terminal_format_1.D)("No IR snapshots recorded yet. Run the planner to capture the first snapshot.")}`;
958
951
  }
959
952
  const lines = [];
960
- const C_ = (s) => `${C.cyan}${s}${C.reset}`;
953
+ const C_ = (s) => `${terminal_format_1.COLORS.cyan}${s}${terminal_format_1.COLORS.reset}`;
961
954
  lines.push(`${C_("IR Snapshots")} (${snapshots.length} total):\n`);
962
- lines.push(`${B("┌──────────────────────┬──────────────────────┬──────────┬────────────────────────────────┐")}`);
963
- lines.push(`${B("│")} ${B("Snapshot ID")} ${B("│")} ${B("Timestamp")} ${B("│")} ${B("Funcs")} ${B("│")} ${B("Intent")} ${B("│")}`);
964
- lines.push(`${B("├──────────────────────┼──────────────────────┼──────────┼────────────────────────────────┤")}`);
955
+ lines.push(`${(0, terminal_format_1.B)("┌──────────────────────┬──────────────────────┬──────────┬────────────────────────────────┐")}`);
956
+ lines.push(`${(0, terminal_format_1.B)("│")} ${(0, terminal_format_1.B)("Snapshot ID")} ${(0, terminal_format_1.B)("│")} ${(0, terminal_format_1.B)("Timestamp")} ${(0, terminal_format_1.B)("│")} ${(0, terminal_format_1.B)("Funcs")} ${(0, terminal_format_1.B)("│")} ${(0, terminal_format_1.B)("Intent")} ${(0, terminal_format_1.B)("│")}`);
957
+ lines.push(`${(0, terminal_format_1.B)("├──────────────────────┼──────────────────────┼──────────┼────────────────────────────────┤")}`);
965
958
  for (const snap of snapshots.slice(0, 20)) {
966
959
  const id = snap.id.slice(-16);
967
960
  const ts = snap.timestamp.slice(0, 19).replace("T", " ");
968
961
  const count = String(snap.functions.length).padStart(4);
969
962
  const intent = (snap.intent || "").slice(0, 30).padEnd(30);
970
- lines.push(`${D("│")} ${D(id)} ${D("│")} ${ts} ${D("│")} ${count} ${D("│")} ${intent} ${D("│")}`);
963
+ lines.push(`${(0, terminal_format_1.D)("│")} ${(0, terminal_format_1.D)(id)} ${(0, terminal_format_1.D)("│")} ${ts} ${(0, terminal_format_1.D)("│")} ${count} ${(0, terminal_format_1.D)("│")} ${intent} ${(0, terminal_format_1.D)("│")}`);
971
964
  }
972
- lines.push(`${B("└──────────────────────┴──────────────────────┴──────────┴────────────────────────────────┘")}`);
965
+ lines.push(`${(0, terminal_format_1.B)("└──────────────────────┴──────────────────────┴──────────┴────────────────────────────────┘")}`);
973
966
  return lines.join("\n");
974
967
  }
975
968
  function formatSnapshotDiff(snapIdA, snapIdB) {
976
969
  const a = (0, semantic_snapshot_1.loadSnapshot)(snapIdA);
977
970
  const b = (0, semantic_snapshot_1.loadSnapshot)(snapIdB);
978
971
  if (!a)
979
- return `${R("Snapshot not found:")} ${snapIdA}`;
972
+ return `${(0, terminal_format_1.R)("Snapshot not found:")} ${snapIdA}`;
980
973
  if (!b)
981
- return `${R("Snapshot not found:")} ${snapIdB}`;
974
+ return `${(0, terminal_format_1.R)("Snapshot not found:")} ${snapIdB}`;
982
975
  const diff = (0, semantic_snapshot_1.diffSnapshots)(a, b);
983
976
  const lines = [];
984
- const C_ = (s) => `${C.cyan}${s}${C.reset}`;
977
+ const C_ = (s) => `${terminal_format_1.COLORS.cyan}${s}${terminal_format_1.COLORS.reset}`;
985
978
  lines.push(`${C_("IR Snapshot Diff")}`);
986
- lines.push(`${D(`${a.id}`)} → ${D(`${b.id}`)}`);
979
+ lines.push(`${(0, terminal_format_1.D)(`${a.id}`)} → ${(0, terminal_format_1.D)(`${b.id}`)}`);
987
980
  lines.push(` ${a.timestamp.slice(0, 19)} → ${b.timestamp.slice(0, 19)}`);
988
981
  lines.push("");
989
982
  if (diff.added.length > 0) {
990
- lines.push(` ${G("+ Added")} (${diff.added.length}):`);
983
+ lines.push(` ${(0, terminal_format_1.G)("+ Added")} (${diff.added.length}):`);
991
984
  for (const f of diff.added) {
992
- lines.push(` ${G("+")} ${f.name}(${f.params.map(p => `${p.name}:${p.type}`).join(", ")}) → ${f.returnType}`);
985
+ lines.push(` ${(0, terminal_format_1.G)("+")} ${f.name}(${f.params.map(p => `${p.name}:${p.type}`).join(", ")}) → ${f.returnType}`);
993
986
  }
994
987
  lines.push("");
995
988
  }
996
989
  if (diff.removed.length > 0) {
997
- lines.push(` ${R("- Removed")} (${diff.removed.length}):`);
990
+ lines.push(` ${(0, terminal_format_1.R)("- Removed")} (${diff.removed.length}):`);
998
991
  for (const f of diff.removed) {
999
- lines.push(` ${R("-")} ${f.name}(${f.params.map(p => `${p.name}:${p.type}`).join(", ")}) → ${f.returnType}`);
992
+ lines.push(` ${(0, terminal_format_1.R)("-")} ${f.name}(${f.params.map(p => `${p.name}:${p.type}`).join(", ")}) → ${f.returnType}`);
1000
993
  }
1001
994
  lines.push("");
1002
995
  }
1003
996
  if (diff.changed.length > 0) {
1004
- lines.push(` ${Y("~ Changed")} (${diff.changed.length}):`);
997
+ lines.push(` ${(0, terminal_format_1.Y)("~ Changed")} (${diff.changed.length}):`);
1005
998
  for (const { before, after } of diff.changed) {
1006
- lines.push(` ${Y("~")} ${before.name}:`);
1007
- lines.push(` ${R("-")} ${before.returnType} (${before.params.map(p => `${p.name}:${p.type}`).join(", ")})`);
1008
- lines.push(` ${G("+")} ${after.returnType} (${after.params.map(p => `${p.name}:${p.type}`).join(", ")})`);
999
+ lines.push(` ${(0, terminal_format_1.Y)("~")} ${before.name}:`);
1000
+ lines.push(` ${(0, terminal_format_1.R)("-")} ${before.returnType} (${before.params.map(p => `${p.name}:${p.type}`).join(", ")})`);
1001
+ lines.push(` ${(0, terminal_format_1.G)("+")} ${after.returnType} (${after.params.map(p => `${p.name}:${p.type}`).join(", ")})`);
1009
1002
  }
1010
1003
  lines.push("");
1011
1004
  }
1012
1005
  if (diff.unchanged > 0) {
1013
- lines.push(` ${D(`${diff.unchanged} functions unchanged`)}`);
1006
+ lines.push(` ${(0, terminal_format_1.D)(`${diff.unchanged} functions unchanged`)}`);
1014
1007
  }
1015
1008
  if (diff.added.length === 0 && diff.removed.length === 0 && diff.changed.length === 0) {
1016
- lines.push(` ${D("No differences — snapshots are identical.")}`);
1009
+ lines.push(` ${(0, terminal_format_1.D)("No differences — snapshots are identical.")}`);
1017
1010
  }
1018
1011
  return lines.join("\n");
1019
1012
  }
1020
1013
  // ── Deterministic Replay: validate session against snapshot vs. live IR ──
1021
1014
  function formatSessionValidation(session) {
1022
1015
  const lines = [];
1023
- const C_ = (s) => `${C.cyan}${s}${C.reset}`;
1016
+ const C_ = (s) => `${terminal_format_1.COLORS.cyan}${s}${terminal_format_1.COLORS.reset}`;
1024
1017
  lines.push(`${C_("Deterministic Replay Validation")}`);
1025
- lines.push(`${D(`Session: ${session.sessionId}`)}`);
1026
- lines.push(`${D(`Intent: ${session.intent}`)}`);
1018
+ lines.push(`${(0, terminal_format_1.D)(`Session: ${session.sessionId}`)}`);
1019
+ lines.push(`${(0, terminal_format_1.D)(`Intent: ${session.intent}`)}`);
1027
1020
  lines.push("");
1028
1021
  // Collect all called functions from all attempts + successful path
1029
1022
  const allCalledFns = new Set();
@@ -1045,14 +1038,14 @@ function formatSessionValidation(session) {
1045
1038
  const snap = (0, semantic_snapshot_1.loadSnapshot)(session.snapshotId);
1046
1039
  if (snap) {
1047
1040
  snapshotFns = new Set(snap.functions.map(f => f.name));
1048
- lines.push(`${D("Snapshot IR:")} ${snap.id} (${snap.functions.length} functions)`);
1041
+ lines.push(`${(0, terminal_format_1.D)("Snapshot IR:")} ${snap.id} (${snap.functions.length} functions)`);
1049
1042
  }
1050
1043
  else {
1051
- lines.push(`${Y("Snapshot not found:")} ${session.snapshotId}`);
1044
+ lines.push(`${(0, terminal_format_1.Y)("Snapshot not found:")} ${session.snapshotId}`);
1052
1045
  }
1053
1046
  }
1054
1047
  else {
1055
- lines.push(`${D("No snapshot linked to this session.")}`);
1048
+ lines.push(`${(0, terminal_format_1.D)("No snapshot linked to this session.")}`);
1056
1049
  }
1057
1050
  // Load current IR
1058
1051
  let currentFns = null;
@@ -1061,64 +1054,64 @@ function formatSessionValidation(session) {
1061
1054
  if (fs.existsSync(irPath)) {
1062
1055
  const ir = JSON.parse(fs.readFileSync(irPath, "utf-8"));
1063
1056
  currentFns = new Set(ir.map((f) => f.name));
1064
- lines.push(`${D("Current IR:")} ir.json (${ir.length} functions)`);
1057
+ lines.push(`${(0, terminal_format_1.D)("Current IR:")} ir.json (${ir.length} functions)`);
1065
1058
  }
1066
1059
  }
1067
- catch { }
1060
+ catch { /* trace step — best-effort */ }
1068
1061
  lines.push("");
1069
1062
  if (!snapshotFns && !currentFns) {
1070
- lines.push(`${D("No IR data available for comparison.")}`);
1063
+ lines.push(`${(0, terminal_format_1.D)("No IR data available for comparison.")}`);
1071
1064
  return lines.join("\n");
1072
1065
  }
1073
1066
  // Per-function validation table
1074
1067
  const fns = [...allCalledFns].sort();
1075
1068
  if (fns.length === 0) {
1076
- lines.push(`${D("No function calls recorded in this session.")}`);
1069
+ lines.push(`${(0, terminal_format_1.D)("No function calls recorded in this session.")}`);
1077
1070
  return lines.join("\n");
1078
1071
  }
1079
- lines.push(`${B("Function validation (then vs. now):")}`);
1080
- lines.push(`${B("┌────────────────────────────┬──────────┬──────────┬──────────────────────────────────────┐")}`);
1081
- lines.push(`${B("│")} ${B("Function")} ${B("│")} ${B("Then")} ${B("│")} ${B("Now")} ${B("│")} ${B("Status")} ${B("│")}`);
1082
- lines.push(`${B("├────────────────────────────┼──────────┼──────────┼──────────────────────────────────────┤")}`);
1072
+ lines.push(`${(0, terminal_format_1.B)("Function validation (then vs. now):")}`);
1073
+ lines.push(`${(0, terminal_format_1.B)("┌────────────────────────────┬──────────┬──────────┬──────────────────────────────────────┐")}`);
1074
+ lines.push(`${(0, terminal_format_1.B)("│")} ${(0, terminal_format_1.B)("Function")} ${(0, terminal_format_1.B)("│")} ${(0, terminal_format_1.B)("Then")} ${(0, terminal_format_1.B)("│")} ${(0, terminal_format_1.B)("Now")} ${(0, terminal_format_1.B)("│")} ${(0, terminal_format_1.B)("Status")} ${(0, terminal_format_1.B)("│")}`);
1075
+ lines.push(`${(0, terminal_format_1.B)("├────────────────────────────┼──────────┼──────────┼──────────────────────────────────────┤")}`);
1083
1076
  let regressions = 0;
1084
1077
  let additions = 0;
1085
1078
  for (const fn of fns) {
1086
1079
  const existed = snapshotFns ? snapshotFns.has(fn) : null;
1087
1080
  const exists = currentFns ? currentFns.has(fn) : null;
1088
- const thenIcon = existed === null ? D("?") : existed ? G("✔") : R("✖");
1089
- const nowIcon = exists === null ? D("?") : exists ? G("✔") : R("✖");
1081
+ const thenIcon = existed === null ? (0, terminal_format_1.D)("?") : existed ? (0, terminal_format_1.G)("✔") : (0, terminal_format_1.R)("✖");
1082
+ const nowIcon = exists === null ? (0, terminal_format_1.D)("?") : exists ? (0, terminal_format_1.G)("✔") : (0, terminal_format_1.R)("✖");
1090
1083
  let status;
1091
1084
  if (existed === true && exists === true) {
1092
- status = D("stable");
1085
+ status = (0, terminal_format_1.D)("stable");
1093
1086
  }
1094
1087
  else if (existed === true && exists === false) {
1095
- status = R("REGRESSION — removed from IR");
1088
+ status = (0, terminal_format_1.R)("REGRESSION — removed from IR");
1096
1089
  regressions++;
1097
1090
  }
1098
1091
  else if (existed === false && exists === true) {
1099
- status = G("ADDED — new in IR");
1092
+ status = (0, terminal_format_1.G)("ADDED — new in IR");
1100
1093
  additions++;
1101
1094
  }
1102
1095
  else if (existed === false && exists === false) {
1103
- status = R("MISSING — never existed");
1096
+ status = (0, terminal_format_1.R)("MISSING — never existed");
1104
1097
  }
1105
1098
  else {
1106
- status = D("unknown");
1099
+ status = (0, terminal_format_1.D)("unknown");
1107
1100
  }
1108
1101
  const fnPad = fn.padEnd(26).slice(0, 26);
1109
- lines.push(`${D("│")} ${fnPad} ${D("│")} ${thenIcon} ${D("│")} ${nowIcon} ${D("│")} ${status.padEnd(36)} ${D("│")}`);
1102
+ lines.push(`${(0, terminal_format_1.D)("│")} ${fnPad} ${(0, terminal_format_1.D)("│")} ${thenIcon} ${(0, terminal_format_1.D)("│")} ${nowIcon} ${(0, terminal_format_1.D)("│")} ${status.padEnd(36)} ${(0, terminal_format_1.D)("│")}`);
1110
1103
  }
1111
- lines.push(`${B("└────────────────────────────┴──────────┴──────────┴──────────────────────────────────────┘")}`);
1104
+ lines.push(`${(0, terminal_format_1.B)("└────────────────────────────┴──────────┴──────────┴──────────────────────────────────────┘")}`);
1112
1105
  lines.push("");
1113
1106
  // Summary
1114
1107
  if (regressions > 0) {
1115
- lines.push(`${R(`⚠ ${regressions} regression(s) detected — functions removed from IR since this session`)}`);
1108
+ lines.push(`${(0, terminal_format_1.R)(`⚠ ${regressions} regression(s) detected — functions removed from IR since this session`)}`);
1116
1109
  }
1117
1110
  if (additions > 0) {
1118
- lines.push(`${G(`+ ${additions} function(s) added to IR since this session`)}`);
1111
+ lines.push(`${(0, terminal_format_1.G)(`+ ${additions} function(s) added to IR since this session`)}`);
1119
1112
  }
1120
1113
  if (regressions === 0 && additions === 0 && fns.length > 0) {
1121
- lines.push(`${G("✔ IR stable — all functions present in both snapshot and current IR.")}`);
1114
+ lines.push(`${(0, terminal_format_1.G)("✔ IR stable — all functions present in both snapshot and current IR.")}`);
1122
1115
  }
1123
1116
  // Protocol validation against snapshot
1124
1117
  if (session.successfulAttempt && session.snapshotId) {
@@ -1158,28 +1151,28 @@ function formatSessionValidation(session) {
1158
1151
  transitions.push(transition);
1159
1152
  ctx.ledger = transitions;
1160
1153
  if (!tValid) {
1161
- lines.push(` ${R("🚫")} ${act.function}: ${rejection?.missingFunctions.join(" → ") || "protocol violation"}`);
1154
+ lines.push(` ${(0, terminal_format_1.R)("🚫")} ${act.function}: ${rejection?.missingFunctions.join(" → ") || "protocol violation"}`);
1162
1155
  valid = false;
1163
1156
  }
1164
1157
  else {
1165
1158
  ctx.currentState = transition.statesAfter;
1166
- lines.push(` ${G("✅")} ${act.function}`);
1159
+ lines.push(` ${(0, terminal_format_1.G)("✅")} ${act.function}`);
1167
1160
  }
1168
1161
  }
1169
1162
  }
1170
1163
  // Ledger consistency check
1171
1164
  const consistency = (0, ssg_validator_1.checkLedgerConsistency)(transitions, nsStates);
1172
1165
  if (!consistency.consistent) {
1173
- lines.push(` ${R("⚠")} Ledger consistency: ${consistency.violations.length} violation(s)`);
1166
+ lines.push(` ${(0, terminal_format_1.R)("⚠")} Ledger consistency: ${consistency.violations.length} violation(s)`);
1174
1167
  valid = false;
1175
1168
  }
1176
1169
  if (valid) {
1177
- lines.push(` ${G("✔ All actions satisfy protocol constraints against snapshot IR.")}`);
1170
+ lines.push(` ${(0, terminal_format_1.G)("✔ All actions satisfy protocol constraints against snapshot IR.")}`);
1178
1171
  }
1179
1172
  }
1180
1173
  }
1181
1174
  catch (e) {
1182
- lines.push(` ${D("(protocol re-validation not available)")}`);
1175
+ lines.push(` ${(0, terminal_format_1.D)("(protocol re-validation not available)")}`);
1183
1176
  }
1184
1177
  }
1185
1178
  }
@@ -1207,41 +1200,41 @@ async function main() {
1207
1200
  const idA = process.argv[3];
1208
1201
  const idB = process.argv[4];
1209
1202
  if (!idA || !idB) {
1210
- console.error(`${R("Usage:")} ts-node src/semantic-trace.ts --diff-ledgers <sessionIdA> <sessionIdB>`);
1203
+ console.error(`${(0, terminal_format_1.R)("Usage:")} ts-node src/semantic-trace.ts --diff-ledgers <sessionIdA> <sessionIdB>`);
1211
1204
  process.exit(1);
1212
1205
  }
1213
1206
  const sessions = (0, failure_corpus_1.getAllSessions)();
1214
1207
  const sessA = sessions.find(s => s.sessionId === idA || s.sessionId.startsWith(idA));
1215
1208
  const sessB = sessions.find(s => s.sessionId === idB || s.sessionId.startsWith(idB));
1216
1209
  if (!sessA) {
1217
- console.error(`${R("Session A not found:")} ${idA}`);
1210
+ console.error(`${(0, terminal_format_1.R)("Session A not found:")} ${idA}`);
1218
1211
  process.exit(1);
1219
1212
  }
1220
1213
  if (!sessB) {
1221
- console.error(`${R("Session B not found:")} ${idB}`);
1214
+ console.error(`${(0, terminal_format_1.R)("Session B not found:")} ${idB}`);
1222
1215
  process.exit(1);
1223
1216
  }
1224
1217
  const ledgerA = sessA.attempts.flatMap(a => a.transitions || []);
1225
1218
  const ledgerB = sessB.attempts.flatMap(a => a.transitions || []);
1226
1219
  const diff = (0, ssg_validator_1.diffLedgers)(ledgerA, ledgerB);
1227
- console.log(`${C_("Ledger Diff")}`);
1228
- console.log(`${D("═".repeat(50))}`);
1229
- console.log(` A: ${D(sessA.sessionId)} (${ledgerA.length} transitions)`);
1230
- console.log(` B: ${D(sessB.sessionId)} (${ledgerB.length} transitions)`);
1220
+ console.log(`${(0, terminal_format_1.C_)("Ledger Diff")}`);
1221
+ console.log(`${(0, terminal_format_1.D)("═".repeat(50))}`);
1222
+ console.log(` A: ${(0, terminal_format_1.D)(sessA.sessionId)} (${ledgerA.length} transitions)`);
1223
+ console.log(` B: ${(0, terminal_format_1.D)(sessB.sessionId)} (${ledgerB.length} transitions)`);
1231
1224
  console.log("");
1232
1225
  if (diff.identical) {
1233
- console.log(` ${G("✔ Ledgers are identical.")}`);
1226
+ console.log(` ${(0, terminal_format_1.G)("✔ Ledgers are identical.")}`);
1234
1227
  }
1235
1228
  else {
1236
- console.log(` ${G(`Unchanged: ${diff.unchanged}`)} ${R(`Only in A: ${diff.onlyInA.length}`)} ${Y(`Only in B: ${diff.onlyInB.length}`)} ${Y(`Changed: ${diff.changed.length}`)}`);
1229
+ console.log(` ${(0, terminal_format_1.G)(`Unchanged: ${diff.unchanged}`)} ${(0, terminal_format_1.R)(`Only in A: ${diff.onlyInA.length}`)} ${(0, terminal_format_1.Y)(`Only in B: ${diff.onlyInB.length}`)} ${(0, terminal_format_1.Y)(`Changed: ${diff.changed.length}`)}`);
1237
1230
  for (const d of diff.onlyInA.slice(0, 3)) {
1238
- console.log(` ${R("-")} @${d.index} ${d.function} ${D(d.hashA)}`);
1231
+ console.log(` ${(0, terminal_format_1.R)("-")} @${d.index} ${d.function} ${(0, terminal_format_1.D)(d.hashA)}`);
1239
1232
  }
1240
1233
  for (const d of diff.onlyInB.slice(0, 3)) {
1241
- console.log(` ${G("+")} @${d.index} ${d.function} ${D(d.hashB)}`);
1234
+ console.log(` ${(0, terminal_format_1.G)("+")} @${d.index} ${d.function} ${(0, terminal_format_1.D)(d.hashB)}`);
1242
1235
  }
1243
1236
  for (const d of diff.changed.slice(0, 3)) {
1244
- console.log(` ${Y("~")} @${d.index} ${d.function} ${D(d.hashA + " → " + d.hashB)}`);
1237
+ console.log(` ${(0, terminal_format_1.Y)("~")} @${d.index} ${d.function} ${(0, terminal_format_1.D)(d.hashA + " → " + d.hashB)}`);
1245
1238
  }
1246
1239
  }
1247
1240
  return;
@@ -1250,11 +1243,11 @@ async function main() {
1250
1243
  const op = process.argv[3];
1251
1244
  const st = process.argv[4];
1252
1245
  if (!op || !st) {
1253
- console.error(`${R("Usage:")} ts-node src/semantic-trace.ts --query-all <producer|consumer> <state>`);
1246
+ console.error(`${(0, terminal_format_1.R)("Usage:")} ts-node src/semantic-trace.ts --query-all <producer|consumer> <state>`);
1254
1247
  process.exit(1);
1255
1248
  }
1256
1249
  if (op !== "producer" && op !== "consumer") {
1257
- console.error(`${R("Operation must be 'producer' or 'consumer'.")}`);
1250
+ console.error(`${(0, terminal_format_1.R)("Operation must be 'producer' or 'consumer'.")}`);
1258
1251
  process.exit(1);
1259
1252
  }
1260
1253
  console.log(formatCrossSessionQuery(op, st));
@@ -1273,7 +1266,7 @@ async function main() {
1273
1266
  const snapB = process.argv[4];
1274
1267
  if (!snapA || !snapB) {
1275
1268
  console.log(formatSnapshotList());
1276
- console.log(`\n${D("Usage:")} ts-node src/semantic-trace.ts --diff <snapshotIdA> <snapshotIdB>`);
1269
+ console.log(`\n${(0, terminal_format_1.D)("Usage:")} ts-node src/semantic-trace.ts --diff <snapshotIdA> <snapshotIdB>`);
1277
1270
  return;
1278
1271
  }
1279
1272
  console.log(formatSnapshotDiff(snapA, snapB));
@@ -1282,14 +1275,14 @@ async function main() {
1282
1275
  if (arg === "--validate") {
1283
1276
  const sessionId = process.argv[3];
1284
1277
  if (!sessionId) {
1285
- console.error(`${R("Usage:")} ts-node src/semantic-trace.ts --validate <sessionId>`);
1286
- console.error(`\n${D("Validates a session's IR snapshot and replays its Semantic Ledger.")}`);
1278
+ console.error(`${(0, terminal_format_1.R)("Usage:")} ts-node src/semantic-trace.ts --validate <sessionId>`);
1279
+ console.error(`\n${(0, terminal_format_1.D)("Validates a session's IR snapshot and replays its Semantic Ledger.")}`);
1287
1280
  process.exit(1);
1288
1281
  }
1289
1282
  const sessionsForValidate = (0, failure_corpus_1.getAllSessions)();
1290
1283
  const session = sessionsForValidate.find(s => s.sessionId === sessionId || s.sessionId.startsWith(sessionId));
1291
1284
  if (!session) {
1292
- console.error(`${R("Session not found:")} ${sessionId}`);
1285
+ console.error(`${(0, terminal_format_1.R)("Session not found:")} ${sessionId}`);
1293
1286
  process.exit(1);
1294
1287
  }
1295
1288
  console.log(formatSessionValidation(session));
@@ -1299,14 +1292,14 @@ async function main() {
1299
1292
  if (arg === "--ledger") {
1300
1293
  const sessionId = process.argv[3];
1301
1294
  if (!sessionId) {
1302
- console.error(`${R("Usage:")} ts-node src/semantic-trace.ts --ledger <sessionId>`);
1303
- console.error(`\n${D("Replays the Semantic Ledger: rebuildState, invariants, ruleHash comparison.")}`);
1295
+ console.error(`${(0, terminal_format_1.R)("Usage:")} ts-node src/semantic-trace.ts --ledger <sessionId>`);
1296
+ console.error(`\n${(0, terminal_format_1.D)("Replays the Semantic Ledger: rebuildState, invariants, ruleHash comparison.")}`);
1304
1297
  process.exit(1);
1305
1298
  }
1306
1299
  const sessionsForLedger = (0, failure_corpus_1.getAllSessions)();
1307
1300
  const session = sessionsForLedger.find(s => s.sessionId === sessionId || s.sessionId.startsWith(sessionId));
1308
1301
  if (!session) {
1309
- console.error(`${R("Session not found:")} ${sessionId}`);
1302
+ console.error(`${(0, terminal_format_1.R)("Session not found:")} ${sessionId}`);
1310
1303
  process.exit(1);
1311
1304
  }
1312
1305
  console.log(formatLedgerReplayValidation(session));
@@ -1317,12 +1310,12 @@ async function main() {
1317
1310
  const sessionId = process.argv[3];
1318
1311
  if (!sessionId) {
1319
1312
  console.log(formatSessionSummary(sessions));
1320
- console.log(`\n${D("Usage:")} ts-node src/semantic-trace.ts --states <sessionId>`);
1313
+ console.log(`\n${(0, terminal_format_1.D)("Usage:")} ts-node src/semantic-trace.ts --states <sessionId>`);
1321
1314
  return;
1322
1315
  }
1323
1316
  const session = sessions.find(s => s.sessionId === sessionId || s.sessionId.startsWith(sessionId));
1324
1317
  if (!session) {
1325
- console.error(`${R("Session not found:")} ${sessionId}`);
1318
+ console.error(`${(0, terminal_format_1.R)("Session not found:")} ${sessionId}`);
1326
1319
  process.exit(1);
1327
1320
  }
1328
1321
  console.log(formatStateTransitions(session));
@@ -1331,19 +1324,19 @@ async function main() {
1331
1324
  if (arg === "replay") {
1332
1325
  const sessionId = process.argv[3];
1333
1326
  if (!sessionId) {
1334
- console.error(`${R("Usage:")} ts-node src/semantic-trace.ts replay <sessionId>`);
1335
- console.error(`\n${D("Available sessions:")}`);
1327
+ console.error(`${(0, terminal_format_1.R)("Usage:")} ts-node src/semantic-trace.ts replay <sessionId>`);
1328
+ console.error(`\n${(0, terminal_format_1.D)("Available sessions:")}`);
1336
1329
  for (const s of sessions) {
1337
- console.error(` ${D(s.sessionId)} — ${s.intent}`);
1330
+ console.error(` ${(0, terminal_format_1.D)(s.sessionId)} — ${s.intent}`);
1338
1331
  }
1339
1332
  process.exit(1);
1340
1333
  }
1341
1334
  const session = sessions.find(s => s.sessionId === sessionId || s.sessionId.startsWith(sessionId));
1342
1335
  if (!session) {
1343
- console.error(`${R("Session not found:")} ${sessionId}`);
1344
- console.error(`\n${D("Available sessions:")}`);
1336
+ console.error(`${(0, terminal_format_1.R)("Session not found:")} ${sessionId}`);
1337
+ console.error(`\n${(0, terminal_format_1.D)("Available sessions:")}`);
1345
1338
  for (const s of sessions) {
1346
- console.error(` ${D(s.sessionId)} — ${s.intent}`);
1339
+ console.error(` ${(0, terminal_format_1.D)(s.sessionId)} — ${s.intent}`);
1347
1340
  }
1348
1341
  process.exit(1);
1349
1342
  }
@@ -1355,108 +1348,108 @@ async function main() {
1355
1348
  const operation = process.argv[4];
1356
1349
  const operand = process.argv[5];
1357
1350
  if (!sessionId || !operation) {
1358
- console.error(`${R("Usage:")} ts-node src/semantic-trace.ts --query <sessionId> <operation> [state|index]`);
1359
- console.error(`\n${B("Operations:")}`);
1360
- console.error(` ${D("producer <state>")} — find transitions that produce a state`);
1361
- console.error(` ${D("consumer <state>")} — find transitions that consume a state`);
1362
- console.error(` ${D("violations")} — list all invalid transitions`);
1363
- console.error(` ${D("transition <index>")} — find a transition by action index`);
1364
- console.error(` ${D("all-states")} — list all unique states in the ledger`);
1351
+ console.error(`${(0, terminal_format_1.R)("Usage:")} ts-node src/semantic-trace.ts --query <sessionId> <operation> [state|index]`);
1352
+ console.error(`\n${(0, terminal_format_1.B)("Operations:")}`);
1353
+ console.error(` ${(0, terminal_format_1.D)("producer <state>")} — find transitions that produce a state`);
1354
+ console.error(` ${(0, terminal_format_1.D)("consumer <state>")} — find transitions that consume a state`);
1355
+ console.error(` ${(0, terminal_format_1.D)("violations")} — list all invalid transitions`);
1356
+ console.error(` ${(0, terminal_format_1.D)("transition <index>")} — find a transition by action index`);
1357
+ console.error(` ${(0, terminal_format_1.D)("all-states")} — list all unique states in the ledger`);
1365
1358
  process.exit(1);
1366
1359
  }
1367
1360
  const sessionsForQuery = (0, failure_corpus_1.getAllSessions)();
1368
1361
  const session = sessionsForQuery.find(s => s.sessionId === sessionId || s.sessionId.startsWith(sessionId));
1369
1362
  if (!session) {
1370
- console.error(`${R("Session not found:")} ${sessionId}`);
1363
+ console.error(`${(0, terminal_format_1.R)("Session not found:")} ${sessionId}`);
1371
1364
  process.exit(1);
1372
1365
  }
1373
1366
  // Collect all transitions from all attempts
1374
1367
  const allTransitions = session.attempts.flatMap(a => a.transitions || []);
1375
1368
  if (allTransitions.length === 0) {
1376
- console.log(`${D("No ledger data in this session.")}`);
1369
+ console.log(`${(0, terminal_format_1.D)("No ledger data in this session.")}`);
1377
1370
  return;
1378
1371
  }
1379
- console.log(`${C_("Ledger Query")} — ${session.sessionId}`);
1380
- console.log(`${D("═".repeat(50))}`);
1381
- console.log(`${D(`Ledger size: ${allTransitions.length} transitions`)}`);
1372
+ console.log(`${(0, terminal_format_1.C_)("Ledger Query")} — ${session.sessionId}`);
1373
+ console.log(`${(0, terminal_format_1.D)("═".repeat(50))}`);
1374
+ console.log(`${(0, terminal_format_1.D)(`Ledger size: ${allTransitions.length} transitions`)}`);
1382
1375
  console.log("");
1383
1376
  if (operation === "producer" || operation === "prod") {
1384
1377
  if (!operand) {
1385
- console.error(`${R("Missing state name.")}`);
1378
+ console.error(`${(0, terminal_format_1.R)("Missing state name.")}`);
1386
1379
  process.exit(1);
1387
1380
  }
1388
1381
  const results = (0, ssg_validator_1.findProducer)(operand, allTransitions);
1389
1382
  if (results.length === 0) {
1390
- console.log(` ${D(`No producer found for "${operand}"`)}`);
1383
+ console.log(` ${(0, terminal_format_1.D)(`No producer found for "${operand}"`)}`);
1391
1384
  }
1392
1385
  else {
1393
- console.log(` ${B(`Producers of "${operand}":`)}`);
1386
+ console.log(` ${(0, terminal_format_1.B)(`Producers of "${operand}":`)}`);
1394
1387
  for (const r of results) {
1395
- console.log(` ${G("→")} ${r.transition.function}() @index=${r.index} [${D(r.namespace)}]`);
1388
+ console.log(` ${(0, terminal_format_1.G)("→")} ${r.transition.function}() @index=${r.index} [${(0, terminal_format_1.D)(r.namespace)}]`);
1396
1389
  }
1397
1390
  }
1398
1391
  }
1399
1392
  else if (operation === "consumer" || operation === "cons") {
1400
1393
  if (!operand) {
1401
- console.error(`${R("Missing state name.")}`);
1394
+ console.error(`${(0, terminal_format_1.R)("Missing state name.")}`);
1402
1395
  process.exit(1);
1403
1396
  }
1404
1397
  const results = (0, ssg_validator_1.findConsumer)(operand, allTransitions);
1405
1398
  if (results.length === 0) {
1406
- console.log(` ${D(`No consumer found for "${operand}"`)}`);
1399
+ console.log(` ${(0, terminal_format_1.D)(`No consumer found for "${operand}"`)}`);
1407
1400
  }
1408
1401
  else {
1409
- console.log(` ${B(`Consumers of "${operand}":`)}`);
1402
+ console.log(` ${(0, terminal_format_1.B)(`Consumers of "${operand}":`)}`);
1410
1403
  for (const r of results) {
1411
- console.log(` ${Y("←")} ${r.transition.function}() @index=${r.index} [${D(r.namespace)}]`);
1404
+ console.log(` ${(0, terminal_format_1.Y)("←")} ${r.transition.function}() @index=${r.index} [${(0, terminal_format_1.D)(r.namespace)}]`);
1412
1405
  }
1413
1406
  }
1414
1407
  }
1415
1408
  else if (operation === "violations" || operation === "viol") {
1416
1409
  const results = (0, ssg_validator_1.findViolations)(allTransitions);
1417
1410
  if (results.length === 0) {
1418
- console.log(` ${G("No violations — all transitions are valid.")}`);
1411
+ console.log(` ${(0, terminal_format_1.G)("No violations — all transitions are valid.")}`);
1419
1412
  }
1420
1413
  else {
1421
- console.log(` ${R(`${results.length} violation(s):`)}`);
1414
+ console.log(` ${(0, terminal_format_1.R)(`${results.length} violation(s):`)}`);
1422
1415
  for (const r of results) {
1423
- console.log(` ${R("✖")} ${r.transition.function}() @index=${r.index} [${D(r.namespace)}]`);
1416
+ console.log(` ${(0, terminal_format_1.R)("✖")} ${r.transition.function}() @index=${r.index} [${(0, terminal_format_1.D)(r.namespace)}]`);
1424
1417
  }
1425
1418
  }
1426
1419
  }
1427
1420
  else if (operation === "transition" || operation === "t") {
1428
1421
  if (!operand) {
1429
- console.error(`${R("Missing action index.")}`);
1422
+ console.error(`${(0, terminal_format_1.R)("Missing action index.")}`);
1430
1423
  process.exit(1);
1431
1424
  }
1432
1425
  const idx = parseInt(operand, 10);
1433
1426
  if (isNaN(idx)) {
1434
- console.error(`${R("Invalid index.")}`);
1427
+ console.error(`${(0, terminal_format_1.R)("Invalid index.")}`);
1435
1428
  process.exit(1);
1436
1429
  }
1437
1430
  const result = (0, ssg_validator_1.findTransition)(idx, allTransitions);
1438
1431
  if (!result) {
1439
- console.log(` ${D(`No transition at index ${idx}`)}`);
1432
+ console.log(` ${(0, terminal_format_1.D)(`No transition at index ${idx}`)}`);
1440
1433
  }
1441
1434
  else {
1442
1435
  const t = result.transition;
1443
- console.log(` ${B(`Transition @${idx}:`)}`);
1444
- console.log(` function: ${C_(t.function)}`);
1445
- console.log(` namespace: ${D(t.namespace)}`);
1446
- console.log(` valid: ${t.valid ? G("yes") : R("no")}`);
1447
- console.log(` acquired: ${t.acquired.length ? G("+" + t.acquired.join(",+")) : D("(none)")}`);
1448
- console.log(` invalidated: ${t.invalidated.length ? R("-" + t.invalidated.join(",-")) : D("(none)")}`);
1436
+ console.log(` ${(0, terminal_format_1.B)(`Transition @${idx}:`)}`);
1437
+ console.log(` function: ${(0, terminal_format_1.C_)(t.function)}`);
1438
+ console.log(` namespace: ${(0, terminal_format_1.D)(t.namespace)}`);
1439
+ console.log(` valid: ${t.valid ? (0, terminal_format_1.G)("yes") : (0, terminal_format_1.R)("no")}`);
1440
+ console.log(` acquired: ${t.acquired.length ? (0, terminal_format_1.G)("+" + t.acquired.join(",+")) : (0, terminal_format_1.D)("(none)")}`);
1441
+ console.log(` invalidated: ${t.invalidated.length ? (0, terminal_format_1.R)("-" + t.invalidated.join(",-")) : (0, terminal_format_1.D)("(none)")}`);
1449
1442
  if (t.ruleHash)
1450
- console.log(` ruleHash: ${D(t.ruleHash)}`);
1443
+ console.log(` ruleHash: ${(0, terminal_format_1.D)(t.ruleHash)}`);
1451
1444
  }
1452
1445
  }
1453
1446
  else if (operation === "all-states" || operation === "states") {
1454
1447
  const states = (0, ssg_validator_1.listAllStates)(allTransitions);
1455
1448
  if (states.length === 0) {
1456
- console.log(` ${D("No states in ledger.")}`);
1449
+ console.log(` ${(0, terminal_format_1.D)("No states in ledger.")}`);
1457
1450
  }
1458
1451
  else {
1459
- console.log(` ${B(`All states (${states.length}):`)}`);
1452
+ console.log(` ${(0, terminal_format_1.B)(`All states (${states.length}):`)}`);
1460
1453
  // Group by namespace
1461
1454
  const byNs = new Map();
1462
1455
  for (const s of states) {
@@ -1465,13 +1458,13 @@ async function main() {
1465
1458
  byNs.get(s.namespace).push(s.state);
1466
1459
  }
1467
1460
  for (const [ns, ss] of [...byNs.entries()].sort()) {
1468
- console.log(` ${C_(ns)}: ${ss.join(", ")}`);
1461
+ console.log(` ${(0, terminal_format_1.C_)(ns)}: ${ss.join(", ")}`);
1469
1462
  }
1470
1463
  }
1471
1464
  }
1472
1465
  else {
1473
- console.error(`${R("Unknown operation:")} ${operation}`);
1474
- console.error(`${D("Valid: producer, consumer, violations, transition, all-states")}`);
1466
+ console.error(`${(0, terminal_format_1.R)("Unknown operation:")} ${operation}`);
1467
+ console.error(`${(0, terminal_format_1.D)("Valid: producer, consumer, violations, transition, all-states")}`);
1475
1468
  process.exit(1);
1476
1469
  }
1477
1470
  return;
@@ -1480,10 +1473,10 @@ async function main() {
1480
1473
  // View a specific session
1481
1474
  const session = sessions.find(s => s.sessionId === arg || s.sessionId.startsWith(arg));
1482
1475
  if (!session) {
1483
- console.error(`${R("Session not found:")} ${arg}`);
1484
- console.error(`\n${D("Available sessions:")}`);
1476
+ console.error(`${(0, terminal_format_1.R)("Session not found:")} ${arg}`);
1477
+ console.error(`\n${(0, terminal_format_1.D)("Available sessions:")}`);
1485
1478
  for (const s of sessions) {
1486
- console.error(` ${D(s.sessionId)} — ${s.intent}`);
1479
+ console.error(` ${(0, terminal_format_1.D)(s.sessionId)} — ${s.intent}`);
1487
1480
  }
1488
1481
  process.exit(1);
1489
1482
  }