omo-ai 5.1.69 → 5.1.70

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 (406) hide show
  1. package/bin/darwin/omo-keychain +0 -0
  2. package/bin/lib/agent-dir.js +8 -1
  3. package/bin/lib/auth-store.js +11 -1
  4. package/bin/lib/bun-bin-shim.js +12 -2
  5. package/bin/lib/category-coverage.js +56 -18
  6. package/bin/lib/child-process.js +2 -1
  7. package/bin/lib/compile-safe-engine.js +14 -2
  8. package/bin/lib/daemon-adopt.js +41 -10
  9. package/bin/lib/daemon-config.js +9 -3
  10. package/bin/lib/daemon-operations.js +11 -3
  11. package/bin/lib/daemon-rollback.js +28 -23
  12. package/bin/lib/daemon-status.js +9 -3
  13. package/bin/lib/daemon.js +18 -3
  14. package/bin/lib/doctor-memory-runtime.js +46 -12
  15. package/bin/lib/doctor-migration.js +65 -38
  16. package/bin/lib/doctor-pi-config.js +8 -3
  17. package/bin/lib/doctor-reflection-lock.js +35 -12
  18. package/bin/lib/doctor.js +63 -23
  19. package/bin/lib/engine-boot.js +3 -1
  20. package/bin/lib/engine-commands.js +11 -1
  21. package/bin/lib/engine-environment.js +8 -1
  22. package/bin/lib/engine-models.js +2 -1
  23. package/bin/lib/engine-prepare.js +18 -3
  24. package/bin/lib/host-status.js +5 -1
  25. package/bin/lib/jsonc-edit.js +10 -6
  26. package/bin/lib/keychain-helper-doctor.js +13 -3
  27. package/bin/lib/launch-spec-mode.js +6 -2
  28. package/bin/lib/launcher.js +31 -19
  29. package/bin/lib/model-chains.js +12 -5
  30. package/bin/lib/npm-dist-tags.js +2 -1
  31. package/bin/lib/package-paths.js +18 -10
  32. package/bin/lib/private-fd-table.js +19 -10
  33. package/bin/lib/provider-map.json +1 -1
  34. package/bin/lib/rpc-stream-errors.js +6 -2
  35. package/bin/lib/same-version.js +6 -1
  36. package/bin/lib/self-update.js +41 -10
  37. package/bin/lib/service-auth.generated.js +41 -20
  38. package/bin/lib/setup-assets-import.js +25 -5
  39. package/bin/lib/setup-commandcode.js +5 -2
  40. package/bin/lib/setup-credentials.js +12 -2
  41. package/bin/lib/setup-detect-refresh.js +9 -6
  42. package/bin/lib/setup-detect.js +4 -5
  43. package/bin/lib/setup-guidance.js +1 -1
  44. package/bin/lib/setup-import.js +35 -7
  45. package/bin/lib/setup-model-choices-import.js +61 -10
  46. package/bin/lib/setup-models.js +9 -5
  47. package/bin/lib/setup-opencode-assets.js +26 -9
  48. package/bin/lib/setup-opencode-models.d.ts +4 -1
  49. package/bin/lib/setup-opencode-models.js +76 -30
  50. package/bin/lib/setup-opencode-providers.js +58 -17
  51. package/bin/lib/setup-providers-import.js +38 -6
  52. package/bin/lib/setup-report.js +9 -7
  53. package/bin/lib/setup-stream-items.js +29 -5
  54. package/bin/lib/setup-stream.d.ts +13 -3
  55. package/bin/lib/setup-stream.js +92 -15
  56. package/bin/lib/setup-summary.js +61 -18
  57. package/bin/lib/sqlite-rows.js +3 -1
  58. package/bin/lib/thread-output.js +14 -4
  59. package/bin/lib/thread.js +224 -38
  60. package/bin/lib/update-args.js +5 -1
  61. package/bin/lib/update-lock.js +13 -2
  62. package/bin/omo.js +1 -1
  63. package/package.json +2 -2
  64. package/plugin/CHANGELOG.md +81 -0
  65. package/plugin/extensions/gateway-store-worker.mjs +1 -1
  66. package/plugin/extensions/memory-run-supervisor.mjs +1 -1
  67. package/plugin/extensions/omo-claim-receipt.js +1 -1
  68. package/plugin/extensions/omo-computer-run-worker.mjs +1 -1
  69. package/plugin/extensions/omo-computer-use.js +2 -2
  70. package/plugin/extensions/omo-desktop-toolkit.js +1 -1
  71. package/plugin/extensions/omo-device-account.js +4 -4
  72. package/plugin/extensions/omo-device-service.js +5 -5
  73. package/plugin/extensions/omo-feedback.js +2 -2
  74. package/plugin/extensions/omo-init-deep-advisor.js +1 -1
  75. package/plugin/extensions/omo-member.js +2 -2
  76. package/plugin/extensions/omo-memory-commands.js +2 -2
  77. package/plugin/extensions/omo-memory-doctor.js +3 -3
  78. package/plugin/extensions/omo-memory-memfs.js +1 -1
  79. package/plugin/extensions/omo-memory-palace.js +1 -1
  80. package/plugin/extensions/omo-memory-sync.js +2 -2
  81. package/plugin/extensions/omo-onboarding-scan.js +2 -2
  82. package/plugin/extensions/omo-recall-store.js +1 -1
  83. package/plugin/extensions/omo-session-history.js +1 -1
  84. package/plugin/extensions/omo-side-panel.js +3 -3
  85. package/plugin/extensions/omo-task.js +2 -2
  86. package/plugin/extensions/omo-telemetry-otlp.js +1 -1
  87. package/plugin/extensions/omo-telemetry-posthog.js +1 -1
  88. package/plugin/extensions/omo-telemetry-recovery.js +1 -1
  89. package/plugin/extensions/omo-thread-client.js +3 -3
  90. package/plugin/extensions/omo.js +3 -3
  91. package/plugin/package.json +1 -1
  92. package/plugin/runtime/agent-toolkit-sdk/sdk.js +2 -2
  93. package/plugin/runtime/ast-grep-mcp/cli.js +26 -5
  94. package/plugin/runtime/ast-grep-mcp/manifest.json +2 -2
  95. package/plugin/runtime/bunshin-ts/sdk.js +4 -4
  96. package/plugin/runtime/category-coverage/index.js +2 -2
  97. package/plugin/runtime/lsp-daemon/dist/.omo-runtime-manifest.json +4 -4
  98. package/plugin/runtime/lsp-daemon/dist/cli.js +8 -2
  99. package/plugin/runtime/lsp-daemon/dist/client.js +8 -2
  100. package/plugin/runtime/lsp-daemon/dist/index.js +8 -2
  101. package/plugin/runtime/rollback-migrate.js +2 -2
  102. package/plugin/runtime/task-config/index.js +2 -2
  103. package/plugin/runtime/thread-sdk/sdk.js +5 -5
  104. package/plugin/scripts/install.mjs +20 -15
  105. package/plugin/skills/ast-grep/references/recipes.md +1 -1
  106. package/plugin/skills/ast-grep/tests/smoke.ps1 +1 -1
  107. package/plugin/skills/ast-grep/tests/smoke.sh +1 -1
  108. package/plugin/skills/browser/runtime/omowright/index.js +16 -16
  109. package/plugin/skills/browser/runtime/omowright/manifest.json +5 -5
  110. package/plugin/skills/browser/runtime/omowright/page-bundle.js +14 -4
  111. package/plugin/skills/browser/scripts/browser-doctor-report.mjs +36 -9
  112. package/plugin/skills/browser/scripts/browser-doctor.mjs +24 -7
  113. package/plugin/skills/browser/scripts/browser-engine-guard.mjs +2 -1
  114. package/plugin/skills/browser/scripts/browser-install.mjs +40 -8
  115. package/plugin/skills/debugging/references/scripts/dap.mjs +280 -170
  116. package/plugin/skills/debugging/references/scripts/fixture-adapter.mjs +104 -42
  117. package/plugin/skills/frontend/scripts/detect/cli.ts +67 -50
  118. package/plugin/skills/frontend/scripts/detect/config.ts +41 -38
  119. package/plugin/skills/frontend/scripts/detect/core/color.ts +109 -94
  120. package/plugin/skills/frontend/scripts/detect/core/page.ts +43 -42
  121. package/plugin/skills/frontend/scripts/detect/core/shadow.ts +38 -29
  122. package/plugin/skills/frontend/scripts/detect/core/source.ts +25 -20
  123. package/plugin/skills/frontend/scripts/detect/detect.ts +63 -45
  124. package/plugin/skills/frontend/scripts/detect/lint.ts +78 -69
  125. package/plugin/skills/frontend/scripts/detect/render/probe-placement.ts +36 -32
  126. package/plugin/skills/frontend/scripts/detect/render/renderer.ts +14 -13
  127. package/plugin/skills/frontend/scripts/detect/render/webview.ts +53 -50
  128. package/plugin/skills/frontend/scripts/detect/report.ts +20 -18
  129. package/plugin/skills/frontend/scripts/detect/rule.ts +21 -21
  130. package/plugin/skills/frontend/scripts/detect/rules/color/ai-color-palette.ts +144 -63
  131. package/plugin/skills/frontend/scripts/detect/rules/color/cream-palette.ts +41 -27
  132. package/plugin/skills/frontend/scripts/detect/rules/color/dark-glow.ts +59 -34
  133. package/plugin/skills/frontend/scripts/detect/rules/color/design-system-color.ts +37 -28
  134. package/plugin/skills/frontend/scripts/detect/rules/color/gradient-text.ts +68 -45
  135. package/plugin/skills/frontend/scripts/detect/rules/color/gray-on-color.ts +34 -25
  136. package/plugin/skills/frontend/scripts/detect/rules/color/index.ts +9 -2
  137. package/plugin/skills/frontend/scripts/detect/rules/color/low-contrast.ts +106 -43
  138. package/plugin/skills/frontend/scripts/detect/rules/color/radial-halo.ts +48 -23
  139. package/plugin/skills/frontend/scripts/detect/rules/color/radial-spotlight-glow.ts +49 -26
  140. package/plugin/skills/frontend/scripts/detect/rules/color/support/animation-opacity.ts +90 -66
  141. package/plugin/skills/frontend/scripts/detect/rules/color/support/color-path.ts +43 -6
  142. package/plugin/skills/frontend/scripts/detect/rules/color/support/contrast-pairs.ts +75 -38
  143. package/plugin/skills/frontend/scripts/detect/rules/color/support/contrast-role.ts +142 -59
  144. package/plugin/skills/frontend/scripts/detect/rules/color/support/glow-forms.ts +93 -44
  145. package/plugin/skills/frontend/scripts/detect/rules/color/support/gradient-samples.ts +115 -114
  146. package/plugin/skills/frontend/scripts/detect/rules/color/support/gradients.ts +77 -66
  147. package/plugin/skills/frontend/scripts/detect/rules/color/support/mockup-roots.ts +178 -48
  148. package/plugin/skills/frontend/scripts/detect/rules/color/support/page-ignore.ts +6 -2
  149. package/plugin/skills/frontend/scripts/detect/rules/color/support/painted-text.ts +171 -108
  150. package/plugin/skills/frontend/scripts/detect/rules/color/support/palette-roles.ts +60 -39
  151. package/plugin/skills/frontend/scripts/detect/rules/color/support/placeholder-contrast.ts +36 -16
  152. package/plugin/skills/frontend/scripts/detect/rules/color/support/stock-accent.ts +48 -18
  153. package/plugin/skills/frontend/scripts/detect/rules/color/support/text-colors.ts +88 -62
  154. package/plugin/skills/frontend/scripts/detect/rules/copy/aphoristic-cadence.ts +25 -15
  155. package/plugin/skills/frontend/scripts/detect/rules/copy/broken-image.ts +20 -12
  156. package/plugin/skills/frontend/scripts/detect/rules/copy/em-dash-overuse.ts +63 -39
  157. package/plugin/skills/frontend/scripts/detect/rules/copy/index.ts +9 -2
  158. package/plugin/skills/frontend/scripts/detect/rules/copy/marketing-buzzword.ts +53 -25
  159. package/plugin/skills/frontend/scripts/detect/rules/copy/numbered-section-labels.ts +49 -28
  160. package/plugin/skills/frontend/scripts/detect/rules/copy/repeated-container-text.ts +80 -47
  161. package/plugin/skills/frontend/scripts/detect/rules/copy/script-error.ts +42 -34
  162. package/plugin/skills/frontend/scripts/detect/rules/copy/skipped-heading.ts +199 -75
  163. package/plugin/skills/frontend/scripts/detect/rules/copy/support/numbered-label.ts +122 -71
  164. package/plugin/skills/frontend/scripts/detect/rules/copy/support/page-text.ts +32 -24
  165. package/plugin/skills/frontend/scripts/detect/rules/copy/theater-slop-phrase.ts +42 -13
  166. package/plugin/skills/frontend/scripts/detect/rules/decoration/blinking-cursor.ts +49 -41
  167. package/plugin/skills/frontend/scripts/detect/rules/decoration/border-accent-on-rounded.ts +10 -10
  168. package/plugin/skills/frontend/scripts/detect/rules/decoration/bounce-easing.ts +87 -68
  169. package/plugin/skills/frontend/scripts/detect/rules/decoration/buried-raster.ts +83 -64
  170. package/plugin/skills/frontend/scripts/detect/rules/decoration/codex-grid-background.ts +29 -29
  171. package/plugin/skills/frontend/scripts/detect/rules/decoration/design-system-radius.ts +33 -26
  172. package/plugin/skills/frontend/scripts/detect/rules/decoration/gpt-thin-border-wide-shadow.ts +61 -58
  173. package/plugin/skills/frontend/scripts/detect/rules/decoration/hard-offset-shadow.ts +25 -23
  174. package/plugin/skills/frontend/scripts/detect/rules/decoration/hero-eyebrow-chip.ts +16 -14
  175. package/plugin/skills/frontend/scripts/detect/rules/decoration/icon-tile-stack.ts +85 -84
  176. package/plugin/skills/frontend/scripts/detect/rules/decoration/index.ts +17 -17
  177. package/plugin/skills/frontend/scripts/detect/rules/decoration/kicker-above-heading.ts +79 -64
  178. package/plugin/skills/frontend/scripts/detect/rules/decoration/marquee.ts +57 -40
  179. package/plugin/skills/frontend/scripts/detect/rules/decoration/organic-clip-path.ts +34 -34
  180. package/plugin/skills/frontend/scripts/detect/rules/decoration/pulsing-dot.ts +92 -58
  181. package/plugin/skills/frontend/scripts/detect/rules/decoration/repeating-stripes-gradient.ts +19 -19
  182. package/plugin/skills/frontend/scripts/detect/rules/decoration/shape-assembled-illustration.ts +59 -53
  183. package/plugin/skills/frontend/scripts/detect/rules/decoration/side-tab.ts +15 -12
  184. package/plugin/skills/frontend/scripts/detect/rules/decoration/support/appearance.ts +89 -85
  185. package/plugin/skills/frontend/scripts/detect/rules/decoration/support/assert-cases.ts +17 -15
  186. package/plugin/skills/frontend/scripts/detect/rules/decoration/support/borders.ts +178 -136
  187. package/plugin/skills/frontend/scripts/detect/rules/decoration/support/clip-geometry.ts +155 -145
  188. package/plugin/skills/frontend/scripts/detect/rules/decoration/support/css-candidates.ts +60 -54
  189. package/plugin/skills/frontend/scripts/detect/rules/decoration/support/curve-samples.ts +51 -48
  190. package/plugin/skills/frontend/scripts/detect/rules/decoration/support/gradient-pattern.ts +43 -34
  191. package/plugin/skills/frontend/scripts/detect/rules/decoration/support/keyframes.ts +118 -113
  192. package/plugin/skills/frontend/scripts/detect/rules/decoration/support/labels.ts +74 -67
  193. package/plugin/skills/frontend/scripts/detect/rules/decoration/support/raster-state.ts +80 -42
  194. package/plugin/skills/frontend/scripts/detect/rules/index.ts +6 -6
  195. package/plugin/skills/frontend/scripts/detect/rules/layout/body-text-viewport-edge.ts +116 -55
  196. package/plugin/skills/frontend/scripts/detect/rules/layout/clipped-overflow-container.ts +22 -9
  197. package/plugin/skills/frontend/scripts/detect/rules/layout/content-hidden-at-rest.ts +113 -52
  198. package/plugin/skills/frontend/scripts/detect/rules/layout/cramped-padding.ts +167 -90
  199. package/plugin/skills/frontend/scripts/detect/rules/layout/edge-flush-cards.ts +82 -41
  200. package/plugin/skills/frontend/scripts/detect/rules/layout/first-viewport-column-overflow.ts +74 -37
  201. package/plugin/skills/frontend/scripts/detect/rules/layout/heading-rhythm.ts +49 -24
  202. package/plugin/skills/frontend/scripts/detect/rules/layout/index.ts +14 -3
  203. package/plugin/skills/frontend/scripts/detect/rules/layout/monotonous-spacing.ts +47 -28
  204. package/plugin/skills/frontend/scripts/detect/rules/layout/nested-cards.ts +66 -31
  205. package/plugin/skills/frontend/scripts/detect/rules/layout/straggler.ts +46 -22
  206. package/plugin/skills/frontend/scripts/detect/rules/layout/support/cards.ts +157 -82
  207. package/plugin/skills/frontend/scripts/detect/rules/layout/support/clipping.ts +98 -50
  208. package/plugin/skills/frontend/scripts/detect/rules/layout/support/declared-mockups.ts +100 -36
  209. package/plugin/skills/frontend/scripts/detect/rules/layout/support/geometry.ts +66 -43
  210. package/plugin/skills/frontend/scripts/detect/rules/layout/support/hidden-interface.ts +56 -24
  211. package/plugin/skills/frontend/scripts/detect/rules/layout/support/layout-cases.ts +23 -8
  212. package/plugin/skills/frontend/scripts/detect/rules/layout/support/line-breaks.ts +28 -16
  213. package/plugin/skills/frontend/scripts/detect/rules/layout/support/motion.ts +88 -56
  214. package/plugin/skills/frontend/scripts/detect/rules/layout/support/padding.ts +106 -68
  215. package/plugin/skills/frontend/scripts/detect/rules/layout/support/rhythm.ts +204 -128
  216. package/plugin/skills/frontend/scripts/detect/rules/layout/text-occlusion.ts +125 -70
  217. package/plugin/skills/frontend/scripts/detect/rules/layout/text-overflow.ts +111 -59
  218. package/plugin/skills/frontend/scripts/detect/rules/layout/unbalanced-heading.ts +27 -16
  219. package/plugin/skills/frontend/scripts/detect/rules/layout/viewport-reflow.ts +38 -23
  220. package/plugin/skills/frontend/scripts/detect/rules/source/ai-color-palette.ts +17 -6
  221. package/plugin/skills/frontend/scripts/detect/rules/source/aphoristic-cadence.ts +19 -9
  222. package/plugin/skills/frontend/scripts/detect/rules/source/border-accent-on-rounded.ts +31 -13
  223. package/plugin/skills/frontend/scripts/detect/rules/source/bounce-easing.ts +41 -16
  224. package/plugin/skills/frontend/scripts/detect/rules/source/broken-image.ts +19 -9
  225. package/plugin/skills/frontend/scripts/detect/rules/source/codex-grid-background.ts +36 -12
  226. package/plugin/skills/frontend/scripts/detect/rules/source/dark-glow.ts +28 -14
  227. package/plugin/skills/frontend/scripts/detect/rules/source/em-dash-overuse.ts +17 -9
  228. package/plugin/skills/frontend/scripts/detect/rules/source/gradient-text.ts +14 -6
  229. package/plugin/skills/frontend/scripts/detect/rules/source/gray-on-color.ts +18 -7
  230. package/plugin/skills/frontend/scripts/detect/rules/source/index.ts +18 -1
  231. package/plugin/skills/frontend/scripts/detect/rules/source/marketing-buzzword.ts +49 -11
  232. package/plugin/skills/frontend/scripts/detect/rules/source/marquee.ts +16 -6
  233. package/plugin/skills/frontend/scripts/detect/rules/source/monotonous-spacing.ts +35 -17
  234. package/plugin/skills/frontend/scripts/detect/rules/source/overused-font.ts +51 -10
  235. package/plugin/skills/frontend/scripts/detect/rules/source/radial-halo.ts +16 -8
  236. package/plugin/skills/frontend/scripts/detect/rules/source/side-tab.ts +88 -47
  237. package/plugin/skills/frontend/scripts/detect/rules/source/support/accent-scans.ts +103 -62
  238. package/plugin/skills/frontend/scripts/detect/rules/source/support/check-source.ts +6 -2
  239. package/plugin/skills/frontend/scripts/detect/rules/source/support/corners.ts +148 -80
  240. package/plugin/skills/frontend/scripts/detect/rules/source/support/css-effects.ts +86 -66
  241. package/plugin/skills/frontend/scripts/detect/rules/source/support/css-scopes.ts +148 -113
  242. package/plugin/skills/frontend/scripts/detect/rules/source/support/image-tags.ts +113 -105
  243. package/plugin/skills/frontend/scripts/detect/rules/source/support/js-punctuation.ts +47 -30
  244. package/plugin/skills/frontend/scripts/detect/rules/source/support/markup-scope.ts +45 -34
  245. package/plugin/skills/frontend/scripts/detect/rules/source/support/source-color.ts +64 -29
  246. package/plugin/skills/frontend/scripts/detect/rules/source/support/source-shadow.ts +17 -10
  247. package/plugin/skills/frontend/scripts/detect/rules/source/support/source-text.ts +128 -86
  248. package/plugin/skills/frontend/scripts/detect/rules/typography/all-caps-body.ts +23 -9
  249. package/plugin/skills/frontend/scripts/detect/rules/typography/design-system-font-size.ts +27 -17
  250. package/plugin/skills/frontend/scripts/detect/rules/typography/design-system-font.ts +27 -17
  251. package/plugin/skills/frontend/scripts/detect/rules/typography/extreme-negative-tracking.ts +26 -12
  252. package/plugin/skills/frontend/scripts/detect/rules/typography/flat-type-hierarchy.ts +41 -19
  253. package/plugin/skills/frontend/scripts/detect/rules/typography/index.ts +14 -3
  254. package/plugin/skills/frontend/scripts/detect/rules/typography/italic-serif-display.ts +67 -16
  255. package/plugin/skills/frontend/scripts/detect/rules/typography/justified-text.ts +47 -25
  256. package/plugin/skills/frontend/scripts/detect/rules/typography/line-length.ts +37 -21
  257. package/plugin/skills/frontend/scripts/detect/rules/typography/oversized-h1.ts +35 -14
  258. package/plugin/skills/frontend/scripts/detect/rules/typography/overused-font.ts +83 -38
  259. package/plugin/skills/frontend/scripts/detect/rules/typography/support/drawn-enlargement.ts +68 -40
  260. package/plugin/skills/frontend/scripts/detect/rules/typography/support/fading-text.ts +59 -39
  261. package/plugin/skills/frontend/scripts/detect/rules/typography/support/flex-runs.ts +13 -8
  262. package/plugin/skills/frontend/scripts/detect/rules/typography/support/font-family.ts +68 -17
  263. package/plugin/skills/frontend/scripts/detect/rules/typography/support/painted-text.ts +173 -67
  264. package/plugin/skills/frontend/scripts/detect/rules/typography/support/svg-size.ts +56 -49
  265. package/plugin/skills/frontend/scripts/detect/rules/typography/support/text-context.ts +155 -78
  266. package/plugin/skills/frontend/scripts/detect/rules/typography/support/text-lines.ts +38 -28
  267. package/plugin/skills/frontend/scripts/detect/rules/typography/support/type-hierarchy.ts +43 -38
  268. package/plugin/skills/frontend/scripts/detect/rules/typography/tight-leading.ts +67 -39
  269. package/plugin/skills/frontend/scripts/detect/rules/typography/tiny-text.ts +34 -15
  270. package/plugin/skills/frontend/scripts/detect/rules/typography/undersized-ui-text.ts +52 -22
  271. package/plugin/skills/frontend/scripts/detect/rules/typography/wide-tracking.ts +37 -19
  272. package/plugin/skills/frontend/scripts/detect/snapshot/collect.ts +154 -145
  273. package/plugin/skills/frontend/scripts/detect/snapshot/style-props.ts +121 -21
  274. package/plugin/skills/frontend/scripts/detect/testing/build-snapshot.ts +140 -65
  275. package/plugin/skills/frontend/scripts/detect/types.ts +81 -76
  276. package/plugin/skills/frontend/scripts/perfection/accent-stripes/color.ts +205 -85
  277. package/plugin/skills/frontend/scripts/perfection/accent-stripes/css-parse.ts +97 -80
  278. package/plugin/skills/frontend/scripts/perfection/accent-stripes/declarations.ts +129 -101
  279. package/plugin/skills/frontend/scripts/perfection/accent-stripes/findings.ts +23 -23
  280. package/plugin/skills/frontend/scripts/perfection/accent-stripes/gradient.ts +43 -42
  281. package/plugin/skills/frontend/scripts/perfection/accent-stripes/lint.ts +75 -60
  282. package/plugin/skills/frontend/scripts/perfection/accent-stripes/markup.ts +131 -106
  283. package/plugin/skills/frontend/scripts/perfection/accent-stripes/selector.ts +28 -25
  284. package/plugin/skills/frontend/scripts/perfection/accent-stripes/tailwind.ts +93 -78
  285. package/plugin/skills/frontend/scripts/perfection/check-accent-stripes.ts +22 -22
  286. package/plugin/skills/frontend/scripts/perfection/check-draft-guard.ts +24 -24
  287. package/plugin/skills/frontend/scripts/perfection/collect-files.ts +49 -36
  288. package/plugin/skills/frontend/scripts/perfection/draft-guard/findings.ts +10 -9
  289. package/plugin/skills/frontend/scripts/perfection/draft-guard/lint.ts +27 -24
  290. package/plugin/skills/frontend/scripts/perfection/draft-guard/rules.ts +46 -42
  291. package/plugin/skills/frontend/scripts/perfection/draft-guard/text-nodes.ts +98 -75
  292. package/plugin/skills/lsp-setup/scripts/detect-lsp.ts +162 -152
  293. package/plugin/skills/lsp-setup/scripts/lsp-server-table.ts +164 -164
  294. package/plugin/skills/lsp-setup/scripts/verify-lsp.ts +94 -91
  295. package/plugin/skills/programming/SKILL.md +2 -2
  296. package/plugin/skills/programming/scripts/go/new-project.ts +68 -68
  297. package/plugin/skills/programming/scripts/python/new-project.ts +64 -64
  298. package/plugin/skills/programming/scripts/python/new-script.ts +39 -39
  299. package/plugin/skills/programming/scripts/rust/new-project.ts +60 -57
  300. package/plugin/skills/programming/scripts/shared/run-tool.ts +7 -7
  301. package/plugin/skills/programming/scripts/typescript/check-no-excuse-rules.ts +96 -36
  302. package/plugin/skills/programming/scripts/typescript/check-test-junk-rules.ts +38 -17
  303. package/plugin/skills/programming/scripts/typescript/check-test-junk.ts +13 -2
  304. package/plugin/skills/programming/scripts/typescript/mutation-proof.ts +16 -4
  305. package/plugin/skills/programming/scripts/typescript/new-project.ts +21 -21
  306. package/plugin/skills/ultimate-browsing/engine/templates/playwright_mobile_chrome.js +65 -62
  307. package/plugin/skills/ultimate-browsing/engine/templates/playwright_real_chrome.js +73 -70
  308. package/plugin/skills/ulw-plan/scripts/plan-templates.mjs +30 -30
  309. package/plugin/skills/ulw-plan/scripts/scaffold-plan.mjs +131 -123
  310. package/plugin/skills/ulw-research/scripts/claim-kinds.mjs +178 -67
  311. package/plugin/skills/ulw-research/scripts/claims-index.mjs +117 -93
  312. package/plugin/skills/ulw-research/scripts/cli-support.mjs +73 -73
  313. package/plugin/skills/ulw-research/scripts/contracts.mjs +604 -174
  314. package/plugin/skills/ulw-research/scripts/conversion-probe.mjs +161 -113
  315. package/plugin/skills/ulw-research/scripts/css-hiding.mjs +126 -92
  316. package/plugin/skills/ulw-research/scripts/css-lite.mjs +143 -137
  317. package/plugin/skills/ulw-research/scripts/design-spec.mjs +123 -107
  318. package/plugin/skills/ulw-research/scripts/entities.mjs +66 -30
  319. package/plugin/skills/ulw-research/scripts/entry-guard.mjs +8 -8
  320. package/plugin/skills/ulw-research/scripts/fact-commands-fill.mjs +104 -51
  321. package/plugin/skills/ulw-research/scripts/fact-commands-meaning.mjs +207 -105
  322. package/plugin/skills/ulw-research/scripts/fact-commands-polish.mjs +143 -76
  323. package/plugin/skills/ulw-research/scripts/fact-commands-verify.mjs +164 -120
  324. package/plugin/skills/ulw-research/scripts/fact-commands.mjs +264 -151
  325. package/plugin/skills/ulw-research/scripts/fact-derive.mjs +92 -48
  326. package/plugin/skills/ulw-research/scripts/fact-expr.mjs +90 -78
  327. package/plugin/skills/ulw-research/scripts/fact-fill.mjs +215 -127
  328. package/plugin/skills/ulw-research/scripts/fact-ledger-kinds.mjs +305 -131
  329. package/plugin/skills/ulw-research/scripts/fact-ledger-schema.mjs +264 -158
  330. package/plugin/skills/ulw-research/scripts/fact-ledger.mjs +93 -57
  331. package/plugin/skills/ulw-research/scripts/fact-locate.mjs +204 -147
  332. package/plugin/skills/ulw-research/scripts/fact-pairs.mjs +126 -108
  333. package/plugin/skills/ulw-research/scripts/fact-recompute.mjs +89 -66
  334. package/plugin/skills/ulw-research/scripts/fidelity-binding.mjs +101 -70
  335. package/plugin/skills/ulw-research/scripts/fidelity-brief.mjs +95 -89
  336. package/plugin/skills/ulw-research/scripts/fidelity-claims.mjs +76 -48
  337. package/plugin/skills/ulw-research/scripts/fidelity-csv.mjs +27 -27
  338. package/plugin/skills/ulw-research/scripts/fidelity-lexicon.mjs +101 -78
  339. package/plugin/skills/ulw-research/scripts/fidelity-originals.mjs +124 -77
  340. package/plugin/skills/ulw-research/scripts/fidelity-policy.mjs +132 -83
  341. package/plugin/skills/ulw-research/scripts/fidelity-records.mjs +179 -117
  342. package/plugin/skills/ulw-research/scripts/fidelity-snapshot-readability.mjs +38 -33
  343. package/plugin/skills/ulw-research/scripts/fidelity-sources.mjs +92 -54
  344. package/plugin/skills/ulw-research/scripts/fidelity-state.mjs +27 -27
  345. package/plugin/skills/ulw-research/scripts/fidelity-trace.mjs +81 -48
  346. package/plugin/skills/ulw-research/scripts/fidelity-value-unit.mjs +207 -104
  347. package/plugin/skills/ulw-research/scripts/fidelity-values.mjs +255 -154
  348. package/plugin/skills/ulw-research/scripts/format-extract-css.mjs +74 -74
  349. package/plugin/skills/ulw-research/scripts/format-extract.mjs +161 -134
  350. package/plugin/skills/ulw-research/scripts/gates-fidelity.mjs +118 -59
  351. package/plugin/skills/ulw-research/scripts/gates-figures.mjs +192 -141
  352. package/plugin/skills/ulw-research/scripts/gates-layout.mjs +119 -85
  353. package/plugin/skills/ulw-research/scripts/gates-static.mjs +109 -102
  354. package/plugin/skills/ulw-research/scripts/gates-structure.mjs +105 -86
  355. package/plugin/skills/ulw-research/scripts/gates-text.mjs +169 -113
  356. package/plugin/skills/ulw-research/scripts/html-foreign-object.mjs +39 -34
  357. package/plugin/skills/ulw-research/scripts/html-lite.mjs +230 -176
  358. package/plugin/skills/ulw-research/scripts/html-markup.mjs +150 -128
  359. package/plugin/skills/ulw-research/scripts/html-text-map.mjs +125 -96
  360. package/plugin/skills/ulw-research/scripts/layout-probe.mjs +10 -8
  361. package/plugin/skills/ulw-research/scripts/lexicon.mjs +36 -19
  362. package/plugin/skills/ulw-research/scripts/markdown-closers.mjs +85 -85
  363. package/plugin/skills/ulw-research/scripts/md-lite.mjs +133 -125
  364. package/plugin/skills/ulw-research/scripts/meaning-check.mjs +154 -123
  365. package/plugin/skills/ulw-research/scripts/number-grammar.mjs +10 -8
  366. package/plugin/skills/ulw-research/scripts/numerals.mjs +181 -137
  367. package/plugin/skills/ulw-research/scripts/outcome-start.mjs +50 -36
  368. package/plugin/skills/ulw-research/scripts/outcome.mjs +194 -153
  369. package/plugin/skills/ulw-research/scripts/particles-ko.mjs +72 -70
  370. package/plugin/skills/ulw-research/scripts/placeholder.mjs +130 -112
  371. package/plugin/skills/ulw-research/scripts/polish-apply.mjs +67 -51
  372. package/plugin/skills/ulw-research/scripts/polish-diff.mjs +10 -5
  373. package/plugin/skills/ulw-research/scripts/polish-project.mjs +67 -57
  374. package/plugin/skills/ulw-research/scripts/polish-rules.mjs +120 -100
  375. package/plugin/skills/ulw-research/scripts/rational.mjs +74 -73
  376. package/plugin/skills/ulw-research/scripts/raw-decode.mjs +74 -74
  377. package/plugin/skills/ulw-research/scripts/raw-locator.mjs +32 -24
  378. package/plugin/skills/ulw-research/scripts/repair-tracker.mjs +98 -93
  379. package/plugin/skills/ulw-research/scripts/report-tools-commands.mjs +265 -176
  380. package/plugin/skills/ulw-research/scripts/report-tools.mjs +65 -62
  381. package/plugin/skills/ulw-research/scripts/sentence-split.mjs +63 -43
  382. package/plugin/skills/ulw-research/scripts/source-commands.mjs +199 -125
  383. package/plugin/skills/ulw-research/scripts/source-refresh.mjs +91 -54
  384. package/plugin/skills/ulw-research/scripts/source-snapshot.mjs +143 -102
  385. package/plugin/skills/ulw-research/scripts/source-view.mjs +82 -46
  386. package/plugin/skills/ulw-research/scripts/sources-citation.mjs +135 -96
  387. package/plugin/skills/ulw-research/scripts/text-normalize.mjs +63 -48
  388. package/plugin/skills/ulw-research/scripts/text-similarity.mjs +15 -15
  389. package/plugin/skills/ulw-research/scripts/unit-algebra.mjs +98 -66
  390. package/plugin/skills/ulw-research/scripts/unit-errors.mjs +14 -14
  391. package/plugin/skills/ulw-research/scripts/unit-metadata.mjs +30 -14
  392. package/plugin/skills/ulw-research/scripts/unit-pairs.mjs +57 -45
  393. package/plugin/skills/ulw-research/scripts/unit-precision.mjs +39 -25
  394. package/plugin/skills/ulw-research/scripts/unit-rules-shapes.mjs +79 -44
  395. package/plugin/skills/ulw-research/scripts/unit-rules.mjs +262 -135
  396. package/plugin/skills/ulw-research/scripts/units.mjs +96 -65
  397. package/plugin/skills/visual-qa/scripts/ansi.ts +3 -6
  398. package/plugin/skills/visual-qa/scripts/cli.ts +52 -52
  399. package/plugin/skills/visual-qa/scripts/east-asian-width.ts +53 -53
  400. package/plugin/skills/visual-qa/scripts/image-diff.ts +86 -86
  401. package/plugin/skills/visual-qa/scripts/png-crc.ts +16 -16
  402. package/plugin/skills/visual-qa/scripts/png-decode.ts +167 -167
  403. package/plugin/skills/visual-qa/scripts/png-synth.ts +36 -40
  404. package/plugin/skills/visual-qa/scripts/tui-grid.ts +63 -63
  405. package/plugin/skills/visual-qa/scripts/types.ts +37 -37
  406. package/plugin/skills/visual-qa/scripts/visual-qa.mjs +268 -289
