self-evolving-workflow 0.0.0-stage → 0.1.4

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 (375) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +195 -2
  3. package/dist/agent-memory-prompts.d.ts +13 -0
  4. package/dist/agent-memory-prompts.js +55 -0
  5. package/dist/cli.d.ts +2 -0
  6. package/dist/cli.js +6 -0
  7. package/dist/closeout.d.ts +105 -0
  8. package/dist/closeout.js +473 -0
  9. package/dist/code.d.ts +39 -0
  10. package/dist/code.js +124 -0
  11. package/dist/codex-memory.d.ts +24 -0
  12. package/dist/codex-memory.js +217 -0
  13. package/dist/common.d.ts +16 -0
  14. package/dist/common.js +52 -0
  15. package/dist/context-envelope.d.ts +59 -0
  16. package/dist/context-envelope.js +23 -0
  17. package/dist/host-adapters.d.ts +34 -0
  18. package/dist/host-adapters.js +151 -0
  19. package/dist/http.d.ts +3 -0
  20. package/dist/http.js +90 -0
  21. package/dist/index.d.ts +16 -0
  22. package/dist/index.js +13 -0
  23. package/dist/knowledge-cli.d.ts +198 -0
  24. package/dist/knowledge-cli.js +761 -0
  25. package/dist/knowledge-reads.d.ts +72 -0
  26. package/dist/knowledge-reads.js +201 -0
  27. package/dist/memory-config.d.ts +44 -0
  28. package/dist/memory-config.js +204 -0
  29. package/dist/memory-evidence.d.ts +13 -0
  30. package/dist/memory-evidence.js +40 -0
  31. package/dist/memory-history.d.ts +46 -0
  32. package/dist/memory-history.js +432 -0
  33. package/dist/memory.d.ts +96 -0
  34. package/dist/memory.js +362 -0
  35. package/dist/retrospective.d.ts +57 -0
  36. package/dist/retrospective.js +240 -0
  37. package/dist/search.d.ts +36 -0
  38. package/dist/search.js +112 -0
  39. package/dist/skill-addition.d.ts +25 -0
  40. package/dist/skill-addition.js +89 -0
  41. package/dist/skill-design.d.ts +96 -0
  42. package/dist/skill-design.js +226 -0
  43. package/dist/skill-replay.d.ts +55 -0
  44. package/dist/skill-replay.js +448 -0
  45. package/dist/skill-route.d.ts +30 -0
  46. package/dist/skill-route.js +75 -0
  47. package/dist/transcript-evidence.d.ts +3 -0
  48. package/dist/transcript-evidence.js +58 -0
  49. package/dist/upstream/chunker.d.ts +24 -0
  50. package/dist/upstream/chunker.js +96 -0
  51. package/dist/upstream/file-protocol.d.ts +45 -0
  52. package/dist/upstream/file-protocol.js +117 -0
  53. package/dist/upstream/frontmatter.d.ts +47 -0
  54. package/dist/upstream/frontmatter.js +86 -0
  55. package/dist/upstream/graph-search.d.ts +33 -0
  56. package/dist/upstream/graph-search.js +67 -0
  57. package/dist/upstream/l1-extraction.d.ts +26 -0
  58. package/dist/upstream/l1-extraction.js +405 -0
  59. package/dist/upstream/llm.d.ts +8 -0
  60. package/dist/upstream/llm.js +1 -0
  61. package/dist/upstream/merge.d.ts +50 -0
  62. package/dist/upstream/merge.js +153 -0
  63. package/dist/upstream/prompts.d.ts +53 -0
  64. package/dist/upstream/prompts.js +181 -0
  65. package/dist/upstream/search-utils.d.ts +34 -0
  66. package/dist/upstream/search-utils.js +55 -0
  67. package/dist/upstream/slug.d.ts +26 -0
  68. package/dist/upstream/slug.js +103 -0
  69. package/dist/upstream/template.d.ts +29 -0
  70. package/dist/upstream/template.js +80 -0
  71. package/dist/upstream/tokenize.d.ts +4 -0
  72. package/dist/upstream/tokenize.js +29 -0
  73. package/dist/wiki-change.d.ts +76 -0
  74. package/dist/wiki-change.js +299 -0
  75. package/dist/wiki-entry.d.ts +26 -0
  76. package/dist/wiki-entry.js +93 -0
  77. package/dist/wiki-ingest.d.ts +12 -0
  78. package/dist/wiki-ingest.js +126 -0
  79. package/dist/wiki-migration.d.ts +16 -0
  80. package/dist/wiki-migration.js +268 -0
  81. package/dist/wiki-tokens.d.ts +1 -0
  82. package/dist/wiki-tokens.js +46 -0
  83. package/dist/wiki.d.ts +103 -0
  84. package/dist/wiki.js +330 -0
  85. package/dist/workflow-cli.d.ts +2 -0
  86. package/dist/workflow-cli.js +319 -0
  87. package/dist/workflow-install.d.ts +37 -0
  88. package/dist/workflow-install.js +148 -0
  89. package/dist/workflow-knowledge.d.ts +18 -0
  90. package/dist/workflow-knowledge.js +32 -0
  91. package/dist/workflow-mcp.d.ts +2 -0
  92. package/dist/workflow-mcp.js +137 -0
  93. package/dist/workflow-names.d.ts +4 -0
  94. package/dist/workflow-names.js +31 -0
  95. package/dist/workflow-runtime.d.ts +735 -0
  96. package/dist/workflow-runtime.js +747 -0
  97. package/dist/workflow-skills.d.ts +48 -0
  98. package/dist/workflow-skills.js +141 -0
  99. package/docs/images/impeccable-skill.png +0 -0
  100. package/docs/images/workflow-overview.png +0 -0
  101. package/docs/images/workflow-skills.png +0 -0
  102. package/package.json +77 -4
  103. package/skills/ew-impeccable/LICENSE +191 -0
  104. package/skills/ew-impeccable/NOTICE.md +19 -0
  105. package/skills/ew-impeccable/SKILL.md +91 -0
  106. package/skills/ew-impeccable/UPSTREAM.md +23 -0
  107. package/skills/ew-impeccable/reference/adapt.md +314 -0
  108. package/skills/ew-impeccable/reference/adapt.native.md +60 -0
  109. package/skills/ew-impeccable/reference/android.md +46 -0
  110. package/skills/ew-impeccable/reference/animate.md +91 -0
  111. package/skills/ew-impeccable/reference/audit.md +138 -0
  112. package/skills/ew-impeccable/reference/audit.native.md +141 -0
  113. package/skills/ew-impeccable/reference/bolder.md +35 -0
  114. package/skills/ew-impeccable/reference/clarify.md +96 -0
  115. package/skills/ew-impeccable/reference/colorize.md +88 -0
  116. package/skills/ew-impeccable/reference/craft-floor.md +44 -0
  117. package/skills/ew-impeccable/reference/craft.md +5 -0
  118. package/skills/ew-impeccable/reference/critique.md +808 -0
  119. package/skills/ew-impeccable/reference/degraded/asset-producer.md +36 -0
  120. package/skills/ew-impeccable/reference/degraded/documenter.md +23 -0
  121. package/skills/ew-impeccable/reference/degraded/finish-reviewer.md +72 -0
  122. package/skills/ew-impeccable/reference/degraded/manual-edit-applier.md +91 -0
  123. package/skills/ew-impeccable/reference/delight.md +72 -0
  124. package/skills/ew-impeccable/reference/distill.md +113 -0
  125. package/skills/ew-impeccable/reference/doctor.md +56 -0
  126. package/skills/ew-impeccable/reference/document.md +418 -0
  127. package/skills/ew-impeccable/reference/extract.md +68 -0
  128. package/skills/ew-impeccable/reference/harden.md +338 -0
  129. package/skills/ew-impeccable/reference/hooks.md +113 -0
  130. package/skills/ew-impeccable/reference/init.md +133 -0
  131. package/skills/ew-impeccable/reference/ios.md +51 -0
  132. package/skills/ew-impeccable/reference/layout.md +86 -0
  133. package/skills/ew-impeccable/reference/live-setup.md +102 -0
  134. package/skills/ew-impeccable/reference/live.md +326 -0
  135. package/skills/ew-impeccable/reference/new-work.md +209 -0
  136. package/skills/ew-impeccable/reference/onboard.md +236 -0
  137. package/skills/ew-impeccable/reference/operate.md +61 -0
  138. package/skills/ew-impeccable/reference/optimize.md +260 -0
  139. package/skills/ew-impeccable/reference/overdrive.md +127 -0
  140. package/skills/ew-impeccable/reference/polish.md +105 -0
  141. package/skills/ew-impeccable/reference/quieter.md +101 -0
  142. package/skills/ew-impeccable/reference/routing.md +20 -0
  143. package/skills/ew-impeccable/reference/shape.md +59 -0
  144. package/skills/ew-impeccable/reference/typeset.md +82 -0
  145. package/skills/ew-impeccable/reference/visualize.md +46 -0
  146. package/skills/ew-impeccable/scripts/build-phase.mjs +1022 -0
  147. package/skills/ew-impeccable/scripts/command-metadata.json +94 -0
  148. package/skills/ew-impeccable/scripts/comp-diff.mjs +391 -0
  149. package/skills/ew-impeccable/scripts/comp-spec.mjs +513 -0
  150. package/skills/ew-impeccable/scripts/concept-seed.mjs +814 -0
  151. package/skills/ew-impeccable/scripts/context-signals.mjs +325 -0
  152. package/skills/ew-impeccable/scripts/context.mjs +1521 -0
  153. package/skills/ew-impeccable/scripts/critique-storage.mjs +473 -0
  154. package/skills/ew-impeccable/scripts/data/font-index-failures.json +121 -0
  155. package/skills/ew-impeccable/scripts/data/font-index.json +1 -0
  156. package/skills/ew-impeccable/scripts/detect-csp.mjs +246 -0
  157. package/skills/ew-impeccable/scripts/detect.mjs +30 -0
  158. package/skills/ew-impeccable/scripts/detector/browser/injected/index.mjs +2580 -0
  159. package/skills/ew-impeccable/scripts/detector/cli/main.mjs +498 -0
  160. package/skills/ew-impeccable/scripts/detector/design-system.mjs +1311 -0
  161. package/skills/ew-impeccable/scripts/detector/detect-antipatterns-browser.js +9486 -0
  162. package/skills/ew-impeccable/scripts/detector/detect-antipatterns.mjs +51 -0
  163. package/skills/ew-impeccable/scripts/detector/engines/browser/detect-url.mjs +434 -0
  164. package/skills/ew-impeccable/scripts/detector/engines/regex/detect-text.mjs +1439 -0
  165. package/skills/ew-impeccable/scripts/detector/engines/static-html/css-cascade.mjs +1242 -0
  166. package/skills/ew-impeccable/scripts/detector/engines/static-html/detect-html.mjs +263 -0
  167. package/skills/ew-impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +189 -0
  168. package/skills/ew-impeccable/scripts/detector/findings.mjs +23 -0
  169. package/skills/ew-impeccable/scripts/detector/node/file-system.mjs +225 -0
  170. package/skills/ew-impeccable/scripts/detector/profile/profiler.mjs +166 -0
  171. package/skills/ew-impeccable/scripts/detector/registry/antipatterns.mjs +636 -0
  172. package/skills/ew-impeccable/scripts/detector/rules/checks.mjs +5750 -0
  173. package/skills/ew-impeccable/scripts/detector/shared/color.mjs +596 -0
  174. package/skills/ew-impeccable/scripts/detector/shared/constants.mjs +127 -0
  175. package/skills/ew-impeccable/scripts/detector/shared/fonts.mjs +30 -0
  176. package/skills/ew-impeccable/scripts/detector/shared/inline-ignores.mjs +148 -0
  177. package/skills/ew-impeccable/scripts/detector/shared/page.mjs +7 -0
  178. package/skills/ew-impeccable/scripts/detector/vendor/MDN-DATA-LICENSE +116 -0
  179. package/skills/ew-impeccable/scripts/detector/vendor/THIRD_PARTY_LICENSES.md +227 -0
  180. package/skills/ew-impeccable/scripts/detector/vendor/static-html-parser.build-entry.txt +11 -0
  181. package/skills/ew-impeccable/scripts/detector/vendor/static-html-parser.bundle.mjs +9121 -0
  182. package/skills/ew-impeccable/scripts/doctor.mjs +330 -0
  183. package/skills/ew-impeccable/scripts/embed-prompt.mjs +166 -0
  184. package/skills/ew-impeccable/scripts/font-match.mjs +457 -0
  185. package/skills/ew-impeccable/scripts/generate-image.mjs +447 -0
  186. package/skills/ew-impeccable/scripts/hook-admin.mjs +829 -0
  187. package/skills/ew-impeccable/scripts/hook-before-edit.mjs +538 -0
  188. package/skills/ew-impeccable/scripts/hook-lib.mjs +2493 -0
  189. package/skills/ew-impeccable/scripts/hook.mjs +79 -0
  190. package/skills/ew-impeccable/scripts/lib/artifact-schema.mjs +93 -0
  191. package/skills/ew-impeccable/scripts/lib/composition-catalog.mjs +200 -0
  192. package/skills/ew-impeccable/scripts/lib/concept-catalog.mjs +395 -0
  193. package/skills/ew-impeccable/scripts/lib/design-parser.mjs +880 -0
  194. package/skills/ew-impeccable/scripts/lib/font-fingerprint.mjs +564 -0
  195. package/skills/ew-impeccable/scripts/lib/font-index.mjs +130 -0
  196. package/skills/ew-impeccable/scripts/lib/hero-checks.mjs +246 -0
  197. package/skills/ew-impeccable/scripts/lib/image-metrics.mjs +306 -0
  198. package/skills/ew-impeccable/scripts/lib/impeccable-config.mjs +640 -0
  199. package/skills/ew-impeccable/scripts/lib/impeccable-paths.mjs +137 -0
  200. package/skills/ew-impeccable/scripts/lib/is-generated.mjs +72 -0
  201. package/skills/ew-impeccable/scripts/lib/live-path-globs.mjs +37 -0
  202. package/skills/ew-impeccable/scripts/lib/open-system-browser.mjs +26 -0
  203. package/skills/ew-impeccable/scripts/lib/png.mjs +281 -0
  204. package/skills/ew-impeccable/scripts/lib/provider.mjs +5 -0
  205. package/skills/ew-impeccable/scripts/lib/raster.mjs +194 -0
  206. package/skills/ew-impeccable/scripts/lib/roll-selection.mjs +369 -0
  207. package/skills/ew-impeccable/scripts/lib/staleness-deep.mjs +491 -0
  208. package/skills/ew-impeccable/scripts/lib/staleness-notice.mjs +169 -0
  209. package/skills/ew-impeccable/scripts/lib/staleness.mjs +532 -0
  210. package/skills/ew-impeccable/scripts/lib/surface-briefs.mjs +149 -0
  211. package/skills/ew-impeccable/scripts/lib/target-args.mjs +42 -0
  212. package/skills/ew-impeccable/scripts/lib/target-slug.mjs +33 -0
  213. package/skills/ew-impeccable/scripts/lib/template-extensions.mjs +146 -0
  214. package/skills/ew-impeccable/scripts/live/accept-css.mjs +617 -0
  215. package/skills/ew-impeccable/scripts/live/accept-verify.mjs +60 -0
  216. package/skills/ew-impeccable/scripts/live/browser-script-parts.mjs +84 -0
  217. package/skills/ew-impeccable/scripts/live/completion.mjs +28 -0
  218. package/skills/ew-impeccable/scripts/live/event-validation.mjs +199 -0
  219. package/skills/ew-impeccable/scripts/live/frameworks/astro.mjs +47 -0
  220. package/skills/ew-impeccable/scripts/live/frameworks/detect-utils.mjs +73 -0
  221. package/skills/ew-impeccable/scripts/live/frameworks/index.mjs +143 -0
  222. package/skills/ew-impeccable/scripts/live/frameworks/journal.mjs +197 -0
  223. package/skills/ew-impeccable/scripts/live/frameworks/nextjs.mjs +49 -0
  224. package/skills/ew-impeccable/scripts/live/frameworks/nuxt.mjs +161 -0
  225. package/skills/ew-impeccable/scripts/live/frameworks/script-src.mjs +17 -0
  226. package/skills/ew-impeccable/scripts/live/frameworks/static-html.mjs +26 -0
  227. package/skills/ew-impeccable/scripts/live/frameworks/sveltekit.mjs +71 -0
  228. package/skills/ew-impeccable/scripts/live/frameworks/tag-strategy.mjs +247 -0
  229. package/skills/ew-impeccable/scripts/live/frameworks/tanstack-start.mjs +70 -0
  230. package/skills/ew-impeccable/scripts/live/frameworks/vite-generic.mjs +42 -0
  231. package/skills/ew-impeccable/scripts/live/generation-preflight.mjs +149 -0
  232. package/skills/ew-impeccable/scripts/live/insert-ui.mjs +458 -0
  233. package/skills/ew-impeccable/scripts/live/instructions.mjs +142 -0
  234. package/skills/ew-impeccable/scripts/live/manual-apply.mjs +939 -0
  235. package/skills/ew-impeccable/scripts/live/manual-edit-routes.mjs +357 -0
  236. package/skills/ew-impeccable/scripts/live/manual-edits-buffer.mjs +152 -0
  237. package/skills/ew-impeccable/scripts/live/poll-lanes.mjs +14 -0
  238. package/skills/ew-impeccable/scripts/live/project-ignores.mjs +139 -0
  239. package/skills/ew-impeccable/scripts/live/roots.mjs +508 -0
  240. package/skills/ew-impeccable/scripts/live/session-store.mjs +563 -0
  241. package/skills/ew-impeccable/scripts/live/source-lock.mjs +105 -0
  242. package/skills/ew-impeccable/scripts/live/source-search.mjs +105 -0
  243. package/skills/ew-impeccable/scripts/live/svelte-ast.mjs +969 -0
  244. package/skills/ew-impeccable/scripts/live/svelte-component.mjs +1366 -0
  245. package/skills/ew-impeccable/scripts/live/sveltekit-adapter.mjs +304 -0
  246. package/skills/ew-impeccable/scripts/live/tanstack-adapter.mjs +259 -0
  247. package/skills/ew-impeccable/scripts/live/ui-surfaces.mjs +75 -0
  248. package/skills/ew-impeccable/scripts/live/vocabulary.mjs +171 -0
  249. package/skills/ew-impeccable/scripts/live-accept.mjs +938 -0
  250. package/skills/ew-impeccable/scripts/live-browser-dom.js +167 -0
  251. package/skills/ew-impeccable/scripts/live-browser-ignores.js +242 -0
  252. package/skills/ew-impeccable/scripts/live-browser-session.js +144 -0
  253. package/skills/ew-impeccable/scripts/live-browser.js +12851 -0
  254. package/skills/ew-impeccable/scripts/live-commit-manual-edits.mjs +1200 -0
  255. package/skills/ew-impeccable/scripts/live-complete.mjs +107 -0
  256. package/skills/ew-impeccable/scripts/live-copy-edit-agent.mjs +800 -0
  257. package/skills/ew-impeccable/scripts/live-discard-manual-edits.mjs +51 -0
  258. package/skills/ew-impeccable/scripts/live-inject.mjs +463 -0
  259. package/skills/ew-impeccable/scripts/live-insert.mjs +292 -0
  260. package/skills/ew-impeccable/scripts/live-manual-edit-evidence.mjs +368 -0
  261. package/skills/ew-impeccable/scripts/live-poll.mjs +430 -0
  262. package/skills/ew-impeccable/scripts/live-resume.mjs +123 -0
  263. package/skills/ew-impeccable/scripts/live-server.mjs +1698 -0
  264. package/skills/ew-impeccable/scripts/live-status.mjs +71 -0
  265. package/skills/ew-impeccable/scripts/live-target.mjs +30 -0
  266. package/skills/ew-impeccable/scripts/live-wrap.mjs +927 -0
  267. package/skills/ew-impeccable/scripts/live.mjs +334 -0
  268. package/skills/ew-impeccable/scripts/modern-screenshot.umd.js +14 -0
  269. package/skills/ew-impeccable/scripts/palette.mjs +628 -0
  270. package/skills/ew-impeccable/scripts/pin.mjs +352 -0
  271. package/skills/ew-impeccable/scripts/serve-question.mjs +1783 -0
  272. package/skills/ew-impeccable/scripts/surface-brief.mjs +74 -0
  273. package/skills/ew-knowledge/SKILL.md +35 -0
  274. package/skills/ew-knowledge/references/closeout-protocol.md +68 -0
  275. package/skills/ew-knowledge/references/knowledge-route.md +73 -0
  276. package/skills/ew-knowledge/references/wiki-maintenance.md +27 -0
  277. package/skills/ew-odyssey/SKILL.md +106 -0
  278. package/skills/ew-odyssey/references/audit-artifacts.md +7 -0
  279. package/skills/ew-odyssey/references/odyssey-base.md +104 -0
  280. package/skills/ew-odyssey/references/odyssey-debug.md +264 -0
  281. package/skills/ew-odyssey/references/odyssey-defensive.md +351 -0
  282. package/skills/ew-odyssey/references/odyssey-improve.md +230 -0
  283. package/skills/ew-odyssey/references/odyssey-planex.md +294 -0
  284. package/skills/ew-odyssey/references/odyssey-review.md +233 -0
  285. package/skills/ew-odyssey/references/odyssey-security.md +231 -0
  286. package/skills/ew-odyssey/references/odyssey-ui.md +232 -0
  287. package/skills/ew-odyssey/references/prepare/odyssey-debug.md +102 -0
  288. package/skills/ew-odyssey/references/prepare/odyssey-defensive.md +117 -0
  289. package/skills/ew-odyssey/references/prepare/odyssey-improve.md +95 -0
  290. package/skills/ew-odyssey/references/prepare/odyssey-planex.md +105 -0
  291. package/skills/ew-odyssey/references/prepare/odyssey-review.md +105 -0
  292. package/skills/ew-odyssey/references/prepare/odyssey-security.md +91 -0
  293. package/skills/ew-odyssey/references/prepare/odyssey-ui.md +88 -0
  294. package/skills/ew-odyssey/references/runtime-adapters.md +31 -0
  295. package/skills/ew-orchestrate/SKILL.md +89 -0
  296. package/skills/ew-orchestrate/references/auto-policy.md +66 -0
  297. package/skills/ew-orchestrate/references/boundary-grill.md +51 -0
  298. package/skills/ew-orchestrate/references/companion-route.md +40 -0
  299. package/skills/ew-orchestrate/references/ew-orchestrate.md +44 -0
  300. package/skills/ew-orchestrate/references/goal.md +51 -0
  301. package/skills/ew-orchestrate/references/orchestrator-run-loop.md +33 -0
  302. package/skills/ew-orchestrate/references/planning.md +54 -0
  303. package/skills/ew-orchestrate/steps/ew-analyze/SKILL.md +70 -0
  304. package/skills/ew-orchestrate/steps/ew-analyze/references/issue-gaps-analyze.md +24 -0
  305. package/skills/ew-orchestrate/steps/ew-analyze/references/prepare.md +8 -0
  306. package/skills/ew-orchestrate/steps/ew-analyze/references/workflow.md +138 -0
  307. package/skills/ew-orchestrate/steps/ew-auto-test/SKILL.md +80 -0
  308. package/skills/ew-orchestrate/steps/ew-auto-test/references/prepare.md +23 -0
  309. package/skills/ew-orchestrate/steps/ew-auto-test/references/workflow.md +31 -0
  310. package/skills/ew-orchestrate/steps/ew-blueprint/SKILL.md +122 -0
  311. package/skills/ew-orchestrate/steps/ew-blueprint/references/prepare.md +21 -0
  312. package/skills/ew-orchestrate/steps/ew-blueprint/references/workflow.md +28 -0
  313. package/skills/ew-orchestrate/steps/ew-brainstorm/SKILL.md +49 -0
  314. package/skills/ew-orchestrate/steps/ew-companion/SKILL.md +50 -0
  315. package/skills/ew-orchestrate/steps/ew-debug/SKILL.md +85 -0
  316. package/skills/ew-orchestrate/steps/ew-debug/references/prepare.md +27 -0
  317. package/skills/ew-orchestrate/steps/ew-debug/references/workflow.md +31 -0
  318. package/skills/ew-orchestrate/steps/ew-execute/SKILL.md +74 -0
  319. package/skills/ew-orchestrate/steps/ew-execute/references/prepare.md +27 -0
  320. package/skills/ew-orchestrate/steps/ew-execute/references/workflow.md +87 -0
  321. package/skills/ew-orchestrate/steps/ew-grill/SKILL.md +62 -0
  322. package/skills/ew-orchestrate/steps/ew-grill/references/prepare.md +26 -0
  323. package/skills/ew-orchestrate/steps/ew-grill/references/workflow.md +31 -0
  324. package/skills/ew-orchestrate/steps/ew-init/SKILL.md +56 -0
  325. package/skills/ew-orchestrate/steps/ew-init/references/prepare.md +25 -0
  326. package/skills/ew-orchestrate/steps/ew-init/references/workflow.md +28 -0
  327. package/skills/ew-orchestrate/steps/ew-plan/SKILL.md +131 -0
  328. package/skills/ew-orchestrate/steps/ew-plan/references/prepare.md +8 -0
  329. package/skills/ew-orchestrate/steps/ew-plan/references/tdd.md +53 -0
  330. package/skills/ew-orchestrate/steps/ew-plan/references/workflow.md +100 -0
  331. package/skills/ew-orchestrate/steps/ew-retrospective/SKILL.md +68 -0
  332. package/skills/ew-orchestrate/steps/ew-retrospective/references/prepare.md +18 -0
  333. package/skills/ew-orchestrate/steps/ew-retrospective/references/workflow.md +34 -0
  334. package/skills/ew-orchestrate/steps/ew-review/SKILL.md +45 -0
  335. package/skills/ew-orchestrate/steps/ew-review/references/prepare.md +17 -0
  336. package/skills/ew-orchestrate/steps/ew-review/references/workflow.md +116 -0
  337. package/skills/ew-orchestrate/steps/ew-roadmap/SKILL.md +62 -0
  338. package/skills/ew-orchestrate/steps/ew-roadmap/references/prepare.md +27 -0
  339. package/skills/ew-orchestrate/steps/ew-roadmap/references/workflow.md +28 -0
  340. package/skills/ew-orchestrate/steps/ew-test/SKILL.md +99 -0
  341. package/skills/ew-orchestrate/steps/ew-test/references/prepare.md +23 -0
  342. package/skills/ew-orchestrate/steps/ew-test/references/workflow.md +23 -0
  343. package/skills/ew-orchestrate/steps/ew-verify/SKILL.md +73 -0
  344. package/skills/ew-orchestrate/steps/ew-verify/references/prepare.md +21 -0
  345. package/skills/ew-orchestrate/steps/ew-verify/references/workflow.md +29 -0
  346. package/skills/ew-skill-design/SKILL.md +30 -0
  347. package/skills/ew-skill-design/references/package-contract.md +40 -0
  348. package/skills/ew-skill-design/references/validation.md +21 -0
  349. package/skills/team-swarm/SKILL.md +68 -0
  350. package/skills/team-swarm/references/mcp-coordination.md +14 -0
  351. package/skills/team-swarm/roles/analyst/role.md +181 -0
  352. package/skills/team-swarm/roles/ant/role.md +149 -0
  353. package/skills/team-swarm/roles/coordinator/commands/converge.md +112 -0
  354. package/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
  355. package/skills/team-swarm/roles/coordinator/commands/iterate.md +171 -0
  356. package/skills/team-swarm/roles/coordinator/role.md +170 -0
  357. package/skills/team-swarm/roles/scorer/role.md +150 -0
  358. package/skills/team-swarm/scripts/aco.py +646 -0
  359. package/skills/team-swarm/scripts/pheromone.py +144 -0
  360. package/skills/team-swarm/scripts/scoring.py +111 -0
  361. package/skills/team-swarm/scripts/test_aco.py +606 -0
  362. package/skills/team-swarm/specs/ant-output-schema.md +127 -0
  363. package/skills/team-swarm/specs/convergence-criteria.md +108 -0
  364. package/skills/team-swarm/specs/pheromone-schema.md +125 -0
  365. package/skills/team-swarm/specs/swarm-config-template.json +71 -0
  366. package/skills/team-swarm/specs/swarm-protocol.md +119 -0
  367. package/skills/workflow-evolve/SKILL.md +64 -0
  368. package/skills/workflow-evolve/references/agy-gate.md +27 -0
  369. package/skills/workflow-evolve/references/auto-loop.md +23 -0
  370. package/skills/workflow-evolve/references/history-review.md +15 -0
  371. package/skills/workflow-evolve/scripts/codex-memory-replay.mjs +86 -0
  372. package/skills/workflow-evolve/scripts/codex-replay.mjs +1 -0
  373. package/skills/workflow-evolve/scripts/evolve-loop.mjs +260 -0
  374. package/skills/workflow-evolve/scripts/memory-codex-mcp.mjs +124 -0
  375. package/workflows/index.json +33 -0
