@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,112 +0,0 @@
1
- // ─── Section 1: Constants ───────────────────────────────────────────────────
2
-
3
- const SAFE_TAGS = new Set([
4
- 'blockquote', 'nav', 'a', 'input', 'textarea', 'select',
5
- 'pre', 'code', 'span', 'th', 'td', 'tr', 'li', 'label',
6
- 'button', 'hr', 'html', 'head', 'body', 'script', 'style',
7
- 'link', 'meta', 'title', 'br', 'img', 'svg', 'path', 'circle',
8
- 'rect', 'line', 'polyline', 'polygon', 'g', 'defs', 'use',
9
- ]);
10
-
11
- // Per-check safe-tags override for the border (side-tab / border-accent)
12
- // rule. We intentionally re-allow <label> here because card-shaped clickable
13
- // labels (e.g. .checklist-item wrapping a checkbox + content) are one of the
14
- // canonical side-tab anti-pattern shapes and must be detected. The rule's
15
- // other preconditions (non-neutral color, width >= 2px on a single side,
16
- // radius > 0 or width >= 3, element size >= 20x20 in the browser path)
17
- // already filter out plain inline form labels so this does not introduce
18
- // false positives. See modern-color-borders.html for the test matrix.
19
- const BORDER_SAFE_TAGS = new Set(
20
- [...SAFE_TAGS].filter(t => t !== 'label')
21
- );
22
-
23
- const OVERUSED_FONTS = new Set([
24
- // Older monoculture (still ubiquitous):
25
- 'inter', 'roboto', 'open sans', 'lato', 'montserrat', 'arial', 'helvetica',
26
- // Newer monoculture (the Anthropic-skill / Vercel / GitHub default wave):
27
- 'fraunces', 'instrument sans', 'instrument serif',
28
- 'geist', 'geist sans', 'geist mono',
29
- 'mona sans',
30
- 'plus jakarta sans', 'space grotesk', 'recoleta',
31
- ]);
32
-
33
- // Brand-associated fonts: don't flag these as "overused" on the brand's own domains.
34
- // Keys are font names, values are arrays of hostname suffixes where the font is allowed.
35
- const GOOGLE_DOMAINS = [
36
- 'google.com', 'youtube.com', 'android.com', 'chromium.org',
37
- 'chrome.com', 'web.dev', 'gstatic.com', 'firebase.google.com',
38
- ];
39
- const VERCEL_DOMAINS = ['vercel.com', 'nextjs.org', 'v0.app'];
40
- const GITHUB_DOMAINS = ['github.com', 'githubnext.com'];
41
- const BRAND_FONT_DOMAINS = {
42
- 'roboto': GOOGLE_DOMAINS,
43
- 'google sans': GOOGLE_DOMAINS,
44
- 'product sans': GOOGLE_DOMAINS,
45
- 'geist': VERCEL_DOMAINS,
46
- 'geist sans': VERCEL_DOMAINS,
47
- 'geist mono': VERCEL_DOMAINS,
48
- 'mona sans': GITHUB_DOMAINS,
49
- };
50
-
51
- function isBrandFontOnOwnDomain(font) {
52
- if (typeof location === 'undefined') return false;
53
- const allowed = BRAND_FONT_DOMAINS[font];
54
- if (!allowed) return false;
55
- const host = location.hostname.toLowerCase();
56
- return allowed.some(suffix => host === suffix || host.endsWith('.' + suffix));
57
- }
58
-
59
- const GENERIC_FONTS = new Set([
60
- 'serif', 'sans-serif', 'monospace', 'cursive', 'fantasy',
61
- 'system-ui', 'ui-serif', 'ui-sans-serif', 'ui-monospace', 'ui-rounded',
62
- '-apple-system', 'blinkmacsystemfont', 'segoe ui',
63
- 'inherit', 'initial', 'unset', 'revert',
64
- ]);
65
-
66
- // WCAG large text thresholds are defined in points: 18pt normal text and
67
- // 14pt bold text. Browsers expose font-size in CSS pixels at 96px per inch.
68
- const WCAG_LARGE_TEXT_PX = 18 * (96 / 72);
69
- const WCAG_LARGE_BOLD_TEXT_PX = 14 * (96 / 72);
70
-
71
- // Em-dash overuse (advisory) thresholds, shared by the regex/static-HTML
72
- // analyzer and the browser DOM check so both fire on the same saturation
73
- // pattern. Two gates must hold: an absolute floor of EM_DASH_FLOOR dashes, and
74
- // a density of at least one dash per EM_DASH_CHARS_PER_DASH characters of body
75
- // text. A long article that uses a few em-dashes is left alone; a short,
76
- // dash-per-clause page is not.
77
- const EM_DASH_FLOOR = 8;
78
- const EM_DASH_CHARS_PER_DASH = 500;
79
-
80
- // Serif faces that show up in italic-display heroes. The rule also fires when
81
- // the primary face is unknown but the stack ends in the generic `serif` token,
82
- // which catches custom/private faces with a serif fallback.
83
- const KNOWN_SERIF_FONTS = new Set([
84
- 'fraunces', 'recoleta', 'newsreader', 'playfair display', 'playfair',
85
- 'cormorant', 'cormorant garamond', 'garamond', 'eb garamond',
86
- 'tiempos', 'tiempos headline', 'tiempos text',
87
- 'lora', 'vollkorn', 'spectral',
88
- 'source serif pro', 'source serif 4', 'source serif',
89
- 'ibm plex serif', 'merriweather',
90
- 'libre caslon', 'libre baskerville', 'baskerville',
91
- 'georgia', 'times new roman', 'times',
92
- 'dm serif display', 'dm serif text',
93
- 'instrument serif', 'gt sectra', 'ogg', 'canela',
94
- 'freight display', 'freight text',
95
- ]);
96
-
97
- export {
98
- SAFE_TAGS,
99
- BORDER_SAFE_TAGS,
100
- OVERUSED_FONTS,
101
- GOOGLE_DOMAINS,
102
- VERCEL_DOMAINS,
103
- GITHUB_DOMAINS,
104
- BRAND_FONT_DOMAINS,
105
- isBrandFontOnOwnDomain,
106
- GENERIC_FONTS,
107
- WCAG_LARGE_TEXT_PX,
108
- WCAG_LARGE_BOLD_TEXT_PX,
109
- EM_DASH_FLOOR,
110
- EM_DASH_CHARS_PER_DASH,
111
- KNOWN_SERIF_FONTS,
112
- };
@@ -1,30 +0,0 @@
1
- const GOOGLE_FONTS_URL_RE = /fonts\.googleapis\.com\/css2?\?[^"'\s)<>]*/gi;
2
-
3
- function normalizeGoogleFontFamilyParam(value) {
4
- return String(value || '')
5
- .split('|')
6
- .map(part => part.split(':')[0].trim().toLowerCase())
7
- .filter(Boolean);
8
- }
9
-
10
- function extractGoogleFontFamilies(text) {
11
- const families = [];
12
- if (!text) return families;
13
-
14
- GOOGLE_FONTS_URL_RE.lastIndex = 0;
15
- let urlMatch;
16
- while ((urlMatch = GOOGLE_FONTS_URL_RE.exec(text)) !== null) {
17
- const url = urlMatch[0];
18
- const queryStart = url.indexOf('?');
19
- if (queryStart === -1) continue;
20
-
21
- const params = new URLSearchParams(url.slice(queryStart + 1).replace(/&amp;/g, '&'));
22
- for (const value of params.getAll('family')) {
23
- families.push(...normalizeGoogleFontFamilyParam(value));
24
- }
25
- }
26
-
27
- return families;
28
- }
29
-
30
- export { extractGoogleFontFamilies };
@@ -1,148 +0,0 @@
1
- /**
2
- * Inline, in-file ignore directives — eslint-disable-style waivers that live at
3
- * the point they apply and travel with the artifact instead of (or alongside)
4
- * an ignore in `.impeccable/config.json`.
5
- *
6
- * A config ignore is the right default for repo-wide policy. This complements it
7
- * for the one case config can't cover: a waiver that belongs to a single file and
8
- * needs to follow that file when it leaves the repo — a generated/exported
9
- * standalone document, an emailed HTML file, a snippet scanned out of context.
10
- *
11
- * Comment-syntax-agnostic: the directive is a raw token matched anywhere on a
12
- * line, so the same marker works across every comment style impeccable scans —
13
- * `//`, `/* *\/`, `<!-- -->`, `#`, `{/* *\/}`, `{# #}`. Trailing comment closers
14
- * are stripped before the rule list is parsed.
15
- *
16
- * Syntax (reason optional; eslint `--` or biome `:` separator):
17
- *
18
- * impeccable-disable <rule>[, <rule>...] [-- reason] whole file
19
- * impeccable-disable-line <rule>... [-- reason] the same line
20
- * impeccable-disable-next-line <rule>... [-- reason] the following line
21
- * impeccable-disable bare / `*` = every rule
22
- *
23
- * Examples:
24
- *
25
- * <!-- impeccable-disable overused-font -- exported brand doc, font is first-party -->
26
- * .brand { font-family: Inter; } /* impeccable-disable-line overused-font *\/
27
- * // impeccable-disable-next-line bounce-easing: intentional playful affordance
28
- *
29
- * Behavior is suppression, for parity with config ignores: a matched directive
30
- * drops the finding. The inline reason is self-documenting in the diff; it is not
31
- * required and is discarded at scan time (only used here to keep reason words out
32
- * of the parsed rule list).
33
- */
34
-
35
- const DIRECTIVE_RE = /impeccable-(disable-next-line|disable-line|disable)\b[ \t]*([^\n\r]*)/gi;
36
-
37
- // Trailing comment closers, so `*/`, `*/}`, `-->`, `*}`, `#}`, `%>`, `}}` don't
38
- // leak into the rule list. Anchored to end-of-line; the leading `\s*` mops up the
39
- // space before the closer. `--+>` covers `-->` and any longer dash run.
40
- const TRAILING_CLOSER_RE = /\s*(?:\*\/\}?|--+>|\*\}|#\}|%>|\}\})\s*$/;
41
-
42
- function normalizeRule(token) {
43
- return String(token || '').trim().toLowerCase();
44
- }
45
-
46
- // Split the directive remainder into rule tokens, dropping any human reason that
47
- // follows an eslint-style `--` or biome-style `:` separator. Rule ids only ever
48
- // contain single hyphens (`overused-font`, `bounce-easing`), so `--` and `:`
49
- // are unambiguous separators.
50
- function parseRuleList(remainder) {
51
- let text = String(remainder || '').replace(TRAILING_CLOSER_RE, '').trim();
52
- // Cut off a human reason at the first `--` (eslint) or `:` (biome) separator.
53
- const reasonSep = text.match(/\s*(?:--+|:)\s*/);
54
- if (reasonSep) text = text.slice(0, reasonSep.index);
55
- const tokens = text.split(/[\s,]+/).map(normalizeRule).filter(Boolean);
56
- if (tokens.length === 0 || tokens.includes('*')) return ['*'];
57
- return tokens;
58
- }
59
-
60
- function addRules(set, rules) {
61
- for (const rule of rules) set.add(rule);
62
- }
63
-
64
- function getSet(map, key) {
65
- let set = map.get(key);
66
- if (!set) {
67
- set = new Set();
68
- map.set(key, set);
69
- }
70
- return set;
71
- }
72
-
73
- /**
74
- * Parse every inline ignore directive in a file's raw text.
75
- *
76
- * Returns sets keyed by the 1-based line the directive *targets* so matching is a
77
- * direct lookup:
78
- * - file: rules disabled for the whole file
79
- * - line: line -> rules disabled on that exact line (disable-line)
80
- * - nextLine: line -> rules disabled on that line (disable-next-line on line-1)
81
- *
82
- * `*` in any set means "every rule".
83
- */
84
- function parseInlineIgnores(content) {
85
- const result = { file: new Set(), line: new Map(), nextLine: new Map() };
86
- const text = typeof content === 'string' ? content : '';
87
- // Cheap bail-out: the substring must be present for any directive to exist.
88
- // Case-insensitive to match DIRECTIVE_RE's `i` flag (e.g. `Impeccable-Disable`).
89
- if (!/impeccable-disable/i.test(text)) return result;
90
-
91
- // Split on `\n` only, exactly as detectText numbers lines, so directive line
92
- // keys line up with finding `line` values (incl. on `\r`-only line endings).
93
- // The directive regex excludes `\r`, so a trailing `\r` on `\r\n` files is
94
- // never captured into the rule list.
95
- const lines = text.split('\n');
96
- for (let i = 0; i < lines.length; i++) {
97
- DIRECTIVE_RE.lastIndex = 0;
98
- let m;
99
- while ((m = DIRECTIVE_RE.exec(lines[i])) !== null) {
100
- const variant = m[1].toLowerCase();
101
- const rules = parseRuleList(m[2]);
102
- if (variant === 'disable') {
103
- addRules(result.file, rules);
104
- } else if (variant === 'disable-line') {
105
- addRules(getSet(result.line, i + 1), rules);
106
- } else {
107
- // disable-next-line on line i+1 targets line i+2.
108
- addRules(getSet(result.nextLine, i + 2), rules);
109
- }
110
- }
111
- }
112
- return result;
113
- }
114
-
115
- function setMatches(set, rule) {
116
- return Boolean(set) && (set.has('*') || set.has(rule));
117
- }
118
-
119
- function isInlineIgnored(finding, directives) {
120
- const rule = normalizeRule(finding && finding.antipattern);
121
- if (!rule) return false;
122
- if (setMatches(directives.file, rule)) return true;
123
- const line = Number(finding && finding.line) || 0;
124
- if (line > 0) {
125
- if (setMatches(directives.line.get(line), rule)) return true;
126
- if (setMatches(directives.nextLine.get(line), rule)) return true;
127
- }
128
- return false;
129
- }
130
-
131
- function hasDirectives(directives) {
132
- return directives.file.size > 0 || directives.line.size > 0 || directives.nextLine.size > 0;
133
- }
134
-
135
- /**
136
- * Drop findings waived by an inline directive in the same file's source text.
137
- * Findings without a usable line number (e.g. static-HTML page-level findings)
138
- * are only matched by whole-file directives — which is the standalone-document
139
- * case this primitive exists for.
140
- */
141
- function applyInlineIgnores(findings, content) {
142
- if (!Array.isArray(findings) || findings.length === 0) return findings;
143
- const directives = parseInlineIgnores(content);
144
- if (!hasDirectives(directives)) return findings;
145
- return findings.filter((finding) => !isInlineIgnored(finding, directives));
146
- }
147
-
148
- export { parseInlineIgnores, applyInlineIgnores, isInlineIgnored };
@@ -1,35 +0,0 @@
1
- /** Remove complete script/style elements and comments without regex-based HTML sanitization. */
2
- function stripHtmlBlocks(content, tagNames = []) {
3
- let out = String(content);
4
- for (const tagName of tagNames) {
5
- const opener = `<${tagName}`;
6
- const closer = `</${tagName}`;
7
- while (true) {
8
- const lower = out.toLowerCase();
9
- const start = lower.indexOf(opener);
10
- if (start === -1) break;
11
- const openEnd = lower.indexOf('>', start + opener.length);
12
- const closeStart = openEnd === -1 ? -1 : lower.indexOf(closer, openEnd + 1);
13
- const closeEnd = closeStart === -1 ? -1 : lower.indexOf('>', closeStart + closer.length);
14
- if (openEnd === -1 || closeStart === -1 || closeEnd === -1) break;
15
- out = out.slice(0, start) + ' ' + out.slice(closeEnd + 1);
16
- }
17
- }
18
- while (true) {
19
- const start = out.indexOf('<!--');
20
- if (start === -1) break;
21
- const normalEnd = out.indexOf('-->', start + 4);
22
- const bangEnd = out.indexOf('--!>', start + 4);
23
- const end = normalEnd === -1 ? bangEnd : bangEnd === -1 ? normalEnd : Math.min(normalEnd, bangEnd);
24
- if (end === -1) break;
25
- out = out.slice(0, start) + out.slice(end + (end === bangEnd ? 4 : 3));
26
- }
27
- return out;
28
- }
29
-
30
- /** Check if content looks like a full page (not a component/partial) */
31
- function isFullPage(content) {
32
- return /<!doctype\s|<html[\s>]|<head[\s>]/i.test(stripHtmlBlocks(content));
33
- }
34
-
35
- export { isFullPage, stripHtmlBlocks };
@@ -1,338 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Deep staleness pass over Impeccable's own project artifacts.
4
- *
5
- * node doctor.mjs # human-readable report
6
- * node doctor.mjs --json # machine-readable, for the skill command
7
- * node doctor.mjs --fix # apply the mechanical migrations only
8
- * node doctor.mjs --target <path> # pick a monorepo workspace
9
- *
10
- * The boot check in context.mjs reports what a session can afford to measure.
11
- * This runs everything: git drift, per-workspace sweep, ignore-list validation
12
- * against the live rule registry, hook script resolution.
13
- *
14
- * `--fix` is deliberately narrow. It performs only the migrations marked
15
- * severity 'auto', the ones with no judgment in them: stamp the product record,
16
- * move a sidecar out of a retired location. Anything that needs an answer from
17
- * the user (a platform value, whether an inherited record still describes an
18
- * app, whether a document has drifted from the code) is reported and left
19
- * alone. Exit code is 0 unless the run itself failed; findings are not errors.
20
- */
21
-
22
- import fs from 'node:fs';
23
- import path from 'node:path';
24
- import { fileURLToPath } from 'node:url';
25
-
26
- import { loadContext, extractPlatform, resolveTargetSelection } from './context.mjs';
27
- import { parseTargetOptions } from './lib/target-args.mjs';
28
- import { IMPECCABLE_COMMAND, IMPECCABLE_PROVIDER_ID } from './lib/provider.mjs';
29
- import { parseDesignMd } from './lib/design-parser.mjs';
30
- import {
31
- PRODUCT_SCHEMA_VERSION,
32
- readProductSchemaVersion,
33
- stampProductSchema,
34
- } from './lib/artifact-schema.mjs';
35
- import {
36
- checkBuildPathUnset,
37
- checkConfig,
38
- checkDesignSidecar,
39
- checkNativePlatformEvidence,
40
- checkProduct,
41
- checkProjectRoots,
42
- checkSurfaceBriefs,
43
- designSidecarCandidatesFor,
44
- } from './lib/staleness.mjs';
45
- import {
46
- checkDesignCoverage,
47
- checkDesignDrift,
48
- checkDetectorIgnores,
49
- checkHookInstallation,
50
- checkLegacyLiveState,
51
- checkWorkspaces,
52
- loadKnownRuleIds,
53
- } from './lib/staleness-deep.mjs';
54
-
55
- const SCRIPTS_DIR = path.dirname(fileURLToPath(import.meta.url));
56
-
57
- function safeRead(filePath) {
58
- try {
59
- return fs.readFileSync(filePath, 'utf-8');
60
- } catch {
61
- return null;
62
- }
63
- }
64
-
65
- function parseArgs(argv) {
66
- const passthrough = [];
67
- const flags = { json: false, fix: false, help: false };
68
- for (const arg of argv) {
69
- if (arg === '--json') flags.json = true;
70
- else if (arg === '--fix') flags.fix = true;
71
- else if (arg === '--help' || arg === '-h') flags.help = true;
72
- else passthrough.push(arg);
73
- }
74
- return { flags, targetOptions: parseTargetOptions(passthrough, { strict: true }) };
75
- }
76
-
77
- function usage() {
78
- return [
79
- `Usage: node doctor.mjs [--json] [--fix] [--target <path>]`,
80
- '',
81
- "Report drift between this project's Impeccable artifacts and what the",
82
- 'installed version reads: PRODUCT.md, DESIGN.md and its sidecar,',
83
- '.impeccable/config.json, surface briefs, and the design hook.',
84
- '',
85
- ' --json Emit findings as JSON.',
86
- ' --fix Apply the mechanical migrations (severity "auto") only.',
87
- ' --target <path> Select a workspace in a monorepo.',
88
- ].join('\n');
89
- }
90
-
91
- async function collect(cwd, targetOptions) {
92
- const ctx = loadContext(cwd, targetOptions);
93
- const projectRoot = ctx.projectRoot || cwd;
94
- const absProductPath = ctx.productPath ? path.resolve(cwd, ctx.productPath) : null;
95
- const absDesignPath = ctx.designPath ? path.resolve(cwd, ctx.designPath) : null;
96
- const sidecarCandidates = designSidecarCandidatesFor(projectRoot, ctx.contextDir);
97
- const knownRuleIds = await loadKnownRuleIds(SCRIPTS_DIR);
98
-
99
- const selection = resolveTargetSelection(cwd, targetOptions);
100
- const workspaceCandidates = selection?.targetCandidates || [];
101
-
102
- const workspaceResult = checkWorkspaces({
103
- repoRoot: ctx.repoRoot,
104
- candidates: workspaceCandidates,
105
- checkNativePlatformEvidence,
106
- extractPlatform,
107
- readFile: safeRead,
108
- });
109
-
110
- const findings = [
111
- ...checkProduct(ctx.product, ctx.productPath || 'PRODUCT.md'),
112
- ...(ctx.product
113
- ? checkNativePlatformEvidence({
114
- projectRoot,
115
- platform: ctx.platform,
116
- product: ctx.product,
117
- productPath: ctx.productPath,
118
- })
119
- : []),
120
- ...checkDesignSidecar({ designPath: absDesignPath, sidecarCandidates, projectRoot }),
121
- ...checkDesignDrift({ designPath: absDesignPath, projectRoot }),
122
- ...checkDesignCoverage({ design: ctx.design, designPath: ctx.designPath, parseDesignMd }),
123
- ...checkConfig({ projectRoot, repoRoot: ctx.repoRoot }),
124
- ...checkBuildPathUnset({ projectRoot, repoRoot: ctx.repoRoot, product: ctx.product }),
125
- ...checkDetectorIgnores({ projectRoot, knownRuleIds }),
126
- ...checkSurfaceBriefs({ candidates: ctx.surfaceBriefCandidates, projectRoot }),
127
- ...checkHookInstallation({
128
- projectRoot,
129
- repoRoot: ctx.repoRoot,
130
- providerId: IMPECCABLE_PROVIDER_ID,
131
- }),
132
- ...checkLegacyLiveState({ projectRoot }),
133
- ...checkProjectRoots({
134
- patterns: readProjectRootPatterns(ctx.repoRoot),
135
- candidates: workspaceCandidates,
136
- }),
137
- ...workspaceResult.findings,
138
- ];
139
-
140
- return {
141
- ctx,
142
- projectRoot,
143
- absProductPath,
144
- sidecarCandidates,
145
- findings,
146
- workspaces: workspaceResult.workspaces,
147
- ruleRegistryAvailable: knownRuleIds !== null,
148
- };
149
- }
150
-
151
- // Read straight from disk rather than importing context.mjs's private reader.
152
- // Only the positive/negative pattern strings matter here.
153
- function readProjectRootPatterns(repoRoot) {
154
- if (!repoRoot) return [];
155
- const patterns = [];
156
- for (const name of ['config.json', 'config.local.json']) {
157
- try {
158
- const raw = JSON.parse(fs.readFileSync(path.join(repoRoot, '.impeccable', name), 'utf-8'));
159
- if (Array.isArray(raw?.projectRoots)) {
160
- for (const entry of raw.projectRoots) {
161
- if (typeof entry === 'string' && entry.trim()) patterns.push(entry.trim());
162
- }
163
- }
164
- } catch { /* missing or malformed: nothing to check */ }
165
- }
166
- return patterns;
167
- }
168
-
169
- /**
170
- * Apply the migrations that carry no decision. Returns what was done and what
171
- * was deliberately left for the user.
172
- */
173
- function applyFixes(report) {
174
- const applied = [];
175
- const skipped = [];
176
-
177
- for (const entry of report.findings) {
178
- if (entry.severity !== 'auto') {
179
- skipped.push({ id: entry.id, reason: 'needs a decision from the user' });
180
- continue;
181
- }
182
- if (entry.id === 'design-sidecar-legacy-path') {
183
- const canonical = report.sidecarCandidates[0];
184
- const present = report.sidecarCandidates.find((candidate) => fs.existsSync(candidate));
185
- if (!canonical || !present || path.resolve(canonical) === path.resolve(present)) continue;
186
- if (fs.existsSync(canonical)) {
187
- skipped.push({ id: entry.id, reason: `${rel(canonical, report.projectRoot)} already exists; not overwriting` });
188
- continue;
189
- }
190
- fs.mkdirSync(path.dirname(canonical), { recursive: true });
191
- fs.renameSync(present, canonical);
192
- applied.push(`Moved ${rel(present, report.projectRoot)} to ${rel(canonical, report.projectRoot)}.`);
193
- continue;
194
- }
195
- if (entry.id === 'legacy-live-state') {
196
- // Reported, never deleted here: a running live session still reads these,
197
- // and losing session state to a doctor run is a worse outcome than a
198
- // stale file. The report says what to remove and when.
199
- skipped.push({ id: entry.id, reason: 'delete by hand once no live session is running' });
200
- continue;
201
- }
202
- skipped.push({ id: entry.id, reason: 'no automatic migration implemented' });
203
- }
204
-
205
- // Stamping the product record is additive and safe, and it is what stops a
206
- // later version proposing an interview the user has already sat through.
207
- const productPath = report.absProductPath;
208
- if (productPath && report.ctx.product && readProductSchemaVersion(report.ctx.product) === null
209
- && !report.findings.some((entry) => entry.id === 'product-schema-legacy')) {
210
- fs.writeFileSync(productPath, stampProductSchema(report.ctx.product), 'utf-8');
211
- applied.push(`Stamped ${rel(productPath, report.projectRoot)} as product-schema ${PRODUCT_SCHEMA_VERSION}.`);
212
- }
213
-
214
- return { applied, skipped };
215
- }
216
-
217
- function rel(filePath, root) {
218
- const value = path.relative(root, filePath);
219
- return value && !value.startsWith('..') ? value.split(path.sep).join('/') : filePath;
220
- }
221
-
222
- const SEVERITY_LABEL = {
223
- auto: 'automatic',
224
- mention: 'worth saying',
225
- route: 'needs a command',
226
- };
227
-
228
- function renderText(report, fixes) {
229
- const lines = [];
230
- const { findings } = report;
231
-
232
- lines.push(`Impeccable doctor: ${rel(report.projectRoot, process.cwd()) || '.'}`);
233
- if (report.ctx.isMonorepo) {
234
- lines.push(`Monorepo, repo root ${rel(report.ctx.repoRoot, process.cwd()) || '.'}.`);
235
- }
236
- lines.push('');
237
-
238
- if (!findings.length) {
239
- lines.push('No drift found. Every artifact matches what this version reads.');
240
- } else {
241
- const order = ['route', 'mention', 'auto'];
242
- for (const severity of order) {
243
- const group = findings.filter((entry) => entry.severity === severity);
244
- if (!group.length) continue;
245
- lines.push(`${SEVERITY_LABEL[severity]} (${group.length}):`);
246
- for (const entry of group) {
247
- lines.push(` ${entry.id}${entry.path ? ` [${entry.path}]` : ''}`);
248
- lines.push(` ${entry.summary}`);
249
- lines.push(` → ${entry.fix}`);
250
- }
251
- lines.push('');
252
- }
253
- }
254
-
255
- if (report.workspaces.length) {
256
- lines.push('Workspaces:');
257
- for (const workspace of report.workspaces) {
258
- lines.push(` ${workspace.path} product: ${workspace.productStatus}`
259
- + ` design: ${workspace.designStatus}`
260
- + `${workspace.platform ? ` platform: ${workspace.platform}` : ''}`);
261
- }
262
- lines.push('');
263
- }
264
-
265
- if (!report.ruleRegistryAvailable) {
266
- lines.push('Note: the bundled detector could not be resolved, so ignored rule ids were not validated.');
267
- lines.push('');
268
- }
269
-
270
- if (fixes) {
271
- lines.push(fixes.applied.length ? 'Applied:' : 'Applied nothing.');
272
- for (const entry of fixes.applied) lines.push(` ${entry}`);
273
- const held = fixes.skipped.filter((entry) => entry.reason !== 'needs a decision from the user');
274
- if (held.length) {
275
- lines.push('Left alone:');
276
- for (const entry of held) lines.push(` ${entry.id}: ${entry.reason}`);
277
- }
278
- } else if (findings.some((entry) => entry.severity === 'auto')) {
279
- lines.push(`Run \`node doctor.mjs --fix\` to apply the automatic migrations, `
280
- + `or \`${IMPECCABLE_COMMAND} doctor\` to work through all of them.`);
281
- }
282
-
283
- return lines.join('\n');
284
- }
285
-
286
- async function cli() {
287
- let parsed;
288
- try {
289
- parsed = parseArgs(process.argv.slice(2));
290
- } catch (err) {
291
- process.stderr.write(`${err.message}\n`);
292
- process.exit(1);
293
- }
294
- if (parsed.flags.help) {
295
- process.stdout.write(`${usage()}\n`);
296
- return;
297
- }
298
-
299
- const report = await collect(process.cwd(), parsed.targetOptions);
300
- const fixes = parsed.flags.fix ? applyFixes(report) : null;
301
-
302
- if (parsed.flags.json) {
303
- process.stdout.write(`${JSON.stringify({
304
- projectRoot: report.projectRoot,
305
- repoRoot: report.ctx.repoRoot,
306
- isMonorepo: report.ctx.isMonorepo,
307
- productPath: report.ctx.productPath,
308
- designPath: report.ctx.designPath,
309
- platform: report.ctx.platform,
310
- ruleRegistryAvailable: report.ruleRegistryAvailable,
311
- findings: report.findings,
312
- workspaces: report.workspaces,
313
- ...(fixes ? { fixes } : {}),
314
- }, null, 2)}\n`);
315
- return;
316
- }
317
-
318
- process.stdout.write(`${renderText(report, fixes)}\n`);
319
- }
320
-
321
- function invokedAsScript() {
322
- const arg = process.argv[1];
323
- if (!arg) return false;
324
- try {
325
- return fs.realpathSync(arg) === fs.realpathSync(fileURLToPath(import.meta.url));
326
- } catch {
327
- return false;
328
- }
329
- }
330
-
331
- if (invokedAsScript()) {
332
- cli().catch((err) => {
333
- process.stderr.write(`impeccable doctor failed: ${err?.message || err}\n`);
334
- process.exit(1);
335
- });
336
- }
337
-
338
- export { collect, applyFixes, renderText };