@@ -15,63 +15,83 @@ const CLOSERS = "\"')]}\u201D\u2019\u00BB\u300D\u300F"
15
15
  const KOREAN_PERIOD_ENDINGS = new Set(["\uB2E4", "\uC694"]) // da, yo (nida ends in da)
16
16
  const KOREAN_QUESTION_ENDING = "\uAE4C" // kka
17
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",
18
+ "e.g",
19
+ "i.e",
20
+ "etc",
21
+ "vs",
22
+ "cf",
23
+ "approx",
24
+ "al",
25
+ "fig",
26
+ "no",
27
+ "mr",
28
+ "mrs",
29
+ "ms",
30
+ "dr",
31
+ "prof",
32
+ "inc",
33
+ "ltd",
34
+ "jr",
35
+ "sr",
19
36
  ])
20
37
  const SPACE = /\s/u
21
38
 
22
39
  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
40
+ const prev = line[at - 1]
41
+ if (line[at] === ".") return KOREAN_PERIOD_ENDINGS.has(prev)
42
+ return line[at] === "?" && prev === KOREAN_QUESTION_ENDING
26
43
  }
27
44
 
28
45
  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)
46
+ let k = at
47
+ while (k > from && !SPACE.test(line[k - 1])) k--
48
+ const word = line
49
+ .slice(k, at)
50
+ .replace(/^[("'[]+/u, "")
51
+ .toLowerCase()
52
+ if (word === "no") return /^\s*\d/u.test(line.slice(at + 1))
53
+ return ABBREVIATIONS.has(word)
34
54
  }
35
55
 
36
56
  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 })
