oh-my-opencode 5.1.44 → 5.1.46

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 (626) hide show
  1. package/.agents/command/publish.md +9 -9
  2. package/.agents/skills/publish/SKILL.md +9 -9
  3. package/.opencode/command/publish.md +9 -9
  4. package/README.de.md +0 -5
  5. package/README.es.md +0 -5
  6. package/README.fr.md +0 -5
  7. package/README.it.md +0 -5
  8. package/README.ja.md +0 -5
  9. package/README.ko.md +0 -5
  10. package/README.md +4 -5
  11. package/README.pt-br.md +0 -5
  12. package/README.ru.md +0 -6
  13. package/README.zh-cn.md +0 -5
  14. package/dist/cli/index.js +865 -413
  15. package/dist/cli/service-auth/keystore.d.ts +4 -2
  16. package/dist/cli-node/index.js +865 -413
  17. package/dist/features/builtin-commands/templates/hyperplan.d.ts +1 -1
  18. package/dist/features/builtin-commands/templates/refactor-sections/team-mode-addendum.d.ts +1 -1
  19. package/dist/features/builtin-commands/templates/remove-ai-slops.d.ts +1 -1
  20. package/dist/hooks/sisyphus-junior-notepad/constants.d.ts +1 -1
  21. package/dist/index.js +5270 -2308
  22. package/dist/oh-my-opencode.schema.json +2 -2
  23. package/dist/plugin/command-execute-before.d.ts +3 -0
  24. package/dist/plugin/skill-context.d.ts +2 -0
  25. package/dist/plugin/skill-security-notice.d.ts +3 -0
  26. package/dist/plugin-config/omo-config-chain.d.ts +1 -0
  27. package/dist/skills/ast-grep/AGENTS.md +1 -1
  28. package/dist/skills/browser/SKILL.md +21 -22
  29. package/dist/skills/browser/references/commands.md +2 -9
  30. package/dist/skills/browser/references/install.md +1 -2
  31. package/dist/skills/browser/runtime/omowright/manifest.json +1 -1
  32. package/dist/skills/browser/scripts/browser-doctor.mjs +2 -2
  33. package/dist/skills/browser/scripts/browser-engine-guard.mjs +63 -487
  34. package/dist/skills/browser/scripts/browser-install.mjs +1 -1
  35. package/dist/skills/browser/scripts/omowright.mjs +1 -10
  36. package/dist/skills/frontend/ATTRIBUTION.md +2 -2
  37. package/dist/skills/frontend/SKILL.md +79 -118
  38. package/dist/skills/frontend/references/design/README.md +75 -224
  39. package/dist/skills/frontend/references/design/stylegallery.md +32 -27
  40. package/dist/skills/frontend/references/perfection/README.md +2 -2
  41. package/dist/skills/frontend/scripts/perfection/check-accent-stripes.ts +8 -24
  42. package/dist/skills/frontend/scripts/perfection/check-draft-guard.test.ts +101 -0
  43. package/dist/skills/frontend/scripts/perfection/check-draft-guard.ts +40 -0
  44. package/dist/skills/frontend/scripts/perfection/collect-files.test.ts +50 -0
  45. package/dist/skills/frontend/scripts/perfection/collect-files.ts +53 -0
  46. package/dist/skills/frontend/scripts/perfection/draft-guard/findings.ts +16 -0
  47. package/dist/skills/frontend/scripts/perfection/draft-guard/lint.ts +38 -0
  48. package/dist/skills/frontend/scripts/perfection/draft-guard/rules.ts +69 -0
  49. package/dist/skills/frontend/scripts/perfection/draft-guard/text-nodes.ts +121 -0
  50. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/attr-lookalikes.tsx +10 -0
  51. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/bound-values.tsx +12 -0
  52. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/const-generics.tsx +3 -0
  53. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/generics.tsx +7 -0
  54. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/measured-stats.html +6 -0
  55. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/plain-copy.html +9 -0
  56. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/state-copy.html +11 -0
  57. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/attribute-edges.html +7 -0
  58. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/components.tsx +16 -0
  59. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/decorative-badge.vue +7 -0
  60. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/emoji-icons.tsx +9 -0
  61. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/jsx-edges.tsx +1 -0
  62. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/promo-copy.html +6 -0
  63. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/promo-copy.tsx +8 -0
  64. package/dist/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/vanity-stats.html +5 -0
  65. package/dist/skills/programming/SKILL.md +10 -7
  66. package/dist/skills/programming/references/typescript/README.md +10 -7
  67. package/dist/skills/programming/references/typescript/bootstrap.md +9 -23
  68. package/dist/skills/programming/references/typescript/oxc-lint.md +130 -0
  69. package/dist/skills/programming/references/typescript/tsconfig-strict.md +6 -62
  70. package/dist/skills/programming/scripts/typescript/check-no-excuse-rules.ts +12 -12
  71. package/dist/skills/programming/scripts/typescript/new-project.test.ts +162 -0
  72. package/dist/skills/programming/scripts/typescript/new-project.ts +20 -81
  73. package/dist/skills/programming/scripts/typescript/oxc/.oxfmtrc.json +9 -0
  74. package/dist/skills/programming/scripts/typescript/oxc/.oxlintrc.json +46 -0
  75. package/dist/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/LICENSE +21 -0
  76. package/dist/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/index.js +10 -0
  77. package/dist/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/no-em-dash-copy.js +28 -0
  78. package/dist/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/require-suppression-reason.js +62 -0
  79. package/dist/skills/programming/scripts/typescript/oxc/tsconfig.json +29 -0
  80. package/dist/skills/refactor/SKILL.md +13 -13
  81. package/dist/skills/ultimate-browsing/engine/AGENTS.md +1 -1
  82. package/dist/skills/ulw-execute/SKILL.md +1 -1
  83. package/dist/skills/ulw-research/AGENTS.md +21 -3
  84. package/dist/skills/ulw-research/SKILL.md +37 -12
  85. package/dist/skills/ulw-research/references/deliverable-phase.md +77 -16
  86. package/dist/skills/ulw-research/references/fact-ledger-grammar.md +134 -0
  87. package/dist/skills/ulw-research/references/fact-ledger.md +95 -0
  88. package/dist/skills/ulw-research/references/fidelity-claim-kinds.md +19 -0
  89. package/dist/skills/ulw-research/references/report-gates.md +68 -3
  90. package/dist/skills/ulw-research/references/report-visualization.md +2 -0
  91. package/dist/skills/ulw-research/references/unit-rules.md +157 -0
  92. package/dist/skills/ulw-research/scripts/claim-kinds.mjs +116 -0
  93. package/dist/skills/ulw-research/scripts/claim-kinds.test.ts +193 -0
  94. package/dist/skills/ulw-research/scripts/claims-index.mjs +125 -0
  95. package/dist/skills/ulw-research/scripts/claims-index.test.ts +149 -0
  96. package/dist/skills/ulw-research/scripts/cli-support.mjs +19 -5
  97. package/dist/skills/ulw-research/scripts/cli-support.test.ts +13 -2
  98. package/dist/skills/ulw-research/scripts/contracts.mjs +89 -3
  99. package/dist/skills/ulw-research/scripts/contracts.test.ts +100 -12
  100. package/dist/skills/ulw-research/scripts/copy-returns.test.ts +183 -0
  101. package/dist/skills/ulw-research/scripts/delivery-barrier.test.ts +245 -0
  102. package/dist/skills/ulw-research/scripts/fact-commands-meaning.mjs +191 -0
  103. package/dist/skills/ulw-research/scripts/fact-commands-verify.mjs +164 -0
  104. package/dist/skills/ulw-research/scripts/fact-commands.mjs +239 -0
  105. package/dist/skills/ulw-research/scripts/fact-derive.mjs +66 -0
  106. package/dist/skills/ulw-research/scripts/fact-derive.test.ts +375 -0
  107. package/dist/skills/ulw-research/scripts/fact-expr.mjs +108 -0
  108. package/dist/skills/ulw-research/scripts/fact-fill.mjs +194 -0
  109. package/dist/skills/ulw-research/scripts/fact-fill.test.ts +221 -0
  110. package/dist/skills/ulw-research/scripts/fact-ledger-grammar.test.ts +197 -0
  111. package/dist/skills/ulw-research/scripts/fact-ledger-kinds.mjs +250 -0
  112. package/dist/skills/ulw-research/scripts/fact-ledger-kinds.test.ts +156 -0
  113. package/dist/skills/ulw-research/scripts/fact-ledger-legacy.test.ts +160 -0
  114. package/dist/skills/ulw-research/scripts/fact-ledger-schema.mjs +221 -0
  115. package/dist/skills/ulw-research/scripts/fact-ledger-schema.test.ts +43 -0
  116. package/dist/skills/ulw-research/scripts/fact-ledger.mjs +123 -0
  117. package/dist/skills/ulw-research/scripts/fact-ledger.test.ts +254 -0
  118. package/dist/skills/ulw-research/scripts/fact-locate.mjs +231 -0
  119. package/dist/skills/ulw-research/scripts/fact-locate.test.ts +118 -0
  120. package/dist/skills/ulw-research/scripts/fact-pairs.mjs +187 -0
  121. package/dist/skills/ulw-research/scripts/fact-pairs.test.ts +167 -0
  122. package/dist/skills/ulw-research/scripts/fact-recompute.mjs +89 -0
  123. package/dist/skills/ulw-research/scripts/fact-unit-dimensions.test.ts +409 -0
  124. package/dist/skills/ulw-research/scripts/fact-unit-rules.test.ts +388 -0
  125. package/dist/skills/ulw-research/scripts/fidelity-binding.mjs +130 -0
  126. package/dist/skills/ulw-research/scripts/fidelity-binding.test.ts +81 -0
  127. package/dist/skills/ulw-research/scripts/fidelity-brief.mjs +150 -0
  128. package/dist/skills/ulw-research/scripts/fidelity-brief.test.ts +179 -0
  129. package/dist/skills/ulw-research/scripts/fidelity-claims.mjs +89 -0
  130. package/dist/skills/ulw-research/scripts/fidelity-lexicon.mjs +145 -0
  131. package/dist/skills/ulw-research/scripts/fidelity-lexicon.test.ts +117 -0
  132. package/dist/skills/ulw-research/scripts/fidelity-records.mjs +163 -0
  133. package/dist/skills/ulw-research/scripts/fidelity-state.mjs +64 -0
  134. package/dist/skills/ulw-research/scripts/fidelity-state.test.ts +46 -0
  135. package/dist/skills/ulw-research/scripts/fidelity-trace.mjs +85 -0
  136. package/dist/skills/ulw-research/scripts/fidelity-trace.test.ts +58 -0
  137. package/dist/skills/ulw-research/scripts/fidelity-values.mjs +229 -0
  138. package/dist/skills/ulw-research/scripts/fidelity-values.test.ts +270 -0
  139. package/dist/skills/ulw-research/scripts/gates-context.test.ts +64 -0
  140. package/dist/skills/ulw-research/scripts/gates-fidelity.mjs +113 -0
  141. package/dist/skills/ulw-research/scripts/gates-fidelity.test.ts +73 -0
  142. package/dist/skills/ulw-research/scripts/gates-static.mjs +29 -9
  143. package/dist/skills/ulw-research/scripts/gates-structure.mjs +1 -1
  144. package/dist/skills/ulw-research/scripts/gates-text.mjs +1 -27
  145. package/dist/skills/ulw-research/scripts/html-lite.mjs +2 -2
  146. package/dist/skills/ulw-research/scripts/html-markup.mjs +182 -0
  147. package/dist/skills/ulw-research/scripts/lexicon.mjs +47 -0
  148. package/dist/skills/ulw-research/scripts/lexicon.test.ts +57 -0
  149. package/dist/skills/ulw-research/scripts/md-lite.mjs +193 -0
  150. package/dist/skills/ulw-research/scripts/md-lite.test.ts +271 -0
  151. package/dist/skills/ulw-research/scripts/meaning-check.mjs +196 -0
  152. package/dist/skills/ulw-research/scripts/meaning-check.test.ts +228 -0
  153. package/dist/skills/ulw-research/scripts/numerals.mjs +226 -0
  154. package/dist/skills/ulw-research/scripts/numerals.test.ts +120 -0
  155. package/dist/skills/ulw-research/scripts/outcome.mjs +8 -8
  156. package/dist/skills/ulw-research/scripts/outcome.test.ts +29 -0
  157. package/dist/skills/ulw-research/scripts/particles-ko.mjs +108 -0
  158. package/dist/skills/ulw-research/scripts/particles-ko.test.ts +86 -0
  159. package/dist/skills/ulw-research/scripts/placeholder.mjs +184 -0
  160. package/dist/skills/ulw-research/scripts/placeholder.test.ts +77 -0
  161. package/dist/skills/ulw-research/scripts/polish-apply.mjs +115 -0
  162. package/dist/skills/ulw-research/scripts/polish-apply.test.ts +363 -0
  163. package/dist/skills/ulw-research/scripts/polish-diff.mjs +31 -0
  164. package/dist/skills/ulw-research/scripts/polish-diff.test.ts +168 -0
  165. package/dist/skills/ulw-research/scripts/polish-markup.test.ts +187 -0
  166. package/dist/skills/ulw-research/scripts/polish-project.mjs +125 -0
  167. package/dist/skills/ulw-research/scripts/polish-rules.mjs +170 -0
  168. package/dist/skills/ulw-research/scripts/rational.mjs +139 -0
  169. package/dist/skills/ulw-research/scripts/rational.test.ts +46 -0
  170. package/dist/skills/ulw-research/scripts/report-tools-commands.mjs +21 -10
  171. package/dist/skills/ulw-research/scripts/report-tools.mjs +15 -0
  172. package/dist/skills/ulw-research/scripts/report-tools.test.ts +458 -2
  173. package/dist/skills/ulw-research/scripts/sentence-split.mjs +77 -0
  174. package/dist/skills/ulw-research/scripts/sentence-split.test.ts +109 -0
  175. package/dist/skills/ulw-research/scripts/source-commands.mjs +140 -0
  176. package/dist/skills/ulw-research/scripts/source-snapshot.mjs +176 -0
  177. package/dist/skills/ulw-research/scripts/source-snapshot.test.ts +113 -0
  178. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/assets/share.csv +3 -0
  179. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/claim-graph.md +13 -0
  180. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/gen-legacy-dev.mjs +89 -0
  181. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/ledger-basic.json +223 -0
  182. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/ledger-legacy-dev.json +859 -0
  183. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/ledger-verify.json +420 -0
  184. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/report-bad.html +19 -0
  185. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/report-good.html +39 -0
  186. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4/acronyms.json +3 -0
  187. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4/meta.json +9 -0
  188. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4/sentences.jsonl +7 -0
  189. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4/text.txt +7 -0
  190. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4.html +19 -0
  191. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S5/acronyms.json +1 -0
  192. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S5/meta.json +9 -0
  193. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S5/sentences.jsonl +1 -0
  194. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S5/text.txt +1 -0
  195. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S9.txt +1 -0
  196. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity-brief-locked.md +17 -0
  197. package/dist/skills/ulw-research/scripts/tests/fixtures/fidelity-brief-pending.md +17 -0
  198. package/dist/skills/ulw-research/scripts/text-normalize.mjs +82 -0
  199. package/dist/skills/ulw-research/scripts/text-normalize.test.ts +73 -0
  200. package/dist/skills/ulw-research/scripts/text-similarity.mjs +28 -0
  201. package/dist/skills/ulw-research/scripts/text-similarity.test.ts +38 -0
  202. package/dist/skills/ulw-research/scripts/unit-algebra.mjs +101 -0
  203. package/dist/skills/ulw-research/scripts/unit-errors.mjs +23 -0
  204. package/dist/skills/ulw-research/scripts/unit-metadata.mjs +31 -0
  205. package/dist/skills/ulw-research/scripts/unit-pairs.mjs +72 -0
  206. package/dist/skills/ulw-research/scripts/unit-precision.mjs +44 -0
  207. package/dist/skills/ulw-research/scripts/unit-rules-shapes.mjs +64 -0
  208. package/dist/skills/ulw-research/scripts/unit-rules.mjs +173 -0
  209. package/dist/skills/ulw-research/scripts/units.mjs +105 -0
  210. package/dist/skills/ulw-research/scripts/units.test.ts +83 -0
  211. package/dist/skills/visual-qa/SKILL.md +70 -63
  212. package/dist/skills/visual-qa/scripts/skill-doc-fields.test.ts +34 -0
  213. package/dist/testing/module-mock-lifecycle.d.ts +1 -1
  214. package/dist/tools/delegate-task/constants.d.ts +1 -1
  215. package/dist/tools/session-manager/constants.d.ts +1 -1
  216. package/dist/tools/session-manager/file-storage.d.ts +9 -2
  217. package/dist/tools/session-manager/sdk-storage.d.ts +19 -1
  218. package/dist/tools/session-manager/session-formatter.d.ts +3 -3
  219. package/dist/tools/session-manager/storage.d.ts +8 -2
  220. package/dist/tools/skill/mcp-capability-formatter.d.ts +1 -1
  221. package/dist/tools/skill/native-skills.d.ts +2 -2
  222. package/dist/tools/skill/skill-mcp-authority.d.ts +3 -0
  223. package/dist/tui.js +537 -104
  224. package/docs/reference/web-terminal-visual-qa.md +8 -0
  225. package/package.json +24 -16
  226. package/packages/lsp-core/src/lsp/client-wrapper.ts +4 -4
  227. package/packages/lsp-core/src/mcp-protocol-pin.test.ts +29 -0
  228. package/packages/lsp-core/src/mcp.ts +5 -2
  229. package/packages/lsp-core/src/post-edit/not-installed.test.ts +2 -2
  230. package/packages/lsp-daemon/dist/cli.js +7 -7
  231. package/packages/lsp-daemon/dist/client.js +7 -7
  232. package/packages/lsp-daemon/dist/index.js +7 -7
  233. package/packages/lsp-daemon/package.json +3 -3
  234. package/packages/lsp-tools-mcp/dist/cli.js +7 -7
  235. package/packages/lsp-tools-mcp/dist/mcp.js +7 -7
  236. package/packages/lsp-tools-mcp/dist/tools.js +4 -4
  237. package/packages/lsp-tools-mcp/package.json +3 -3
  238. package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
  239. package/packages/omo-codex/plugin/components/bootstrap/dist/cli.js +77 -26
  240. package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
  241. package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
  242. package/packages/omo-codex/plugin/components/bootstrap/src/hook.ts +1 -1
  243. package/packages/omo-codex/plugin/components/comment-checker/biome.json +1 -21
  244. package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
  245. package/packages/omo-codex/plugin/components/comment-checker/package.json +4 -4
  246. package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
  247. package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
  248. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/biome.json +1 -21
  249. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
  250. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +4 -4
  251. package/packages/omo-codex/plugin/components/lsp/biome.json +1 -21
  252. package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +3 -3
  253. package/packages/omo-codex/plugin/components/lsp/dist/cli.js +4 -4
  254. package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
  255. package/packages/omo-codex/plugin/components/lsp/package.json +4 -4
  256. package/packages/omo-codex/plugin/components/lsp/scripts/build-runtime.mjs +0 -1
  257. package/packages/omo-codex/plugin/components/lsp/test/codex-hook-not-installed.test.ts +1 -1
  258. package/packages/omo-codex/plugin/components/rules/biome.json +1 -21
  259. package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
  260. package/packages/omo-codex/plugin/components/rules/package.json +4 -4
  261. package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
  262. package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
  263. package/packages/omo-codex/plugin/components/telemetry/biome.json +1 -21
  264. package/packages/omo-codex/plugin/components/telemetry/dist/cli.js +90 -1
  265. package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +91 -1
  266. package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
  267. package/packages/omo-codex/plugin/components/telemetry/package.json +4 -4
  268. package/packages/omo-codex/plugin/components/ultrawork/agents/lazycodex-gate-reviewer.toml +2 -2
  269. package/packages/omo-codex/plugin/components/ultrawork/biome.json +1 -21
  270. package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
  271. package/packages/omo-codex/plugin/components/ultrawork/package.json +4 -4
  272. package/packages/omo-codex/plugin/components/ulw-execute-continuation/biome.json +1 -21
  273. package/packages/omo-codex/plugin/components/ulw-execute-continuation/directive.md +1 -1
  274. package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +1 -1
  275. package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +4 -4
  276. package/packages/omo-codex/plugin/components/ulw-loop/biome.json +1 -21
  277. package/packages/omo-codex/plugin/components/ulw-loop/dist/checkpoint.js +1 -1
  278. package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +7 -7
  279. package/packages/omo-codex/plugin/components/ulw-loop/dist/codex-goal-instruction.js +5 -5
  280. package/packages/omo-codex/plugin/components/ulw-loop/dist/stop-resume-hook.js +1 -1
  281. package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +5 -5
  282. package/packages/omo-codex/plugin/components/ulw-loop/package.json +4 -4
  283. package/packages/omo-codex/plugin/components/ulw-loop/src/checkpoint.ts +1 -1
  284. package/packages/omo-codex/plugin/components/ulw-loop/src/codex-goal-instruction.ts +5 -5
  285. package/packages/omo-codex/plugin/components/ulw-loop/src/stop-resume-hook.ts +1 -1
  286. package/packages/omo-codex/plugin/components/ulw-loop/test/fixtures/commit-mutations.mjs +2 -0
  287. package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
  288. package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
  289. package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
  290. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
  291. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
  292. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
  293. package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
  294. package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +1 -1
  295. package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
  296. package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
  297. package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
  298. package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
  299. package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
  300. package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
  301. package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
  302. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
  303. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
  304. package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
  305. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
  306. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
  307. package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
  308. package/packages/omo-codex/plugin/package-lock.json +12 -12
  309. package/packages/omo-codex/plugin/package.json +1 -1
  310. package/packages/omo-codex/plugin/scripts/sync-skills.mjs +14 -9
  311. package/packages/omo-codex/plugin/skills/ast-grep/AGENTS.md +1 -1
  312. package/packages/omo-codex/plugin/skills/browser/SKILL.md +21 -22
  313. package/packages/omo-codex/plugin/skills/browser/references/commands.md +2 -9
  314. package/packages/omo-codex/plugin/skills/browser/references/install.md +1 -2
  315. package/packages/omo-codex/plugin/skills/browser/runtime/omowright/manifest.json +1 -1
  316. package/packages/omo-codex/plugin/skills/browser/scripts/browser-doctor.mjs +2 -2
  317. package/packages/omo-codex/plugin/skills/browser/scripts/browser-engine-guard.mjs +63 -487
  318. package/packages/omo-codex/plugin/skills/browser/scripts/browser-install.mjs +1 -1
  319. package/packages/omo-codex/plugin/skills/browser/scripts/omowright.mjs +1 -10
  320. package/packages/omo-codex/plugin/skills/frontend/ATTRIBUTION.md +2 -2
  321. package/packages/omo-codex/plugin/skills/frontend/SKILL.md +79 -118
  322. package/packages/omo-codex/plugin/skills/frontend/references/design/README.md +75 -224
  323. package/packages/omo-codex/plugin/skills/frontend/references/design/stylegallery.md +32 -27
  324. package/packages/omo-codex/plugin/skills/frontend/references/perfection/README.md +2 -2
  325. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/check-accent-stripes.ts +8 -24
  326. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/check-draft-guard.ts +40 -0
  327. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/collect-files.ts +53 -0
  328. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/draft-guard/findings.ts +16 -0
  329. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/draft-guard/lint.ts +38 -0
  330. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/draft-guard/rules.ts +69 -0
  331. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/draft-guard/text-nodes.ts +121 -0
  332. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/attr-lookalikes.tsx +10 -0
  333. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/bound-values.tsx +12 -0
  334. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/const-generics.tsx +3 -0
  335. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/generics.tsx +7 -0
  336. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/measured-stats.html +6 -0
  337. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/plain-copy.html +9 -0
  338. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/state-copy.html +11 -0
  339. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/attribute-edges.html +7 -0
  340. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/components.tsx +16 -0
  341. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/decorative-badge.vue +7 -0
  342. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/emoji-icons.tsx +9 -0
  343. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/jsx-edges.tsx +1 -0
  344. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/promo-copy.html +6 -0
  345. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/promo-copy.tsx +8 -0
  346. package/packages/omo-codex/plugin/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/vanity-stats.html +5 -0
  347. package/packages/omo-codex/plugin/skills/init-deep/SKILL.md +1 -1
  348. package/packages/omo-codex/plugin/skills/programming/SKILL.md +10 -7
  349. package/packages/omo-codex/plugin/skills/programming/references/typescript/README.md +10 -7
  350. package/packages/omo-codex/plugin/skills/programming/references/typescript/bootstrap.md +9 -23
  351. package/packages/omo-codex/plugin/skills/programming/references/typescript/oxc-lint.md +130 -0
  352. package/packages/omo-codex/plugin/skills/programming/references/typescript/tsconfig-strict.md +6 -62
  353. package/packages/omo-codex/plugin/skills/programming/scripts/typescript/check-no-excuse-rules.ts +12 -12
  354. package/packages/omo-codex/plugin/skills/programming/scripts/typescript/new-project.ts +20 -81
  355. package/packages/omo-codex/plugin/skills/programming/scripts/typescript/oxc/.oxfmtrc.json +9 -0
  356. package/packages/omo-codex/plugin/skills/programming/scripts/typescript/oxc/.oxlintrc.json +46 -0
  357. package/packages/omo-codex/plugin/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/LICENSE +21 -0
  358. package/packages/omo-codex/plugin/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/index.js +10 -0
  359. package/packages/omo-codex/plugin/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/no-em-dash-copy.js +28 -0
  360. package/packages/omo-codex/plugin/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/require-suppression-reason.js +62 -0
  361. package/packages/omo-codex/plugin/skills/programming/scripts/typescript/oxc/tsconfig.json +29 -0
  362. package/packages/omo-codex/plugin/skills/refactor/SKILL.md +14 -14
  363. package/packages/omo-codex/plugin/skills/remove-ai-slops/SKILL.md +1 -1
  364. package/packages/omo-codex/plugin/skills/review-work/SKILL.md +2 -2
  365. package/packages/omo-codex/plugin/skills/ultimate-browsing/engine/AGENTS.md +1 -1
  366. package/packages/omo-codex/plugin/skills/ulw-execute/SKILL.md +2 -2
  367. package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +1 -1
  368. package/packages/omo-codex/plugin/skills/ulw-research/AGENTS.md +21 -3
  369. package/packages/omo-codex/plugin/skills/ulw-research/SKILL.md +37 -12
  370. package/packages/omo-codex/plugin/skills/ulw-research/references/deliverable-phase.md +77 -16
  371. package/packages/omo-codex/plugin/skills/ulw-research/references/fact-ledger-grammar.md +134 -0
  372. package/packages/omo-codex/plugin/skills/ulw-research/references/fact-ledger.md +95 -0
  373. package/packages/omo-codex/plugin/skills/ulw-research/references/fidelity-claim-kinds.md +19 -0
  374. package/packages/omo-codex/plugin/skills/ulw-research/references/report-gates.md +68 -3
  375. package/packages/omo-codex/plugin/skills/ulw-research/references/report-visualization.md +2 -0
  376. package/packages/omo-codex/plugin/skills/ulw-research/references/unit-rules.md +157 -0
  377. package/packages/omo-codex/plugin/skills/ulw-research/scripts/claim-kinds.mjs +116 -0
  378. package/packages/omo-codex/plugin/skills/ulw-research/scripts/claims-index.mjs +125 -0
  379. package/packages/omo-codex/plugin/skills/ulw-research/scripts/cli-support.mjs +19 -5
  380. package/packages/omo-codex/plugin/skills/ulw-research/scripts/contracts.mjs +89 -3
  381. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-commands-meaning.mjs +191 -0
  382. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-commands-verify.mjs +164 -0
  383. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-commands.mjs +239 -0
  384. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-derive.mjs +66 -0
  385. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-expr.mjs +108 -0
  386. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-fill.mjs +194 -0
  387. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-ledger-kinds.mjs +250 -0
  388. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-ledger-schema.mjs +221 -0
  389. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-ledger.mjs +123 -0
  390. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-locate.mjs +231 -0
  391. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-pairs.mjs +187 -0
  392. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fact-recompute.mjs +89 -0
  393. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-binding.mjs +130 -0
  394. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-brief.mjs +150 -0
  395. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-claims.mjs +89 -0
  396. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-lexicon.mjs +145 -0
  397. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-records.mjs +163 -0
  398. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-state.mjs +64 -0
  399. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-trace.mjs +85 -0
  400. package/packages/omo-codex/plugin/skills/ulw-research/scripts/fidelity-values.mjs +229 -0
  401. package/packages/omo-codex/plugin/skills/ulw-research/scripts/gates-fidelity.mjs +113 -0
  402. package/packages/omo-codex/plugin/skills/ulw-research/scripts/gates-static.mjs +29 -9
  403. package/packages/omo-codex/plugin/skills/ulw-research/scripts/gates-structure.mjs +1 -1
  404. package/packages/omo-codex/plugin/skills/ulw-research/scripts/gates-text.mjs +1 -27
  405. package/packages/omo-codex/plugin/skills/ulw-research/scripts/html-lite.mjs +2 -2
  406. package/packages/omo-codex/plugin/skills/ulw-research/scripts/html-markup.mjs +182 -0
  407. package/packages/omo-codex/plugin/skills/ulw-research/scripts/lexicon.mjs +47 -0
  408. package/packages/omo-codex/plugin/skills/ulw-research/scripts/md-lite.mjs +193 -0
  409. package/packages/omo-codex/plugin/skills/ulw-research/scripts/meaning-check.mjs +196 -0
  410. package/packages/omo-codex/plugin/skills/ulw-research/scripts/numerals.mjs +226 -0
  411. package/packages/omo-codex/plugin/skills/ulw-research/scripts/outcome.mjs +8 -8
  412. package/packages/omo-codex/plugin/skills/ulw-research/scripts/particles-ko.mjs +108 -0
  413. package/packages/omo-codex/plugin/skills/ulw-research/scripts/placeholder.mjs +184 -0
  414. package/packages/omo-codex/plugin/skills/ulw-research/scripts/polish-apply.mjs +115 -0
  415. package/packages/omo-codex/plugin/skills/ulw-research/scripts/polish-diff.mjs +31 -0
  416. package/packages/omo-codex/plugin/skills/ulw-research/scripts/polish-project.mjs +125 -0
  417. package/packages/omo-codex/plugin/skills/ulw-research/scripts/polish-rules.mjs +170 -0
  418. package/packages/omo-codex/plugin/skills/ulw-research/scripts/rational.mjs +139 -0
  419. package/packages/omo-codex/plugin/skills/ulw-research/scripts/report-tools-commands.mjs +21 -10
  420. package/packages/omo-codex/plugin/skills/ulw-research/scripts/report-tools.mjs +15 -0
  421. package/packages/omo-codex/plugin/skills/ulw-research/scripts/sentence-split.mjs +77 -0
  422. package/packages/omo-codex/plugin/skills/ulw-research/scripts/source-commands.mjs +140 -0
  423. package/packages/omo-codex/plugin/skills/ulw-research/scripts/source-snapshot.mjs +176 -0
  424. package/packages/omo-codex/plugin/skills/ulw-research/scripts/text-normalize.mjs +82 -0
  425. package/packages/omo-codex/plugin/skills/ulw-research/scripts/text-similarity.mjs +28 -0
  426. package/packages/omo-codex/plugin/skills/ulw-research/scripts/unit-algebra.mjs +101 -0
  427. package/packages/omo-codex/plugin/skills/ulw-research/scripts/unit-errors.mjs +23 -0
  428. package/packages/omo-codex/plugin/skills/ulw-research/scripts/unit-metadata.mjs +31 -0
  429. package/packages/omo-codex/plugin/skills/ulw-research/scripts/unit-pairs.mjs +72 -0
  430. package/packages/omo-codex/plugin/skills/ulw-research/scripts/unit-precision.mjs +44 -0
  431. package/packages/omo-codex/plugin/skills/ulw-research/scripts/unit-rules-shapes.mjs +64 -0
  432. package/packages/omo-codex/plugin/skills/ulw-research/scripts/unit-rules.mjs +173 -0
  433. package/packages/omo-codex/plugin/skills/ulw-research/scripts/units.mjs +105 -0
  434. package/packages/omo-codex/plugin/skills/visual-qa/SKILL.md +71 -64
  435. package/packages/omo-codex/plugin/test/component-bundled-cli.test.mjs +4 -1
  436. package/packages/omo-codex/plugin/test/sync-skills-codex-compatibility.test.mjs +19 -0
  437. package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +12 -8
  438. package/packages/omo-codex/scripts/install-dist/install-local.mjs +169 -30
  439. package/packages/shared-skills/skills/ast-grep/AGENTS.md +1 -1
  440. package/packages/shared-skills/skills/browser/SKILL.md +21 -22
  441. package/packages/shared-skills/skills/browser/references/commands.md +2 -9
  442. package/packages/shared-skills/skills/browser/references/install.md +1 -2
  443. package/packages/shared-skills/skills/browser/runtime/omowright/manifest.json +1 -1
  444. package/packages/shared-skills/skills/browser/scripts/browser-doctor.mjs +2 -2
  445. package/packages/shared-skills/skills/browser/scripts/browser-engine-guard.mjs +63 -487
  446. package/packages/shared-skills/skills/browser/scripts/browser-install.mjs +1 -1
  447. package/packages/shared-skills/skills/browser/scripts/omowright.mjs +1 -10
  448. package/packages/shared-skills/skills/frontend/ATTRIBUTION.md +2 -2
  449. package/packages/shared-skills/skills/frontend/SKILL.md +79 -118
  450. package/packages/shared-skills/skills/frontend/references/design/README.md +75 -224
  451. package/packages/shared-skills/skills/frontend/references/design/stylegallery.md +32 -27
  452. package/packages/shared-skills/skills/frontend/references/perfection/README.md +2 -2
  453. package/packages/shared-skills/skills/frontend/scripts/perfection/check-accent-stripes.ts +8 -24
  454. package/packages/shared-skills/skills/frontend/scripts/perfection/check-draft-guard.test.ts +101 -0
  455. package/packages/shared-skills/skills/frontend/scripts/perfection/check-draft-guard.ts +40 -0
  456. package/packages/shared-skills/skills/frontend/scripts/perfection/collect-files.test.ts +50 -0
  457. package/packages/shared-skills/skills/frontend/scripts/perfection/collect-files.ts +53 -0
  458. package/packages/shared-skills/skills/frontend/scripts/perfection/draft-guard/findings.ts +16 -0
  459. package/packages/shared-skills/skills/frontend/scripts/perfection/draft-guard/lint.ts +38 -0
  460. package/packages/shared-skills/skills/frontend/scripts/perfection/draft-guard/rules.ts +69 -0
  461. package/packages/shared-skills/skills/frontend/scripts/perfection/draft-guard/text-nodes.ts +121 -0
  462. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/attr-lookalikes.tsx +10 -0
  463. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/bound-values.tsx +12 -0
  464. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/const-generics.tsx +3 -0
  465. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/generics.tsx +7 -0
  466. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/measured-stats.html +6 -0
  467. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/plain-copy.html +9 -0
  468. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/negative/state-copy.html +11 -0
  469. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/attribute-edges.html +7 -0
  470. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/components.tsx +16 -0
  471. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/decorative-badge.vue +7 -0
  472. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/emoji-icons.tsx +9 -0
  473. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/jsx-edges.tsx +1 -0
  474. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/promo-copy.html +6 -0
  475. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/promo-copy.tsx +8 -0
  476. package/packages/shared-skills/skills/frontend/scripts/perfection/fixtures/draft-guard/positive/vanity-stats.html +5 -0
  477. package/packages/shared-skills/skills/programming/SKILL.md +10 -7
  478. package/packages/shared-skills/skills/programming/references/typescript/README.md +10 -7
  479. package/packages/shared-skills/skills/programming/references/typescript/bootstrap.md +9 -23
  480. package/packages/shared-skills/skills/programming/references/typescript/oxc-lint.md +130 -0
  481. package/packages/shared-skills/skills/programming/references/typescript/tsconfig-strict.md +6 -62
  482. package/packages/shared-skills/skills/programming/scripts/typescript/check-no-excuse-rules.ts +12 -12
  483. package/packages/shared-skills/skills/programming/scripts/typescript/new-project.test.ts +162 -0
  484. package/packages/shared-skills/skills/programming/scripts/typescript/new-project.ts +20 -81
  485. package/packages/shared-skills/skills/programming/scripts/typescript/oxc/.oxfmtrc.json +9 -0
  486. package/packages/shared-skills/skills/programming/scripts/typescript/oxc/.oxlintrc.json +46 -0
  487. package/packages/shared-skills/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/LICENSE +21 -0
  488. package/packages/shared-skills/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/index.js +10 -0
  489. package/packages/shared-skills/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/no-em-dash-copy.js +28 -0
  490. package/packages/shared-skills/skills/programming/scripts/typescript/oxc/lint/oxlint-plugin/require-suppression-reason.js +62 -0
  491. package/packages/shared-skills/skills/programming/scripts/typescript/oxc/tsconfig.json +29 -0
  492. package/packages/shared-skills/skills/refactor/SKILL.md +13 -13
  493. package/packages/shared-skills/skills/ultimate-browsing/engine/AGENTS.md +1 -1
  494. package/packages/shared-skills/skills/ulw-execute/SKILL.md +1 -1
  495. package/packages/shared-skills/skills/ulw-research/AGENTS.md +21 -3
  496. package/packages/shared-skills/skills/ulw-research/SKILL.md +37 -12
  497. package/packages/shared-skills/skills/ulw-research/references/deliverable-phase.md +77 -16
  498. package/packages/shared-skills/skills/ulw-research/references/fact-ledger-grammar.md +134 -0
  499. package/packages/shared-skills/skills/ulw-research/references/fact-ledger.md +95 -0
  500. package/packages/shared-skills/skills/ulw-research/references/fidelity-claim-kinds.md +19 -0
  501. package/packages/shared-skills/skills/ulw-research/references/report-gates.md +68 -3
  502. package/packages/shared-skills/skills/ulw-research/references/report-visualization.md +2 -0
  503. package/packages/shared-skills/skills/ulw-research/references/unit-rules.md +157 -0
  504. package/packages/shared-skills/skills/ulw-research/scripts/claim-kinds.mjs +116 -0
  505. package/packages/shared-skills/skills/ulw-research/scripts/claim-kinds.test.ts +193 -0
  506. package/packages/shared-skills/skills/ulw-research/scripts/claims-index.mjs +125 -0
  507. package/packages/shared-skills/skills/ulw-research/scripts/claims-index.test.ts +149 -0
  508. package/packages/shared-skills/skills/ulw-research/scripts/cli-support.mjs +19 -5
  509. package/packages/shared-skills/skills/ulw-research/scripts/cli-support.test.ts +13 -2
  510. package/packages/shared-skills/skills/ulw-research/scripts/contracts.mjs +89 -3
  511. package/packages/shared-skills/skills/ulw-research/scripts/contracts.test.ts +100 -12
  512. package/packages/shared-skills/skills/ulw-research/scripts/copy-returns.test.ts +183 -0
  513. package/packages/shared-skills/skills/ulw-research/scripts/delivery-barrier.test.ts +245 -0
  514. package/packages/shared-skills/skills/ulw-research/scripts/fact-commands-meaning.mjs +191 -0
  515. package/packages/shared-skills/skills/ulw-research/scripts/fact-commands-verify.mjs +164 -0
  516. package/packages/shared-skills/skills/ulw-research/scripts/fact-commands.mjs +239 -0
  517. package/packages/shared-skills/skills/ulw-research/scripts/fact-derive.mjs +66 -0
  518. package/packages/shared-skills/skills/ulw-research/scripts/fact-derive.test.ts +375 -0
  519. package/packages/shared-skills/skills/ulw-research/scripts/fact-expr.mjs +108 -0
  520. package/packages/shared-skills/skills/ulw-research/scripts/fact-fill.mjs +194 -0
  521. package/packages/shared-skills/skills/ulw-research/scripts/fact-fill.test.ts +221 -0
  522. package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-grammar.test.ts +197 -0
  523. package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-kinds.mjs +250 -0
  524. package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-kinds.test.ts +156 -0
  525. package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-legacy.test.ts +160 -0
  526. package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-schema.mjs +221 -0
  527. package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger-schema.test.ts +43 -0
  528. package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger.mjs +123 -0
  529. package/packages/shared-skills/skills/ulw-research/scripts/fact-ledger.test.ts +254 -0
  530. package/packages/shared-skills/skills/ulw-research/scripts/fact-locate.mjs +231 -0
  531. package/packages/shared-skills/skills/ulw-research/scripts/fact-locate.test.ts +118 -0
  532. package/packages/shared-skills/skills/ulw-research/scripts/fact-pairs.mjs +187 -0
  533. package/packages/shared-skills/skills/ulw-research/scripts/fact-pairs.test.ts +167 -0
  534. package/packages/shared-skills/skills/ulw-research/scripts/fact-recompute.mjs +89 -0
  535. package/packages/shared-skills/skills/ulw-research/scripts/fact-unit-dimensions.test.ts +409 -0
  536. package/packages/shared-skills/skills/ulw-research/scripts/fact-unit-rules.test.ts +388 -0
  537. package/packages/shared-skills/skills/ulw-research/scripts/fidelity-binding.mjs +130 -0
  538. package/packages/shared-skills/skills/ulw-research/scripts/fidelity-binding.test.ts +81 -0
  539. package/packages/shared-skills/skills/ulw-research/scripts/fidelity-brief.mjs +150 -0
  540. package/packages/shared-skills/skills/ulw-research/scripts/fidelity-brief.test.ts +179 -0
  541. package/packages/shared-skills/skills/ulw-research/scripts/fidelity-claims.mjs +89 -0
  542. package/packages/shared-skills/skills/ulw-research/scripts/fidelity-lexicon.mjs +145 -0
  543. package/packages/shared-skills/skills/ulw-research/scripts/fidelity-lexicon.test.ts +117 -0
  544. package/packages/shared-skills/skills/ulw-research/scripts/fidelity-records.mjs +163 -0
  545. package/packages/shared-skills/skills/ulw-research/scripts/fidelity-state.mjs +64 -0
  546. package/packages/shared-skills/skills/ulw-research/scripts/fidelity-state.test.ts +46 -0
  547. package/packages/shared-skills/skills/ulw-research/scripts/fidelity-trace.mjs +85 -0
  548. package/packages/shared-skills/skills/ulw-research/scripts/fidelity-trace.test.ts +58 -0
  549. package/packages/shared-skills/skills/ulw-research/scripts/fidelity-values.mjs +229 -0
  550. package/packages/shared-skills/skills/ulw-research/scripts/fidelity-values.test.ts +270 -0
  551. package/packages/shared-skills/skills/ulw-research/scripts/gates-context.test.ts +64 -0
  552. package/packages/shared-skills/skills/ulw-research/scripts/gates-fidelity.mjs +113 -0
  553. package/packages/shared-skills/skills/ulw-research/scripts/gates-fidelity.test.ts +73 -0
  554. package/packages/shared-skills/skills/ulw-research/scripts/gates-static.mjs +29 -9
  555. package/packages/shared-skills/skills/ulw-research/scripts/gates-structure.mjs +1 -1
  556. package/packages/shared-skills/skills/ulw-research/scripts/gates-text.mjs +1 -27
  557. package/packages/shared-skills/skills/ulw-research/scripts/html-lite.mjs +2 -2
  558. package/packages/shared-skills/skills/ulw-research/scripts/html-markup.mjs +182 -0
  559. package/packages/shared-skills/skills/ulw-research/scripts/lexicon.mjs +47 -0
  560. package/packages/shared-skills/skills/ulw-research/scripts/lexicon.test.ts +57 -0
  561. package/packages/shared-skills/skills/ulw-research/scripts/md-lite.mjs +193 -0
  562. package/packages/shared-skills/skills/ulw-research/scripts/md-lite.test.ts +271 -0
  563. package/packages/shared-skills/skills/ulw-research/scripts/meaning-check.mjs +196 -0
  564. package/packages/shared-skills/skills/ulw-research/scripts/meaning-check.test.ts +228 -0
  565. package/packages/shared-skills/skills/ulw-research/scripts/numerals.mjs +226 -0
  566. package/packages/shared-skills/skills/ulw-research/scripts/numerals.test.ts +120 -0
  567. package/packages/shared-skills/skills/ulw-research/scripts/outcome.mjs +8 -8
  568. package/packages/shared-skills/skills/ulw-research/scripts/outcome.test.ts +29 -0
  569. package/packages/shared-skills/skills/ulw-research/scripts/particles-ko.mjs +108 -0
  570. package/packages/shared-skills/skills/ulw-research/scripts/particles-ko.test.ts +86 -0
  571. package/packages/shared-skills/skills/ulw-research/scripts/placeholder.mjs +184 -0
  572. package/packages/shared-skills/skills/ulw-research/scripts/placeholder.test.ts +77 -0
  573. package/packages/shared-skills/skills/ulw-research/scripts/polish-apply.mjs +115 -0
  574. package/packages/shared-skills/skills/ulw-research/scripts/polish-apply.test.ts +363 -0
  575. package/packages/shared-skills/skills/ulw-research/scripts/polish-diff.mjs +31 -0
  576. package/packages/shared-skills/skills/ulw-research/scripts/polish-diff.test.ts +168 -0
  577. package/packages/shared-skills/skills/ulw-research/scripts/polish-markup.test.ts +187 -0
  578. package/packages/shared-skills/skills/ulw-research/scripts/polish-project.mjs +125 -0
  579. package/packages/shared-skills/skills/ulw-research/scripts/polish-rules.mjs +170 -0
  580. package/packages/shared-skills/skills/ulw-research/scripts/rational.mjs +139 -0
  581. package/packages/shared-skills/skills/ulw-research/scripts/rational.test.ts +46 -0
  582. package/packages/shared-skills/skills/ulw-research/scripts/report-tools-commands.mjs +21 -10
  583. package/packages/shared-skills/skills/ulw-research/scripts/report-tools.mjs +15 -0
  584. package/packages/shared-skills/skills/ulw-research/scripts/report-tools.test.ts +458 -2
  585. package/packages/shared-skills/skills/ulw-research/scripts/sentence-split.mjs +77 -0
  586. package/packages/shared-skills/skills/ulw-research/scripts/sentence-split.test.ts +109 -0
  587. package/packages/shared-skills/skills/ulw-research/scripts/source-commands.mjs +140 -0
  588. package/packages/shared-skills/skills/ulw-research/scripts/source-snapshot.mjs +176 -0
  589. package/packages/shared-skills/skills/ulw-research/scripts/source-snapshot.test.ts +113 -0
  590. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/assets/share.csv +3 -0
  591. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/claim-graph.md +13 -0
  592. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/gen-legacy-dev.mjs +89 -0
  593. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/ledger-basic.json +223 -0
  594. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/ledger-legacy-dev.json +859 -0
  595. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/ledger-verify.json +420 -0
  596. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/report-bad.html +19 -0
  597. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/report-good.html +39 -0
  598. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4/acronyms.json +3 -0
  599. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4/meta.json +9 -0
  600. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4/sentences.jsonl +7 -0
  601. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4/text.txt +7 -0
  602. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S4.html +19 -0
  603. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S5/acronyms.json +1 -0
  604. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S5/meta.json +9 -0
  605. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S5/sentences.jsonl +1 -0
  606. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S5/text.txt +1 -0
  607. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity/sources/S9.txt +1 -0
  608. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity-brief-locked.md +17 -0
  609. package/packages/shared-skills/skills/ulw-research/scripts/tests/fixtures/fidelity-brief-pending.md +17 -0
  610. package/packages/shared-skills/skills/ulw-research/scripts/text-normalize.mjs +82 -0
  611. package/packages/shared-skills/skills/ulw-research/scripts/text-normalize.test.ts +73 -0
  612. package/packages/shared-skills/skills/ulw-research/scripts/text-similarity.mjs +28 -0
  613. package/packages/shared-skills/skills/ulw-research/scripts/text-similarity.test.ts +38 -0
  614. package/packages/shared-skills/skills/ulw-research/scripts/unit-algebra.mjs +101 -0
  615. package/packages/shared-skills/skills/ulw-research/scripts/unit-errors.mjs +23 -0
  616. package/packages/shared-skills/skills/ulw-research/scripts/unit-metadata.mjs +31 -0
  617. package/packages/shared-skills/skills/ulw-research/scripts/unit-pairs.mjs +72 -0
  618. package/packages/shared-skills/skills/ulw-research/scripts/unit-precision.mjs +44 -0
  619. package/packages/shared-skills/skills/ulw-research/scripts/unit-rules-shapes.mjs +64 -0
  620. package/packages/shared-skills/skills/ulw-research/scripts/unit-rules.mjs +173 -0
  621. package/packages/shared-skills/skills/ulw-research/scripts/units.mjs +105 -0
  622. package/packages/shared-skills/skills/ulw-research/scripts/units.test.ts +83 -0
  623. package/packages/shared-skills/skills/visual-qa/SKILL.md +70 -63
  624. package/packages/shared-skills/skills/visual-qa/scripts/skill-doc-fields.test.ts +34 -0
  625. package/script/qa/web-terminal-visual-qa.mjs +6 -2
  626. package/script/qa/xterm-live-terminal.mjs +26 -3
