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

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 (245) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/intercom/skills/intercom/SKILL.md +32 -1
  5. package/dist/builtin/mcp/package.json +1 -1
  6. package/dist/builtin/subagents/CHANGELOG.md +12 -0
  7. package/dist/builtin/subagents/README.md +2 -0
  8. package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
  9. package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
  10. package/dist/builtin/subagents/agents/codebase-online-researcher.md +3 -3
  11. package/dist/builtin/subagents/agents/debugger.md +7 -5
  12. package/dist/builtin/subagents/agents/worker.md +4 -2
  13. package/dist/builtin/subagents/package.json +1 -1
  14. package/dist/builtin/subagents/skills/agent-browser/SKILL.md +56 -0
  15. package/dist/builtin/subagents/skills/subagent/SKILL.md +32 -8
  16. package/dist/builtin/subagents/src/extension/index.bundle.mjs +7 -4
  17. package/dist/builtin/web-access/package.json +1 -1
  18. package/dist/builtin/workflows/CHANGELOG.md +30 -0
  19. package/dist/builtin/workflows/README.md +4 -2
  20. package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
  21. package/dist/builtin/workflows/builtin/{chunk-n8g2da69.js → chunk-00ywx588.js} +1 -1
  22. package/dist/builtin/workflows/builtin/{chunk-d1xqh1rd.js → chunk-55p5dxjk.js} +1 -1
  23. package/dist/builtin/workflows/builtin/{chunk-1dydq7w3.js → chunk-7f381xnq.js} +62 -24
  24. package/dist/builtin/workflows/builtin/{chunk-k18g9me8.js → chunk-7h7s5xdj.js} +1 -1
  25. package/dist/builtin/workflows/builtin/{chunk-n4yxrsm9.js → chunk-e83tc6nr.js} +1 -1
  26. package/dist/builtin/workflows/builtin/{chunk-sn5mchnx.js → chunk-evfb0312.js} +1 -1
  27. package/dist/builtin/workflows/builtin/{chunk-scgprmdj.js → chunk-ne6vh5ct.js} +1 -1
  28. package/dist/builtin/workflows/builtin/{chunk-119kxb28.js → chunk-pfm1kgqz.js} +62 -43
  29. package/dist/builtin/workflows/builtin/{chunk-hnbbb5r0.js → chunk-tdqvdrg1.js} +4 -4
  30. package/dist/builtin/workflows/builtin/{chunk-kf5xpbkz.js → chunk-tvcydq13.js} +1 -1
  31. package/dist/builtin/workflows/builtin/{chunk-9y0f90rd.js → chunk-x2nftpgj.js} +1 -1
  32. package/dist/builtin/workflows/builtin/{chunk-vt9zgr9d.js → chunk-zj5162bh.js} +4 -4
  33. package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
  34. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
  35. package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
  36. package/dist/builtin/workflows/builtin/goal.js +4 -4
  37. package/dist/builtin/workflows/builtin/index.d.ts +1 -1
  38. package/dist/builtin/workflows/builtin/index.js +12 -12
  39. package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
  40. package/dist/builtin/workflows/builtin/open-claude-design.d.ts +1 -1
  41. package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
  42. package/dist/builtin/workflows/builtin/ralph.js +4 -4
  43. package/dist/builtin/workflows/builtin/steering-context.js +1 -1
  44. package/dist/builtin/workflows/builtin/tournament.js +3 -3
  45. package/dist/builtin/workflows/package.json +1 -1
  46. package/dist/builtin/workflows/skills/impeccable/SKILL.md +18 -11
  47. package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -1
  48. package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +1 -1
  49. package/dist/builtin/workflows/skills/impeccable/reference/animate.md +1 -1
  50. package/dist/builtin/workflows/skills/impeccable/reference/audit.md +5 -5
  51. package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +6 -6
  52. package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +2 -2
  53. package/dist/builtin/workflows/skills/impeccable/reference/clarify.md +1 -1
  54. package/dist/builtin/workflows/skills/impeccable/reference/colorize.md +1 -1
  55. package/dist/builtin/workflows/skills/impeccable/reference/craft-floor.md +0 -6
  56. package/dist/builtin/workflows/skills/impeccable/reference/critique.md +19 -41
  57. package/dist/builtin/workflows/skills/impeccable/reference/degraded/asset-producer.md +11 -65
  58. package/dist/builtin/workflows/skills/impeccable/reference/degraded/documenter.md +3 -3
  59. package/dist/builtin/workflows/skills/impeccable/reference/degraded/finish-reviewer.md +4 -4
  60. package/dist/builtin/workflows/skills/impeccable/reference/degraded/manual-edit-applier.md +1 -1
  61. package/dist/builtin/workflows/skills/impeccable/reference/delight.md +1 -1
  62. package/dist/builtin/workflows/skills/impeccable/reference/distill.md +2 -2
  63. package/dist/builtin/workflows/skills/impeccable/reference/doctor.md +4 -4
  64. package/dist/builtin/workflows/skills/impeccable/reference/document.md +4 -4
  65. package/dist/builtin/workflows/skills/impeccable/reference/extract.md +1 -1
  66. package/dist/builtin/workflows/skills/impeccable/reference/harden.md +1 -1
  67. package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +21 -21
  68. package/dist/builtin/workflows/skills/impeccable/reference/init.md +8 -8
  69. package/dist/builtin/workflows/skills/impeccable/reference/layout.md +2 -2
  70. package/dist/builtin/workflows/skills/impeccable/reference/live-setup.md +10 -8
  71. package/dist/builtin/workflows/skills/impeccable/reference/live.md +39 -38
  72. package/dist/builtin/workflows/skills/impeccable/reference/new-work.md +48 -21
  73. package/dist/builtin/workflows/skills/impeccable/reference/onboard.md +1 -1
  74. package/dist/builtin/workflows/skills/impeccable/reference/optimize.md +1 -1
  75. package/dist/builtin/workflows/skills/impeccable/reference/overdrive.md +1 -1
  76. package/dist/builtin/workflows/skills/impeccable/reference/polish.md +11 -3
  77. package/dist/builtin/workflows/skills/impeccable/reference/quieter.md +2 -2
  78. package/dist/builtin/workflows/skills/impeccable/reference/routing.md +13 -7
  79. package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +2 -2
  80. package/dist/builtin/workflows/skills/impeccable/reference/visualize.md +13 -19
  81. package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -0
  82. package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index-failures.json +121 -0
  83. package/dist/builtin/workflows/skills/impeccable/scripts/data/font-index.json +1 -0
  84. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable +212 -0
  85. package/dist/builtin/workflows/skills/impeccable/scripts/impeccable.cmd +218 -0
  86. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-dom.js +21 -0
  87. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-ignores.js +242 -0
  88. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser-session.js +25 -4
  89. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +666 -197
  90. package/dist/builtin/workflows/skills/research-codebase/SKILL.md +1 -1
  91. package/dist/builtin/workflows/src/extension/index.bundle.mjs +156 -84
  92. package/dist/builtin/workflows/src/index.js +62 -24
  93. package/dist/core/execution-model-router.d.ts +2 -0
  94. package/dist/core/execution-model-router.d.ts.map +1 -1
  95. package/dist/core/execution-model-router.js +30 -4
  96. package/dist/core/execution-model-router.js.map +1 -1
  97. package/dist/core/model-routing-task.d.ts +1 -1
  98. package/dist/core/model-routing-task.d.ts.map +1 -1
  99. package/dist/core/model-routing-task.js +4 -3
  100. package/dist/core/model-routing-task.js.map +1 -1
  101. package/dist/core/system-prompt.d.ts.map +1 -1
  102. package/dist/core/system-prompt.js +2 -1
  103. package/dist/core/system-prompt.js.map +1 -1
  104. package/dist/index.d.ts +1 -1
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.js +1 -1
  107. package/dist/index.js.map +1 -1
  108. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  109. package/dist/modes/interactive/components/chat-message-renderer.js +4 -0
  110. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  111. package/docs/computer-use.md +22 -21
  112. package/docs/getting-started/first-session.md +2 -2
  113. package/docs/getting-started/installation.md +6 -2
  114. package/docs/intercom.md +6 -1
  115. package/docs/models/model-selection.md +11 -7
  116. package/docs/quickstart.md +1 -1
  117. package/docs/skills.md +1 -1
  118. package/docs/subagents/reference.md +2 -2
  119. package/docs/subagents.md +7 -1
  120. package/docs/usage.md +2 -0
  121. package/docs/windows.md +1 -1
  122. package/docs/workflows/api-reference.md +3 -4
  123. package/docs/workflows/builtins.md +2 -2
  124. package/docs/workflows/operations.md +1 -1
  125. package/docs/workflows/reliable-design.md +12 -1
  126. package/docs/workflows/verification.md +8 -8
  127. package/npm-shrinkwrap.json +32 -32
  128. package/package.json +3 -3
  129. package/dist/builtin/subagents/skills/playwright-cli/SKILL.md +0 -420
  130. package/dist/builtin/subagents/skills/playwright-cli/references/element-attributes.md +0 -23
  131. package/dist/builtin/subagents/skills/playwright-cli/references/playwright-tests.md +0 -39
  132. package/dist/builtin/subagents/skills/playwright-cli/references/request-mocking.md +0 -87
  133. package/dist/builtin/subagents/skills/playwright-cli/references/running-code.md +0 -241
  134. package/dist/builtin/subagents/skills/playwright-cli/references/session-management.md +0 -225
  135. package/dist/builtin/subagents/skills/playwright-cli/references/storage-state.md +0 -275
  136. package/dist/builtin/subagents/skills/playwright-cli/references/test-generation.md +0 -433
  137. package/dist/builtin/subagents/skills/playwright-cli/references/tracing.md +0 -139
  138. package/dist/builtin/subagents/skills/playwright-cli/references/video-recording.md +0 -143
  139. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_asset_producer.toml +0 -94
  140. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_documenter.toml +0 -27
  141. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_finish_reviewer.toml +0 -41
  142. package/dist/builtin/workflows/skills/impeccable/agents/impeccable_manual_edit_applier.toml +0 -95
  143. package/dist/builtin/workflows/skills/impeccable/agents/openai.yaml +0 -4
  144. package/dist/builtin/workflows/skills/impeccable/scripts/concept-seed.mjs +0 -695
  145. package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +0 -325
  146. package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +0 -1503
  147. package/dist/builtin/workflows/skills/impeccable/scripts/critique-storage.mjs +0 -222
  148. package/dist/builtin/workflows/skills/impeccable/scripts/detect-csp.mjs +0 -198
  149. package/dist/builtin/workflows/skills/impeccable/scripts/detect.mjs +0 -21
  150. package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +0 -2073
  151. package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +0 -432
  152. package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +0 -1121
  153. package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +0 -8746
  154. package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns.mjs +0 -51
  155. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +0 -376
  156. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +0 -1168
  157. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +0 -1192
  158. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +0 -290
  159. package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +0 -189
  160. package/dist/builtin/workflows/skills/impeccable/scripts/detector/findings.mjs +0 -18
  161. package/dist/builtin/workflows/skills/impeccable/scripts/detector/node/file-system.mjs +0 -213
  162. package/dist/builtin/workflows/skills/impeccable/scripts/detector/profile/profiler.mjs +0 -166
  163. package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +0 -617
  164. package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +0 -5534
  165. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/color.mjs +0 -588
  166. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/constants.mjs +0 -112
  167. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +0 -30
  168. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/inline-ignores.mjs +0 -148
  169. package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +0 -35
  170. package/dist/builtin/workflows/skills/impeccable/scripts/doctor.mjs +0 -338
  171. package/dist/builtin/workflows/skills/impeccable/scripts/embed-prompt.mjs +0 -270
  172. package/dist/builtin/workflows/skills/impeccable/scripts/generate-image.mjs +0 -277
  173. package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +0 -783
  174. package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +0 -2305
  175. package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +0 -78
  176. package/dist/builtin/workflows/skills/impeccable/scripts/lib/artifact-schema.mjs +0 -93
  177. package/dist/builtin/workflows/skills/impeccable/scripts/lib/composition-catalog.mjs +0 -200
  178. package/dist/builtin/workflows/skills/impeccable/scripts/lib/concept-catalog.mjs +0 -395
  179. package/dist/builtin/workflows/skills/impeccable/scripts/lib/design-parser.mjs +0 -925
  180. package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +0 -640
  181. package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-paths.mjs +0 -137
  182. package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +0 -72
  183. package/dist/builtin/workflows/skills/impeccable/scripts/lib/open-system-browser.mjs +0 -57
  184. package/dist/builtin/workflows/skills/impeccable/scripts/lib/provider.mjs +0 -5
  185. package/dist/builtin/workflows/skills/impeccable/scripts/lib/roll-selection.mjs +0 -369
  186. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-deep.mjs +0 -483
  187. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness-notice.mjs +0 -169
  188. package/dist/builtin/workflows/skills/impeccable/scripts/lib/staleness.mjs +0 -528
  189. package/dist/builtin/workflows/skills/impeccable/scripts/lib/surface-briefs.mjs +0 -151
  190. package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-args.mjs +0 -42
  191. package/dist/builtin/workflows/skills/impeccable/scripts/lib/target-slug.mjs +0 -33
  192. package/dist/builtin/workflows/skills/impeccable/scripts/lib/template-extensions.mjs +0 -146
  193. package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-css.mjs +0 -617
  194. package/dist/builtin/workflows/skills/impeccable/scripts/live/accept-verify.mjs +0 -71
  195. package/dist/builtin/workflows/skills/impeccable/scripts/live/browser-script-parts.mjs +0 -77
  196. package/dist/builtin/workflows/skills/impeccable/scripts/live/completion.mjs +0 -28
  197. package/dist/builtin/workflows/skills/impeccable/scripts/live/event-validation.mjs +0 -199
  198. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/astro.mjs +0 -47
  199. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/detect-utils.mjs +0 -157
  200. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/index.mjs +0 -143
  201. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/journal.mjs +0 -205
  202. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nextjs.mjs +0 -49
  203. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/nuxt.mjs +0 -170
  204. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/script-src.mjs +0 -26
  205. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/static-html.mjs +0 -26
  206. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/sveltekit.mjs +0 -71
  207. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tag-strategy.mjs +0 -247
  208. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/tanstack-start.mjs +0 -70
  209. package/dist/builtin/workflows/skills/impeccable/scripts/live/frameworks/vite-generic.mjs +0 -42
  210. package/dist/builtin/workflows/skills/impeccable/scripts/live/generation-preflight.mjs +0 -149
  211. package/dist/builtin/workflows/skills/impeccable/scripts/live/insert-ui.mjs +0 -458
  212. package/dist/builtin/workflows/skills/impeccable/scripts/live/instructions.mjs +0 -169
  213. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-apply.mjs +0 -939
  214. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edit-routes.mjs +0 -357
  215. package/dist/builtin/workflows/skills/impeccable/scripts/live/manual-edits-buffer.mjs +0 -152
  216. package/dist/builtin/workflows/skills/impeccable/scripts/live/poll-lanes.mjs +0 -14
  217. package/dist/builtin/workflows/skills/impeccable/scripts/live/roots.mjs +0 -670
  218. package/dist/builtin/workflows/skills/impeccable/scripts/live/session-store.mjs +0 -563
  219. package/dist/builtin/workflows/skills/impeccable/scripts/live/source-lock.mjs +0 -105
  220. package/dist/builtin/workflows/skills/impeccable/scripts/live/source-search.mjs +0 -105
  221. package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-ast.mjs +0 -969
  222. package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +0 -1401
  223. package/dist/builtin/workflows/skills/impeccable/scripts/live/sveltekit-adapter.mjs +0 -314
  224. package/dist/builtin/workflows/skills/impeccable/scripts/live/tanstack-adapter.mjs +0 -280
  225. package/dist/builtin/workflows/skills/impeccable/scripts/live/ui-surfaces.mjs +0 -75
  226. package/dist/builtin/workflows/skills/impeccable/scripts/live/vocabulary.mjs +0 -171
  227. package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +0 -961
  228. package/dist/builtin/workflows/skills/impeccable/scripts/live-commit-manual-edits.mjs +0 -1244
  229. package/dist/builtin/workflows/skills/impeccable/scripts/live-complete.mjs +0 -107
  230. package/dist/builtin/workflows/skills/impeccable/scripts/live-copy-edit-agent.mjs +0 -800
  231. package/dist/builtin/workflows/skills/impeccable/scripts/live-discard-manual-edits.mjs +0 -51
  232. package/dist/builtin/workflows/skills/impeccable/scripts/live-inject.mjs +0 -515
  233. package/dist/builtin/workflows/skills/impeccable/scripts/live-insert.mjs +0 -292
  234. package/dist/builtin/workflows/skills/impeccable/scripts/live-manual-edit-evidence.mjs +0 -371
  235. package/dist/builtin/workflows/skills/impeccable/scripts/live-poll.mjs +0 -427
  236. package/dist/builtin/workflows/skills/impeccable/scripts/live-resume.mjs +0 -123
  237. package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +0 -1675
  238. package/dist/builtin/workflows/skills/impeccable/scripts/live-status.mjs +0 -71
  239. package/dist/builtin/workflows/skills/impeccable/scripts/live-target.mjs +0 -30
  240. package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +0 -927
  241. package/dist/builtin/workflows/skills/impeccable/scripts/live.mjs +0 -365
  242. package/dist/builtin/workflows/skills/impeccable/scripts/palette.mjs +0 -628
  243. package/dist/builtin/workflows/skills/impeccable/scripts/pin.mjs +0 -224
  244. package/dist/builtin/workflows/skills/impeccable/scripts/serve-question.mjs +0 -1540
  245. package/dist/builtin/workflows/skills/impeccable/scripts/surface-brief.mjs +0 -74