57
+ let start = from
58
+ let end = to
59
+ while (start < end && SPACE.test(line[start])) start++
60
+ while (end > start && SPACE.test(line[end - 1])) end--
61
+ const text = line.slice(start, end)
62
+ if (normalizeText(text) === "") return
63
+ out.push({ sid: `s${out.length + 1}`, start: base + start, end: base + end, text })
44
64
  }
45
65
 
46
66
  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)
67
+ let from = 0
68
+ for (let i = 0; i < line.length; i++) {
69
+ if (!TERMINATORS.includes(line[i])) continue
70
+ let j = i + 1
71
+ while (j < line.length && (TERMINATORS.includes(line[j]) || CLOSERS.includes(line[j]))) j++
72
+ const atBreak = j >= line.length || SPACE.test(line[j])
73
+ const closed = [...line.slice(i + 1, j)].some((c) => CLOSERS.includes(c))
74
+ const korean = !closed && isKoreanEnding(line, i)
75
+ const abbreviation = line[i] === "." && !korean && isAbbreviation(line, from, i)
76
+ if ((atBreak || korean) && !abbreviation) {
77
+ pushSegment(line, base, from, j, out)
78
+ from = j
79
+ }
80
+ i = j - 1
81
+ }
82
+ pushSegment(line, base, from, line.length, out)
63
83
  }