@@ -1,8 +1,13 @@
1
1
  import { describe, expect, onTestFinished, test } from "bun:test"
2
- import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
2
+ import { createHash } from "node:crypto"
3
+ import { copyFileSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
3
4
  import { tmpdir } from "node:os"
4
5
  import { delimiter, join } from "node:path"
5
6
 
7
+ import { PROMOTION } from "./fact-commands-meaning.mjs"
8
+ import { writeFidelityRecord } from "./fidelity-records.mjs"
9
+ import { PAIR_KINDS } from "./fact-pairs.mjs"
10
+ import { VERDICT_SCHEMA } from "./meaning-check.mjs"
6
11
  import { COMMANDS, run } from "./report-tools.mjs"
7
12
 
8
13
  const SCRIPT = join(import.meta.dir, "report-tools.mjs")
@@ -33,7 +38,7 @@ describe("help and usage", () => {
33
38
  test("#given --help --json #when run #then it lists exactly the command matrix", async () => {
34
39
  const result = await run(["--help", "--json"])
35
40
  expect(result.json.commands).toEqual([...COMMANDS])
36
- expect(COMMANDS).toEqual(["check", "layout-probe", "repair decide", "outcome init", "outcome set", "outcome gate", "outcome render", "outcome state", "outcome verify", "outcome finish", "outcome briefing", "format-extract"])
41
+ expect(COMMANDS).toEqual(["check", "layout-probe", "repair decide", "outcome init", "outcome set", "outcome gate", "outcome render", "outcome state", "outcome verify", "outcome finish", "outcome briefing", "format-extract", "fact add", "fact quote", "fact retract", "fact export", "fact fill", "fact verify", "fact derive", "source snapshot", "claims index"])
37
42
  })
38
43
 
39
44
  test("#given no arguments under node #when spawned #then it exits 2 with a usage line on stderr", () => {
@@ -84,6 +89,7 @@ describe("outcome", () => {
84
89
  await run(["outcome", "set", "pdf", "delivered", "--path", pdf, "--session-dir", dir])
85
90
  await run(["outcome", "set", "docx", "skipped", "--reason", "no editing audience", "--session-dir", dir])
86
91
  await run(["outcome", "gate", "static", "pass", "--session-dir", dir])
92
+ await run(["outcome", "gate", "fidelity", "not_run", "--reason", "Fixture has no factual content", "--session-dir", dir])
87
93
  const after = await run(["outcome", "verify", "--session-dir", dir])
88
94
  // then
89
95
  expect(before.exitCode).toBe(1)
@@ -185,6 +191,7 @@ describe("manifest bookkeeping", () => {
185
191
  await run(["outcome", "init", "--session-dir", dir, "--promised", "pdf"])
186
192
  await run(["outcome", "set", "pdf", "delivered", "--path", pdf, "--session-dir", dir])
187
193
  writeFileSync(join(dir, "sources-ledger.md"), ["[S1] https://a.example/x", "[S2] https://b.example/y"].join("\n"))
194
+ await run(["outcome", "gate", "fidelity", "not_run", "--reason", "Fixture has no factual content", "--session-dir", dir])
188
195
  const now = new Date(new Date(2026, 0, 1, 12, 0, 0).getTime() + 30 * 60_000).toISOString()
189
196
  const result = await run(["outcome", "finish", "--session-dir", dir, "--now", now])
190
197
  const manifest = JSON.parse(readFileSync(join(dir, "outcome.json"), "utf8"))
@@ -212,3 +219,452 @@ describe("format-extract exit codes", () => {
212
219
  expect(proc.exitCode).toBe(2)
213
220
  })
214
221
  })
222
+
223
+ const FIDELITY = join(FIXTURES, "fidelity")
224
+ const sha256 = (path: string) => createHash("sha256").update(readFileSync(path)).digest("hex")
225
+
226
+ type CliRow = { fact_id: string; kind: string; value: string | null }
227
+ type CliJson = { data: { row: CliRow; context: { match: string } }; defects: { code: string }[] }
228
+
229
+ function nodeJson(args: string[]) {
230
+ const proc = nodeWithoutBun(args)
231
+ const stdout = proc.stdout.toString()
232
+ let json = {} as CliJson
233
+ try {
234
+ json = JSON.parse(stdout) as CliJson
235
+ } catch {}
236
+ return { code: proc.exitCode, json, stdout, stderr: proc.stderr.toString() }
237
+ }
238
+
239
+ /** A session with the locked brief, S4 snapshotted, F1 (span), Q1 (completion), and F<n> (span in mm). */
240
+ function fidelitySession() {
241
+ const dir = sessionDir()
242
+ copyFileSync(join(FIXTURES, "fidelity-brief-locked.md"), join(dir, "brief.md"))
243
+ const s = ["--session-dir", dir]
244
+ const snap = nodeJson(["source", "snapshot", "--id", "S4", "--html", join(FIDELITY, "sources", "S4.html"), ...s])
245
+ const add = nodeJson(["fact", "add", "--source", "S4", "--find", "Span length", "--label", "span_len", "--json", ...s])
246
+ const quote = nodeJson(["fact", "quote", "--source", "S4", "--match", "no earlier than 2027", "--label", "completion", "--json", ...s])
247
+ const derive = nodeJson(["fact", "derive", "--op", "convert", "F1", "--to", "mm", "--label", "span_mm", "--json", ...s])
248
+ const mm = derive.json.data?.row?.fact_id
249
+ const source = [
250
+ '<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Bridge</title></head><body><h1>Bridge</h1>',
251
+ "<h2>Findings</h2>",
252
+ "<p>The span length is {{F1:span_len}} [S4].</p>",
253
+ `<p>In millimetres the span is {{${mm}:span_mm}} [S4].</p>`,
254
+ "<p>The operator wrote {{Q1:completion}} [S4].</p>",
255
+ "<h2>How this report was made</h2><p>Collected from one cited public page [S4].</p>",
256
+ '<h2>Sources</h2><ol><li id="s4">[S4] Bridge page, retrieved 2026-10-01.</li></ol></body></html>',
257
+ ].join("\n")
258
+ writeFileSync(join(dir, "report.src.html"), source)
259
+ return { dir, s, snap, add, quote, derive, mm }
260
+ }
261
+
262
+ function verify(dir: string, report: string, extra: string[] = []) {
263
+ return nodeJson(["fact", "verify", join(dir, report), "--sources", join(dir, "sources"), "--brief", join(dir, "brief.md"), "--session-dir", dir, ...extra])
264
+ }
265
+
266
+ const codesOf = (json: { defects?: { code: string }[] }) => (json.defects ?? []).map((d) => d.code)
267
+
268
+ describe("fact, source, and claims under node", () => {
269
+ test("#given a fresh session #when snapshot, add, quote, derive, fill, and verify run #then the filled report verifies clean", () => {
270
+ // given
271
+ const { dir, s, snap, add, quote, derive, mm } = fidelitySession()
272
+ // when
273
+ const filled = nodeJson(["fact", "fill", join(dir, "report.src.html"), "--out", join(dir, "report.html"), ...s])
274
+ const checked = verify(dir, "report.html")
275
+ // then
276
+ expect(snap.code).toBe(0)
277
+ expect(add.code).toBe(0)
278
+ expect(add.json.data.row.value).toBe("320")
279
+ expect(add.json.data.context.match).toBe("320 m")
280
+ expect(quote.code).toBe(0)
281
+ expect(quote.json.data.row.fact_id).toBe("Q1")
282
+ expect(derive.code).toBe(0)
283
+ expect(mm).toBe("F2")
284
+ expect(filled.code).toBe(0)
285
+ expect(readFileSync(join(dir, "report.html"), "utf8")).toContain("320,000 mm (320 m)")
286
+ expect(checked.code).toBe(0)
287
+ expect(checked.json.defects).toEqual([])
288
+ const record = JSON.parse(readFileSync(join(dir, "fidelity-defects.json"), "utf8"))
289
+ expect(record.artifact_sha256).toBe(sha256(join(dir, "report.html")))
290
+ })
291
+
292
+ test("#given a filled report #when a value is hand-edited or a number typed #then verify exits 1 with the code", () => {
293
+ const { dir, s } = fidelitySession()
294
+ nodeJson(["fact", "fill", join(dir, "report.src.html"), "--out", join(dir, "report.html"), ...s])
295
+ const html = readFileSync(join(dir, "report.html"), "utf8")
296
+ writeFileSync(join(dir, "unit.html"), html.replace("320 m", "320 mm"))
297
+ writeFileSync(join(dir, "typed.html"), html.replace("<h2>How", "<p>Revenue grew 12% [S4].</p>\n<h2>How"))
298
+ const unit = verify(dir, "unit.html")
299
+ const typed = verify(dir, "typed.html")
300
+ expect(unit.code).toBe(1)
301
+ expect(codesOf(unit.json)).toContain("unit_mismatch")
302
+ expect(typed.code).toBe(1)
303
+ expect(codesOf(typed.json)).toContain("untraceable_number")
304
+ })
305
+
306
+ test("#given an anchor that is not in the source #when fact add runs #then it exits 1 with fact_not_located and writes no row", () => {
307
+ const { dir, s } = fidelitySession()
308
+ const proc = nodeJson(["fact", "add", "--source", "S4", "--find", "nope", "--label", "x", ...s])
309
+ expect(proc.code).toBe(1)
310
+ expect(proc.stdout).toContain("fact_not_located")
311
+ expect(JSON.parse(readFileSync(join(dir, "fact-ledger.json"), "utf8")).rows.map((r: { fact_id: string }) => r.fact_id)).toEqual(["F1", "Q1", "F2"])
312
+ })
313
+
314
+ test("#given a snapshotted source #when snapshotted again with the same or different content #then same is a no-op and different exits 1", () => {
315
+ const { dir, s } = fidelitySession()
316
+ writeFileSync(join(dir, "other.txt"), "Span length: 999 m\n")
317
+ expect(nodeJson(["source", "snapshot", "--id", "S4", "--html", join(FIDELITY, "sources", "S4.html"), ...s]).code).toBe(0)
318
+ expect(nodeJson(["source", "snapshot", "--id", "S4", "--text", join(dir, "other.txt"), ...s]).code).toBe(1)
319
+ })
320
+
321
+ test("#given an assumed value with and without a rationale #when added #then the row is kind assumed, and no rationale exits 2", () => {
322
+ const { s } = fidelitySession()
323
+ const added = nodeJson(["fact", "add", "--assumed", "12", "--unit", "%", "--rationale", "planning share chosen by the requester", "--label", "share_assumed", "--json", ...s])
324
+ expect(added.code).toBe(0)
325
+ expect(added.json.data.row.kind).toBe("assumed")
326
+ expect(nodeJson(["fact", "add", "--assumed", "12", "--label", "x", ...s]).code).toBe(2)
327
+ })
328
+
329
+ test("#given the fixture claim graph #when claims index runs #then claims.json lists its claims", () => {
330
+ const dir = sessionDir()
331
+ const proc = nodeJson(["claims", "index", join(FIDELITY, "claim-graph.md"), "--out", join(dir, "claims.json")])
332
+ expect(proc.code).toBe(0)
333
+ expect(JSON.parse(readFileSync(join(dir, "claims.json"), "utf8")).claims.length).toBeGreaterThan(0)
334
+ })
335
+
336
+ test("#given a ledger #when exported as csv #then rows carry fact_id and plot_value and stderr has the coverage line", () => {
337
+ const { s } = fidelitySession()
338
+ const proc = nodeJson(["fact", "export", "--csv", ...s])
339
+ expect(proc.code).toBe(0)
340
+ expect(proc.stdout.split("\n")[0]).toContain("fact_id")
341
+ expect(proc.stdout).toContain("F2")
342
+ expect(proc.stderr).toContain("1 of 1 sources snapshotted")
343
+ })
344
+ })
345
+
346
+ type Pair = { pair_id: string; kind: string; fact_ids?: string[]; sentence: string; quote?: string }
347
+
348
+ /** A filled session plus the pair artifact `fact pairs` wrote for it. */
349
+ function pairedSession() {
350
+ const session = fidelitySession()
351
+ const { dir, s } = session
352
+ nodeJson(["fact", "fill", join(dir, "report.src.html"), "--out", join(dir, "report.html"), ...s])
353
+ const pairs = nodeJson(["fact", "pairs", join(dir, "report.html"), "--ledger", join(dir, "fact-ledger.json"), "--out", join(dir, "pairs.json"), ...s])
354
+ return { ...session, pairs }
355
+ }
356
+
357
+ function verdicts(dir: string, name: string, tier: string, list: object[]) {
358
+ const file = join(dir, name)
359
+ writeFileSync(file, JSON.stringify({ model_tier: tier, verdicts: list }))
360
+ return file
361
+ }
362
+
363
+ const calibrationRows = (dir: string) =>
364
+ readFileSync(join(dir, "fidelity-calibration.jsonl"), "utf8")
365
+ .trim()
366
+ .split("\n")
367
+ .map((line) => JSON.parse(line))
368
+ .filter((row) => row.header !== true && row.run !== true)
369
+
370
+ const runLines = (dir: string) =>
371
+ readFileSync(join(dir, "fidelity-calibration.jsonl"), "utf8")
372
+ .trim()
373
+ .split("\n")
374
+ .map((line) => JSON.parse(line))
375
+ .filter((row) => row.run === true)
376
+
377
+ describe("meaning verifier under node", () => {
378
+ test("#given the filled fixture #when fact pairs runs #then pairs.json holds one quote pair per cited ledger quote", () => {
379
+ const { dir, pairs } = pairedSession()
380
+ const written = JSON.parse(readFileSync(join(dir, "pairs.json"), "utf8"))
381
+ expect(pairs.code).toBe(0)
382
+ expect(written.skipped).toBe(false)
383
+ expect(written.pairs.map((p: Pair) => [p.pair_id, p.kind, p.fact_ids])).toEqual([
384
+ ["P1", "quote", ["F1"]],
385
+ ["P2", "quote", ["Q1"]],
386
+ ])
387
+ expect(written.pairs_sha256).toMatch(/^[0-9a-f]{64}$/)
388
+ expect(Object.keys(written.counts).filter((key) => key !== "total" && key !== "force_strong")).toEqual([...PAIR_KINDS])
389
+ expect(written.verdict_schema).toEqual(JSON.parse(JSON.stringify(VERDICT_SCHEMA)))
390
+ })
391
+
392
+ test("#given cheap and strong verdicts agreeing on hedge_dropped #when meaning-check runs #then it exits 1 with one confirmed defect and one calibration line", () => {
393
+ const { dir, s } = pairedSession()
394
+ const drift = { pair_id: "P2", verdict: "drift", drift_kind: "hedge_dropped", fragment: "no earlier than 2027", source_fragment: "we estimate", explanation: "The estimate reads as a fact." }
395
+ const cheap = verdicts(dir, "cheap.json", "cheap", [drift, { pair_id: "P1", verdict: "ok" }])
396
+ const strong = verdicts(dir, "strong.json", "strong", [drift])
397
+ const checked = nodeJson(["fact", "meaning-check", "--pairs", join(dir, "pairs.json"), "--verdicts", cheap, "--verdicts", strong, ...s])
398
+ const record = JSON.parse(readFileSync(join(dir, "fidelity-meaning-defects.json"), "utf8"))
399
+ expect(checked.code).toBe(1)
400
+ expect(codesOf(checked.json)).toEqual(["meaning_drift_confirmed"])
401
+ expect(codesOf(record)).toEqual(["meaning_drift_confirmed"])
402
+ expect(calibrationRows(dir)).toHaveLength(1)
403
+ expect(calibrationRows(dir)[0]).toMatchObject({ pair_id: "P2", drift_kind: "hedge_dropped", confirmed: true, disputed: false })
404
+ const header = JSON.parse(readFileSync(join(dir, "fidelity-calibration.jsonl"), "utf8").split("\n")[0])
405
+ expect(header.promotion).toEqual({ ...PROMOTION })
406
+ const again = nodeJson(["fact", "meaning-check", "--pairs", join(dir, "pairs.json"), "--verdicts", cheap, "--verdicts", strong, ...s])
407
+ expect(again.code).toBe(1)
408
+ expect(calibrationRows(dir)).toHaveLength(1)
409
+ })
410
+
411
+ test("#given a dispute on the confirmed pair #when meaning-check runs #then the defect stays and the calibration line is disputed", () => {
412
+ const { dir, s } = pairedSession()
413
+ const drift = { pair_id: "P2", verdict: "drift", drift_kind: "hedge_dropped", fragment: "no earlier than 2027", source_fragment: "we estimate" }
414
+ const files = ["--verdicts", verdicts(dir, "cheap.json", "cheap", [drift, { pair_id: "P1", verdict: "ok" }]), "--verdicts", verdicts(dir, "strong.json", "strong", [drift])]
415
+ const checked = nodeJson(["fact", "meaning-check", "--pairs", join(dir, "pairs.json"), ...files, "--dispute", "P2", "--reason", "the operator states it", ...s])
416
+ expect(checked.code).toBe(1)
417
+ expect(codesOf(checked.json)).toEqual(["meaning_drift_confirmed"])
418
+ expect(calibrationRows(dir)[0]).toMatchObject({ pair_id: "P2", disputed: true, reason: "the operator states it" })
419
+ })
420
+
421
+ test("#given a dropped verdict and an unread pair #when meaning-check runs #then both pairs are meaning_unverified and it exits 1", () => {
422
+ const { dir, s } = pairedSession()
423
+ const cheap = verdicts(dir, "cheap.json", "cheap", [{ pair_id: "P2", verdict: "drift", drift_kind: "hedge_dropped", fragment: "certainly by 2027", source_fragment: "we estimate" }])
424
+ const checked = nodeJson(["fact", "meaning-check", "--pairs", join(dir, "pairs.json"), "--verdicts", cheap, ...s])
425
+ const summary = JSON.parse(checked.stderr.trim().split("\n").at(-1) ?? "{}")
426
+ expect(checked.code).toBe(1)
427
+ expect(checked.json.status).toBe("fail")
428
+ expect(codesOf(checked.json)).toEqual(["meaning_unverified", "meaning_unverified"])
429
+ expect(checked.json.unverified.map((gap: { pair_id: string }) => gap.pair_id)).toEqual(["P1", "P2"])
430
+ expect(summary).toMatchObject({ command: "fact meaning-check", defects: 2, dropped: 1, unverified: 2 })
431
+ })
432
+
433
+ test("#given an unreadable verdict file or a malformed pairs file #when meaning-check runs #then it exits 2", () => {
434
+ const { dir, s } = pairedSession()
435
+ const broken = join(dir, "broken.json")
436
+ writeFileSync(broken, "{ not json")
437
+ expect(nodeJson(["fact", "meaning-check", "--pairs", join(dir, "pairs.json"), "--verdicts", broken, ...s]).code).toBe(2)
438
+ const ok = verdicts(dir, "cheap.json", "cheap", [])
439
+ for (const body of ["{}", "null", '{ "pairs": "P1" }']) {
440
+ writeFileSync(join(dir, "bad-pairs.json"), body)
441
+ expect(nodeJson(["fact", "meaning-check", "--pairs", join(dir, "bad-pairs.json"), "--verdicts", ok, ...s]).code, body).toBe(2)
442
+ }
443
+ })
444
+
445
+ test("#given a confirmed run then a dispute on the same inputs #when meaning-check reruns #then the log still holds one run with the dispute", () => {
446
+ const { dir, s } = pairedSession()
447
+ const drift = { pair_id: "P2", verdict: "drift", drift_kind: "hedge_dropped", fragment: "no earlier than 2027", source_fragment: "we estimate" }
448
+ const files = ["--verdicts", verdicts(dir, "cheap.json", "cheap", [drift, { pair_id: "P1", verdict: "ok" }]), "--verdicts", verdicts(dir, "strong.json", "strong", [drift])]
449
+ const first = nodeJson(["fact", "meaning-check", "--pairs", join(dir, "pairs.json"), ...files, ...s])
450
+ const disputed = nodeJson(["fact", "meaning-check", "--pairs", join(dir, "pairs.json"), ...files, "--dispute", "P2", "--reason", "the operator states it", ...s])
451
+ expect(disputed.code).toBe(1)
452
+ expect(disputed.json.run_id).toBe(first.json.run_id)
453
+ expect(disputed.json.promotion_eligibility).toMatchObject({ runs: 1, confirmed: 1, disputed_confirmed: 1, disputed_to_confirmed: 1 })
454
+ expect(calibrationRows(dir)).toEqual([expect.objectContaining({ pair_id: "P2", disputed: true, reason: "the operator states it" })])
455
+ const plain = nodeJson(["fact", "meaning-check", "--pairs", join(dir, "pairs.json"), ...files, ...s])
456
+ expect(plain.json.promotion_eligibility).toMatchObject({ runs: 1, disputed_confirmed: 1 })
457
+ })
458
+
459
+ test("#given a run with no flagged pair #when meaning-check runs #then the run is still logged and counted", () => {
460
+ const { dir, s } = pairedSession()
461
+ const ok = (pair_id: string) => ({ pair_id, verdict: "ok" })
462
+ const files = ["--verdicts", verdicts(dir, "cheap.json", "cheap", [ok("P1"), ok("P2")]), "--verdicts", verdicts(dir, "strong.json", "strong", [ok("P1"), ok("P2")])]
463
+ const checked = nodeJson(["fact", "meaning-check", "--pairs", join(dir, "pairs.json"), ...files, ...s])
464
+ expect(checked.code).toBe(0)
465
+ expect(calibrationRows(dir)).toEqual([])
466
+ expect(runLines(dir)).toEqual([expect.objectContaining({ run_id: checked.json.run_id, flagged: 0 })])
467
+ expect(checked.json.promotion_eligibility.runs).toBe(1)
468
+ })
469
+
470
+ test("#given a corrupt calibration log #when meaning-check runs #then it exits 2 naming the file and line", () => {
471
+ const { dir, s } = pairedSession()
472
+ writeFileSync(join(dir, "fidelity-calibration.jsonl"), "{ not json\n")
473
+ const checked = nodeJson(["fact", "meaning-check", "--pairs", join(dir, "pairs.json"), "--verdicts", verdicts(dir, "cheap.json", "cheap", []), ...s])
474
+ expect(checked.code).toBe(2)
475
+ expect(checked.stderr).toContain(`${join(dir, "fidelity-calibration.jsonl")}:1`)
476
+ })
477
+
478
+ test("#given a skipped pairs file #when meaning-check runs #then it is accepted only when the locked brief says off", () => {
479
+ const { dir, s } = fidelitySession()
480
+ const skip = join(dir, "skip.json")
481
+ writeFileSync(skip, JSON.stringify({ schemaVersion: 1, skipped: true, pairs: [] }))
482
+ const check = () => nodeJson(["fact", "meaning-check", "--pairs", skip, "--verdicts", verdicts(dir, "cheap.json", "cheap", []), ...s])
483
+ const on = check()
484
+ expect(on.code).toBe(1)
485
+ expect(on.json.error).toBe("meaning_check_required")
486
+ writeFileSync(join(dir, "brief.md"), "# Brief\n")
487
+ expect(check().json.error).toBe("fidelity_interview_incomplete")
488
+ expect(check().code).toBe(1)
489
+ writeFileSync(join(dir, "brief.md"), readFileSync(join(FIXTURES, "fidelity-brief-locked.md"), "utf8").replace("meaning check: on", "meaning check: off"))
490
+ const off = check()
491
+ expect(off.code).toBe(0)
492
+ expect(off.json.status).toBe("skipped")
493
+ })
494
+
495
+ test("#given a brief with meaning check off #when fact pairs runs #then it exits 0 and writes skipped", () => {
496
+ const { dir, s } = fidelitySession()
497
+ const brief = readFileSync(join(dir, "brief.md"), "utf8").replace("meaning check: on", "meaning check: off")
498
+ writeFileSync(join(dir, "brief.md"), brief)
499
+ nodeJson(["fact", "fill", join(dir, "report.src.html"), "--out", join(dir, "report.html"), ...s])
500
+ const pairs = nodeJson(["fact", "pairs", join(dir, "report.html"), "--out", join(dir, "pairs.json"), ...s])
501
+ expect(pairs.code).toBe(0)
502
+ expect(JSON.parse(readFileSync(join(dir, "pairs.json"), "utf8"))).toMatchObject({ skipped: true })
503
+ })
504
+ })
505
+
506
+ describe("markdown editions under node", () => {
507
+ const MD = ["# Bridge", "", "## Findings", "", "The span length is {{F1:span_len}} [S4].", "", "The operator wrote {{Q1:completion}} [S4].", "", "## How this report was made", "", "Collected from one cited public page [S4].", "", "## Sources", "", "1. [S4] Bridge page, retrieved 2026-10-01.", ""].join("\n")
508
+
509
+ function mdSession() {
510
+ const session = fidelitySession()
511
+ writeFileSync(join(session.dir, "report.src.md"), MD)
512
+ const filled = nodeJson(["fact", "fill", join(session.dir, "report.src.md"), "--format", "md", "--out", join(session.dir, "report.md"), ...session.s])
513
+ return { ...session, filled }
514
+ }
515
+
516
+ test("#given a markdown source #when filled and verified as md #then verify passes and records the md bytes", () => {
517
+ const { dir, filled } = mdSession()
518
+ const checked = verify(dir, "report.md", ["--format", "md"])
519
+ expect(filled.code).toBe(0)
520
+ expect(readFileSync(join(dir, "report.md"), "utf8")).toContain("The span length is 320 m [S4].")
521
+ expect(checked.code).toBe(0)
522
+ expect(checked.json.defects).toEqual([])
523
+ expect(JSON.parse(readFileSync(join(dir, "fidelity-defects.json"), "utf8")).artifact_sha256).toBe(sha256(join(dir, "report.md")))
524
+ })
525
+
526
+ test("#given a filled markdown edition #when a value is hand-edited or a number typed #then md verify exits 1 with the code", () => {
527
+ const { dir } = mdSession()
528
+ const md = readFileSync(join(dir, "report.md"), "utf8")
529
+ writeFileSync(join(dir, "typed.md"), md.replace("## How", "Revenue grew 12% [S4].\n\n## How"))
530
+ copyFileSync(join(dir, "report.md.fill-map.json"), join(dir, "typed.md.fill-map.json"))
531
+ const typed = verify(dir, "typed.md", ["--format", "md"])
532
+ expect(typed.code).toBe(1)
533
+ expect(codesOf(typed.json)).toContain("untraceable_number")
534
+ })
535
+
536
+ test("#given a filled markdown edition with an unterminated fence #when verified or paired #then both refuse with exit 2", () => {
537
+ const { dir, s } = mdSession()
538
+ writeFileSync(join(dir, "fence.md"), `${readFileSync(join(dir, "report.md"), "utf8")}\n\`\`\`\nunclosed code\n`)
539
+ copyFileSync(join(dir, "report.md.fill-map.json"), join(dir, "fence.md.fill-map.json"))
540
+ const checked = verify(dir, "fence.md", ["--format", "md"])
541
+ expect(checked.code).toBe(2)
542
+ expect(checked.stderr).toContain("unterminated_fence")
543
+ expect(nodeJson(["fact", "pairs", join(dir, "fence.md"), "--out", join(dir, "pairs.json"), ...s]).code).toBe(2)
544
+ })
545
+
546
+ test("#given a filled markdown edition #when fact pairs runs on it #then it pairs the same quotes as the html edition", () => {
547
+ const { dir, s } = mdSession()
548
+ const pairs = nodeJson(["fact", "pairs", join(dir, "report.md"), "--out", join(dir, "pairs.json"), ...s])
549
+ expect(pairs.code).toBe(0)
550
+ expect(JSON.parse(readFileSync(join(dir, "pairs.json"), "utf8")).pairs.map((p: Pair) => p.fact_ids)).toEqual([["F1"], ["Q1"]])
551
+ })
552
+ })
553
+
554
+ describe("repair decide with several defect files", () => {
555
+ test("#given two --defects files #when decided #then the attempt signature carries both codes", async () => {
556
+ const dir = sessionDir()
557
+ const state = join(dir, "repair-state.json")
558
+ await run(["repair", "decide", "--state", state, "--defects", defectsFile(dir, "a.json", ["heading_generic"]), "--defects", defectsFile(dir, "b.json", ["untraceable_number"])])
559
+ const signature = JSON.parse(readFileSync(state, "utf8")).attempts[0].signature
560
+ expect(signature).toContain("heading_generic")
561
+ expect(signature).toContain("untraceable_number")
562
+ })
563
+ })
564
+
565
+ describe("fidelity delivery barrier", () => {
566
+ /** The locked brief has meaning check on, so a deliverable session also carries a clean meaning record. */
567
+ const meaningRan = (dir: string) => writeFidelityRecord(join(dir, "fidelity-meaning-defects.json"), "meaning", { artifact_sha256: sha256(join(dir, "report.html")), report: join(dir, "report.html"), defects: [] })
568
+
569
+ async function deliveredSession(codes: string[]) {
570
+ const { dir, s } = fidelitySession()
571
+ nodeJson(["fact", "fill", join(dir, "report.src.html"), "--out", join(dir, "report.html"), ...s])
572
+ meaningRan(dir)
573
+ const record = (list: string[]) => writeFidelityRecord(join(dir, "fidelity-defects.json"), "fidelity", { artifact_sha256: sha256(join(dir, "report.html")), report: join(dir, "report.html"), defects: list.map((code) => ({ code, message: code })) })
574
+ record(codes)
575
+ await run(["outcome", "init", "--session-dir", dir, "--promised", "html"])
576
+ await run(["outcome", "set", "html", "delivered", "--path", join(dir, "report.html"), "--verified-by", join(dir, "fidelity-defects.json"), "--session-dir", dir])
577
+ const decide = ["repair", "decide", "--state", join(dir, "repair-state.json"), "--defects", join(dir, "fidelity-defects.json"), "--artifact-bytes", "4096", "--renders", "1", "--session-dir", dir]
578
+ await run(decide)
579
+ const decision = await run(decide)
580
+ return { dir, record, decision }
581
+ }
582
+
583
+ test("#given a clean meaning record #when the report is edited and fact verify re-run #then the stale meaning record refuses, and a fresh one passes", async () => {
584
+ // given: meaning check on, readers clean, the edition verified and delivered
585
+ const { dir, s } = pairedSession()
586
+ const report = join(dir, "report.html")
587
+ const clean = [{ pair_id: "P1", verdict: "ok" }, { pair_id: "P2", verdict: "ok" }]
588
+ const readers = () => nodeJson(["fact", "meaning-check", "--pairs", join(dir, "pairs.json"), "--verdicts", verdicts(dir, "cheap.json", "cheap", clean), "--verdicts", verdicts(dir, "strong.json", "strong", clean), ...s])
589
+ expect(readers().code).toBe(0)
590
+ expect(verify(dir, "report.html").code).toBe(0)
591
+ await run(["outcome", "init", "--session-dir", dir, "--promised", "html"])
592
+ await run(["outcome", "set", "html", "delivered", "--path", report, "--verified-by", join(dir, "fidelity-defects.json"), "--session-dir", dir])
593
+ const first = await run(["outcome", "verify", "--session-dir", dir])
594
+ // when: draft 2 (a repair rewrite) is re-verified by fact verify only
595
+ writeFileSync(report, `${readFileSync(report, "utf8")}\n<!-- draft 2 -->\n`)
596
+ expect(verify(dir, "report.html").code).toBe(0)
597
+ const stale = await run(["outcome", "verify", "--session-dir", dir])
598
+ // when: the meaning readers run again on draft 2
599
+ expect(nodeJson(["fact", "pairs", report, "--out", join(dir, "pairs.json"), ...s]).code).toBe(0)
600
+ expect(readers().code).toBe(0)
601
+ const fresh = await run(["outcome", "verify", "--session-dir", dir])
602
+ // then
603
+ expect(first.exitCode).toBe(0)
604
+ expect(stale.exitCode).toBe(1)
605
+ expect(stale.json.problems).toContainEqual(expect.objectContaining({ code: "edition_unverified", path: join(dir, "fidelity-meaning-defects.json"), message: expect.stringContaining("meaning record") }))
606
+ expect(fresh.exitCode).toBe(0)
607
+ })
608
+
609
+ test("#given an unregistered appendix value #when verified #then untraceable_number and outcome verify refuses", async () => {
610
+ const { dir, s } = fidelitySession()
611
+ nodeJson(["fact", "fill", join(dir, "report.src.html"), "--out", join(dir, "report.html"), ...s])
612
+ const html = readFileSync(join(dir, "report.html"), "utf8").replace("<h2>How", "<h2>Appendix</h2>\n<p>Revenue grew 12% [S4].</p>\n<h2>How")
613
+ writeFileSync(join(dir, "report.html"), html)
614
+ const checked = verify(dir, "report.html")
615
+ await run(["outcome", "init", "--session-dir", dir, "--promised", "html"])
616
+ await run(["outcome", "set", "html", "delivered", "--path", join(dir, "report.html"), "--verified-by", join(dir, "fidelity-defects.json"), "--session-dir", dir])
617
+ const outcome = await run(["outcome", "verify", "--session-dir", dir])
618
+ expect(codesOf(checked.json)).toContain("untraceable_number")
619
+ expect(outcome.exitCode).toBe(1)
620
+ expect(outcome.json.problems.map((p: { code: string }) => p.code)).toContain("fidelity_unresolved")
621
+ })
622
+
623
+ for (const code of ["untraceable_number", "unbound_sentence"]) {
624
+ test(`#given ${code} left after repair delivers on exhaustion #when verified and finished #then both refuse, and an empty record passes`, async () => {
625
+ const { dir, record, decision } = await deliveredSession([code])
626
+ const refused = await run(["outcome", "verify", "--session-dir", dir])
627
+ const finish = await run(["outcome", "finish", "--session-dir", dir])
628
+ record([])
629
+ const passed = await run(["outcome", "verify", "--session-dir", dir])
630
+ const finished = await run(["outcome", "finish", "--session-dir", dir])
631
+ expect(decision.json.decision.action).toBe("deliver")
632
+ expect(refused.exitCode).toBe(1)
633
+ expect(JSON.stringify(refused.json.problems)).toContain(`fidelity_unresolved: ${code}`)
634
+ expect(finish.exitCode).toBe(1)
635
+ expect(passed.exitCode).toBe(0)
636
+ expect(finished.exitCode).toBe(0)
637
+ })
638
+ }
639
+
640
+ test("#given a clean main report and an inline edition #when the edition lacks or mismatches its verify record #then edition_unverified, and its own record passes", async () => {
641
+ // given
642
+ const { dir, s } = fidelitySession()
643
+ nodeJson(["fact", "fill", join(dir, "report.src.html"), "--out", join(dir, "report.html"), ...s])
644
+ expect(verify(dir, "report.html").code).toBe(0)
645
+ meaningRan(dir)
646
+ expect(nodeJson(["fact", "fill", join(dir, "report.src.html"), "--inline", "--out", join(dir, "report.inline.html"), ...s]).code).toBe(0)
647
+ await run(["outcome", "init", "--session-dir", dir, "--promised", "html,pdf"])
648
+ await run(["outcome", "set", "html", "delivered", "--path", join(dir, "report.html"), "--verified-by", join(dir, "fidelity-defects.json"), "--session-dir", dir])
649
+ const problems = async () => {
650
+ const result = await run(["outcome", "verify", "--session-dir", dir])
651
+ return { exitCode: result.exitCode, codes: result.json.problems.map((p: { code: string }) => p.code) }
652
+ }
653
+ // when: no --verified-by
654
+ await run(["outcome", "set", "pdf", "delivered", "--path", join(dir, "report.inline.html"), "--session-dir", dir])
655
+ const missing = await problems()
656
+ // when: a record for different bytes
657
+ expect(verify(dir, "report.inline.html", ["--out", join(dir, "fidelity-inline.json")]).code).toBe(0)
658
+ const inline = readFileSync(join(dir, "report.inline.html"), "utf8")
659
+ writeFileSync(join(dir, "report.inline.html"), inline.replace("320,000 mm", "330,000 mm"))
660
+ await run(["outcome", "set", "pdf", "delivered", "--path", join(dir, "report.inline.html"), "--verified-by", join(dir, "fidelity-inline.json"), "--session-dir", dir])
661
+ const altered = await problems()
662
+ // when: restored to the verified bytes
663
+ writeFileSync(join(dir, "report.inline.html"), inline)
664
+ const matched = await problems()
665
+ // then
666
+ expect(missing).toEqual({ exitCode: 1, codes: ["edition_unverified"] })
667
+ expect(altered).toEqual({ exitCode: 1, codes: ["edition_unverified"] })
668
+ expect(matched).toEqual({ exitCode: 0, codes: [] })
669
+ })
670
+ })
@@ -0,0 +1,77 @@
1
+ // sentence-split.mjs - deterministic sentence index for snapshot text.
2
+ //
3
+ // splitSentences(text) returns [{ sid, start, end, text }] with sid "s<k>" (1-based) and
4
+ // start/end as offsets into the raw text, so text.slice(start, end) === record.text.
5
+ // Boundaries: a line break; ". ! ?" followed by whitespace or end of line (known
6
+ // abbreviations such as "e.g." excepted); and the Korean endings da. yo. nida. kka? even
7
+ // with no following space, unless closing punctuation follows (quoted speech such as
8
+ // '...da."rago' then needs whitespace like any other terminator). "no." is an abbreviation
9
+ // only before a number ("No. 5"). Plain Node ESM, no dependencies.
10
+
11
+ import { normalizeText } from "./text-normalize.mjs"
12
+
13
+ const TERMINATORS = ".!?"
14
+ const CLOSERS = "\"')]}\u201D\u2019\u00BB\u300D\u300F"
15
+ const KOREAN_PERIOD_ENDINGS = new Set(["\uB2E4", "\uC694"]) // da, yo (nida ends in da)
16
+ const KOREAN_QUESTION_ENDING = "\uAE4C" // kka
17
+ const ABBREVIATIONS = new Set([
18
+ "e.g", "i.e", "etc", "vs", "cf", "approx", "al", "fig", "no", "mr", "mrs", "ms", "dr", "prof", "inc", "ltd", "jr", "sr",
19
+ ])
20
+ const SPACE = /\s/u
21
+
22
+ function isKoreanEnding(line, at) {
23
+ const prev = line[at - 1]
24
+ if (line[at] === ".") return KOREAN_PERIOD_ENDINGS.has(prev)
25
+ return line[at] === "?" && prev === KOREAN_QUESTION_ENDING
26
+ }
27
+
28
+ function isAbbreviation(line, from, at) {
29
+ let k = at
30
+ while (k > from && !SPACE.test(line[k - 1])) k--
31
+ const word = line.slice(k, at).replace(/^[("'[]+/u, "").toLowerCase()
32
+ if (word === "no") return /^\s*\d/u.test(line.slice(at + 1))
33
+ return ABBREVIATIONS.has(word)
34
+ }
35
+
36
+ function pushSegment(line, base, from, to, out) {
37
+ let start = from
38
+ let end = to
39
+ while (start < end && SPACE.test(line[start])) start++
40
+ while (end > start && SPACE.test(line[end - 1])) end--
41
+ const text = line.slice(start, end)
42
+ if (normalizeText(text) === "") return
43
+ out.push({ sid: `s${out.length + 1}`, start: base + start, end: base + end, text })
44
+ }
45
+
46
+ function splitLine(line, base, out) {
47
+ let from = 0
48
+ for (let i = 0; i < line.length; i++) {
49
+ if (!TERMINATORS.includes(line[i])) continue
50
+ let j = i + 1
51
+ while (j < line.length && (TERMINATORS.includes(line[j]) || CLOSERS.includes(line[j]))) j++
52
+ const atBreak = j >= line.length || SPACE.test(line[j])
53
+ const closed = [...line.slice(i + 1, j)].some((c) => CLOSERS.includes(c))
54
+ const korean = !closed && isKoreanEnding(line, i)
55
+ const abbreviation = line[i] === "." && !korean && isAbbreviation(line, from, i)
56
+ if ((atBreak || korean) && !abbreviation) {
57
+ pushSegment(line, base, from, j, out)
58
+ from = j
59
+ }
60
+ i = j - 1
61
+ }
62
+ pushSegment(line, base, from, line.length, out)
63
+ }
64
+
65
+ export function splitSentences(text) {
66
+ const source = String(text ?? "")
67
+ const out = []
68
+ let base = 0
69
+ while (base <= source.length) {
70
+ const newline = source.indexOf("\n", base)
71
+ const stop = newline === -1 ? source.length : newline
72
+ splitLine(source.slice(base, stop), base, out)
73
+ if (newline === -1) break
74
+ base = newline + 1
75
+ }
76
+ return out
77
+ }