@bastani/atomic 0.9.20-alpha.4 → 0.9.20-alpha.6

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 (474) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +37 -0
  3. package/dist/builtin/intercom/CHANGELOG.md +16 -0
  4. package/dist/builtin/intercom/broker/broker.ts +110 -39
  5. package/dist/builtin/intercom/broker/client.ts +8 -1
  6. package/dist/builtin/intercom/index.bundle.mjs +61 -2
  7. package/dist/builtin/intercom/live-route-refusal.ts +69 -0
  8. package/dist/builtin/intercom/package.json +2 -2
  9. package/dist/builtin/intercom/recoverable-disconnect.ts +16 -4
  10. package/dist/builtin/intercom/skills/intercom/SKILL.md +43 -12
  11. package/dist/builtin/intercom/types.ts +3 -1
  12. package/dist/builtin/mcp/package.json +2 -2
  13. package/dist/builtin/subagents/CHANGELOG.md +18 -0
  14. package/dist/builtin/subagents/README.md +2 -0
  15. package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
  16. package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
  17. package/dist/builtin/subagents/agents/codebase-online-researcher.md +3 -3
  18. package/dist/builtin/subagents/agents/debugger.md +7 -5
  19. package/dist/builtin/subagents/agents/worker.md +4 -2
  20. package/dist/builtin/subagents/package.json +3 -3
  21. package/dist/builtin/subagents/skills/agent-browser/SKILL.md +56 -0
  22. package/dist/builtin/subagents/skills/cua-driver/BROWSER.md +494 -0
  23. package/dist/builtin/subagents/skills/cua-driver/EMBEDDING.md +578 -0
  24. package/dist/builtin/subagents/skills/cua-driver/LINUX.md +364 -0
  25. package/dist/builtin/subagents/skills/cua-driver/MACOS.md +509 -0
  26. package/dist/builtin/subagents/skills/cua-driver/README.md +113 -0
  27. package/dist/builtin/subagents/skills/cua-driver/RECORDING.md +162 -0
  28. package/dist/builtin/subagents/skills/cua-driver/SKILL.md +1105 -0
  29. package/dist/builtin/subagents/skills/cua-driver/WINDOWS.md +866 -0
  30. package/dist/builtin/subagents/skills/subagent/SKILL.md +32 -8
  31. package/dist/builtin/subagents/src/extension/index.bundle.mjs +7 -4
  32. package/dist/builtin/web-access/package.json +2 -2
  33. package/dist/builtin/workflows/CHANGELOG.md +43 -0
  34. package/dist/builtin/workflows/README.md +4 -2
  35. package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
  36. package/dist/builtin/workflows/builtin/{chunk-1dydq7w3.js → chunk-2hzrv5y8.js} +202 -45
  37. package/dist/builtin/workflows/builtin/{chunk-n4yxrsm9.js → chunk-3tx8ry44.js} +3 -2
  38. package/dist/builtin/workflows/builtin/{chunk-n8g2da69.js → chunk-5724b0cf.js} +1 -1
  39. package/dist/builtin/workflows/builtin/{chunk-scgprmdj.js → chunk-7n51c5gh.js} +1 -1
  40. package/dist/builtin/workflows/builtin/{chunk-9y0f90rd.js → chunk-9z3ztr2a.js} +1 -1
  41. package/dist/builtin/workflows/builtin/{chunk-vt9zgr9d.js → chunk-deq63d9p.js} +4 -4
  42. package/dist/builtin/workflows/builtin/{chunk-k18g9me8.js → chunk-dxjxtgmp.js} +1 -1
  43. package/dist/builtin/workflows/builtin/{chunk-kf5xpbkz.js → chunk-ffdrv23t.js} +1 -1
  44. package/dist/builtin/workflows/builtin/{chunk-119kxb28.js → chunk-hmt5w62g.js} +72 -45
  45. package/dist/builtin/workflows/builtin/{chunk-hnbbb5r0.js → chunk-jngsbbpm.js} +4 -4
  46. package/dist/builtin/workflows/builtin/{chunk-d1xqh1rd.js → chunk-njmf5ze7.js} +1 -1
  47. package/dist/builtin/workflows/builtin/{chunk-sn5mchnx.js → chunk-vn0wb31x.js} +1 -1
  48. package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
  49. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
  50. package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
  51. package/dist/builtin/workflows/builtin/goal.js +4 -4
  52. package/dist/builtin/workflows/builtin/index.d.ts +1 -1
  53. package/dist/builtin/workflows/builtin/index.js +12 -12
  54. package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
  55. package/dist/builtin/workflows/builtin/open-claude-design.d.ts +1 -1
  56. package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
  57. package/dist/builtin/workflows/builtin/ralph.js +4 -4
  58. package/dist/builtin/workflows/builtin/steering-context.js +1 -1
  59. package/dist/builtin/workflows/builtin/tournament.js +3 -3
  60. package/dist/builtin/workflows/package.json +2 -2
  61. package/dist/builtin/workflows/skills/impeccable/SKILL.md +18 -11
  62. package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -1
  63. package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +1 -1
  64. package/dist/builtin/workflows/skills/impeccable/reference/animate.md +1 -1
  65. package/dist/builtin/workflows/skills/impeccable/reference/audit.md +5 -5
  66. package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +6 -6
  67. package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +2 -2
  68. package/dist/builtin/workflows/skills/impeccable/reference/clarify.md +1 -1
  69. package/dist/builtin/workflows/skills/impeccable/reference/colorize.md +1 -1
  70. package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +0 -6
  71. package/dist/builtin/workflows/skills/impeccable/reference/critique.md +19 -41
  72. package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +11 -65
  73. package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +3 -3
  74. package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +4 -4
  75. package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +1 -1
  76. package/dist/builtin/workflows/skills/impeccable/reference/delight.md +1 -1
  77. package/dist/builtin/workflows/skills/impeccable/reference/distill.md +2 -2
  78. package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +4 -4
  79. package/dist/builtin/workflows/skills/impeccable/reference/document.md +4 -4
  80. package/dist/builtin/workflows/skills/impeccable/reference/extract.md +1 -1
  81. package/dist/builtin/workflows/skills/impeccable/reference/harden.md +1 -1
  82. package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +21 -21
  83. package/dist/builtin/workflows/skills/impeccable/reference/init.md +8 -8
  84. package/dist/builtin/workflows/skills/impeccable/reference/layout.md +2 -2
  85. package/dist/builtin/workflows/skills/impeccable/reference/live-setup.md +10 -8
  86. package/dist/builtin/workflows/skills/impeccable/reference/live.md +39 -38
  87. package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +48 -21
  88. package/dist/builtin/workflows/skills/impeccable/reference/onboard.md +1 -1
  89. package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +1 -1
  90. package/dist/builtin/workflows/skills/impeccable/reference/overdrive.md +1 -1
  91. package/dist/builtin/workflows/skills/impeccable/reference/polish.md +11 -3
  92. package/dist/builtin/workflows/skills/impeccable/reference/quieter.md +2 -2
  93. package/dist/builtin/workflows/skills/impeccable/reference/routing.md +13 -7
  94. package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +2 -2
  95. package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +13 -19
  96. package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -0
  97. package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index-failures.json +121 -0
  98. package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index.json +1 -0
  99. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +212 -0
  100. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +218 -0
  101. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-dom.js +21 -0
  102. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +242 -0
  103. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +25 -4
  104. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +666 -197
  105. package/dist/builtin/workflows/skills/research-codebase/SKILL.md +1 -1
  106. package/dist/builtin/workflows/src/extension/index.bundle.mjs +352 -117
  107. package/dist/builtin/workflows/src/index.js +1403 -1218
  108. package/dist/cli/args.d.ts.map +1 -1
  109. package/dist/cli/args.js +15 -4
  110. package/dist/cli/args.js.map +1 -1
  111. package/dist/cli/file-processor.d.ts +1 -1
  112. package/dist/cli/file-processor.d.ts.map +1 -1
  113. package/dist/cli/file-processor.js.map +1 -1
  114. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  115. package/dist/core/agent-session-auto-compaction.js +40 -12
  116. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  117. package/dist/core/agent-session-bash.d.ts.map +1 -1
  118. package/dist/core/agent-session-bash.js +9 -8
  119. package/dist/core/agent-session-bash.js.map +1 -1
  120. package/dist/core/agent-session-boundaries.d.ts +68 -0
  121. package/dist/core/agent-session-boundaries.d.ts.map +1 -0
  122. package/dist/core/agent-session-boundaries.js +334 -0
  123. package/dist/core/agent-session-boundaries.js.map +1 -0
  124. package/dist/core/agent-session-compaction.js +1 -1
  125. package/dist/core/agent-session-compaction.js.map +1 -1
  126. package/dist/core/agent-session-events.d.ts.map +1 -1
  127. package/dist/core/agent-session-events.js +27 -13
  128. package/dist/core/agent-session-events.js.map +1 -1
  129. package/dist/core/agent-session-export.d.ts.map +1 -1
  130. package/dist/core/agent-session-export.js +16 -20
  131. package/dist/core/agent-session-export.js.map +1 -1
  132. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  133. package/dist/core/agent-session-message-queue.js +3 -2
  134. package/dist/core/agent-session-message-queue.js.map +1 -1
  135. package/dist/core/agent-session-methods.d.ts +30 -4
  136. package/dist/core/agent-session-methods.d.ts.map +1 -1
  137. package/dist/core/agent-session-methods.js.map +1 -1
  138. package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
  139. package/dist/core/agent-session-persistent-custom-messages.js +2 -1
  140. package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
  141. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  142. package/dist/core/agent-session-prompt.js +93 -25
  143. package/dist/core/agent-session-prompt.js.map +1 -1
  144. package/dist/core/agent-session-retry.d.ts.map +1 -1
  145. package/dist/core/agent-session-retry.js +4 -9
  146. package/dist/core/agent-session-retry.js.map +1 -1
  147. package/dist/core/agent-session-runtime.js +1 -1
  148. package/dist/core/agent-session-runtime.js.map +1 -1
  149. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  150. package/dist/core/agent-session-tool-hooks.js +15 -5
  151. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  152. package/dist/core/agent-session-tree.d.ts.map +1 -1
  153. package/dist/core/agent-session-tree.js +2 -3
  154. package/dist/core/agent-session-tree.js.map +1 -1
  155. package/dist/core/agent-session-types.d.ts +6 -0
  156. package/dist/core/agent-session-types.d.ts.map +1 -1
  157. package/dist/core/agent-session-types.js.map +1 -1
  158. package/dist/core/agent-session.d.ts +15 -2
  159. package/dist/core/agent-session.d.ts.map +1 -1
  160. package/dist/core/agent-session.js +17 -1
  161. package/dist/core/agent-session.js.map +1 -1
  162. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  163. package/dist/core/compaction/branch-summarization.js +1 -0
  164. package/dist/core/compaction/branch-summarization.js.map +1 -1
  165. package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
  166. package/dist/core/compaction/compaction-boundary.js +11 -6
  167. package/dist/core/compaction/compaction-boundary.js.map +1 -1
  168. package/dist/core/compaction/compaction.d.ts +3 -1
  169. package/dist/core/compaction/compaction.d.ts.map +1 -1
  170. package/dist/core/compaction/compaction.js +37 -0
  171. package/dist/core/compaction/compaction.js.map +1 -1
  172. package/dist/core/crash-log.d.ts +6 -0
  173. package/dist/core/crash-log.d.ts.map +1 -0
  174. package/dist/core/crash-log.js +69 -0
  175. package/dist/core/crash-log.js.map +1 -0
  176. package/dist/core/execution-model-router.d.ts +3 -0
  177. package/dist/core/execution-model-router.d.ts.map +1 -1
  178. package/dist/core/execution-model-router.js +45 -16
  179. package/dist/core/execution-model-router.js.map +1 -1
  180. package/dist/core/export-html/template-js/tree-filter-render.js +6 -1
  181. package/dist/core/export-html/template.js +6 -1
  182. package/dist/core/extensions/agent-events.d.ts +69 -3
  183. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  184. package/dist/core/extensions/agent-events.js.map +1 -1
  185. package/dist/core/extensions/api-types.d.ts +5 -3
  186. package/dist/core/extensions/api-types.d.ts.map +1 -1
  187. package/dist/core/extensions/api-types.js.map +1 -1
  188. package/dist/core/extensions/event-results.d.ts +3 -0
  189. package/dist/core/extensions/event-results.d.ts.map +1 -1
  190. package/dist/core/extensions/event-results.js.map +1 -1
  191. package/dist/core/extensions/event-types.d.ts +2 -2
  192. package/dist/core/extensions/event-types.d.ts.map +1 -1
  193. package/dist/core/extensions/event-types.js.map +1 -1
  194. package/dist/core/extensions/index.d.ts +1 -1
  195. package/dist/core/extensions/index.d.ts.map +1 -1
  196. package/dist/core/extensions/index.js.map +1 -1
  197. package/dist/core/extensions/provider-types.d.ts +2 -0
  198. package/dist/core/extensions/provider-types.d.ts.map +1 -1
  199. package/dist/core/extensions/provider-types.js.map +1 -1
  200. package/dist/core/extensions/runner-events.d.ts +16 -2
  201. package/dist/core/extensions/runner-events.d.ts.map +1 -1
  202. package/dist/core/extensions/runner-events.js +98 -5
  203. package/dist/core/extensions/runner-events.js.map +1 -1
  204. package/dist/core/extensions/runner.d.ts +3 -2
  205. package/dist/core/extensions/runner.d.ts.map +1 -1
  206. package/dist/core/extensions/runner.js +4 -1
  207. package/dist/core/extensions/runner.js.map +1 -1
  208. package/dist/core/index.d.ts +1 -1
  209. package/dist/core/index.d.ts.map +1 -1
  210. package/dist/core/index.js.map +1 -1
  211. package/dist/core/messages.d.ts +10 -0
  212. package/dist/core/messages.d.ts.map +1 -1
  213. package/dist/core/messages.js +57 -0
  214. package/dist/core/messages.js.map +1 -1
  215. package/dist/core/model-config.d.ts +52 -0
  216. package/dist/core/model-config.d.ts.map +1 -1
  217. package/dist/core/model-config.js +16 -0
  218. package/dist/core/model-config.js.map +1 -1
  219. package/dist/core/model-resolver-defaults.d.ts.map +1 -1
  220. package/dist/core/model-resolver-defaults.js +2 -1
  221. package/dist/core/model-resolver-defaults.js.map +1 -1
  222. package/dist/core/model-routing-task.d.ts +1 -1
  223. package/dist/core/model-routing-task.d.ts.map +1 -1
  224. package/dist/core/model-routing-task.js +4 -3
  225. package/dist/core/model-routing-task.js.map +1 -1
  226. package/dist/core/prompt-templates-async.d.ts +2 -2
  227. package/dist/core/prompt-templates-async.d.ts.map +1 -1
  228. package/dist/core/prompt-templates-async.js +57 -29
  229. package/dist/core/prompt-templates-async.js.map +1 -1
  230. package/dist/core/prompt-templates.d.ts +6 -1
  231. package/dist/core/prompt-templates.d.ts.map +1 -1
  232. package/dist/core/prompt-templates.js +61 -35
  233. package/dist/core/prompt-templates.js.map +1 -1
  234. package/dist/core/provider-composer-internal.d.ts +1 -0
  235. package/dist/core/provider-composer-internal.d.ts.map +1 -1
  236. package/dist/core/provider-composer-internal.js +19 -0
  237. package/dist/core/provider-composer-internal.js.map +1 -1
  238. package/dist/core/resource-loader-assets.d.ts.map +1 -1
  239. package/dist/core/resource-loader-assets.js +6 -6
  240. package/dist/core/resource-loader-assets.js.map +1 -1
  241. package/dist/core/sdk.js +3 -2
  242. package/dist/core/sdk.js.map +1 -1
  243. package/dist/core/session-manager-core.d.ts +10 -3
  244. package/dist/core/session-manager-core.d.ts.map +1 -1
  245. package/dist/core/session-manager-core.js +65 -7
  246. package/dist/core/session-manager-core.js.map +1 -1
  247. package/dist/core/session-manager-entries.d.ts +4 -1
  248. package/dist/core/session-manager-entries.d.ts.map +1 -1
  249. package/dist/core/session-manager-entries.js +8 -0
  250. package/dist/core/session-manager-entries.js.map +1 -1
  251. package/dist/core/session-manager-history.d.ts +16 -1
  252. package/dist/core/session-manager-history.d.ts.map +1 -1
  253. package/dist/core/session-manager-history.js +105 -42
  254. package/dist/core/session-manager-history.js.map +1 -1
  255. package/dist/core/session-manager-types.d.ts +30 -3
  256. package/dist/core/session-manager-types.d.ts.map +1 -1
  257. package/dist/core/session-manager-types.js.map +1 -1
  258. package/dist/core/session-manager.d.ts +2 -2
  259. package/dist/core/session-manager.d.ts.map +1 -1
  260. package/dist/core/session-manager.js +1 -1
  261. package/dist/core/session-manager.js.map +1 -1
  262. package/dist/core/structured-output/index.d.ts +0 -1
  263. package/dist/core/structured-output/index.d.ts.map +1 -1
  264. package/dist/core/structured-output/index.js +3 -15
  265. package/dist/core/structured-output/index.js.map +1 -1
  266. package/dist/core/structured-output/jev-client.d.ts +4 -8
  267. package/dist/core/structured-output/jev-client.d.ts.map +1 -1
  268. package/dist/core/structured-output/jev-client.js +36 -32
  269. package/dist/core/structured-output/jev-client.js.map +1 -1
  270. package/dist/core/structured-output/jev.d.ts.map +1 -1
  271. package/dist/core/structured-output/jev.js +4 -12
  272. package/dist/core/structured-output/jev.js.map +1 -1
  273. package/dist/core/structured-output/types.d.ts +0 -2
  274. package/dist/core/structured-output/types.d.ts.map +1 -1
  275. package/dist/core/structured-output/types.js.map +1 -1
  276. package/dist/core/system-prompt.d.ts.map +1 -1
  277. package/dist/core/system-prompt.js +2 -1
  278. package/dist/core/system-prompt.js.map +1 -1
  279. package/dist/core/tools/read.d.ts +4 -0
  280. package/dist/core/tools/read.d.ts.map +1 -1
  281. package/dist/core/tools/read.js +5 -1
  282. package/dist/core/tools/read.js.map +1 -1
  283. package/dist/index-extensions.d.ts +1 -1
  284. package/dist/index-extensions.d.ts.map +1 -1
  285. package/dist/index-extensions.js.map +1 -1
  286. package/dist/index.d.ts +3 -3
  287. package/dist/index.d.ts.map +1 -1
  288. package/dist/index.js +3 -3
  289. package/dist/index.js.map +1 -1
  290. package/dist/main-app-mode.d.ts +1 -1
  291. package/dist/main-app-mode.d.ts.map +1 -1
  292. package/dist/main-app-mode.js +3 -2
  293. package/dist/main-app-mode.js.map +1 -1
  294. package/dist/main.d.ts.map +1 -1
  295. package/dist/main.js +1 -1
  296. package/dist/main.js.map +1 -1
  297. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  298. package/dist/modes/interactive/components/chat-message-renderer.js +4 -0
  299. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  300. package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
  301. package/dist/modes/interactive/components/tree-selector-content.js +6 -0
  302. package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
  303. package/dist/modes/interactive/components/tree-selector-model.d.ts.map +1 -1
  304. package/dist/modes/interactive/components/tree-selector-model.js +1 -0
  305. package/dist/modes/interactive/components/tree-selector-model.js.map +1 -1
  306. package/dist/modes/interactive/interactive-agent-events.js +17 -1
  307. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  308. package/dist/modes/interactive/interactive-mode-helpers.d.ts +1 -0
  309. package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
  310. package/dist/modes/interactive/interactive-mode-helpers.js +16 -0
  311. package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
  312. package/dist/modes/interactive/interactive-mode-surface.d.ts +1 -0
  313. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  314. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  315. package/dist/modes/interactive/interactive-process-lifecycle.js +13 -1
  316. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  317. package/dist/modes/interactive/interactive-session-runtime.js +5 -1
  318. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  319. package/dist/utils/mime.js +1 -1
  320. package/dist/utils/mime.js.map +1 -1
  321. package/dist/utils/tool-result-images.d.ts +3 -1
  322. package/dist/utils/tool-result-images.d.ts.map +1 -1
  323. package/dist/utils/tool-result-images.js +4 -1
  324. package/dist/utils/tool-result-images.js.map +1 -1
  325. package/docs/compaction.md +5 -1
  326. package/docs/computer-use.md +123 -73
  327. package/docs/extensions/events.md +75 -7
  328. package/docs/extensions.md +6 -2
  329. package/docs/getting-started/first-session.md +3 -2
  330. package/docs/getting-started/installation.md +6 -2
  331. package/docs/intercom/operations.md +13 -1
  332. package/docs/intercom.md +7 -2
  333. package/docs/models/evals.md +68 -82
  334. package/docs/models/model-selection.md +11 -7
  335. package/docs/models/reference.md +30 -2
  336. package/docs/packages.md +2 -0
  337. package/docs/prompt-templates.md +1 -0
  338. package/docs/providers.md +8 -2
  339. package/docs/quickstart.md +1 -1
  340. package/docs/sdk/reference.md +1 -2
  341. package/docs/sdk/structured-decisions.md +10 -9
  342. package/docs/sdk.md +13 -2
  343. package/docs/session-format.md +17 -2
  344. package/docs/settings.md +1 -1
  345. package/docs/skills.md +3 -1
  346. package/docs/subagents/reference.md +6 -6
  347. package/docs/subagents.md +8 -2
  348. package/docs/usage.md +2 -0
  349. package/docs/windows.md +1 -1
  350. package/docs/workflows/api-reference.md +5 -4
  351. package/docs/workflows/authoring.md +191 -0
  352. package/docs/workflows/builtins.md +2 -2
  353. package/docs/workflows/operations.md +10 -4
  354. package/docs/workflows/reliable-design.md +12 -1
  355. package/docs/workflows/verification.md +27 -14
  356. package/npm-shrinkwrap.json +69 -69
  357. package/package.json +8 -8
  358. package/dist/builtin/subagents/skills/playwright-cli/SKILL.md +0 -420
  359. package/dist/builtin/subagents/skills/playwright-cli/references/element-attributes.md +0 -23
  360. package/dist/builtin/subagents/skills/playwright-cli/references/playwright-tests.md +0 -39
  361. package/dist/builtin/subagents/skills/playwright-cli/references/request-mocking.md +0 -87
  362. package/dist/builtin/subagents/skills/playwright-cli/references/running-code.md +0 -241
  363. package/dist/builtin/subagents/skills/playwright-cli/references/session-management.md +0 -225
  364. package/dist/builtin/subagents/skills/playwright-cli/references/storage-state.md +0 -275
  365. package/dist/builtin/subagents/skills/playwright-cli/references/test-generation.md +0 -433
  366. package/dist/builtin/subagents/skills/playwright-cli/references/tracing.md +0 -139
  367. package/dist/builtin/subagents/skills/playwright-cli/references/video-recording.md +0 -143
  368. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_asset_producer.toml +0 -94
  369. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_documenter.toml +0 -27
  370. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_finish_reviewer.toml +0 -41
  371. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_manual_edit_applier.toml +0 -95
  372. package/dist/builtin/workflows/skills/impeccable/agents/openai.yaml +0 -4
  373. package/dist/builtin/workflows/skills/impeccable/scripts/concept-seed.mjs +0 -695
  374. package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +0 -325
  375. package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +0 -1503
  376. package/dist/builtin/workflows/skills/impeccable/scripts/critique-storage.mjs +0 -222
  377. package/dist/builtin/workflows/skills/impeccable/scripts/detect-csp.mjs +0 -198
  378. package/dist/builtin/workflows/skills/impeccable/scripts/detect.mjs +0 -21
  379. package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +0 -2073
  380. package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +0 -432
  381. package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +0 -1121
  382. package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +0 -8746
  383. package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns.mjs +0 -51
  384. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +0 -376
  385. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +0 -1168
  386. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +0 -1192
  387. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +0 -290
  388. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +0 -189
  389. package/dist/builtin/workflows/skills/impeccable/scripts/detector/findings.mjs +0 -18
  390. package/dist/builtin/workflows/skills/impeccable/scripts/detector/node/file-system.mjs +0 -213
  391. package/dist/builtin/workflows/skills/impeccable/scripts/detector/profile/profiler.mjs +0 -166
  392. package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +0 -617
  393. package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +0 -5534
  394. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/color.mjs +0 -588
  395. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/constants.mjs +0 -112
  396. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +0 -30
  397. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/inline-ignores.mjs +0 -148
  398. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +0 -35
  399. package/dist/builtin/workflows/skills/impeccable/scripts/doctor.mjs +0 -338
  400. package/dist/builtin/workflows/skills/impeccable/scripts/embed-prompt.mjs +0 -270
  401. package/dist/builtin/workflows/skills/impeccable/scripts/generate-image.mjs +0 -277
  402. package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +0 -783
  403. package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +0 -2305
  404. package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +0 -78
  405. package/dist/builtin/workflows/skills/impeccable/scripts/lib/artifact-schema.mjs +0 -93
  406. package/dist/builtin/workflows/skills/impeccable/scripts/lib/composition-catalog.mjs +0 -200
  407. package/dist/builtin/workflows/skills/impeccable/scripts/lib/concept-catalog.mjs +0 -395
  408. package/dist/builtin/workflows/skills/impeccable/scripts/lib/design-parser.mjs +0 -925
  409. package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +0 -640
  410. package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-paths.mjs +0 -137
  411. package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +0 -72
  412. package/dist/builtin/workflows/skills/impeccable/scripts/lib/open-system-browser.mjs +0 -57
  413. package/dist/builtin/workflows/skills/impeccable/scripts/lib/provider.mjs +0 -5
  414. package/dist/builtin/workflows/skills/impeccable/scripts/lib/roll-selection.mjs +0 -369
  415. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-deep.mjs +0 -483
  416. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-notice.mjs +0 -169
  417. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness.mjs +0 -528
  418. package/dist/builtin/workflows/skills/impeccable/scripts/lib/surface-briefs.mjs +0 -151
  419. package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-args.mjs +0 -42
  420. package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-slug.mjs +0 -33
  421. package/dist/builtin/workflows/skills/impeccable/scripts/lib/template-extensions.mjs +0 -146
  422. package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-css.mjs +0 -617
  423. package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-verify.mjs +0 -71
  424. package/dist/builtin/workflows/skills/impeccable/scripts/live/browser-script-parts.mjs +0 -77
  425. package/dist/builtin/workflows/skills/impeccable/scripts/live/completion.mjs +0 -28
  426. package/dist/builtin/workflows/skills/impeccable/scripts/live/event-validation.mjs +0 -199
  427. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/astro.mjs +0 -47
  428. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/detect-utils.mjs +0 -157
  429. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/index.mjs +0 -143
  430. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/journal.mjs +0 -205
  431. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nextjs.mjs +0 -49
  432. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nuxt.mjs +0 -170
  433. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/script-src.mjs +0 -26
  434. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/static-html.mjs +0 -26
  435. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/sveltekit.mjs +0 -71
  436. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tag-strategy.mjs +0 -247
  437. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tanstack-start.mjs +0 -70
  438. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/vite-generic.mjs +0 -42
  439. package/dist/builtin/workflows/skills/impeccable/scripts/live/generation-preflight.mjs +0 -149
  440. package/dist/builtin/workflows/skills/impeccable/scripts/live/insert-ui.mjs +0 -458
  441. package/dist/builtin/workflows/skills/impeccable/scripts/live/instructions.mjs +0 -169
  442. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-apply.mjs +0 -939
  443. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edit-routes.mjs +0 -357
  444. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edits-buffer.mjs +0 -152
  445. package/dist/builtin/workflows/skills/impeccable/scripts/live/poll-lanes.mjs +0 -14
  446. package/dist/builtin/workflows/skills/impeccable/scripts/live/roots.mjs +0 -670
  447. package/dist/builtin/workflows/skills/impeccable/scripts/live/session-store.mjs +0 -563
  448. package/dist/builtin/workflows/skills/impeccable/scripts/live/source-lock.mjs +0 -105
  449. package/dist/builtin/workflows/skills/impeccable/scripts/live/source-search.mjs +0 -105
  450. package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-ast.mjs +0 -969
  451. package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +0 -1401
  452. package/dist/builtin/workflows/skills/impeccable/scripts/live/sveltekit-adapter.mjs +0 -314
  453. package/dist/builtin/workflows/skills/impeccable/scripts/live/tanstack-adapter.mjs +0 -280
  454. package/dist/builtin/workflows/skills/impeccable/scripts/live/ui-surfaces.mjs +0 -75
  455. package/dist/builtin/workflows/skills/impeccable/scripts/live/vocabulary.mjs +0 -171
  456. package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +0 -961
  457. package/dist/builtin/workflows/skills/impeccable/scripts/live-commit-manual-edits.mjs +0 -1244
  458. package/dist/builtin/workflows/skills/impeccable/scripts/live-complete.mjs +0 -107
  459. package/dist/builtin/workflows/skills/impeccable/scripts/live-copy-edit-agent.mjs +0 -800
  460. package/dist/builtin/workflows/skills/impeccable/scripts/live-discard-manual-edits.mjs +0 -51
  461. package/dist/builtin/workflows/skills/impeccable/scripts/live-inject.mjs +0 -515
  462. package/dist/builtin/workflows/skills/impeccable/scripts/live-insert.mjs +0 -292
  463. package/dist/builtin/workflows/skills/impeccable/scripts/live-manual-edit-evidence.mjs +0 -371
  464. package/dist/builtin/workflows/skills/impeccable/scripts/live-poll.mjs +0 -427
  465. package/dist/builtin/workflows/skills/impeccable/scripts/live-resume.mjs +0 -123
  466. package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +0 -1675
  467. package/dist/builtin/workflows/skills/impeccable/scripts/live-status.mjs +0 -71
  468. package/dist/builtin/workflows/skills/impeccable/scripts/live-target.mjs +0 -30
  469. package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +0 -927
  470. package/dist/builtin/workflows/skills/impeccable/scripts/live.mjs +0 -365
  471. package/dist/builtin/workflows/skills/impeccable/scripts/palette.mjs +0 -628
  472. package/dist/builtin/workflows/skills/impeccable/scripts/pin.mjs +0 -224
  473. package/dist/builtin/workflows/skills/impeccable/scripts/serve-question.mjs +0 -1540
  474. package/dist/builtin/workflows/skills/impeccable/scripts/surface-brief.mjs +0 -74