64
84
 
65
85
  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
86
+ const source = String(text ?? "")
87
+ const out = []
88
+ let base = 0
89
+ while (base <= source.length) {
90
+ const newline = source.indexOf("\n", base)
91
+ const stop = newline === -1 ? source.length : newline
92
+ splitLine(source.slice(base, stop), base, out)
93
+ if (newline === -1) break
94
+ base = newline + 1
95
+ }
96
+ return out
77
97
  }
@@ -28,32 +28,33 @@ import { readSnapshot } from "./source-view.mjs"
28
28
  const FETCH_TIMEOUT_MS = 30_000
29
29
  const TOOL_EXTRACTOR = "tool:source-snapshot@1"
30
30
  export const SNAPSHOT_USAGE =
31
- "usage: source probe-conversion <raw-file> <converted-file> | source snapshot --id S<n> (--url <u> | --html <file> | --raw <file> [--text <file> --extractor NAME@VERSION] | --text <file> (converted-only) | --command '<argv json>' --cwd DIR) [--charset NAME] [--kind page|command|document|converted-only] [--provenance primary|secondary] [--revision R] [--replace] --session-dir D"
31
+ "usage: source probe-conversion <raw-file> <converted-file> | source snapshot --id S<n> (--url <u> | --html <file> | --raw <file> [--text <file> --extractor NAME@VERSION] | --text <file> (converted-only) | --command '<argv json>' --cwd DIR) [--charset NAME] [--kind page|command|document|converted-only] [--provenance primary|secondary] [--revision R] [--replace] --session-dir D"
32
32
 