@@ -0,0 +1,1439 @@
1
+ import { GENERIC_FONTS, OVERUSED_FONTS, EM_DASH_FLOOR, EM_DASH_CHARS_PER_DASH } from '../../shared/constants.mjs';
2
+ import { isNeutralColor } from '../../shared/color.mjs';
3
+ import { extractGoogleFontFamilies } from '../../shared/fonts.mjs';
4
+ import { checkSourceDesignSystem } from '../../design-system.mjs';
5
+ import { scanCssTextForGlow, scanCssTextForGridBackground, scanCssTextForMarquee, scanCssTextForPseudoStripe, scanCssTextForRadialHalo } from '../../rules/checks.mjs';
6
+ import { isFullPage } from '../../shared/page.mjs';
7
+ import { applyInlineIgnores } from '../../shared/inline-ignores.mjs';
8
+ import { finding } from '../../findings.mjs';
9
+ import { profileFindings, profileStep } from '../../profile/profiler.mjs';
10
+
11
+ // ---------------------------------------------------------------------------
12
+ // Regex fallback (non-HTML files: CSS, JSX, TSX, etc.)
13
+ // ---------------------------------------------------------------------------
14
+
15
+ const hasRounded = (line) =>
16
+ /\brounded(?:-\w+)?\b/.test(line.replace(/\brounded-none\b/g, ''));
17
+ const hasBorderRadius = (line) => /border-radius/i.test(line);
18
+ const isSafeElement = (line) => /<(?:blockquote|nav[\s>]|pre[\s>]|code[\s>]|a\s|input[\s>]|span[\s>])/i.test(line);
19
+
20
+
21
+ /** Strip HTML to plain text — drops script/style/comments/tags so
22
+ * content-text analyzers don't false-positive on code or CSS. */
23
+ function stripHtmlToText(html) {
24
+ return html
25
+ .replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, ' ')
26
+ .replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, ' ')
27
+ .replace(/<!--[\s\S]*?-->/g, ' ')
28
+ .replace(/<[^>]+>/g, ' ')
29
+ .replace(/\s+/g, ' ');
30
+ }
31
+
32
+ const PAGE_ANALYZER_EXTS = new Set(['.html', '.htm', '.astro', '.vue', '.svelte']);
33
+
34
+ function extFromFilePath(filePath) {
35
+ return filePath ? (filePath.match(/\.\w+$/)?.[0] || '').toLowerCase() : '';
36
+ }
37
+
38
+ function shouldRunPageAnalyzers(content, filePath) {
39
+ if (!isFullPage(content)) return false;
40
+ const ext = extFromFilePath(filePath);
41
+ return !ext || PAGE_ANALYZER_EXTS.has(ext);
42
+ }
43
+
44
+ const JS_SOURCE_EXTS = new Set(['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs']);
45
+ const STYLESHEET_EXTS = new Set(['.css', '.scss', '.sass', '.less']);
46
+ const REGEX_PREFIX_KEYWORDS = new Set(['await', 'case', 'default', 'delete', 'do', 'else', 'in', 'instanceof', 'new', 'of', 'return', 'throw', 'typeof', 'void', 'yield']);
47
+ const BLOCK_BRACE_PREFIX_KEYWORDS = new Set(['do', 'else', 'finally', 'try']);
48
+
49
+ function isInsideOpeningJsxTag(source) {
50
+ const tagStart = source.lastIndexOf('<');
51
+ if (tagStart === -1 || !/^<[A-Za-z][\w.:-]*/.test(source.slice(tagStart))) return false;
52
+
53
+ let quote = '';
54
+ for (let cursor = tagStart + 1; cursor < source.length; cursor++) {
55
+ const char = source[cursor];
56
+ if (quote) {
57
+ if (char === '\\') cursor++;
58
+ else if (char === quote) quote = '';
59
+ } else if (char === "'" || char === '"') {
60
+ quote = char;
61
+ } else if (char === '>') {
62
+ return false;
63
+ }
64
+ }
65
+ return true;
66
+ }
67
+
68
+ /**
69
+ * Blank JavaScript comments without moving any following source. Regex
70
+ * findings keep their original line numbers, while prose examples inside
71
+ * comments cannot masquerade as rendered markup.
72
+ */
73
+ function stripJsComments(content, options = {}) {
74
+ let state = 'code';
75
+ let output = '';
76
+ let lastSignificant = '';
77
+ let previousSignificant = '';
78
+ let antePreviousSignificant = '';
79
+ let currentWord = '';
80
+ let currentWordPrefix = '';
81
+ let wordSeparated = false;
82
+ let regexCharClass = false;
83
+ let jsxExpressionDepth = 0;
84
+ let lastClosedBraceKind = '';
85
+ const braceKinds = [];
86
+ const templateExpressionDepths = [];
87
+
88
+ const braceKind = (startsJsxExpression = false) => (
89
+ !startsJsxExpression && (
90
+ !lastSignificant ||
91
+ lastSignificant === ')' ||
92
+ lastSignificant === ';' ||
93
+ lastSignificant === '}' ||
94
+ (previousSignificant === '=' && lastSignificant === '>') ||
95
+ BLOCK_BRACE_PREFIX_KEYWORDS.has(currentWord)
96
+ ) ? 'block' : 'expression'
97
+ );
98
+
99
+ const recordSignificant = (char) => {
100
+ if (/\s/.test(char)) {
101
+ wordSeparated = true;
102
+ return;
103
+ }
104
+ const isWordChar = /[\w$]/.test(char);
105
+ if (isWordChar && (wordSeparated || !currentWord)) {
106
+ currentWord = '';
107
+ currentWordPrefix = lastSignificant;
108
+ } else if (!isWordChar) {
109
+ currentWordPrefix = '';
110
+ }
111
+ wordSeparated = false;
112
+ antePreviousSignificant = previousSignificant;
113
+ previousSignificant = lastSignificant;
114
+ lastSignificant = char;
115
+ currentWord = isWordChar ? currentWord + char : '';
116
+ };
117
+
118
+ for (let i = 0; i < content.length; i++) {
119
+ const char = content[i];
120
+ const next = content[i + 1];
121
+
122
+ if (state === 'line-comment') {
123
+ if (char === '\n') {
124
+ output += char;
125
+ state = 'code';
126
+ } else {
127
+ output += ' ';
128
+ }
129
+ continue;
130
+ }
131
+
132
+ if (state === 'block-comment') {
133
+ if (char === '*' && next === '/') {
134
+ output += ' ';
135
+ i++;
136
+ state = 'code';
137
+ } else {
138
+ output += char === '\n' ? '\n' : ' ';
139
+ }
140
+ continue;
141
+ }
142
+
143
+ if (state === 'regex') {
144
+ output += char;
145
+ if (char === '\\' && next) {
146
+ output += next;
147
+ i++;
148
+ } else if (char === '[') {
149
+ regexCharClass = true;
150
+ } else if (char === ']') {
151
+ regexCharClass = false;
152
+ } else if (char === '/' && !regexCharClass) {
153
+ state = 'code';
154
+ recordSignificant('/');
155
+ }
156
+ continue;
157
+ }
158
+
159
+ if (state === 'template' && char === '$' && next === '{') {
160
+ output += '${';
161
+ i++;
162
+ recordSignificant('$');
163
+ recordSignificant('{');
164
+ templateExpressionDepths.push(1);
165
+ braceKinds.push('expression');
166
+ if (jsxExpressionDepth) jsxExpressionDepth++;
167
+ state = 'code';
168
+ continue;
169
+ }
170
+
171
+ if (state !== 'code') {
172
+ output += char;
173
+ if (char === '\\' && next) {
174
+ output += next;
175
+ i++;
176
+ } else if (
177
+ (state === 'single-quote' && char === "'") ||
178
+ (state === 'double-quote' && char === '"') ||
179
+ (state === 'template' && char === '`')
180
+ ) {
181
+ state = 'code';
182
+ recordSignificant(char);
183
+ }
184
+ continue;
185
+ }
186
+
187
+ const jsxUrlSeparator = options.jsx && char === '/' && next === '/' &&
188
+ jsxExpressionDepth === 0 &&
189
+ (output.endsWith('http:') ||
190
+ output.endsWith('https:') ||
191
+ (/<[A-Za-z](?:[^>]*[^/])?>[^<]*$/.test(output.slice(output.lastIndexOf('\n') + 1)) &&
192
+ /^[\w.-]+\.[A-Za-z]{2,}(?=[:/?#\s<]|$)/.test(content.slice(i + 2))));
193
+ const afterPostfixUpdate = (lastSignificant === '+' || lastSignificant === '-') &&
194
+ previousSignificant === lastSignificant &&
195
+ antePreviousSignificant !== lastSignificant;
196
+ if (char === '/' && next === '/' && jsxUrlSeparator) {
197
+ output += '//';
198
+ i++;
199
+ recordSignificant('/');
200
+ recordSignificant('/');
201
+ } else if (char === '/' && next === '/') {
202
+ output += ' ';
203
+ i++;
204
+ state = 'line-comment';
205
+ } else if (char === '/' && next === '*') {
206
+ output += ' ';
207
+ i++;
208
+ state = 'block-comment';
209
+ } else if (templateExpressionDepths.length && char === '{') {
210
+ output += char;
211
+ templateExpressionDepths[templateExpressionDepths.length - 1]++;
212
+ braceKinds.push(braceKind());
213
+ if (jsxExpressionDepth) jsxExpressionDepth++;
214
+ recordSignificant(char);
215
+ } else if (templateExpressionDepths.length && char === '}') {
216
+ output += char;
217
+ const depthIndex = templateExpressionDepths.length - 1;
218
+ templateExpressionDepths[depthIndex]--;
219
+ lastClosedBraceKind = braceKinds.pop() || '';
220
+ if (jsxExpressionDepth) jsxExpressionDepth--;
221
+ recordSignificant(char);
222
+ if (templateExpressionDepths[depthIndex] === 0) {
223
+ templateExpressionDepths.pop();
224
+ state = 'template';
225
+ }
226
+ } else if (
227
+ char === '/' &&
228
+ (!lastSignificant ||
229
+ (/[=([{!?:;,&|+\-*%^~<>]/.test(lastSignificant) && !afterPostfixUpdate) ||
230
+ (lastSignificant === '}' && lastClosedBraceKind === 'block') ||
231
+ (previousSignificant === '=' && lastSignificant === '>') ||
232
+ (currentWordPrefix !== '.' && REGEX_PREFIX_KEYWORDS.has(currentWord)))
233
+ ) {
234
+ output += char;
235
+ state = 'regex';
236
+ regexCharClass = false;
237
+ } else {
238
+ output += char;
239
+ const startsJsxExpression = options.jsx && char === '{' && jsxExpressionDepth === 0 &&
240
+ (/<[A-Za-z](?:[^>]*[^/])?>[^<]*$/.test(output.slice(output.lastIndexOf('\n') + 1, -1)) ||
241
+ isInsideOpeningJsxTag(output.slice(0, -1)));
242
+ if (char === '{') braceKinds.push(braceKind(startsJsxExpression));
243
+ else if (char === '}') lastClosedBraceKind = braceKinds.pop() || '';
244
+ if (char === '{' && (jsxExpressionDepth || startsJsxExpression)) jsxExpressionDepth++;
245
+ else if (char === '}' && jsxExpressionDepth) jsxExpressionDepth--;
246
+ recordSignificant(char);
247
+ if (char === "'") state = 'single-quote';
248
+ else if (char === '"') state = 'double-quote';
249
+ else if (char === '`') state = 'template';
250
+ }
251
+ }
252
+
253
+ return output;
254
+ }
255
+
256
+ function stripCssComments(content) {
257
+ return content.replace(/\/\*[\s\S]*?\*\//g, comment => comment.replace(/[^\n]/g, ' '));
258
+ }
259
+
260
+ function blankHtmlComments(text) {
261
+ return text.replace(/<!--[\s\S]*?-->/g, comment => comment.replace(/[^\n]/g, ' '));
262
+ }
263
+
264
+ function blankCssLineCommentsInStyleBlocks(text) {
265
+ const re = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
266
+ let output = '';
267
+ let lastIndex = 0;
268
+ let match;
269
+ while ((match = re.exec(text)) !== null) {
270
+ const inner = match[1];
271
+ const openLength = match[0].length - inner.length - '</style>'.length;
272
+ output += text.slice(lastIndex, match.index);
273
+ output += match[0].slice(0, openLength);
274
+ output += blankCssLineComments(inner);
275
+ output += match[0].slice(openLength + inner.length);
276
+ lastIndex = re.lastIndex;
277
+ }
278
+ return output + text.slice(lastIndex);
279
+ }
280
+
281
+ function blankHtmlAndCssCommentsOutsideScripts(text) {
282
+ const re = /<script\b[^>]*>[\s\S]*?<\/script>/gi;
283
+ let output = '';
284
+ let lastIndex = 0;
285
+ let match;
286
+ while ((match = re.exec(text)) !== null) {
287
+ output += blankCssLineCommentsInStyleBlocks(stripCssComments(blankHtmlComments(text.slice(lastIndex, match.index))));
288
+ output += match[0];
289
+ lastIndex = re.lastIndex;
290
+ }
291
+ return output + blankCssLineCommentsInStyleBlocks(stripCssComments(blankHtmlComments(text.slice(lastIndex))));
292
+ }
293
+
294
+ function blankCssLineComments(text) {
295
+ let output = '';
296
+ let state = 'code';
297
+ let urlDepth = 0;
298
+ for (let i = 0; i < text.length; i++) {
299
+ const char = text[i];
300
+ const next = text[i + 1];
301
+ if (state === 'line') {
302
+ if (char === '\n') {
303
+ output += '\n';
304
+ state = 'code';
305
+ } else {
306
+ output += ' ';
307
+ }
308
+ continue;
309
+ }
310
+ if (state === 'single' || state === 'double') {
311
+ output += char;
312
+ if (char === '\\' && next) {
313
+ output += next;
314
+ i++;
315
+ } else if ((state === 'single' && char === "'") || (state === 'double' && char === '"')) {
316
+ state = 'code';
317
+ }
318
+ continue;
319
+ }
320
+ const prev = output.length ? output[output.length - 1] : '';
321
+ if (char === '/' && next === '/' && urlDepth === 0 && prev !== ':' && prev !== '(' && prev !== '\\') {
322
+ output += ' ';
323
+ i++;
324
+ state = 'line';
325
+ continue;
326
+ }
327
+ if (char === "'") state = 'single';
328
+ else if (char === '"') state = 'double';
329
+ if (char === '(') {
330
+ const behind = output.replace(/\s+$/, '');
331
+ if (urlDepth > 0 || /url$/i.test(behind)) urlDepth++;
332
+ } else if (char === ')' && urlDepth) {
333
+ urlDepth--;
334
+ }
335
+ output += char;
336
+ }
337
+ return output;
338
+ }
339
+
340
+ function findAstroFrontmatterClose(text) {
341
+ if (!text.startsWith('---')) return -1;
342
+ let cursor = text.indexOf('\n');
343
+ if (cursor === -1) return -1;
344
+ cursor += 1;
345
+ while (cursor < text.length) {
346
+ if (text[cursor - 1] === '\n' && text.startsWith('---', cursor)) {
347
+ let end = cursor + 3;
348
+ while (text[end] === ' ' || text[end] === '\t') end++;
349
+ if (end >= text.length || text[end] === '\n' || text[end] === '\r') return cursor - 1;
350
+ }
351
+ const char = text[cursor];
352
+ const next = text[cursor + 1];
353
+ if (char === "'" || char === '"') {
354
+ const close = findQuotedStringEnd(text, cursor, char);
355
+ if (close === -1) return -1;
356
+ cursor = close + 1;
357
+ continue;
358
+ }
359
+ if (char === '`') {
360
+ const close = findTemplateLiteralEnd(text, cursor);
361
+ if (close === -1) return -1;
362
+ cursor = close + 1;
363
+ continue;
364
+ }
365
+ if (char === '/' && next === '/') {
366
+ const lineEnd = text.indexOf('\n', cursor);
367
+ if (lineEnd === -1) return -1;
368
+ cursor = lineEnd;
369
+ continue;
370
+ }
371
+ if (char === '/' && next === '*') {
372
+ const commentEnd = text.indexOf('*/', cursor + 2);
373
+ if (commentEnd === -1) return -1;
374
+ cursor = commentEnd + 2;
375
+ continue;
376
+ }
377
+ if (char === '/' && next !== '/' && next !== '*') {
378
+ const close = findRegexLiteralEnd(text, cursor);
379
+ if (close !== -1) {
380
+ cursor = close + 1;
381
+ continue;
382
+ }
383
+ }
384
+ cursor++;
385
+ }
386
+ return -1;
387
+ }
388
+
389
+ function blankAstroFrontmatterComments(text) {
390
+ const close = findAstroFrontmatterClose(text);
391
+ if (close === -1) return text;
392
+ return stripJsComments(text.slice(0, close)) + text.slice(close);
393
+ }
394
+
395
+ function blankCommentsForMatchers(text, ext) {
396
+ if (PAGE_ANALYZER_EXTS.has(ext)) {
397
+ const withFrontmatter = ext === '.astro' ? blankAstroFrontmatterComments(text) : text;
398
+ return blankHtmlAndCssCommentsOutsideScripts(withFrontmatter);
399
+ }
400
+ if (STYLESHEET_EXTS.has(ext)) {
401
+ const withoutBlocks = stripCssComments(text);
402
+ return ext === '.css' ? withoutBlocks : blankCssLineComments(withoutBlocks);
403
+ }
404
+ return text;
405
+ }
406
+
407
+ function firstOverusedGoogleFont(text) {
408
+ return extractGoogleFontFamilies(text).find(f => OVERUSED_FONTS.has(f)) || '';
409
+ }
410
+
411
+ // CSS named colors whose channels are equal (achromatic). Anything outside
412
+ // this set falls through to the format parsers, and an unrecognized spelling
413
+ // stays non-neutral so a real accent is never skipped.
414
+ const NEUTRAL_COLOR_KEYWORDS = new Set([
415
+ 'transparent', 'currentcolor',
416
+ 'black', 'white', 'gray', 'grey', 'silver',
417
+ 'dimgray', 'dimgrey', 'darkgray', 'darkgrey', 'lightgray', 'lightgrey',
418
+ 'gainsboro', 'whitesmoke',
419
+ ]);
420
+
421
+ function hexChannels(color) {
422
+ const long = color.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})(?:[0-9a-f]{2})?$/i);
423
+ if (long) return [parseInt(long[1], 16), parseInt(long[2], 16), parseInt(long[3], 16)];
424
+ const short = color.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])(?:[0-9a-f])?$/i);
425
+ if (short) return [1, 2, 3].map((i) => parseInt(short[i] + short[i], 16));
426
+ return null;
427
+ }
428
+
429
+ /**
430
+ * Split one box-shadow layer into top-level tokens.
431
+ *
432
+ * Whitespace inside parens does not separate tokens: `rgb(0 0 0)` and
433
+ * `var(--x, 4px)` are each a single value, and splitting them on spaces would
434
+ * read their innards as separate lengths.
435
+ */
436
+ function tokenizeShadowLayer(layer) {
437
+ const tokens = [];
438
+ let depth = 0;
439
+ let current = '';
440
+ for (const char of String(layer || '')) {
441
+ if (char === '(') depth++;
442
+ else if (char === ')') depth--;
443
+ else if (depth === 0 && /\s/.test(char)) {
444
+ if (current) tokens.push(current);
445
+ current = '';
446
+ continue;
447
+ }
448
+ current += char;
449
+ }
450
+ if (current) tokens.push(current);
451
+ return tokens;
452
+ }
453
+
454
+ function lastMatch(text, re) {
455
+ const all = [...String(text || '').matchAll(re)];
456
+ return all.length ? all[all.length - 1] : null;
457
+ }
458
+
459
+ function isShadowLength(token) {
460
+ return /^-?\d*\.?\d+(?:px)?$/i.test(String(token || ''));
461
+ }
462
+
463
+ /**
464
+ * Neutrality test for colors as written in source CSS.
465
+ *
466
+ * shared/color.mjs's isNeutralColor only parses the computed function forms a
467
+ * browser or jsdom emits (rgb/oklch/lab/...) and deliberately reports every
468
+ * other spelling as chromatic so an unknown format is never silently skipped.
469
+ * That default is wrong for authored CSS, where `#000` and `black` are the
470
+ * normal spellings: calling it directly reports a plain black hairline as a
471
+ * colored stripe. Handle hex and named neutrals here, then defer.
472
+ */
473
+ function isNeutralAuthoredColor(rawColor) {
474
+ const c = String(rawColor || '').trim().toLowerCase();
475
+ if (!c) return false;
476
+ if (NEUTRAL_COLOR_KEYWORDS.has(c)) return true;
477
+ // Modern rgb() takes space-separated channels (`rgb(0 0 0)`). shared/color.mjs
478
+ // parses only the comma form a browser's getComputedStyle emits, so authored
479
+ // space-separated neutrals fell through it and reported as chromatic — the
480
+ // exemption this function exists for, missed. Normalize before delegating.
481
+ if (/^rgba?\(/i.test(c)) {
482
+ const channels = c.match(/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i);
483
+ if (channels) {
484
+ const values = [1, 2, 3].map((i) => Number(channels[i]));
485
+ return (Math.max(...values) - Math.min(...values)) < 30;
486
+ }
487
+ return isNeutralColor(c);
488
+ }
489
+ if (/^(?:hsla?|oklch|oklab|lab|lch|hwb)\(/i.test(c)) return isNeutralColor(c);
490
+ const channels = hexChannels(c);
491
+ if (channels) return (Math.max(...channels) - Math.min(...channels)) < 30;
492
+ return false;
493
+ }
494
+
495
+ function isNeutralBorderColor(str) {
496
+ const m = str.match(/solid\s+((?:rgba?|hsla?|oklch|oklab|lab|lch|hwb|color)\([^)]*\)|#[0-9a-f]{3,8}\b|[a-z]+)/i);
497
+ if (!m) return false;
498
+ return isNeutralAuthoredColor(m[1]);
499
+ }
500
+
501
+ const TW_SOLID_CHROMATIC_BG_RE = /\bbg-(?:red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-\d+(?!\/)\b/;
502
+
503
+ function scanJs(text, start, onChar) {
504
+ let stringQuote = '';
505
+ let inTemplate = false;
506
+ let paren = 0;
507
+ let brace = 0;
508
+ const interpBrace = [];
509
+
510
+ for (let i = start; i < text.length; i++) {
511
+ const char = text[i];
512
+ const prev = text[i - 1];
513
+ const next = text[i + 1];
514
+
515
+ if (stringQuote) {
516
+ if (char === '\\') { i++; continue; }
517
+ if (char === stringQuote) stringQuote = '';
518
+ continue;
519
+ }
520
+ if (inTemplate && interpBrace.length === 0) {
521
+ if (char === '\\') { i++; continue; }
522
+ if (char === '$' && next === '{') {
523
+ brace++;
524
+ interpBrace.push(brace);
525
+ i++;
526
+ continue;
527
+ }
528
+ if (char === '`') { inTemplate = false; continue; }
529
+ continue;
530
+ }
531
+
532
+ if (char === "'" || char === '"') { stringQuote = char; continue; }
533
+ if (char === '`') { inTemplate = true; continue; }
534
+ if (char === '(') { paren++; continue; }
535
+ if (char === ')') { paren--; continue; }
536
+ if (char === '{') { brace++; continue; }
537
+ if (char === '}') {
538
+ brace--;
539
+ if (interpBrace.length && brace < interpBrace[interpBrace.length - 1]) interpBrace.pop();
540
+ continue;
541
+ }
542
+ if (onChar(char, i, prev, next, { paren, brace })) return;
543
+ }
544
+ }
545
+
546
+ function containingMarkupTag(line, index) {
547
+ let i = 0;
548
+ while (i < line.length) {
549
+ const tagStart = line.indexOf('<', i);
550
+ if (tagStart === -1) break;
551
+ if (!/^<[A-Za-z]/.test(line.slice(tagStart))) {
552
+ i = tagStart + 1;
553
+ continue;
554
+ }
555
+ let tagEnd = -1;
556
+ scanJs(line, tagStart + 1, (char, j, _p, _n, depth) => {
557
+ if (char === '>' && depth.brace === 0) {
558
+ tagEnd = j;
559
+ return true;
560
+ }
561
+ return false;
562
+ });
563
+ if (tagEnd === -1) break;
564
+ if (index >= tagStart && index <= tagEnd) {
565
+ return { text: line.slice(tagStart, tagEnd + 1), start: tagStart };
566
+ }
567
+ i = tagEnd + 1;
568
+ }
569
+ return { text: line, start: 0 };
570
+ }
571
+
572
+ function findTernarySplit(text) {
573
+ let qPos = -1;
574
+ let qParen = 0;
575
+ let qBrace = 0;
576
+ let nested = 0;
577
+ let colonPos = -1;
578
+ let split = null;
579
+
580
+ const isQuestion = (char, prev, next) =>
581
+ char === '?' && prev !== '.' && prev !== '?' && next !== '?' && next !== '.';
582
+ const sameDepth = (depth) => depth.paren === qParen && depth.brace === qBrace;
583
+
584
+ scanJs(text, 0, (char, i, prev, next, depth) => {
585
+ if (colonPos === -1) {
586
+ if (qPos === -1 && isQuestion(char, prev, next)) {
587
+ qPos = i;
588
+ qParen = depth.paren;
589
+ qBrace = depth.brace;
590
+ return false;
591
+ }
592
+ if (qPos !== -1 && isQuestion(char, prev, next) && sameDepth(depth)) {
593
+ nested++;
594
+ return false;
595
+ }
596
+ if (qPos !== -1 && char === ':' && sameDepth(depth)) {
597
+ if (nested) nested--;
598
+ else colonPos = i;
599
+ }
600
+ return false;
601
+ }
602
+ if (char === ',' && sameDepth(depth)) {
603
+ split = {
604
+ common: text.slice(0, qPos),
605
+ consequent: text.slice(qPos + 1, colonPos),
606
+ alternate: text.slice(colonPos + 1, i),
607
+ suffix: text.slice(i),
608
+ };
609
+ return true;
610
+ }
611
+ return false;
612
+ });
613
+
614
+ if (!split && qPos !== -1 && colonPos !== -1) {
615
+ split = {
616
+ common: text.slice(0, qPos),
617
+ consequent: text.slice(qPos + 1, colonPos),
618
+ alternate: text.slice(colonPos + 1),
619
+ suffix: '',
620
+ };
621
+ }
622
+ return split;
623
+ }
624
+
625
+ function exclusiveClassScopes(text) {
626
+ const split = findTernarySplit(text);
627
+ if (!split) return [text];
628
+ return [
629
+ ...exclusiveClassScopes(split.consequent).map((part) => split.common + part + split.suffix),
630
+ ...exclusiveClassScopes(split.alternate).map((part) => split.common + part + split.suffix),
631
+ ];
632
+ }
633
+
634
+ function grayOnColorScopes(line, index) {
635
+ return exclusiveClassScopes(containingMarkupTag(line, index).text);
636
+ }
637
+
638
+ function grayOnColorPairs(line, grayClass, index) {
639
+ return grayOnColorScopes(line, index).filter((scope) => scope.includes(grayClass));
640
+ }
641
+
642
+ const REGEX_MATCHERS = [
643
+ // --- Side-tab ---
644
+ { id: 'side-tab', regex: /\bborder-[lrse]-(\d+)\b/g,
645
+ test: (m, line) => { const n = +m[1]; return hasRounded(line) ? n >= 2 : n >= 4; },
646
+ fmt: (m) => m[0] },
647
+ { id: 'side-tab', regex: /border-(?:left|right)\s*:\s*(\d+)px\s+solid[^;]*/gi,
648
+ test: (m, line) => { if (isSafeElement(line)) return false; if (isNeutralBorderColor(m[0])) return false; const n = +m[1]; return hasBorderRadius(line) ? n >= 2 : n >= 3; },
649
+ fmt: (m) => m[0].replace(/\s*;?\s*$/, '') },
650
+ { id: 'side-tab', regex: /border-(?:left|right)-width\s*:\s*(\d+)px/gi,
651
+ test: (m, line) => !isSafeElement(line) && +m[1] >= 3,
652
+ fmt: (m) => m[0] },
653
+ { id: 'side-tab', regex: /border-inline-(?:start|end)\s*:\s*(\d+)px\s+solid/gi,
654
+ test: (m, line) => !isSafeElement(line) && +m[1] >= 3,
655
+ fmt: (m) => m[0] },
656
+ { id: 'side-tab', regex: /border-inline-(?:start|end)-width\s*:\s*(\d+)px/gi,
657
+ test: (m, line) => !isSafeElement(line) && +m[1] >= 3,
658
+ fmt: (m) => m[0] },
659
+ { id: 'side-tab', regex: /border(?:Left|Right)\s*[:=]\s*["'`](\d+)px\s+solid/g,
660
+ test: (m) => +m[1] >= 3,
661
+ fmt: (m) => m[0] },
662
+ // --- Border accent on rounded ---
663
+ { id: 'border-accent-on-rounded', regex: /\bborder-[tb]-(\d+)\b/g,
664
+ test: (m, line) => hasRounded(line) && +m[1] >= 1,
665
+ fmt: (m) => m[0] },
666
+ { id: 'border-accent-on-rounded', regex: /border-(?:top|bottom)\s*:\s*(\d+)px\s+solid/gi,
667
+ test: (m, line) => +m[1] >= 3 && hasBorderRadius(line),
668
+ fmt: (m) => m[0] },
669
+ // --- Overused font ---
670
+ { id: 'overused-font', regex: /font-family\s*:\s*['"]?(Inter|Roboto|Open Sans|Lato|Montserrat|Arial|Helvetica|Fraunces|Geist Sans|Geist Mono|Geist|Mona Sans|Plus Jakarta Sans|Space Grotesk|Recoleta|Instrument Sans|Instrument Serif)\b/gi,
671
+ test: () => true,
672
+ fmt: (m) => m[0] },
673
+ { id: 'overused-font', regex: /fonts\.googleapis\.com\/css2?\?[^"'\s)<>]*/gi,
674
+ test: (m) => {
675
+ m.overusedGoogleFont = firstOverusedGoogleFont(m[0]);
676
+ return Boolean(m.overusedGoogleFont);
677
+ },
678
+ fmt: (m) => `Google Fonts: ${m.overusedGoogleFont || firstOverusedGoogleFont(m[0])}` },
679
+ // --- Gradient text ---
680
+ { id: 'gradient-text', regex: /background-clip\s*:\s*text|-webkit-background-clip\s*:\s*text/gi,
681
+ test: (m, line) => /gradient/i.test(line),
682
+ fmt: () => 'background-clip: text + gradient' },
683
+ // --- Gradient text (Tailwind) ---
684
+ { id: 'gradient-text', regex: /\bbg-clip-text\b/g,
685
+ test: (m, line) => /\bbg-gradient-to-/i.test(line),
686
+ fmt: () => 'bg-clip-text + bg-gradient' },
687
+ // --- Tailwind gray on colored bg ---
688
+ { id: 'gray-on-color', regex: /\btext-(?:gray|slate|zinc|neutral|stone)-(\d+)\b/g,
689
+ test: (m, line) => grayOnColorPairs(line, m[0], m.index).some((scope) => TW_SOLID_CHROMATIC_BG_RE.test(scope)),
690
+ fmt: (m, line) => {
691
+ const bg = grayOnColorPairs(line, m[0], m.index)
692
+ .map((scope) => scope.match(TW_SOLID_CHROMATIC_BG_RE))
693
+ .find(Boolean);
694
+ return `${m[0]} on ${bg?.[0] || '?'}`;
695
+ } },
696
+ // --- Tailwind AI palette ---
697
+ { id: 'ai-color-palette', regex: /\btext-(?:purple|violet|indigo)-(\d+)\b/g,
698
+ test: (m, line) => /\btext-(?:[2-9]xl|[3-9]xl)\b|<h[1-3]/i.test(line),
699
+ fmt: (m) => `${m[0]} on heading` },
700
+ { id: 'ai-color-palette', regex: /\bfrom-(?:purple|violet|indigo)-(\d+)\b/g,
701
+ test: (m, line) => /\bto-(?:purple|violet|indigo|blue|cyan|pink|fuchsia)-\d+\b/.test(line),
702
+ fmt: (m) => `${m[0]} gradient` },
703
+ // --- Bounce/elastic easing ---
704
+ { id: 'bounce-easing', regex: /\banimate-bounce\b/g,
705
+ test: () => true,
706
+ fmt: () => 'animate-bounce (Tailwind)' },
707
+ { id: 'bounce-easing', regex: /animation(?:-name)?\s*:\s*([^;{}]*(?:bounce|elastic|wobble|jiggle|spring)[^;{}]*)/gi,
708
+ test: () => true,
709
+ fmt: (m) => {
710
+ const token = m[1]
711
+ .split(/[,\s]+/)
712
+ .find((part) => /bounce|elastic|wobble|jiggle|spring/i.test(part));
713
+ return `animation: ${token || m[1].trim()}`;
714
+ } },
715
+ { id: 'bounce-easing', regex: /cubic-bezier\(\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*,\s*([\d.-]+)\s*\)/g,
716
+ test: (m) => {
717
+ const y1 = parseFloat(m[2]), y2 = parseFloat(m[4]);
718
+ return y1 < -0.1 || y1 > 1.1 || y2 < -0.1 || y2 > 1.1;
719
+ },
720
+ fmt: (m) => `cubic-bezier(${m[1]}, ${m[2]}, ${m[3]}, ${m[4]})` },
721
+ // --- Layout property transition ---
722
+ // JSX inline style objects use comma-delimited quoted values, not semicolons (issue #548).
723
+ { id: 'layout-transition', regex: /transition\s*:\s*(?:(['"])((?:(?!\1)[^\\]|\\.)*)\1|([^;{}]+))/gi,
724
+ test: (m) => {
725
+ const val = (m[2] ?? m[3] ?? '').toLowerCase();
726
+ if (/\ball\b/.test(val)) return false;
727
+ return /\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding\b|\bmargin\b/.test(val);
728
+ },
729
+ fmt: (m) => {
730
+ const raw = m[2] ?? m[3] ?? '';
731
+ const found = raw.match(/\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding(?:-(?:top|right|bottom|left))?\b|\bmargin(?:-(?:top|right|bottom|left))?\b/gi);
732
+ return `transition: ${found ? found.join(', ') : raw.trim()}`;
733
+ } },
734
+ { id: 'layout-transition', regex: /transition-property\s*:\s*(?:(['"])((?:(?!\1)[^\\]|\\.)*)\1|([^;{}]+))/gi,
735
+ test: (m) => {
736
+ const val = (m[2] ?? m[3] ?? '').toLowerCase();
737
+ if (/\ball\b/.test(val)) return false;
738
+ return /\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding\b|\bmargin\b/.test(val);
739
+ },
740
+ fmt: (m) => {
741
+ const raw = m[2] ?? m[3] ?? '';
742
+ const found = raw.match(/\b(?:(?:max|min)-)?(?:width|height)\b|\bpadding(?:-(?:top|right|bottom|left))?\b|\bmargin(?:-(?:top|right|bottom|left))?\b/gi);
743
+ return `transition-property: ${found ? found.join(', ') : raw.trim()}`;
744
+ } },
745
+ // --- Broken image: src="" or src="#" or src=" " ---
746
+ { id: 'broken-image', regex: /<img\b[^>]*?\bsrc\s*=\s*(?:""|''|"\s+"|'\s+'|"#"|'#')/gi,
747
+ test: () => true,
748
+ fmt: (m) => m[0].slice(0, 100) },
749
+ // --- Broken image: <img> with no src attribute at all ---
750
+ { id: 'broken-image', regex: /<img\b(?:(?!\bsrc\s*=)[^>])*>/gi,
751
+ test: (m) => !/\bsrc\s*=/i.test(m[0]),
752
+ fmt: (m) => m[0].slice(0, 100) },
753
+ ];
754
+
755
+ const REGEX_ANALYZERS = [
756
+ // Monotonous spacing (regex)
757
+ (content, filePath) => {
758
+ const vals = [];
759
+ let m;
760
+ const pxRe = /(?:padding|margin)(?:-(?:top|right|bottom|left))?\s*:\s*(\d+)px/gi;
761
+ while ((m = pxRe.exec(content)) !== null) { const v = +m[1]; if (v > 0 && v < 200) vals.push(v); }
762
+ const remRe = /(?:padding|margin)(?:-(?:top|right|bottom|left))?\s*:\s*([\d.]+)rem/gi;
763
+ while ((m = remRe.exec(content)) !== null) { const v = Math.round(parseFloat(m[1]) * 16); if (v > 0 && v < 200) vals.push(v); }
764
+ const gapRe = /gap\s*:\s*(\d+)px/gi;
765
+ while ((m = gapRe.exec(content)) !== null) vals.push(+m[1]);
766
+ const twRe = /\b(?:p|px|py|pt|pb|pl|pr|m|mx|my|mt|mb|ml|mr|gap)-(\d+)\b/g;
767
+ while ((m = twRe.exec(content)) !== null) vals.push(+m[1] * 4);
768
+ const rounded = vals.map(v => Math.round(v / 4) * 4);
769
+ if (rounded.length < 10) return [];
770
+ const counts = {};
771
+ for (const v of rounded) counts[v] = (counts[v] || 0) + 1;
772
+ const maxCount = Math.max(...Object.values(counts));
773
+ const pct = maxCount / rounded.length;
774
+ const unique = [...new Set(rounded)].filter(v => v > 0);
775
+ if (pct <= 0.6 || unique.length > 3) return [];
776
+ const dominant = Object.entries(counts).sort((a, b) => b[1] - a[1])[0][0];
777
+ return [finding('monotonous-spacing', filePath, `~${dominant}px used ${maxCount}/${rounded.length} times (${Math.round(pct * 100)}%)`)];
778
+ },
779
+ // Em-dash overuse (ADVISORY): the AI cadence tell is em-dash *saturation*,
780
+ // not the occasional dash. Humans use em-dashes legitimately, so this rule is
781
+ // advisory (surfaced separately, never a failure, hook-skipped by default) and
782
+ // its threshold is deliberately conservative. Two gates must both hold:
783
+ // 1. Absolute floor of EM_DASH_FLOOR (8) dashes — a page with a handful
784
+ // never fires, no matter how short.
785
+ // 2. Density: at least one dash per EM_DASH_CHARS_PER_DASH (500) characters
786
+ // of body text, so a long article that uses eight across several thousand
787
+ // words is left alone while a short, dash-per-clause landing page is not.
788
+ // Raised from the old flat 5-dash floor, which fired on ordinary long prose.
789
+ //
790
+ // stripHtmlToText drops tags but leaves character-entity escapes intact, so
791
+ // a model that writes `&mdash;`, `&#8212;`, or `&#x2014;` renders an em-dash
792
+ // the counter never saw. Decode the em-dash entities (named, zero-padded
793
+ // decimal, upper/lower hex) to the literal glyph first. En-dash entities are
794
+ // deliberately left alone: the rule counts em-dashes, and the literal `–`
795
+ // was never counted either.
796
+ (content, filePath) => {
797
+ const text = stripHtmlToText(content)
798
+ .replace(/&mdash;|&#0*8212;|&#x0*2014;/gi, '—');
799
+ let count = 0;
800
+ const re = /[—]|--(?=\S)/g;
801
+ while (re.exec(text) !== null) count++;
802
+ if (count < EM_DASH_FLOOR) return [];
803
+ // Saturation gate: dashes must be dense in the prose, not sprinkled through
804
+ // a long document. textLength <= count * chars-per-dash means the density is
805
+ // at or above the threshold.
806
+ if (text.length > count * EM_DASH_CHARS_PER_DASH) return [];
807
+ return [finding('em-dash-overuse', filePath, `${count} em-dashes in body text`)];
808
+ },
809
+ // Marketing buzzwords: SaaS phrase list
810
+ (content, filePath) => {
811
+ const text = stripHtmlToText(content);
812
+ const lower = text.toLowerCase();
813
+ const BUZZWORDS = [
814
+ 'streamline your', 'empower your', 'supercharge your',
815
+ 'unleash your', 'unleash the power', 'leverage the power',
816
+ 'built for the modern', 'trusted by leading', 'trusted by the world',
817
+ 'best-in-class', 'industry-leading', 'world-class', 'enterprise-grade',
818
+ 'next-generation', 'cutting-edge', 'transform your business',
819
+ 'revolutionize', 'game-changer', 'game changing',
820
+ 'mission-critical', 'best of breed', 'future-proof', 'future proof',
821
+ 'seamless experience', 'seamlessly integrate',
822
+ 'drive engagement', 'drive growth', 'drive results',
823
+ 'harness the power',
824
+ ];
825
+ let count = 0;
826
+ let firstSample = '';
827
+ for (const phrase of BUZZWORDS) {
828
+ let from = 0;
829
+ while (true) {
830
+ const idx = lower.indexOf(phrase, from);
831
+ if (idx === -1) break;
832
+ count++;
833
+ if (!firstSample) {
834
+ firstSample = text.slice(Math.max(0, idx - 12), Math.min(text.length, idx + phrase.length + 12)).trim();
835
+ }
836
+ from = idx + phrase.length;
837
+ }
838
+ }
839
+ if (count === 0) return [];
840
+ return [finding('marketing-buzzword', filePath, `${count} buzzword phrase${count === 1 ? '' : 's'}: "${firstSample}"`)];
841
+ },
842
+ // Aphoristic cadence: manufactured-contrast + short-rebuttal
843
+ (content, filePath) => {
844
+ const text = stripHtmlToText(content);
845
+ const NOT_A_RE = /\bNot an? [a-z][^.!?]{1,40}[.!]\s+[A-Z][^.!?]{1,60}[.!]/g;
846
+ const SHORT_REBUTTAL_RE = /\b[A-Z][^.!?]{4,80}[.!]\s+(No|Just)\s+[a-z][^.!?]{2,60}[.!]/g;
847
+ let count = 0;
848
+ let firstSample = '';
849
+ let m;
850
+ NOT_A_RE.lastIndex = 0;
851
+ while ((m = NOT_A_RE.exec(text)) !== null) {
852
+ count++;
853
+ if (!firstSample) firstSample = m[0].trim().slice(0, 80);
854
+ }
855
+ SHORT_REBUTTAL_RE.lastIndex = 0;
856
+ while ((m = SHORT_REBUTTAL_RE.exec(text)) !== null) {
857
+ count++;
858
+ if (!firstSample) firstSample = m[0].trim().slice(0, 80);
859
+ }
860
+ if (count < 3) return [];
861
+ return [finding('aphoristic-cadence', filePath, `${count} aphoristic constructions: "${firstSample}"`)];
862
+ },
863
+ // Dark glow / chromatic halo shadows (page-level). Shared scanner handles
864
+ // any color format, single-level var() resolution, zero-offset halos on
865
+ // any background, and text-shadow glows.
866
+ (content, filePath) => {
867
+ const hits = scanCssTextForGlow(content);
868
+ if (hits.length === 0) return [];
869
+ const lines = content.substring(0, hits[0].index).split('\n');
870
+ return [finding('dark-glow', filePath, hits[0].snippet, lines.length)];
871
+ },
872
+ // Radial-gradient background halo on a dark page (the gradient sibling
873
+ // of the dark-glow shadow tell).
874
+ (content, filePath) => {
875
+ const hits = scanCssTextForRadialHalo(content);
876
+ if (hits.length === 0) return [];
877
+ const lines = content.substring(0, hits[0].index).split('\n');
878
+ return [finding('radial-halo', filePath, hits[0].snippet, lines.length)];
879
+ },
880
+ // Auto-scrolling marquees (<marquee> or infinite horizontal loop
881
+ // animations).
882
+ (content, filePath) => scanCssTextForMarquee(content).map(hit => finding('marquee', filePath, hit.snippet)),
883
+ ];
884
+
885
+ // ---------------------------------------------------------------------------
886
+ // Structural CSS checks used by source files whose styles are not parsed by
887
+ // the static HTML engine.
888
+ // ---------------------------------------------------------------------------
889
+
890
+ const CHROMATIC_SHADOW_TOKEN_RE = /(?:^|-)(?:accent|kinpaku|patina|gold|red|orange|amber|yellow|lime|green|emerald|teal|cyan|blue|indigo|violet|purple|magenta|pink|rose|coral|aqua|mint|burgundy|crimson|scarlet)(?:-|$)/i;
891
+
892
+ function insetStripeColorIsChromatic(rawColor) {
893
+ const color = String(rawColor || '').trim().replace(/\s*!important\s*$/i, '');
894
+ if (/^(?:currentcolor|transparent|inherit|unset)$/i.test(color)) return false;
895
+ const variable = color.match(/^var\(\s*(--[\w-]+)/i);
896
+ if (variable) return CHROMATIC_SHADOW_TOKEN_RE.test(variable[1]);
897
+ if (!/^(?:#|rgba?\(|hsla?\(|hwb\(|oklch\(|oklab\(|lch\(|lab\(|color\(|[a-z]+$)/i.test(color)) return false;
898
+ return !isNeutralAuthoredColor(color);
899
+ }
900
+
901
+ /**
902
+ * Blank out comment bodies while preserving every byte offset (and therefore
903
+ * every line number) so commented-out CSS is not scanned as live rules.
904
+ */
905
+ function blankCssComments(css) {
906
+ return css.replace(/\/\*[\s\S]*?\*\//g, (block) => block.replace(/[^\n]/g, ' '));
907
+ }
908
+
909
+ function scanInsetStripeCss(rawContent, filePath, lineOffset = 0) {
910
+ const content = blankCssComments(rawContent);
911
+ const findings = [];
912
+ const ruleRe = /([^{};]+)\{([^{}]*)\}/g;
913
+ let match;
914
+ // Deriving each line with content.slice(0, offset).split('\n') re-scans the
915
+ // whole prefix per rule, which is O(n^2) on a large stylesheet. Rule matches
916
+ // arrive in source order, so carry a monotonic cursor instead: one pass total.
917
+ let scanOffset = 0;
918
+ let scanLine = 1;
919
+ const lineAtOffset = (offset) => {
920
+ while (scanOffset < offset) {
921
+ if (content[scanOffset] === '\n') scanLine++;
922
+ scanOffset++;
923
+ }
924
+ return scanLine;
925
+ };
926
+ while ((match = ruleRe.exec(content)) !== null) {
927
+ // The selector group is `[^{};]+`, which greedily absorbs the whitespace and
928
+ // newlines trailing the previous rule. Advance past that run before deriving
929
+ // the line, or every rule after the first reports the preceding line.
930
+ const selectorStart = match.index + (match[1].length - match[1].trimStart().length);
931
+ const selector = match[1].trim().replace(/\s+/g, ' ');
932
+ if (!selector) continue;
933
+ if (/:(?:hover|focus|focus-visible|focus-within|active|checked|target)\b/i.test(selector)) continue;
934
+ if (/\[aria-selected\s*[*^$|~]?=\s*["']?true/i.test(selector)) continue;
935
+ if (/\[aria-current(?!\s*[*^$|~]?=\s*["']?false)/i.test(selector)) continue;
936
+ if (/(?:^|[\s._[-])(?:active|current|selected)(?![\w])/i.test(selector)) continue;
937
+ if (/(?:^|[\s>+~,(])(?:button|hr|tr|td|th|table|blockquote|pre|code)(?![\w-])/i.test(selector)) continue;
938
+
939
+ // Read the last of a repeated declaration, not the first: that is what the
940
+ // cascade paints. Taking the first both flagged stripes that a later
941
+ // `box-shadow: none` had cancelled and missed stripes that overrode an
942
+ // earlier value, and mis-skipped rules whose narrow width was overridden.
943
+ const width = lastMatch(match[2], /(?:^|;)\s*(?:width|inline-size)\s*:\s*(\d+(?:\.\d+)?)px/gi);
944
+ if (width && Number(width[1]) <= 40) continue;
945
+ const declaration = lastMatch(match[2], /(?:^|;)\s*box-shadow\s*:\s*([^;]+)/gi);
946
+ if (!declaration || !/\binset\b/i.test(declaration[1])) continue;
947
+ // `!important` qualifies the declaration, not the shadow value, so strip it
948
+ // before the layers are read. Tokenizing split it into its own token, which
949
+ // made the color count wrong and silently stopped flagging stripes declared
950
+ // with it — a shape the previous regex handled.
951
+ const shadowValue = declaration[1].replace(/\s*!\s*important\s*$/i, '').trim();
952
+
953
+ for (const rawLayer of shadowValue.split(/,(?![^(]*\))/)) {
954
+ const layer = rawLayer.trim();
955
+ // Parse the layer by its grammar rather than by one spelling of it.
956
+ // A box-shadow layer is `inset? && <length>{2,4} && <color>?` in any
957
+ // order, so `inset 4px 0 red`, `4px 0 0 red inset`, and `red 4px 0 inset`
958
+ // all paint the same stripe. Matching a fixed token order missed three
959
+ // valid spellings in a row; enumerate the tokens instead. Tokenizing must
960
+ // respect parens: `rgb(0 0 0)` is one color token, and splitting it on
961
+ // whitespace would read its channels as lengths.
962
+ const tokens = tokenizeShadowLayer(layer);
963
+ if (!tokens.some((token) => /^inset$/i.test(token))) continue;
964
+ const rest = tokens.filter((token) => !/^inset$/i.test(token));
965
+ const lengths = rest.filter(isShadowLength);
966
+ const colors = rest.filter((token) => !isShadowLength(token));
967
+ // Only the two offsets are required; omitted blur/spread default to 0,
968
+ // which is exactly the stripe shape. More than one non-length token is a
969
+ // layer shape we do not claim to understand, so leave it alone.
970
+ if (lengths.length < 2 || lengths.length > 4 || colors.length !== 1) continue;
971
+ const values = lengths.map((token) => ({
972
+ n: Number(token.replace(/px$/i, '')),
973
+ hasPx: /px$/i.test(token),
974
+ }));
975
+ const x = values[0];
976
+ const y = values[1];
977
+ const blur = values[2] ? values[2].n : 0;
978
+ const spread = values[3] ? values[3].n : 0;
979
+ if ((x.n !== 0 && !x.hasPx) || (y.n !== 0 && !y.hasPx) || blur !== 0 || spread !== 0) continue;
980
+ const ax = Math.abs(x.n);
981
+ const ay = Math.abs(y.n);
982
+ if (!((ax >= 3 && ax <= 12 && ay === 0) || (ay >= 3 && ay <= 12 && ax === 0))) continue;
983
+ if (!insetStripeColorIsChromatic(colors[0])) continue;
984
+ const edge = ay === 0 ? (x.n > 0 ? 'left' : 'right') : (y.n > 0 ? 'top' : 'bottom');
985
+ const line = lineOffset + lineAtOffset(selectorStart);
986
+ findings.push(finding('side-tab', filePath, `${selector} — inset box-shadow ${ay === 0 ? ax : ay}px stripe (${edge})`, line));
987
+ break;
988
+ }
989
+ }
990
+ return findings;
991
+ }
992
+
993
+ // ---------------------------------------------------------------------------
994
+ // Style block extraction (Astro/Vue/Svelte <style> blocks)
995
+ // ---------------------------------------------------------------------------
996
+
997
+ function extractStyleBlocks(content, ext) {
998
+ ext = ext.toLowerCase();
999
+ if (ext !== '.astro' && ext !== '.vue' && ext !== '.svelte') return [];
1000
+ const blocks = [];
1001
+ const re = /<style[^>]*>([\s\S]*?)<\/style>/gi;
1002
+ let m;
1003
+ while ((m = re.exec(content)) !== null) {
1004
+ const before = content.substring(0, m.index);
1005
+ const startLine = before.split('\n').length + 1;
1006
+ blocks.push({ content: m[1], startLine });
1007
+ }
1008
+ return blocks;
1009
+ }
1010
+
1011
+ // ---------------------------------------------------------------------------
1012
+ // CSS-in-JS extraction (styled-components, emotion)
1013
+ // ---------------------------------------------------------------------------
1014
+
1015
+ const CSS_IN_JS_EXTENSIONS = new Set(['.js', '.ts', '.jsx', '.tsx']);
1016
+
1017
+ function findQuotedStringEnd(content, start, quote) {
1018
+ for (let cursor = start + 1; cursor < content.length; cursor++) {
1019
+ if (content[cursor] === '\\') cursor++;
1020
+ else if (content[cursor] === quote) return cursor;
1021
+ }
1022
+ return -1;
1023
+ }
1024
+
1025
+ function findRegexLiteralEnd(content, start) {
1026
+ let inCharacterClass = false;
1027
+ for (let cursor = start + 1; cursor < content.length; cursor++) {
1028
+ const char = content[cursor];
1029
+ if (char === '\\') {
1030
+ cursor++;
1031
+ } else if (char === '[') {
1032
+ inCharacterClass = true;
1033
+ } else if (char === ']') {
1034
+ inCharacterClass = false;
1035
+ } else if (char === '/' && !inCharacterClass) {
1036
+ while (/[A-Za-z]/.test(content[cursor + 1] || '')) cursor++;
1037
+ return cursor;
1038
+ } else if (char === '\n' || char === '\r') {
1039
+ return -1;
1040
+ }
1041
+ }
1042
+ return -1;
1043
+ }
1044
+
1045
+ function findTemplateExpressionEnd(content, start) {
1046
+ let depth = 1;
1047
+ let lastSignificant = '';
1048
+ let previousSignificant = '';
1049
+ let antePreviousSignificant = '';
1050
+ let currentWord = '';
1051
+ let currentWordPrefix = '';
1052
+ let wordSeparated = false;
1053
+ let lastClosedBraceKind = '';
1054
+ const braceKinds = [];
1055
+
1056
+ const braceKind = () => (
1057
+ lastSignificant === ')' ||
1058
+ lastSignificant === ';' ||
1059
+ lastSignificant === '}' ||
1060
+ (previousSignificant === '=' && lastSignificant === '>') ||
1061
+ BLOCK_BRACE_PREFIX_KEYWORDS.has(currentWord)
1062
+ ? 'block'
1063
+ : 'expression'
1064
+ );
1065
+
1066
+ const recordSignificant = (char) => {
1067
+ if (/\s/.test(char)) {
1068
+ wordSeparated = true;
1069
+ return;
1070
+ }
1071
+ const isWordChar = /[\w$]/.test(char);
1072
+ if (isWordChar && (wordSeparated || !currentWord)) {
1073
+ currentWord = '';
1074
+ currentWordPrefix = lastSignificant;
1075
+ } else if (!isWordChar) {
1076
+ currentWordPrefix = '';
1077
+ }
1078
+ wordSeparated = false;
1079
+ antePreviousSignificant = previousSignificant;
1080
+ previousSignificant = lastSignificant;
1081
+ lastSignificant = char;
1082
+ currentWord = isWordChar ? currentWord + char : '';
1083
+ };
1084
+
1085
+ for (let cursor = start; cursor < content.length; cursor++) {
1086
+ const char = content[cursor];
1087
+ const next = content[cursor + 1];
1088
+ const afterPostfixUpdate = (lastSignificant === '+' || lastSignificant === '-') &&
1089
+ previousSignificant === lastSignificant &&
1090
+ antePreviousSignificant !== lastSignificant;
1091
+ if (char === "'" || char === '"') {
1092
+ cursor = findQuotedStringEnd(content, cursor, char);
1093
+ if (cursor === -1) return -1;
1094
+ recordSignificant(')');
1095
+ } else if (char === '/' && next === '/') {
1096
+ const lineEnd = content.indexOf('\n', cursor + 2);
1097
+ if (lineEnd === -1) return -1;
1098
+ cursor = lineEnd;
1099
+ } else if (char === '/' && next === '*') {
1100
+ const commentEnd = content.indexOf('*/', cursor + 2);
1101
+ if (commentEnd === -1) return -1;
1102
+ cursor = commentEnd + 1;
1103
+ } else if (
1104
+ char === '/' &&
1105
+ (!lastSignificant ||
1106
+ (/[=([{!?:;,&|+\-*%^~<>]/.test(lastSignificant) && !afterPostfixUpdate) ||
1107
+ (lastSignificant === '}' && lastClosedBraceKind === 'block') ||
1108
+ (previousSignificant === '=' && lastSignificant === '>') ||
1109
+ (currentWordPrefix !== '.' && REGEX_PREFIX_KEYWORDS.has(currentWord)))
1110
+ ) {
1111
+ cursor = findRegexLiteralEnd(content, cursor);
1112
+ if (cursor === -1) return -1;
1113
+ recordSignificant(')');
1114
+ } else if (char === '`') {
1115
+ cursor = findTemplateLiteralEnd(content, cursor);
1116
+ if (cursor === -1) return -1;
1117
+ recordSignificant(')');
1118
+ } else if (char === '{') {
1119
+ depth++;
1120
+ braceKinds.push(braceKind());
1121
+ recordSignificant(char);
1122
+ } else if (char === '}') {
1123
+ depth--;
1124
+ if (depth === 0) return cursor;
1125
+ lastClosedBraceKind = braceKinds.pop() || '';
1126
+ recordSignificant(char);
1127
+ } else {
1128
+ recordSignificant(char);
1129
+ }
1130
+ }
1131
+ return -1;
1132
+ }
1133
+
1134
+ function findTemplateLiteralEnd(content, start) {
1135
+ for (let cursor = start + 1; cursor < content.length; cursor++) {
1136
+ const char = content[cursor];
1137
+ if (char === '\\') {
1138
+ cursor++;
1139
+ } else if (char === '`') {
1140
+ return cursor;
1141
+ } else if (char === '$' && content[cursor + 1] === '{') {
1142
+ cursor = findTemplateExpressionEnd(content, cursor + 2);
1143
+ if (cursor === -1) return -1;
1144
+ }
1145
+ }
1146
+ return -1;
1147
+ }
1148
+
1149
+ function findCSSinJSTemplates(content) {
1150
+ const templates = [];
1151
+ const tagRe = /\b(?:styled(?:\.\w+|\([^)]+\))|css)/g;
1152
+ let match;
1153
+ while ((match = tagRe.exec(content)) !== null) {
1154
+ let cursor = match.index + match[0].length;
1155
+ while (/\s/.test(content[cursor] || '')) cursor++;
1156
+
1157
+ if (content[cursor] === '<') {
1158
+ let depth = 0;
1159
+ while (cursor < content.length) {
1160
+ const char = content[cursor];
1161
+ if (char === '<') depth++;
1162
+ else if (char === '>' && content[cursor - 1] !== '=') depth--;
1163
+ cursor++;
1164
+ if (depth === 0) break;
1165
+ }
1166
+ if (depth !== 0) continue;
1167
+ while (/\s/.test(content[cursor] || '')) cursor++;
1168
+ }
1169
+
1170
+ if (content[cursor] !== '`') continue;
1171
+ const contentStart = cursor + 1;
1172
+ cursor = findTemplateLiteralEnd(content, cursor);
1173
+ if (cursor === -1) continue;
1174
+
1175
+ templates.push({
1176
+ tagStart: match.index,
1177
+ contentStart,
1178
+ contentEnd: cursor,
1179
+ });
1180
+ tagRe.lastIndex = cursor + 1;
1181
+ }
1182
+ return templates;
1183
+ }
1184
+
1185
+ function extractCSSinJS(content, ext) {
1186
+ ext = ext.toLowerCase();
1187
+ if (!CSS_IN_JS_EXTENSIONS.has(ext)) return [];
1188
+ return findCSSinJSTemplates(content).map((template) => {
1189
+ const before = content.substring(0, template.tagStart);
1190
+ const startLine = before.split('\n').length;
1191
+ return {
1192
+ content: content.slice(template.contentStart, template.contentEnd),
1193
+ startLine,
1194
+ };
1195
+ });
1196
+ }
1197
+
1198
+ function stripCssInJsComments(content, ext) {
1199
+ if (!CSS_IN_JS_EXTENSIONS.has(ext.toLowerCase())) return content;
1200
+ const templates = findCSSinJSTemplates(content);
1201
+ let output = '';
1202
+ let cursor = 0;
1203
+ for (const template of templates) {
1204
+ output += content.slice(cursor, template.contentStart);
1205
+ output += stripCssComments(content.slice(template.contentStart, template.contentEnd));
1206
+ cursor = template.contentEnd;
1207
+ }
1208
+ return output + content.slice(cursor);
1209
+ }
1210
+
1211
+ function runRegexMatchers(lines, filePath, lineOffset = 0, blockContext = null, options = {}) {
1212
+ const { profile, phase = 'regex-matchers' } = options || {};
1213
+ const findings = [];
1214
+ if (!profile) {
1215
+ for (const matcher of REGEX_MATCHERS) {
1216
+ for (let i = 0; i < lines.length; i++) {
1217
+ const line = lines[i];
1218
+ matcher.regex.lastIndex = 0;
1219
+ let m;
1220
+ while ((m = matcher.regex.exec(line)) !== null) {
1221
+ // For extracted blocks, use nearby lines as context for multi-line CSS patterns
1222
+ const context = blockContext
1223
+ ? lines.slice(Math.max(0, i - 3), Math.min(lines.length, i + 4)).join(' ')
1224
+ : line;
1225
+ if (matcher.test(m, context)) {
1226
+ findings.push(finding(matcher.id, filePath, matcher.fmt(m, context), i + 1 + lineOffset));
1227
+ }
1228
+ }
1229
+ }
1230
+ }
1231
+ return findings;
1232
+ }
1233
+
1234
+ for (const matcher of REGEX_MATCHERS) {
1235
+ const matcherFindings = profileFindings(profile, {
1236
+ engine: 'regex',
1237
+ phase,
1238
+ ruleId: matcher.id,
1239
+ target: filePath,
1240
+ }, () => {
1241
+ const matches = [];
1242
+ for (let i = 0; i < lines.length; i++) {
1243
+ const line = lines[i];
1244
+ matcher.regex.lastIndex = 0;
1245
+ let m;
1246
+ while ((m = matcher.regex.exec(line)) !== null) {
1247
+ // For extracted blocks, use nearby lines as context for multi-line CSS patterns
1248
+ const context = blockContext
1249
+ ? lines.slice(Math.max(0, i - 3), Math.min(lines.length, i + 4)).join(' ')
1250
+ : line;
1251
+ if (matcher.test(m, context)) {
1252
+ matches.push(finding(matcher.id, filePath, matcher.fmt(m, context), i + 1 + lineOffset));
1253
+ }
1254
+ }
1255
+ }
1256
+ return matches;
1257
+ });
1258
+ findings.push(...matcherFindings);
1259
+ }
1260
+ return findings;
1261
+ }
1262
+
1263
+ /** Page-level analyzers that scan rendered text content (em-dash use,
1264
+ * buzzword phrases, aphoristic cadence).
1265
+ * These are detector-agnostic — they work on any HTML/text source
1266
+ * and don't need a parsed DOM. Exported so detectHtml can call them
1267
+ * for `.html` files (which otherwise skip the regex engine). */
1268
+ const TEXT_CONTENT_ANALYZER_IDS = [
1269
+ 'em-dash-overuse',
1270
+ 'marketing-buzzword',
1271
+ 'aphoristic-cadence',
1272
+ ];
1273
+
1274
+ function runTextContentAnalyzers(content, filePath, options = {}) {
1275
+ const profile = options?.profile;
1276
+ if (!shouldRunPageAnalyzers(content, filePath)) return [];
1277
+ // The 3 text-content analyzers are at indices 1-3 in REGEX_ANALYZERS.
1278
+ // flat-type-hierarchy left this source-only path in issue #619 because it
1279
+ // needs rendered role and usage evidence.
1280
+ const findings = [];
1281
+ for (let i = 0; i < TEXT_CONTENT_ANALYZER_IDS.length; i++) {
1282
+ const analyzer = REGEX_ANALYZERS[1 + i];
1283
+ const ruleId = TEXT_CONTENT_ANALYZER_IDS[i];
1284
+ findings.push(...profileFindings(profile, {
1285
+ engine: 'regex',
1286
+ phase: 'text-content',
1287
+ ruleId,
1288
+ target: filePath,
1289
+ }, () => analyzer(content, filePath)));
1290
+ }
1291
+ return findings;
1292
+ }
1293
+
1294
+ function detectText(content, filePath, options = {}) {
1295
+ const profile = options?.profile;
1296
+ const findings = [];
1297
+ const ext = extFromFilePath(filePath);
1298
+ const commentStrippedSource = JS_SOURCE_EXTS.has(ext) ? stripJsComments(content, {
1299
+ jsx: ext === '.js' || ext === '.jsx' || ext === '.tsx',
1300
+ }) : blankCommentsForMatchers(content, ext);
1301
+ const source = stripCssInJsComments(commentStrippedSource, ext);
1302
+ const lines = source.split('\n');
1303
+
1304
+ // Run regex matchers on the full file content (catches Tailwind classes, inline styles)
1305
+ // Enable block context for CSS files where related properties span multiple lines
1306
+ findings.push(...runRegexMatchers(lines, filePath, 0, STYLESHEET_EXTS.has(ext) || null, {
1307
+ profile,
1308
+ phase: 'source',
1309
+ }));
1310
+ // Pseudo-element stripes (::before/::after absolute bars) carry the same
1311
+ // side-tab silhouette without any border token, so the line matchers can't
1312
+ // see them (issue #394). The shared scanner already runs on full HTML pages
1313
+ // via checkHtmlPatterns; give standalone stylesheets, component style
1314
+ // blocks, and CSS-in-JS templates the same coverage. Each hit carries the
1315
+ // rule's source offset, so the finding gets a real line and line-scoped
1316
+ // inline ignores keep working.
1317
+ const pseudoStripeFindings = (text, lineOffset) =>
1318
+ scanCssTextForPseudoStripe(text).map(hit =>
1319
+ finding(hit.id, filePath, hit.snippet, lineOffset + text.slice(0, hit.index).split('\n').length));
1320
+
1321
+ if (STYLESHEET_EXTS.has(ext)) {
1322
+ findings.push(...scanInsetStripeCss(content, filePath));
1323
+ findings.push(...pseudoStripeFindings(content, 0));
1324
+ }
1325
+
1326
+ // Block-level CSS checks that need multiple declarations must run over the
1327
+ // complete source, not line-by-line. This covers standalone stylesheets,
1328
+ // component style blocks, inline styles, and CSS-in-JS templates.
1329
+ findings.push(...profileFindings(profile, {
1330
+ engine: 'regex',
1331
+ phase: 'source',
1332
+ ruleId: 'codex-grid-background',
1333
+ target: filePath,
1334
+ }, () => scanCssTextForGridBackground(source).map(hit => {
1335
+ const line = source.substring(0, hit.index).split('\n').length;
1336
+ return finding('codex-grid-background', filePath, hit.snippet, line);
1337
+ })));
1338
+
1339
+ // Extract and scan <style> blocks from Astro/Vue/Svelte components.
1340
+ const styleBlocks = profile
1341
+ ? profileStep(profile, {
1342
+ engine: 'regex',
1343
+ phase: 'extract',
1344
+ ruleId: 'style-blocks',
1345
+ target: filePath,
1346
+ }, () => extractStyleBlocks(content, ext))
1347
+ : extractStyleBlocks(content, ext);
1348
+ for (const block of styleBlocks) {
1349
+ const blockContent = blankCssLineComments(stripCssComments(block.content));
1350
+ const blockLines = blockContent.split('\n');
1351
+ findings.push(...runRegexMatchers(blockLines, filePath, block.startLine - 1, true, {
1352
+ profile,
1353
+ phase: 'style-block',
1354
+ }));
1355
+ // block.startLine is the first line *after* the <style> tag, but block.content
1356
+ // begins at the character right after that tag — so its own line 1 sits on the
1357
+ // tag's line, whether or not a newline follows immediately. lineAtOffset is
1358
+ // 1-based, so the offset is startLine - 2; startLine - 1 double-counted and
1359
+ // reported every selector one line low. runRegexMatchers keeps startLine - 1
1360
+ // because it indexes its split lines from zero.
1361
+ findings.push(...scanInsetStripeCss(blockContent, filePath, block.startLine - 2));
1362
+ findings.push(...pseudoStripeFindings(blockContent, block.startLine - 2));
1363
+ }
1364
+
1365
+ // Extract and scan CSS-in-JS template literals
1366
+ const cssJsBlocks = profile
1367
+ ? profileStep(profile, {
1368
+ engine: 'regex',
1369
+ phase: 'extract',
1370
+ ruleId: 'css-in-js',
1371
+ target: filePath,
1372
+ }, () => extractCSSinJS(source, ext))
1373
+ : extractCSSinJS(source, ext);
1374
+ for (const block of cssJsBlocks) {
1375
+ const blockContent = stripCssComments(block.content);
1376
+ const blockLines = blockContent.split('\n');
1377
+ findings.push(...runRegexMatchers(blockLines, filePath, block.startLine - 1, true, {
1378
+ profile,
1379
+ phase: 'css-in-js',
1380
+ }));
1381
+ findings.push(...scanInsetStripeCss(blockContent, filePath, block.startLine - 1));
1382
+ findings.push(...pseudoStripeFindings(blockContent, block.startLine - 1));
1383
+ }
1384
+
1385
+ if (options?.designSystem) {
1386
+ findings.push(...profileFindings(profile, {
1387
+ engine: 'regex',
1388
+ phase: 'source',
1389
+ ruleId: 'design-system',
1390
+ target: filePath,
1391
+ }, () => checkSourceDesignSystem(content, filePath, { designSystem: options.designSystem })));
1392
+ }
1393
+
1394
+ // Deduplicate findings (same antipattern + similar snippet, within 2 lines)
1395
+ const deduped = [];
1396
+ for (const f of findings) {
1397
+ const isDupe = deduped.some(d =>
1398
+ d.antipattern === f.antipattern &&
1399
+ d.snippet === f.snippet &&
1400
+ Math.abs(d.line - f.line) <= 2
1401
+ );
1402
+ if (!isDupe) deduped.push(f);
1403
+ }
1404
+
1405
+ // Page-level analyzers only run on full pages
1406
+ if (shouldRunPageAnalyzers(content, filePath)) {
1407
+ const analyzerIds = [
1408
+ 'monotonous-spacing',
1409
+ 'em-dash-overuse',
1410
+ 'marketing-buzzword',
1411
+ 'aphoristic-cadence',
1412
+ 'dark-glow',
1413
+ ];
1414
+ for (let i = 0; i < REGEX_ANALYZERS.length; i++) {
1415
+ const analyzer = REGEX_ANALYZERS[i];
1416
+ deduped.push(...profileFindings(profile, {
1417
+ engine: 'regex',
1418
+ phase: 'page-analyzer',
1419
+ ruleId: analyzerIds[i] || `analyzer-${i + 1}`,
1420
+ target: filePath,
1421
+ }, () => analyzer(content, filePath)));
1422
+ }
1423
+ }
1424
+
1425
+ // Inline `impeccable-disable*` waivers travel with the file; honor them unless
1426
+ // explicitly bypassed (`--no-config` / `--no-inline-ignores`).
1427
+ return options?.inlineIgnores === false ? deduped : applyInlineIgnores(deduped, content);
1428
+ }
1429
+
1430
+ export {
1431
+ REGEX_MATCHERS,
1432
+ REGEX_ANALYZERS,
1433
+ TEXT_CONTENT_ANALYZER_IDS,
1434
+ extractStyleBlocks,
1435
+ extractCSSinJS,
1436
+ runRegexMatchers,
1437
+ runTextContentAnalyzers,
1438
+ detectText,
1439
+ };