@oriro/orirocli 0.1.8 → 0.1.11

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 (1445) hide show
  1. package/ATTRIBUTION.md +53 -45
  2. package/LICENSE +21 -0
  3. package/README.md +20 -17
  4. package/dist/cli.js +4425 -2975
  5. package/package.json +64 -64
  6. package/skills/1password/SKILL.md +118 -118
  7. package/skills/1password/references/cli-examples.md +29 -29
  8. package/skills/1password/references/get-started.md +21 -21
  9. package/skills/21stdev/SKILL.md +64 -0
  10. package/skills/algorithmic-art/LICENSE +21 -21
  11. package/skills/algorithmic-art/SKILL.md +446 -446
  12. package/skills/algorithmic-art/templates/generator_template.js +223 -223
  13. package/skills/algorithmic-art/templates/viewer.html +598 -598
  14. package/skills/apple-notes/SKILL.md +81 -81
  15. package/skills/apple-reminders/SKILL.md +122 -122
  16. package/skills/bear-notes/SKILL.md +111 -111
  17. package/skills/blogwatcher/SKILL.md +73 -73
  18. package/skills/blucli/SKILL.md +51 -51
  19. package/skills/brand-guidelines/LICENSE +21 -21
  20. package/skills/brand-guidelines/SKILL.md +76 -76
  21. package/skills/business/biz-analysis/LICENSE +21 -21
  22. package/skills/business/biz-analysis/SKILL.md +103 -103
  23. package/skills/business/biz-corporate-strategy/LICENSE +21 -21
  24. package/skills/business/biz-corporate-strategy/SKILL.md +76 -76
  25. package/skills/business/biz-customer-success/LICENSE +21 -21
  26. package/skills/business/biz-customer-success/SKILL.md +55 -55
  27. package/skills/business/biz-entrepreneurship/LICENSE +21 -21
  28. package/skills/business/biz-entrepreneurship/SKILL.md +72 -72
  29. package/skills/business/biz-hr/LICENSE +21 -21
  30. package/skills/business/biz-hr/SKILL.md +67 -67
  31. package/skills/business/biz-international/LICENSE +21 -21
  32. package/skills/business/biz-international/SKILL.md +51 -51
  33. package/skills/business/biz-leadership/LICENSE +21 -21
  34. package/skills/business/biz-leadership/SKILL.md +106 -106
  35. package/skills/business/biz-marketing-strategy/LICENSE +21 -21
  36. package/skills/business/biz-marketing-strategy/SKILL.md +119 -119
  37. package/skills/business/biz-negotiation/LICENSE +21 -21
  38. package/skills/business/biz-negotiation/SKILL.md +152 -152
  39. package/skills/business/biz-operations/LICENSE +21 -21
  40. package/skills/business/biz-operations/SKILL.md +74 -74
  41. package/skills/business/biz-project/LICENSE +21 -21
  42. package/skills/business/biz-project/SKILL.md +203 -203
  43. package/skills/business/biz-risk/LICENSE +21 -21
  44. package/skills/business/biz-risk/SKILL.md +85 -85
  45. package/skills/business/biz-sales/LICENSE +21 -21
  46. package/skills/business/biz-sales/SKILL.md +92 -92
  47. package/skills/business/biz-startup-ops/LICENSE +21 -21
  48. package/skills/business/biz-startup-ops/SKILL.md +70 -70
  49. package/skills/business/biz-strategy/LICENSE +21 -21
  50. package/skills/business/biz-strategy/SKILL.md +233 -233
  51. package/skills/business/biz-supply-chain-advanced/LICENSE +21 -21
  52. package/skills/business/biz-supply-chain-advanced/SKILL.md +68 -68
  53. package/skills/business/fin-chartered-exams/LICENSE +21 -21
  54. package/skills/business/fin-chartered-exams/SKILL.md +69 -69
  55. package/skills/camsnap/SKILL.md +49 -49
  56. package/skills/canvas/SKILL.md +82 -82
  57. package/skills/canvas-design/LICENSE +21 -21
  58. package/skills/canvas-design/SKILL.md +140 -140
  59. package/skills/canvas-design/canvas-fonts/ArsenalSC-OFL.txt +93 -93
  60. package/skills/canvas-design/canvas-fonts/BigShoulders-OFL.txt +93 -93
  61. package/skills/canvas-design/canvas-fonts/Boldonse-OFL.txt +93 -93
  62. package/skills/canvas-design/canvas-fonts/BricolageGrotesque-OFL.txt +93 -93
  63. package/skills/canvas-design/canvas-fonts/CrimsonPro-OFL.txt +93 -93
  64. package/skills/canvas-design/canvas-fonts/DMMono-OFL.txt +93 -93
  65. package/skills/canvas-design/canvas-fonts/EricaOne-OFL.txt +94 -94
  66. package/skills/canvas-design/canvas-fonts/GeistMono-OFL.txt +93 -93
  67. package/skills/canvas-design/canvas-fonts/Gloock-OFL.txt +93 -93
  68. package/skills/canvas-design/canvas-fonts/IBMPlexMono-OFL.txt +93 -93
  69. package/skills/canvas-design/canvas-fonts/InstrumentSans-OFL.txt +93 -93
  70. package/skills/canvas-design/canvas-fonts/JetBrainsMono-OFL.txt +93 -93
  71. package/skills/canvas-design/canvas-fonts/Jura-OFL.txt +93 -93
  72. package/skills/canvas-design/canvas-fonts/LibreBaskerville-OFL.txt +93 -93
  73. package/skills/canvas-design/canvas-fonts/Lora-OFL.txt +93 -93
  74. package/skills/canvas-design/canvas-fonts/NationalPark-OFL.txt +93 -93
  75. package/skills/canvas-design/canvas-fonts/Outfit-OFL.txt +93 -93
  76. package/skills/canvas-design/canvas-fonts/PixelifySans-OFL.txt +93 -93
  77. package/skills/canvas-design/canvas-fonts/RedHatMono-OFL.txt +93 -93
  78. package/skills/canvas-design/canvas-fonts/Silkscreen-OFL.txt +93 -93
  79. package/skills/canvas-design/canvas-fonts/SmoochSans-OFL.txt +93 -93
  80. package/skills/canvas-design/canvas-fonts/Tektur-OFL.txt +93 -93
  81. package/skills/canvas-design/canvas-fonts/WorkSans-OFL.txt +93 -93
  82. package/skills/canvas-design/canvas-fonts/YoungSerif-OFL.txt +93 -93
  83. package/skills/coding-agent/SKILL.md +146 -146
  84. package/skills/communication/comm-business-writing/LICENSE +21 -21
  85. package/skills/communication/comm-business-writing/SKILL.md +67 -67
  86. package/skills/communication/comm-cross-cultural/LICENSE +21 -21
  87. package/skills/communication/comm-cross-cultural/SKILL.md +88 -88
  88. package/skills/communication/comm-journalism/LICENSE +21 -21
  89. package/skills/communication/comm-journalism/SKILL.md +81 -81
  90. package/skills/communication/comm-linguistics/LICENSE +21 -21
  91. package/skills/communication/comm-linguistics/SKILL.md +82 -82
  92. package/skills/communication/comm-negotiation/LICENSE +21 -21
  93. package/skills/communication/comm-negotiation/SKILL.md +120 -120
  94. package/skills/communication/comm-presentations/LICENSE +21 -21
  95. package/skills/communication/comm-presentations/SKILL.md +93 -93
  96. package/skills/communication/comm-public-speaking/LICENSE +21 -21
  97. package/skills/communication/comm-public-speaking/SKILL.md +68 -68
  98. package/skills/communication/comm-writing/LICENSE +21 -21
  99. package/skills/communication/comm-writing/SKILL.md +69 -69
  100. package/skills/craft/ai-engineering/LICENSE +21 -21
  101. package/skills/craft/ai-engineering/SKILL.md +828 -828
  102. package/skills/craft/app-builder-guide/LICENSE +21 -21
  103. package/skills/craft/app-builder-guide/SKILL.md +332 -332
  104. package/skills/craft/become-an-ai-engineer-26/CONTRIBUTING.md +46 -46
  105. package/skills/craft/become-an-ai-engineer-26/LICENSE +21 -21
  106. package/skills/craft/become-an-ai-engineer-26/README.md +270 -270
  107. package/skills/craft/become-an-ai-engineer-26/SKILL.md +667 -667
  108. package/skills/craft/become-an-ai-engineer-26/community/BUILDS.md +13 -13
  109. package/skills/craft/become-an-ai-engineer-26/community/DISCUSSIONS.md +8 -8
  110. package/skills/craft/become-an-ai-engineer-26/phases/phase-0-mental-models/README.md +14 -14
  111. package/skills/craft/become-an-ai-engineer-26/phases/phase-0-mental-models/project/TEMPLATE.md +33 -33
  112. package/skills/craft/become-an-ai-engineer-26/phases/phase-1-first-agent/README.md +25 -25
  113. package/skills/craft/become-an-ai-engineer-26/phases/phase-1-first-agent/code/raw_loop.py +126 -126
  114. package/skills/craft/become-an-ai-engineer-26/phases/phase-2-architecture/README.md +17 -17
  115. package/skills/craft/become-an-ai-engineer-26/phases/phase-3-harness/README.md +17 -17
  116. package/skills/craft/become-an-ai-engineer-26/phases/phase-4-evals/README.md +21 -21
  117. package/skills/craft/become-an-ai-engineer-26/phases/phase-4-evals/code/.github/workflows/eval.yml +40 -40
  118. package/skills/craft/become-an-ai-engineer-26/phases/phase-5-production/README.md +16 -16
  119. package/skills/craft/become-an-ai-engineer-26/projects/1-mobile-app-slm/README.md +11 -11
  120. package/skills/craft/become-an-ai-engineer-26/projects/2-self-improving-coder/README.md +11 -11
  121. package/skills/craft/become-an-ai-engineer-26/projects/3-video-editor-agent/README.md +11 -11
  122. package/skills/craft/become-an-ai-engineer-26/projects/4-personal-life-os/README.md +12 -12
  123. package/skills/craft/become-an-ai-engineer-26/projects/5-enterprise-workflow/README.md +12 -12
  124. package/skills/craft/become-an-ai-engineer-26/references/benchmark-numbers.md +41 -41
  125. package/skills/craft/become-an-ai-engineer-26/references/mhc-stable-training.md +73 -73
  126. package/skills/craft/become-an-ai-engineer-26/references/stack-decisions.md +37 -37
  127. package/skills/craft/become-an-ai-engineer-26/references/yarn-context-extension.md +123 -123
  128. package/skills/craft/codex-result-handling/LICENSE +21 -21
  129. package/skills/craft/codex-result-handling/SKILL.md +26 -26
  130. package/skills/craft/debug-and-build-methodology/LICENSE +21 -21
  131. package/skills/craft/debug-and-build-methodology/SKILL.md +432 -432
  132. package/skills/craft/design/LICENSE +21 -21
  133. package/skills/craft/design/SKILL.md +274 -274
  134. package/skills/craft/dev/LICENSE +21 -21
  135. package/skills/craft/dev/SKILL.md +12 -12
  136. package/skills/craft/dev/release.md +85 -85
  137. package/skills/craft/dev/roll.md +50 -50
  138. package/skills/craft/doc-coauthoring/LICENSE +21 -21
  139. package/skills/craft/doc-coauthoring/SKILL.md +397 -397
  140. package/skills/craft/focus/LICENSE +21 -21
  141. package/skills/craft/focus/SKILL.md +432 -432
  142. package/skills/craft/focus/UPSTREAM_README.md +233 -233
  143. package/skills/craft/gh/LICENSE +21 -21
  144. package/skills/craft/gh/SKILL.md +84 -84
  145. package/skills/craft/gh-skill/LICENSE +21 -21
  146. package/skills/craft/gh-skill/SKILL.md +121 -121
  147. package/skills/craft/godmode/LICENSE +21 -21
  148. package/skills/craft/godmode/SKILL.md +87 -87
  149. package/skills/craft/godmode/references/android-launch.md +680 -680
  150. package/skills/craft/godmode/references/data-gcp.md +1038 -1038
  151. package/skills/craft/godmode/references/expo-eas.md +816 -816
  152. package/skills/craft/godmode/references/ios-launch.md +734 -734
  153. package/skills/craft/google-ai-latest/LICENSE +21 -21
  154. package/skills/craft/google-ai-latest/SKILL.md +682 -682
  155. package/skills/craft/gpt-5-4-prompting/LICENSE +21 -21
  156. package/skills/craft/gpt-5-4-prompting/SKILL.md +63 -63
  157. package/skills/craft/gpt-5-4-prompting/references/codex-prompt-antipatterns.md +101 -101
  158. package/skills/craft/gpt-5-4-prompting/references/codex-prompt-recipes.md +150 -150
  159. package/skills/craft/gpt-5-4-prompting/references/prompt-blocks.md +172 -172
  160. package/skills/craft/grill-me/LICENSE +21 -21
  161. package/skills/craft/grill-me/SKILL.md +13 -13
  162. package/skills/craft/idea-to-deploy/LICENSE +21 -21
  163. package/skills/craft/idea-to-deploy/SKILL.md +292 -292
  164. package/skills/craft/idea-to-deploy/references/auth-playbook.md +195 -195
  165. package/skills/craft/idea-to-deploy/references/gcp-deployment.md +268 -268
  166. package/skills/craft/idea-to-deploy/references/stack-selection.md +117 -117
  167. package/skills/craft/image-generation-engineer/LICENSE +21 -21
  168. package/skills/craft/image-generation-engineer/SKILL.md +183 -183
  169. package/skills/craft/image-generation-engineer/references/architectures.md +260 -260
  170. package/skills/craft/image-generation-engineer/references/foundations.md +107 -107
  171. package/skills/craft/image-generation-engineer/references/inference-and-serving.md +253 -253
  172. package/skills/craft/image-generation-engineer/references/training.md +149 -149
  173. package/skills/craft/marketing/LICENSE +21 -21
  174. package/skills/craft/marketing/SKILL.md +1954 -1954
  175. package/skills/craft/master-architect/LICENSE +21 -21
  176. package/skills/craft/master-architect/SKILL.md +361 -361
  177. package/skills/craft/master-architect/references/ai-ml.md +317 -317
  178. package/skills/craft/master-architect/references/architecture.md +268 -268
  179. package/skills/craft/master-architect/references/auth-playbook.md +195 -195
  180. package/skills/craft/master-architect/references/cloud.md +323 -323
  181. package/skills/craft/master-architect/references/cyber.md +839 -839
  182. package/skills/craft/master-architect/references/data-eng.md +366 -366
  183. package/skills/craft/master-architect/references/devops.md +550 -550
  184. package/skills/craft/master-architect/references/gcp-deployment.md +268 -268
  185. package/skills/craft/master-architect/references/languages.md +748 -748
  186. package/skills/craft/master-architect/references/legacy.md +240 -240
  187. package/skills/craft/master-architect/references/mobile.md +447 -447
  188. package/skills/craft/master-architect/references/patterns.md +451 -451
  189. package/skills/craft/master-architect/references/saas-patterns.md +379 -379
  190. package/skills/craft/master-architect/references/sdlc.md +349 -349
  191. package/skills/craft/master-architect/references/stack-selection.md +117 -117
  192. package/skills/craft/oriro-ui-2026/LICENSE +21 -21
  193. package/skills/craft/oriro-ui-2026/SKILL.md +329 -329
  194. package/skills/craft/playwright-cli/LICENSE +21 -21
  195. package/skills/craft/playwright-cli/SKILL.md +393 -393
  196. package/skills/craft/playwright-cli/references/element-attributes.md +23 -23
  197. package/skills/craft/playwright-cli/references/playwright-tests.md +39 -39
  198. package/skills/craft/playwright-cli/references/request-mocking.md +87 -87
  199. package/skills/craft/playwright-cli/references/running-code.md +240 -240
  200. package/skills/craft/playwright-cli/references/session-management.md +226 -226
  201. package/skills/craft/playwright-cli/references/spec-driven-testing.md +312 -312
  202. package/skills/craft/playwright-cli/references/storage-state.md +275 -275
  203. package/skills/craft/playwright-cli/references/test-generation.md +134 -134
  204. package/skills/craft/playwright-cli/references/tracing.md +142 -142
  205. package/skills/craft/playwright-cli/references/video-recording.md +150 -150
  206. package/skills/craft/remotion-best-practices/LICENSE +21 -21
  207. package/skills/craft/remotion-best-practices/SKILL.md +345 -345
  208. package/skills/craft/remotion-best-practices/rules/3d.md +86 -86
  209. package/skills/craft/remotion-best-practices/rules/assets/charts-bar-chart.tsx +165 -165
  210. package/skills/craft/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +89 -89
  211. package/skills/craft/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +101 -101
  212. package/skills/craft/remotion-best-practices/rules/audio-visualization.md +195 -195
  213. package/skills/craft/remotion-best-practices/rules/audio.md +167 -167
  214. package/skills/craft/remotion-best-practices/rules/calculate-metadata.md +118 -118
  215. package/skills/craft/remotion-best-practices/rules/compositions.md +132 -132
  216. package/skills/craft/remotion-best-practices/rules/display-captions.md +176 -176
  217. package/skills/craft/remotion-best-practices/rules/ffmpeg.md +34 -34
  218. package/skills/craft/remotion-best-practices/rules/get-audio-duration.md +58 -58
  219. package/skills/craft/remotion-best-practices/rules/get-video-dimensions.md +68 -68
  220. package/skills/craft/remotion-best-practices/rules/get-video-duration.md +60 -60
  221. package/skills/craft/remotion-best-practices/rules/gifs.md +135 -135
  222. package/skills/craft/remotion-best-practices/rules/google-fonts.md +72 -72
  223. package/skills/craft/remotion-best-practices/rules/html-in-canvas.md +122 -122
  224. package/skills/craft/remotion-best-practices/rules/images.md +67 -67
  225. package/skills/craft/remotion-best-practices/rules/import-srt-captions.md +69 -69
  226. package/skills/craft/remotion-best-practices/rules/light-leaks.md +73 -73
  227. package/skills/craft/remotion-best-practices/rules/local-fonts.md +65 -65
  228. package/skills/craft/remotion-best-practices/rules/lottie.md +67 -67
  229. package/skills/craft/remotion-best-practices/rules/maplibre.md +441 -441
  230. package/skills/craft/remotion-best-practices/rules/measuring-dom-nodes.md +34 -34
  231. package/skills/craft/remotion-best-practices/rules/measuring-text.md +140 -140
  232. package/skills/craft/remotion-best-practices/rules/parameters.md +109 -109
  233. package/skills/craft/remotion-best-practices/rules/sequencing.md +144 -144
  234. package/skills/craft/remotion-best-practices/rules/sfx.md +30 -30
  235. package/skills/craft/remotion-best-practices/rules/silence-detection.md +73 -73
  236. package/skills/craft/remotion-best-practices/rules/subtitles.md +36 -36
  237. package/skills/craft/remotion-best-practices/rules/tailwind.md +11 -11
  238. package/skills/craft/remotion-best-practices/rules/text-animations.md +20 -20
  239. package/skills/craft/remotion-best-practices/rules/timing.md +130 -130
  240. package/skills/craft/remotion-best-practices/rules/transcribe-captions.md +70 -70
  241. package/skills/craft/remotion-best-practices/rules/transitions.md +193 -193
  242. package/skills/craft/remotion-best-practices/rules/transparent-videos.md +102 -102
  243. package/skills/craft/remotion-best-practices/rules/trimming.md +51 -51
  244. package/skills/craft/remotion-best-practices/rules/videos.md +169 -169
  245. package/skills/craft/remotion-best-practices/rules/voiceover.md +94 -94
  246. package/skills/craft/supabase-postgres-best-practices/CHANGELOG.md +25 -25
  247. package/skills/craft/supabase-postgres-best-practices/LICENSE +21 -21
  248. package/skills/craft/supabase-postgres-best-practices/SKILL.md +69 -69
  249. package/skills/craft/supabase-postgres-best-practices/references/_contributing.md +166 -166
  250. package/skills/craft/supabase-postgres-best-practices/references/_sections.md +47 -47
  251. package/skills/craft/supabase-postgres-best-practices/references/_template.md +34 -34
  252. package/skills/craft/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -55
  253. package/skills/craft/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -49
  254. package/skills/craft/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -46
  255. package/skills/craft/supabase-postgres-best-practices/references/conn-limits.md +44 -44
  256. package/skills/craft/supabase-postgres-best-practices/references/conn-pooling.md +41 -41
  257. package/skills/craft/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -46
  258. package/skills/craft/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -54
  259. package/skills/craft/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -53
  260. package/skills/craft/supabase-postgres-best-practices/references/data-pagination.md +50 -50
  261. package/skills/craft/supabase-postgres-best-practices/references/data-upsert.md +50 -50
  262. package/skills/craft/supabase-postgres-best-practices/references/lock-advisory.md +56 -56
  263. package/skills/craft/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -68
  264. package/skills/craft/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -50
  265. package/skills/craft/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -54
  266. package/skills/craft/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -45
  267. package/skills/craft/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -55
  268. package/skills/craft/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -55
  269. package/skills/craft/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -44
  270. package/skills/craft/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -40
  271. package/skills/craft/supabase-postgres-best-practices/references/query-index-types.md +48 -48
  272. package/skills/craft/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -43
  273. package/skills/craft/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -45
  274. package/skills/craft/supabase-postgres-best-practices/references/schema-constraints.md +80 -80
  275. package/skills/craft/supabase-postgres-best-practices/references/schema-data-types.md +46 -46
  276. package/skills/craft/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -59
  277. package/skills/craft/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -55
  278. package/skills/craft/supabase-postgres-best-practices/references/schema-partitioning.md +55 -55
  279. package/skills/craft/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -61
  280. package/skills/craft/supabase-postgres-best-practices/references/security-privileges.md +54 -54
  281. package/skills/craft/supabase-postgres-best-practices/references/security-rls-basics.md +50 -50
  282. package/skills/craft/supabase-postgres-best-practices/references/security-rls-performance.md +63 -63
  283. package/skills/craft/uipm-banner-design/LICENSE +21 -21
  284. package/skills/craft/uipm-banner-design/SKILL.md +201 -201
  285. package/skills/craft/uipm-banner-design/references/banner-sizes-and-styles.md +129 -129
  286. package/skills/craft/uipm-brand/LICENSE +21 -21
  287. package/skills/craft/uipm-brand/SKILL.md +104 -104
  288. package/skills/craft/uipm-brand/references/approval-checklist.md +184 -184
  289. package/skills/craft/uipm-brand/references/asset-organization.md +167 -167
  290. package/skills/craft/uipm-brand/references/brand-guideline-template.md +161 -161
  291. package/skills/craft/uipm-brand/references/color-palette-management.md +203 -203
  292. package/skills/craft/uipm-brand/references/consistency-checklist.md +105 -105
  293. package/skills/craft/uipm-brand/references/logo-usage-rules.md +204 -204
  294. package/skills/craft/uipm-brand/references/messaging-framework.md +91 -91
  295. package/skills/craft/uipm-brand/references/typography-specifications.md +265 -265
  296. package/skills/craft/uipm-brand/references/update.md +128 -128
  297. package/skills/craft/uipm-brand/references/visual-identity.md +109 -109
  298. package/skills/craft/uipm-brand/references/voice-framework.md +99 -99
  299. package/skills/craft/uipm-brand/scripts/extract-colors.cjs +333 -333
  300. package/skills/craft/uipm-brand/scripts/inject-brand-context.cjs +324 -324
  301. package/skills/craft/uipm-brand/scripts/sync-brand-to-tokens.cjs +269 -269
  302. package/skills/craft/uipm-brand/scripts/validate-asset.cjs +361 -361
  303. package/skills/craft/uipm-brand/templates/brand-guidelines-starter.md +280 -280
  304. package/skills/craft/uipm-design/LICENSE +21 -21
  305. package/skills/craft/uipm-design/SKILL.md +305 -305
  306. package/skills/craft/uipm-design/data/cip/deliverables.csv +50 -50
  307. package/skills/craft/uipm-design/data/cip/industries.csv +20 -20
  308. package/skills/craft/uipm-design/data/cip/mockup-contexts.csv +20 -20
  309. package/skills/craft/uipm-design/data/cip/styles.csv +20 -20
  310. package/skills/craft/uipm-design/data/icon/styles.csv +16 -16
  311. package/skills/craft/uipm-design/data/logo/colors.csv +56 -56
  312. package/skills/craft/uipm-design/data/logo/industries.csv +56 -56
  313. package/skills/craft/uipm-design/data/logo/styles.csv +56 -56
  314. package/skills/craft/uipm-design/references/banner-sizes-and-styles.md +129 -129
  315. package/skills/craft/uipm-design/references/cip-deliverable-guide.md +111 -111
  316. package/skills/craft/uipm-design/references/cip-design.md +121 -121
  317. package/skills/craft/uipm-design/references/cip-prompt-engineering.md +94 -94
  318. package/skills/craft/uipm-design/references/cip-style-guide.md +76 -76
  319. package/skills/craft/uipm-design/references/design-routing.md +226 -226
  320. package/skills/craft/uipm-design/references/icon-design.md +122 -122
  321. package/skills/craft/uipm-design/references/logo-color-psychology.md +113 -113
  322. package/skills/craft/uipm-design/references/logo-design.md +92 -92
  323. package/skills/craft/uipm-design/references/logo-prompt-engineering.md +176 -176
  324. package/skills/craft/uipm-design/references/logo-style-guide.md +129 -129
  325. package/skills/craft/uipm-design/references/slides-copywriting-formulas.md +92 -92
  326. package/skills/craft/uipm-design/references/slides-create.md +5 -5
  327. package/skills/craft/uipm-design/references/slides-html-template.md +374 -374
  328. package/skills/craft/uipm-design/references/slides-layout-patterns.md +155 -155
  329. package/skills/craft/uipm-design/references/slides-strategies.md +97 -97
  330. package/skills/craft/uipm-design/references/slides.md +42 -42
  331. package/skills/craft/uipm-design/references/social-photos-design.md +353 -353
  332. package/skills/craft/uipm-design/scripts/cip/core.py +215 -215
  333. package/skills/craft/uipm-design/scripts/cip/generate.py +484 -484
  334. package/skills/craft/uipm-design/scripts/cip/render-html.py +424 -424
  335. package/skills/craft/uipm-design/scripts/cip/search.py +127 -127
  336. package/skills/craft/uipm-design/scripts/icon/generate.py +487 -487
  337. package/skills/craft/uipm-design/scripts/logo/core.py +175 -175
  338. package/skills/craft/uipm-design/scripts/logo/generate.py +362 -362
  339. package/skills/craft/uipm-design/scripts/logo/search.py +114 -114
  340. package/skills/craft/uipm-design-system/LICENSE +21 -21
  341. package/skills/craft/uipm-design-system/SKILL.md +255 -255
  342. package/skills/craft/uipm-design-system/data/slide-backgrounds.csv +11 -11
  343. package/skills/craft/uipm-design-system/data/slide-charts.csv +26 -26
  344. package/skills/craft/uipm-design-system/data/slide-color-logic.csv +14 -14
  345. package/skills/craft/uipm-design-system/data/slide-copy.csv +26 -26
  346. package/skills/craft/uipm-design-system/data/slide-layout-logic.csv +16 -16
  347. package/skills/craft/uipm-design-system/data/slide-layouts.csv +26 -26
  348. package/skills/craft/uipm-design-system/data/slide-strategies.csv +16 -16
  349. package/skills/craft/uipm-design-system/data/slide-typography.csv +15 -15
  350. package/skills/craft/uipm-design-system/references/component-specs.md +236 -236
  351. package/skills/craft/uipm-design-system/references/component-tokens.md +214 -214
  352. package/skills/craft/uipm-design-system/references/primitive-tokens.md +199 -199
  353. package/skills/craft/uipm-design-system/references/semantic-tokens.md +215 -215
  354. package/skills/craft/uipm-design-system/references/states-and-variants.md +243 -243
  355. package/skills/craft/uipm-design-system/references/tailwind-integration.md +257 -257
  356. package/skills/craft/uipm-design-system/references/token-architecture.md +226 -226
  357. package/skills/craft/uipm-design-system/scripts/embed-tokens.cjs +97 -97
  358. package/skills/craft/uipm-design-system/scripts/fetch-background.py +317 -317
  359. package/skills/craft/uipm-design-system/scripts/generate-slide.py +753 -753
  360. package/skills/craft/uipm-design-system/scripts/generate-tokens.cjs +213 -213
  361. package/skills/craft/uipm-design-system/scripts/html-token-validator.py +327 -327
  362. package/skills/craft/uipm-design-system/scripts/search-slides.py +218 -218
  363. package/skills/craft/uipm-design-system/scripts/slide-token-validator.py +35 -35
  364. package/skills/craft/uipm-design-system/scripts/slide_search_core.py +453 -453
  365. package/skills/craft/uipm-design-system/scripts/validate-tokens.cjs +254 -254
  366. package/skills/craft/uipm-design-system/templates/design-tokens-starter.json +143 -143
  367. package/skills/craft/uipm-slides/LICENSE +21 -21
  368. package/skills/craft/uipm-slides/SKILL.md +45 -45
  369. package/skills/craft/uipm-slides/references/copywriting-formulas.md +92 -92
  370. package/skills/craft/uipm-slides/references/create.md +5 -5
  371. package/skills/craft/uipm-slides/references/html-template.md +374 -374
  372. package/skills/craft/uipm-slides/references/layout-patterns.md +155 -155
  373. package/skills/craft/uipm-slides/references/slide-strategies.md +97 -97
  374. package/skills/craft/uipm-ui-ux-pro-max/LICENSE +21 -21
  375. package/skills/craft/uipm-ui-ux-pro-max/SKILL.md +678 -678
  376. package/skills/craft/uipm-ui-ux-pro-max/data/_sync_all.py +414 -414
  377. package/skills/craft/uipm-ui-ux-pro-max/data/app-interface.csv +30 -30
  378. package/skills/craft/uipm-ui-ux-pro-max/data/charts.csv +26 -26
  379. package/skills/craft/uipm-ui-ux-pro-max/data/colors.csv +161 -161
  380. package/skills/craft/uipm-ui-ux-pro-max/data/design.csv +1775 -1775
  381. package/skills/craft/uipm-ui-ux-pro-max/data/draft.csv +1778 -1778
  382. package/skills/craft/uipm-ui-ux-pro-max/data/google-fonts.csv +1924 -1924
  383. package/skills/craft/uipm-ui-ux-pro-max/data/icons.csv +105 -105
  384. package/skills/craft/uipm-ui-ux-pro-max/data/landing.csv +35 -35
  385. package/skills/craft/uipm-ui-ux-pro-max/data/products.csv +162 -162
  386. package/skills/craft/uipm-ui-ux-pro-max/data/react-performance.csv +45 -45
  387. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/angular.csv +51 -51
  388. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/astro.csv +54 -54
  389. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/flutter.csv +53 -53
  390. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -56
  391. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -53
  392. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/laravel.csv +51 -51
  393. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/nextjs.csv +53 -53
  394. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -51
  395. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -59
  396. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/react-native.csv +52 -52
  397. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/react.csv +54 -54
  398. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/shadcn.csv +61 -61
  399. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/svelte.csv +54 -54
  400. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/swiftui.csv +51 -51
  401. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/threejs.csv +54 -54
  402. package/skills/craft/uipm-ui-ux-pro-max/data/stacks/vue.csv +50 -50
  403. package/skills/craft/uipm-ui-ux-pro-max/data/styles.csv +85 -85
  404. package/skills/craft/uipm-ui-ux-pro-max/data/typography.csv +74 -74
  405. package/skills/craft/uipm-ui-ux-pro-max/data/ui-reasoning.csv +162 -162
  406. package/skills/craft/uipm-ui-ux-pro-max/data/ux-guidelines.csv +99 -99
  407. package/skills/craft/uipm-ui-ux-pro-max/scripts/core.py +262 -262
  408. package/skills/craft/uipm-ui-ux-pro-max/scripts/design_system.py +1148 -1148
  409. package/skills/craft/uipm-ui-ux-pro-max/scripts/search.py +114 -114
  410. package/skills/craft/uipm-ui-ux-pro-max/templates/base/quick-reference.md +297 -297
  411. package/skills/craft/uipm-ui-ux-pro-max/templates/base/skill-content.md +375 -375
  412. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/agent.json +21 -21
  413. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/augment.json +18 -18
  414. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/claude.json +21 -21
  415. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/codebuddy.json +21 -21
  416. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/codex.json +21 -21
  417. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/continue.json +21 -21
  418. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/copilot.json +21 -21
  419. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/cursor.json +21 -21
  420. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/droid.json +21 -21
  421. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/gemini.json +21 -21
  422. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/kilocode.json +21 -21
  423. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/kiro.json +21 -21
  424. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/opencode.json +21 -21
  425. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/qoder.json +21 -21
  426. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/roocode.json +21 -21
  427. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/trae.json +21 -21
  428. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/warp.json +18 -18
  429. package/skills/craft/uipm-ui-ux-pro-max/templates/platforms/windsurf.json +21 -21
  430. package/skills/craft/vercel-optimize/AGENTS.md +48 -48
  431. package/skills/craft/vercel-optimize/CONTRIBUTING.md +41 -41
  432. package/skills/craft/vercel-optimize/LICENSE +21 -21
  433. package/skills/craft/vercel-optimize/README.md +91 -91
  434. package/skills/craft/vercel-optimize/SKILL.md +325 -325
  435. package/skills/craft/vercel-optimize/lib/auth-route.mjs +23 -23
  436. package/skills/craft/vercel-optimize/lib/budget-summary.mjs +208 -208
  437. package/skills/craft/vercel-optimize/lib/citations.mjs +147 -147
  438. package/skills/craft/vercel-optimize/lib/cost-coverage.mjs +162 -162
  439. package/skills/craft/vercel-optimize/lib/dedup-recs.mjs +340 -340
  440. package/skills/craft/vercel-optimize/lib/deep-dive.mjs +371 -371
  441. package/skills/craft/vercel-optimize/lib/display-labels.mjs +219 -219
  442. package/skills/craft/vercel-optimize/lib/extract-claims.mjs +640 -640
  443. package/skills/craft/vercel-optimize/lib/framework-support.mjs +69 -69
  444. package/skills/craft/vercel-optimize/lib/gates/build-minutes-fanout.mjs +73 -73
  445. package/skills/craft/vercel-optimize/lib/gates/cold-start.mjs +72 -72
  446. package/skills/craft/vercel-optimize/lib/gates/contract.mjs +82 -82
  447. package/skills/craft/vercel-optimize/lib/gates/cwv-poor.mjs +95 -95
  448. package/skills/craft/vercel-optimize/lib/gates/external-api-slow.mjs +60 -60
  449. package/skills/craft/vercel-optimize/lib/gates/hard-gates.mjs +70 -70
  450. package/skills/craft/vercel-optimize/lib/gates/index.mjs +45 -45
  451. package/skills/craft/vercel-optimize/lib/gates/isr-overrevalidation.mjs +62 -62
  452. package/skills/craft/vercel-optimize/lib/gates/middleware-heavy.mjs +53 -53
  453. package/skills/craft/vercel-optimize/lib/gates/observability-events-attribution.mjs +58 -58
  454. package/skills/craft/vercel-optimize/lib/gates/platform-bot-protection.mjs +123 -123
  455. package/skills/craft/vercel-optimize/lib/gates/platform-fluid-compute.mjs +94 -94
  456. package/skills/craft/vercel-optimize/lib/gates/region-misconfig.mjs +71 -71
  457. package/skills/craft/vercel-optimize/lib/gates/route-errors.mjs +95 -95
  458. package/skills/craft/vercel-optimize/lib/gates/scanner-driven.mjs +150 -150
  459. package/skills/craft/vercel-optimize/lib/gates/select-candidates.mjs +137 -137
  460. package/skills/craft/vercel-optimize/lib/gates/slow-route.mjs +97 -97
  461. package/skills/craft/vercel-optimize/lib/gates/types.d.ts +38 -38
  462. package/skills/craft/vercel-optimize/lib/gates/uncached-route.mjs +103 -103
  463. package/skills/craft/vercel-optimize/lib/gates/usage-spike-triage.mjs +122 -122
  464. package/skills/craft/vercel-optimize/lib/grade-recommendation.mjs +170 -170
  465. package/skills/craft/vercel-optimize/lib/impact-label.mjs +128 -128
  466. package/skills/craft/vercel-optimize/lib/impact-magnitude.mjs +66 -66
  467. package/skills/craft/vercel-optimize/lib/investigation-brief.mjs +751 -751
  468. package/skills/craft/vercel-optimize/lib/observation-safety.mjs +217 -217
  469. package/skills/craft/vercel-optimize/lib/project-facts.mjs +101 -101
  470. package/skills/craft/vercel-optimize/lib/queries.mjs +333 -333
  471. package/skills/craft/vercel-optimize/lib/reconcile-candidates.mjs +388 -388
  472. package/skills/craft/vercel-optimize/lib/render-report.mjs +1065 -1065
  473. package/skills/craft/vercel-optimize/lib/repo-root.mjs +97 -97
  474. package/skills/craft/vercel-optimize/lib/route-normalize.mjs +224 -224
  475. package/skills/craft/vercel-optimize/lib/sanitizers/bot-protection-certainty.mjs +56 -56
  476. package/skills/craft/vercel-optimize/lib/sanitizers/cache-tag-invalidation-certainty.mjs +33 -33
  477. package/skills/craft/vercel-optimize/lib/sanitizers/count-correct.mjs +53 -53
  478. package/skills/craft/vercel-optimize/lib/sanitizers/function-duration-invocations.mjs +32 -32
  479. package/skills/craft/vercel-optimize/lib/sanitizers/index.mjs +87 -87
  480. package/skills/craft/vercel-optimize/lib/sanitizers/middleware-conflict.mjs +37 -37
  481. package/skills/craft/vercel-optimize/lib/sanitizers/missing-citation.mjs +16 -16
  482. package/skills/craft/vercel-optimize/lib/sanitizers/pre-release.mjs +75 -75
  483. package/skills/craft/vercel-optimize/lib/sanitizers/rate-limit.mjs +73 -73
  484. package/skills/craft/vercel-optimize/lib/sanitizers/rendering-mode-mislabel.mjs +42 -42
  485. package/skills/craft/vercel-optimize/lib/sanitizers/undeclared-dep.mjs +110 -110
  486. package/skills/craft/vercel-optimize/lib/sanitizers/vercel-directive-strip.mjs +37 -37
  487. package/skills/craft/vercel-optimize/lib/sanitizers/window-units.mjs +26 -26
  488. package/skills/craft/vercel-optimize/lib/scanners/cache-components-suspense-dedupe.mjs +114 -114
  489. package/skills/craft/vercel-optimize/lib/scanners/edge-heavy-import.mjs +102 -102
  490. package/skills/craft/vercel-optimize/lib/scanners/force-dynamic.mjs +39 -39
  491. package/skills/craft/vercel-optimize/lib/scanners/headers-in-page.mjs +43 -43
  492. package/skills/craft/vercel-optimize/lib/scanners/index.mjs +35 -35
  493. package/skills/craft/vercel-optimize/lib/scanners/large-static-asset.mjs +93 -93
  494. package/skills/craft/vercel-optimize/lib/scanners/max-age-without-s-maxage.mjs +47 -47
  495. package/skills/craft/vercel-optimize/lib/scanners/middleware-broad-matcher.mjs +53 -53
  496. package/skills/craft/vercel-optimize/lib/scanners/missing-cache-headers.mjs +97 -97
  497. package/skills/craft/vercel-optimize/lib/scanners/prisma-include-tree.mjs +39 -39
  498. package/skills/craft/vercel-optimize/lib/scanners/region-pin-in-config.mjs +89 -89
  499. package/skills/craft/vercel-optimize/lib/scanners/source-maps-production.mjs +33 -33
  500. package/skills/craft/vercel-optimize/lib/scanners/sveltekit-prerender-missing.mjs +47 -47
  501. package/skills/craft/vercel-optimize/lib/scanners/turbo-force-bypass.mjs +136 -136
  502. package/skills/craft/vercel-optimize/lib/scanners/unoptimized-image.mjs +127 -127
  503. package/skills/craft/vercel-optimize/lib/scanners/use-cache-date-stamp.mjs +112 -112
  504. package/skills/craft/vercel-optimize/lib/support-topics.mjs +365 -365
  505. package/skills/craft/vercel-optimize/lib/throttle.mjs +280 -280
  506. package/skills/craft/vercel-optimize/lib/util.mjs +17 -17
  507. package/skills/craft/vercel-optimize/lib/vercel.mjs +855 -855
  508. package/skills/craft/vercel-optimize/lib/verify-claim.mjs +1843 -1843
  509. package/skills/craft/vercel-optimize/lib/workspace-resolver.mjs +552 -552
  510. package/skills/craft/vercel-optimize/metadata.json +14 -14
  511. package/skills/craft/vercel-optimize/references/candidates.md +176 -176
  512. package/skills/craft/vercel-optimize/references/data-collection.md +224 -224
  513. package/skills/craft/vercel-optimize/references/docs-library.json +683 -683
  514. package/skills/craft/vercel-optimize/references/doctrine.md +108 -108
  515. package/skills/craft/vercel-optimize/references/observability-plus.md +109 -109
  516. package/skills/craft/vercel-optimize/references/playbooks/README.md +57 -57
  517. package/skills/craft/vercel-optimize/references/playbooks/ai-application.md +32 -32
  518. package/skills/craft/vercel-optimize/references/playbooks/api-service.md +30 -30
  519. package/skills/craft/vercel-optimize/references/playbooks/content-site.md +30 -30
  520. package/skills/craft/vercel-optimize/references/playbooks/ecommerce.md +30 -30
  521. package/skills/craft/vercel-optimize/references/playbooks/marketing.md +30 -30
  522. package/skills/craft/vercel-optimize/references/playbooks/saas.md +31 -31
  523. package/skills/craft/vercel-optimize/references/playbooks/sveltekit.md +75 -75
  524. package/skills/craft/vercel-optimize/references/recommendations.md +214 -214
  525. package/skills/craft/vercel-optimize/references/scanner-patterns.md +266 -266
  526. package/skills/craft/vercel-optimize/references/scoring.md +208 -208
  527. package/skills/craft/vercel-optimize/references/support-topics/README.md +50 -50
  528. package/skills/craft/vercel-optimize/references/support-topics/astro-edge-middleware-scope.md +30 -30
  529. package/skills/craft/vercel-optimize/references/support-topics/astro-output-mode-and-isr.md +31 -31
  530. package/skills/craft/vercel-optimize/references/support-topics/auth-preserving-parallelization.md +30 -30
  531. package/skills/craft/vercel-optimize/references/support-topics/bot-protection-product-guardrails.md +32 -32
  532. package/skills/craft/vercel-optimize/references/support-topics/build-minutes-monorepo-fanout.md +32 -32
  533. package/skills/craft/vercel-optimize/references/support-topics/cache-components-static-shell-boundaries.md +31 -31
  534. package/skills/craft/vercel-optimize/references/support-topics/cache-components-suspense-dedupe-pitfall.md +32 -32
  535. package/skills/craft/vercel-optimize/references/support-topics/cdn-cache-auth-safety.md +31 -31
  536. package/skills/craft/vercel-optimize/references/support-topics/cold-start-initialization-bundle.md +31 -31
  537. package/skills/craft/vercel-optimize/references/support-topics/core-web-vitals-client-bottlenecks.md +33 -33
  538. package/skills/craft/vercel-optimize/references/support-topics/database-egress-pooling-region.md +32 -32
  539. package/skills/craft/vercel-optimize/references/support-topics/dynamic-rendering-traps.md +31 -31
  540. package/skills/craft/vercel-optimize/references/support-topics/external-api-critical-path-platform.md +31 -31
  541. package/skills/craft/vercel-optimize/references/support-topics/external-api-critical-path.md +31 -31
  542. package/skills/craft/vercel-optimize/references/support-topics/fast-data-transfer-payloads.md +26 -26
  543. package/skills/craft/vercel-optimize/references/support-topics/fluid-compute-caveats.md +26 -26
  544. package/skills/craft/vercel-optimize/references/support-topics/function-duration-io-and-after.md +31 -31
  545. package/skills/craft/vercel-optimize/references/support-topics/function-invocation-reduction.md +31 -31
  546. package/skills/craft/vercel-optimize/references/support-topics/function-region-misconfiguration-ttfb.md +31 -31
  547. package/skills/craft/vercel-optimize/references/support-topics/image-optimization-cost-control.md +31 -31
  548. package/skills/craft/vercel-optimize/references/support-topics/isr-revalidation-static-generation.md +31 -31
  549. package/skills/craft/vercel-optimize/references/support-topics/middleware-proxy-edge-cost.md +30 -30
  550. package/skills/craft/vercel-optimize/references/support-topics/next-fetch-revalidate-floor.md +30 -30
  551. package/skills/craft/vercel-optimize/references/support-topics/next-font-cls-self-hosting.md +31 -31
  552. package/skills/craft/vercel-optimize/references/support-topics/next-heavy-ui-lazy-load-boundaries.md +28 -28
  553. package/skills/craft/vercel-optimize/references/support-topics/next-image-lcp-preload-sizes.md +31 -31
  554. package/skills/craft/vercel-optimize/references/support-topics/next-route-handler-get-cache-defaults.md +30 -30
  555. package/skills/craft/vercel-optimize/references/support-topics/next-script-third-party-strategy.md +31 -31
  556. package/skills/craft/vercel-optimize/references/support-topics/nextjs-version-cache-semantics.md +31 -31
  557. package/skills/craft/vercel-optimize/references/support-topics/not-found-catchall-request-waste.md +33 -33
  558. package/skills/craft/vercel-optimize/references/support-topics/nuxt-route-rules-cache-isr.md +31 -31
  559. package/skills/craft/vercel-optimize/references/support-topics/observability-events-cost-attribution.md +27 -27
  560. package/skills/craft/vercel-optimize/references/support-topics/post-response-work-waituntil.md +26 -26
  561. package/skills/craft/vercel-optimize/references/support-topics/route-error-durable-offload.md +33 -33
  562. package/skills/craft/vercel-optimize/references/support-topics/route-error-runtime-limits.md +31 -31
  563. package/skills/craft/vercel-optimize/references/support-topics/runtime-cache-reusable-data.md +30 -30
  564. package/skills/craft/vercel-optimize/references/support-topics/sveltekit-isr-prerender-safety.md +31 -31
  565. package/skills/craft/vercel-optimize/references/support-topics/sveltekit-split-cold-start-tradeoff.md +30 -30
  566. package/skills/craft/vercel-optimize/references/support-topics/usage-spike-triage.md +31 -31
  567. package/skills/craft/vercel-optimize/references/support-topics/use-cache-date-stamp-isr-write-amplifier.md +31 -31
  568. package/skills/craft/vercel-optimize/references/support-topics/use-cache-remote-shared-origin-data.md +30 -30
  569. package/skills/craft/vercel-optimize/references/support-topics/workflow-resumable-stream-routes.md +32 -32
  570. package/skills/craft/vercel-optimize/references/verification.md +102 -102
  571. package/skills/craft/vercel-optimize/references/voice.md +76 -76
  572. package/skills/craft/vercel-optimize/scripts/budget-summary.mjs +58 -58
  573. package/skills/craft/vercel-optimize/scripts/build-docs.mjs +76 -76
  574. package/skills/craft/vercel-optimize/scripts/check-citations.mjs +91 -91
  575. package/skills/craft/vercel-optimize/scripts/check-docs-fresh.mjs +100 -100
  576. package/skills/craft/vercel-optimize/scripts/collect-signals.mjs +638 -638
  577. package/skills/craft/vercel-optimize/scripts/collect-sub-agent-outputs.mjs +306 -306
  578. package/skills/craft/vercel-optimize/scripts/deep-dive.mjs +358 -358
  579. package/skills/craft/vercel-optimize/scripts/gate-investigations.mjs +178 -178
  580. package/skills/craft/vercel-optimize/scripts/merge-signals.mjs +203 -203
  581. package/skills/craft/vercel-optimize/scripts/prepare-investigation-brief.mjs +249 -249
  582. package/skills/craft/vercel-optimize/scripts/reconcile-candidates.mjs +69 -69
  583. package/skills/craft/vercel-optimize/scripts/render-report.mjs +462 -462
  584. package/skills/craft/vercel-optimize/scripts/scan-codebase.mjs +361 -361
  585. package/skills/craft/vercel-optimize/scripts/verify-and-regen.mjs +379 -379
  586. package/skills/craft/vercel-optimize/scripts/verify-finding.mjs +21 -21
  587. package/skills/craft/web-design-guidelines/LICENSE +21 -21
  588. package/skills/craft/web-design-guidelines/SKILL.md +43 -43
  589. package/skills/craft/zero-to-live/LICENSE +21 -21
  590. package/skills/craft/zero-to-live/SKILL.md +422 -422
  591. package/skills/creative/creative-3d-modeling/LICENSE +21 -21
  592. package/skills/creative/creative-3d-modeling/SKILL.md +70 -70
  593. package/skills/creative/creative-architecture/LICENSE +21 -21
  594. package/skills/creative/creative-architecture/SKILL.md +94 -94
  595. package/skills/creative/creative-design-principles/LICENSE +21 -21
  596. package/skills/creative/creative-design-principles/SKILL.md +95 -95
  597. package/skills/creative/creative-fashion-advanced/LICENSE +21 -21
  598. package/skills/creative/creative-fashion-advanced/SKILL.md +68 -68
  599. package/skills/creative/creative-fashion-design/LICENSE +21 -21
  600. package/skills/creative/creative-fashion-design/SKILL.md +66 -66
  601. package/skills/creative/creative-game-design/LICENSE +21 -21
  602. package/skills/creative/creative-game-design/SKILL.md +77 -77
  603. package/skills/creative/creative-industrial-design/LICENSE +21 -21
  604. package/skills/creative/creative-industrial-design/SKILL.md +57 -57
  605. package/skills/creative/creative-interior-design/LICENSE +21 -21
  606. package/skills/creative/creative-interior-design/SKILL.md +59 -59
  607. package/skills/creative/creative-music-theory/LICENSE +21 -21
  608. package/skills/creative/creative-music-theory/SKILL.md +98 -98
  609. package/skills/creative/creative-photography/LICENSE +21 -21
  610. package/skills/creative/creative-photography/SKILL.md +87 -87
  611. package/skills/creative/creative-textile-science/LICENSE +21 -21
  612. package/skills/creative/creative-textile-science/SKILL.md +67 -67
  613. package/skills/creative/creative-ux/LICENSE +21 -21
  614. package/skills/creative/creative-ux/SKILL.md +81 -81
  615. package/skills/creative/creative-video/LICENSE +21 -21
  616. package/skills/creative/creative-video/SKILL.md +84 -84
  617. package/skills/creative/creative-writing-craft/LICENSE +21 -21
  618. package/skills/creative/creative-writing-craft/SKILL.md +91 -91
  619. package/skills/diagram-maker/SKILL.md +56 -56
  620. package/skills/diagram-maker/references/excalidraw-patterns.md +85 -85
  621. package/skills/diagram-maker/references/svg-template.md +112 -112
  622. package/skills/discord/SKILL.md +140 -140
  623. package/skills/education/edu-adult-learning/LICENSE +21 -21
  624. package/skills/education/edu-adult-learning/SKILL.md +81 -81
  625. package/skills/education/edu-africa-multilingual/LICENSE +21 -21
  626. package/skills/education/edu-africa-multilingual/SKILL.md +55 -55
  627. package/skills/education/edu-arabic/LICENSE +21 -21
  628. package/skills/education/edu-arabic/SKILL.md +60 -60
  629. package/skills/education/edu-australia-nz/LICENSE +21 -21
  630. package/skills/education/edu-australia-nz/SKILL.md +48 -48
  631. package/skills/education/edu-china-mandarin/LICENSE +21 -21
  632. package/skills/education/edu-china-mandarin/SKILL.md +58 -58
  633. package/skills/education/edu-critical-thinking/LICENSE +21 -21
  634. package/skills/education/edu-critical-thinking/SKILL.md +86 -86
  635. package/skills/education/edu-curriculum/LICENSE +21 -21
  636. package/skills/education/edu-curriculum/SKILL.md +87 -87
  637. package/skills/education/edu-ed-tech/LICENSE +21 -21
  638. package/skills/education/edu-ed-tech/SKILL.md +73 -73
  639. package/skills/education/edu-france/LICENSE +21 -21
  640. package/skills/education/edu-france/SKILL.md +42 -42
  641. package/skills/education/edu-germany/LICENSE +21 -21
  642. package/skills/education/edu-germany/SKILL.md +46 -46
  643. package/skills/education/edu-india-competitive/LICENSE +21 -21
  644. package/skills/education/edu-india-competitive/SKILL.md +159 -159
  645. package/skills/education/edu-india-east/LICENSE +21 -21
  646. package/skills/education/edu-india-east/SKILL.md +60 -60
  647. package/skills/education/edu-india-hindi/LICENSE +21 -21
  648. package/skills/education/edu-india-hindi/SKILL.md +107 -107
  649. package/skills/education/edu-india-south/LICENSE +21 -21
  650. package/skills/education/edu-india-south/SKILL.md +64 -64
  651. package/skills/education/edu-india-west/LICENSE +21 -21
  652. package/skills/education/edu-india-west/SKILL.md +68 -68
  653. package/skills/education/edu-indonesia-malay/LICENSE +21 -21
  654. package/skills/education/edu-indonesia-malay/SKILL.md +57 -57
  655. package/skills/education/edu-international-ib/LICENSE +21 -21
  656. package/skills/education/edu-international-ib/SKILL.md +61 -61
  657. package/skills/education/edu-japan/LICENSE +21 -21
  658. package/skills/education/edu-japan/SKILL.md +48 -48
  659. package/skills/education/edu-korea/LICENSE +21 -21
  660. package/skills/education/edu-korea/SKILL.md +48 -48
  661. package/skills/education/edu-learning-science/LICENSE +21 -21
  662. package/skills/education/edu-learning-science/SKILL.md +76 -76
  663. package/skills/education/edu-portuguese-brazil/LICENSE +21 -21
  664. package/skills/education/edu-portuguese-brazil/SKILL.md +51 -51
  665. package/skills/education/edu-russia/LICENSE +21 -21
  666. package/skills/education/edu-russia/SKILL.md +50 -50
  667. package/skills/education/edu-spain-latam/LICENSE +21 -21
  668. package/skills/education/edu-spain-latam/SKILL.md +55 -55
  669. package/skills/education/edu-special/LICENSE +21 -21
  670. package/skills/education/edu-special/SKILL.md +76 -76
  671. package/skills/education/edu-thailand/LICENSE +21 -21
  672. package/skills/education/edu-thailand/SKILL.md +55 -55
  673. package/skills/education/edu-turkey/LICENSE +21 -21
  674. package/skills/education/edu-turkey/SKILL.md +58 -58
  675. package/skills/education/edu-uk-gcse-alevel/LICENSE +21 -21
  676. package/skills/education/edu-uk-gcse-alevel/SKILL.md +51 -51
  677. package/skills/education/edu-usa-graduate/LICENSE +21 -21
  678. package/skills/education/edu-usa-graduate/SKILL.md +57 -57
  679. package/skills/education/edu-usa-sat-act/LICENSE +21 -21
  680. package/skills/education/edu-usa-sat-act/SKILL.md +55 -55
  681. package/skills/education/edu-vietnam/LICENSE +21 -21
  682. package/skills/education/edu-vietnam/SKILL.md +53 -53
  683. package/skills/eightctl/SKILL.md +54 -54
  684. package/skills/engineering/eng-aerospace/LICENSE +21 -21
  685. package/skills/engineering/eng-aerospace/SKILL.md +117 -117
  686. package/skills/engineering/eng-chemical/LICENSE +21 -21
  687. package/skills/engineering/eng-chemical/SKILL.md +63 -63
  688. package/skills/engineering/eng-civil/LICENSE +21 -21
  689. package/skills/engineering/eng-civil/SKILL.md +223 -223
  690. package/skills/engineering/eng-control-systems/LICENSE +21 -21
  691. package/skills/engineering/eng-control-systems/SKILL.md +158 -158
  692. package/skills/engineering/eng-cryogenics/LICENSE +21 -21
  693. package/skills/engineering/eng-cryogenics/SKILL.md +151 -151
  694. package/skills/engineering/eng-electrical/LICENSE +21 -21
  695. package/skills/engineering/eng-electrical/SKILL.md +70 -70
  696. package/skills/engineering/eng-electronics-embedded/LICENSE +21 -21
  697. package/skills/engineering/eng-electronics-embedded/SKILL.md +89 -89
  698. package/skills/engineering/eng-environmental/LICENSE +21 -21
  699. package/skills/engineering/eng-environmental/SKILL.md +66 -66
  700. package/skills/engineering/eng-manufacturing/LICENSE +21 -21
  701. package/skills/engineering/eng-manufacturing/SKILL.md +78 -78
  702. package/skills/engineering/eng-mechanical/LICENSE +21 -21
  703. package/skills/engineering/eng-mechanical/SKILL.md +66 -66
  704. package/skills/engineering/eng-project/LICENSE +21 -21
  705. package/skills/engineering/eng-project/SKILL.md +72 -72
  706. package/skills/engineering/eng-propulsion/LICENSE +21 -21
  707. package/skills/engineering/eng-propulsion/SKILL.md +133 -133
  708. package/skills/engineering/eng-robotics/LICENSE +21 -21
  709. package/skills/engineering/eng-robotics/SKILL.md +92 -92
  710. package/skills/engineering/eng-systems/LICENSE +21 -21
  711. package/skills/engineering/eng-systems/SKILL.md +81 -81
  712. package/skills/environment/env-biodiversity/LICENSE +21 -21
  713. package/skills/environment/env-biodiversity/SKILL.md +66 -66
  714. package/skills/environment/env-circular-economy/LICENSE +21 -21
  715. package/skills/environment/env-circular-economy/SKILL.md +71 -71
  716. package/skills/environment/env-climate-action/LICENSE +21 -21
  717. package/skills/environment/env-climate-action/SKILL.md +55 -55
  718. package/skills/environment/env-energy/LICENSE +21 -21
  719. package/skills/environment/env-energy/SKILL.md +83 -83
  720. package/skills/environment/env-sustainability-biz/LICENSE +21 -21
  721. package/skills/environment/env-sustainability-biz/SKILL.md +65 -65
  722. package/skills/environment/env-water/LICENSE +21 -21
  723. package/skills/environment/env-water/SKILL.md +67 -67
  724. package/skills/finance/finance-accounting/LICENSE +21 -21
  725. package/skills/finance/finance-accounting/SKILL.md +239 -239
  726. package/skills/finance/finance-banking/LICENSE +21 -21
  727. package/skills/finance/finance-banking/SKILL.md +54 -54
  728. package/skills/finance/finance-corporate/LICENSE +21 -21
  729. package/skills/finance/finance-corporate/SKILL.md +105 -105
  730. package/skills/finance/finance-crypto/LICENSE +21 -21
  731. package/skills/finance/finance-crypto/SKILL.md +94 -94
  732. package/skills/finance/finance-debt-management/LICENSE +21 -21
  733. package/skills/finance/finance-debt-management/SKILL.md +87 -87
  734. package/skills/finance/finance-insurance/LICENSE +21 -21
  735. package/skills/finance/finance-insurance/SKILL.md +91 -91
  736. package/skills/finance/finance-investing/LICENSE +21 -21
  737. package/skills/finance/finance-investing/SKILL.md +269 -269
  738. package/skills/finance/finance-options-derivatives/LICENSE +21 -21
  739. package/skills/finance/finance-options-derivatives/SKILL.md +68 -68
  740. package/skills/finance/finance-personal/LICENSE +21 -21
  741. package/skills/finance/finance-personal/SKILL.md +268 -268
  742. package/skills/finance/finance-real-estate/LICENSE +21 -21
  743. package/skills/finance/finance-real-estate/SKILL.md +110 -110
  744. package/skills/finance/finance-startup/LICENSE +21 -21
  745. package/skills/finance/finance-startup/SKILL.md +253 -253
  746. package/skills/finance/finance-tax-planning/LICENSE +21 -21
  747. package/skills/finance/finance-tax-planning/SKILL.md +89 -89
  748. package/skills/finance/finance-trading/LICENSE +21 -21
  749. package/skills/finance/finance-trading/SKILL.md +112 -112
  750. package/skills/gemini/SKILL.md +51 -51
  751. package/skills/gh-issues/SKILL.md +216 -216
  752. package/skills/gifgrep/SKILL.md +89 -89
  753. package/skills/github/SKILL.md +87 -87
  754. package/skills/gog/SKILL.md +120 -120
  755. package/skills/goplaces/SKILL.md +56 -56
  756. package/skills/graphify/SKILL.md +619 -0
  757. package/skills/graphify/__init__.py +28 -0
  758. package/skills/graphify/__main__.py +4582 -0
  759. package/skills/graphify/affected.py +154 -0
  760. package/skills/graphify/always_on/agents-md.md +12 -0
  761. package/skills/graphify/always_on/antigravity-rules.md +14 -0
  762. package/skills/graphify/always_on/claude-md.md +9 -0
  763. package/skills/graphify/always_on/gemini-md.md +9 -0
  764. package/skills/graphify/always_on/kiro-steering.md +5 -0
  765. package/skills/graphify/always_on/vscode-instructions.md +17 -0
  766. package/skills/graphify/analyze.py +724 -0
  767. package/skills/graphify/benchmark.py +155 -0
  768. package/skills/graphify/build.py +487 -0
  769. package/skills/graphify/cache.py +417 -0
  770. package/skills/graphify/callflow_html.py +2020 -0
  771. package/skills/graphify/cluster.py +272 -0
  772. package/skills/graphify/command-kilo.md +15 -0
  773. package/skills/graphify/dedup.py +429 -0
  774. package/skills/graphify/detect.py +1379 -0
  775. package/skills/graphify/diagnostics.py +390 -0
  776. package/skills/graphify/export.py +1408 -0
  777. package/skills/graphify/extract.py +11570 -0
  778. package/skills/graphify/global_graph.py +159 -0
  779. package/skills/graphify/google_workspace.py +223 -0
  780. package/skills/graphify/hooks.py +457 -0
  781. package/skills/graphify/ingest.py +331 -0
  782. package/skills/graphify/llm.py +1896 -0
  783. package/skills/graphify/manifest.py +4 -0
  784. package/skills/graphify/mcp_ingest.py +392 -0
  785. package/skills/graphify/multigraph_compat.py +212 -0
  786. package/skills/graphify/pg_introspect.py +142 -0
  787. package/skills/graphify/prs.py +748 -0
  788. package/skills/graphify/querylog.py +70 -0
  789. package/skills/graphify/report.py +218 -0
  790. package/skills/graphify/scip_ingest.py +363 -0
  791. package/skills/graphify/security.py +336 -0
  792. package/skills/graphify/semantic_cleanup.py +319 -0
  793. package/skills/graphify/serve.py +1309 -0
  794. package/skills/graphify/skill-aider.md +1246 -0
  795. package/skills/graphify/skill-amp.md +613 -0
  796. package/skills/graphify/skill-claw.md +616 -0
  797. package/skills/graphify/skill-codex.md +613 -0
  798. package/skills/graphify/skill-copilot.md +616 -0
  799. package/skills/graphify/skill-devin.md +1372 -0
  800. package/skills/graphify/skill-droid.md +613 -0
  801. package/skills/graphify/skill-kilo.md +625 -0
  802. package/skills/graphify/skill-kiro.md +615 -0
  803. package/skills/graphify/skill-opencode.md +608 -0
  804. package/skills/graphify/skill-pi.md +615 -0
  805. package/skills/graphify/skill-trae.md +614 -0
  806. package/skills/graphify/skill-vscode.md +612 -0
  807. package/skills/graphify/skill-windows.md +651 -0
  808. package/skills/graphify/skills/amp/references/add-watch.md +56 -0
  809. package/skills/graphify/skills/amp/references/exports.md +71 -0
  810. package/skills/graphify/skills/amp/references/extraction-spec.md +68 -0
  811. package/skills/graphify/skills/amp/references/github-and-merge.md +46 -0
  812. package/skills/graphify/skills/amp/references/hooks.md +33 -0
  813. package/skills/graphify/skills/amp/references/query.md +249 -0
  814. package/skills/graphify/skills/amp/references/transcribe.md +48 -0
  815. package/skills/graphify/skills/amp/references/update.md +179 -0
  816. package/skills/graphify/skills/claude/references/add-watch.md +56 -0
  817. package/skills/graphify/skills/claude/references/exports.md +71 -0
  818. package/skills/graphify/skills/claude/references/extraction-spec.md +68 -0
  819. package/skills/graphify/skills/claude/references/github-and-merge.md +46 -0
  820. package/skills/graphify/skills/claude/references/hooks.md +33 -0
  821. package/skills/graphify/skills/claude/references/query.md +103 -0
  822. package/skills/graphify/skills/claude/references/transcribe.md +48 -0
  823. package/skills/graphify/skills/claude/references/update.md +179 -0
  824. package/skills/graphify/skills/claw/references/add-watch.md +56 -0
  825. package/skills/graphify/skills/claw/references/exports.md +71 -0
  826. package/skills/graphify/skills/claw/references/extraction-spec.md +29 -0
  827. package/skills/graphify/skills/claw/references/github-and-merge.md +46 -0
  828. package/skills/graphify/skills/claw/references/hooks.md +33 -0
  829. package/skills/graphify/skills/claw/references/query.md +249 -0
  830. package/skills/graphify/skills/claw/references/transcribe.md +48 -0
  831. package/skills/graphify/skills/claw/references/update.md +179 -0
  832. package/skills/graphify/skills/codex/references/add-watch.md +56 -0
  833. package/skills/graphify/skills/codex/references/exports.md +71 -0
  834. package/skills/graphify/skills/codex/references/extraction-spec.md +29 -0
  835. package/skills/graphify/skills/codex/references/github-and-merge.md +46 -0
  836. package/skills/graphify/skills/codex/references/hooks.md +33 -0
  837. package/skills/graphify/skills/codex/references/query.md +249 -0
  838. package/skills/graphify/skills/codex/references/transcribe.md +48 -0
  839. package/skills/graphify/skills/codex/references/update.md +179 -0
  840. package/skills/graphify/skills/copilot/references/add-watch.md +56 -0
  841. package/skills/graphify/skills/copilot/references/exports.md +71 -0
  842. package/skills/graphify/skills/copilot/references/extraction-spec.md +68 -0
  843. package/skills/graphify/skills/copilot/references/github-and-merge.md +46 -0
  844. package/skills/graphify/skills/copilot/references/hooks.md +33 -0
  845. package/skills/graphify/skills/copilot/references/query.md +249 -0
  846. package/skills/graphify/skills/copilot/references/transcribe.md +48 -0
  847. package/skills/graphify/skills/copilot/references/update.md +179 -0
  848. package/skills/graphify/skills/droid/references/add-watch.md +56 -0
  849. package/skills/graphify/skills/droid/references/exports.md +71 -0
  850. package/skills/graphify/skills/droid/references/extraction-spec.md +68 -0
  851. package/skills/graphify/skills/droid/references/github-and-merge.md +46 -0
  852. package/skills/graphify/skills/droid/references/hooks.md +33 -0
  853. package/skills/graphify/skills/droid/references/query.md +249 -0
  854. package/skills/graphify/skills/droid/references/transcribe.md +48 -0
  855. package/skills/graphify/skills/droid/references/update.md +179 -0
  856. package/skills/graphify/skills/kilo/references/add-watch.md +56 -0
  857. package/skills/graphify/skills/kilo/references/exports.md +71 -0
  858. package/skills/graphify/skills/kilo/references/extraction-spec.md +68 -0
  859. package/skills/graphify/skills/kilo/references/github-and-merge.md +46 -0
  860. package/skills/graphify/skills/kilo/references/hooks.md +33 -0
  861. package/skills/graphify/skills/kilo/references/query.md +249 -0
  862. package/skills/graphify/skills/kilo/references/transcribe.md +48 -0
  863. package/skills/graphify/skills/kilo/references/update.md +179 -0
  864. package/skills/graphify/skills/kiro/references/add-watch.md +56 -0
  865. package/skills/graphify/skills/kiro/references/exports.md +71 -0
  866. package/skills/graphify/skills/kiro/references/extraction-spec.md +29 -0
  867. package/skills/graphify/skills/kiro/references/github-and-merge.md +46 -0
  868. package/skills/graphify/skills/kiro/references/hooks.md +33 -0
  869. package/skills/graphify/skills/kiro/references/query.md +249 -0
  870. package/skills/graphify/skills/kiro/references/transcribe.md +48 -0
  871. package/skills/graphify/skills/kiro/references/update.md +179 -0
  872. package/skills/graphify/skills/opencode/references/add-watch.md +56 -0
  873. package/skills/graphify/skills/opencode/references/exports.md +71 -0
  874. package/skills/graphify/skills/opencode/references/extraction-spec.md +68 -0
  875. package/skills/graphify/skills/opencode/references/github-and-merge.md +46 -0
  876. package/skills/graphify/skills/opencode/references/hooks.md +33 -0
  877. package/skills/graphify/skills/opencode/references/query.md +249 -0
  878. package/skills/graphify/skills/opencode/references/transcribe.md +48 -0
  879. package/skills/graphify/skills/opencode/references/update.md +179 -0
  880. package/skills/graphify/skills/pi/references/add-watch.md +56 -0
  881. package/skills/graphify/skills/pi/references/exports.md +71 -0
  882. package/skills/graphify/skills/pi/references/extraction-spec.md +29 -0
  883. package/skills/graphify/skills/pi/references/github-and-merge.md +46 -0
  884. package/skills/graphify/skills/pi/references/hooks.md +33 -0
  885. package/skills/graphify/skills/pi/references/query.md +249 -0
  886. package/skills/graphify/skills/pi/references/transcribe.md +48 -0
  887. package/skills/graphify/skills/pi/references/update.md +179 -0
  888. package/skills/graphify/skills/trae/references/add-watch.md +56 -0
  889. package/skills/graphify/skills/trae/references/exports.md +71 -0
  890. package/skills/graphify/skills/trae/references/extraction-spec.md +68 -0
  891. package/skills/graphify/skills/trae/references/github-and-merge.md +46 -0
  892. package/skills/graphify/skills/trae/references/hooks.md +35 -0
  893. package/skills/graphify/skills/trae/references/query.md +249 -0
  894. package/skills/graphify/skills/trae/references/transcribe.md +48 -0
  895. package/skills/graphify/skills/trae/references/update.md +179 -0
  896. package/skills/graphify/skills/vscode/references/add-watch.md +56 -0
  897. package/skills/graphify/skills/vscode/references/exports.md +71 -0
  898. package/skills/graphify/skills/vscode/references/extraction-spec.md +68 -0
  899. package/skills/graphify/skills/vscode/references/github-and-merge.md +46 -0
  900. package/skills/graphify/skills/vscode/references/hooks.md +33 -0
  901. package/skills/graphify/skills/vscode/references/query.md +249 -0
  902. package/skills/graphify/skills/vscode/references/transcribe.md +48 -0
  903. package/skills/graphify/skills/vscode/references/update.md +179 -0
  904. package/skills/graphify/skills/windows/references/add-watch.md +56 -0
  905. package/skills/graphify/skills/windows/references/exports.md +71 -0
  906. package/skills/graphify/skills/windows/references/extraction-spec.md +68 -0
  907. package/skills/graphify/skills/windows/references/github-and-merge.md +46 -0
  908. package/skills/graphify/skills/windows/references/hooks.md +33 -0
  909. package/skills/graphify/skills/windows/references/query.md +249 -0
  910. package/skills/graphify/skills/windows/references/transcribe.md +48 -0
  911. package/skills/graphify/skills/windows/references/update.md +179 -0
  912. package/skills/graphify/symbol_resolution.py +538 -0
  913. package/skills/graphify/transcribe.py +184 -0
  914. package/skills/graphify/tree_html.py +582 -0
  915. package/skills/graphify/validate.py +72 -0
  916. package/skills/graphify/watch.py +898 -0
  917. package/skills/graphify/wiki.py +282 -0
  918. package/skills/health/health-aging/LICENSE +21 -21
  919. package/skills/health/health-aging/SKILL.md +82 -82
  920. package/skills/health/health-chronic/LICENSE +21 -21
  921. package/skills/health/health-chronic/SKILL.md +202 -202
  922. package/skills/health/health-dental/LICENSE +21 -21
  923. package/skills/health/health-dental/SKILL.md +41 -41
  924. package/skills/health/health-eye-care/LICENSE +21 -21
  925. package/skills/health/health-eye-care/SKILL.md +56 -56
  926. package/skills/health/health-first-aid/LICENSE +21 -21
  927. package/skills/health/health-first-aid/SKILL.md +201 -201
  928. package/skills/health/health-fitness/LICENSE +21 -21
  929. package/skills/health/health-fitness/SKILL.md +111 -111
  930. package/skills/health/health-general/LICENSE +21 -21
  931. package/skills/health/health-general/SKILL.md +277 -277
  932. package/skills/health/health-mens/LICENSE +21 -21
  933. package/skills/health/health-mens/SKILL.md +53 -53
  934. package/skills/health/health-mental/LICENSE +21 -21
  935. package/skills/health/health-mental/SKILL.md +221 -221
  936. package/skills/health/health-naturopathy-ayurveda/LICENSE +21 -21
  937. package/skills/health/health-naturopathy-ayurveda/SKILL.md +60 -60
  938. package/skills/health/health-nutrition/LICENSE +21 -21
  939. package/skills/health/health-nutrition/SKILL.md +262 -262
  940. package/skills/health/health-pediatric/LICENSE +21 -21
  941. package/skills/health/health-pediatric/SKILL.md +94 -94
  942. package/skills/health/health-pharmacology/LICENSE +21 -21
  943. package/skills/health/health-pharmacology/SKILL.md +87 -87
  944. package/skills/health/health-pregnancy/LICENSE +21 -21
  945. package/skills/health/health-pregnancy/SKILL.md +71 -71
  946. package/skills/health/health-skin/LICENSE +21 -21
  947. package/skills/health/health-skin/SKILL.md +71 -71
  948. package/skills/health/health-sleep/LICENSE +21 -21
  949. package/skills/health/health-sleep/SKILL.md +81 -81
  950. package/skills/health/health-womens/LICENSE +21 -21
  951. package/skills/health/health-womens/SKILL.md +72 -72
  952. package/skills/health/health-yoga-wellness/LICENSE +21 -21
  953. package/skills/health/health-yoga-wellness/SKILL.md +58 -58
  954. package/skills/healthcare-systems/health-sys-global/LICENSE +21 -21
  955. package/skills/healthcare-systems/health-sys-global/SKILL.md +69 -69
  956. package/skills/healthcare-systems/health-sys-management/LICENSE +21 -21
  957. package/skills/healthcare-systems/health-sys-management/SKILL.md +71 -71
  958. package/skills/healthcare-systems/health-sys-navigation/LICENSE +21 -21
  959. package/skills/healthcare-systems/health-sys-navigation/SKILL.md +60 -60
  960. package/skills/healthcare-systems/health-sys-public/LICENSE +21 -21
  961. package/skills/healthcare-systems/health-sys-public/SKILL.md +71 -71
  962. package/skills/healthcheck/SKILL.md +109 -109
  963. package/skills/himalaya/SKILL.md +84 -84
  964. package/skills/himalaya/references/configuration.md +184 -184
  965. package/skills/himalaya/references/message-composition.md +199 -199
  966. package/skills/humanities/humanities-history-world/LICENSE +21 -21
  967. package/skills/humanities/humanities-history-world/SKILL.md +59 -59
  968. package/skills/humanities/humanities-indian-classical/LICENSE +21 -21
  969. package/skills/humanities/humanities-indian-classical/SKILL.md +104 -104
  970. package/skills/humanities/humanities-philosophy/LICENSE +21 -21
  971. package/skills/humanities/humanities-philosophy/SKILL.md +105 -105
  972. package/skills/humanities/humanities-world-religions/LICENSE +21 -21
  973. package/skills/humanities/humanities-world-religions/SKILL.md +67 -67
  974. package/skills/impeccable/SKILL.md +186 -0
  975. package/skills/impeccable/agents/impeccable_asset_producer.toml +92 -0
  976. package/skills/impeccable/agents/impeccable_manual_edit_applier.toml +95 -0
  977. package/skills/impeccable/agents/openai.yaml +4 -0
  978. package/skills/impeccable/reference/adapt.md +311 -0
  979. package/skills/impeccable/reference/animate.md +201 -0
  980. package/skills/impeccable/reference/audit.md +133 -0
  981. package/skills/impeccable/reference/bolder.md +113 -0
  982. package/skills/impeccable/reference/brand.md +108 -0
  983. package/skills/impeccable/reference/clarify.md +288 -0
  984. package/skills/impeccable/reference/codex.md +105 -0
  985. package/skills/impeccable/reference/colorize.md +257 -0
  986. package/skills/impeccable/reference/craft.md +123 -0
  987. package/skills/impeccable/reference/critique.md +790 -0
  988. package/skills/impeccable/reference/delight.md +302 -0
  989. package/skills/impeccable/reference/distill.md +111 -0
  990. package/skills/impeccable/reference/document.md +429 -0
  991. package/skills/impeccable/reference/extract.md +69 -0
  992. package/skills/impeccable/reference/harden.md +347 -0
  993. package/skills/impeccable/reference/init.md +172 -0
  994. package/skills/impeccable/reference/interaction-design.md +189 -0
  995. package/skills/impeccable/reference/layout.md +161 -0
  996. package/skills/impeccable/reference/live.md +720 -0
  997. package/skills/impeccable/reference/onboard.md +234 -0
  998. package/skills/impeccable/reference/optimize.md +258 -0
  999. package/skills/impeccable/reference/overdrive.md +130 -0
  1000. package/skills/impeccable/reference/polish.md +241 -0
  1001. package/skills/impeccable/reference/product.md +60 -0
  1002. package/skills/impeccable/reference/quieter.md +99 -0
  1003. package/skills/impeccable/reference/shape.md +165 -0
  1004. package/skills/impeccable/reference/typeset.md +279 -0
  1005. package/skills/impeccable/scripts/cleanup-deprecated.mjs +284 -0
  1006. package/skills/impeccable/scripts/command-metadata.json +94 -0
  1007. package/skills/impeccable/scripts/context-signals.mjs +225 -0
  1008. package/skills/impeccable/scripts/context.mjs +266 -0
  1009. package/skills/impeccable/scripts/critique-storage.mjs +242 -0
  1010. package/skills/impeccable/scripts/design-parser.mjs +835 -0
  1011. package/skills/impeccable/scripts/detect-csp.mjs +198 -0
  1012. package/skills/impeccable/scripts/detect.mjs +21 -0
  1013. package/skills/impeccable/scripts/detector/browser/injected/index.mjs +1733 -0
  1014. package/skills/impeccable/scripts/detector/cli/main.mjs +244 -0
  1015. package/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +4618 -0
  1016. package/skills/impeccable/scripts/detector/detect-antipatterns.mjs +43 -0
  1017. package/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +252 -0
  1018. package/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +535 -0
  1019. package/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +986 -0
  1020. package/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +208 -0
  1021. package/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +189 -0
  1022. package/skills/impeccable/scripts/detector/findings.mjs +12 -0
  1023. package/skills/impeccable/scripts/detector/node/file-system.mjs +198 -0
  1024. package/skills/impeccable/scripts/detector/profile/profiler.mjs +166 -0
  1025. package/skills/impeccable/scripts/detector/registry/antipatterns.mjs +419 -0
  1026. package/skills/impeccable/scripts/detector/rules/checks.mjs +2384 -0
  1027. package/skills/impeccable/scripts/detector/shared/color.mjs +124 -0
  1028. package/skills/impeccable/scripts/detector/shared/constants.mjs +101 -0
  1029. package/skills/impeccable/scripts/detector/shared/page.mjs +7 -0
  1030. package/skills/impeccable/scripts/impeccable-paths.mjs +126 -0
  1031. package/skills/impeccable/scripts/is-generated.mjs +69 -0
  1032. package/skills/impeccable/scripts/live-accept.mjs +812 -0
  1033. package/skills/impeccable/scripts/live-browser-session.js +123 -0
  1034. package/skills/impeccable/scripts/live-browser.js +10295 -0
  1035. package/skills/impeccable/scripts/live-commit-manual-edits.mjs +1241 -0
  1036. package/skills/impeccable/scripts/live-complete.mjs +75 -0
  1037. package/skills/impeccable/scripts/live-completion.mjs +19 -0
  1038. package/skills/impeccable/scripts/live-copy-edit-agent.mjs +683 -0
  1039. package/skills/impeccable/scripts/live-discard-manual-edits.mjs +51 -0
  1040. package/skills/impeccable/scripts/live-event-validation.mjs +137 -0
  1041. package/skills/impeccable/scripts/live-inject.mjs +557 -0
  1042. package/skills/impeccable/scripts/live-insert-ui.mjs +458 -0
  1043. package/skills/impeccable/scripts/live-insert.mjs +272 -0
  1044. package/skills/impeccable/scripts/live-manual-edit-evidence.mjs +363 -0
  1045. package/skills/impeccable/scripts/live-manual-edits-buffer.mjs +152 -0
  1046. package/skills/impeccable/scripts/live-poll.mjs +379 -0
  1047. package/skills/impeccable/scripts/live-resume.mjs +94 -0
  1048. package/skills/impeccable/scripts/live-server.mjs +2326 -0
  1049. package/skills/impeccable/scripts/live-session-store.mjs +289 -0
  1050. package/skills/impeccable/scripts/live-status.mjs +61 -0
  1051. package/skills/impeccable/scripts/live-svelte-component.mjs +826 -0
  1052. package/skills/impeccable/scripts/live-sveltekit-adapter.mjs +274 -0
  1053. package/skills/impeccable/scripts/live-ui-core.mjs +179 -0
  1054. package/skills/impeccable/scripts/live-vocabulary.mjs +36 -0
  1055. package/skills/impeccable/scripts/live-wrap.mjs +894 -0
  1056. package/skills/impeccable/scripts/live.mjs +246 -0
  1057. package/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
  1058. package/skills/impeccable/scripts/palette.mjs +633 -0
  1059. package/skills/impeccable/scripts/pin.mjs +214 -0
  1060. package/skills/imsg/SKILL.md +126 -126
  1061. package/skills/industry/industry-construction/LICENSE +21 -21
  1062. package/skills/industry/industry-construction/SKILL.md +81 -81
  1063. package/skills/industry/industry-education-sector/LICENSE +21 -21
  1064. package/skills/industry/industry-education-sector/SKILL.md +49 -49
  1065. package/skills/industry/industry-fashion/LICENSE +21 -21
  1066. package/skills/industry/industry-fashion/SKILL.md +82 -82
  1067. package/skills/industry/industry-food/LICENSE +21 -21
  1068. package/skills/industry/industry-food/SKILL.md +79 -79
  1069. package/skills/industry/industry-government/LICENSE +21 -21
  1070. package/skills/industry/industry-government/SKILL.md +80 -80
  1071. package/skills/industry/industry-hospitality/LICENSE +21 -21
  1072. package/skills/industry/industry-hospitality/SKILL.md +73 -73
  1073. package/skills/industry/industry-insurance-sector/LICENSE +21 -21
  1074. package/skills/industry/industry-insurance-sector/SKILL.md +57 -57
  1075. package/skills/industry/industry-logistics/LICENSE +21 -21
  1076. package/skills/industry/industry-logistics/SKILL.md +80 -80
  1077. package/skills/industry/industry-media/LICENSE +21 -21
  1078. package/skills/industry/industry-media/SKILL.md +66 -66
  1079. package/skills/industry/industry-nonprofit/LICENSE +21 -21
  1080. package/skills/industry/industry-nonprofit/SKILL.md +77 -77
  1081. package/skills/industry/industry-pharma/LICENSE +21 -21
  1082. package/skills/industry/industry-pharma/SKILL.md +69 -69
  1083. package/skills/industry/industry-real-estate/LICENSE +21 -21
  1084. package/skills/industry/industry-real-estate/SKILL.md +61 -61
  1085. package/skills/industry/industry-sports/LICENSE +21 -21
  1086. package/skills/industry/industry-sports/SKILL.md +71 -71
  1087. package/skills/industry/industry-tech-startup/LICENSE +21 -21
  1088. package/skills/industry/industry-tech-startup/SKILL.md +82 -82
  1089. package/skills/internal-comms/LICENSE +21 -21
  1090. package/skills/internal-comms/SKILL.md +38 -38
  1091. package/skills/internal-comms/examples/3p-updates.md +49 -49
  1092. package/skills/internal-comms/examples/company-newsletter.md +76 -76
  1093. package/skills/internal-comms/examples/faq-answers.md +35 -35
  1094. package/skills/internal-comms/examples/general-comms.md +19 -19
  1095. package/skills/legal/legal-business/LICENSE +21 -21
  1096. package/skills/legal/legal-business/SKILL.md +227 -227
  1097. package/skills/legal/legal-consumer/LICENSE +21 -21
  1098. package/skills/legal/legal-consumer/SKILL.md +155 -155
  1099. package/skills/legal/legal-contracts/LICENSE +21 -21
  1100. package/skills/legal/legal-contracts/SKILL.md +268 -268
  1101. package/skills/legal/legal-corporate-governance/LICENSE +21 -21
  1102. package/skills/legal/legal-corporate-governance/SKILL.md +53 -53
  1103. package/skills/legal/legal-employment/LICENSE +21 -21
  1104. package/skills/legal/legal-employment/SKILL.md +291 -291
  1105. package/skills/legal/legal-immigration/LICENSE +21 -21
  1106. package/skills/legal/legal-immigration/SKILL.md +146 -146
  1107. package/skills/legal/legal-international/LICENSE +21 -21
  1108. package/skills/legal/legal-international/SKILL.md +51 -51
  1109. package/skills/legal/legal-ip/LICENSE +21 -21
  1110. package/skills/legal/legal-ip/SKILL.md +264 -264
  1111. package/skills/legal/legal-privacy/LICENSE +21 -21
  1112. package/skills/legal/legal-privacy/SKILL.md +161 -161
  1113. package/skills/legal/legal-real-estate/LICENSE +21 -21
  1114. package/skills/legal/legal-real-estate/SKILL.md +142 -142
  1115. package/skills/legal/legal-startup/LICENSE +21 -21
  1116. package/skills/legal/legal-startup/SKILL.md +182 -182
  1117. package/skills/legal/legal-tax/LICENSE +21 -21
  1118. package/skills/legal/legal-tax/SKILL.md +156 -156
  1119. package/skills/mcp-builder/LICENSE +21 -21
  1120. package/skills/mcp-builder/SKILL.md +257 -257
  1121. package/skills/mcp-builder/reference/evaluation.md +630 -630
  1122. package/skills/mcp-builder/reference/mcp_best_practices.md +269 -269
  1123. package/skills/mcp-builder/reference/node_mcp_server.md +980 -980
  1124. package/skills/mcp-builder/reference/python_mcp_server.md +737 -737
  1125. package/skills/mcp-builder/scripts/connections.py +151 -151
  1126. package/skills/mcp-builder/scripts/evaluation.py +373 -373
  1127. package/skills/mcp-builder/scripts/example_evaluation.xml +22 -22
  1128. package/skills/mcp-builder/scripts/requirements.txt +2 -2
  1129. package/skills/mcporter/SKILL.md +65 -65
  1130. package/skills/meme-maker/SKILL.md +46 -46
  1131. package/skills/meme-maker/references/templates.json +358 -358
  1132. package/skills/meme-maker/scripts/meme.mjs +398 -398
  1133. package/skills/mental-health/mental-health-cbt/LICENSE +21 -21
  1134. package/skills/mental-health/mental-health-cbt/SKILL.md +254 -254
  1135. package/skills/mental-health/psych-addiction/LICENSE +21 -21
  1136. package/skills/mental-health/psych-addiction/SKILL.md +79 -79
  1137. package/skills/mental-health/psych-behavioral-econ/LICENSE +21 -21
  1138. package/skills/mental-health/psych-behavioral-econ/SKILL.md +84 -84
  1139. package/skills/mental-health/psych-child/LICENSE +21 -21
  1140. package/skills/mental-health/psych-child/SKILL.md +84 -84
  1141. package/skills/mental-health/psych-grief/LICENSE +21 -21
  1142. package/skills/mental-health/psych-grief/SKILL.md +85 -85
  1143. package/skills/mental-health/psych-mindfulness/LICENSE +21 -21
  1144. package/skills/mental-health/psych-mindfulness/SKILL.md +71 -71
  1145. package/skills/mental-health/psych-org/LICENSE +21 -21
  1146. package/skills/mental-health/psych-org/SKILL.md +115 -115
  1147. package/skills/mental-health/psych-positive/LICENSE +21 -21
  1148. package/skills/mental-health/psych-positive/SKILL.md +86 -86
  1149. package/skills/mental-health/psych-relationships/LICENSE +21 -21
  1150. package/skills/mental-health/psych-relationships/SKILL.md +100 -100
  1151. package/skills/mental-health/psych-trauma/LICENSE +21 -21
  1152. package/skills/mental-health/psych-trauma/SKILL.md +109 -109
  1153. package/skills/model-usage/SKILL.md +75 -75
  1154. package/skills/model-usage/references/codexbar-cli.md +33 -33
  1155. package/skills/model-usage/scripts/model_usage.py +319 -319
  1156. package/skills/model-usage/scripts/test_model_usage.py +40 -40
  1157. package/skills/nano-pdf/SKILL.md +42 -42
  1158. package/skills/node-connect/SKILL.md +147 -147
  1159. package/skills/node-inspect-debugger/SKILL.md +88 -88
  1160. package/skills/notion/SKILL.md +154 -154
  1161. package/skills/obsidian/SKILL.md +123 -123
  1162. package/skills/openai-whisper/SKILL.md +42 -42
  1163. package/skills/openai-whisper-api/SKILL.md +75 -75
  1164. package/skills/openai-whisper-api/scripts/transcribe.sh +154 -154
  1165. package/skills/openhue/SKILL.md +116 -116
  1166. package/skills/oracle/SKILL.md +130 -130
  1167. package/skills/ordercli/SKILL.md +82 -82
  1168. package/skills/peekaboo/SKILL.md +217 -217
  1169. package/skills/pyproject.toml +10 -10
  1170. package/skills/python-debugpy/SKILL.md +76 -76
  1171. package/skills/sag/SKILL.md +91 -91
  1172. package/skills/science/sci-astronomy/LICENSE +21 -21
  1173. package/skills/science/sci-astronomy/SKILL.md +80 -80
  1174. package/skills/science/sci-biology/LICENSE +21 -21
  1175. package/skills/science/sci-biology/SKILL.md +74 -74
  1176. package/skills/science/sci-chemistry/LICENSE +21 -21
  1177. package/skills/science/sci-chemistry/SKILL.md +89 -89
  1178. package/skills/science/sci-climate/LICENSE +21 -21
  1179. package/skills/science/sci-climate/SKILL.md +72 -72
  1180. package/skills/science/sci-data-analysis/LICENSE +21 -21
  1181. package/skills/science/sci-data-analysis/SKILL.md +87 -87
  1182. package/skills/science/sci-environmental-science/LICENSE +21 -21
  1183. package/skills/science/sci-environmental-science/SKILL.md +69 -69
  1184. package/skills/science/sci-geology/LICENSE +21 -21
  1185. package/skills/science/sci-geology/SKILL.md +56 -56
  1186. package/skills/science/sci-method/LICENSE +21 -21
  1187. package/skills/science/sci-method/SKILL.md +77 -77
  1188. package/skills/science/sci-neuroscience/LICENSE +21 -21
  1189. package/skills/science/sci-neuroscience/SKILL.md +79 -79
  1190. package/skills/science/sci-physics/LICENSE +21 -21
  1191. package/skills/science/sci-physics/SKILL.md +78 -78
  1192. package/skills/science/sci-research-methods/LICENSE +21 -21
  1193. package/skills/science/sci-research-methods/SKILL.md +83 -83
  1194. package/skills/science/sci-statistics/LICENSE +21 -21
  1195. package/skills/science/sci-statistics/SKILL.md +249 -249
  1196. package/skills/session-logs/SKILL.md +155 -155
  1197. package/skills/sherpa-onnx-tts/SKILL.md +113 -113
  1198. package/skills/skill-creator/SKILL.md +81 -81
  1199. package/skills/skill-creator/license.txt +202 -202
  1200. package/skills/skill-creator/scripts/init_skill.py +378 -378
  1201. package/skills/skill-creator/scripts/package_skill.py +144 -144
  1202. package/skills/skill-creator/scripts/quick_validate.py +169 -169
  1203. package/skills/skill-creator/scripts/test_init_skill.py +51 -51
  1204. package/skills/skill-creator/scripts/test_package_skill.py +199 -199
  1205. package/skills/skill-creator/scripts/test_quick_validate.py +116 -116
  1206. package/skills/slack/SKILL.md +82 -82
  1207. package/skills/slack-gif-creator/LICENSE +21 -21
  1208. package/skills/slack-gif-creator/SKILL.md +293 -293
  1209. package/skills/slack-gif-creator/requirements.txt +3 -3
  1210. package/skills/social-sciences/social-anthropology/LICENSE +21 -21
  1211. package/skills/social-sciences/social-anthropology/SKILL.md +62 -62
  1212. package/skills/social-sciences/social-economics/LICENSE +21 -21
  1213. package/skills/social-sciences/social-economics/SKILL.md +88 -88
  1214. package/skills/social-sciences/social-geography/LICENSE +21 -21
  1215. package/skills/social-sciences/social-geography/SKILL.md +61 -61
  1216. package/skills/social-sciences/social-international-dev/LICENSE +21 -21
  1217. package/skills/social-sciences/social-international-dev/SKILL.md +76 -76
  1218. package/skills/social-sciences/social-political-science/LICENSE +21 -21
  1219. package/skills/social-sciences/social-political-science/SKILL.md +70 -70
  1220. package/skills/social-sciences/social-public-policy/LICENSE +21 -21
  1221. package/skills/social-sciences/social-public-policy/SKILL.md +73 -73
  1222. package/skills/social-sciences/social-sociology/LICENSE +21 -21
  1223. package/skills/social-sciences/social-sociology/SKILL.md +78 -78
  1224. package/skills/songsee/SKILL.md +53 -53
  1225. package/skills/sonoscli/SKILL.md +69 -69
  1226. package/skills/spike/SKILL.md +55 -55
  1227. package/skills/spotify-player/SKILL.md +68 -68
  1228. package/skills/summarize/SKILL.md +90 -90
  1229. package/skills/taskflow/SKILL.md +153 -153
  1230. package/skills/taskflow/examples/inbox-triage.lobster +33 -33
  1231. package/skills/taskflow/examples/pr-intake.lobster +32 -32
  1232. package/skills/taskflow-inbox-triage/SKILL.md +123 -123
  1233. package/skills/technical/ai-ethics/LICENSE +21 -21
  1234. package/skills/technical/ai-ethics/SKILL.md +92 -92
  1235. package/skills/technical/ai-product-builder/LICENSE +21 -21
  1236. package/skills/technical/ai-product-builder/SKILL.md +180 -180
  1237. package/skills/technical/analytics-setup/LICENSE +21 -21
  1238. package/skills/technical/analytics-setup/SKILL.md +125 -125
  1239. package/skills/technical/api-builder/LICENSE +21 -21
  1240. package/skills/technical/api-builder/SKILL.md +202 -202
  1241. package/skills/technical/architecture-decisions/LICENSE +21 -21
  1242. package/skills/technical/architecture-decisions/SKILL.md +120 -120
  1243. package/skills/technical/auth-security/LICENSE +21 -21
  1244. package/skills/technical/auth-security/SKILL.md +209 -209
  1245. package/skills/technical/blockchain-web3/LICENSE +21 -21
  1246. package/skills/technical/blockchain-web3/SKILL.md +84 -84
  1247. package/skills/technical/cloud-architecture/LICENSE +21 -21
  1248. package/skills/technical/cloud-architecture/SKILL.md +85 -85
  1249. package/skills/technical/content-platform/LICENSE +21 -21
  1250. package/skills/technical/content-platform/SKILL.md +134 -134
  1251. package/skills/technical/cybersecurity-advanced/LICENSE +21 -21
  1252. package/skills/technical/cybersecurity-advanced/SKILL.md +99 -99
  1253. package/skills/technical/data-engineering/LICENSE +21 -21
  1254. package/skills/technical/data-engineering/SKILL.md +117 -117
  1255. package/skills/technical/database-design/LICENSE +21 -21
  1256. package/skills/technical/database-design/SKILL.md +185 -185
  1257. package/skills/technical/devops-cicd/LICENSE +21 -21
  1258. package/skills/technical/devops-cicd/SKILL.md +181 -181
  1259. package/skills/technical/ecommerce-builder/LICENSE +21 -21
  1260. package/skills/technical/ecommerce-builder/SKILL.md +123 -123
  1261. package/skills/technical/email-marketing/LICENSE +21 -21
  1262. package/skills/technical/email-marketing/SKILL.md +128 -128
  1263. package/skills/technical/fintech-builder/LICENSE +21 -21
  1264. package/skills/technical/fintech-builder/SKILL.md +141 -141
  1265. package/skills/technical/full-stack-web/LICENSE +21 -21
  1266. package/skills/technical/full-stack-web/SKILL.md +173 -173
  1267. package/skills/technical/gdpr-basics/LICENSE +21 -21
  1268. package/skills/technical/gdpr-basics/SKILL.md +145 -145
  1269. package/skills/technical/launch-playbook/LICENSE +21 -21
  1270. package/skills/technical/launch-playbook/SKILL.md +95 -95
  1271. package/skills/technical/marketing-copy/LICENSE +21 -21
  1272. package/skills/technical/marketing-copy/SKILL.md +126 -126
  1273. package/skills/technical/marketplace-builder/LICENSE +21 -21
  1274. package/skills/technical/marketplace-builder/SKILL.md +105 -105
  1275. package/skills/technical/mobile-pwa/LICENSE +21 -21
  1276. package/skills/technical/mobile-pwa/SKILL.md +191 -191
  1277. package/skills/technical/no-code-tools/LICENSE +21 -21
  1278. package/skills/technical/no-code-tools/SKILL.md +80 -80
  1279. package/skills/technical/open-source/LICENSE +21 -21
  1280. package/skills/technical/open-source/SKILL.md +71 -71
  1281. package/skills/technical/performance-optimization/LICENSE +21 -21
  1282. package/skills/technical/performance-optimization/SKILL.md +155 -155
  1283. package/skills/technical/pricing-design/LICENSE +21 -21
  1284. package/skills/technical/pricing-design/SKILL.md +87 -87
  1285. package/skills/technical/product-management/LICENSE +21 -21
  1286. package/skills/technical/product-management/SKILL.md +94 -94
  1287. package/skills/technical/saas-builder/LICENSE +21 -21
  1288. package/skills/technical/saas-builder/SKILL.md +138 -138
  1289. package/skills/technical/scope-estimation/LICENSE +21 -21
  1290. package/skills/technical/scope-estimation/SKILL.md +99 -99
  1291. package/skills/technical/secrets-management/LICENSE +21 -21
  1292. package/skills/technical/secrets-management/SKILL.md +135 -135
  1293. package/skills/technical/seo-technical/LICENSE +21 -21
  1294. package/skills/technical/seo-technical/SKILL.md +136 -136
  1295. package/skills/technical/technical-writing/LICENSE +21 -21
  1296. package/skills/technical/technical-writing/SKILL.md +149 -149
  1297. package/skills/technical/ux-research-tools/LICENSE +21 -21
  1298. package/skills/technical/ux-research-tools/SKILL.md +54 -54
  1299. package/skills/theme-factory/LICENSE +21 -21
  1300. package/skills/theme-factory/SKILL.md +65 -65
  1301. package/skills/theme-factory/themes/arctic-frost.md +19 -19
  1302. package/skills/theme-factory/themes/botanical-garden.md +19 -19
  1303. package/skills/theme-factory/themes/desert-rose.md +19 -19
  1304. package/skills/theme-factory/themes/forest-canopy.md +19 -19
  1305. package/skills/theme-factory/themes/golden-hour.md +19 -19
  1306. package/skills/theme-factory/themes/midnight-galaxy.md +19 -19
  1307. package/skills/theme-factory/themes/modern-minimalist.md +19 -19
  1308. package/skills/theme-factory/themes/ocean-depths.md +19 -19
  1309. package/skills/theme-factory/themes/sunset-boulevard.md +19 -19
  1310. package/skills/theme-factory/themes/tech-innovation.md +19 -19
  1311. package/skills/things-mac/SKILL.md +90 -90
  1312. package/skills/tmux/SKILL.md +95 -95
  1313. package/skills/tmux/scripts/find-sessions.sh +112 -112
  1314. package/skills/tmux/scripts/wait-for-text.sh +83 -83
  1315. package/skills/trades/trades-agriculture/LICENSE +21 -21
  1316. package/skills/trades/trades-agriculture/SKILL.md +80 -80
  1317. package/skills/trades/trades-automotive/LICENSE +21 -21
  1318. package/skills/trades/trades-automotive/SKILL.md +84 -84
  1319. package/skills/trades/trades-carpentry/LICENSE +21 -21
  1320. package/skills/trades/trades-carpentry/SKILL.md +71 -71
  1321. package/skills/trades/trades-cooking-pro/LICENSE +21 -21
  1322. package/skills/trades/trades-cooking-pro/SKILL.md +90 -90
  1323. package/skills/trades/trades-electrical/LICENSE +21 -21
  1324. package/skills/trades/trades-electrical/SKILL.md +146 -146
  1325. package/skills/trades/trades-hvac/LICENSE +21 -21
  1326. package/skills/trades/trades-hvac/SKILL.md +80 -80
  1327. package/skills/trades/trades-landscaping/LICENSE +21 -21
  1328. package/skills/trades/trades-landscaping/SKILL.md +60 -60
  1329. package/skills/trades/trades-metalworking/LICENSE +21 -21
  1330. package/skills/trades/trades-metalworking/SKILL.md +64 -64
  1331. package/skills/trades/trades-painting/LICENSE +21 -21
  1332. package/skills/trades/trades-painting/SKILL.md +70 -70
  1333. package/skills/trades/trades-plumbing/LICENSE +21 -21
  1334. package/skills/trades/trades-plumbing/SKILL.md +160 -160
  1335. package/skills/trades/trades-welding/LICENSE +21 -21
  1336. package/skills/trades/trades-welding/SKILL.md +82 -82
  1337. package/skills/trello/SKILL.md +112 -112
  1338. package/skills/uipm-ui-styling/LICENSE.txt +202 -0
  1339. package/skills/uipm-ui-styling/SKILL.md +328 -0
  1340. package/skills/uipm-ui-styling/canvas-fonts/ArsenalSC-OFL.txt +93 -0
  1341. package/skills/uipm-ui-styling/canvas-fonts/ArsenalSC-Regular.ttf +0 -0
  1342. package/skills/uipm-ui-styling/canvas-fonts/BigShoulders-Bold.ttf +0 -0
  1343. package/skills/uipm-ui-styling/canvas-fonts/BigShoulders-OFL.txt +93 -0
  1344. package/skills/uipm-ui-styling/canvas-fonts/BigShoulders-Regular.ttf +0 -0
  1345. package/skills/uipm-ui-styling/canvas-fonts/Boldonse-OFL.txt +93 -0
  1346. package/skills/uipm-ui-styling/canvas-fonts/Boldonse-Regular.ttf +0 -0
  1347. package/skills/uipm-ui-styling/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
  1348. package/skills/uipm-ui-styling/canvas-fonts/BricolageGrotesque-OFL.txt +93 -0
  1349. package/skills/uipm-ui-styling/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
  1350. package/skills/uipm-ui-styling/canvas-fonts/CrimsonPro-Bold.ttf +0 -0
  1351. package/skills/uipm-ui-styling/canvas-fonts/CrimsonPro-Italic.ttf +0 -0
  1352. package/skills/uipm-ui-styling/canvas-fonts/CrimsonPro-OFL.txt +93 -0
  1353. package/skills/uipm-ui-styling/canvas-fonts/CrimsonPro-Regular.ttf +0 -0
  1354. package/skills/uipm-ui-styling/canvas-fonts/DMMono-OFL.txt +93 -0
  1355. package/skills/uipm-ui-styling/canvas-fonts/DMMono-Regular.ttf +0 -0
  1356. package/skills/uipm-ui-styling/canvas-fonts/EricaOne-OFL.txt +94 -0
  1357. package/skills/uipm-ui-styling/canvas-fonts/EricaOne-Regular.ttf +0 -0
  1358. package/skills/uipm-ui-styling/canvas-fonts/GeistMono-Bold.ttf +0 -0
  1359. package/skills/uipm-ui-styling/canvas-fonts/GeistMono-OFL.txt +93 -0
  1360. package/skills/uipm-ui-styling/canvas-fonts/GeistMono-Regular.ttf +0 -0
  1361. package/skills/uipm-ui-styling/canvas-fonts/Gloock-OFL.txt +93 -0
  1362. package/skills/uipm-ui-styling/canvas-fonts/Gloock-Regular.ttf +0 -0
  1363. package/skills/uipm-ui-styling/canvas-fonts/IBMPlexMono-Bold.ttf +0 -0
  1364. package/skills/uipm-ui-styling/canvas-fonts/IBMPlexMono-OFL.txt +93 -0
  1365. package/skills/uipm-ui-styling/canvas-fonts/IBMPlexMono-Regular.ttf +0 -0
  1366. package/skills/uipm-ui-styling/canvas-fonts/IBMPlexSerif-Bold.ttf +0 -0
  1367. package/skills/uipm-ui-styling/canvas-fonts/IBMPlexSerif-BoldItalic.ttf +0 -0
  1368. package/skills/uipm-ui-styling/canvas-fonts/IBMPlexSerif-Italic.ttf +0 -0
  1369. package/skills/uipm-ui-styling/canvas-fonts/IBMPlexSerif-Regular.ttf +0 -0
  1370. package/skills/uipm-ui-styling/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
  1371. package/skills/uipm-ui-styling/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
  1372. package/skills/uipm-ui-styling/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
  1373. package/skills/uipm-ui-styling/canvas-fonts/InstrumentSans-OFL.txt +93 -0
  1374. package/skills/uipm-ui-styling/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
  1375. package/skills/uipm-ui-styling/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
  1376. package/skills/uipm-ui-styling/canvas-fonts/InstrumentSerif-Regular.ttf +0 -0
  1377. package/skills/uipm-ui-styling/canvas-fonts/Italiana-OFL.txt +93 -0
  1378. package/skills/uipm-ui-styling/canvas-fonts/Italiana-Regular.ttf +0 -0
  1379. package/skills/uipm-ui-styling/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
  1380. package/skills/uipm-ui-styling/canvas-fonts/JetBrainsMono-OFL.txt +93 -0
  1381. package/skills/uipm-ui-styling/canvas-fonts/JetBrainsMono-Regular.ttf +0 -0
  1382. package/skills/uipm-ui-styling/canvas-fonts/Jura-Light.ttf +0 -0
  1383. package/skills/uipm-ui-styling/canvas-fonts/Jura-Medium.ttf +0 -0
  1384. package/skills/uipm-ui-styling/canvas-fonts/Jura-OFL.txt +93 -0
  1385. package/skills/uipm-ui-styling/canvas-fonts/LibreBaskerville-OFL.txt +93 -0
  1386. package/skills/uipm-ui-styling/canvas-fonts/LibreBaskerville-Regular.ttf +0 -0
  1387. package/skills/uipm-ui-styling/canvas-fonts/Lora-Bold.ttf +0 -0
  1388. package/skills/uipm-ui-styling/canvas-fonts/Lora-BoldItalic.ttf +0 -0
  1389. package/skills/uipm-ui-styling/canvas-fonts/Lora-Italic.ttf +0 -0
  1390. package/skills/uipm-ui-styling/canvas-fonts/Lora-OFL.txt +93 -0
  1391. package/skills/uipm-ui-styling/canvas-fonts/Lora-Regular.ttf +0 -0
  1392. package/skills/uipm-ui-styling/canvas-fonts/NationalPark-Bold.ttf +0 -0
  1393. package/skills/uipm-ui-styling/canvas-fonts/NationalPark-OFL.txt +93 -0
  1394. package/skills/uipm-ui-styling/canvas-fonts/NationalPark-Regular.ttf +0 -0
  1395. package/skills/uipm-ui-styling/canvas-fonts/NothingYouCouldDo-OFL.txt +93 -0
  1396. package/skills/uipm-ui-styling/canvas-fonts/NothingYouCouldDo-Regular.ttf +0 -0
  1397. package/skills/uipm-ui-styling/canvas-fonts/Outfit-Bold.ttf +0 -0
  1398. package/skills/uipm-ui-styling/canvas-fonts/Outfit-OFL.txt +93 -0
  1399. package/skills/uipm-ui-styling/canvas-fonts/Outfit-Regular.ttf +0 -0
  1400. package/skills/uipm-ui-styling/canvas-fonts/PixelifySans-Medium.ttf +0 -0
  1401. package/skills/uipm-ui-styling/canvas-fonts/PixelifySans-OFL.txt +93 -0
  1402. package/skills/uipm-ui-styling/canvas-fonts/PoiretOne-OFL.txt +93 -0
  1403. package/skills/uipm-ui-styling/canvas-fonts/PoiretOne-Regular.ttf +0 -0
  1404. package/skills/uipm-ui-styling/canvas-fonts/RedHatMono-Bold.ttf +0 -0
  1405. package/skills/uipm-ui-styling/canvas-fonts/RedHatMono-OFL.txt +93 -0
  1406. package/skills/uipm-ui-styling/canvas-fonts/RedHatMono-Regular.ttf +0 -0
  1407. package/skills/uipm-ui-styling/canvas-fonts/Silkscreen-OFL.txt +93 -0
  1408. package/skills/uipm-ui-styling/canvas-fonts/Silkscreen-Regular.ttf +0 -0
  1409. package/skills/uipm-ui-styling/canvas-fonts/SmoochSans-Medium.ttf +0 -0
  1410. package/skills/uipm-ui-styling/canvas-fonts/SmoochSans-OFL.txt +93 -0
  1411. package/skills/uipm-ui-styling/canvas-fonts/Tektur-Medium.ttf +0 -0
  1412. package/skills/uipm-ui-styling/canvas-fonts/Tektur-OFL.txt +93 -0
  1413. package/skills/uipm-ui-styling/canvas-fonts/Tektur-Regular.ttf +0 -0
  1414. package/skills/uipm-ui-styling/canvas-fonts/WorkSans-Bold.ttf +0 -0
  1415. package/skills/uipm-ui-styling/canvas-fonts/WorkSans-BoldItalic.ttf +0 -0
  1416. package/skills/uipm-ui-styling/canvas-fonts/WorkSans-Italic.ttf +0 -0
  1417. package/skills/uipm-ui-styling/canvas-fonts/WorkSans-OFL.txt +93 -0
  1418. package/skills/uipm-ui-styling/canvas-fonts/WorkSans-Regular.ttf +0 -0
  1419. package/skills/uipm-ui-styling/canvas-fonts/YoungSerif-OFL.txt +93 -0
  1420. package/skills/uipm-ui-styling/canvas-fonts/YoungSerif-Regular.ttf +0 -0
  1421. package/skills/uipm-ui-styling/references/canvas-design-system.md +320 -0
  1422. package/skills/uipm-ui-styling/references/shadcn-accessibility.md +471 -0
  1423. package/skills/uipm-ui-styling/references/shadcn-components.md +424 -0
  1424. package/skills/uipm-ui-styling/references/shadcn-theming.md +373 -0
  1425. package/skills/uipm-ui-styling/references/tailwind-customization.md +483 -0
  1426. package/skills/uipm-ui-styling/references/tailwind-responsive.md +382 -0
  1427. package/skills/uipm-ui-styling/references/tailwind-utilities.md +455 -0
  1428. package/skills/uipm-ui-styling/scripts/.coverage +0 -0
  1429. package/skills/uipm-ui-styling/scripts/requirements.txt +17 -0
  1430. package/skills/uipm-ui-styling/scripts/shadcn_add.py +292 -0
  1431. package/skills/uipm-ui-styling/scripts/tailwind_config_gen.py +456 -0
  1432. package/skills/uipm-ui-styling/scripts/tests/coverage-ui.json +1 -0
  1433. package/skills/uipm-ui-styling/scripts/tests/requirements.txt +3 -0
  1434. package/skills/uipm-ui-styling/scripts/tests/test_shadcn_add.py +266 -0
  1435. package/skills/uipm-ui-styling/scripts/tests/test_tailwind_config_gen.py +336 -0
  1436. package/skills/video-frames/SKILL.md +50 -50
  1437. package/skills/video-frames/scripts/frame.sh +81 -81
  1438. package/skills/voice-call/SKILL.md +49 -49
  1439. package/skills/wacli/SKILL.md +76 -76
  1440. package/skills/weather/SKILL.md +91 -91
  1441. package/skills/web-artifacts-builder/LICENSE +21 -21
  1442. package/skills/web-artifacts-builder/SKILL.md +82 -82
  1443. package/skills/web-artifacts-builder/scripts/bundle-artifact.sh +53 -53
  1444. package/skills/web-artifacts-builder/scripts/init-artifact.sh +322 -322
  1445. package/skills/xurl/SKILL.md +124 -124