33
33
  function readInput(path) {
34
- try {
35
- return readFileSync(path, "utf8")
36
- } catch (error) {
37
- throw new CliError(`cannot read ${path}: ${error.code ?? error.message}`)
38
- }
34
+ try {
35
+ return readFileSync(path, "utf8")
36
+ } catch (error) {
37
+ throw new CliError(`cannot read ${path}: ${error.code ?? error.message}`)
38
+ }
39
39
  }
40
40
 
41
41
  /** The session dir from --session-dir or SESSION_DIR; a usage error when neither is set. */
42
42
  export function sessionDirOf(flags) {
43
- const dir = flags["session-dir"] ?? process.env.SESSION_DIR
44
- if (!dir || dir === true) throw new CliError("--session-dir is required (or set SESSION_DIR)")
45
- return resolve(dir)
43
+ const dir = flags["session-dir"] ?? process.env.SESSION_DIR
44
+ if (!dir || dir === true) throw new CliError("--session-dir is required (or set SESSION_DIR)")
45
+ return resolve(dir)
46
46
  }
47
47
 
48
48
  /** The snapshot as source-view.mjs reads it ({ meta, raw, sha256, drift, view }); unreadable is a usage error. */
49
49
  export function snapshotOf(sessionDir, id) {
50
- const dir = join(sessionDir, "sources", String(id))
51
- if (!existsSync(join(dir, "meta.json"))) throw new CliError(`source ${id} has no snapshot; run source snapshot --id ${id} first`)
52
- try {
53
- return readSnapshot(dir)
54
- } catch (error) {
55
- throw new CliError(`source ${id}: ${error.message}`)
56
- }
50
+ const dir = join(sessionDir, "sources", String(id))
51
+ if (!existsSync(join(dir, "meta.json")))
52
+ throw new CliError(`source ${id} has no snapshot; run source snapshot --id ${id} first`)
53
+ try {
54
+ return readSnapshot(dir)
55
+ } catch (error) {
56
+ throw new CliError(`source ${id}: ${error.message}`)
57
+ }
57
58
  }