@@ -1,222 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Critique persistence helper.
4
- *
5
- * Each critique run writes a per-target snapshot to
6
- * .impeccable/critique/<timestamp>__<slug>.md
7
- * with a small YAML frontmatter carrying the score + P0/P1 counts.
8
- *
9
- * The polish workflow reads the latest matching snapshot at start as its
10
- * fix backlog. No other skill auto-reads critique output.
11
- *
12
- * The slug is derived mechanically from the *resolved* primary artifact
13
- * (file path or URL), never from the user's natural-language phrasing.
14
- * Slug stability across runs is what lets the trend display work.
15
- *
16
- * CLI entry points (called from skill instructions):
17
- * node critique-storage.mjs slug <resolved-target>
18
- * node critique-storage.mjs write <slug> <snapshot-body-file>
19
- * node critique-storage.mjs latest <slug>
20
- * node critique-storage.mjs trend <slug> [limit]
21
- *
22
- * Note: there is intentionally no `ignore` subcommand. ignore.md is a plain
23
- * markdown file; the model reads it directly with its file-read tool. This
24
- * helper only exists for operations the model can't trivially do inline
25
- * (normalizing paths, generating filenames, globbing + parsing frontmatter).
26
- */
27
-
28
- import fs from 'node:fs';
29
- import path from 'node:path';
30
- import { fileURLToPath, pathToFileURL } from 'node:url';
31
- import { getCritiqueDir } from './lib/impeccable-paths.mjs';
32
- import { slugFromTarget } from './lib/target-slug.mjs';
33
-
34
- export { slugFromTarget } from './lib/target-slug.mjs';
35
-
36
- /**
37
- * Mechanically derive a slug from a resolved target. Returns null if the
38
- * input doesn't look like a stable identifier (empty, project root, etc).
39
- *
40
- * Accepts file paths and URLs. The model resolves "the homepage" to a
41
- * concrete artifact before calling this — we never slug a natural-language
42
- * phrase.
43
- */
44
- /**
45
- * Filename-safe UTC ISO timestamp: hyphens for separators, trailing Z.
46
- * Plain colons aren't allowed on Windows filesystems.
47
- */
48
- export function nowFilenameStamp(date = new Date()) {
49
- const iso = date.toISOString(); // 2026-05-12T18:30:00.123Z
50
- return iso.replace(/[:.]/g, '-').replace(/-\d+Z$/, 'Z');
51
- }
52
-
53
- /**
54
- * Write a snapshot for `slug`. `meta` carries the small structured frontmatter
55
- * keys read back by readTrend(). `body` is the human-readable critique
56
- * report (everything below the frontmatter).
57
- *
58
- * Returns the absolute path written.
59
- */
60
- export function writeSnapshot({ slug, meta, body, cwd = process.cwd(), now = new Date() }) {
61
- if (!slug) throw new Error('writeSnapshot requires a slug');
62
- const dir = getCritiqueDir(cwd);
63
- fs.mkdirSync(dir, { recursive: true });
64
- const timestamp = nowFilenameStamp(now);
65
- const filePath = path.join(dir, `${timestamp}__${slug}.md`);
66
- // Spread `meta` first so internally computed `timestamp` and `slug`
67
- // always win. Otherwise a caller-supplied meta blob (parsed from the
68
- // IMPECCABLE_CRITIQUE_META env var) could clobber them, leaving the
69
- // filename in disagreement with its frontmatter and corrupting trends.
70
- const front = serializeFrontmatter({ ...meta, timestamp, slug });
71
- fs.writeFileSync(filePath, `${front}\n${body.trim()}\n`, 'utf-8');
72
- return filePath;
73
- }
74
-
75
- function serializeFrontmatter(obj) {
76
- const lines = ['---'];
77
- for (const [key, value] of Object.entries(obj)) {
78
- if (value === undefined || value === null) continue;
79
- const str = typeof value === 'string' ? value : String(value);
80
- // Quote strings that contain : or # to keep parsing simple.
81
- const needsQuotes = typeof value === 'string' && /[:#]/.test(str);
82
- lines.push(`${key}: ${needsQuotes ? JSON.stringify(str) : str}`);
83
- }
84
- lines.push('---');
85
- return lines.join('\n');
86
- }
87
-
88
- function parseFrontmatter(text) {
89
- const match = text.match(/^---\r?\n([\s\S]*?)\r?\n---/);
90
- if (!match) return {};
91
- const out = {};
92
- for (const line of match[1].split(/\r?\n/)) {
93
- const colon = line.indexOf(':');
94
- if (colon < 0) continue;
95
- const key = line.slice(0, colon).trim();
96
- let value = line.slice(colon + 1).trim();
97
- if (/^".*"$/.test(value)) {
98
- try { value = JSON.parse(value); } catch { /* leave as-is */ }
99
- } else if (/^-?\d+$/.test(value)) {
100
- value = Number(value);
101
- }
102
- out[key] = value;
103
- }
104
- return out;
105
- }
106
-
107
- /**
108
- * Return snapshot files matching `suffix`, sorted oldest → newest.
109
- */
110
- const SNAPSHOT_FILENAME = /^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}Z__.+\.md$/;
111
-
112
- function listSnapshots(suffix, cwd) {
113
- const dir = getCritiqueDir(cwd);
114
- if (!fs.existsSync(dir)) return [];
115
- return fs.readdirSync(dir)
116
- .filter((f) => SNAPSHOT_FILENAME.test(f) && f.endsWith(suffix))
117
- .sort()
118
- .map((f) => path.join(dir, f));
119
- }
120
-
121
- function readLatestSnapshotMatching(suffix, cwd) {
122
- const filePath = listSnapshots(suffix, cwd).at(-1);
123
- if (!filePath) return null;
124
- const body = fs.readFileSync(filePath, 'utf-8');
125
- return { path: filePath, body, meta: parseFrontmatter(body) };
126
- }
127
-
128
- /**
129
- * Return the most recent snapshot for `slug`, or null. Polish reads this
130
- * to find its fix backlog when the slug matches.
131
- */
132
- export function readLatestSnapshot(slug, { cwd = process.cwd() } = {}) {
133
- return readLatestSnapshotMatching(`__${slug}.md`, cwd);
134
- }
135
-
136
- /** Return the most recent snapshot across all targets, or null. */
137
- export function readLatestSnapshotAcrossTargets({ cwd = process.cwd() } = {}) {
138
- return readLatestSnapshotMatching('.md', cwd);
139
- }
140
-
141
- /**
142
- * Return the last `limit` snapshots' frontmatter, oldest → newest.
143
- * Critique appends a one-line trend to its output using this.
144
- */
145
- export function readTrend(slug, { limit = 5, cwd = process.cwd() } = {}) {
146
- const all = listSnapshots(`__${slug}.md`, cwd);
147
- const slice = all.slice(-limit);
148
- return slice.map((file) => parseFrontmatter(fs.readFileSync(file, 'utf-8')));
149
- }
150
-
151
- // ---- CLI ---------------------------------------------------------------
152
-
153
- // Accept either a ready slug or a concrete target (path/URL) everywhere, so
154
- // callers never have to run the slug step separately. Anything containing a
155
- // path or URL marker is resolved through slugFromTarget.
156
- function coerceSlug(value) {
157
- if (!value) return null;
158
- if (/^[a-z0-9-]+$/.test(value) && !value.includes('/')) return value;
159
- return slugFromTarget(value);
160
- }
161
-
162
- function main(argv) {
163
- const [cmd, ...args] = argv;
164
- switch (cmd) {
165
- case 'slug': {
166
- const slug = slugFromTarget(args[0]);
167
- if (!slug) { process.stderr.write('no stable slug for input\n'); process.exit(1); }
168
- process.stdout.write(`${slug}\n`);
169
- return;
170
- }
171
- case 'write': {
172
- const [slugArg, bodyFile] = args;
173
- const slug = coerceSlug(slugArg);
174
- if (!slug || !bodyFile) { process.stderr.write('usage: write <slug-or-target> <body-file>\n'); process.exit(1); }
175
- const raw = fs.readFileSync(bodyFile, 'utf-8');
176
- // The body file may be a full report. The caller passes the meta as
177
- // a JSON object on stdin if it wants structured frontmatter; otherwise
178
- // we write with minimal metadata.
179
- let meta = {};
180
- const metaArg = process.env.IMPECCABLE_CRITIQUE_META;
181
- if (metaArg) {
182
- try { meta = JSON.parse(metaArg); } catch { /* ignore */ }
183
- }
184
- const out = writeSnapshot({ slug, meta, body: raw });
185
- process.stdout.write(`${out}\n`);
186
- return;
187
- }
188
- case 'latest': {
189
- const latest = readLatestSnapshot(coerceSlug(args[0]));
190
- if (!latest) { process.exit(2); }
191
- process.stdout.write(latest.body);
192
- return;
193
- }
194
- case 'trend': {
195
- const rows = readTrend(coerceSlug(args[0]), { limit: args[1] ? Number(args[1]) : 5 });
196
- process.stdout.write(JSON.stringify(rows, null, 2) + '\n');
197
- return;
198
- }
199
- default:
200
- process.stderr.write('usage: critique-storage.mjs <slug|write|latest|trend> [args]\n');
201
- process.exit(1);
202
- }
203
- }
204
-
205
- function isMainModule() {
206
- if (!process.argv[1]) return false;
207
- try {
208
- return fs.realpathSync(fileURLToPath(import.meta.url)) === fs.realpathSync(process.argv[1]);
209
- } catch {
210
- // pathToFileURL normalizes Windows paths; keep it as a fallback for any
211
- // environment where realpath is unavailable.
212
- return import.meta.url === pathToFileURL(process.argv[1]).href;
213
- }
214
- }
215
-
216
- // Why the realpath check: generated skills are often reached through symlinked
217
- // harness directories (for example a demo repo's `.agents` -> source `.agents`).
218
- // Node resolves import.meta.url to the real file, while process.argv[1] keeps
219
- // the symlink path. Comparing canonical paths prevents a silent exit-0 no-op.
220
- if (isMainModule()) {
221
- main(process.argv.slice(2));
222
- }
@@ -1,198 +0,0 @@
1
- /**
2
- * Scan a project tree for Content-Security-Policy signals and classify the
3
- * shape so the agent knows which patch template to propose.
4
- *
5
- * Used at first-time `live.mjs` setup. Mechanical (grep-based) — no network,
6
- * no dev server, no JS evaluation. The classification drives a user-facing
7
- * consent prompt; the agent does the actual patch writing.
8
- *
9
- * Shapes are named by patch mechanism, not framework origin:
10
- * - "append-arrays": CSP defined as structured directive arrays. Patch
11
- * appends a dev-only localhost entry. Covers:
12
- * - Monorepo helpers with additional*Src options
13
- * (e.g. createBaseNextConfig for Next)
14
- * - SvelteKit kit.csp.directives
15
- * - nuxt-security module's contentSecurityPolicy
16
- * - "append-string": CSP built as a literal value string. Patch splices
17
- * a dev-only token into script-src and connect-src.
18
- * Covers:
19
- * - Inline Next.js headers() with CSP string
20
- * - Nuxt routeRules / nitro.routeRules CSP headers
21
- * - "middleware": CSP set dynamically in middleware.{ts,js}.
22
- * Detected but not auto-patched in v1.
23
- * - "meta-tag": <meta http-equiv="Content-Security-Policy"> in
24
- * layout files. Detected but not auto-patched in v1.
25
- * - null: no CSP signals found; no patch needed.
26
- */
27
-
28
- import fs from 'node:fs';
29
- import path from 'node:path';
30
-
31
- const SKIP_DIRS = new Set([
32
- 'node_modules',
33
- '.git',
34
- '.next',
35
- '.turbo',
36
- '.svelte-kit',
37
- '.nuxt',
38
- '.astro',
39
- 'dist',
40
- 'build',
41
- 'out',
42
- '.vercel',
43
- ]);
44
-
45
- const SCAN_EXTS = new Set(['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts', '.tsx', '.jsx']);
46
- const LAYOUT_EXTS = new Set(['.tsx', '.jsx', '.astro', '.vue', '.svelte', '.html']);
47
- const MAX_DEPTH = 6;
48
- const MAX_READ_BYTES = 64 * 1024;
49
-
50
- // append-arrays signals: CSP expressed as structured directive arrays
51
- const MONOREPO_HELPER_SIGNALS = [
52
- /\bbuildCSPConfig\b/,
53
- /\bbuildSecurityHeaders\b/,
54
- /\badditionalScriptSrc\b/,
55
- /\badditionalConnectSrc\b/,
56
- /\bcreateBaseNextConfig\b/,
57
- ];
58
- const SVELTEKIT_CSP_SIGNALS = [
59
- /\bkit\s*:/,
60
- /\bcsp\s*:/,
61
- /\bdirectives\s*:/,
62
- ];
63
- const NUXT_SECURITY_SIGNALS = [
64
- /['"]nuxt-security['"]/,
65
- /\bcontentSecurityPolicy\b/,
66
- ];
67
-
68
- // append-string signals: CSP written as a literal value string
69
- const INLINE_HEADER_SIGNALS = [
70
- /["']Content-Security-Policy["']/i,
71
- /\bscript-src\b/,
72
- /\bconnect-src\b/,
73
- ];
74
- const NUXT_ROUTE_RULES_SIGNALS = [
75
- /\brouteRules\b/,
76
- /Content-Security-Policy/i,
77
- /\bscript-src\b/,
78
- ];
79
-
80
- const MIDDLEWARE_HINT = /headers\.set\(\s*["']Content-Security-Policy["']/i;
81
- const META_TAG_HINT = /http-equiv\s*=\s*["']Content-Security-Policy["']/i;
82
-
83
- /**
84
- * @param {string} cwd Project root.
85
- * @returns {{ shape: string|null, signals: string[] }}
86
- */
87
- export function detectCsp(cwd = process.cwd()) {
88
- const hits = { appendArrays: [], appendString: [], middleware: [], metaTag: [] };
89
-
90
- walk(cwd, cwd, 0, (absPath, relPath, body) => {
91
- const ext = path.extname(absPath);
92
- const base = path.basename(absPath).toLowerCase();
93
- const isConfig = (name) =>
94
- new RegExp('(^|/)' + name + '\\.config\\.').test(relPath);
95
-
96
- // === append-arrays candidates ===
97
-
98
- // Monorepo CSP helper: packages/*/src/.../(config|security)/*
99
- if (SCAN_EXTS.has(ext) &&
100
- /packages\/[^/]+\/src\/.*(config|next-config|security)/.test(relPath) &&
101
- MONOREPO_HELPER_SIGNALS.some((re) => re.test(body))) {
102
- hits.appendArrays.push(relPath);
103
- return;
104
- }
105
-
106
- // SvelteKit kit.csp.directives
107
- if (SCAN_EXTS.has(ext) && isConfig('svelte') &&
108
- SVELTEKIT_CSP_SIGNALS.every((re) => re.test(body))) {
109
- hits.appendArrays.push(relPath);
110
- return;
111
- }
112
-
113
- // Nuxt nuxt-security module
114
- if (SCAN_EXTS.has(ext) && isConfig('nuxt') &&
115
- NUXT_SECURITY_SIGNALS.every((re) => re.test(body))) {
116
- hits.appendArrays.push(relPath);
117
- return;
118
- }
119
-
120
- // === append-string candidates ===
121
-
122
- // Inline headers in Next/Nuxt/SvelteKit/Astro/Vite config
123
- if (SCAN_EXTS.has(ext) &&
124
- /(^|\/)(next|nuxt|vite|astro|svelte)\.config\./.test(relPath) &&
125
- INLINE_HEADER_SIGNALS.every((re) => re.test(body))) {
126
- // Nuxt routeRules is a sub-shape of append-string; we already covered
127
- // nuxt-security above via return, so any remaining Nuxt CSP match here
128
- // is a route-rules / inline-headers case. Either way, same patch
129
- // mechanism.
130
- hits.appendString.push(relPath);
131
- return;
132
- }
133
-
134
- // === detect-only shapes ===
135
-
136
- if ((base === 'middleware.ts' || base === 'middleware.js' || base === 'middleware.mjs') &&
137
- MIDDLEWARE_HINT.test(body)) {
138
- hits.middleware.push(relPath);
139
- }
140
-
141
- if (LAYOUT_EXTS.has(ext) && META_TAG_HINT.test(body)) {
142
- hits.metaTag.push(relPath);
143
- }
144
- });
145
-
146
- // Priority: append-arrays > append-string > middleware > meta-tag.
147
- // Structured patches are safer than string splices; runtime and HTML
148
- // injection patches are less reliable and v1 doesn't auto-apply them.
149
- if (hits.appendArrays.length > 0) {
150
- return { shape: 'append-arrays', signals: hits.appendArrays };
151
- }
152
- if (hits.appendString.length > 0) {
153
- return { shape: 'append-string', signals: hits.appendString };
154
- }
155
- if (hits.middleware.length > 0) {
156
- return { shape: 'middleware', signals: hits.middleware };
157
- }
158
- if (hits.metaTag.length > 0) {
159
- return { shape: 'meta-tag', signals: hits.metaTag };
160
- }
161
- return { shape: null, signals: [] };
162
- }
163
-
164
- function walk(root, dir, depth, visit) {
165
- if (depth > MAX_DEPTH) return;
166
- let entries;
167
- try { entries = fs.readdirSync(dir, { withFileTypes: true }); }
168
- catch { return; }
169
-
170
- for (const entry of entries) {
171
- const abs = path.join(dir, entry.name);
172
- if (entry.isDirectory()) {
173
- if (SKIP_DIRS.has(entry.name)) continue;
174
- walk(root, abs, depth + 1, visit);
175
- continue;
176
- }
177
- if (!entry.isFile()) continue;
178
- const ext = path.extname(entry.name);
179
- if (!SCAN_EXTS.has(ext) && !LAYOUT_EXTS.has(ext)) continue;
180
- let body;
181
- try {
182
- const fd = fs.openSync(abs, 'r');
183
- try {
184
- const buf = Buffer.alloc(MAX_READ_BYTES);
185
- const n = fs.readSync(fd, buf, 0, MAX_READ_BYTES, 0);
186
- body = buf.slice(0, n).toString('utf-8');
187
- } finally { fs.closeSync(fd); }
188
- } catch { continue; }
189
- visit(abs, path.relative(root, abs), body);
190
- }
191
- }
192
-
193
- // CLI mode
194
- const _running = process.argv[1];
195
- if (_running?.endsWith('detect-csp.mjs') || _running?.endsWith('detect-csp.mjs/')) {
196
- const result = detectCsp(process.cwd());
197
- console.log(JSON.stringify(result, null, 2));
198
- }
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from 'node:fs';
4
- import path from 'node:path';
5
- import { pathToFileURL, fileURLToPath } from 'node:url';
6
-
7
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
- const candidates = [
9
- path.join(__dirname, 'detector', 'detect-antipatterns.mjs'),
10
- path.join(__dirname, '..', '..', 'cli', 'engine', 'detect-antipatterns.mjs'),
11
- ];
12
- const detectorPath = candidates.find(p => fs.existsSync(p));
13
-
14
- if (!detectorPath) {
15
- process.stderr.write('Error: bundled detector not found.\n');
16
- process.exit(1);
17
- }
18
-
19
- const { detectCli } = await import(pathToFileURL(detectorPath));
20
-
21
- await detectCli();