@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,365 +0,0 @@
1
- /**
2
- * CLI entry point: prepare everything needed to enter the live variant poll loop.
3
- *
4
- * Does (all in one command):
5
- * 1. Check .impeccable/live/config.json (returns config_missing if first-ever run)
6
- * 2. Start the live server in the background (or reuse a running one)
7
- * 3. Inject the browser script tag into the project's entry file
8
- * 4. Read PRODUCT.md / DESIGN.md for project context
9
- * 5. Print a single JSON blob with everything the agent needs
10
- *
11
- * After this, the agent's only remaining steps are:
12
- * - Open the project's live dev/preview URL in the browser (optional, if browser automation exists)—not `serverPort`; that port is the Impeccable helper for /live.js and /poll
13
- * - Enter the harness-native poll loop: `node live-poll.mjs`
14
- *
15
- * Usage:
16
- * node live.mjs # Prepare everything, print JSON, exit
17
- * node live.mjs --help
18
- */
19
-
20
- import { execFileSync } from 'node:child_process';
21
- import fs from 'node:fs';
22
- import path from 'node:path';
23
- import { fileURLToPath } from 'node:url';
24
- import { resolveTargetSelection } from './context.mjs';
25
- import { resolveFiles } from './live-inject.mjs';
26
- import { readLiveServerInfo } from './lib/impeccable-paths.mjs';
27
- import { resolveSurfaceBrief } from './lib/surface-briefs.mjs';
28
- import { resolveLiveTarget } from './live-target.mjs';
29
- import { bootInstructions } from './live/instructions.mjs';
30
- import { resolveRoots, writeRootsManifest } from './live/roots.mjs';
31
-
32
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
33
-
34
- async function liveCli() {
35
- const args = process.argv.slice(2);
36
- const liveTarget = resolveLiveTarget(process.cwd(), args);
37
-
38
- if (args.includes('--help') || args.includes('-h')) {
39
- console.log(`Usage: node live.mjs
40
-
41
- Prepare everything for live variant mode in a single command:
42
- - Checks .impeccable/live/config.json (required, created once per project)
43
- - Starts (or reuses) the live server in the background
44
- - Injects the browser script tag
45
- - Reads PRODUCT.md / DESIGN.md for project context
46
- - Prepares the harness-native foreground/background poll loop
47
- - In monorepos, choose a child app first; --target <path> is the fallback/manual path
48
-
49
- On success, prints a JSON blob with:
50
- { ok, serverPort, serverToken, pageFiles, projectRoot, repoRoot, targetPath, productPath, designPath }
51
-
52
- On target_selection_required, prints:
53
- { ok: false, error: "target_selection_required", targetCandidates }
54
-
55
- On config_missing, prints:
56
- { ok: false, error: "config_missing", configPath, hint }
57
-
58
- The agent should then:
59
- 1. If target_selection_required, ask which app to use and rerun from that child cwd
60
- 2. If config_missing, create the config and re-run this script
61
- 3. Optionally open the project's dev/preview URL in the browser (see reference/live.md—not serverPort)
62
- 4. Enter the poll loop: node live-poll.mjs`);
63
- process.exit(0);
64
- }
65
-
66
- // Legacy workspace-monorepo selection first: it carries richer candidate
67
- // metadata (context inheritance status) than the roots scan.
68
- const targetSelection = resolveTargetSelection(liveTarget.originalCwd, liveTarget.targetOptions);
69
- if (targetSelection) {
70
- console.log(JSON.stringify({
71
- ok: false,
72
- error: 'target_selection_required',
73
- ...targetSelection,
74
- hint: 'Ask the user which app Impeccable should use, then rerun live from that child app cwd. Use --target <path> only as a fallback or explicit path diagnostic.',
75
- }, null, 2));
76
- process.exit(0);
77
- }
78
-
79
- const rootsResult = resolveRoots({
80
- cwd: liveTarget.originalCwd,
81
- targetPath: liveTarget.absoluteTargetPath,
82
- });
83
- if (rootsResult.selection) {
84
- console.log(JSON.stringify({
85
- ok: false,
86
- error: 'target_selection_required',
87
- targetCandidates: rootsResult.selection.candidates,
88
- hint: 'Several apps with a dev-server config exist. Ask the user which one to use, then rerun with --target <path into that app>.',
89
- }, null, 2));
90
- process.exit(0);
91
- }
92
- const roots = rootsResult.manifest;
93
- const activeCwd = roots.appRoot;
94
- const outputTargetPath = liveTarget.targetPath || null;
95
-
96
- // Gate on readable CONTENT, not path existence, so an empty or unreadable
97
- // PRODUCT.md routes to init instead of passing the gate and then reporting
98
- // hasProduct: false in the same payload.
99
- const product = safeRead(roots.productPath);
100
- const design = safeRead(roots.designPath);
101
- const missingContext = [];
102
- if (!product) missingContext.push('PRODUCT.md');
103
- if (!design) missingContext.push('DESIGN.md');
104
- if (missingContext.length > 0) {
105
- console.log(JSON.stringify({
106
- ok: false,
107
- error: 'context_missing',
108
- missing: missingContext,
109
- nextCommand: missingContext.includes('PRODUCT.md') ? 'init' : 'document',
110
- targetPath: outputTargetPath,
111
- projectRoot: roots.appRoot,
112
- repoRoot: roots.repoRoot,
113
- productPath: relOrNull(liveTarget.originalCwd, roots.productPath),
114
- designPath: relOrNull(liveTarget.originalCwd, roots.designPath),
115
- }, null, 2));
116
- process.exit(0);
117
- }
118
-
119
- // Persist the decision before anything else spawns, so every helper the
120
- // agent runs later (from any cwd inside the repo) lands on the same roots.
121
- writeRootsManifest(roots);
122
-
123
- // 1. Check config (fail fast if missing — no point starting anything else)
124
- const checkOut = runScript('live-inject.mjs', ['--check'], { cwd: activeCwd });
125
- const checkResult = safeParse(checkOut);
126
- if (!checkResult || !checkResult.ok) {
127
- console.log(JSON.stringify({
128
- ...(checkResult || { ok: false, error: 'check_failed', raw: checkOut }),
129
- targetPath: outputTargetPath,
130
- projectRoot: roots.appRoot,
131
- repoRoot: roots.repoRoot,
132
- }));
133
- process.exit(0);
134
- }
135
-
136
- // 2. Start server (or reuse existing)
137
- const serverInfo = ensureServerRunning(activeCwd);
138
- if (!serverInfo) {
139
- console.log(JSON.stringify({ ok: false, error: 'server_start_failed' }));
140
- process.exit(1);
141
- }
142
-
143
- // 3. Inject the script tag at the current port
144
- const injectOut = runScript(
145
- 'live-inject.mjs',
146
- ['--port', String(serverInfo.port), '--token', String(serverInfo.token)],
147
- { cwd: activeCwd },
148
- );
149
- const injectResult = safeParse(injectOut);
150
- if (!injectResult || !injectResult.ok) {
151
- console.log(JSON.stringify({
152
- ok: false,
153
- error: 'inject_failed',
154
- detail: injectResult || injectOut,
155
- serverPort: serverInfo.port,
156
- }));
157
- process.exit(1);
158
- }
159
-
160
- // 4. Compute drift-heal: compare resolved inject targets against the
161
- // project's HTML files. Orphans are HTML files not covered by config.
162
- // Warning only — the agent decides whether to act.
163
- const resolvedFiles = resolveFiles(activeCwd, checkResult.config);
164
- const drift = scanForDrift(activeCwd, resolvedFiles, checkResult.config);
165
-
166
- // 5. Emit everything the agent needs. The surface brief rides along so the
167
- // agent does not spend three more tool calls (and a --help miss) on
168
- // surface-brief.mjs before the first poll.
169
- let surfaceBrief = null;
170
- let surfaceBriefPath = null;
171
- try {
172
- // Briefs live under .impeccable/surfaces, which in a nested-app repo sits
173
- // at the CONTEXT or repo root, not the app root; context.mjs already finds
174
- // them there, and live must not report "no brief" for the same project.
175
- const briefRoots = [roots.appRoot, roots.contextRoot, roots.repoRoot]
176
- .filter(Boolean)
177
- .filter((dir, i, arr) => arr.findIndex((other) => path.resolve(other) === path.resolve(dir)) === i);
178
- for (const briefRoot of briefRoots) {
179
- const resolvedBrief = resolveSurfaceBrief(briefRoot, liveTarget.absoluteTargetPath || null);
180
- if (!resolvedBrief?.brief) continue;
181
- surfaceBrief = resolvedBrief.brief.text ?? safeRead(resolvedBrief.brief.path);
182
- surfaceBriefPath = resolvedBrief.brief.path
183
- ? path.relative(liveTarget.originalCwd, resolvedBrief.brief.path)
184
- : null;
185
- break;
186
- }
187
- } catch { /* briefs are optional context */ }
188
- console.log(JSON.stringify({
189
- ok: true,
190
- serverPort: serverInfo.port,
191
- serverToken: serverInfo.token,
192
- pageFiles: resolvedFiles,
193
- liveConfigPath: checkResult.path,
194
- configDrift: drift,
195
- targetPath: outputTargetPath,
196
- projectRoot: roots.appRoot,
197
- repoRoot: roots.repoRoot,
198
- roots,
199
- hasProduct: !!product,
200
- product,
201
- productPath: relOrNull(liveTarget.originalCwd, roots.productPath),
202
- hasDesign: !!design,
203
- design,
204
- designPath: relOrNull(liveTarget.originalCwd, roots.designPath),
205
- hasSurfaceBrief: !!surfaceBrief,
206
- surfaceBrief,
207
- surfaceBriefPath,
208
- _instructions: bootInstructions({ scriptsPath: __dirname }),
209
- }, null, 2));
210
- }
211
-
212
- function safeRead(p) {
213
- if (!p) return null;
214
- try { return fs.readFileSync(p, 'utf-8'); } catch { return null; }
215
- }
216
-
217
- function relOrNull(base, p) {
218
- return p ? path.relative(base, p) : null;
219
- }
220
-
221
- /**
222
- * Drift-heal scan. Walks the project for HTML files under common
223
- * page-source directories (public/, src/, app/, pages/) and reports any
224
- * that aren't covered by the resolved inject targets. This is purely
225
- * advisory — the agent can ignore it, or suggest the user add the
226
- * orphans to config.files.
227
- *
228
- * Skipped if config.files already contains at least one glob pattern
229
- * covering everything in practice (signaled by the orphan count being 0).
230
- */
231
- function scanForDrift(rootDir, resolvedFiles, config) {
232
- const SCAN_ROOTS = ['public', 'src', 'app', 'pages'];
233
- const IGNORE_DIRS = new Set([
234
- 'node_modules', '.git', '.next', '.nuxt', '.svelte-kit', '.astro',
235
- '.turbo', '.vercel', '.cache', 'coverage', 'dist', 'build',
236
- ]);
237
-
238
- const resolvedSet = new Set(resolvedFiles.map((f) => f.split(path.sep).join('/')));
239
-
240
- // Files matching the user's `exclude` globs are intentional omissions,
241
- // not drift. Compile them to regexes so the orphan list stays signal.
242
- const userExcludeRegexes = (Array.isArray(config.exclude) ? config.exclude : [])
243
- .map((p) => globToRegex(p));
244
- const isUserExcluded = (rel) => userExcludeRegexes.some((re) => re.test(rel));
245
-
246
- const orphans = [];
247
-
248
- const walk = (dir, relBase) => {
249
- let entries;
250
- try { entries = fs.readdirSync(dir, { withFileTypes: true }); }
251
- catch { return; }
252
- for (const e of entries) {
253
- const rel = relBase ? `${relBase}/${e.name}` : e.name;
254
- if (e.isDirectory()) {
255
- if (IGNORE_DIRS.has(e.name) || e.name.startsWith('.')) continue;
256
- walk(path.join(dir, e.name), rel);
257
- } else if (e.isFile() && e.name.endsWith('.html')) {
258
- if (resolvedSet.has(rel)) continue;
259
- if (isUserExcluded(rel)) continue;
260
- orphans.push(rel);
261
- }
262
- }
263
- };
264
-
265
- for (const root of SCAN_ROOTS) {
266
- const abs = path.join(rootDir, root);
267
- if (fs.existsSync(abs) && fs.statSync(abs).isDirectory()) {
268
- walk(abs, root);
269
- }
270
- }
271
-
272
- if (orphans.length === 0) return null;
273
- const capped = orphans.slice(0, 20);
274
- return {
275
- orphans: capped,
276
- orphanCount: orphans.length,
277
- hint: `${orphans.length} HTML file(s) exist but aren't in config.files. Consider adding them, or use a glob pattern like "public/**/*.html".`,
278
- };
279
- }
280
-
281
- /**
282
- * Same glob-to-regex mapping used by live-inject.mjs. Kept inline here
283
- * to avoid a circular import (live-inject.mjs already imports nothing
284
- * from live.mjs). The two must stay in sync.
285
- */
286
- function globToRegex(pattern) {
287
- let re = '';
288
- let i = 0;
289
- while (i < pattern.length) {
290
- const c = pattern[i];
291
- if (c === '*') {
292
- if (pattern[i + 1] === '*') {
293
- if (pattern[i + 2] === '/') { re += '(?:.*/)?'; i += 3; }
294
- else { re += '.*'; i += 2; }
295
- } else {
296
- re += '[^/]*';
297
- i += 1;
298
- }
299
- } else if (c === '?') {
300
- re += '[^/]';
301
- i += 1;
302
- } else if (/[.+^${}()|[\]\\]/.test(c)) {
303
- re += '\\' + c;
304
- i += 1;
305
- } else {
306
- re += c;
307
- i += 1;
308
- }
309
- }
310
- return new RegExp('^' + re + '$');
311
- }
312
-
313
- // ---------------------------------------------------------------------------
314
- // Helpers
315
- // ---------------------------------------------------------------------------
316
-
317
- function runScript(name, args, options = {}) {
318
- const scriptPath = path.join(__dirname, name);
319
- try {
320
- // argv form, never a shell: string interpolation into double quotes would
321
- // let a `"` or `$(...)` in any future caller's arg escape into the shell
322
- // (issue #476).
323
- return execFileSync(process.execPath, [scriptPath, ...args], {
324
- encoding: 'utf-8',
325
- cwd: options.cwd || process.cwd(),
326
- timeout: 15_000,
327
- });
328
- } catch (err) {
329
- // execFileSync throws on non-zero exit; return stdout if any
330
- return err.stdout || err.message || '';
331
- }
332
- }
333
-
334
- function safeParse(out) {
335
- try { return JSON.parse(String(out).trim()); } catch { return null; }
336
- }
337
-
338
- /**
339
- * Return { pid, port, token } for the running live server, starting one if needed.
340
- */
341
- function ensureServerRunning(cwd = process.cwd()) {
342
- // Try to reuse an existing server
343
- try {
344
- const existing = readLiveServerInfo(cwd)?.info;
345
- if (existing && existing.pid) {
346
- try {
347
- process.kill(existing.pid, 0); // throws if dead
348
- return existing;
349
- } catch { /* stale PID file — the server script will clean it up */ }
350
- }
351
- } catch { /* no PID file */ }
352
-
353
- // Start a new server
354
- const out = runScript('live-server.mjs', ['--background'], { cwd });
355
- return safeParse(out);
356
- }
357
-
358
- // ---------------------------------------------------------------------------
359
- // Auto-execute
360
- // ---------------------------------------------------------------------------
361
-
362
- const _running = process.argv[1];
363
- if (_running?.endsWith('live.mjs') || _running?.endsWith('live.mjs/')) {
364
- liveCli();
365
- }