58
59
 
59
60
  /**
@@ -61,77 +62,99 @@ export function snapshotOf(sessionDir, id) {
61
62
  * or pending floor points at nothing; a malformed floor is a usage error (parseSourceFloor's CliError).
62
63
  */
63
64
  export function pointedFlag(sessionDir, url) {
64
- const brief = join(sessionDir, "brief.md")
65
- const floor = existsSync(brief) ? (parseFidelityBlock(readInput(brief)).fields?.["source floor"] ?? "") : ""
66
- if (floor === "" || floor === "pending") return false
67
- const rule = parseSourceFloor(floor)
68
- return rule?.kind === "pointed" && rule.list.includes(url)
65
+ const brief = join(sessionDir, "brief.md")
66
+ const floor = existsSync(brief) ? (parseFidelityBlock(readInput(brief)).fields?.["source floor"] ?? "") : ""
67
+ if (floor === "" || floor === "pending") return false
68
+ const rule = parseSourceFloor(floor)
69
+ return rule?.kind === "pointed" && rule.list.includes(url)
69
70
  }
70
71
 
71
72
  async function fetchSource(url) {
72
- if (!URL.canParse(url)) throw new CliError(`--url is not a URL: ${url}`)
73
- let response
74
- try {
75
- response = await fetch(url, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) })
76
- } catch (error) {
77
- throw new CliError(`fetch failed for ${url}: ${error.message}`)
78
- }
79
- if (!response.ok) {
80
- await response.body?.cancel()
81
- throw new CliError(`fetch failed: HTTP ${response.status} for ${url}`)
82
- }
83
- const type = response.headers.get("content-type") ?? ""
84
- if (/pdf/i.test(type)) {
85
- await response.body?.cancel()
86
- throw new CliError(`pdf response: ${url}; save the bytes and use --raw <file.pdf> --text <extracted.txt> --extractor NAME@VERSION`)
87
- }
88
- const raw = Buffer.from(await response.arrayBuffer())
89
- return { url, raw, charset: headerCharset(type), markup: /html|xml/i.test(type) || /^\s*</.test(raw.subarray(0, 1024).toString("latin1")) }
73
+ if (!URL.canParse(url)) throw new CliError(`--url is not a URL: ${url}`)
74
+ let response
75
+ try {
76
+ response = await fetch(url, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) })
77
+ } catch (error) {
78
+ throw new CliError(`fetch failed for ${url}: ${error.message}`)
79
+ }
80
+ if (!response.ok) {
81
+ await response.body?.cancel()
82
+ throw new CliError(`fetch failed: HTTP ${response.status} for ${url}`)
83
+ }
84
+ const type = response.headers.get("content-type") ?? ""
85
+ if (/pdf/i.test(type)) {
86
+ await response.body?.cancel()
87
+ throw new CliError(
88
+ `pdf response: ${url}; save the bytes and use --raw <file.pdf> --text <extracted.txt> --extractor NAME@VERSION`,
89
+ )
90
+ }
91
+ const raw = Buffer.from(await response.arrayBuffer())
92
+ return {
93
+ url,
94
+ raw,
95
+ charset: headerCharset(type),
96
+ markup: /html|xml/i.test(type) || /^\s*</.test(raw.subarray(0, 1024).toString("latin1")),
97
+ }
90
98
  }
91
99
 