@@ -1,588 +0,0 @@
1
- // ─── Section 2: Color Utilities ─────────────────────────────────────────────
2
-
3
- function isNeutralColor(color) {
4
- if (!color || color === 'transparent') return true;
5
-
6
- // rgb/rgba — use channel spread. Threshold 30 ≈ 11.7% of the 0–255 range.
7
- const rgb = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
8
- if (rgb) {
9
- return (Math.max(+rgb[1], +rgb[2], +rgb[3]) - Math.min(+rgb[1], +rgb[2], +rgb[3])) < 30;
10
- }
11
-
12
- // oklch()/lch() — chroma is the second numeric component.
13
- // oklch chroma is ~0–0.4 in sRGB gamut; >= 0.02 reads as tinted, not gray.
14
- // lch chroma is ~0–150; >= 3 reads as tinted. jsdom emits both formats
15
- // literally (it does NOT convert them to rgb).
16
- const oklch = color.match(/oklch\(\s*[\d.]+%?\s*([\d.-]+)/i);
17
- if (oklch) return parseFloat(oklch[1]) < 0.02;
18
- const lch = color.match(/lch\(\s*[\d.]+%?\s*([\d.-]+)/i);
19
- if (lch) return parseFloat(lch[1]) < 3;
20
-
21
- // oklab()/lab() — a and b are signed axes; chroma = sqrt(a² + b²).
22
- // oklab a/b are ~-0.4..0.4, threshold 0.02. lab a/b are ~-128..127, threshold 3.
23
- const oklab = color.match(/oklab\(\s*[\d.]+%?\s*([\d.-]+)\s+([\d.-]+)/i);
24
- if (oklab) {
25
- const a = parseFloat(oklab[1]), b = parseFloat(oklab[2]);
26
- return Math.hypot(a, b) < 0.02;
27
- }
28
- const lab = color.match(/lab\(\s*[\d.]+%?\s*([\d.-]+)\s+([\d.-]+)/i);
29
- if (lab) {
30
- const a = parseFloat(lab[1]), b = parseFloat(lab[2]);
31
- return Math.hypot(a, b) < 3;
32
- }
33
-
34
- // hsl/hsla — saturation is the second numeric component (percent).
35
- // Modern jsdom usually converts hsl() to rgb, but handle it directly for
36
- // safety across versions and for any engine that preserves the format.
37
- const hsl = color.match(/hsla?\(\s*[\d.-]+\s*,?\s*([\d.]+)%/i);
38
- if (hsl) return parseFloat(hsl[1]) < 10;
39
-
40
- // hwb(hue whiteness% blackness%) — a pixel is fully gray when
41
- // whiteness + blackness >= 100; chroma-like saturation = 1 - (w+b)/100.
42
- const hwb = color.match(/hwb\(\s*[\d.-]+\s+([\d.]+)%\s+([\d.]+)%/i);
43
- if (hwb) {
44
- const w = parseFloat(hwb[1]), b = parseFloat(hwb[2]);
45
- return (1 - Math.min(100, w + b) / 100) < 0.1;
46
- }
47
-
48
- // Unknown / unrecognized format — err on the side of DETECTING rather
49
- // than silently skipping. This is the opposite of the previous default,
50
- // which was the root cause of the oklch bug.
51
- return false;
52
- }
53
-
54
- function parseRgb(color) {
55
- if (!color || color === 'transparent') return null;
56
- const m = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
57
- if (!m) return null;
58
- return { r: +m[1], g: +m[2], b: +m[3], a: m[4] !== undefined ? +m[4] : 1 };
59
- }
60
-
61
- function relativeLuminance({ r, g, b }) {
62
- const [rs, gs, bs] = [r / 255, g / 255, b / 255].map(c =>
63
- c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4
64
- );
65
- return 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
66
- }
67
-
68
- function contrastRatio(c1, c2) {
69
- const l1 = relativeLuminance(c1);
70
- const l2 = relativeLuminance(c2);
71
- return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
72
- }
73
-
74
- // The CSS color functions worth pulling out of a longer declaration. The set
75
- // is deliberately closed: `linear-gradient(` and `url(` also look like
76
- // `name(` and must not be read as colors.
77
- const COLOR_FUNCTION_NAMES = new Set([
78
- 'rgb', 'rgba', 'hsl', 'hsla', 'hwb', 'oklch', 'oklab', 'lch', 'lab', 'color', 'color-mix',
79
- ]);
80
-
81
- // Pull every color-function token out of a value, with balanced-paren capture
82
- // so nested forms (`color-mix(in oklab, oklch(...) 20%, transparent)`) survive
83
- // whole. Returns the raw substrings in source order.
84
- function extractColorFunctionTokens(value) {
85
- const str = String(value || '');
86
- const tokens = [];
87
- const re = /([a-z][a-z-]*)\(/gi;
88
- let m;
89
- while ((m = re.exec(str)) !== null) {
90
- if (!COLOR_FUNCTION_NAMES.has(m[1].toLowerCase())) continue;
91
- let depth = 0, end = -1;
92
- for (let i = m.index + m[0].length - 1; i < str.length; i++) {
93
- if (str[i] === '(') depth++;
94
- else if (str[i] === ')') { depth--; if (depth === 0) { end = i; break; } }
95
- }
96
- if (end < 0) break;
97
- tokens.push(str.slice(m.index, end + 1));
98
- re.lastIndex = end + 1;
99
- }
100
- return tokens;
101
- }
102
-
103
- function parseGradientColors(bgImage) {
104
- if (!bgImage || !bgImage.includes('gradient')) return [];
105
- const colors = [];
106
- // Stops arrive in whatever syntax the author wrote and the browser kept.
107
- // A dark ground painted as `linear-gradient(oklch(...), oklch(...))` used
108
- // to read as a gradient with no stops at all.
109
- for (const token of extractColorFunctionTokens(bgImage)) {
110
- const c = parseAnyColor(token);
111
- if (c) colors.push(c);
112
- }
113
- for (const m of bgImage.matchAll(/#([0-9a-f]{6}|[0-9a-f]{3})\b/gi)) {
114
- const h = m[1];
115
- if (h.length === 6) {
116
- colors.push({ r: parseInt(h.slice(0,2),16), g: parseInt(h.slice(2,4),16), b: parseInt(h.slice(4,6),16), a: 1 });
117
- } else {
118
- colors.push({ r: parseInt(h[0]+h[0],16), g: parseInt(h[1]+h[1],16), b: parseInt(h[2]+h[2],16), a: 1 });
119
- }
120
- }
121
- return colors;
122
- }
123
-
124
- function hasChroma(c, threshold = 30) {
125
- if (!c) return false;
126
- return (Math.max(c.r, c.g, c.b) - Math.min(c.r, c.g, c.b)) >= threshold;
127
- }
128
-
129
- function getHue(c) {
130
- if (!c) return 0;
131
- const r = c.r / 255, g = c.g / 255, b = c.b / 255;
132
- const max = Math.max(r, g, b), min = Math.min(r, g, b);
133
- if (max === min) return 0;
134
- const d = max - min;
135
- let h;
136
- if (max === r) h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
137
- else if (max === g) h = ((b - r) / d + 2) / 6;
138
- else h = ((r - g) / d + 4) / 6;
139
- return Math.round(h * 360);
140
- }
141
-
142
- function colorToHex(c) {
143
- if (!c) return '?';
144
- return '#' + [c.r, c.g, c.b].map(v => v.toString(16).padStart(2, '0')).join('');
145
- }
146
-
147
- // ─── Color-space conversions ────────────────────────────────────────────────
148
- //
149
- // Every function here lands on 8-bit sRGB, clamped to gamut. Chrome, Safari,
150
- // and Firefox all keep the authored color space in getComputedStyle output
151
- // (`oklch(0.84 0.19 80.46)`, `lch(20 5 60)`, `color(srgb 1.04 0.72 -0.21)`),
152
- // so a detector that only reads rgb() is blind on any modern palette. The
153
- // expected outputs are pinned in tests/detect-antipatterns.test.js against
154
- // what Chrome itself paints for the same strings.
155
-
156
- function clamp01(x) {
157
- return Number.isFinite(x) ? Math.max(0, Math.min(1, x)) : 0;
158
- }
159
-
160
- // Linear-light sRGB channel to the encoded 0-255 value.
161
- function encodeSrgbChannel(x) {
162
- const c = clamp01(x);
163
- return Math.round((c <= 0.0031308 ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - 0.055) * 255);
164
- }
165
-
166
- function decodeSrgbChannel(x) {
167
- const c = Number.isFinite(x) ? x : 0;
168
- const sign = c < 0 ? -1 : 1;
169
- const abs = Math.abs(c);
170
- return sign * (abs <= 0.04045 ? abs / 12.92 : Math.pow((abs + 0.055) / 1.055, 2.4));
171
- }
172
-
173
- function linearSrgbToColor(r, g, b, a = 1) {
174
- return { r: encodeSrgbChannel(r), g: encodeSrgbChannel(g), b: encodeSrgbChannel(b), a };
175
- }
176
-
177
- // OKLab to sRGB (Björn Ottosson's matrices). L in 0..1, a/b are signed axes.
178
- function oklabToRgb(L, a, b) {
179
- const l_ = L + 0.3963377774 * a + 0.2158037573 * b;
180
- const m_ = L - 0.1055613458 * a - 0.0638541728 * b;
181
- const s_ = L - 0.0894841775 * a - 1.2914855480 * b;
182
- const lc = l_ * l_ * l_, mc = m_ * m_ * m_, sc = s_ * s_ * s_;
183
- return linearSrgbToColor(
184
- 4.0767416621 * lc - 3.3077115913 * mc + 0.2309699292 * sc,
185
- -1.2684380046 * lc + 2.6097574011 * mc - 0.3413193965 * sc,
186
- -0.0041960863 * lc - 0.7034186147 * mc + 1.7076147010 * sc,
187
- );
188
- }
189
-
190
- // OKLCH to sRGB. L in 0..1, C in 0..~0.4 typical, H in degrees. Chroma past
191
- // the sRGB gamut clamps per channel rather than producing NaN.
192
- function oklchToRgb(L, C, H) {
193
- const hRad = (H * Math.PI) / 180;
194
- return oklabToRgb(L, C * Math.cos(hRad), C * Math.sin(hRad));
195
- }
196
-
197
- // CIE Lab to sRGB. CSS lab()/lch() use the D50 white point; the matrix below
198
- // is the Bradford-adapted XYZ-D50 to linear-sRGB transform from CSS Color 4.
199
- function labToRgb(L, a, b) {
200
- const kappa = 24389 / 27, epsilon = 216 / 24389;
201
- const fy = (L + 16) / 116, fx = fy + a / 500, fz = fy - b / 200;
202
- const invert = (t) => (t * t * t > epsilon ? t * t * t : (116 * t - 16) / kappa);
203
- const yr = L > kappa * epsilon ? Math.pow((L + 16) / 116, 3) : L / kappa;
204
- const Xn = 0.3457 / 0.3585, Zn = (1 - 0.3457 - 0.3585) / 0.3585;
205
- const x = invert(fx) * Xn, y = yr, z = invert(fz) * Zn;
206
- return linearSrgbToColor(
207
- 3.1341359569958707 * x - 1.6173863321612538 * y - 0.4906619460083532 * z,
208
- -0.9787955029120890 * x + 1.9162545672595240 * y + 0.0334427311613195 * z,
209
- 0.0719553798841168 * x - 0.2289768264158322 * y + 1.4053860583241250 * z,
210
- );
211
- }
212
-
213
- function lchToRgb(L, C, H) {
214
- const hRad = (H * Math.PI) / 180;
215
- return labToRgb(L, C * Math.cos(hRad), C * Math.sin(hRad));
216
- }
217
-
218
- // color(<space> c1 c2 c3) for the spaces that turn up in real stylesheets.
219
- // `srgb` is what Chrome serializes most color-mix() results into, routinely
220
- // with channels outside 0..1. Spaces we do not model return null so callers
221
- // abstain instead of measuring against a color we invented.
222
- function colorFunctionToRgb(space, c1, c2, c3) {
223
- switch (space) {
224
- case 'srgb':
225
- return { r: Math.round(clamp01(c1) * 255), g: Math.round(clamp01(c2) * 255), b: Math.round(clamp01(c3) * 255), a: 1 };
226
- case 'srgb-linear':
227
- return linearSrgbToColor(c1, c2, c3);
228
- case 'display-p3': {
229
- const [R, G, B] = [decodeSrgbChannel(c1), decodeSrgbChannel(c2), decodeSrgbChannel(c3)];
230
- return linearSrgbToColor(
231
- 1.2249401762805587 * R - 0.2249404646817506 * G + 0.0000002884022551 * B,
232
- -0.0420569547096138 * R + 1.0420571661298634 * G - 0.0000002113202247 * B,
233
- -0.0196375587040044 * R - 0.0786360772174755 * G + 1.0982736359214800 * B,
234
- );
235
- }
236
- default:
237
- return null;
238
- }
239
- }
240
-
241
- function hslToRgb(h, s, l) {
242
- h = ((h % 360) + 360) % 360;
243
- const c = (1 - Math.abs(2 * l - 1)) * s;
244
- const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
245
- const m0 = l - c / 2;
246
- const [r, g, b] =
247
- h < 60 ? [c, x, 0] :
248
- h < 120 ? [x, c, 0] :
249
- h < 180 ? [0, c, x] :
250
- h < 240 ? [0, x, c] :
251
- h < 300 ? [x, 0, c] : [c, 0, x];
252
- return {
253
- r: Math.round((r + m0) * 255),
254
- g: Math.round((g + m0) * 255),
255
- b: Math.round((b + m0) * 255),
256
- a: 1,
257
- };
258
- }
259
-
260
- function hwbToRgb(h, w, bl) {
261
- if (w + bl >= 1) {
262
- const g = Math.round((w / (w + bl)) * 255);
263
- return { r: g, g, b: g, a: 1 };
264
- }
265
- const base = hslToRgb(h, 1, 0.5);
266
- const mix = (c) => Math.round(((c / 255) * (1 - w - bl) + w) * 255);
267
- return { r: mix(base.r), g: mix(base.g), b: mix(base.b), a: 1 };
268
- }
269
-
270
- // Common CSS named colors — the handful that actually show up in generated
271
- // UIs, not the full 148-name spec list. Includes the achromatic names so a
272
- // named gray parses (and correctly reads as no-chroma) instead of being
273
- // treated as an unknown color.
274
- const CSS_NAMED_COLORS = {
275
- black: { r: 0, g: 0, b: 0 },
276
- white: { r: 255, g: 255, b: 255 },
277
- gray: { r: 128, g: 128, b: 128 },
278
- grey: { r: 128, g: 128, b: 128 },
279
- silver: { r: 192, g: 192, b: 192 },
280
- dimgray: { r: 105, g: 105, b: 105 },
281
- darkgray: { r: 169, g: 169, b: 169 },
282
- lightgray: { r: 211, g: 211, b: 211 },
283
- gainsboro: { r: 220, g: 220, b: 220 },
284
- whitesmoke: { r: 245, g: 245, b: 245 },
285
- red: { r: 255, g: 0, b: 0 },
286
- crimson: { r: 220, g: 20, b: 60 },
287
- tomato: { r: 255, g: 99, b: 71 },
288
- coral: { r: 255, g: 127, b: 80 },
289
- salmon: { r: 250, g: 128, b: 114 },
290
- orange: { r: 255, g: 165, b: 0 },
291
- gold: { r: 255, g: 215, b: 0 },
292
- yellow: { r: 255, g: 255, b: 0 },
293
- olive: { r: 128, g: 128, b: 0 },
294
- lime: { r: 0, g: 255, b: 0 },
295
- green: { r: 0, g: 128, b: 0 },
296
- teal: { r: 0, g: 128, b: 128 },
297
- turquoise: { r: 64, g: 224, b: 208 },
298
- cyan: { r: 0, g: 255, b: 255 },
299
- aqua: { r: 0, g: 255, b: 255 },
300
- skyblue: { r: 135, g: 206, b: 235 },
301
- dodgerblue: { r: 30, g: 144, b: 255 },
302
- blue: { r: 0, g: 0, b: 255 },
303
- navy: { r: 0, g: 0, b: 128 },
304
- indigo: { r: 75, g: 0, b: 130 },
305
- rebeccapurple: { r: 102, g: 51, b: 153 },
306
- purple: { r: 128, g: 0, b: 128 },
307
- violet: { r: 238, g: 130, b: 238 },
308
- orchid: { r: 218, g: 112, b: 214 },
309
- magenta: { r: 255, g: 0, b: 255 },
310
- fuchsia: { r: 255, g: 0, b: 255 },
311
- hotpink: { r: 255, g: 105, b: 180 },
312
- pink: { r: 255, g: 192, b: 203 },
313
- maroon: { r: 128, g: 0, b: 0 },
314
- };
315
-
316
- // Split a string on top-level commas (ignoring commas nested in parens).
317
- function splitTopLevelCommas(str) {
318
- const parts = [];
319
- let depth = 0, start = 0;
320
- for (let i = 0; i < str.length; i++) {
321
- const ch = str[i];
322
- if (ch === '(') depth++;
323
- else if (ch === ')') depth = Math.max(0, depth - 1);
324
- else if (ch === ',' && depth === 0) {
325
- parts.push(str.slice(start, i).trim());
326
- start = i + 1;
327
- }
328
- }
329
- const tail = str.slice(start).trim();
330
- if (tail) parts.push(tail);
331
- return parts;
332
- }
333
-
334
- // Evaluate a CSS color-mix() expression to {r,g,b,a}. Returns null when
335
- // the expression can't be resolved (unresolved var(), unknown colors).
336
- //
337
- // Mixing is done with premultiplied alpha in sRGB regardless of the
338
- // declared interpolation space. That is exact for the dominant generated-UI
339
- // pattern — `color-mix(in oklab, <color> N%, transparent)` — where the
340
- // result is simply <color> at alpha N% in ANY rectangular space, and a
341
- // close-enough approximation for opaque-opaque mixes (the detector only
342
- // consumes these values for contrast/chroma thresholds, not for display).
343
- function parseColorMix(str) {
344
- const m = String(str).trim().match(/^color-mix\(/i);
345
- if (!m) return null;
346
- // Balanced-paren capture of the arguments.
347
- let depth = 0, end = -1;
348
- const open = str.indexOf('(');
349
- for (let i = open; i < str.length; i++) {
350
- if (str[i] === '(') depth++;
351
- else if (str[i] === ')') { depth--; if (depth === 0) { end = i; break; } }
352
- }
353
- if (end < 0) return null;
354
- const args = splitTopLevelCommas(str.slice(open + 1, end));
355
- if (args.length !== 3 || !/^in\s/i.test(args[0])) return null;
356
-
357
- const parseComponent = (component) => {
358
- // Percentage may lead or trail the color per spec.
359
- let pct = null;
360
- let colorStr = component;
361
- const trail = component.match(/\s+([\d.]+)%$/);
362
- const lead = component.match(/^([\d.]+)%\s+/);
363
- if (trail) { pct = parseFloat(trail[1]); colorStr = component.slice(0, trail.index).trim(); }
364
- else if (lead) { pct = parseFloat(lead[1]); colorStr = component.slice(lead[0].length).trim(); }
365
- let color;
366
- if (/^transparent$/i.test(colorStr)) color = { r: 0, g: 0, b: 0, a: 0 };
367
- else color = parseAnyColor(colorStr);
368
- if (!color) return null;
369
- return { color, pct };
370
- };
371
-
372
- const c1 = parseComponent(args[1]);
373
- const c2 = parseComponent(args[2]);
374
- if (!c1 || !c2) return null;
375
- let p1 = c1.pct, p2 = c2.pct;
376
- if (p1 == null && p2 == null) { p1 = 50; p2 = 50; }
377
- else if (p1 == null) p1 = 100 - p2;
378
- else if (p2 == null) p2 = 100 - p1;
379
- const sum = p1 + p2;
380
- if (sum <= 0) return null;
381
- // Per spec: weights normalize to sum; when sum < 100 the result alpha is
382
- // additionally scaled by sum/100.
383
- const w1 = p1 / sum, w2 = p2 / sum;
384
- const alphaScale = sum < 100 ? sum / 100 : 1;
385
- const a1 = c1.color.a ?? 1, a2 = c2.color.a ?? 1;
386
- const a = (a1 * w1 + a2 * w2) * alphaScale;
387
- if (a <= 0) return { r: 0, g: 0, b: 0, a: 0 };
388
- const mix = (ch) => Math.round((c1.color[ch] * a1 * w1 + c2.color[ch] * a2 * w2) / (a1 * w1 + a2 * w2));
389
- return { r: mix('r'), g: mix('g'), b: mix('b'), a: Math.min(1, a) };
390
- }
391
-
392
- // Composite a translucent color over an opaque(ish) base (simple
393
- // source-over in sRGB). Returns an opaque {r,g,b,a:1}.
394
- function compositeColorOver(top, base) {
395
- const a = top.a ?? 1;
396
- return {
397
- r: Math.round(top.r * a + base.r * (1 - a)),
398
- g: Math.round(top.g * a + base.g * (1 - a)),
399
- b: Math.round(top.b * a + base.b * (1 - a)),
400
- a: 1,
401
- };
402
- }
403
-
404
- // A color() / lab() / lch() component: a bare number, a percentage against
405
- // `scale`, or the `none` keyword (which resolves to zero for our purposes).
406
- function parseColorComponent(token, scale = 1) {
407
- if (token == null) return null;
408
- const t = String(token).trim();
409
- if (/^none$/i.test(t)) return 0;
410
- const num = parseFloat(t);
411
- if (!Number.isFinite(num)) return null;
412
- return t.endsWith('%') ? (num / 100) * scale : num;
413
- }
414
-
415
- function parseAlphaToken(token) {
416
- if (token == null) return 1;
417
- const t = String(token).trim();
418
- if (/^none$/i.test(t)) return 1;
419
- const num = parseFloat(t);
420
- if (!Number.isFinite(num)) return 1;
421
- return t.endsWith('%') ? num / 100 : num;
422
- }
423
-
424
- // Extended color parser: rgb/rgba/hex/oklch/oklab/lch/lab/hsl/hwb/color()/
425
- // color-mix/common named colors. Returns null on no match. Use this when the
426
- // input might be any CSS color form; use plain parseRgb when you only expect
427
- // computed rgb() values from real browsers.
428
- function parseAnyColor(s) {
429
- if (!s || typeof s !== 'string') return null;
430
- const str = s.trim();
431
- if (str === 'transparent' || str === 'currentcolor' || str === 'inherit') return null;
432
- if (/^color-mix\(/i.test(str)) return parseColorMix(str);
433
- let m;
434
- m = str.match(/rgba?\(\s*(\d+(?:\.\d+)?)\s*,?\s*(\d+(?:\.\d+)?)\s*,?\s*(\d+(?:\.\d+)?)(?:\s*[,/]\s*([\d.]+)(%)?)?\s*\)/);
435
- if (m) {
436
- const c = { r: Math.round(+m[1]), g: Math.round(+m[2]), b: Math.round(+m[3]), a: 1 };
437
- if (m[4] !== undefined) c.a = m[5] === '%' ? parseFloat(m[4]) / 100 : +m[4];
438
- return c;
439
- }
440
- m = str.match(/^#([0-9a-f]{3,8})$/i);
441
- if (m) {
442
- const h = m[1];
443
- if (h.length === 3 || h.length === 4) {
444
- return {
445
- r: parseInt(h[0] + h[0], 16),
446
- g: parseInt(h[1] + h[1], 16),
447
- b: parseInt(h[2] + h[2], 16),
448
- a: h.length === 4 ? parseInt(h[3] + h[3], 16) / 255 : 1,
449
- };
450
- }
451
- if (h.length === 6 || h.length === 8) {
452
- return {
453
- r: parseInt(h.slice(0, 2), 16),
454
- g: parseInt(h.slice(2, 4), 16),
455
- b: parseInt(h.slice(4, 6), 16),
456
- a: h.length === 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1,
457
- };
458
- }
459
- }
460
- // OKLCH parser. Tailwind v4's CSS minifier squishes the space after
461
- // `%` ("21.5%.02 50"), so the separator between L and C may be absent.
462
- // Match L (with optional %), then C and H separated permissively.
463
- m = str.match(/oklch\(\s*([\d.]+)(%?)\s*[\s,]*\s*([\d.]+)\s*[\s,]+\s*([-\d.]+)(?:deg)?(?:\s*\/\s*([\d.]+)(%)?)?\s*\)/i);
464
- if (m) {
465
- const Lnum = parseFloat(m[1]);
466
- const L = m[2] === '%' ? Lnum / 100 : Lnum;
467
- const rgb = oklchToRgb(L, parseFloat(m[3]), parseFloat(m[4]));
468
- if (m[5] !== undefined) {
469
- const alpha = parseFloat(m[5]);
470
- rgb.a = m[6] === '%' ? alpha / 100 : alpha;
471
- }
472
- return rgb;
473
- }
474
- // OKLAB — a/b are signed axes; percentages map 100% → 0.4.
475
- m = str.match(/oklab\(\s*([\d.]+)(%?)\s+(-?[\d.]+)(%?)\s+(-?[\d.]+)(%?)(?:\s*\/\s*([\d.]+)(%)?)?\s*\)/i);
476
- if (m) {
477
- const L = m[2] === '%' ? parseFloat(m[1]) / 100 : parseFloat(m[1]);
478
- const a = m[4] === '%' ? parseFloat(m[3]) * 0.004 : parseFloat(m[3]);
479
- const b = m[6] === '%' ? parseFloat(m[5]) * 0.004 : parseFloat(m[5]);
480
- const rgb = oklabToRgb(L, a, b);
481
- if (m[7] !== undefined) {
482
- const alpha = parseFloat(m[7]);
483
- rgb.a = m[8] === '%' ? alpha / 100 : alpha;
484
- }
485
- return rgb;
486
- }
487
- // LCH / LAB — CIE, D50 white point. Chrome serializes lch(20% 5 60) as
488
- // `lch(20 5 60)`, so L arrives with or without its percent sign. In both
489
- // spaces L runs 0..100 and 100% means 100.
490
- m = str.match(/^lch\(\s*([\d.]+%?|none)\s+([\d.]+%?|none)\s+(-?[\d.]+)(?:deg)?(?:\s*\/\s*([\d.]+%?|none))?\s*\)$/i);
491
- if (m) {
492
- const L = parseColorComponent(m[1], 100);
493
- const C = parseColorComponent(m[2], 150);
494
- const H = parseFloat(m[3]);
495
- if (L == null || C == null || !Number.isFinite(H)) return null;
496
- const rgb = lchToRgb(L, C, H);
497
- rgb.a = parseAlphaToken(m[4]);
498
- return rgb;
499
- }
500
- m = str.match(/^lab\(\s*([\d.]+%?|none)\s+(-?[\d.]+%?|none)\s+(-?[\d.]+%?|none)(?:\s*\/\s*([\d.]+%?|none))?\s*\)$/i);
501
- if (m) {
502
- const L = parseColorComponent(m[1], 100);
503
- const a = parseColorComponent(m[2], 125);
504
- const b = parseColorComponent(m[3], 125);
505
- if (L == null || a == null || b == null) return null;
506
- const rgb = labToRgb(L, a, b);
507
- rgb.a = parseAlphaToken(m[4]);
508
- return rgb;
509
- }
510
- // color(<space> c1 c2 c3 [/ alpha]) — what Chrome hands back for most
511
- // color-mix() results and for any wide-gamut color an author wrote.
512
- m = str.match(/^color\(\s*([a-z0-9-]+)\s+(-?[\d.eE+-]+%?|none)\s+(-?[\d.eE+-]+%?|none)\s+(-?[\d.eE+-]+%?|none)(?:\s*\/\s*([\d.]+%?|none))?\s*\)$/i);
513
- if (m) {
514
- const c1 = parseColorComponent(m[2]);
515
- const c2 = parseColorComponent(m[3]);
516
- const c3 = parseColorComponent(m[4]);
517
- if (c1 == null || c2 == null || c3 == null) return null;
518
- const rgb = colorFunctionToRgb(m[1].toLowerCase(), c1, c2, c3);
519
- if (!rgb) return null;
520
- rgb.a = parseAlphaToken(m[5]);
521
- return rgb;
522
- }
523
- // HSL/HSLA — comma or space syntax, optional deg on hue.
524
- m = str.match(/hsla?\(\s*(-?[\d.]+)(?:deg)?\s*[,\s]\s*([\d.]+)%\s*[,\s]\s*([\d.]+)%(?:\s*[,/]\s*([\d.]+)(%)?)?\s*\)/i);
525
- if (m) {
526
- const rgb = hslToRgb(parseFloat(m[1]), parseFloat(m[2]) / 100, parseFloat(m[3]) / 100);
527
- if (m[4] !== undefined) {
528
- const alpha = parseFloat(m[4]);
529
- rgb.a = m[5] === '%' ? alpha / 100 : alpha;
530
- }
531
- return rgb;
532
- }
533
- // HWB — hue whiteness% blackness%.
534
- m = str.match(/hwb\(\s*(-?[\d.]+)(?:deg)?\s+([\d.]+)%\s+([\d.]+)%(?:\s*\/\s*([\d.]+)(%)?)?\s*\)/i);
535
- if (m) {
536
- const rgb = hwbToRgb(parseFloat(m[1]), parseFloat(m[2]) / 100, parseFloat(m[3]) / 100);
537
- if (m[4] !== undefined) {
538
- const alpha = parseFloat(m[4]);
539
- rgb.a = m[5] === '%' ? alpha / 100 : alpha;
540
- }
541
- return rgb;
542
- }
543
- const named = CSS_NAMED_COLORS[str.toLowerCase()];
544
- if (named) return { ...named, a: 1 };
545
- return null;
546
- }
547
-
548
- // True when a computed background-color string names no paint at all. Used to
549
- // tell "this layer is see-through" (walk on to the ancestor) apart from "this
550
- // layer has a color we could not read" (stop and abstain).
551
- //
552
- // `inherit` belongs here even though it is not literally see-through: it means
553
- // "paint with the parent's background-color", and walking on to the parent IS
554
- // that resolution. Real browsers resolve the keyword before getComputedStyle
555
- // output; only jsdom's partial cascade hands it through verbatim, and treating
556
- // it as unreadable would make the walk abstain on a surface it can know.
557
- // (`currentcolor` is NOT here — it is real paint in the element's own text
558
- // color; resolveBackgroundInfo substitutes the computed color for it.)
559
- function isNoPaintColorValue(value) {
560
- const v = String(value || '').trim().toLowerCase();
561
- if (!v) return true;
562
- return v === 'transparent' || v === 'none' || v === 'initial' || v === 'inherit' || v === 'unset' || v === 'revert' || v === 'revert-layer';
563
- }
564
-
565
- export {
566
- isNeutralColor,
567
- parseRgb,
568
- relativeLuminance,
569
- contrastRatio,
570
- parseGradientColors,
571
- extractColorFunctionTokens,
572
- hasChroma,
573
- getHue,
574
- colorToHex,
575
- oklabToRgb,
576
- oklchToRgb,
577
- labToRgb,
578
- lchToRgb,
579
- colorFunctionToRgb,
580
- hslToRgb,
581
- hwbToRgb,
582
- CSS_NAMED_COLORS,
583
- splitTopLevelCommas,
584
- parseColorMix,
585
- parseAnyColor,
586
- compositeColorOver,
587
- isNoPaintColorValue,
588
- };