@@ -0,0 +1,2326 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Live variant mode server (self-contained, zero dependencies).
4
+ *
5
+ * Serves the browser script (/live.js), the detection overlay (/detect.js),
6
+ * uses Server-Sent Events (SSE) for server→browser push, and HTTP POST for
7
+ * browser→server events. Agent communicates via HTTP long-poll (/poll).
8
+ *
9
+ * Usage:
10
+ * node <scripts_path>/live-server.mjs # start
11
+ * node <scripts_path>/live-server.mjs stop # stop + remove injected live.js tag
12
+ * node <scripts_path>/live-server.mjs stop --keep-inject # stop only
13
+ * node <scripts_path>/live-server.mjs --help
14
+ */
15
+
16
+ import http from 'node:http';
17
+ import { randomUUID } from 'node:crypto';
18
+ import { spawn, execFileSync } from 'node:child_process';
19
+ import fs from 'node:fs';
20
+ import path from 'node:path';
21
+ import net from 'node:net';
22
+ import { fileURLToPath } from 'node:url';
23
+ import { parseDesignMd } from './design-parser.mjs';
24
+ import { resolveContextDir } from './context.mjs';
25
+ import { createLiveSessionStore } from './live-session-store.mjs';
26
+ import { validateEvent } from './live-event-validation.mjs';
27
+ import { LIVE_COMMANDS } from './live-vocabulary.mjs';
28
+ import {
29
+ getDesignSidecarPath,
30
+ getLiveDir,
31
+ getLiveAnnotationsDir,
32
+ readLiveServerInfo,
33
+ removeLiveServerInfo,
34
+ resolveDesignSidecarPath,
35
+ writeLiveServerInfo,
36
+ } from './impeccable-paths.mjs';
37
+ import {
38
+ countByPage as countPendingByPage,
39
+ readBuffer as readManualEditsBuffer,
40
+ removeEntries as removeManualEditEntries,
41
+ stageEntry as stageManualEditEntry,
42
+ truncateBuffer as truncateManualEditsBuffer,
43
+ } from './live-manual-edits-buffer.mjs';
44
+ import { buildManualEditEvidence } from './live-manual-edit-evidence.mjs';
45
+ import { commitManualEdits } from './live-commit-manual-edits.mjs';
46
+ import {
47
+ applyDeferredSvelteComponentAccepts,
48
+ removeAllSvelteComponentSessions,
49
+ } from './live-svelte-component.mjs';
50
+
51
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
52
+ // PRODUCT.md / DESIGN.md live wherever context.mjs resolves. The generated
53
+ // DESIGN sidecar is project-local at .impeccable/design.json, with legacy
54
+ // DESIGN.json fallback for existing projects.
55
+ const CONTEXT_DIR = resolveContextDir(process.cwd());
56
+ const DEFAULT_POLL_TIMEOUT = 600_000; // 10 min — agent re-polls on timeout anyway
57
+ const SSE_HEARTBEAT_INTERVAL = 30_000; // keepalive ping every 30s
58
+
59
+ // ---------------------------------------------------------------------------
60
+ // Port detection
61
+ // ---------------------------------------------------------------------------
62
+
63
+ async function findOpenPort(start = 8400) {
64
+ return new Promise((resolve) => {
65
+ const srv = net.createServer();
66
+ srv.listen(start, '127.0.0.1', () => {
67
+ const port = srv.address().port;
68
+ srv.close(() => resolve(port));
69
+ });
70
+ srv.on('error', () => resolve(findOpenPort(start + 1)));
71
+ });
72
+ }
73
+
74
+ // ---------------------------------------------------------------------------
75
+ // Session state
76
+ // ---------------------------------------------------------------------------
77
+
78
+ const state = {
79
+ token: null,
80
+ port: null,
81
+ sseClients: new Set(), // SSE response objects (server→browser push)
82
+ pendingEvents: [], // browser events waiting for agent ack ({ event, leaseUntil })
83
+ pendingPolls: [], // agent poll callbacks waiting for browser events
84
+ nextEventSeq: 1,
85
+ lastAgentPollingBroadcast: null,
86
+ exitTimer: null,
87
+ sessionDir: null, // per-session tmp dir for annotation screenshots
88
+ sessionStore: null,
89
+ leaseTimer: null,
90
+ manualEditActivity: null,
91
+ nextManualEditSeq: 1,
92
+ // Deferreds for in-flight chat-routed Apply events. Keyed by event id; each
93
+ // entry is resolved when the chat agent POSTs an ack carrying the batch
94
+ // result, or rejected when the hard timeout fires.
95
+ pendingApplyDeferreds: new Map(),
96
+ // Updated whenever a /poll long-poll request arrives or is resolved with an
97
+ // event. Used to detect "a chat agent is likely attached" without requiring
98
+ // a poll to be parked at the exact moment we dispatch.
99
+ lastPollAt: 0,
100
+ timedOutApplyIds: new Map(),
101
+ };
102
+
103
+ const CHAT_POLL_FRESHNESS_MS = 60_000;
104
+ const APPLY_EVENT_HARD_TIMEOUT_MS = Number(process.env.IMPECCABLE_LIVE_APPLY_EVENT_HARD_TIMEOUT_MS || 150_000);
105
+ const APPLY_EVENT_SOFT_DEADLINE_MS = Number(process.env.IMPECCABLE_LIVE_APPLY_EVENT_SOFT_DEADLINE_MS || 120_000);
106
+ const DEFAULT_MANUAL_EDIT_APPLY_CHUNK_SIZE = 3;
107
+ const MIN_MANUAL_EDIT_APPLY_CHUNK_SIZE = 1;
108
+ const MAX_MANUAL_EDIT_APPLY_CHUNK_SIZE = 20;
109
+ const MANUAL_APPLY_COMPACT_TEXT_LIMIT = 240;
110
+ const MANUAL_APPLY_COMPACT_NEARBY_LIMIT = 4;
111
+ const POLL_LEASE_EXPIRY_TIMER_GRACE_MS = 2;
112
+ const DEBUG_MANUAL_EDIT_EVENTS = /^(1|true|yes)$/i.test(process.env.IMPECCABLE_LIVE_DEBUG_EVENTS || '');
113
+
114
+ function tombstoneTimedOutApplyId(eventId, details = {}) {
115
+ if (!eventId) return;
116
+ state.timedOutApplyIds.set(eventId, details);
117
+ if (state.timedOutApplyIds.size <= 200) return;
118
+ const oldest = state.timedOutApplyIds.keys().next().value;
119
+ state.timedOutApplyIds.delete(oldest);
120
+ }
121
+
122
+ function chatAgentLikelyActive() {
123
+ if (state.pendingPolls.length > 0) return true;
124
+ if (!state.lastPollAt) return false;
125
+ return Date.now() - state.lastPollAt < CHAT_POLL_FRESHNESS_MS;
126
+ }
127
+
128
+ function manualEditApplyChunkSize(env = process.env) {
129
+ const raw = Number(env.IMPECCABLE_LIVE_MANUAL_EDIT_CHUNK_SIZE);
130
+ if (!Number.isFinite(raw)) return DEFAULT_MANUAL_EDIT_APPLY_CHUNK_SIZE;
131
+ const size = Math.trunc(raw);
132
+ return Math.max(MIN_MANUAL_EDIT_APPLY_CHUNK_SIZE, Math.min(MAX_MANUAL_EDIT_APPLY_CHUNK_SIZE, size));
133
+ }
134
+
135
+ function countManualApplyOps(entriesOrBatch) {
136
+ const entries = Array.isArray(entriesOrBatch)
137
+ ? entriesOrBatch
138
+ : Array.isArray(entriesOrBatch?.entries) ? entriesOrBatch.entries : [];
139
+ let count = 0;
140
+ for (const entry of entries) count += Array.isArray(entry.ops) ? entry.ops.length : 0;
141
+ return count;
142
+ }
143
+
144
+ function pushApplyEventAndWait(batch, pageUrl, chunk = null, repair = null) {
145
+ const eventId = randomUUID().replace(/-/g, '').slice(0, 8);
146
+ const evidencePath = writeManualApplyEvidence(eventId, batch);
147
+ const event = {
148
+ type: 'manual_edit_apply',
149
+ id: eventId,
150
+ pageUrl,
151
+ batch: compactManualApplyBatch(batch),
152
+ evidencePath,
153
+ agentAction: buildManualApplyAgentAction(eventId),
154
+ schemaVersion: 1,
155
+ deadlineMs: APPLY_EVENT_SOFT_DEADLINE_MS,
156
+ };
157
+ if (chunk) event.chunk = chunk;
158
+ if (repair) event.repair = repair;
159
+ const rollbackSnapshot = snapshotApplyEventFiles(batch);
160
+ recordManualEditActivity('manual_edit_apply_dispatched', {
161
+ id: eventId,
162
+ pageUrl,
163
+ chunk,
164
+ repair,
165
+ entryCount: Array.isArray(batch.entries) ? batch.entries.length : 0,
166
+ opCount: countManualApplyOps(batch),
167
+ fileCount: collectManualApplyFiles(batch).length,
168
+ });
169
+ return new Promise((resolve, reject) => {
170
+ const timer = setTimeout(() => {
171
+ state.pendingApplyDeferreds.delete(eventId);
172
+ tombstoneTimedOutApplyId(eventId, { batch, rollbackSnapshot });
173
+ acknowledgePendingEvent(eventId);
174
+ removeManualApplyEvidence(evidencePath);
175
+ recordManualEditActivity('manual_edit_apply_timeout', {
176
+ id: eventId,
177
+ pageUrl,
178
+ chunk,
179
+ entryCount: Array.isArray(batch.entries) ? batch.entries.length : 0,
180
+ opCount: countManualApplyOps(batch),
181
+ });
182
+ reject(new Error('chat_agent_timeout'));
183
+ }, APPLY_EVENT_HARD_TIMEOUT_MS);
184
+ state.pendingApplyDeferreds.set(eventId, { resolve, reject, timer, event, batch, pageUrl, rollbackSnapshot });
185
+ enqueueEvent(event);
186
+ });
187
+ }
188
+
189
+ function writeManualApplyEvidence(eventId, batch) {
190
+ const dir = manualApplyEvidenceDir(process.cwd());
191
+ fs.mkdirSync(dir, { recursive: true });
192
+ const evidencePath = path.join(dir, `${eventId}.json`);
193
+ fs.writeFileSync(evidencePath, JSON.stringify(batch, null, 2) + '\n', 'utf-8');
194
+ return evidencePath;
195
+ }
196
+
197
+ function manualApplyEvidenceDir(cwd = process.cwd()) {
198
+ return path.join(getLiveDir(cwd), 'manual-edit-evidence');
199
+ }
200
+
201
+ function normalizeManualApplyEvidencePath(evidencePath, cwd = process.cwd()) {
202
+ if (!evidencePath || typeof evidencePath !== 'string') return null;
203
+ const fullPath = path.isAbsolute(evidencePath) ? evidencePath : path.resolve(cwd, evidencePath);
204
+ const evidenceDir = manualApplyEvidenceDir(cwd);
205
+ const relative = path.relative(evidenceDir, fullPath);
206
+ if (!relative || relative.startsWith('..') || path.isAbsolute(relative)) return null;
207
+ if (path.extname(relative) !== '.json') return null;
208
+ return fullPath;
209
+ }
210
+
211
+ function removeManualApplyEvidence(evidencePath, cwd = process.cwd()) {
212
+ const fullPath = normalizeManualApplyEvidencePath(evidencePath, cwd);
213
+ if (!fullPath) return false;
214
+ try {
215
+ fs.unlinkSync(fullPath);
216
+ return true;
217
+ } catch {
218
+ return false;
219
+ }
220
+ }
221
+
222
+ function referencedManualApplyEvidencePaths(cwd = process.cwd()) {
223
+ const referenced = new Set();
224
+ const add = (event) => {
225
+ const fullPath = normalizeManualApplyEvidencePath(event?.evidencePath, cwd);
226
+ if (fullPath) referenced.add(fullPath);
227
+ };
228
+ for (const entry of state.pendingEvents) add(entry.event);
229
+ for (const deferred of state.pendingApplyDeferreds.values()) add(deferred.event);
230
+ return referenced;
231
+ }
232
+
233
+ function pruneStaleManualApplyEvidence(cwd = process.cwd()) {
234
+ const dir = manualApplyEvidenceDir(cwd);
235
+ if (!fs.existsSync(dir)) return [];
236
+ const referenced = referencedManualApplyEvidencePaths(cwd);
237
+ const removed = [];
238
+ for (const name of fs.readdirSync(dir)) {
239
+ if (!name.endsWith('.json')) continue;
240
+ const fullPath = path.join(dir, name);
241
+ if (referenced.has(fullPath)) continue;
242
+ try {
243
+ fs.unlinkSync(fullPath);
244
+ removed.push(fullPath);
245
+ } catch {
246
+ // Stale evidence cleanup is best-effort; Apply verification never relies
247
+ // on deleting these files.
248
+ }
249
+ }
250
+ return removed;
251
+ }
252
+
253
+ function compactManualApplyBatch(batch = {}) {
254
+ const entries = (batch.entries || []).map(compactManualApplyEntry);
255
+ const candidates = compactManualApplyCandidates(batch.candidates || []);
256
+ return {
257
+ version: batch.version,
258
+ pageUrl: batch.pageUrl || null,
259
+ count: batch.count,
260
+ entries,
261
+ ops: entries.flatMap((entry) => entry.ops.map((op) => ({ ...op, entryId: entry.id }))),
262
+ candidates: candidates.length > 0 ? candidates : undefined,
263
+ context: batch.context ? {
264
+ bufferPath: batch.context.bufferPath,
265
+ totalEntries: batch.context.totalEntries,
266
+ totalOps: batch.context.totalOps,
267
+ chunkIndex: batch.context.chunkIndex,
268
+ chunkTotal: batch.context.chunkTotal,
269
+ totalApplyOps: batch.context.totalApplyOps,
270
+ } : undefined,
271
+ };
272
+ }
273
+
274
+ function compactManualApplyCandidates(candidates) {
275
+ return (Array.isArray(candidates) ? candidates : [])
276
+ .slice(0, 24)
277
+ .map((candidate) => ({
278
+ entryId: candidate.entryId,
279
+ ref: candidate.ref,
280
+ sourceHint: compactManualApplySourceMatch(candidate.sourceHint),
281
+ textMatches: compactManualApplySourceMatches(candidate.textMatches, 8),
282
+ objectKeyMatches: compactManualApplySourceMatches(candidate.objectKeyMatches, 8),
283
+ contextTextMatches: compactManualApplySourceMatches(candidate.contextTextMatches, 8),
284
+ locatorMatches: compactManualApplySourceMatches(candidate.locatorMatches, 6),
285
+ }));
286
+ }
287
+
288
+ function compactManualApplySourceMatches(matches, limit) {
289
+ return (Array.isArray(matches) ? matches : [])
290
+ .slice(0, limit)
291
+ .map(compactManualApplySourceMatch)
292
+ .filter(Boolean);
293
+ }
294
+
295
+ function compactManualApplySourceMatch(match) {
296
+ if (!match || typeof match !== 'object') return null;
297
+ const file = match.relativeFile || match.file;
298
+ if (!file && !match.line) return null;
299
+ return {
300
+ file: summarizeManualLogFile(file),
301
+ line: match.line || null,
302
+ column: match.column || null,
303
+ reason: match.reason || match.kind || undefined,
304
+ status: match.status || undefined,
305
+ };
306
+ }
307
+
308
+ function compactManualApplyEntry(entry = {}) {
309
+ return {
310
+ id: entry.id,
311
+ pageUrl: entry.pageUrl,
312
+ stagedAt: entry.stagedAt || null,
313
+ element: compactManualApplyContext(entry.element),
314
+ ops: (entry.ops || []).map(compactManualApplyOp),
315
+ };
316
+ }
317
+
318
+ function compactManualApplyOp(op = {}) {
319
+ return {
320
+ entryId: op.entryId,
321
+ ref: op.ref,
322
+ contextRef: op.contextRef,
323
+ tag: op.tag,
324
+ elementId: op.elementId,
325
+ classes: Array.isArray(op.classes) ? op.classes : [],
326
+ originalText: op.originalText,
327
+ newText: op.newText,
328
+ deleted: op.deleted === true || undefined,
329
+ sourceHint: op.sourceHint || null,
330
+ leaf: compactManualApplyContext(op.leaf),
331
+ nearbyEditableTexts: compactNearbyManualEditTexts(op.nearbyEditableTexts),
332
+ container: compactManualApplyContext(op.container),
333
+ contextHints: Array.isArray(op.contextHints) ? op.contextHints.slice(0, 8) : undefined,
334
+ };
335
+ }
336
+
337
+ function compactManualApplyContext(value) {
338
+ if (!value || typeof value !== 'object') return null;
339
+ return {
340
+ ref: value.ref,
341
+ tagName: value.tagName || value.tag || null,
342
+ id: value.id || null,
343
+ classes: Array.isArray(value.classes) ? value.classes : [],
344
+ textContent: truncateManualApplyText(value.textContent, MANUAL_APPLY_COMPACT_TEXT_LIMIT),
345
+ };
346
+ }
347
+
348
+ function compactNearbyManualEditTexts(items) {
349
+ return (Array.isArray(items) ? items : [])
350
+ .slice(0, MANUAL_APPLY_COMPACT_NEARBY_LIMIT)
351
+ .map((item) => typeof item === 'string' ? { text: truncateManualApplyText(item, MANUAL_APPLY_COMPACT_TEXT_LIMIT) } : {
352
+ ref: item?.ref,
353
+ tag: item?.tag,
354
+ classes: Array.isArray(item?.classes) ? item.classes : [],
355
+ text: truncateManualApplyText(item?.text, MANUAL_APPLY_COMPACT_TEXT_LIMIT),
356
+ });
357
+ }
358
+
359
+ function truncateManualApplyText(value, max) {
360
+ if (typeof value !== 'string') return value || null;
361
+ return value.length > max ? value.slice(0, max) : value;
362
+ }
363
+
364
+ async function pushApplyBatchInChunksAndWait(batch, pageUrl, context = {}) {
365
+ const repair = context?.repair || batch?.repair || null;
366
+ if (repair) return pushApplyEventAndWait(batch, pageUrl, null, repair);
367
+ const chunks = splitManualApplyBatch(batch, manualEditApplyChunkSize());
368
+ if (chunks.length <= 1) return pushApplyEventAndWait(batch, pageUrl);
369
+
370
+ const expectedOpsByEntry = new Map();
371
+ for (const entry of batch?.entries || []) {
372
+ expectedOpsByEntry.set(entry.id, Array.isArray(entry.ops) ? entry.ops.length : 0);
373
+ }
374
+
375
+ const appliedOpsByEntry = new Map();
376
+ const failedByEntry = new Map();
377
+ const files = new Set();
378
+ const notes = [];
379
+ let aborted = false;
380
+
381
+ for (const chunk of chunks) {
382
+ if (aborted) {
383
+ markChunkEntriesFailed(failedByEntry, chunk, 'manual_edit_chunk_aborted');
384
+ continue;
385
+ }
386
+
387
+ let result;
388
+ try {
389
+ result = normalizeApplyChunkResult(await pushApplyEventAndWait(chunk.batch, pageUrl, chunk.meta));
390
+ } catch (err) {
391
+ markChunkEntriesFailed(failedByEntry, chunk, err.message || 'chat_agent_error');
392
+ aborted = true;
393
+ continue;
394
+ }
395
+
396
+ for (const file of result.files) files.add(file);
397
+ notes.push(...result.notes);
398
+
399
+ const chunkFailedIds = new Set();
400
+ for (const item of result.failed) {
401
+ const entryId = item.entryId || item.id;
402
+ if (!entryId) continue;
403
+ chunkFailedIds.add(entryId);
404
+ if (!failedByEntry.has(entryId)) {
405
+ failedByEntry.set(entryId, {
406
+ entryId,
407
+ reason: item.reason || item.message || 'failed',
408
+ candidates: Array.isArray(item.candidates) ? item.candidates : [],
409
+ });
410
+ }
411
+ }
412
+
413
+ if (result.status === 'error') {
414
+ markChunkEntriesFailed(failedByEntry, chunk, result.message || firstFailureReason(result) || 'chat_agent_error');
415
+ aborted = true;
416
+ continue;
417
+ }
418
+
419
+ const reportedAppliedIds = new Set(result.appliedEntryIds);
420
+ for (const entryId of reportedAppliedIds) {
421
+ if (!chunk.entryIds.has(entryId) || chunkFailedIds.has(entryId)) continue;
422
+ appliedOpsByEntry.set(entryId, (appliedOpsByEntry.get(entryId) || 0) + (chunk.opCountsByEntry.get(entryId) || 0));
423
+ }
424
+
425
+ for (const entryId of chunk.entryIds) {
426
+ if (reportedAppliedIds.has(entryId) || chunkFailedIds.has(entryId)) continue;
427
+ if (!failedByEntry.has(entryId)) {
428
+ failedByEntry.set(entryId, { entryId, reason: 'not_reported_applied', candidates: [] });
429
+ }
430
+ }
431
+ }
432
+
433
+ const appliedEntryIds = [];
434
+ for (const [entryId, expectedOps] of expectedOpsByEntry.entries()) {
435
+ if (failedByEntry.has(entryId)) continue;
436
+ if ((appliedOpsByEntry.get(entryId) || 0) === expectedOps && expectedOps > 0) {
437
+ appliedEntryIds.push(entryId);
438
+ } else if (!failedByEntry.has(entryId)) {
439
+ failedByEntry.set(entryId, { entryId, reason: 'not_reported_applied', candidates: [] });
440
+ }
441
+ }
442
+
443
+ const failed = [...failedByEntry.values()];
444
+ return {
445
+ status: failed.length === 0 ? 'done' : appliedEntryIds.length > 0 ? 'partial' : 'error',
446
+ appliedEntryIds,
447
+ failed,
448
+ files: [...files],
449
+ notes,
450
+ };
451
+ }
452
+
453
+ function normalizeApplyChunkResult(result) {
454
+ const status = result?.status === 'partial' ? 'partial' : result?.status === 'error' ? 'error' : 'done';
455
+ return {
456
+ status,
457
+ message: typeof result?.message === 'string' ? result.message : null,
458
+ appliedEntryIds: Array.isArray(result?.appliedEntryIds) ? result.appliedEntryIds.filter((id) => typeof id === 'string') : [],
459
+ failed: Array.isArray(result?.failed) ? result.failed.filter(Boolean) : [],
460
+ files: Array.isArray(result?.files) ? result.files.filter((file) => typeof file === 'string') : [],
461
+ notes: Array.isArray(result?.notes) ? result.notes.filter((note) => typeof note === 'string') : [],
462
+ };
463
+ }
464
+
465
+ function manualApplyResultShapeHint(eventId = 'EVENT_ID') {
466
+ return `Use live-poll.mjs --reply ${eventId} done --data '{"status":"done","appliedEntryIds":["ENTRY_ID"],"failed":[],"files":["src/page.html"],"notes":[]}'`;
467
+ }
468
+
469
+ function invalidManualApplyResult(reason, eventId, extra = {}) {
470
+ return {
471
+ ok: false,
472
+ body: {
473
+ error: 'invalid_manual_apply_result',
474
+ reason,
475
+ hint: manualApplyResultShapeHint(eventId),
476
+ ...extra,
477
+ },
478
+ };
479
+ }
480
+
481
+ function validateManualApplyResultMessage(msg, deferred) {
482
+ let data = msg?.data;
483
+ const eventId = msg?.id || deferred?.event?.id || 'EVENT_ID';
484
+ if (!data || typeof data !== 'object' || Array.isArray(data)) {
485
+ return invalidManualApplyResult('missing_result_data', eventId);
486
+ }
487
+ if ('entries' in data || 'ops' in data) {
488
+ return invalidManualApplyResult('summary_result_not_allowed', eventId);
489
+ }
490
+ if (!['done', 'partial', 'error'].includes(data.status)) {
491
+ return invalidManualApplyResult('invalid_status', eventId, { status: data.status ?? null });
492
+ }
493
+
494
+ for (const key of ['appliedEntryIds', 'failed', 'files', 'notes']) {
495
+ if (!Array.isArray(data[key])) {
496
+ return invalidManualApplyResult(`${key}_must_be_array`, eventId);
497
+ }
498
+ }
499
+
500
+ for (const [index, value] of data.appliedEntryIds.entries()) {
501
+ if (typeof value !== 'string' || !value) {
502
+ return invalidManualApplyResult('appliedEntryIds_must_contain_strings', eventId, { index });
503
+ }
504
+ }
505
+ for (const [index, value] of data.files.entries()) {
506
+ if (typeof value !== 'string' || !value) {
507
+ return invalidManualApplyResult('files_must_contain_strings', eventId, { index });
508
+ }
509
+ }
510
+ for (const [index, value] of data.notes.entries()) {
511
+ if (typeof value !== 'string') {
512
+ return invalidManualApplyResult('notes_must_contain_strings', eventId, { index });
513
+ }
514
+ }
515
+ for (const [index, item] of data.failed.entries()) {
516
+ if (!item || typeof item !== 'object' || Array.isArray(item)) {
517
+ return invalidManualApplyResult('failed_must_contain_objects', eventId, { index });
518
+ }
519
+ if (typeof item.entryId !== 'string' || !item.entryId) {
520
+ return invalidManualApplyResult('failed_entryId_required', eventId, { index });
521
+ }
522
+ if (typeof item.reason !== 'string' || !item.reason) {
523
+ return invalidManualApplyResult('failed_reason_required', eventId, { index });
524
+ }
525
+ }
526
+
527
+ const eventEntryIds = new Set((deferred?.batch?.entries || []).map((entry) => entry.id).filter(Boolean));
528
+ for (const entryId of data.appliedEntryIds) {
529
+ if (eventEntryIds.size > 0 && !eventEntryIds.has(entryId)) {
530
+ return invalidManualApplyResult('applied_entry_id_not_in_event', eventId, { entryId });
531
+ }
532
+ }
533
+ for (const item of data.failed) {
534
+ if (eventEntryIds.size > 0 && !eventEntryIds.has(item.entryId)) {
535
+ return invalidManualApplyResult('failed_entry_id_not_in_event', eventId, { entryId: item.entryId });
536
+ }
537
+ }
538
+
539
+ if (data.status === 'done') {
540
+ if (data.failed.length > 0) {
541
+ return invalidManualApplyResult('done_result_has_failed_entries', eventId);
542
+ }
543
+ if (countManualApplyOps(deferred?.batch) > 0 && data.appliedEntryIds.length === 0) {
544
+ return invalidManualApplyResult('done_result_missing_applied_entry_ids', eventId);
545
+ }
546
+ }
547
+ if (data.status === 'partial' && data.appliedEntryIds.length === 0 && data.failed.length === 0) {
548
+ return invalidManualApplyResult('partial_result_has_no_entries', eventId);
549
+ }
550
+ if (data.status === 'error' && data.appliedEntryIds.length > 0) {
551
+ return invalidManualApplyResult('error_result_has_applied_entries', eventId);
552
+ }
553
+
554
+ return {
555
+ ok: true,
556
+ result: {
557
+ status: data.status,
558
+ message: typeof data.message === 'string' ? data.message : undefined,
559
+ appliedEntryIds: data.appliedEntryIds,
560
+ failed: data.failed,
561
+ files: data.files,
562
+ notes: data.notes,
563
+ },
564
+ };
565
+ }
566
+
567
+ function firstFailureReason(result) {
568
+ const first = Array.isArray(result?.failed) ? result.failed.find(Boolean) : null;
569
+ return first?.reason || first?.message || null;
570
+ }
571
+
572
+ function markChunkEntriesFailed(failedByEntry, chunk, reason) {
573
+ for (const entryId of chunk.entryIds) {
574
+ if (failedByEntry.has(entryId)) continue;
575
+ failedByEntry.set(entryId, { entryId, reason, candidates: [] });
576
+ }
577
+ }
578
+
579
+ function splitManualApplyBatch(batch, maxOps) {
580
+ const totalOpCount = countManualApplyOps(batch);
581
+ if (totalOpCount <= maxOps) {
582
+ return [{
583
+ batch,
584
+ meta: null,
585
+ entryIds: new Set((batch?.entries || []).map((entry) => entry.id).filter(Boolean)),
586
+ opCountsByEntry: new Map((batch?.entries || []).map((entry) => [entry.id, Array.isArray(entry.ops) ? entry.ops.length : 0])),
587
+ }];
588
+ }
589
+
590
+ const rawChunks = [];
591
+ let current = createManualApplyChunkBuilder();
592
+ for (const entry of batch?.entries || []) {
593
+ const ops = entry.ops || [];
594
+ if (ops.length <= maxOps) {
595
+ if (current.opCount > 0 && current.opCount + ops.length > maxOps) {
596
+ rawChunks.push(current);
597
+ current = createManualApplyChunkBuilder();
598
+ }
599
+ for (const op of ops) addOpToManualApplyChunk(current, entry, op);
600
+ continue;
601
+ }
602
+ if (current.opCount > 0) {
603
+ rawChunks.push(current);
604
+ current = createManualApplyChunkBuilder();
605
+ }
606
+ for (const op of ops) {
607
+ if (current.opCount >= maxOps) {
608
+ rawChunks.push(current);
609
+ current = createManualApplyChunkBuilder();
610
+ }
611
+ addOpToManualApplyChunk(current, entry, op);
612
+ }
613
+ }
614
+ if (current.opCount > 0) rawChunks.push(current);
615
+
616
+ return rawChunks.map((chunk, index) => ({
617
+ batch: {
618
+ ...batch,
619
+ count: chunk.opCount,
620
+ entries: chunk.entries,
621
+ ops: chunk.ops,
622
+ candidates: filterManualApplyChunkCandidates(batch, chunk.refsByEntry),
623
+ context: {
624
+ ...(batch?.context || {}),
625
+ totalEntries: chunk.entries.length,
626
+ totalOps: chunk.opCount,
627
+ chunkIndex: index + 1,
628
+ chunkTotal: rawChunks.length,
629
+ totalApplyOps: totalOpCount,
630
+ },
631
+ },
632
+ meta: {
633
+ index: index + 1,
634
+ total: rawChunks.length,
635
+ opCount: chunk.opCount,
636
+ totalOpCount,
637
+ },
638
+ entryIds: new Set(chunk.entries.map((entry) => entry.id).filter(Boolean)),
639
+ opCountsByEntry: chunk.opCountsByEntry,
640
+ }));
641
+ }
642
+
643
+ function createManualApplyChunkBuilder() {
644
+ return {
645
+ entries: [],
646
+ entryById: new Map(),
647
+ entryIds: new Set(),
648
+ ops: [],
649
+ refsByEntry: new Map(),
650
+ opCountsByEntry: new Map(),
651
+ opCount: 0,
652
+ };
653
+ }
654
+
655
+ function addOpToManualApplyChunk(chunk, entry, op) {
656
+ let chunkEntry = chunk.entryById.get(entry.id);
657
+ if (!chunkEntry) {
658
+ chunkEntry = { ...entry, ops: [] };
659
+ chunk.entryById.set(entry.id, chunkEntry);
660
+ chunk.entryIds.add(entry.id);
661
+ chunk.entries.push(chunkEntry);
662
+ }
663
+ chunkEntry.ops.push(op);
664
+ chunk.ops.push({ ...op, entryId: op.entryId || entry.id });
665
+ if (!chunk.refsByEntry.has(entry.id)) chunk.refsByEntry.set(entry.id, new Set());
666
+ if (op.ref) chunk.refsByEntry.get(entry.id).add(op.ref);
667
+ chunk.opCountsByEntry.set(entry.id, (chunk.opCountsByEntry.get(entry.id) || 0) + 1);
668
+ chunk.opCount += 1;
669
+ }
670
+
671
+ function filterManualApplyChunkCandidates(batch, refsByEntry) {
672
+ return (batch?.candidates || []).filter((candidate) => {
673
+ const refs = refsByEntry.get(candidate.entryId);
674
+ if (!refs) return false;
675
+ if (!candidate.ref) return true;
676
+ return refs.has(candidate.ref);
677
+ });
678
+ }
679
+
680
+ function resolveApplyDeferred(eventId, body) {
681
+ const deferred = state.pendingApplyDeferreds.get(eventId);
682
+ if (!deferred) return false;
683
+ state.pendingApplyDeferreds.delete(eventId);
684
+ clearTimeout(deferred.timer);
685
+ removeManualApplyEvidence(deferred.event?.evidencePath);
686
+ deferred.resolve(body);
687
+ return true;
688
+ }
689
+
690
+ function rejectApplyDeferred(eventId, reason) {
691
+ const deferred = state.pendingApplyDeferreds.get(eventId);
692
+ if (!deferred) return false;
693
+ state.pendingApplyDeferreds.delete(eventId);
694
+ clearTimeout(deferred.timer);
695
+ removeManualApplyEvidence(deferred.event?.evidencePath);
696
+ deferred.reject(new Error(reason || 'chat_agent_error'));
697
+ return true;
698
+ }
699
+
700
+ function snapshotApplyEventFiles(batch) {
701
+ const snapshot = new Map();
702
+ for (const relativeFile of collectManualApplyFiles(batch)) {
703
+ const absolute = path.resolve(process.cwd(), relativeFile);
704
+ try {
705
+ snapshot.set(relativeFile, {
706
+ exists: fs.existsSync(absolute),
707
+ content: fs.existsSync(absolute) ? fs.readFileSync(absolute, 'utf-8') : '',
708
+ });
709
+ } catch {
710
+ // If a file cannot be read before dispatch, do not attempt late rollback.
711
+ }
712
+ }
713
+ return snapshot;
714
+ }
715
+
716
+ function manualApplyTransactionPath(cwd = process.cwd()) {
717
+ return path.join(getLiveDir(cwd), 'manual-edit-apply-transaction.json');
718
+ }
719
+
720
+ function readManualApplyTransaction(cwd = process.cwd()) {
721
+ const file = manualApplyTransactionPath(cwd);
722
+ if (!fs.existsSync(file)) return null;
723
+ try {
724
+ return JSON.parse(fs.readFileSync(file, 'utf-8'));
725
+ } catch {
726
+ return null;
727
+ }
728
+ }
729
+
730
+ function writeManualApplyTransaction({ cwd = process.cwd(), pageUrl = null, batch }) {
731
+ const file = manualApplyTransactionPath(cwd);
732
+ const files = collectManualApplyFiles(batch);
733
+ const transaction = {
734
+ version: 1,
735
+ id: randomUUID().replace(/-/g, '').slice(0, 8),
736
+ createdAt: new Date().toISOString(),
737
+ pageUrl,
738
+ entryIds: (batch?.entries || []).map((entry) => entry.id).filter(Boolean),
739
+ files: files.map((relativeFile) => {
740
+ const absolute = path.resolve(cwd, relativeFile);
741
+ const exists = fs.existsSync(absolute);
742
+ return {
743
+ file: relativeFile,
744
+ exists,
745
+ content: exists ? fs.readFileSync(absolute, 'utf-8') : '',
746
+ };
747
+ }),
748
+ };
749
+ fs.mkdirSync(path.dirname(file), { recursive: true });
750
+ fs.writeFileSync(`${file}.tmp`, JSON.stringify(transaction, null, 2) + '\n', 'utf-8');
751
+ fs.renameSync(`${file}.tmp`, file);
752
+ return transaction;
753
+ }
754
+
755
+ function clearManualApplyTransaction(cwd = process.cwd(), transactionId = null) {
756
+ const file = manualApplyTransactionPath(cwd);
757
+ if (!fs.existsSync(file)) return false;
758
+ if (transactionId) {
759
+ const existing = readManualApplyTransaction(cwd);
760
+ if (existing?.id && existing.id !== transactionId) return false;
761
+ }
762
+ try {
763
+ fs.unlinkSync(file);
764
+ return true;
765
+ } catch {
766
+ return false;
767
+ }
768
+ }
769
+
770
+ function rollbackManualApplyTransaction({ cwd = process.cwd(), pageUrl = null, reason = 'manual_edit_transaction_rollback' } = {}) {
771
+ const transaction = readManualApplyTransaction(cwd);
772
+ if (!transaction) return null;
773
+ if (pageUrl && transaction.pageUrl && transaction.pageUrl !== pageUrl) return null;
774
+
775
+ let pendingIds = new Set();
776
+ try {
777
+ const buffer = readManualEditsBuffer(cwd);
778
+ pendingIds = new Set((buffer.entries || []).map((entry) => entry.id).filter(Boolean));
779
+ } catch {
780
+ pendingIds = new Set(transaction.entryIds || []);
781
+ }
782
+ const shouldRollback = (transaction.entryIds || []).some((id) => pendingIds.has(id));
783
+ if (!shouldRollback) {
784
+ clearManualApplyTransaction(cwd, transaction.id);
785
+ return { id: transaction.id, reason, rolledBackFiles: [], rollbackFailures: [], skipped: 'entries_not_pending' };
786
+ }
787
+
788
+ const rolledBackFiles = [];
789
+ const rollbackFailures = [];
790
+ for (const item of transaction.files || []) {
791
+ const relativeFile = normalizeProjectFile(item.file);
792
+ if (!relativeFile) continue;
793
+ const absolute = path.resolve(cwd, relativeFile);
794
+ try {
795
+ if (item.exists) {
796
+ fs.mkdirSync(path.dirname(absolute), { recursive: true });
797
+ fs.writeFileSync(absolute, item.content || '', 'utf-8');
798
+ } else if (fs.existsSync(absolute)) {
799
+ fs.rmSync(absolute);
800
+ }
801
+ rolledBackFiles.push(relativeFile);
802
+ } catch (err) {
803
+ rollbackFailures.push({ file: relativeFile, reason: 'restore_failed', message: err.message || String(err) });
804
+ }
805
+ }
806
+ clearManualApplyTransaction(cwd, transaction.id);
807
+ recordManualEditActivity('manual_edit_transaction_rolled_back', {
808
+ id: transaction.id,
809
+ pageUrl: transaction.pageUrl || null,
810
+ reason,
811
+ entryIds: transaction.entryIds || [],
812
+ rolledBackFiles: rolledBackFiles.map(summarizeManualLogFile).filter(Boolean),
813
+ rollbackFailures: summarizeManualDiagnostics(rollbackFailures),
814
+ });
815
+ return { id: transaction.id, reason, rolledBackFiles, rollbackFailures };
816
+ }
817
+
818
+ function collectManualApplyFiles(batch, extraFiles = []) {
819
+ const files = [];
820
+ for (const entry of batch?.entries || []) {
821
+ for (const op of entry.ops || []) files.push(op.sourceHint?.file);
822
+ }
823
+ for (const candidate of batch?.candidates || []) {
824
+ files.push(candidate.sourceHint?.relativeFile, candidate.sourceHint?.file);
825
+ for (const item of candidate.textMatches || []) files.push(item.file);
826
+ for (const item of candidate.objectKeyMatches || []) files.push(item.file);
827
+ for (const item of candidate.locatorMatches || []) files.push(item.file);
828
+ for (const item of candidate.contextTextMatches || []) files.push(item.file);
829
+ }
830
+ files.push(...(extraFiles || []));
831
+ return [...new Set(files)]
832
+ .map((file) => normalizeProjectFile(file))
833
+ .filter(Boolean);
834
+ }
835
+
836
+ function normalizeProjectFile(file) {
837
+ if (!file || typeof file !== 'string') return null;
838
+ const absolute = path.isAbsolute(file) ? file : path.resolve(process.cwd(), file);
839
+ const relative = path.relative(process.cwd(), absolute);
840
+ if (!relative || relative.startsWith('..') || path.isAbsolute(relative)) return null;
841
+ return relative;
842
+ }
843
+
844
+ function rollbackApplySnapshot(batch, rollbackSnapshot, extraFiles = [], reason = 'manual_edit_apply_snapshot_rollback') {
845
+ const scope = collectManualApplyFiles(batch, extraFiles);
846
+ const rolledBackFiles = [];
847
+ const rollbackFailures = [];
848
+ for (const relativeFile of scope) {
849
+ const before = rollbackSnapshot?.get(relativeFile);
850
+ if (!before) continue;
851
+ const absolute = path.resolve(process.cwd(), relativeFile);
852
+ try {
853
+ if (before.exists) {
854
+ fs.mkdirSync(path.dirname(absolute), { recursive: true });
855
+ fs.writeFileSync(absolute, before.content, 'utf-8');
856
+ } else if (fs.existsSync(absolute)) {
857
+ fs.rmSync(absolute);
858
+ }
859
+ rolledBackFiles.push(relativeFile);
860
+ } catch (err) {
861
+ rollbackFailures.push({ file: relativeFile, reason: 'restore_failed', message: err.message || String(err) });
862
+ }
863
+ }
864
+ return { rolledBackFiles, rollbackFailures };
865
+ }
866
+
867
+ function rollbackTimedOutApplyReply(msg) {
868
+ const details = state.timedOutApplyIds.get(msg.id);
869
+ if (!details) return { rolledBackFiles: [], rollbackFailures: [] };
870
+ state.timedOutApplyIds.delete(msg.id);
871
+ return rollbackApplySnapshot(details.batch, details.rollbackSnapshot, msg.data?.files || [], 'stale_manual_edit_apply_reply');
872
+ }
873
+
874
+ // Cap per-annotation upload size. A full 1920×1080 PNG is typically <1 MB;
875
+ // cap at 10 MB to guard against runaway writes from a misbehaving client.
876
+ const MAX_ANNOTATION_BYTES = 10 * 1024 * 1024;
877
+
878
+ function enqueueEvent(event) {
879
+ if (!event || (event.id && state.pendingEvents.some((entry) => entry.event?.id === event.id && entry.event?.type === event.type))) return;
880
+ state.pendingEvents.push({ event, leaseUntil: 0, seq: state.nextEventSeq++ });
881
+ flushPendingPolls();
882
+ }
883
+
884
+ function restorePendingEventsFromStore() {
885
+ if (!state.sessionStore) return;
886
+ for (const snapshot of state.sessionStore.listActiveSessions()) {
887
+ if (snapshot.pendingEvent) enqueueEvent(snapshot.pendingEvent);
888
+ }
889
+ }
890
+
891
+ function findAvailablePendingEvent(now = Date.now()) {
892
+ for (const entry of state.pendingEvents) {
893
+ if (entry.leaseUntil && entry.leaseUntil > now) continue;
894
+ return entry;
895
+ }
896
+ return null;
897
+ }
898
+
899
+ function leaseEvent(entry, leaseMs) {
900
+ if (!entry.event?.id) {
901
+ const idx = state.pendingEvents.indexOf(entry);
902
+ if (idx !== -1) state.pendingEvents.splice(idx, 1);
903
+ return entry.event;
904
+ }
905
+ entry.leaseUntil = Date.now() + leaseMs;
906
+ scheduleLeaseFlush();
907
+ broadcastAgentPollingIfChanged();
908
+ return entry.event;
909
+ }
910
+
911
+ function acknowledgePendingEvent(id) {
912
+ if (!id) return false;
913
+ const idx = state.pendingEvents.findIndex((entry) => entry.event?.id === id);
914
+ if (idx === -1) return false;
915
+ const acknowledged = state.pendingEvents[idx].event;
916
+ state.pendingEvents.splice(idx, 1);
917
+ scheduleLeaseFlush();
918
+ broadcastAgentPollingIfChanged();
919
+ return acknowledged;
920
+ }
921
+
922
+ function findPendingEventById(id) {
923
+ if (!id) return null;
924
+ const entry = state.pendingEvents.find((item) => item.event?.id === id);
925
+ return entry?.event || null;
926
+ }
927
+
928
+ function manualApplyReplyCommand(eventOrId = 'EVENT_ID') {
929
+ const id = typeof eventOrId === 'string' ? eventOrId : eventOrId?.id || 'EVENT_ID';
930
+ return `live-poll.mjs --reply ${id} done --data '<json>'`;
931
+ }
932
+
933
+ function buildManualApplyAgentAction(eventOrId = 'EVENT_ID') {
934
+ return {
935
+ kind: 'manual_edit_apply',
936
+ required: 'apply_source_edits_then_reply',
937
+ replyCommand: manualApplyReplyCommand(eventOrId),
938
+ warning: 'Polling only leases this work item; it does not commit source edits.',
939
+ };
940
+ }
941
+
942
+ function summarizeManualApplyEvent(event = {}, batch = event.batch) {
943
+ const entries = Array.isArray(batch?.entries) ? batch.entries : [];
944
+ const opCount = entries.reduce((sum, entry) => sum + (Array.isArray(entry.ops) ? entry.ops.length : 0), 0);
945
+ return {
946
+ pageUrl: event.pageUrl || null,
947
+ chunk: event.chunk || null,
948
+ entryCount: entries.length,
949
+ opCount,
950
+ files: collectManualApplyFiles(batch),
951
+ };
952
+ }
953
+
954
+ function summarizePendingEventForStatus(entry) {
955
+ const event = entry.event || {};
956
+ const summary = {
957
+ id: event.id,
958
+ type: event.type,
959
+ leased: !!(entry.leaseUntil && entry.leaseUntil > Date.now()),
960
+ leaseUntil: entry.leaseUntil || null,
961
+ };
962
+ if (event.type === 'manual_edit_apply') {
963
+ summary.pageUrl = event.pageUrl || null;
964
+ summary.chunk = event.chunk || null;
965
+ summary.repair = event.repair || null;
966
+ summary.evidencePath = event.evidencePath || null;
967
+ summary.agentAction = event.agentAction || buildManualApplyAgentAction(event);
968
+ summary.manualApplySummary = summarizeManualApplyEvent(event, state.pendingApplyDeferreds.get(event.id)?.batch || event.batch);
969
+ }
970
+ return summary;
971
+ }
972
+
973
+ function summarizeActiveSessionForClient(snapshot = {}) {
974
+ return {
975
+ id: snapshot.id,
976
+ phase: snapshot.phase,
977
+ pageUrl: snapshot.pageUrl ?? null,
978
+ sourceFile: snapshot.sourceFile ?? null,
979
+ previewFile: snapshot.previewFile ?? null,
980
+ previewMode: snapshot.previewMode ?? null,
981
+ expectedVariants: snapshot.expectedVariants ?? 0,
982
+ arrivedVariants: snapshot.arrivedVariants ?? 0,
983
+ visibleVariant: snapshot.visibleVariant ?? null,
984
+ checkpointRevision: snapshot.checkpointRevision ?? 0,
985
+ paramValues: snapshot.paramValues || {},
986
+ };
987
+ }
988
+
989
+ function activeSessionSummaries() {
990
+ if (!state.sessionStore) return [];
991
+ return state.sessionStore.listActiveSessions().map((snapshot) => summarizeActiveSessionForClient(snapshot));
992
+ }
993
+
994
+ function cancelQueuedAnonymousExitEvents() {
995
+ let removed = 0;
996
+ for (let i = state.pendingEvents.length - 1; i >= 0; i -= 1) {
997
+ const event = state.pendingEvents[i]?.event;
998
+ if (event?.type !== 'exit' || event.id) continue;
999
+ state.pendingEvents.splice(i, 1);
1000
+ removed += 1;
1001
+ }
1002
+ if (removed > 0) {
1003
+ scheduleLeaseFlush();
1004
+ broadcastAgentPollingIfChanged();
1005
+ }
1006
+ return removed;
1007
+ }
1008
+
1009
+ function cancelPendingManualApplyEvents(pageUrl, reason = 'manual_edit_discarded') {
1010
+ const canceledById = new Map();
1011
+ const shouldCancel = (event) => event?.type === 'manual_edit_apply' && (!pageUrl || event.pageUrl === pageUrl);
1012
+
1013
+ for (let i = state.pendingEvents.length - 1; i >= 0; i -= 1) {
1014
+ const event = state.pendingEvents[i]?.event;
1015
+ if (!shouldCancel(event)) continue;
1016
+ state.pendingEvents.splice(i, 1);
1017
+ removeManualApplyEvidence(event.evidencePath);
1018
+ canceledById.set(event.id, {
1019
+ id: event.id,
1020
+ pageUrl: event.pageUrl,
1021
+ entryCount: event.batch?.entries?.length || 0,
1022
+ });
1023
+ }
1024
+
1025
+ for (const [eventId, deferred] of [...state.pendingApplyDeferreds.entries()]) {
1026
+ if (!shouldCancel(deferred.event)) continue;
1027
+ state.pendingApplyDeferreds.delete(eventId);
1028
+ clearTimeout(deferred.timer);
1029
+ const rollback = rollbackApplySnapshot(deferred.batch, deferred.rollbackSnapshot, [], reason);
1030
+ tombstoneTimedOutApplyId(eventId, {
1031
+ batch: deferred.batch,
1032
+ rollbackSnapshot: deferred.rollbackSnapshot,
1033
+ reason,
1034
+ });
1035
+ removeManualApplyEvidence(deferred.event?.evidencePath);
1036
+ canceledById.set(eventId, {
1037
+ id: eventId,
1038
+ pageUrl: deferred.pageUrl,
1039
+ entryCount: deferred.batch?.entries?.length || 0,
1040
+ rolledBackFiles: rollback.rolledBackFiles,
1041
+ rollbackFailures: rollback.rollbackFailures,
1042
+ });
1043
+ deferred.reject(new Error(reason));
1044
+ }
1045
+
1046
+ if (canceledById.size > 0) flushPendingPolls();
1047
+ return [...canceledById.values()];
1048
+ }
1049
+
1050
+ function scheduleLeaseFlush() {
1051
+ if (state.leaseTimer) {
1052
+ clearTimeout(state.leaseTimer);
1053
+ state.leaseTimer = null;
1054
+ }
1055
+ const now = Date.now();
1056
+ const nextLeaseUntil = state.pendingEvents
1057
+ .map((entry) => entry.leaseUntil || 0)
1058
+ .filter((leaseUntil) => leaseUntil > now)
1059
+ .sort((a, b) => a - b)[0];
1060
+ if (!nextLeaseUntil) return;
1061
+ state.leaseTimer = setTimeout(() => {
1062
+ state.leaseTimer = null;
1063
+ flushPendingPolls();
1064
+ broadcastAgentPollingIfChanged();
1065
+ }, Math.max(0, nextLeaseUntil - now + POLL_LEASE_EXPIRY_TIMER_GRACE_MS));
1066
+ }
1067
+
1068
+ function flushPendingPolls() {
1069
+ let changed = false;
1070
+ while (state.pendingPolls.length > 0) {
1071
+ const entry = findAvailablePendingEvent();
1072
+ if (!entry) {
1073
+ scheduleLeaseFlush();
1074
+ broadcastAgentPollingIfChanged();
1075
+ return;
1076
+ }
1077
+ const poll = state.pendingPolls.shift();
1078
+ poll.resolve(leaseEvent(entry, poll.leaseMs));
1079
+ changed = true;
1080
+ }
1081
+ scheduleLeaseFlush();
1082
+ if (changed) broadcastAgentPollingIfChanged();
1083
+ }
1084
+
1085
+ function agentPollingConnected() {
1086
+ const now = Date.now();
1087
+ return state.pendingPolls.length > 0
1088
+ || state.pendingEvents.some((entry) => entry.leaseUntil && entry.leaseUntil > now);
1089
+ }
1090
+
1091
+ function broadcastAgentPollingIfChanged() {
1092
+ const connected = agentPollingConnected();
1093
+ if (state.lastAgentPollingBroadcast === connected) return;
1094
+ state.lastAgentPollingBroadcast = connected;
1095
+ broadcast({ type: 'agent_polling', connected });
1096
+ }
1097
+
1098
+ /** Push a message to all connected SSE clients. */
1099
+ function broadcast(msg) {
1100
+ const data = 'data: ' + JSON.stringify(msg) + '\n\n';
1101
+ for (const res of state.sseClients) {
1102
+ try { res.write(data); } catch { /* client gone */ }
1103
+ }
1104
+ }
1105
+
1106
+ function recordManualEditActivity(type, details = {}) {
1107
+ const entry = {
1108
+ seq: state.nextManualEditSeq++,
1109
+ type,
1110
+ ts: new Date().toISOString(),
1111
+ ...details,
1112
+ };
1113
+ state.manualEditActivity = entry;
1114
+ if (DEBUG_MANUAL_EDIT_EVENTS) {
1115
+ try {
1116
+ const filePath = path.join(getLiveDir(process.cwd()), 'manual-edit-events.jsonl');
1117
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
1118
+ fs.appendFileSync(filePath, JSON.stringify(entry) + '\n');
1119
+ } catch {
1120
+ /* diagnostics are best-effort; never block live mode on observability */
1121
+ }
1122
+ }
1123
+ broadcast(entry);
1124
+ return entry;
1125
+ }
1126
+
1127
+ function getManualEditStatus() {
1128
+ try {
1129
+ const { totalCount, perPage } = countPendingByPage(process.cwd());
1130
+ return { totalCount, perPage, lastActivity: state.manualEditActivity };
1131
+ } catch (err) {
1132
+ return {
1133
+ totalCount: null,
1134
+ perPage: {},
1135
+ lastActivity: state.manualEditActivity,
1136
+ error: err.message,
1137
+ };
1138
+ }
1139
+ }
1140
+
1141
+ function summarizePendingManualEditBatch(pageUrl = null) {
1142
+ try {
1143
+ const buffer = readManualEditsBuffer(process.cwd());
1144
+ const entries = (buffer.entries || [])
1145
+ .filter((entry) => !pageUrl || entry.pageUrl === pageUrl);
1146
+ return {
1147
+ pendingEntryCount: entries.length,
1148
+ pendingOpCount: entries.reduce((sum, entry) => sum + (entry.ops?.length || 0), 0),
1149
+ };
1150
+ } catch (err) {
1151
+ return { pendingSummaryError: err.message || String(err) };
1152
+ }
1153
+ }
1154
+
1155
+ function summarizeManualApplyFailures(failed) {
1156
+ if (!Array.isArray(failed)) return [];
1157
+ return failed.slice(0, 20).map((item) => ({
1158
+ id: item.id || item.entryId || null,
1159
+ reason: item.reason || item.message || 'failed',
1160
+ message: compactManualLogText(item.message, 300),
1161
+ files: Array.isArray(item.files) ? item.files.slice(0, 12).map(summarizeManualLogFile).filter(Boolean) : undefined,
1162
+ checks: summarizeManualDiagnostics(item.checks),
1163
+ failures: summarizeManualDiagnostics(item.failures),
1164
+ candidates: summarizeManualDiagnostics(item.candidates),
1165
+ }));
1166
+ }
1167
+
1168
+ function summarizeManualDiagnostics(items) {
1169
+ if (!Array.isArray(items) || items.length === 0) return undefined;
1170
+ return items.slice(0, 12).map((item) => ({
1171
+ reason: item.reason || item.kind || undefined,
1172
+ detail: compactManualLogText(item.detail, 220),
1173
+ message: compactManualLogText(item.message, 300),
1174
+ file: summarizeManualLogFile(item.file || item.relativeFile),
1175
+ line: item.line || undefined,
1176
+ ref: compactManualLogText(item.ref, 180),
1177
+ marker: compactManualLogText(item.marker, 120),
1178
+ files: Array.isArray(item.files) ? item.files.slice(0, 8).map(summarizeManualLogFile).filter(Boolean) : undefined,
1179
+ }));
1180
+ }
1181
+
1182
+ function summarizeManualLogFile(file) {
1183
+ if (!file || typeof file !== 'string') return undefined;
1184
+ if (!path.isAbsolute(file)) return file;
1185
+ const relative = path.relative(process.cwd(), file);
1186
+ return relative && !relative.startsWith('..') && !path.isAbsolute(relative) ? relative : file;
1187
+ }
1188
+
1189
+ function compactManualLogText(value, max = 200) {
1190
+ if (typeof value !== 'string') return undefined;
1191
+ const normalized = value.replace(/\s+/g, ' ').trim();
1192
+ if (normalized.length <= max) return normalized;
1193
+ return normalized.slice(0, max) + `... [truncated ${normalized.length - max} chars]`;
1194
+ }
1195
+
1196
+ // ---------------------------------------------------------------------------
1197
+ // Load scripts
1198
+ // ---------------------------------------------------------------------------
1199
+
1200
+ function loadBrowserScripts() {
1201
+ // Detection script: prefer the skill-bundled detector, then fall back to
1202
+ // source/npm package locations for local development and older installs.
1203
+ // This one IS cached — detect.js rarely changes during a session.
1204
+ const detectPaths = [
1205
+ path.join(__dirname, 'detector', 'detect-antipatterns-browser.js'),
1206
+ path.join(__dirname, '..', '..', 'cli', 'engine', 'detect-antipatterns-browser.js'),
1207
+ path.join(__dirname, '..', '..', '..', '..', 'cli', 'engine', 'detect-antipatterns-browser.js'),
1208
+ path.join(process.cwd(), 'node_modules', 'impeccable', 'cli', 'engine', 'detect-antipatterns-browser.js'),
1209
+ ];
1210
+ let detectScript = '';
1211
+ for (const p of detectPaths) {
1212
+ try { detectScript = fs.readFileSync(p, 'utf-8'); break; } catch { /* try next */ }
1213
+ }
1214
+
1215
+ // live-browser.js: DO NOT cache. Return the path so the /live.js handler
1216
+ // can re-read on every request. Editing the browser script during iteration
1217
+ // should land on the next tab reload, not require a server restart.
1218
+ const sessionPath = path.join(__dirname, 'live-browser-session.js');
1219
+ const livePath = path.join(__dirname, 'live-browser.js');
1220
+ for (const p of [sessionPath, livePath]) {
1221
+ if (!fs.existsSync(p)) {
1222
+ process.stderr.write('Error: live browser script not found at ' + p + '\n');
1223
+ process.exit(1);
1224
+ }
1225
+ }
1226
+
1227
+ return { detectScript, sessionPath, livePath };
1228
+ }
1229
+
1230
+ function hasProjectContext() {
1231
+ // PRODUCT.md carries brand voice / anti-references — that's what determines
1232
+ // whether variants are brand-aware. DESIGN.md (visual tokens) is a separate
1233
+ // concern, surfaced by the design panel's own empty state.
1234
+ try {
1235
+ fs.accessSync(path.join(CONTEXT_DIR, 'PRODUCT.md'), fs.constants.R_OK);
1236
+ return true;
1237
+ } catch { return false; }
1238
+ }
1239
+
1240
+ function statOrNull(filePath) {
1241
+ try { return fs.statSync(filePath); } catch { return null; }
1242
+ }
1243
+
1244
+ // HTTP request handler
1245
+ // ---------------------------------------------------------------------------
1246
+
1247
+ function createRequestHandler({ detectScript, sessionPath, livePath }) {
1248
+ return (req, res) => {
1249
+ const url = new URL(req.url, `http://localhost:${state.port}`);
1250
+ res.setHeader('Access-Control-Allow-Origin', '*');
1251
+ res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
1252
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
1253
+ if (req.method === 'OPTIONS') { res.writeHead(204); res.end(); return; }
1254
+
1255
+ const p = url.pathname;
1256
+
1257
+ // --- Scripts ---
1258
+ if (p === '/live.js') {
1259
+ // Re-read from disk each request so edits to live-browser.js land on
1260
+ // the next tab reload. No-store headers prevent browser caching across
1261
+ // sessions — during iteration, a cached old script silently breaks
1262
+ // every subsequent session.
1263
+ let sessionScript;
1264
+ let liveScript;
1265
+ try {
1266
+ sessionScript = fs.readFileSync(sessionPath, 'utf-8');
1267
+ liveScript = fs.readFileSync(livePath, 'utf-8');
1268
+ } catch (err) {
1269
+ res.writeHead(500, { 'Content-Type': 'text/plain' });
1270
+ res.end('Error reading live browser scripts: ' + err.message);
1271
+ return;
1272
+ }
1273
+ const body =
1274
+ `window.__IMPECCABLE_TOKEN__ = '${state.token}';\n` +
1275
+ `window.__IMPECCABLE_PORT__ = ${state.port};\n` +
1276
+ // Canonical command vocabulary (values + labels + icons). live-browser.js
1277
+ // builds its action picker from this instead of an inline copy.
1278
+ `window.__IMPECCABLE_VOCAB__ = ${JSON.stringify(LIVE_COMMANDS)};\n` +
1279
+ sessionScript + '\n' +
1280
+ liveScript;
1281
+ res.writeHead(200, {
1282
+ 'Content-Type': 'application/javascript',
1283
+ 'Cache-Control': 'no-store, no-cache, must-revalidate, max-age=0',
1284
+ 'Pragma': 'no-cache',
1285
+ });
1286
+ res.end(body);
1287
+ return;
1288
+ }
1289
+ if (p === '/detect.js' || p === '/') {
1290
+ if (!detectScript) { res.writeHead(404); res.end('Not available'); return; }
1291
+ res.writeHead(200, { 'Content-Type': 'application/javascript' });
1292
+ res.end(detectScript);
1293
+ return;
1294
+ }
1295
+
1296
+ // --- Vendored modern-screenshot (UMD build) ---
1297
+ // Lazy-loaded by live.js when the user clicks Go; exposes
1298
+ // window.modernScreenshot.domToBlob(...) for capture.
1299
+ if (p === '/modern-screenshot.js') {
1300
+ const vendorPath = path.join(__dirname, 'modern-screenshot.umd.js');
1301
+ try {
1302
+ res.writeHead(200, {
1303
+ 'Content-Type': 'application/javascript',
1304
+ 'Cache-Control': 'public, max-age=31536000, immutable',
1305
+ });
1306
+ res.end(fs.readFileSync(vendorPath));
1307
+ } catch {
1308
+ res.writeHead(404); res.end('Vendor script not found');
1309
+ }
1310
+ return;
1311
+ }
1312
+
1313
+ // --- Annotation upload (browser → server, raw PNG body) ---
1314
+ // Client generates the eventId, POSTs the PNG, then POSTs the generate
1315
+ // event with screenshotPath already set. Keeps bytes out of the SSE/poll
1316
+ // bridge and preserves the "one shot from the user's POV" UX.
1317
+ if (p === '/annotation' && req.method === 'POST') {
1318
+ const token = url.searchParams.get('token');
1319
+ if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
1320
+ const eventId = url.searchParams.get('eventId');
1321
+ if (!eventId || !/^[A-Za-z0-9_-]{1,64}$/.test(eventId)) {
1322
+ res.writeHead(400, { 'Content-Type': 'application/json' });
1323
+ res.end(JSON.stringify({ error: 'Invalid eventId' }));
1324
+ return;
1325
+ }
1326
+ if ((req.headers['content-type'] || '').toLowerCase() !== 'image/png') {
1327
+ res.writeHead(415, { 'Content-Type': 'application/json' });
1328
+ res.end(JSON.stringify({ error: 'Content-Type must be image/png' }));
1329
+ return;
1330
+ }
1331
+ if (!state.sessionDir) {
1332
+ res.writeHead(500, { 'Content-Type': 'application/json' });
1333
+ res.end(JSON.stringify({ error: 'Session dir unavailable' }));
1334
+ return;
1335
+ }
1336
+ const chunks = [];
1337
+ let total = 0;
1338
+ let aborted = false;
1339
+ req.on('data', (c) => {
1340
+ if (aborted) return;
1341
+ total += c.length;
1342
+ if (total > MAX_ANNOTATION_BYTES) {
1343
+ aborted = true;
1344
+ res.writeHead(413, { 'Content-Type': 'application/json' });
1345
+ res.end(JSON.stringify({ error: 'Payload too large' }));
1346
+ req.destroy();
1347
+ return;
1348
+ }
1349
+ chunks.push(c);
1350
+ });
1351
+ req.on('end', () => {
1352
+ if (aborted) return;
1353
+ const absPath = path.join(state.sessionDir, eventId + '.png');
1354
+ try {
1355
+ fs.writeFileSync(absPath, Buffer.concat(chunks));
1356
+ } catch (err) {
1357
+ res.writeHead(500, { 'Content-Type': 'application/json' });
1358
+ res.end(JSON.stringify({ error: 'Write failed: ' + err.message }));
1359
+ return;
1360
+ }
1361
+ res.writeHead(200, { 'Content-Type': 'application/json' });
1362
+ res.end(JSON.stringify({ ok: true, path: absPath }));
1363
+ });
1364
+ req.on('error', () => {
1365
+ if (!aborted) {
1366
+ res.writeHead(500, { 'Content-Type': 'application/json' });
1367
+ res.end(JSON.stringify({ error: 'Upload failed' }));
1368
+ }
1369
+ });
1370
+ return;
1371
+ }
1372
+
1373
+ // --- Health ---
1374
+ if (p === '/status') {
1375
+ const token = url.searchParams.get('token');
1376
+ if (token !== state.token) { res.writeHead(401, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ error: 'Unauthorized' })); return; }
1377
+ const sessions = activeSessionSummaries();
1378
+ res.writeHead(200, { 'Content-Type': 'application/json' });
1379
+ res.end(JSON.stringify({
1380
+ status: 'ok',
1381
+ port: state.port,
1382
+ connectedClients: state.sseClients.size,
1383
+ pendingEvents: state.pendingEvents.map((entry) => summarizePendingEventForStatus(entry)),
1384
+ agentPolling: agentPollingConnected(),
1385
+ activeSessions: sessions,
1386
+ manualEdits: getManualEditStatus(),
1387
+ }));
1388
+ return;
1389
+ }
1390
+
1391
+ if (p === '/health') {
1392
+ res.writeHead(200, { 'Content-Type': 'application/json' });
1393
+ res.end(JSON.stringify({
1394
+ status: 'ok', port: state.port, mode: 'variant',
1395
+ hasProjectContext: hasProjectContext(),
1396
+ connectedClients: state.sseClients.size,
1397
+ }));
1398
+ return;
1399
+ }
1400
+
1401
+ // --- Design system (unified v2 response) + raw ---
1402
+ // /design-system.json returns both parsed DESIGN.md and .impeccable/design.json
1403
+ // sidecar when present. Panel merges them:
1404
+ // { present, parsed, sidecar, hasMd, hasSidecar,
1405
+ // mdNewerThanJson, parseError?, sidecarError? }
1406
+ // - parsed: output of parseDesignMd (frontmatter
1407
+ // + six canonical sections) when DESIGN.md exists.
1408
+ // - sidecar: .impeccable/design.json contents when present.
1409
+ // Expected shape: schemaVersion 2, carrying
1410
+ // extensions + components + narrative.
1411
+ // /design-system/raw returns DESIGN.md markdown verbatim
1412
+ if (p === '/design-system.json' || p === '/design-system/raw') {
1413
+ const token = url.searchParams.get('token');
1414
+ if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
1415
+
1416
+ const mdPath = path.join(CONTEXT_DIR, 'DESIGN.md');
1417
+ const jsonPath = resolveDesignSidecarPath(process.cwd(), CONTEXT_DIR) || getDesignSidecarPath(process.cwd());
1418
+ const mdStat = statOrNull(mdPath);
1419
+ const jsonStat = statOrNull(jsonPath);
1420
+
1421
+ if (p === '/design-system/raw') {
1422
+ if (!mdStat) { res.writeHead(404); res.end('Not found'); return; }
1423
+ res.writeHead(200, { 'Content-Type': 'text/markdown; charset=utf-8' });
1424
+ res.end(fs.readFileSync(mdPath, 'utf-8'));
1425
+ return;
1426
+ }
1427
+
1428
+ if (!mdStat && !jsonStat) {
1429
+ res.writeHead(404, { 'Content-Type': 'application/json' });
1430
+ res.end(JSON.stringify({ present: false }));
1431
+ return;
1432
+ }
1433
+
1434
+ const response = {
1435
+ present: true,
1436
+ hasMd: !!mdStat,
1437
+ hasSidecar: !!jsonStat,
1438
+ mdNewerThanJson: !!(mdStat && jsonStat && mdStat.mtimeMs > jsonStat.mtimeMs + 1000),
1439
+ };
1440
+
1441
+ if (mdStat) {
1442
+ try {
1443
+ response.parsed = parseDesignMd(fs.readFileSync(mdPath, 'utf-8'));
1444
+ } catch (err) {
1445
+ response.parseError = err.message;
1446
+ }
1447
+ }
1448
+
1449
+ if (jsonStat) {
1450
+ try {
1451
+ response.sidecar = JSON.parse(fs.readFileSync(jsonPath, 'utf-8'));
1452
+ } catch (err) {
1453
+ response.sidecarError = 'Failed to parse .impeccable/design.json: ' + err.message;
1454
+ }
1455
+ }
1456
+
1457
+ res.writeHead(200, { 'Content-Type': 'application/json' });
1458
+ res.end(JSON.stringify(response));
1459
+ return;
1460
+ }
1461
+
1462
+ // --- Source file (no-HMR fallback) ---
1463
+ if (p === '/source') {
1464
+ const token = url.searchParams.get('token');
1465
+ if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
1466
+ const filePath = url.searchParams.get('path');
1467
+ if (!filePath || filePath.includes('..')) { res.writeHead(400); res.end('Bad path'); return; }
1468
+ const absPath = path.resolve(process.cwd(), filePath);
1469
+ if (!absPath.startsWith(process.cwd())) { res.writeHead(403); res.end('Forbidden'); return; }
1470
+ let content;
1471
+ try { content = fs.readFileSync(absPath, 'utf-8'); }
1472
+ catch { res.writeHead(404); res.end('File not found'); return; }
1473
+ res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
1474
+ res.end(content);
1475
+ return;
1476
+ }
1477
+
1478
+ // --- SSE: server→browser push (replaces WebSocket) ---
1479
+ if (p === '/events' && req.method === 'GET') {
1480
+ const token = url.searchParams.get('token');
1481
+ if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
1482
+ clearTimeout(state.exitTimer);
1483
+ state.exitTimer = null;
1484
+ cancelQueuedAnonymousExitEvents();
1485
+ res.writeHead(200, {
1486
+ 'Content-Type': 'text/event-stream',
1487
+ 'Cache-Control': 'no-cache',
1488
+ 'Connection': 'keep-alive',
1489
+ });
1490
+ res.write('data: ' + JSON.stringify({
1491
+ type: 'connected',
1492
+ hasProjectContext: hasProjectContext(),
1493
+ agentPolling: agentPollingConnected(),
1494
+ activeSessions: activeSessionSummaries(),
1495
+ }) + '\n\n');
1496
+
1497
+ state.sseClients.add(res);
1498
+
1499
+ // Keepalive: SSE comment every 30s prevents silent connection drops.
1500
+ const heartbeat = setInterval(() => {
1501
+ try { res.write(': keepalive\n\n'); } catch { clearInterval(heartbeat); }
1502
+ }, SSE_HEARTBEAT_INTERVAL);
1503
+
1504
+ req.on('close', () => {
1505
+ clearInterval(heartbeat);
1506
+ state.sseClients.delete(res);
1507
+ if (state.sseClients.size === 0) {
1508
+ clearTimeout(state.exitTimer);
1509
+ state.exitTimer = setTimeout(() => {
1510
+ if (state.sseClients.size === 0) enqueueEvent({ type: 'exit' });
1511
+ }, 8000);
1512
+ }
1513
+ });
1514
+ return;
1515
+ }
1516
+
1517
+ // --- Manual copy edits: Save stages entries, Apply commits the staged
1518
+ // page batch through the local AI copy-edit runner.
1519
+ if (p === '/manual-edit-stash' && req.method === 'POST') {
1520
+ let body = '';
1521
+ req.on('data', (c) => { body += c; });
1522
+ req.on('end', () => {
1523
+ let msg;
1524
+ try { msg = JSON.parse(body); } catch {
1525
+ res.writeHead(400, { 'Content-Type': 'application/json' });
1526
+ res.end(JSON.stringify({ error: 'Invalid JSON' }));
1527
+ return;
1528
+ }
1529
+ if (msg.token !== state.token) {
1530
+ res.writeHead(401, { 'Content-Type': 'application/json' });
1531
+ res.end(JSON.stringify({ error: 'Unauthorized' }));
1532
+ return;
1533
+ }
1534
+ const error = validateEvent({ ...msg, type: 'manual_edits' });
1535
+ if (error) {
1536
+ res.writeHead(400, { 'Content-Type': 'application/json' });
1537
+ res.end(JSON.stringify({ error }));
1538
+ return;
1539
+ }
1540
+ try {
1541
+ stageManualEditEntry(process.cwd(), {
1542
+ id: msg.id,
1543
+ pageUrl: msg.pageUrl,
1544
+ element: msg.element,
1545
+ ops: msg.ops,
1546
+ });
1547
+ } catch (err) {
1548
+ res.writeHead(500, { 'Content-Type': 'application/json' });
1549
+ res.end(JSON.stringify({ error: 'stash_write_failed', message: err.message }));
1550
+ return;
1551
+ }
1552
+ const { totalCount, perPage } = countPendingByPage(process.cwd());
1553
+ const pendingCount = perPage[msg.pageUrl] || 0;
1554
+ recordManualEditActivity('manual_edit_stashed', {
1555
+ id: msg.id,
1556
+ pageUrl: msg.pageUrl,
1557
+ opCount: msg.ops.length,
1558
+ pendingCount,
1559
+ totalCount,
1560
+ hintedFileCount: new Set((msg.ops || []).map((op) => summarizeManualLogFile(op.sourceHint?.file)).filter(Boolean)).size,
1561
+ });
1562
+ res.writeHead(200, { 'Content-Type': 'application/json' });
1563
+ res.end(JSON.stringify({ ok: true, pendingCount, totalCount, perPage }));
1564
+ });
1565
+ return;
1566
+ }
1567
+
1568
+ // GET /manual-edit-stash?pageUrl=<url> → { count, totalCount, perPage, entries }
1569
+ if (p === '/manual-edit-stash' && req.method === 'GET') {
1570
+ const token = url.searchParams.get('token');
1571
+ if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
1572
+ const pageUrl = url.searchParams.get('pageUrl') || '';
1573
+ const { totalCount, perPage } = countPendingByPage(process.cwd());
1574
+ const buffer = readManualEditsBuffer(process.cwd());
1575
+ const entriesForPage = pageUrl ? buffer.entries.filter((e) => e.pageUrl === pageUrl) : buffer.entries;
1576
+ res.writeHead(200, { 'Content-Type': 'application/json' });
1577
+ res.end(JSON.stringify({
1578
+ count: pageUrl ? (perPage[pageUrl] || 0) : totalCount,
1579
+ totalCount,
1580
+ perPage,
1581
+ entries: entriesForPage,
1582
+ }));
1583
+ return;
1584
+ }
1585
+
1586
+ // POST /manual-edit-commit?pageUrl=<url> → ask the AI to apply the staged page batch.
1587
+ if (p === '/manual-edit-commit' && req.method === 'POST') {
1588
+ const token = url.searchParams.get('token');
1589
+ if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
1590
+ const pageUrl = url.searchParams.get('pageUrl');
1591
+ const asyncMode = /^(1|true|yes)$/i.test(url.searchParams.get('async') || '');
1592
+ const repairOnly = /^(1|true|yes)$/i.test(url.searchParams.get('repair') || '');
1593
+ const existingTransaction = readManualApplyTransaction(process.cwd());
1594
+ if (repairOnly && !existingTransaction) {
1595
+ res.writeHead(409, { 'Content-Type': 'application/json' });
1596
+ res.end(JSON.stringify({ error: 'manual_edit_repair_transaction_missing' }));
1597
+ return;
1598
+ }
1599
+ const recoveredTransaction = repairOnly ? null : rollbackManualApplyTransaction({
1600
+ cwd: process.cwd(),
1601
+ pageUrl,
1602
+ reason: 'manual_edit_commit_recovered_abandoned_transaction',
1603
+ });
1604
+ const before = getManualEditStatus();
1605
+ const pendingCount = pageUrl ? (before.perPage[pageUrl] || 0) : before.totalCount;
1606
+ recordManualEditActivity('manual_edit_commit_started', {
1607
+ pageUrl,
1608
+ repairOnly,
1609
+ pendingCount,
1610
+ totalCount: before.totalCount,
1611
+ recoveredTransaction: recoveredTransaction ? {
1612
+ id: recoveredTransaction.id,
1613
+ reason: recoveredTransaction.reason,
1614
+ skipped: recoveredTransaction.skipped,
1615
+ rolledBackFiles: recoveredTransaction.rolledBackFiles,
1616
+ rollbackFailures: summarizeManualDiagnostics(recoveredTransaction.rollbackFailures),
1617
+ } : null,
1618
+ ...summarizePendingManualEditBatch(pageUrl),
1619
+ });
1620
+ if (asyncMode) {
1621
+ res.writeHead(202, { 'Content-Type': 'application/json' });
1622
+ res.end(JSON.stringify({
1623
+ status: 'started',
1624
+ pendingCount,
1625
+ totalCount: before.totalCount,
1626
+ perPage: before.perPage,
1627
+ }));
1628
+ }
1629
+ (async () => {
1630
+ let result;
1631
+ let routedProvider = 'subprocess';
1632
+ let transaction = null;
1633
+ let commitBatch = null;
1634
+ try {
1635
+ if (pendingCount > 0) {
1636
+ const transactionBatch = buildManualEditEvidence({ cwd: process.cwd(), pageUrl });
1637
+ commitBatch = transactionBatch;
1638
+ if (!repairOnly && countManualApplyOps(transactionBatch) > 0) {
1639
+ transaction = writeManualApplyTransaction({
1640
+ cwd: process.cwd(),
1641
+ pageUrl,
1642
+ batch: transactionBatch,
1643
+ });
1644
+ } else if (repairOnly && existingTransaction) {
1645
+ transaction = existingTransaction;
1646
+ }
1647
+ }
1648
+ const requestedMode = (process.env.IMPECCABLE_LIVE_COPY_AGENT || 'auto').trim().toLowerCase();
1649
+ const useChatRoute = requestedMode === 'chat'
1650
+ || (requestedMode === 'auto' && chatAgentLikelyActive());
1651
+ if (useChatRoute) {
1652
+ routedProvider = 'chat';
1653
+ const timeoutMs = Number(process.env.IMPECCABLE_LIVE_COPY_AGENT_TIMEOUT_MS || 120000);
1654
+ result = await commitManualEdits({
1655
+ cwd: process.cwd(),
1656
+ pageUrl,
1657
+ provider: 'chat',
1658
+ env: process.env,
1659
+ timeoutMs,
1660
+ chatAvailable: chatAgentLikelyActive,
1661
+ applyBatchToSource: (batch, context) => pushApplyBatchInChunksAndWait(batch, pageUrl, context),
1662
+ repairOnly,
1663
+ transactionId: transaction?.id || existingTransaction?.id || null,
1664
+ batch: commitBatch,
1665
+ });
1666
+ } else {
1667
+ const timeoutMs = Number(process.env.IMPECCABLE_LIVE_COPY_AGENT_TIMEOUT_MS || 120000);
1668
+ const provider = ['codex', 'claude', 'mock'].includes(requestedMode) ? requestedMode : undefined;
1669
+ result = await commitManualEdits({
1670
+ cwd: process.cwd(),
1671
+ pageUrl,
1672
+ provider,
1673
+ env: process.env,
1674
+ timeoutMs,
1675
+ chatAvailable: chatAgentLikelyActive,
1676
+ repairOnly,
1677
+ transactionId: transaction?.id || existingTransaction?.id || null,
1678
+ batch: commitBatch,
1679
+ });
1680
+ }
1681
+ } catch (err) {
1682
+ if (transaction) {
1683
+ rollbackManualApplyTransaction({
1684
+ cwd: process.cwd(),
1685
+ pageUrl,
1686
+ reason: 'manual_edit_commit_exception',
1687
+ });
1688
+ }
1689
+ const message = err.stderr?.toString?.() || err.message;
1690
+ recordManualEditActivity('manual_edit_commit_failed', {
1691
+ pageUrl,
1692
+ provider: routedProvider,
1693
+ error: 'manual_edit_commit_failed',
1694
+ message,
1695
+ transactionId: transaction?.id || null,
1696
+ });
1697
+ if (!asyncMode) {
1698
+ res.writeHead(500, { 'Content-Type': 'application/json' });
1699
+ res.end(JSON.stringify({
1700
+ error: 'manual_edit_commit_failed',
1701
+ message,
1702
+ }));
1703
+ }
1704
+ return;
1705
+ } finally {
1706
+ if (transaction) {
1707
+ const shouldKeepTransaction = result?.needsManualDecision === true;
1708
+ if (!shouldKeepTransaction) clearManualApplyTransaction(process.cwd(), transaction.id);
1709
+ }
1710
+ }
1711
+ const { totalCount, perPage } = countPendingByPage(process.cwd());
1712
+ if (result?.needsManualDecision) {
1713
+ recordManualEditActivity('manual_edit_repair_needs_decision', {
1714
+ pageUrl,
1715
+ provider: routedProvider,
1716
+ transactionId: transaction?.id || existingTransaction?.id || null,
1717
+ repair: result.repair || null,
1718
+ failed: summarizeManualApplyFailures(result.failed),
1719
+ files: Array.isArray(result.files) ? result.files.slice(0, 20).map(summarizeManualLogFile).filter(Boolean) : [],
1720
+ remainingCount: pageUrl ? (perPage[pageUrl] || 0) : totalCount,
1721
+ totalCount,
1722
+ });
1723
+ } else {
1724
+ recordManualEditActivity('manual_edit_commit_done', {
1725
+ pageUrl,
1726
+ provider: routedProvider,
1727
+ reason: result.reason || null,
1728
+ repair: result.repair || null,
1729
+ appliedCount: Array.isArray(result.applied) ? result.applied.length : 0,
1730
+ failedCount: Array.isArray(result.failed) ? result.failed.length : 0,
1731
+ failed: summarizeManualApplyFailures(result.failed),
1732
+ files: Array.isArray(result.files) ? result.files.slice(0, 20).map(summarizeManualLogFile).filter(Boolean) : [],
1733
+ warnings: summarizeManualDiagnostics(result.warnings),
1734
+ rolledBackFiles: Array.isArray(result.rolledBackFiles) ? result.rolledBackFiles.slice(0, 20).map(summarizeManualLogFile).filter(Boolean) : [],
1735
+ rollbackFailures: summarizeManualDiagnostics(result.rollbackFailures),
1736
+ unreportedFiles: Array.isArray(result.unreportedFiles) ? result.unreportedFiles.slice(0, 20).map(summarizeManualLogFile).filter(Boolean) : undefined,
1737
+ noteCount: Array.isArray(result.notes) ? result.notes.length : 0,
1738
+ cleared: result.cleared || 0,
1739
+ remainingCount: pageUrl ? (perPage[pageUrl] || 0) : totalCount,
1740
+ totalCount,
1741
+ });
1742
+ }
1743
+ if (!asyncMode) {
1744
+ res.writeHead(200, { 'Content-Type': 'application/json' });
1745
+ res.end(JSON.stringify({ ...result, totalCount, perPage }));
1746
+ }
1747
+ })();
1748
+ return;
1749
+ }
1750
+
1751
+ // POST /manual-edit-repair-decision → user resolves an exhausted repair loop.
1752
+ if (p === '/manual-edit-repair-decision' && req.method === 'POST') {
1753
+ let body = '';
1754
+ req.on('data', (chunk) => { body += chunk; });
1755
+ req.on('end', () => {
1756
+ let payload = {};
1757
+ try { payload = body ? JSON.parse(body) : {}; } catch {
1758
+ res.writeHead(400, { 'Content-Type': 'application/json' });
1759
+ res.end(JSON.stringify({ error: 'Invalid JSON' }));
1760
+ return;
1761
+ }
1762
+ const token = payload.token || url.searchParams.get('token');
1763
+ if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
1764
+ const pageUrl = payload.pageUrl || url.searchParams.get('pageUrl') || null;
1765
+ const action = String(payload.action || url.searchParams.get('action') || '').trim().toLowerCase();
1766
+ if (action !== 'rollback') {
1767
+ res.writeHead(400, { 'Content-Type': 'application/json' });
1768
+ res.end(JSON.stringify({ error: 'unsupported_manual_edit_repair_decision', action }));
1769
+ return;
1770
+ }
1771
+ const rollback = rollbackManualApplyTransaction({
1772
+ cwd: process.cwd(),
1773
+ pageUrl,
1774
+ reason: 'manual_edit_user_requested_rollback',
1775
+ });
1776
+ const { totalCount, perPage } = countPendingByPage(process.cwd());
1777
+ const response = {
1778
+ action,
1779
+ pageUrl,
1780
+ rollback,
1781
+ remainingCount: pageUrl ? (perPage[pageUrl] || 0) : totalCount,
1782
+ totalCount,
1783
+ perPage,
1784
+ };
1785
+ recordManualEditActivity('manual_edit_repair_rollback_done', response);
1786
+ res.writeHead(200, { 'Content-Type': 'application/json' });
1787
+ res.end(JSON.stringify(response));
1788
+ });
1789
+ return;
1790
+ }
1791
+
1792
+ // POST /manual-edit-discard?pageUrl=<url> → drops entries (all if no pageUrl)
1793
+ if (p === '/manual-edit-discard' && req.method === 'POST') {
1794
+ const token = url.searchParams.get('token');
1795
+ if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
1796
+ const pageUrl = url.searchParams.get('pageUrl');
1797
+ let discarded;
1798
+ let discardedEntries = [];
1799
+ let canceledApplyEvents = [];
1800
+ let transactionRollback = null;
1801
+ try {
1802
+ const buffer = readManualEditsBuffer(process.cwd());
1803
+ transactionRollback = rollbackManualApplyTransaction({
1804
+ cwd: process.cwd(),
1805
+ pageUrl,
1806
+ reason: 'manual_edit_discarded',
1807
+ });
1808
+ if (pageUrl) {
1809
+ discardedEntries = buffer.entries.filter((entry) => entry.pageUrl === pageUrl);
1810
+ discarded = removeManualEditEntries(process.cwd(), (entry) => entry.pageUrl === pageUrl);
1811
+ } else {
1812
+ discardedEntries = buffer.entries;
1813
+ discarded = truncateManualEditsBuffer(process.cwd());
1814
+ }
1815
+ canceledApplyEvents = cancelPendingManualApplyEvents(pageUrl);
1816
+ } catch (err) {
1817
+ res.writeHead(500, { 'Content-Type': 'application/json' });
1818
+ res.end(JSON.stringify({ error: 'discard_failed', message: err.message }));
1819
+ return;
1820
+ }
1821
+ const { totalCount, perPage } = countPendingByPage(process.cwd());
1822
+ recordManualEditActivity('manual_edit_discarded', {
1823
+ pageUrl,
1824
+ discarded,
1825
+ canceledApplyIds: canceledApplyEvents.map((event) => event.id),
1826
+ transactionRollback: transactionRollback ? {
1827
+ id: transactionRollback.id,
1828
+ rolledBackFiles: transactionRollback.rolledBackFiles?.map(summarizeManualLogFile).filter(Boolean) || [],
1829
+ rollbackFailures: summarizeManualDiagnostics(transactionRollback.rollbackFailures),
1830
+ skipped: transactionRollback.skipped,
1831
+ } : undefined,
1832
+ totalCount,
1833
+ });
1834
+ res.writeHead(200, { 'Content-Type': 'application/json' });
1835
+ res.end(JSON.stringify({ discarded, entries: discardedEntries, canceledApplyEvents, totalCount, perPage }));
1836
+ return;
1837
+ }
1838
+
1839
+ // Defense in depth: redirect any stragglers from the old /manual-edit endpoint.
1840
+ if (p === '/manual-edit' && req.method === 'POST') {
1841
+ res.writeHead(410, { 'Content-Type': 'application/json' });
1842
+ res.end(JSON.stringify({ error: '/manual-edit is removed; use /manual-edit-stash and /manual-edit-commit for staged copy edits.' }));
1843
+ return;
1844
+ }
1845
+
1846
+ // --- Browser→server events (replaces WebSocket messages) ---
1847
+ if (p === '/events' && req.method === 'POST') {
1848
+ let body = '';
1849
+ req.on('data', (c) => { body += c; });
1850
+ req.on('end', () => {
1851
+ let msg;
1852
+ try { msg = JSON.parse(body); } catch {
1853
+ res.writeHead(400, { 'Content-Type': 'application/json' });
1854
+ res.end(JSON.stringify({ error: 'Invalid JSON' }));
1855
+ return;
1856
+ }
1857
+ if (msg.token !== state.token) {
1858
+ res.writeHead(401, { 'Content-Type': 'application/json' });
1859
+ res.end(JSON.stringify({ error: 'Unauthorized' }));
1860
+ return;
1861
+ }
1862
+ // Defense in depth: manual copy edits must use the staged stash/apply
1863
+ // endpoints. The direct Save event path is disabled in the browser.
1864
+ if (msg.type === 'manual_edits') {
1865
+ res.writeHead(400, { 'Content-Type': 'application/json' });
1866
+ res.end(JSON.stringify({ error: 'manual_edits must POST to /manual-edit-stash, not /events' }));
1867
+ return;
1868
+ }
1869
+ if (msg.type === 'manual_edit_apply') {
1870
+ res.writeHead(400, { 'Content-Type': 'application/json' });
1871
+ res.end(JSON.stringify({ error: 'manual_edit_apply is disabled; use /manual-edit-stash then /manual-edit-commit' }));
1872
+ return;
1873
+ }
1874
+ const error = validateEvent(msg);
1875
+ if (error) {
1876
+ res.writeHead(400, { 'Content-Type': 'application/json' });
1877
+ res.end(JSON.stringify({ error }));
1878
+ return;
1879
+ }
1880
+ if (state.sessionStore && msg.id) {
1881
+ try {
1882
+ state.sessionStore.appendEvent(msg);
1883
+ } catch (err) {
1884
+ res.writeHead(500, { 'Content-Type': 'application/json' });
1885
+ res.end(JSON.stringify({ error: 'session_store_append_failed', message: err.message }));
1886
+ return;
1887
+ }
1888
+ }
1889
+ if (msg.type === 'exit') {
1890
+ cleanupSvelteComponentSessionsBeforeExit();
1891
+ }
1892
+ if (msg.type !== 'checkpoint') {
1893
+ enqueueEvent(msg);
1894
+ }
1895
+ res.writeHead(200, { 'Content-Type': 'application/json' });
1896
+ res.end(JSON.stringify({ ok: true }));
1897
+ });
1898
+ return;
1899
+ }
1900
+
1901
+ // --- Stop ---
1902
+ if (p === '/stop') {
1903
+ const token = url.searchParams.get('token');
1904
+ if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
1905
+ res.writeHead(200, { 'Content-Type': 'text/plain' });
1906
+ res.end('stopping');
1907
+ shutdown();
1908
+ return;
1909
+ }
1910
+
1911
+ // --- Agent poll ---
1912
+ if (p === '/poll' && req.method === 'GET') {
1913
+ handlePollGet(req, res, url);
1914
+ return;
1915
+ }
1916
+ if (p === '/poll' && req.method === 'POST') {
1917
+ handlePollPost(req, res);
1918
+ return;
1919
+ }
1920
+
1921
+ res.writeHead(404); res.end('Not found');
1922
+ };
1923
+ }
1924
+
1925
+ // ---------------------------------------------------------------------------
1926
+ // Agent poll endpoints (unchanged from WS version)
1927
+ // ---------------------------------------------------------------------------
1928
+
1929
+ function handlePollGet(req, res, url) {
1930
+ const token = url.searchParams.get('token');
1931
+ if (token !== state.token) {
1932
+ res.writeHead(401, { 'Content-Type': 'application/json' });
1933
+ res.end(JSON.stringify({ error: 'Unauthorized' }));
1934
+ return;
1935
+ }
1936
+ state.lastPollAt = Date.now();
1937
+ const timeout = parseInt(url.searchParams.get('timeout') || DEFAULT_POLL_TIMEOUT, 10);
1938
+ const leaseMs = parseInt(url.searchParams.get('leaseMs') || '30000', 10);
1939
+ const available = findAvailablePendingEvent();
1940
+ if (available) {
1941
+ res.writeHead(200, { 'Content-Type': 'application/json' });
1942
+ res.end(JSON.stringify(leaseEvent(available, leaseMs)));
1943
+ return;
1944
+ }
1945
+ const poll = { resolve, leaseMs };
1946
+ const timer = setTimeout(() => {
1947
+ const idx = state.pendingPolls.indexOf(poll);
1948
+ if (idx !== -1) state.pendingPolls.splice(idx, 1);
1949
+ broadcastAgentPollingIfChanged();
1950
+ res.writeHead(200, { 'Content-Type': 'application/json' });
1951
+ res.end(JSON.stringify({ type: 'timeout' }));
1952
+ }, timeout);
1953
+ function resolve(event) {
1954
+ clearTimeout(timer);
1955
+ state.lastPollAt = Date.now();
1956
+ res.writeHead(200, { 'Content-Type': 'application/json' });
1957
+ res.end(JSON.stringify(event));
1958
+ }
1959
+ state.pendingPolls.push(poll);
1960
+ broadcastAgentPollingIfChanged();
1961
+ scheduleLeaseFlush();
1962
+ req.on('close', () => {
1963
+ clearTimeout(timer);
1964
+ const idx = state.pendingPolls.indexOf(poll);
1965
+ if (idx !== -1) state.pendingPolls.splice(idx, 1);
1966
+ broadcastAgentPollingIfChanged();
1967
+ });
1968
+ }
1969
+
1970
+ function sessionFileMetadataFromPollReply(file) {
1971
+ if (!file || typeof file !== 'string') return { file };
1972
+ const normalized = file.split(path.sep).join('/');
1973
+ const base = { file: normalized };
1974
+ if (!normalized.endsWith('/manifest.json') && normalized !== 'manifest.json') return base;
1975
+ if (!normalized.includes('node_modules/.impeccable-live/') && !normalized.includes('src/lib/impeccable/')) return base;
1976
+
1977
+ let full;
1978
+ try {
1979
+ full = path.resolve(process.cwd(), normalized);
1980
+ const rel = path.relative(process.cwd(), full);
1981
+ if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return base;
1982
+ } catch {
1983
+ return base;
1984
+ }
1985
+
1986
+ try {
1987
+ const manifest = JSON.parse(fs.readFileSync(full, 'utf-8'));
1988
+ if (manifest?.previewMode !== 'svelte-component' || !manifest.sourceFile) return base;
1989
+ return {
1990
+ file: String(manifest.sourceFile).split(path.sep).join('/'),
1991
+ sourceFile: String(manifest.sourceFile).split(path.sep).join('/'),
1992
+ previewFile: normalized,
1993
+ previewMode: 'svelte-component',
1994
+ };
1995
+ } catch {
1996
+ return base;
1997
+ }
1998
+ }
1999
+
2000
+ function handlePollPost(req, res) {
2001
+ let body = '';
2002
+ req.on('data', (c) => { body += c; });
2003
+ req.on('end', () => {
2004
+ let msg;
2005
+ try { msg = JSON.parse(body); } catch {
2006
+ res.writeHead(400, { 'Content-Type': 'application/json' });
2007
+ res.end(JSON.stringify({ error: 'Invalid JSON' }));
2008
+ return;
2009
+ }
2010
+ if (msg.token !== state.token) {
2011
+ res.writeHead(401, { 'Content-Type': 'application/json' });
2012
+ res.end(JSON.stringify({ error: 'Unauthorized' }));
2013
+ return;
2014
+ }
2015
+ const pendingApplyDeferred = state.pendingApplyDeferreds.get(msg.id);
2016
+ if (pendingApplyDeferred) {
2017
+ const validation = validateManualApplyResultMessage(msg, pendingApplyDeferred);
2018
+ if (!validation.ok) {
2019
+ recordManualEditActivity('manual_edit_apply_reply_invalid', {
2020
+ id: msg.id,
2021
+ pageUrl: pendingApplyDeferred.pageUrl,
2022
+ chunk: pendingApplyDeferred.event?.chunk || null,
2023
+ repair: pendingApplyDeferred.event?.repair || null,
2024
+ reason: validation.body?.reason || validation.body?.error || 'invalid_manual_apply_result',
2025
+ status: msg.data?.status || null,
2026
+ });
2027
+ res.writeHead(400, { 'Content-Type': 'application/json' });
2028
+ res.end(JSON.stringify(validation.body));
2029
+ return;
2030
+ }
2031
+ recordManualEditActivity('manual_edit_apply_reply_received', {
2032
+ id: msg.id,
2033
+ pageUrl: pendingApplyDeferred.pageUrl,
2034
+ chunk: pendingApplyDeferred.event?.chunk || null,
2035
+ repair: pendingApplyDeferred.event?.repair || null,
2036
+ status: validation.result.status,
2037
+ appliedCount: validation.result.appliedEntryIds.length,
2038
+ failed: summarizeManualApplyFailures(validation.result.failed),
2039
+ fileCount: validation.result.files.length,
2040
+ noteCount: validation.result.notes.length,
2041
+ });
2042
+ resolveApplyDeferred(msg.id, validation.result);
2043
+ acknowledgePendingEvent(msg.id);
2044
+ flushPendingPolls();
2045
+ res.writeHead(200, { 'Content-Type': 'application/json' });
2046
+ res.end(JSON.stringify({ ok: true }));
2047
+ return;
2048
+ }
2049
+ if (state.timedOutApplyIds.has(msg.id)) {
2050
+ const rollback = rollbackTimedOutApplyReply(msg);
2051
+ recordManualEditActivity('manual_edit_apply_stale_reply_rejected', {
2052
+ id: msg.id,
2053
+ rolledBackFileCount: rollback.rolledBackFiles?.length || 0,
2054
+ rollbackFailureCount: rollback.rollbackFailures?.length || 0,
2055
+ });
2056
+ res.writeHead(409, { 'Content-Type': 'application/json' });
2057
+ res.end(JSON.stringify({ error: 'stale_manual_edit_apply_reply', ...rollback }));
2058
+ return;
2059
+ }
2060
+ const pendingEventBeforeAck = findPendingEventById(msg.id);
2061
+ if (pendingEventBeforeAck?.type === 'steer' && msg.type === 'steer_done'
2062
+ && !msg.file && !(typeof msg.message === 'string' && msg.message.trim())) {
2063
+ res.writeHead(400, { 'Content-Type': 'application/json' });
2064
+ res.end(JSON.stringify({
2065
+ error: 'steer_done_requires_file_or_message',
2066
+ hint: 'Reply with --file after writing source, or include a message explaining an intentional no-op.',
2067
+ }));
2068
+ return;
2069
+ }
2070
+ const acknowledgedEvent = acknowledgePendingEvent(msg.id);
2071
+ let skipJournalReply = false;
2072
+ let existingSession = null;
2073
+ if (!acknowledgedEvent && state.sessionStore && msg.id) {
2074
+ try {
2075
+ existingSession = state.sessionStore.getSnapshot(msg.id, { includeCompleted: true });
2076
+ if (!existingSession?.updatedAt) existingSession = null;
2077
+ skipJournalReply = existingSession?.phase === 'completed' || existingSession?.phase === 'discarded';
2078
+ } catch { /* fall through and record the reply normally */ }
2079
+ }
2080
+ if (!acknowledgedEvent && !existingSession) {
2081
+ recordManualEditActivity('manual_edit_poll_reply_unknown', {
2082
+ id: msg.id || null,
2083
+ type: msg.type || null,
2084
+ });
2085
+ res.writeHead(msg.id ? 404 : 400, { 'Content-Type': 'application/json' });
2086
+ res.end(JSON.stringify({
2087
+ error: msg.id ? 'unknown_poll_reply_id' : 'missing_poll_reply_id',
2088
+ id: msg.id,
2089
+ }));
2090
+ return;
2091
+ }
2092
+ const replyFileMeta = sessionFileMetadataFromPollReply(msg.file);
2093
+ if (state.sessionStore && msg.id && !skipJournalReply) {
2094
+ try {
2095
+ const eventType = msg.type === 'steer_done'
2096
+ ? 'steer_done'
2097
+ : msg.type === 'discard' || msg.type === 'discarded'
2098
+ ? 'discarded'
2099
+ : msg.type === 'complete'
2100
+ ? 'complete'
2101
+ : msg.type === 'error'
2102
+ ? 'agent_error'
2103
+ : 'agent_done';
2104
+ state.sessionStore.appendEvent({
2105
+ type: eventType,
2106
+ id: msg.id,
2107
+ file: replyFileMeta.file,
2108
+ sourceFile: replyFileMeta.sourceFile,
2109
+ previewFile: replyFileMeta.previewFile,
2110
+ previewMode: replyFileMeta.previewMode,
2111
+ message: msg.message,
2112
+ sourceEventType: acknowledgedEvent?.type,
2113
+ carbonize: msg.data?.carbonize === true,
2114
+ });
2115
+ } catch { /* keep reply path best-effort; browser still needs SSE */ }
2116
+ }
2117
+ flushPendingPolls();
2118
+ // Forward the reply to the browser via SSE
2119
+ broadcast({
2120
+ type: msg.type || 'done',
2121
+ id: msg.id,
2122
+ message: msg.message,
2123
+ file: msg.file,
2124
+ sourceFile: replyFileMeta.sourceFile,
2125
+ previewFile: replyFileMeta.previewFile,
2126
+ previewMode: replyFileMeta.previewMode,
2127
+ data: msg.data,
2128
+ });
2129
+ res.writeHead(200, { 'Content-Type': 'application/json' });
2130
+ res.end(JSON.stringify({ ok: true }));
2131
+ });
2132
+ }
2133
+
2134
+ // ---------------------------------------------------------------------------
2135
+ // Lifecycle
2136
+ // ---------------------------------------------------------------------------
2137
+
2138
+ let httpServer = null;
2139
+
2140
+ function shutdown() {
2141
+ cleanupSvelteComponentSessionsBeforeExit();
2142
+ removeLiveServerInfo(process.cwd());
2143
+ if (state.leaseTimer) clearTimeout(state.leaseTimer);
2144
+ state.leaseTimer = null;
2145
+ if (state.sessionDir) {
2146
+ try { fs.rmSync(state.sessionDir, { recursive: true, force: true }); } catch {}
2147
+ }
2148
+ for (const res of state.sseClients) { try { res.end(); } catch {} }
2149
+ state.sseClients.clear();
2150
+ for (const poll of state.pendingPolls) poll.resolve({ type: 'exit' });
2151
+ state.pendingPolls.length = 0;
2152
+ if (httpServer) httpServer.close();
2153
+ process.exit(0);
2154
+ }
2155
+
2156
+ function cleanupSvelteComponentSessionsBeforeExit() {
2157
+ try {
2158
+ removeAllSvelteComponentSessions(process.cwd());
2159
+ } catch (err) {
2160
+ console.warn('[impeccable] Svelte component session cleanup failed:', err.message);
2161
+ }
2162
+ }
2163
+
2164
+ function applyLegacyDeferredAcceptsOnStartup() {
2165
+ try {
2166
+ const result = applyDeferredSvelteComponentAccepts(process.cwd());
2167
+ if (result.applied > 0 || result.failed > 0) {
2168
+ console.log('[impeccable] applied legacy deferred Svelte component accepts:', JSON.stringify(result));
2169
+ }
2170
+ } catch (err) {
2171
+ console.warn('[impeccable] legacy deferred Svelte component accept apply failed:', err.message);
2172
+ }
2173
+ }
2174
+
2175
+ // ---------------------------------------------------------------------------
2176
+ // Main
2177
+ // ---------------------------------------------------------------------------
2178
+
2179
+ const args = process.argv.slice(2);
2180
+
2181
+ if (args.includes('--help') || args.includes('-h')) {
2182
+ console.log(`Usage: node live-server.mjs [options]
2183
+
2184
+ Start the live variant mode server (zero dependencies).
2185
+
2186
+ Commands:
2187
+ (default) Start the server (foreground)
2188
+ stop Stop the server and remove the injected live.js script tag
2189
+ stop --keep-inject Stop the server only (leave the script tag in the HTML entry)
2190
+
2191
+ Options:
2192
+ --background Start detached, print connection JSON to stdout, then exit
2193
+ --port=PORT Use a specific port (default: auto-detect starting at 8400)
2194
+ --keep-inject Only with stop: skip live-inject.mjs --remove
2195
+ --help Show this help
2196
+
2197
+ Endpoints:
2198
+ /live.js Browser script (element picker + variant cycling)
2199
+ /detect.js Detection overlay (backwards compatible)
2200
+ /modern-screenshot.js Vendored modern-screenshot UMD build (lazy-loaded by live.js)
2201
+ /annotation POST raw image/png to stage a variant screenshot
2202
+ /events SSE stream (server→browser) + POST (browser→server)
2203
+ /poll Long-poll for agent CLI
2204
+ /manual-edit-stash Stage browser copy edits
2205
+ /manual-edit-commit Apply staged browser copy edits
2206
+ /manual-edit-discard Discard staged browser copy edits
2207
+ /source Raw source file reader (no-HMR fallback)
2208
+ /status Durable recovery status (token-protected)
2209
+ /health Health check`);
2210
+ process.exit(0);
2211
+ }
2212
+
2213
+ if (args.includes('stop')) {
2214
+ const keepInject = args.includes('--keep-inject');
2215
+ try {
2216
+ const { info } = readLiveServerInfo(process.cwd()) || {};
2217
+ const res = await fetch(`http://localhost:${info.port}/stop?token=${info.token}`);
2218
+ if (res.ok) console.log(`Stopped live server on port ${info.port}.`);
2219
+ } catch {
2220
+ console.log('No running live server found.');
2221
+ }
2222
+ if (!keepInject) {
2223
+ const injectPath = path.join(__dirname, 'live-inject.mjs');
2224
+ try {
2225
+ const out = execFileSync(process.execPath, [injectPath, '--remove'], {
2226
+ encoding: 'utf-8',
2227
+ cwd: process.cwd(),
2228
+ });
2229
+ const line = out.trim().split('\n').filter(Boolean).pop();
2230
+ if (line) {
2231
+ try {
2232
+ const j = JSON.parse(line);
2233
+ if (j.removed === true) {
2234
+ console.log(`Removed live script tag from ${j.file}.`);
2235
+ }
2236
+ } catch {
2237
+ /* ignore non-JSON lines */
2238
+ }
2239
+ }
2240
+ } catch (err) {
2241
+ const detail = err.stderr?.toString?.().trim?.()
2242
+ || err.stdout?.toString?.().trim?.()
2243
+ || err.message
2244
+ || String(err);
2245
+ console.warn(`Note: could not remove live script tag (${detail.split('\n')[0]})`);
2246
+ }
2247
+ }
2248
+ process.exit(0);
2249
+ }
2250
+
2251
+ // --background: spawn a detached child server, wait for it to be ready,
2252
+ // print the connection JSON, then exit. This keeps the startup command
2253
+ // simple (no shell backgrounding or chained commands).
2254
+ if (args.includes('--background')) {
2255
+ const childArgs = args.filter(a => a !== '--background');
2256
+ const child = spawn(process.execPath, [fileURLToPath(import.meta.url), ...childArgs], {
2257
+ detached: true,
2258
+ stdio: 'ignore',
2259
+ cwd: process.cwd(),
2260
+ });
2261
+ child.unref();
2262
+
2263
+ // Poll for the PID file (the child writes it once the HTTP server is listening).
2264
+ const deadline = Date.now() + 10_000;
2265
+ while (Date.now() < deadline) {
2266
+ try {
2267
+ const { info } = readLiveServerInfo(process.cwd()) || {};
2268
+ if (info.pid !== process.pid) {
2269
+ // Output JSON so the agent can read port + token from stdout.
2270
+ console.log(JSON.stringify(info));
2271
+ process.exit(0);
2272
+ }
2273
+ } catch { /* not ready yet */ }
2274
+ await new Promise(r => setTimeout(r, 200));
2275
+ }
2276
+ console.error('Timed out waiting for live server to start.');
2277
+ process.exit(1);
2278
+ }
2279
+
2280
+ // Check for existing session
2281
+ const existingRecord = readLiveServerInfo(process.cwd());
2282
+ if (existingRecord?.info) {
2283
+ const existing = existingRecord.info;
2284
+ try {
2285
+ process.kill(existing.pid, 0);
2286
+ console.error(`Live server already running on port ${existing.port} (pid ${existing.pid}).`);
2287
+ console.error('Stop it first with: node ' + path.basename(fileURLToPath(import.meta.url)) + ' stop');
2288
+ process.exit(1);
2289
+ } catch {
2290
+ try { fs.unlinkSync(existingRecord.path); } catch {}
2291
+ }
2292
+ }
2293
+
2294
+ state.token = randomUUID();
2295
+ state.sessionStore = createLiveSessionStore({ cwd: process.cwd() });
2296
+ rollbackManualApplyTransaction({
2297
+ cwd: process.cwd(),
2298
+ reason: 'manual_edit_server_start_recovered_abandoned_transaction',
2299
+ });
2300
+ applyLegacyDeferredAcceptsOnStartup();
2301
+ restorePendingEventsFromStore();
2302
+ pruneStaleManualApplyEvidence(process.cwd());
2303
+ const portArg = args.find(a => a.startsWith('--port='));
2304
+ state.port = portArg ? parseInt(portArg.split('=')[1], 10) : await findOpenPort();
2305
+ // Annotation screenshots live in the project root so the agent's Read tool
2306
+ // doesn't trip a per-file permission prompt. Sessioned by token so concurrent
2307
+ // projects (or quick restarts) don't collide.
2308
+ const annotRoot = getLiveAnnotationsDir(process.cwd());
2309
+ fs.mkdirSync(annotRoot, { recursive: true });
2310
+ state.sessionDir = fs.mkdtempSync(path.join(annotRoot, 'session-'));
2311
+
2312
+ const { detectScript, sessionPath, livePath } = loadBrowserScripts();
2313
+ httpServer = http.createServer(createRequestHandler({ detectScript, sessionPath, livePath }));
2314
+
2315
+ httpServer.listen(state.port, '127.0.0.1', () => {
2316
+ writeLiveServerInfo(process.cwd(), { pid: process.pid, port: state.port, token: state.token });
2317
+ const url = `http://localhost:${state.port}`;
2318
+ console.log(`\nImpeccable live server running on ${url}`);
2319
+ console.log(`Token: ${state.token}\n`);
2320
+ console.log(`Script: ${url}/live.js`);
2321
+ console.log('Inject: managed by live-inject.mjs; Astro source tags use is:inline automatically.');
2322
+ console.log(`Stop: node ${path.basename(fileURLToPath(import.meta.url))} stop`);
2323
+ });
2324
+
2325
+ process.on('SIGINT', shutdown);
2326
+ process.on('SIGTERM', shutdown);