92
100
  function runCommand(argvJson, cwd) {
93
- let argv
94
- try {
95
- argv = JSON.parse(argvJson)
96
- } catch (error) {
97
- throw new CliError(`--command must be a JSON array of strings: ${error.message}`)
98
- }
99
- if (!Array.isArray(argv) || argv.length === 0 || !argv.every((part) => typeof part === "string" && part.length > 0)) {
100
- throw new CliError("--command must be a non-empty JSON array of non-empty strings")
101
- }
102
- if (!cwd || cwd === true) throw new CliError("--command needs --cwd DIR")
103
- const proc = spawnSync(argv[0], argv.slice(1), { cwd: resolve(cwd), shell: false, maxBuffer: 64 * 1024 * 1024 })
104
- if (proc.error) throw new CliError(`--command could not start: ${proc.error.message}`)
105
- const receipt = { argv, cwd: resolve(cwd), exit_status: proc.status, stdout_sha256: sha256Of(proc.stdout), stderr_sha256: sha256Of(proc.stderr) }
106
- return { path: `command:${argv.join(" ")}`, raw: proc.stdout, kind: "command", receipt }
101
+ let argv
102
+ try {
103
+ argv = JSON.parse(argvJson)
104
+ } catch (error) {
105
+ throw new CliError(`--command must be a JSON array of strings: ${error.message}`)
106
+ }
107
+ if (!Array.isArray(argv) || argv.length === 0 || !argv.every((part) => typeof part === "string" && part.length > 0)) {
108
+ throw new CliError("--command must be a non-empty JSON array of non-empty strings")
109
+ }
110
+ if (!cwd || cwd === true) throw new CliError("--command needs --cwd DIR")
111
+ const proc = spawnSync(argv[0], argv.slice(1), { cwd: resolve(cwd), shell: false, maxBuffer: 64 * 1024 * 1024 })
112
+ if (proc.error) throw new CliError(`--command could not start: ${proc.error.message}`)
113
+ const receipt = {
114
+ argv,
115
+ cwd: resolve(cwd),
116
+ exit_status: proc.status,
117
+ stdout_sha256: sha256Of(proc.stdout),
118
+ stderr_sha256: sha256Of(proc.stderr),
119
+ }
120
+ return { path: `command:${argv.join(" ")}`, raw: proc.stdout, kind: "command", receipt }
107
121
  }
108
122
 
109
123
  function readBytes(path) {
110
- try {
111
- return readFileSync(path)
112
- } catch (error) {
113
- throw new CliError(`cannot read ${path}: ${error.code ?? error.message}`)
114
- }
124
+ try {
125
+ return readFileSync(path)
126
+ } catch (error) {
127
+ throw new CliError(`cannot read ${path}: ${error.code ?? error.message}`)
128
+ }
115
129
  }
116
130
 
117
131
  /** The snapshot input the flags describe; shared by `source snapshot` and `source refresh`. */
118
132
  export async function acquire(flags) {
119
- const given = ["url", "html", "text", "command"].filter((name) => flags[name] !== undefined)
120
- if (flags.raw !== undefined && given.some((name) => name !== "text")) throw new CliError("--raw goes alone or with --text (--url, --html and --command already keep the raw bytes)")
121
- if (given.length + (flags.raw !== undefined && flags.text === undefined ? 1 : 0) !== 1) throw new CliError(SNAPSHOT_USAGE)
122
- if (flags.extractor !== undefined && flags.text === undefined) throw new CliError("--extractor goes with --text only")
123
- if (flags.charset !== undefined && encodingOf(flags.charset) === null) throw new CliError(`--charset ${flags.charset} is not a known encoding`)
124
- const charset = flags.charset === undefined ? {} : { charset: encodingOf(flags.charset) }
125
- if (flags.url !== undefined) return { ...(await fetchSource(flags.url)), ...charset, extractor: TOOL_EXTRACTOR }
126
- if (flags.html !== undefined) return { path: resolve(flags.html), raw: readBytes(flags.html), markup: true, ...charset, extractor: "model" }
127
- if (flags.raw !== undefined && flags.text === undefined) return { path: resolve(flags.raw), raw: readBytes(flags.raw), ...charset, extractor: "model" }
128
- if (flags.text !== undefined) {
129
- const extractor = flags.extractor === undefined ? "model" : `extractor:${flags.extractor}`
130
- if (flags.raw !== undefined) return { path: resolve(flags.raw), raw: readBytes(flags.raw), text: readInput(flags.text), ...charset, extractor }
131
- if (flags.kind !== undefined && flags.kind !== "converted-only") throw new CliError("--text without --raw registers a converted-only source; pass --raw <original bytes> to keep a measurable snapshot")
132
- return { path: resolve(flags.text), text: readInput(flags.text), kind: "converted-only", extractor }
133
- }
134
- return { ...runCommand(flags.command, flags.cwd), extractor: TOOL_EXTRACTOR }
133
+ const given = ["url", "html", "text", "command"].filter((name) => flags[name] !== undefined)
134
+ if (flags.raw !== undefined && given.some((name) => name !== "text"))
135
+ throw new CliError("--raw goes alone or with --text (--url, --html and --command already keep the raw bytes)")
136
+ if (given.length + (flags.raw !== undefined && flags.text === undefined ? 1 : 0) !== 1)
137
+ throw new CliError(SNAPSHOT_USAGE)
138
+ if (flags.extractor !== undefined && flags.text === undefined) throw new CliError("--extractor goes with --text only")
139
+ if (flags.charset !== undefined && encodingOf(flags.charset) === null)
140
+ throw new CliError(`--charset ${flags.charset} is not a known encoding`)
141
+ const charset = flags.charset === undefined ? {} : { charset: encodingOf(flags.charset) }
142
+ if (flags.url !== undefined) return { ...(await fetchSource(flags.url)), ...charset, extractor: TOOL_EXTRACTOR }
143
+ if (flags.html !== undefined)
144
+ return { path: resolve(flags.html), raw: readBytes(flags.html), markup: true, ...charset, extractor: "model" }
145
+ if (flags.raw !== undefined && flags.text === undefined)
146
+ return { path: resolve(flags.raw), raw: readBytes(flags.raw), ...charset, extractor: "model" }
147
+ if (flags.text !== undefined) {
148
+ const extractor = flags.extractor === undefined ? "model" : `extractor:${flags.extractor}`
149
+ if (flags.raw !== undefined)
150
+ return { path: resolve(flags.raw), raw: readBytes(flags.raw), text: readInput(flags.text), ...charset, extractor }
151
+ if (flags.kind !== undefined && flags.kind !== "converted-only")
152
+ throw new CliError(
153
+ "--text without --raw registers a converted-only source; pass --raw <original bytes> to keep a measurable snapshot",
154
+ )
155
+ return { path: resolve(flags.text), text: readInput(flags.text), kind: "converted-only", extractor }
156
+ }
157
+ return { ...runCommand(flags.command, flags.cwd), extractor: TOOL_EXTRACTOR }
135
158
  }
136
159
 
137
160
  /**
@@ -140,61 +163,112 @@ export async function acquire(flags) {
140
163
  * pinned; plain `--text` without `--replace`, or over an id with no raw.bin, stays converted-only.
141
164
  */
142
165
  function declareOverKeptRaw(sourcesDir, id, input) {
143
- const dir = join(sourcesDir, String(id))
144
- if (input.kind !== "converted-only" || !existsSync(join(dir, "raw.bin")) || !existsSync(join(dir, "meta.json"))) return
145
- const before = JSON.parse(readFileSync(join(dir, "meta.json"), "utf8"))
146
- const raw = readFileSync(join(dir, "raw.bin"))
147
- if (sha256Of(raw) !== before.sha256) throw new CliError(`snapshot_hash_mismatch: ${id} raw.bin no longer matches its pinned hash`)
148
- Object.assign(input, { url: before.url, raw, kind: before.kind, observed_at: before.observed_at, declared: true })
149
- delete input.path
166
+ const dir = join(sourcesDir, String(id))
167
+ if (input.kind !== "converted-only" || !existsSync(join(dir, "raw.bin")) || !existsSync(join(dir, "meta.json")))
168
+ return
169
+ const before = JSON.parse(readFileSync(join(dir, "meta.json"), "utf8"))
170
+ const raw = readFileSync(join(dir, "raw.bin"))
171
+ if (sha256Of(raw) !== before.sha256)
172
+ throw new CliError(`snapshot_hash_mismatch: ${id} raw.bin no longer matches its pinned hash`)
173
+ Object.assign(input, { url: before.url, raw, kind: before.kind, observed_at: before.observed_at, declared: true })
174
+ delete input.path
150
175
  }
151
176
 
152
177
  export async function runSource(argv) {
153
- const [sub, ...rest] = argv
154
- if (sub === "refresh") return (await import("./source-refresh.mjs")).runRefresh(rest)
155
- if (sub === "probe-conversion") return runConversionProbe(rest)
156
- if (sub !== "snapshot") throw new CliError(SNAPSHOT_USAGE)
157
- const args = parseArgs(rest, { booleans: ["replace"] })
158
- const id = args.required("id")
159
- const sessionDir = sessionDirOf(args.flags)
160
- const sourcesDir = join(sessionDir, "sources")
161
- const replace = args.flags.replace === true
162
- const pinned = replace ? readLedger(sessionDir).rows.filter((row) => row.source_id === id && (row.status ?? "active") === "active").map((row) => row.fact_id) : []
163
- if (pinned.length > 0) {
164
- const message = `${id} is cited by active row(s) ${pinned.join(", ")}; retract them first, or snapshot the corrected text under a new id`
165
- return { json: { command: "source snapshot", status: "fail", exitCode: 1, error: "snapshot_pinned", message, rows: pinned }, summary: `source snapshot: ${message}`, exitCode: 1 }
166
- }
167
- const { receipt, ...input } = await acquire(args.flags)
168
- if (replace) declareOverKeptRaw(sourcesDir, id, input)
169
- if (args.flags.kind !== undefined) input.kind = args.flags.kind
170
- if (args.flags.provenance !== undefined) input.provenance = args.flags.provenance
171
- if (args.flags.revision !== undefined) input.revision = args.flags.revision
172
- let written
173
- try {
174
- written = writeSnapshot(sourcesDir, id, input, { replace })
175
- } catch (error) {
176
- if (String(error.message).startsWith("snapshot_exists")) {
177
- return { json: { command: "source snapshot", status: "fail", exitCode: 1, error: "snapshot_exists", message: error.message }, summary: `source snapshot: ${error.message}`, exitCode: 1 }
178
- }
179
- if (error instanceof TypeError) throw new CliError(error.message)
180
- throw error
181
- }
182
- if (receipt) writeFileSync(join(written.dir, "command.json"), `${JSON.stringify(receipt, null, 2)}\n`)
183
- const meta = JSON.parse(readFileSync(join(written.dir, "meta.json"), "utf8"))
184
- const data = { source_id: id, directory: written.dir, snapshot_sha256: written.sha256, extractor: meta.extractor, kind: meta.kind, provenance: meta.provenance, text_source: meta.text_source, ...(written.altered ? { conversion_altered_numbers: written.altered } : {}) }
185
- const probe = written.altered ? `; conversion ${written.altered.length} altered${written.altered.length ? ` (${written.altered.join(", ")}): fact add refuses those numbers` : ""}` : ""
186
- return { json: { command: "source snapshot", status: "pass", exitCode: 0, data }, summary: `source snapshot: ${id} ${written.sha256.slice(0, 12)} (${meta.extractor}, ${meta.text_source})${probe}`, exitCode: 0 }
178
+ const [sub, ...rest] = argv
179
+ if (sub === "refresh") return (await import("./source-refresh.mjs")).runRefresh(rest)
180
+ if (sub === "probe-conversion") return runConversionProbe(rest)
181
+ if (sub !== "snapshot") throw new CliError(SNAPSHOT_USAGE)
182
+ const args = parseArgs(rest, { booleans: ["replace"] })
183
+ const id = args.required("id")
184
+ const sessionDir = sessionDirOf(args.flags)
185
+ const sourcesDir = join(sessionDir, "sources")
186
+ const replace = args.flags.replace === true
187
+ const pinned = replace
188
+ ? readLedger(sessionDir)
189
+ .rows.filter((row) => row.source_id === id && (row.status ?? "active") === "active")
190
+ .map((row) => row.fact_id)
191
+ : []
192
+ if (pinned.length > 0) {
193
+ const message = `${id} is cited by active row(s) ${pinned.join(", ")}; retract them first, or snapshot the corrected text under a new id`
194
+ return {
195
+ json: {
196
+ command: "source snapshot",
197
+ status: "fail",
198
+ exitCode: 1,
199
+ error: "snapshot_pinned",
200
+ message,
201
+ rows: pinned,
202
+ },
203
+ summary: `source snapshot: ${message}`,
204
+ exitCode: 1,
205
+ }
206
+ }
207
+ const { receipt, ...input } = await acquire(args.flags)
208
+ if (replace) declareOverKeptRaw(sourcesDir, id, input)
209
+ if (args.flags.kind !== undefined) input.kind = args.flags.kind
210
+ if (args.flags.provenance !== undefined) input.provenance = args.flags.provenance
211
+ if (args.flags.revision !== undefined) input.revision = args.flags.revision
212
+ let written
213
+ try {
214
+ written = writeSnapshot(sourcesDir, id, input, { replace })
215
+ } catch (error) {
216
+ if (String(error.message).startsWith("snapshot_exists")) {
217
+ return {
218
+ json: {
219
+ command: "source snapshot",
220
+ status: "fail",
221
+ exitCode: 1,
222
+ error: "snapshot_exists",
223
+ message: error.message,
224
+ },
225
+ summary: `source snapshot: ${error.message}`,
226
+ exitCode: 1,
227
+ }
228
+ }
229
+ if (error instanceof TypeError) throw new CliError(error.message)
230
+ throw error
231
+ }
232
+ if (receipt) writeFileSync(join(written.dir, "command.json"), `${JSON.stringify(receipt, null, 2)}\n`)
233
+ const meta = JSON.parse(readFileSync(join(written.dir, "meta.json"), "utf8"))
234
+ const data = {
235
+ source_id: id,
236
+ directory: written.dir,
237
+ snapshot_sha256: written.sha256,
238
+ extractor: meta.extractor,
239
+ kind: meta.kind,
240
+ provenance: meta.provenance,
241
+ text_source: meta.text_source,
242
+ ...(written.altered ? { conversion_altered_numbers: written.altered } : {}),
243
+ }
244
+ const probe = written.altered
245
+ ? `; conversion ${written.altered.length} altered${written.altered.length ? ` (${written.altered.join(", ")}): fact add refuses those numbers` : ""}`
246
+ : ""
247
+ return {
248
+ json: { command: "source snapshot", status: "pass", exitCode: 0, data },
249
+ summary: `source snapshot: ${id} ${written.sha256.slice(0, 12)} (${meta.extractor}, ${meta.text_source})${probe}`,
250
+ exitCode: 0,
251
+ }
187
252
  }
188
253
 
189
254
  export function runClaims(argv) {
190
- const [sub, ...rest] = argv
191
- const args = parseArgs(rest)
192
- const [graph] = args.positionals
193
- if (sub !== "index" || !graph) throw new CliError("usage: claims index <claim-graph.md> --out claims.json")
194
- const out = args.required("out")
195
- const index = indexClaims(readInput(graph))
196
- if (index.errors.length > 0) throw new CliError(`claims index ${graph}: ${index.errors.join("; ")}`)
197
- writeJsonAtomic(out, { schemaVersion: 1, graph: resolve(graph), graph_sha256: sha256Of(readFileSync(graph)), ...index })
198
- const verified = index.claims.filter((claim) => claim.in_verified).length
199
- return { json: { command: "claims index", out: resolve(out), claims: index.claims.length, verified }, summary: `claims index: ${index.claims.length} claim(s), ${verified} verified`, exitCode: 0 }
255
+ const [sub, ...rest] = argv
256
+ const args = parseArgs(rest)
257
+ const [graph] = args.positionals
258
+ if (sub !== "index" || !graph) throw new CliError("usage: claims index <claim-graph.md> --out claims.json")
259
+ const out = args.required("out")
260
+ const index = indexClaims(readInput(graph))
261
+ if (index.errors.length > 0) throw new CliError(`claims index ${graph}: ${index.errors.join("; ")}`)
262
+ writeJsonAtomic(out, {
263
+ schemaVersion: 1,
264
+ graph: resolve(graph),
265
+ graph_sha256: sha256Of(readFileSync(graph)),
266
+ ...index,
267
+ })
268
+ const verified = index.claims.filter((claim) => claim.in_verified).length
269
+ return {
270
+ json: { command: "claims index", out: resolve(out), claims: index.claims.length, verified },
271
+ summary: `claims index: ${index.claims.length} claim(s), ${verified} verified`,
272
+ exitCode: 0,
273
+ }
200
274
  }