agentvfx 0.0.0-stage → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (483) hide show
  1. package/AGENTS.md +8 -0
  2. package/GEMINI.md +1 -0
  3. package/LICENSE +172 -0
  4. package/README.md +236 -2
  5. package/package.json +35 -4
  6. package/skills/agentvfx/LICENSE +172 -0
  7. package/skills/agentvfx/NOTICE +44 -0
  8. package/skills/agentvfx/SKILL.md +90 -0
  9. package/skills/agentvfx/engine/core/constants.mjs +84 -0
  10. package/skills/agentvfx/engine/core/flash-constants.mjs +23 -0
  11. package/skills/agentvfx/engine/core/flash.mjs +240 -0
  12. package/skills/agentvfx/engine/core/mark.mjs +28 -0
  13. package/skills/agentvfx/engine/core/palettes.mjs +36 -0
  14. package/skills/agentvfx/engine/core/schedule.mjs +85 -0
  15. package/skills/agentvfx/engine/core/templates.mjs +43 -0
  16. package/skills/agentvfx/engine/core/util.mjs +167 -0
  17. package/skills/agentvfx/engine/core/validate.mjs +334 -0
  18. package/skills/agentvfx/engine/node/analysis.mjs +172 -0
  19. package/skills/agentvfx/engine/node/audio.mjs +621 -0
  20. package/skills/agentvfx/engine/node/board.mjs +24 -0
  21. package/skills/agentvfx/engine/node/chrome.mjs +349 -0
  22. package/skills/agentvfx/engine/node/encode.mjs +110 -0
  23. package/skills/agentvfx/engine/node/eye.mjs +77 -0
  24. package/skills/agentvfx/engine/node/footage.mjs +129 -0
  25. package/skills/agentvfx/engine/node/frame-worker.mjs +39 -0
  26. package/skills/agentvfx/engine/node/host.mjs +31 -0
  27. package/skills/agentvfx/engine/node/job.mjs +181 -0
  28. package/skills/agentvfx/engine/node/png.mjs +112 -0
  29. package/skills/agentvfx/engine/node/render.mjs +161 -0
  30. package/skills/agentvfx/engine/node/stage-capture.mjs +187 -0
  31. package/skills/agentvfx/engine/node/stage-serve.mjs +72 -0
  32. package/skills/agentvfx/engine/node/stills.mjs +100 -0
  33. package/skills/agentvfx/engine/node/ws-server.mjs +132 -0
  34. package/skills/agentvfx/engine/web/gl.mjs +319 -0
  35. package/skills/agentvfx/engine/web/glsl-common.mjs +78 -0
  36. package/skills/agentvfx/engine/web/init.js +23 -0
  37. package/skills/agentvfx/engine/web/prelude.mjs +150 -0
  38. package/skills/agentvfx/engine/web/render.html +11 -0
  39. package/skills/agentvfx/engine/web/render.mjs +388 -0
  40. package/skills/agentvfx/engine/web/scale.mjs +15 -0
  41. package/skills/agentvfx/engine/web/text.mjs +158 -0
  42. package/skills/agentvfx/plates/terminalcore/README.md +61 -0
  43. package/skills/agentvfx/plates/terminalcore/__pycache__/crt.cpython-313.pyc +0 -0
  44. package/skills/agentvfx/plates/terminalcore/__pycache__/font.cpython-313.pyc +0 -0
  45. package/skills/agentvfx/plates/terminalcore/__pycache__/gallery.cpython-313.pyc +0 -0
  46. package/skills/agentvfx/plates/terminalcore/__pycache__/gallery_mats.cpython-313.pyc +0 -0
  47. package/skills/agentvfx/plates/terminalcore/__pycache__/gallery_room.cpython-313.pyc +0 -0
  48. package/skills/agentvfx/plates/terminalcore/__pycache__/materials.cpython-313.pyc +0 -0
  49. package/skills/agentvfx/plates/terminalcore/__pycache__/nodekit.cpython-313.pyc +0 -0
  50. package/skills/agentvfx/plates/terminalcore/__pycache__/room.cpython-313.pyc +0 -0
  51. package/skills/agentvfx/plates/terminalcore/__pycache__/shots.cpython-313.pyc +0 -0
  52. package/skills/agentvfx/plates/terminalcore/__pycache__/textures.cpython-313.pyc +0 -0
  53. package/skills/agentvfx/plates/terminalcore/__pycache__/wall.cpython-313.pyc +0 -0
  54. package/skills/agentvfx/plates/terminalcore/crt.py +143 -0
  55. package/skills/agentvfx/plates/terminalcore/font.py +80 -0
  56. package/skills/agentvfx/plates/terminalcore/gallery.py +61 -0
  57. package/skills/agentvfx/plates/terminalcore/gallery_mats.py +144 -0
  58. package/skills/agentvfx/plates/terminalcore/gallery_room.py +126 -0
  59. package/skills/agentvfx/plates/terminalcore/materials.py +170 -0
  60. package/skills/agentvfx/plates/terminalcore/nodekit.py +87 -0
  61. package/skills/agentvfx/plates/terminalcore/room.py +82 -0
  62. package/skills/agentvfx/plates/terminalcore/scene.py +219 -0
  63. package/skills/agentvfx/plates/terminalcore/shots.py +48 -0
  64. package/skills/agentvfx/plates/terminalcore/textures.py +79 -0
  65. package/skills/agentvfx/plates/terminalcore/wall.py +103 -0
  66. package/skills/agentvfx/references/plates.md +22 -0
  67. package/skills/agentvfx/references/template-format.md +149 -0
  68. package/skills/agentvfx/references/web.md +63 -0
  69. package/skills/agentvfx/runtime/agentvfx.js +708 -0
  70. package/skills/agentvfx/schemas/fx-score.schema.json +98 -0
  71. package/skills/agentvfx/scripts/export-web.mjs +155 -0
  72. package/skills/agentvfx/scripts/loop.mjs +129 -0
  73. package/skills/agentvfx/scripts/make-beat.mjs +133 -0
  74. package/skills/agentvfx/scripts/plate.mjs +82 -0
  75. package/skills/agentvfx/scripts/vfx.mjs +173 -0
  76. package/skills/agentvfx/templates/_test/feedback-counter/fx.json +11 -0
  77. package/skills/agentvfx/templates/_test/feedback-counter/main.frag +4 -0
  78. package/skills/agentvfx/templates/_test/feedback-counter/pass0.frag +4 -0
  79. package/skills/agentvfx/templates/_test/gradient/fx.json +23 -0
  80. package/skills/agentvfx/templates/_test/gradient/main.frag +5 -0
  81. package/skills/agentvfx/templates/_test/identity/fx.json +10 -0
  82. package/skills/agentvfx/templates/_test/identity/main.frag +4 -0
  83. package/skills/agentvfx/templates/_test/strobe/fx.json +14 -0
  84. package/skills/agentvfx/templates/_test/strobe/main.frag +6 -0
  85. package/skills/agentvfx/templates/_test/text-probe/fx.json +15 -0
  86. package/skills/agentvfx/templates/_test/text-probe/main.frag +6 -0
  87. package/skills/agentvfx/templates/brutal/NOTES.md +14 -0
  88. package/skills/agentvfx/templates/brutal/_src/boot-log/def.mjs +57 -0
  89. package/skills/agentvfx/templates/brutal/_src/boot-log/main.src.frag +129 -0
  90. package/skills/agentvfx/templates/brutal/_src/build.mjs +33 -0
  91. package/skills/agentvfx/templates/brutal/_src/halftone-field/def.mjs +72 -0
  92. package/skills/agentvfx/templates/brutal/_src/halftone-field/main.src.frag +94 -0
  93. package/skills/agentvfx/templates/brutal/_src/hud-deck/deck-left.src.glsl +100 -0
  94. package/skills/agentvfx/templates/brutal/_src/hud-deck/deck-right.src.glsl +61 -0
  95. package/skills/agentvfx/templates/brutal/_src/hud-deck/deck-tiles.src.glsl +153 -0
  96. package/skills/agentvfx/templates/brutal/_src/hud-deck/def.mjs +82 -0
  97. package/skills/agentvfx/templates/brutal/_src/hud-deck/main.src.frag +110 -0
  98. package/skills/agentvfx/templates/brutal/_src/hud-deck/pass0.src.frag +38 -0
  99. package/skills/agentvfx/templates/brutal/_src/shared/defs.mjs +28 -0
  100. package/skills/agentvfx/templates/brutal/_src/shared/icons.glsl +72 -0
  101. package/skills/agentvfx/templates/brutal/_src/shared/lib.glsl +115 -0
  102. package/skills/agentvfx/templates/brutal/_src/shared/screen.glsl +43 -0
  103. package/skills/agentvfx/templates/brutal/boot-log/demo-acid.json +1 -0
  104. package/skills/agentvfx/templates/brutal/boot-log/demo-phosphor.json +1 -0
  105. package/skills/agentvfx/templates/brutal/boot-log/demo-ultramarine.json +1 -0
  106. package/skills/agentvfx/templates/brutal/boot-log/fx.json +257 -0
  107. package/skills/agentvfx/templates/brutal/boot-log/main.frag +242 -0
  108. package/skills/agentvfx/templates/brutal/collage/_src/00-lib.glsl +73 -0
  109. package/skills/agentvfx/templates/brutal/collage/_src/10-spectrum-scope.glsl +73 -0
  110. package/skills/agentvfx/templates/brutal/collage/_src/20-meter-readout-cross.glsl +87 -0
  111. package/skills/agentvfx/templates/brutal/collage/_src/30-footage-fillers.glsl +92 -0
  112. package/skills/agentvfx/templates/brutal/collage/_src/40-editorial.glsl +232 -0
  113. package/skills/agentvfx/templates/brutal/collage/_src/50-typefx.glsl +163 -0
  114. package/skills/agentvfx/templates/brutal/collage/_src/60-scene-lib.glsl +104 -0
  115. package/skills/agentvfx/templates/brutal/collage/_src/61-scene-specimen.glsl +71 -0
  116. package/skills/agentvfx/templates/brutal/collage/_src/62-scene-wiring.glsl +96 -0
  117. package/skills/agentvfx/templates/brutal/collage/_src/63-scene-fieldcut.glsl +119 -0
  118. package/skills/agentvfx/templates/brutal/collage/_src/64-scene-pattern.glsl +64 -0
  119. package/skills/agentvfx/templates/brutal/collage/_src/641-scene-anatomy.glsl +49 -0
  120. package/skills/agentvfx/templates/brutal/collage/_src/642-scene-deck.glsl +78 -0
  121. package/skills/agentvfx/templates/brutal/collage/_src/643-scene-bootlog.glsl +60 -0
  122. package/skills/agentvfx/templates/brutal/collage/_src/644-scene-tunnel.glsl +48 -0
  123. package/skills/agentvfx/templates/brutal/collage/_src/645-scene-runner.glsl +42 -0
  124. package/skills/agentvfx/templates/brutal/collage/_src/646-scene-ascii.glsl +66 -0
  125. package/skills/agentvfx/templates/brutal/collage/_src/647-scene-cubewall.glsl +80 -0
  126. package/skills/agentvfx/templates/brutal/collage/_src/648-scene-vortex.glsl +46 -0
  127. package/skills/agentvfx/templates/brutal/collage/_src/649-scene-sticker.glsl +72 -0
  128. package/skills/agentvfx/templates/brutal/collage/_src/65-scene-main.glsl +1 -0
  129. package/skills/agentvfx/templates/brutal/collage/_src/650-scene-ribbon.glsl +55 -0
  130. package/skills/agentvfx/templates/brutal/collage/_src/651-scene-slab.glsl +38 -0
  131. package/skills/agentvfx/templates/brutal/collage/_src/652-scene-framedial.glsl +79 -0
  132. package/skills/agentvfx/templates/brutal/collage/_src/653-scene-tilt.glsl +40 -0
  133. package/skills/agentvfx/templates/brutal/collage/_src/654-scene-marquee.glsl +45 -0
  134. package/skills/agentvfx/templates/brutal/collage/_src/655-scene-lens.glsl +57 -0
  135. package/skills/agentvfx/templates/brutal/collage/_src/656-scene-liquid.glsl +35 -0
  136. package/skills/agentvfx/templates/brutal/collage/_src/657-scene-panelgrid.glsl +75 -0
  137. package/skills/agentvfx/templates/brutal/collage/_src/658-scene-mirror.glsl +49 -0
  138. package/skills/agentvfx/templates/brutal/collage/_src/66-scene-main.glsl +27 -0
  139. package/skills/agentvfx/templates/brutal/collage/_src/90-main.glsl +120 -0
  140. package/skills/agentvfx/templates/brutal/collage/_src/build.mjs +24 -0
  141. package/skills/agentvfx/templates/brutal/collage/_src/sync-presets.mjs +16 -0
  142. package/skills/agentvfx/templates/brutal/collage/demo-bone-lime.json +1 -0
  143. package/skills/agentvfx/templates/brutal/collage/demo-lime-sparse.json +1 -0
  144. package/skills/agentvfx/templates/brutal/collage/demo-orange-dense.json +1 -0
  145. package/skills/agentvfx/templates/brutal/collage/demo-ultra-slow.json +1 -0
  146. package/skills/agentvfx/templates/brutal/collage/fx.json +4882 -0
  147. package/skills/agentvfx/templates/brutal/collage/layout.mjs +97 -0
  148. package/skills/agentvfx/templates/brutal/collage/layouts.json +366 -0
  149. package/skills/agentvfx/templates/brutal/collage/main.frag +2367 -0
  150. package/skills/agentvfx/templates/brutal/collage/pass0.frag +265 -0
  151. package/skills/agentvfx/templates/brutal/halftone-field/demo-acid.json +1 -0
  152. package/skills/agentvfx/templates/brutal/halftone-field/demo-ascii.json +1 -0
  153. package/skills/agentvfx/templates/brutal/halftone-field/demo-dither.json +1 -0
  154. package/skills/agentvfx/templates/brutal/halftone-field/demo-orange.json +1 -0
  155. package/skills/agentvfx/templates/brutal/halftone-field/demo-phosphor.json +1 -0
  156. package/skills/agentvfx/templates/brutal/halftone-field/demo-ultramarine.json +1 -0
  157. package/skills/agentvfx/templates/brutal/halftone-field/fx.json +474 -0
  158. package/skills/agentvfx/templates/brutal/halftone-field/main.frag +248 -0
  159. package/skills/agentvfx/templates/brutal/hud-deck/demo-acid.json +1 -0
  160. package/skills/agentvfx/templates/brutal/hud-deck/demo-night.json +1 -0
  161. package/skills/agentvfx/templates/brutal/hud-deck/demo-octagon.json +1 -0
  162. package/skills/agentvfx/templates/brutal/hud-deck/demo-ultramarine.json +1 -0
  163. package/skills/agentvfx/templates/brutal/hud-deck/fx.json +601 -0
  164. package/skills/agentvfx/templates/brutal/hud-deck/main.frag +645 -0
  165. package/skills/agentvfx/templates/brutal/hud-deck/pass0.frag +38 -0
  166. package/skills/agentvfx/templates/brutal/lattice/demo-cobalt-fine.json +1 -0
  167. package/skills/agentvfx/templates/brutal/lattice/demo-ink-yellow.json +1 -0
  168. package/skills/agentvfx/templates/brutal/lattice/demo-vermilion.json +1 -0
  169. package/skills/agentvfx/templates/brutal/lattice/demo-violet-slow.json +1 -0
  170. package/skills/agentvfx/templates/brutal/lattice/fx.json +130 -0
  171. package/skills/agentvfx/templates/brutal/lattice/main.frag +175 -0
  172. package/skills/agentvfx/templates/brutal/lattice/pass0.frag +29 -0
  173. package/skills/agentvfx/templates/glitch/block-glitch/demo-mosaic.json +1 -0
  174. package/skills/agentvfx/templates/glitch/block-glitch/demo-onset.json +1 -0
  175. package/skills/agentvfx/templates/glitch/block-glitch/demo-static.json +1 -0
  176. package/skills/agentvfx/templates/glitch/block-glitch/demo-tear.json +1 -0
  177. package/skills/agentvfx/templates/glitch/block-glitch/fx.json +54 -0
  178. package/skills/agentvfx/templates/glitch/block-glitch/main.frag +132 -0
  179. package/skills/agentvfx/templates/glitch/block-glitch/pass0.frag +12 -0
  180. package/skills/agentvfx/templates/glitch/pixel-sort/NOTES.md +13 -0
  181. package/skills/agentvfx/templates/glitch/pixel-sort/build-passes.mjs +162 -0
  182. package/skills/agentvfx/templates/glitch/pixel-sort/demo-chunk.json +1 -0
  183. package/skills/agentvfx/templates/glitch/pixel-sort/demo-hue.json +1 -0
  184. package/skills/agentvfx/templates/glitch/pixel-sort/demo-kick.json +1 -0
  185. package/skills/agentvfx/templates/glitch/pixel-sort/demo-streak.json +1 -0
  186. package/skills/agentvfx/templates/glitch/pixel-sort/demo-vertical.json +1 -0
  187. package/skills/agentvfx/templates/glitch/pixel-sort/fx.json +60 -0
  188. package/skills/agentvfx/templates/glitch/pixel-sort/main.frag +83 -0
  189. package/skills/agentvfx/templates/glitch/pixel-sort/pass0.frag +64 -0
  190. package/skills/agentvfx/templates/glitch/pixel-sort/pass1.frag +66 -0
  191. package/skills/agentvfx/templates/glitch/pixel-sort/pass2.frag +66 -0
  192. package/skills/agentvfx/templates/glitch/pixel-sort/pass3.frag +66 -0
  193. package/skills/agentvfx/templates/glitch/pixel-sort/pass4.frag +66 -0
  194. package/skills/agentvfx/templates/glitch/pixel-sort/pass5.frag +66 -0
  195. package/skills/agentvfx/templates/glitch/pixel-sort/pass6.frag +66 -0
  196. package/skills/agentvfx/templates/glitch/pixel-sort/pass7.frag +66 -0
  197. package/skills/agentvfx/templates/glitch/pixel-sort/pass8.frag +66 -0
  198. package/skills/agentvfx/templates/glitch/rgb-split/demo-diagonal-stutter.json +1 -0
  199. package/skills/agentvfx/templates/glitch/rgb-split/demo-hard.json +1 -0
  200. package/skills/agentvfx/templates/glitch/rgb-split/demo-kick.json +1 -0
  201. package/skills/agentvfx/templates/glitch/rgb-split/demo-radial.json +1 -0
  202. package/skills/agentvfx/templates/glitch/rgb-split/fx.json +46 -0
  203. package/skills/agentvfx/templates/glitch/rgb-split/main.frag +76 -0
  204. package/skills/agentvfx/templates/glitch/vhs/demo-clean.json +1 -0
  205. package/skills/agentvfx/templates/glitch/vhs/demo-crash.json +1 -0
  206. package/skills/agentvfx/templates/glitch/vhs/demo-tape.json +1 -0
  207. package/skills/agentvfx/templates/glitch/vhs/demo-worn.json +1 -0
  208. package/skills/agentvfx/templates/glitch/vhs/fx.json +46 -0
  209. package/skills/agentvfx/templates/glitch/vhs/main.frag +96 -0
  210. package/skills/agentvfx/templates/impact/impact-1bit/demo-onebit-bayer.json +1 -0
  211. package/skills/agentvfx/templates/impact/impact-1bit/fx.json +45 -0
  212. package/skills/agentvfx/templates/impact/impact-1bit/main.frag +64 -0
  213. package/skills/agentvfx/templates/impact/impact-invert/demo-invert-snap.json +1 -0
  214. package/skills/agentvfx/templates/impact/impact-invert/fx.json +37 -0
  215. package/skills/agentvfx/templates/impact/impact-invert/main.frag +44 -0
  216. package/skills/agentvfx/templates/impact/punch-shake/demo-punch-hard.json +1 -0
  217. package/skills/agentvfx/templates/impact/punch-shake/fx.json +36 -0
  218. package/skills/agentvfx/templates/impact/punch-shake/main.frag +62 -0
  219. package/skills/agentvfx/templates/impact/rgb-hit/demo-rgb-slam.json +1 -0
  220. package/skills/agentvfx/templates/impact/rgb-hit/fx.json +39 -0
  221. package/skills/agentvfx/templates/impact/rgb-hit/main.frag +62 -0
  222. package/skills/agentvfx/templates/impact/signal-cut/demo-lime-hold.json +1 -0
  223. package/skills/agentvfx/templates/impact/signal-cut/demo-lime.json +1 -0
  224. package/skills/agentvfx/templates/impact/signal-cut/demo-orange.json +1 -0
  225. package/skills/agentvfx/templates/impact/signal-cut/demo-ultramarine.json +1 -0
  226. package/skills/agentvfx/templates/impact/signal-cut/fx.json +83 -0
  227. package/skills/agentvfx/templates/impact/signal-cut/main.frag +101 -0
  228. package/skills/agentvfx/templates/impact/signal-cut/pass0.frag +68 -0
  229. package/skills/agentvfx/templates/impact/speedline-burst/demo-speed-white.json +1 -0
  230. package/skills/agentvfx/templates/impact/speedline-burst/fx.json +44 -0
  231. package/skills/agentvfx/templates/impact/speedline-burst/main.frag +68 -0
  232. package/skills/agentvfx/templates/impact/strobe-burst/demo-strobe-white-16.json +1 -0
  233. package/skills/agentvfx/templates/impact/strobe-burst/fx.json +42 -0
  234. package/skills/agentvfx/templates/impact/strobe-burst/main.frag +43 -0
  235. package/skills/agentvfx/templates/light/anamorphic-streak/demo-anamorphic-cinema.json +10 -0
  236. package/skills/agentvfx/templates/light/anamorphic-streak/demo-data.json +10 -0
  237. package/skills/agentvfx/templates/light/anamorphic-streak/fx.json +47 -0
  238. package/skills/agentvfx/templates/light/anamorphic-streak/main.frag +45 -0
  239. package/skills/agentvfx/templates/light/anamorphic-streak/pass0.frag +22 -0
  240. package/skills/agentvfx/templates/light/anamorphic-streak/pass1.frag +16 -0
  241. package/skills/agentvfx/templates/light/anamorphic-streak/pass2.frag +16 -0
  242. package/skills/agentvfx/templates/light/anamorphic-streak/pass3.frag +16 -0
  243. package/skills/agentvfx/templates/light/bloom-glow/demo-clip01-low.json +11 -0
  244. package/skills/agentvfx/templates/light/bloom-glow/demo-neon-night.json +10 -0
  245. package/skills/agentvfx/templates/light/bloom-glow/demo-phosphor.json +11 -0
  246. package/skills/agentvfx/templates/light/bloom-glow/fx.json +53 -0
  247. package/skills/agentvfx/templates/light/bloom-glow/main.frag +85 -0
  248. package/skills/agentvfx/templates/light/bloom-glow/pass0.frag +21 -0
  249. package/skills/agentvfx/templates/light/bloom-glow/pass1.frag +50 -0
  250. package/skills/agentvfx/templates/light/bloom-glow/pass2.frag +44 -0
  251. package/skills/agentvfx/templates/light/bloom-glow/pass3.frag +32 -0
  252. package/skills/agentvfx/templates/light/bloom-glow/pass4.frag +48 -0
  253. package/skills/agentvfx/templates/light/bloom-glow/pass5.frag +46 -0
  254. package/skills/agentvfx/templates/light/god-rays/demo-golden-hour.json +10 -0
  255. package/skills/agentvfx/templates/light/god-rays/demo-point-lamp.json +10 -0
  256. package/skills/agentvfx/templates/light/god-rays/fx.json +39 -0
  257. package/skills/agentvfx/templates/light/god-rays/main.frag +54 -0
  258. package/skills/agentvfx/templates/light/lens-flare/demo-clip01-bar.json +11 -0
  259. package/skills/agentvfx/templates/light/lens-flare/demo-eye-bar.json +10 -0
  260. package/skills/agentvfx/templates/light/lens-flare/demo-sun-ghosts.json +10 -0
  261. package/skills/agentvfx/templates/light/lens-flare/fx.json +49 -0
  262. package/skills/agentvfx/templates/light/lens-flare/main.frag +86 -0
  263. package/skills/agentvfx/templates/light/lens-flare/pass0.frag +24 -0
  264. package/skills/agentvfx/templates/light/light-leak/demo-slit.json +10 -0
  265. package/skills/agentvfx/templates/light/light-leak/demo-vintage-burn.json +10 -0
  266. package/skills/agentvfx/templates/light/light-leak/fx.json +40 -0
  267. package/skills/agentvfx/templates/light/light-leak/main.frag +46 -0
  268. package/skills/agentvfx/templates/light/light-stage/fx.json +29 -0
  269. package/skills/agentvfx/templates/light/light-stage/main.frag +56 -0
  270. package/skills/agentvfx/templates/light/light-sweep/demo-hard-bar.json +12 -0
  271. package/skills/agentvfx/templates/light/light-sweep/demo-logo-sweep.json +10 -0
  272. package/skills/agentvfx/templates/light/light-sweep/demo-onset.json +11 -0
  273. package/skills/agentvfx/templates/light/light-sweep/fx.json +45 -0
  274. package/skills/agentvfx/templates/light/light-sweep/main.frag +29 -0
  275. package/skills/agentvfx/templates/light/light-sweep/pass0.frag +17 -0
  276. package/skills/agentvfx/templates/light/light-sweep/pass1.frag +15 -0
  277. package/skills/agentvfx/templates/light/neon-saber/demo-hairline.json +10 -0
  278. package/skills/agentvfx/templates/light/neon-saber/demo-saber-laser.json +10 -0
  279. package/skills/agentvfx/templates/light/neon-saber/fx.json +48 -0
  280. package/skills/agentvfx/templates/light/neon-saber/main.frag +27 -0
  281. package/skills/agentvfx/templates/light/neon-saber/pass0.frag +46 -0
  282. package/skills/agentvfx/templates/light/neon-saber/pass1.frag +15 -0
  283. package/skills/agentvfx/templates/psychedelic/echo-flow/demo-trail.json +1 -0
  284. package/skills/agentvfx/templates/psychedelic/echo-flow/fx.json +38 -0
  285. package/skills/agentvfx/templates/psychedelic/echo-flow/main.frag +19 -0
  286. package/skills/agentvfx/templates/psychedelic/echo-flow/pass0.frag +16 -0
  287. package/skills/agentvfx/templates/psychedelic/echo-flow/pass1.frag +20 -0
  288. package/skills/agentvfx/templates/psychedelic/echo-flow/pass2.frag +11 -0
  289. package/skills/agentvfx/templates/psychedelic/echo-flow/pass3.frag +4 -0
  290. package/skills/agentvfx/templates/psychedelic/hologram-scan/demo-cyan.json +1 -0
  291. package/skills/agentvfx/templates/psychedelic/hologram-scan/fx.json +36 -0
  292. package/skills/agentvfx/templates/psychedelic/hologram-scan/main.frag +30 -0
  293. package/skills/agentvfx/templates/psychedelic/kaleido-fold/demo-six.json +1 -0
  294. package/skills/agentvfx/templates/psychedelic/kaleido-fold/fx.json +37 -0
  295. package/skills/agentvfx/templates/psychedelic/kaleido-fold/main.frag +10 -0
  296. package/skills/agentvfx/templates/psychedelic/kaleido-fold/pass0.frag +34 -0
  297. package/skills/agentvfx/templates/psychedelic/mosh-melt/demo-classic.json +1 -0
  298. package/skills/agentvfx/templates/psychedelic/mosh-melt/fx.json +38 -0
  299. package/skills/agentvfx/templates/psychedelic/mosh-melt/main.frag +20 -0
  300. package/skills/agentvfx/templates/psychedelic/mosh-melt/pass0.frag +22 -0
  301. package/skills/agentvfx/templates/psychedelic/sacred/NOTES.md +13 -0
  302. package/skills/agentvfx/templates/psychedelic/sacred/demo-classic.json +1 -0
  303. package/skills/agentvfx/templates/psychedelic/sacred/demo-halo.json +1 -0
  304. package/skills/agentvfx/templates/psychedelic/sacred/demo-slow-tide.json +1 -0
  305. package/skills/agentvfx/templates/psychedelic/sacred/demo-thermal.json +1 -0
  306. package/skills/agentvfx/templates/psychedelic/sacred/fx.json +263 -0
  307. package/skills/agentvfx/templates/psychedelic/sacred/main.frag +109 -0
  308. package/skills/agentvfx/templates/psychedelic/sacred/pass0.frag +25 -0
  309. package/skills/agentvfx/templates/psychedelic/sacred/pass1.frag +23 -0
  310. package/skills/agentvfx/templates/psychedelic/tidal-bands/demo-classic.json +1 -0
  311. package/skills/agentvfx/templates/psychedelic/tidal-bands/fx.json +37 -0
  312. package/skills/agentvfx/templates/psychedelic/tidal-bands/main.frag +54 -0
  313. package/skills/agentvfx/templates/scope/_chrome.glsl +242 -0
  314. package/skills/agentvfx/templates/scope/goniometer/demo-boot-green.json +1 -0
  315. package/skills/agentvfx/templates/scope/goniometer/demo-field-lime.json +1 -0
  316. package/skills/agentvfx/templates/scope/goniometer/demo-field-ultramarine.json +1 -0
  317. package/skills/agentvfx/templates/scope/goniometer/demo-glow-phosphor.json +1 -0
  318. package/skills/agentvfx/templates/scope/goniometer/demo-hud-black.json +1 -0
  319. package/skills/agentvfx/templates/scope/goniometer/fx.json +635 -0
  320. package/skills/agentvfx/templates/scope/goniometer/main.frag +33 -0
  321. package/skills/agentvfx/templates/scope/goniometer/pass0.frag +58 -0
  322. package/skills/agentvfx/templates/scope/goniometer/pass1.frag +43 -0
  323. package/skills/agentvfx/templates/scope/goniometer/pass2.frag +12 -0
  324. package/skills/agentvfx/templates/scope/goniometer/pass3.frag +12 -0
  325. package/skills/agentvfx/templates/scope/goniometer/pass4.frag +12 -0
  326. package/skills/agentvfx/templates/scope/goniometer/pass5.frag +12 -0
  327. package/skills/agentvfx/templates/scope/goniometer/pass6.frag +251 -0
  328. package/skills/agentvfx/templates/scope/scope-polar/demo-boot-green.json +1 -0
  329. package/skills/agentvfx/templates/scope/scope-polar/demo-field-lime.json +1 -0
  330. package/skills/agentvfx/templates/scope/scope-polar/demo-field-ultramarine.json +1 -0
  331. package/skills/agentvfx/templates/scope/scope-polar/demo-glow-phosphor.json +1 -0
  332. package/skills/agentvfx/templates/scope/scope-polar/demo-hud-black.json +1 -0
  333. package/skills/agentvfx/templates/scope/scope-polar/fx.json +686 -0
  334. package/skills/agentvfx/templates/scope/scope-polar/main.frag +39 -0
  335. package/skills/agentvfx/templates/scope/scope-polar/pass0.frag +84 -0
  336. package/skills/agentvfx/templates/scope/scope-polar/pass1.frag +49 -0
  337. package/skills/agentvfx/templates/scope/scope-polar/pass2.frag +12 -0
  338. package/skills/agentvfx/templates/scope/scope-polar/pass3.frag +12 -0
  339. package/skills/agentvfx/templates/scope/scope-polar/pass4.frag +12 -0
  340. package/skills/agentvfx/templates/scope/scope-polar/pass5.frag +12 -0
  341. package/skills/agentvfx/templates/scope/scope-polar/pass6.frag +251 -0
  342. package/skills/agentvfx/templates/scope/scope-triggered/demo-boot-green.json +1 -0
  343. package/skills/agentvfx/templates/scope/scope-triggered/demo-field-lime.json +1 -0
  344. package/skills/agentvfx/templates/scope/scope-triggered/demo-field-ultramarine.json +1 -0
  345. package/skills/agentvfx/templates/scope/scope-triggered/demo-glow-phosphor.json +1 -0
  346. package/skills/agentvfx/templates/scope/scope-triggered/demo-hud-black.json +1 -0
  347. package/skills/agentvfx/templates/scope/scope-triggered/fx.json +712 -0
  348. package/skills/agentvfx/templates/scope/scope-triggered/main.frag +36 -0
  349. package/skills/agentvfx/templates/scope/scope-triggered/pass0.frag +78 -0
  350. package/skills/agentvfx/templates/scope/scope-triggered/pass1.frag +50 -0
  351. package/skills/agentvfx/templates/scope/scope-triggered/pass2.frag +12 -0
  352. package/skills/agentvfx/templates/scope/scope-triggered/pass3.frag +12 -0
  353. package/skills/agentvfx/templates/scope/scope-triggered/pass4.frag +12 -0
  354. package/skills/agentvfx/templates/scope/scope-triggered/pass5.frag +12 -0
  355. package/skills/agentvfx/templates/scope/scope-triggered/pass6.frag +251 -0
  356. package/skills/agentvfx/templates/scope/spectrogram-scroll/demo-boot-green.json +1 -0
  357. package/skills/agentvfx/templates/scope/spectrogram-scroll/demo-field-lime.json +1 -0
  358. package/skills/agentvfx/templates/scope/spectrogram-scroll/demo-field-ultramarine.json +1 -0
  359. package/skills/agentvfx/templates/scope/spectrogram-scroll/demo-glow-phosphor.json +1 -0
  360. package/skills/agentvfx/templates/scope/spectrogram-scroll/demo-hud-black.json +1 -0
  361. package/skills/agentvfx/templates/scope/spectrogram-scroll/fx.json +595 -0
  362. package/skills/agentvfx/templates/scope/spectrogram-scroll/main.frag +83 -0
  363. package/skills/agentvfx/templates/scope/spectrogram-scroll/pass0.frag +52 -0
  364. package/skills/agentvfx/templates/scope/spectrogram-scroll/pass1.frag +251 -0
  365. package/skills/agentvfx/templates/scope/xy-phosphor/demo-boot-green.json +1 -0
  366. package/skills/agentvfx/templates/scope/xy-phosphor/demo-field-lime.json +1 -0
  367. package/skills/agentvfx/templates/scope/xy-phosphor/demo-field-ultramarine.json +1 -0
  368. package/skills/agentvfx/templates/scope/xy-phosphor/demo-glow-phosphor.json +1 -0
  369. package/skills/agentvfx/templates/scope/xy-phosphor/demo-hud-black.json +1 -0
  370. package/skills/agentvfx/templates/scope/xy-phosphor/fx.json +642 -0
  371. package/skills/agentvfx/templates/scope/xy-phosphor/main.frag +33 -0
  372. package/skills/agentvfx/templates/scope/xy-phosphor/pass0.frag +56 -0
  373. package/skills/agentvfx/templates/scope/xy-phosphor/pass1.frag +44 -0
  374. package/skills/agentvfx/templates/scope/xy-phosphor/pass2.frag +12 -0
  375. package/skills/agentvfx/templates/scope/xy-phosphor/pass3.frag +12 -0
  376. package/skills/agentvfx/templates/scope/xy-phosphor/pass4.frag +12 -0
  377. package/skills/agentvfx/templates/scope/xy-phosphor/pass5.frag +12 -0
  378. package/skills/agentvfx/templates/scope/xy-phosphor/pass6.frag +251 -0
  379. package/skills/agentvfx/templates/spectrum/_src/bars-linear/fx.src.json +61 -0
  380. package/skills/agentvfx/templates/spectrum/_src/bars-linear/main.src.frag +112 -0
  381. package/skills/agentvfx/templates/spectrum/_src/bars-linear/pass0.src.frag +2 -0
  382. package/skills/agentvfx/templates/spectrum/_src/bars-mirror/fx.src.json +51 -0
  383. package/skills/agentvfx/templates/spectrum/_src/bars-mirror/main.src.frag +72 -0
  384. package/skills/agentvfx/templates/spectrum/_src/bars-mirror/pass0.src.frag +2 -0
  385. package/skills/agentvfx/templates/spectrum/_src/bass-circle/fx.src.json +56 -0
  386. package/skills/agentvfx/templates/spectrum/_src/bass-circle/main.src.frag +136 -0
  387. package/skills/agentvfx/templates/spectrum/_src/bass-circle/pass0.src.frag +2 -0
  388. package/skills/agentvfx/templates/spectrum/_src/build.mjs +68 -0
  389. package/skills/agentvfx/templates/spectrum/_src/label-bars/fx.src.json +54 -0
  390. package/skills/agentvfx/templates/spectrum/_src/label-bars/main.src.frag +102 -0
  391. package/skills/agentvfx/templates/spectrum/_src/label-bars/pass0.src.frag +2 -0
  392. package/skills/agentvfx/templates/spectrum/_src/shared/bars-fn.glsl +64 -0
  393. package/skills/agentvfx/templates/spectrum/_src/shared/bars-pass.glsl +22 -0
  394. package/skills/agentvfx/templates/spectrum/_src/shared/clock.glsl +7 -0
  395. package/skills/agentvfx/templates/spectrum/_src/shared/hud.glsl +50 -0
  396. package/skills/agentvfx/templates/spectrum/_src/shared/stage.glsl +74 -0
  397. package/skills/agentvfx/templates/spectrum/_src/spectrum-particles/fx.src.json +58 -0
  398. package/skills/agentvfx/templates/spectrum/_src/spectrum-particles/main.src.frag +119 -0
  399. package/skills/agentvfx/templates/spectrum/_src/spectrum-particles/pass0.src.frag +33 -0
  400. package/skills/agentvfx/templates/spectrum/_src/spectrum-radial/fx.src.json +56 -0
  401. package/skills/agentvfx/templates/spectrum/_src/spectrum-radial/main.src.frag +95 -0
  402. package/skills/agentvfx/templates/spectrum/_src/spectrum-radial/pass0.src.frag +2 -0
  403. package/skills/agentvfx/templates/spectrum/_src/waveform-line/fx.src.json +60 -0
  404. package/skills/agentvfx/templates/spectrum/_src/waveform-line/main.src.frag +98 -0
  405. package/skills/agentvfx/templates/spectrum/_src/waveform-line/pass0.src.frag +43 -0
  406. package/skills/agentvfx/templates/spectrum/bars-linear/demo-graph-acid.json +1 -0
  407. package/skills/agentvfx/templates/spectrum/bars-linear/demo-graph-black.json +1 -0
  408. package/skills/agentvfx/templates/spectrum/bars-linear/fx.json +632 -0
  409. package/skills/agentvfx/templates/spectrum/bars-linear/main.frag +233 -0
  410. package/skills/agentvfx/templates/spectrum/bars-linear/pass0.frag +91 -0
  411. package/skills/agentvfx/templates/spectrum/bars-mirror/demo-field-acid.json +1 -0
  412. package/skills/agentvfx/templates/spectrum/bars-mirror/demo-field-ultramarine.json +1 -0
  413. package/skills/agentvfx/templates/spectrum/bars-mirror/fx.json +539 -0
  414. package/skills/agentvfx/templates/spectrum/bars-mirror/main.frag +193 -0
  415. package/skills/agentvfx/templates/spectrum/bars-mirror/pass0.frag +91 -0
  416. package/skills/agentvfx/templates/spectrum/bass-circle/demo-bracket-black.json +1 -0
  417. package/skills/agentvfx/templates/spectrum/bass-circle/demo-bracket-ultramarine.json +1 -0
  418. package/skills/agentvfx/templates/spectrum/bass-circle/fx.json +552 -0
  419. package/skills/agentvfx/templates/spectrum/bass-circle/main.frag +258 -0
  420. package/skills/agentvfx/templates/spectrum/bass-circle/pass0.frag +91 -0
  421. package/skills/agentvfx/templates/spectrum/label-bars/demo-deck-black.json +1 -0
  422. package/skills/agentvfx/templates/spectrum/label-bars/demo-deck-ultramarine.json +1 -0
  423. package/skills/agentvfx/templates/spectrum/label-bars/fx.json +552 -0
  424. package/skills/agentvfx/templates/spectrum/label-bars/main.frag +223 -0
  425. package/skills/agentvfx/templates/spectrum/label-bars/pass0.frag +91 -0
  426. package/skills/agentvfx/templates/spectrum/spectrum-particles/demo-cloud-black.json +1 -0
  427. package/skills/agentvfx/templates/spectrum/spectrum-particles/demo-cloud-ultramarine.json +1 -0
  428. package/skills/agentvfx/templates/spectrum/spectrum-particles/fx.json +584 -0
  429. package/skills/agentvfx/templates/spectrum/spectrum-particles/main.frag +240 -0
  430. package/skills/agentvfx/templates/spectrum/spectrum-particles/pass0.frag +101 -0
  431. package/skills/agentvfx/templates/spectrum/spectrum-radial/demo-starburst-black.json +1 -0
  432. package/skills/agentvfx/templates/spectrum/spectrum-radial/demo-starburst-ultramarine.json +1 -0
  433. package/skills/agentvfx/templates/spectrum/spectrum-radial/fx.json +566 -0
  434. package/skills/agentvfx/templates/spectrum/spectrum-radial/main.frag +217 -0
  435. package/skills/agentvfx/templates/spectrum/spectrum-radial/pass0.frag +91 -0
  436. package/skills/agentvfx/templates/spectrum/waveform-line/demo-strip-acid.json +1 -0
  437. package/skills/agentvfx/templates/spectrum/waveform-line/demo-strip-black.json +1 -0
  438. package/skills/agentvfx/templates/spectrum/waveform-line/fx.json +481 -0
  439. package/skills/agentvfx/templates/spectrum/waveform-line/main.frag +219 -0
  440. package/skills/agentvfx/templates/spectrum/waveform-line/pass0.frag +48 -0
  441. package/skills/agentvfx/templates/spectrum/waveform-line/pass1.frag +86 -0
  442. package/skills/agentvfx/test/_render_light.mjs +38 -0
  443. package/skills/agentvfx/test/audio-stereo.test.mjs +45 -0
  444. package/skills/agentvfx/test/audio.test.mjs +257 -0
  445. package/skills/agentvfx/test/brutal.test.mjs +190 -0
  446. package/skills/agentvfx/test/concept-collage-layout.test.mjs +236 -0
  447. package/skills/agentvfx/test/concept-collage-scenes.test.mjs +305 -0
  448. package/skills/agentvfx/test/concept-collage-typefx.test.mjs +153 -0
  449. package/skills/agentvfx/test/concept-collage.test.mjs +84 -0
  450. package/skills/agentvfx/test/concept-lattice.test.mjs +133 -0
  451. package/skills/agentvfx/test/concept-signal-cut.test.mjs +172 -0
  452. package/skills/agentvfx/test/credit-overlay.test.mjs +58 -0
  453. package/skills/agentvfx/test/credit.test.mjs +42 -0
  454. package/skills/agentvfx/test/doctor.test.mjs +31 -0
  455. package/skills/agentvfx/test/encode.test.mjs +22 -0
  456. package/skills/agentvfx/test/fixtures/r7-collage-LAYOUTS.json +5780 -0
  457. package/skills/agentvfx/test/fixtures/score-bad-duration.json +7 -0
  458. package/skills/agentvfx/test/fixtures/score-bad-safety.json +8 -0
  459. package/skills/agentvfx/test/fixtures/score-identity-footage.json +8 -0
  460. package/skills/agentvfx/test/fixtures/score-missing-template.json +7 -0
  461. package/skills/agentvfx/test/fixtures/score-ok.json +8 -0
  462. package/skills/agentvfx/test/fixtures/score-strobe-12hz.json +8 -0
  463. package/skills/agentvfx/test/fixtures/score-text-probe.json +1 -0
  464. package/skills/agentvfx/test/flash-audit.test.mjs +150 -0
  465. package/skills/agentvfx/test/flash.test.mjs +83 -0
  466. package/skills/agentvfx/test/footage.test.mjs +88 -0
  467. package/skills/agentvfx/test/glitch.test.mjs +272 -0
  468. package/skills/agentvfx/test/impact.test.mjs +231 -0
  469. package/skills/agentvfx/test/imports.test.mjs +39 -0
  470. package/skills/agentvfx/test/light.test.mjs +200 -0
  471. package/skills/agentvfx/test/loop.test.mjs +80 -0
  472. package/skills/agentvfx/test/psychedelic.test.mjs +99 -0
  473. package/skills/agentvfx/test/render.test.mjs +73 -0
  474. package/skills/agentvfx/test/sacred.test.mjs +175 -0
  475. package/skills/agentvfx/test/schema.test.mjs +103 -0
  476. package/skills/agentvfx/test/scope.test.mjs +306 -0
  477. package/skills/agentvfx/test/spectrum.test.mjs +165 -0
  478. package/skills/agentvfx/test/text.test.mjs +142 -0
  479. package/skills/agentvfx/test/web.test.mjs +397 -0
  480. package/skills/agentvfx/test-media/SOURCES.md +39 -0
  481. package/skills/agentvfx/test-media/beat-132.mp3 +0 -0
  482. package/skills/agentvfx/test-media/clip-01.mp4 +0 -0
  483. package/skills/agentvfx/test-media/clip-02.mp4 +0 -0
@@ -0,0 +1,231 @@
1
+ import { after, before, describe, it } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { spawnSync } from "node:child_process";
4
+ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
5
+ import { tmpdir } from "node:os";
6
+ import path from "node:path";
7
+ import { loadLibrary } from "../engine/core/templates.mjs";
8
+ import { validateScore } from "../engine/core/validate.mjs";
9
+ import { renderScore } from "../engine/node/render.mjs";
10
+ import { runJob } from "../engine/node/job.mjs";
11
+ import { findFfmpeg } from "../engine/node/encode.mjs";
12
+ import { openFootage } from "../engine/node/footage.mjs";
13
+
14
+ const lib = loadLibrary();
15
+ const W = 320;
16
+ const H = 180;
17
+ const SR = 48000;
18
+ const IDS = ["impact-invert", "impact-1bit", "punch-shake", "rgb-hit", "speedline-burst", "strobe-burst"];
19
+ const FLASHING = { "impact-invert": "possible", "impact-1bit": "possible", "speedline-burst": "possible", "strobe-burst": "strobe" };
20
+ let tmp;
21
+ let clip;
22
+ let click;
23
+ let calm;
24
+ let baseFrames;
25
+
26
+ function wav(seconds, times) {
27
+ const n = Math.floor(seconds * SR);
28
+ const data = Buffer.alloc(n * 4);
29
+ for (const c of times) {
30
+ for (let k = 0; k < 96 && Math.floor(c * SR) + k < n; k++) {
31
+ const v = Math.round(Math.sin((2 * Math.PI * 2000 * k) / SR) * Math.exp(-k / 24) * 0.9 * 32767);
32
+ const o = (Math.floor(c * SR) + k) * 4;
33
+ data.writeInt16LE(v, o);
34
+ data.writeInt16LE(v, o + 2);
35
+ }
36
+ }
37
+ const h = Buffer.alloc(44);
38
+ h.write("RIFF", 0);
39
+ h.writeUInt32LE(36 + data.length, 4);
40
+ h.write("WAVEfmt ", 8);
41
+ h.writeUInt32LE(16, 16);
42
+ h.writeUInt16LE(1, 20);
43
+ h.writeUInt16LE(2, 22);
44
+ h.writeUInt32LE(SR, 24);
45
+ h.writeUInt32LE(SR * 4, 28);
46
+ h.writeUInt16LE(4, 32);
47
+ h.writeUInt16LE(16, 34);
48
+ h.write("data", 36);
49
+ h.writeUInt32LE(data.length, 40);
50
+ return Buffer.concat([h, data]);
51
+ }
52
+
53
+ const score = (hits, extra = {}) => {
54
+ const v = validateScore({ version: 1, template: "sacred", params: { blend: 0 }, input: { video: clip }, durationSec: 3, seed: 5, hits, out: "t", credit: { overlay: false }, ...extra }, lib);
55
+ assert.equal(v.ok, true, JSON.stringify(v.errors));
56
+ return v.value;
57
+ };
58
+
59
+ async function frames(sc, keep, audio = null) {
60
+ const footage = openFootage(clip, { fps: 30, durationSec: sc.durationSec, longEdge: W });
61
+ const kept = new Map();
62
+ const dir = mkdtempSync(path.join(tmp, "r-"));
63
+ try {
64
+ await renderScore(sc, lib, { outDir: dir, width: W, height: H, footage, replay: false, features: audio, onFrame: (f, a) => { if (keep.includes(f)) kept.set(f, Buffer.from(a.rgba)); } });
65
+ } finally {
66
+ footage.close();
67
+ }
68
+ return kept;
69
+ }
70
+
71
+ function diff(a, b, ch = [0, 1, 2]) {
72
+ let s = 0;
73
+ for (let i = 0; i < W * H; i++) for (const c of ch) s += Math.abs(a[i * 4 + c] - b[i * 4 + c]);
74
+ return s / (W * H * ch.length);
75
+ }
76
+ const same = (a, b) => diff(a, b) === 0;
77
+
78
+ function lumaPerFrame(film) {
79
+ const r = spawnSync(findFfmpeg(), ["-v", "error", "-i", film, "-vf", "scale=16:9:flags=area,format=gray", "-f", "rawvideo", "-"], { maxBuffer: 1 << 26 });
80
+ assert.equal(r.status, 0, r.stderr?.toString());
81
+ const out = [];
82
+ for (let f = 0; f * 144 < r.stdout.length; f++) out.push(r.stdout.subarray(f * 144, f * 144 + 144).reduce((s, v) => s + v, 0) / 144);
83
+ return out;
84
+ }
85
+
86
+ before(async () => {
87
+ tmp = mkdtempSync(path.join(tmpdir(), "agentvfx-impact-"));
88
+ clip = path.join(tmp, "in.mp4");
89
+ const r = spawnSync(findFfmpeg(), ["-v", "error", "-y", "-f", "lavfi", "-i", `testsrc2=size=${W}x${H}:rate=30`, "-t", "4", "-c:v", "libx264", "-pix_fmt", "yuv420p", clip], { encoding: "utf8" });
90
+ assert.equal(r.status, 0, r.stderr);
91
+ calm = path.join(tmp, "calm.mp4");
92
+ const g = spawnSync(findFfmpeg(), ["-v", "error", "-y", "-f", "lavfi", "-i", `color=c=0x3a4048:size=${W}x${H}:rate=30`, "-t", "4", "-c:v", "libx264", "-pix_fmt", "yuv420p", calm], { encoding: "utf8" });
93
+ assert.equal(g.status, 0, g.stderr);
94
+ click = path.join(tmp, "click-240.wav");
95
+ writeFileSync(click, wav(4, Array.from({ length: 15 }, (_, k) => k * 0.25)));
96
+ baseFrames = await frames(score([]), Array.from({ length: 90 }, (_, i) => i));
97
+ });
98
+ after(() => rmSync(tmp, { recursive: true, force: true }));
99
+
100
+ describe("impact family library contract", () => {
101
+ for (const id of IDS) {
102
+ it(`${id}: declared honestly, 3+ presets, safe substitute for flashing templates, demo validates`, () => {
103
+ const t = lib.get(id);
104
+ assert.ok(t, `${id} missing from the library`);
105
+ assert.equal(t.family, "impact");
106
+ assert.ok(Object.keys(t.fx.X_AGENTVFX.presets).length >= 3);
107
+ assert.equal(t.fx.X_AGENTVFX.flash, FLASHING[id] ?? "none");
108
+ if (FLASHING[id]) {
109
+ const sub = t.fx.X_AGENTVFX.safeSubstitute;
110
+ assert.ok(sub, `${id} needs safeSubstitute`);
111
+ if (sub.template) assert.equal(lib.get(sub.template).fx.X_AGENTVFX.flash, "none");
112
+ else assert.ok(sub.params && sub.params.pulses === 1 && sub.params.level <= 0.09, "params-only substitute must be a single low-level pulse");
113
+ }
114
+ for (const preset of Object.keys(t.fx.X_AGENTVFX.presets)) score([{ t: 1, template: id, preset, durationFrames: 6 }]);
115
+ });
116
+ }
117
+ });
118
+
119
+ describe("hit behaviour at frame level (hit at frame 30)", () => {
120
+ const run = async (id, preset, durationFrames, params, keep) => frames(score([{ t: 1, template: id, preset, params, durationFrames }]), keep);
121
+
122
+ it("impact-invert: hard negative, chunky (no blended pixels) while decaying, clean after", async () => {
123
+ const k = await run("impact-invert", "invert-snap", 4, { hitFrames: 4, holdFrames: 1, decayCurve: 1 }, [29, 30, 31, 34]);
124
+ assert.ok(same(k.get(29), baseFrames.get(29)));
125
+ assert.ok(diff(k.get(30), baseFrames.get(30)) > 60, "frame 30 is a hard negative");
126
+ const a = k.get(31);
127
+ const b = baseFrames.get(31);
128
+ let changed = 0;
129
+ let acc = 0;
130
+ for (let i = 0; i < W * H; i++) {
131
+ const d = Math.abs(a[i * 4] - b[i * 4]) + Math.abs(a[i * 4 + 1] - b[i * 4 + 1]) + Math.abs(a[i * 4 + 2] - b[i * 4 + 2]);
132
+ if (d > 6) { changed += 1; acc += d; }
133
+ }
134
+ const frac = changed / (W * H);
135
+ assert.ok(frac > 0.2 && frac < 0.95, `decay frame changes ${(frac * 100).toFixed(0)}% of pixels`);
136
+ assert.ok(acc / changed / 3 > 40, "changed pixels are fully inverted, not a milky mix");
137
+ assert.ok(same(k.get(34), baseFrames.get(34)), "clean frame after the hit");
138
+ });
139
+
140
+ it("impact-1bit: two flat colours only, clean after the hit", async () => {
141
+ const k = await run("impact-1bit", "onebit-hard", 3, { hitFrames: 3, holdFrames: 2 }, [30, 33]);
142
+ const f = k.get(30);
143
+ let flat = 0;
144
+ for (let i = 0; i < W * H; i++) if ([0, 1, 2].every((c) => f[i * 4 + c] <= 8) || [0, 1, 2].every((c) => f[i * 4 + c] >= 247)) flat += 1;
145
+ assert.ok(flat / (W * H) > 0.99, `${((flat / (W * H)) * 100).toFixed(1)}% pure black or white`);
146
+ assert.ok(same(k.get(33), baseFrames.get(33)));
147
+ });
148
+
149
+ it("punch-shake: scales and shakes the frame, decays, clean after hitFrames", async () => {
150
+ const k = await run("punch-shake", "punch-hard", 6, {}, [29, 30, 32, 35, 36]);
151
+ assert.ok(same(k.get(29), baseFrames.get(29)));
152
+ const d0 = diff(k.get(30), baseFrames.get(30));
153
+ assert.ok(d0 > 15, `punch frame differs by ${d0.toFixed(1)}`);
154
+ assert.ok(diff(k.get(35), baseFrames.get(35)) < d0, "decays");
155
+ assert.ok(same(k.get(36), baseFrames.get(36)));
156
+ });
157
+
158
+ it("rgb-hit: only red and blue move, green untouched, back to clean", async () => {
159
+ const k = await run("rgb-hit", "rgb-slam", 6, { tearRows: 0, pop: 1, hitFrames: 6 }, [30, 36]);
160
+ const a = k.get(30);
161
+ const b = baseFrames.get(30);
162
+ assert.ok(diff(a, b, [1]) <= 1, "green channel unchanged");
163
+ assert.ok(diff(a, b, [0]) > 4 && diff(a, b, [2]) > 4, "red and blue are displaced");
164
+ assert.ok(same(k.get(36), baseFrames.get(36)));
165
+ });
166
+
167
+ it("speedline-burst: hard white core at the centre, lines reach the edge, clean after", async () => {
168
+ const k = await run("speedline-burst", "speed-white", 5, {}, [30, 35]);
169
+ const f = k.get(30);
170
+ const o = ((H >> 1) * W + (W >> 1)) * 4;
171
+ assert.deepEqual([f[o], f[o + 1], f[o + 2]], [255, 255, 255]);
172
+ assert.ok(diff(f, baseFrames.get(30)) > 20);
173
+ assert.ok(same(k.get(35), baseFrames.get(35)));
174
+ });
175
+ });
176
+
177
+ describe("strobe-burst: 240 BPM grid, stage and safe variant", () => {
178
+ const P = { tempo: 240, division: 16, pulses: 8, duty: 0.5, offDim: 0.35 };
179
+ const period = (60 / 240 * 4) / 16 * 30;
180
+ const litAt = (n) => {
181
+ const p = Math.floor(n / period + 1e-4);
182
+ return p < P.pulses && n - p * period < Math.max(1, Math.floor(period * P.duty + 0.5)) - 1e-4;
183
+ };
184
+ const sc = () => score([], { input: { video: clip, audio: click }, durationSec: 4 });
185
+
186
+ it("stage mode renders every scheduled flash on the detected beats, writes SAFETY.txt", async () => {
187
+ const dir = mkdtempSync(path.join(tmp, "job-"));
188
+ const probe = await runJob({ ...sc(), hits: [] }, lib, { outDir: dir, width: 160, height: 90, replay: false });
189
+ const beats = JSON.parse(readFileSync(path.join(dir, "features.json"), "utf8")).meta.beats;
190
+ assert.ok(beats.length >= 4, `only ${beats.length} beats detected`);
191
+ for (const b of beats) assert.ok(Array.from({ length: 16 }, (_, k) => Math.round(k * 7.5)).some((c) => Math.abs(c - b) <= 1), `beat ${b} is not on the 240 BPM clicks`);
192
+ assert.equal(probe.ok, true);
193
+ const hitLen = 8;
194
+ const run = await runJob(score(beats.map((b) => ({ beat: beats.indexOf(b), template: "strobe-burst", params: P, durationFrames: hitLen })), { input: { video: clip, audio: click }, durationSec: 4 }), lib, { outDir: dir, width: W, height: H, replay: false });
195
+ const lum = lumaPerFrame(run.render.film);
196
+ for (const b of beats) {
197
+ if (b + hitLen > lum.length) continue;
198
+ assert.ok(lum[b] > 240, `hit at beat ${b} is not a full white frame (${lum[b].toFixed(0)})`);
199
+ for (let n = 0; n < hitLen; n++) {
200
+ if (litAt(n)) assert.ok(lum[b + n] > 240, `scheduled flash at beat ${b}+${n} missing (${lum[b + n].toFixed(0)})`);
201
+ else assert.ok(lum[b + n] < 240, `frame ${b + n} should be between flashes`);
202
+ }
203
+ }
204
+ assert.ok(existsSync(path.join(dir, "SAFETY.txt")), "SAFETY.txt written in stage mode");
205
+ assert.equal(run.flash.exceeds, true);
206
+ });
207
+
208
+ it("safeVariant: film.safe.mp4 stays within the flash limits", async () => {
209
+ const hits = Array.from({ length: 16 }, (_, k) => ({ t: k * 0.25, template: "strobe-burst", params: { tempo: 240, division: 16 }, durationFrames: 2 }));
210
+ const dir = mkdtempSync(path.join(tmp, "job-"));
211
+ const run = await runJob(score(hits, { input: { video: calm, audio: click }, durationSec: 4, safety: { mode: "stage", safeVariant: true } }), lib, { outDir: dir, width: W, height: H, replay: false });
212
+ assert.equal(run.flash.exceeds, true, "the stage master flashes too much by design");
213
+ assert.ok(run.safeVariant, "safe variant rendered");
214
+ assert.equal(run.safeVariant.flash.exceeds, false, JSON.stringify(run.safeVariant.flash));
215
+ assert.ok(existsSync(path.join(dir, "film.safe.mp4")));
216
+ assert.ok(run.safeVariant.substitutions.length > 0, "over-rate hits were substituted");
217
+ });
218
+ });
219
+
220
+ describe("every impact template renders, replays deterministically, reports flashes", () => {
221
+ for (const id of IDS) {
222
+ it(id, async () => {
223
+ const dir = mkdtempSync(path.join(tmp, "job-"));
224
+ const preset = Object.keys(lib.get(id).fx.X_AGENTVFX.presets)[0];
225
+ const run = await runJob(score([{ t: 1, template: id, preset, durationFrames: 6 }]), lib, { outDir: dir, width: W, height: H, replay: true });
226
+ assert.equal(run.render.frames, 90);
227
+ assert.equal(run.determinism.pass, true);
228
+ assert.ok(run.flash && typeof run.flash.exceeds === "boolean", "flash report present");
229
+ });
230
+ }
231
+ });
@@ -0,0 +1,39 @@
1
+ import { test } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
4
+ import path from "node:path";
5
+ import { fileURLToPath, pathToFileURL } from "node:url";
6
+
7
+ const SKILL = fileURLToPath(new URL("..", import.meta.url));
8
+ const ENGINE = path.join(SKILL, "engine");
9
+
10
+ const walk = (dir) => readdirSync(dir).flatMap((n) => {
11
+ const p = path.join(dir, n);
12
+ return statSync(p).isDirectory() ? walk(p) : p.endsWith(".mjs") ? [p] : [];
13
+ });
14
+ const files = walk(ENGINE);
15
+
16
+ test("every relative import in the engine stays inside skill/agentvfx", () => {
17
+ for (const f of files) {
18
+ const text = readFileSync(f, "utf8");
19
+ for (const m of text.matchAll(/(?:from|import)\s*\(?\s*["'](\.{1,2}\/[^"']+)["']/gu)) {
20
+ const target = path.resolve(path.dirname(f), m[1]);
21
+ assert.ok(target.startsWith(SKILL), `${path.relative(SKILL, f)} imports ${m[1]} outside the skill`);
22
+ }
23
+ }
24
+ });
25
+
26
+ // Browser entry modules touch the DOM at load; for them only check that every relative import exists.
27
+ const isBrowserEntry = (f) => /\bdocument\.getElementById\b/u.test(readFileSync(f, "utf8"));
28
+
29
+ for (const f of files) {
30
+ test(`imports ${path.relative(SKILL, f)}`, async () => {
31
+ if (!isBrowserEntry(f)) {
32
+ await import(pathToFileURL(f).href);
33
+ return;
34
+ }
35
+ for (const m of readFileSync(f, "utf8").matchAll(/from\s*["'](\.{1,2}\/[^"']+)["']/gu)) {
36
+ assert.ok(existsSync(path.resolve(path.dirname(f), m[1])), `${path.relative(SKILL, f)} imports missing ${m[1]}`);
37
+ }
38
+ });
39
+ }
@@ -0,0 +1,200 @@
1
+ import { test } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import { createFlashAuditor } from "../engine/core/flash.mjs";
8
+ import { loadLibrary } from "../engine/core/templates.mjs";
9
+ import { validateScore, validateTemplate } from "../engine/core/validate.mjs";
10
+ import { openFootage } from "../engine/node/footage.mjs";
11
+ import { renderScore } from "../engine/node/render.mjs";
12
+
13
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
14
+ const clip = path.join(root, "test-media/clip-01.mp4");
15
+ const familyDir = path.join(root, "templates/light");
16
+ const IDS = ["bloom-glow", "anamorphic-streak", "god-rays", "light-leak", "neon-saber", "lens-flare", "light-sweep"];
17
+ const BASES = ["light-stage"];
18
+
19
+ function rec709(buf, o) {
20
+ return (0.2126 * buf[o] + 0.7152 * buf[o + 1] + 0.0722 * buf[o + 2]) / 255;
21
+ }
22
+
23
+ /** Mean display luma of the 1px ring at radius r around (cx, cy). */
24
+ function ringMean(buf, w, h, cx, cy, r) {
25
+ const steps = Math.max(24, Math.ceil(Math.PI * 2 * r));
26
+ let sum = 0;
27
+ let n = 0;
28
+ for (let i = 0; i < steps; i++) {
29
+ const a = (i / steps) * Math.PI * 2;
30
+ const x = Math.round(cx + Math.cos(a) * r);
31
+ const y = Math.round(cy + Math.sin(a) * r);
32
+ if (x < 0 || y < 0 || x >= w || y >= h) continue;
33
+ sum += rec709(buf, (y * w + x) * 4);
34
+ n += 1;
35
+ }
36
+ return sum / n;
37
+ }
38
+
39
+ /** Mean display luma of the darkest fifth of the frame. */
40
+ function darkestMean(buf, w, h) {
41
+ const n = w * h;
42
+ const lum = new Float64Array(n);
43
+ for (let i = 0; i < n; i++) lum[i] = rec709(buf, i * 4);
44
+ const sorted = Float64Array.from(lum).sort();
45
+ const k = Math.max(1, Math.floor(n * 0.2));
46
+ let sum = 0;
47
+ for (let i = 0; i < k; i++) sum += sorted[i];
48
+ return sum / k;
49
+ }
50
+
51
+ function findImpulse(buf, w, h) {
52
+ let best = -1;
53
+ let x = 0;
54
+ let y = 0;
55
+ const x0 = Math.floor(w * 0.35);
56
+ const x1 = Math.ceil(w * 0.65);
57
+ const y0 = Math.floor(h * 0.35);
58
+ const y1 = Math.ceil(h * 0.65);
59
+ for (let yy = y0; yy < y1; yy++) {
60
+ for (let xx = x0; xx < x1; xx++) {
61
+ const o = (yy * w + xx) * 4;
62
+ const s = buf[o] + buf[o + 1] + buf[o + 2];
63
+ if (s > best) {
64
+ best = s;
65
+ x = xx;
66
+ y = yy;
67
+ }
68
+ }
69
+ }
70
+ return { x, y };
71
+ }
72
+
73
+ /** Radius, as a fraction of height, where the halo falls through half its inner-ring peak. */
74
+ function halfRadiusFrac(buf, w, h, cx, cy) {
75
+ const maxR = Math.floor(h * 0.45);
76
+ const rings = [];
77
+ for (let r = 1; r <= maxR; r++) rings.push(ringMean(buf, w, h, cx, cy, r));
78
+ let worstRise = 0;
79
+ let worstStep = 0;
80
+ for (let i = 0; i < rings.length - 1; i++) {
81
+ worstRise = Math.max(worstRise, rings[i + 1] - rings[i]);
82
+ worstStep = Math.max(worstStep, rings[i] - rings[i + 1]);
83
+ }
84
+ const peak = rings[0];
85
+ let half = rings.length + 1;
86
+ for (let i = 0; i < rings.length; i++) {
87
+ if (rings[i] < peak * 0.5) {
88
+ half = i + 1;
89
+ break;
90
+ }
91
+ }
92
+ return { worstRise, worstStep, peak, frac: half / h };
93
+ }
94
+
95
+ test("light family", { timeout: 1_800_000 }, async (t) => {
96
+ const lib = loadLibrary();
97
+
98
+ await t.test("seven templates validate and each demo score validates", () => {
99
+ assert.deepEqual([...lib.keys()].filter((id) => lib.get(id).family === "light").sort(), [...IDS, ...BASES].sort());
100
+ for (const id of [...IDS, ...BASES]) {
101
+ const tpl = lib.get(id);
102
+ const v = validateTemplate(tpl.fx, id);
103
+ assert.equal(v.ok, true, `${id} ${JSON.stringify(v.errors)}`);
104
+ assert.equal(tpl.fx.X_AGENTVFX.family, "light");
105
+ assert.ok(Object.keys(tpl.fx.X_AGENTVFX.presets).length >= 3);
106
+ if (!IDS.includes(id)) continue;
107
+ const demos = readdirSync(path.join(familyDir, id)).filter((f) => f.startsWith("demo-") && f.endsWith(".json"));
108
+ assert.ok(demos.length >= 1, `${id} needs a demo score`);
109
+ for (const demo of demos) {
110
+ const score = JSON.parse(readFileSync(path.join(familyDir, id, demo), "utf8"));
111
+ const s = validateScore(score, lib);
112
+ assert.equal(s.ok, true, `${demo} ${JSON.stringify(s.errors)}`);
113
+ }
114
+ }
115
+ });
116
+
117
+ for (const id of IDS) {
118
+ await t.test(`${id} renders 90 frames, determinism passes, flash audit is recorded`, async () => {
119
+ const tpl = lib.get(id);
120
+ const preset = Object.keys(tpl.fx.X_AGENTVFX.presets)[0];
121
+ const dir = mkdtempSync(path.join(tmpdir(), "agentvfx-light-"));
122
+ const ref = openFootage(clip, { fps: 30, durationSec: 3, longEdge: 320 });
123
+ const src0 = Buffer.from(await ref.frame(0));
124
+ ref.close();
125
+ const footage = openFootage(clip, { fps: 30, durationSec: 3, longEdge: 320 });
126
+ const auditor = createFlashAuditor({ fps: 30, width: footage.width, height: footage.height });
127
+ let out0 = null;
128
+ try {
129
+ const v = validateScore({
130
+ version: 1, template: id, preset, input: { video: clip }, durationSec: 3, seed: 12, out: id,
131
+ }, lib);
132
+ assert.equal(v.ok, true, JSON.stringify(v.errors));
133
+ const report = await renderScore(v.value, lib, {
134
+ outDir: dir,
135
+ width: footage.width,
136
+ height: footage.height,
137
+ footage,
138
+ replay: true,
139
+ onFrame: (f, a) => {
140
+ auditor.push({ width: footage.width, height: footage.height, data: a.rgba });
141
+ if (f === 0 && !out0) out0 = Buffer.from(a.rgba);
142
+ },
143
+ });
144
+ const flash = auditor.finish();
145
+ assert.equal(report.frames, 90);
146
+ const rise = darkestMean(out0, footage.width, footage.height) - darkestMean(src0, footage.width, footage.height);
147
+ assert.ok(rise <= 0.03, `${id} darkest-fifth luma rose ${rise.toFixed(4)}`);
148
+ assert.equal(report.determinism.pass, true, JSON.stringify(report.determinism));
149
+ assert.equal(typeof flash.flashesPerSecondMax, "number");
150
+ assert.equal(typeof flash.redFlashes, "number");
151
+ assert.equal(typeof flash.exceeds, "boolean");
152
+ assert.equal(flash.limits.frames, 90);
153
+ } finally {
154
+ footage.close();
155
+ rmSync(dir, { recursive: true, force: true });
156
+ }
157
+ });
158
+ }
159
+
160
+ await t.test("bloom-glow on one white pixel falls off smoothly and the radius scales", async () => {
161
+ const probe = {
162
+ version: 1,
163
+ template: "bloom-glow",
164
+ params: {
165
+ probeDot: 1, paletteMix: 0, tint: [1, 1, 1, 1], toneMap: 1,
166
+ bloomRadius: 0.36, bloomMix: 0.15, bloomGain: 16, levelGain: 1.6,
167
+ coreTrim: 0.04, threshold: 0.15, knee: 0.9,
168
+ },
169
+ durationSec: 3,
170
+ seed: 3,
171
+ out: "bloom-probe",
172
+ };
173
+ const v = validateScore(probe, lib);
174
+ assert.equal(v.ok, true, JSON.stringify(v.errors));
175
+ const measured = [];
176
+ for (const [w, h] of [[960, 540], [1920, 1080]]) {
177
+ const dir = mkdtempSync(path.join(tmpdir(), "agentvfx-bloom-"));
178
+ let kept = null;
179
+ try {
180
+ const report = await renderScore(v.value, lib, {
181
+ outDir: dir, width: w, height: h, replay: false,
182
+ onFrame: (f, a) => { if (f === 0) kept = Buffer.from(a.rgba); },
183
+ });
184
+ assert.equal(report.frames, 90);
185
+ const spot = findImpulse(kept, w, h);
186
+ const centre = rec709(kept, (spot.y * w + spot.x) * 4);
187
+ assert.ok(centre > 0.75, `impulse pixel ${centre.toFixed(3)} at ${w}x${h}`);
188
+ const m = halfRadiusFrac(kept, w, h, spot.x, spot.y);
189
+ assert.ok(m.peak >= 12 / 255, `halo peak ${(m.peak * 255).toFixed(1)}/255 at ${w}x${h}`);
190
+ assert.ok(m.worstRise * 255 <= 2, `rise ${(m.worstRise * 255).toFixed(2)}/255 at ${w}x${h}`);
191
+ assert.ok(m.worstStep * 255 <= 2, `step ${(m.worstStep * 255).toFixed(2)}/255 at ${w}x${h}`);
192
+ measured.push(m.frac);
193
+ } finally {
194
+ rmSync(dir, { recursive: true, force: true });
195
+ }
196
+ }
197
+ const rel = Math.abs(measured[0] - measured[1]) / Math.max(measured[1], 1e-4);
198
+ assert.ok(rel <= 0.05, `relative radii ${measured.map((n) => n.toFixed(4)).join(" vs ")} differ by ${(rel * 100).toFixed(1)}%`);
199
+ });
200
+ });
@@ -0,0 +1,80 @@
1
+ // Ping-pong loop tool: no audio, 2N-2 frames, seamless wrap, flash audit over the loop played twice.
2
+ import assert from "node:assert/strict";
3
+ import { spawnSync } from "node:child_process";
4
+ import { mkdtempSync, rmSync } from "node:fs";
5
+ import { tmpdir } from "node:os";
6
+ import path from "node:path";
7
+ import test from "node:test";
8
+ import { findFfmpeg, findFfprobe, probeVideo } from "../engine/node/encode.mjs";
9
+ import { auditLoop, pingpong, readFrames } from "../scripts/loop.mjs";
10
+
11
+ const ffmpeg = findFfmpeg();
12
+ const ffprobe = findFfprobe();
13
+
14
+ function makeClip(dir, n = 30) {
15
+ // 1 s, 30 fps, 160x90 ffmpeg test pattern (moves every frame), with a sine audio track that must be dropped.
16
+ const src = path.join(dir, "src.mp4");
17
+ const r = spawnSync(ffmpeg, ["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=s=160x90:r=30:d=1",
18
+ "-f", "lavfi", "-i", "sine=f=440:d=1",
19
+ "-frames:v", String(n), "-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac", "-shortest", src]);
20
+ assert.equal(r.status, 0, String(r.stderr));
21
+ return src;
22
+ }
23
+
24
+ test("pingpong drops audio, has 2N-2 frames and wraps without a jump", { skip: !ffmpeg || !ffprobe }, () => {
25
+ const dir = mkdtempSync(path.join(tmpdir(), "agentvfx-loop-"));
26
+ try {
27
+ const src = makeClip(dir);
28
+ const out = path.join(dir, "loop.mp4");
29
+ const res = pingpong(src, out);
30
+ assert.equal(res.frames, 58);
31
+ const audio = spawnSync(ffprobe, ["-v", "error", "-select_streams", "a", "-show_entries", "stream=index", "-of", "csv=p=0", out], { encoding: "utf8" });
32
+ assert.equal(audio.stdout.trim(), "", "no audio stream");
33
+ assert.equal(probeVideo(out).frames, 58);
34
+ const frames = readFrames(out);
35
+ const mad = (a, b) => { let s = 0; for (let i = 0; i < a.data.length; i += 4) s += Math.abs(a.data[i] - b.data[i]); return s / (a.data.length / 4); };
36
+ const step = mad(frames[0], frames[1]);
37
+ const wrap = mad(frames.at(-1), frames[0]);
38
+ assert.ok(step > 0.5, "the box moves");
39
+ assert.ok(wrap <= step * 1.5, `wrap step ${wrap} vs normal step ${step}`);
40
+ const jump = mad(readFrames(src).at(-1), readFrames(src)[0]);
41
+ assert.ok(jump > step * 5, "negative control: the source loop jumps");
42
+ } finally { rmSync(dir, { recursive: true, force: true }); }
43
+ });
44
+
45
+ test("pingpong hold freezes each turn for the given frames", { skip: !ffmpeg || !ffprobe }, () => {
46
+ const dir = mkdtempSync(path.join(tmpdir(), "agentvfx-loop-"));
47
+ try {
48
+ const out = path.join(dir, "hold.mp4");
49
+ assert.equal(pingpong(makeClip(dir), out, { hold: 3 }).frames, 64);
50
+ assert.equal(probeVideo(out).frames, 64);
51
+ const f = readFrames(out);
52
+ const mad = (a, b) => { let s = 0; for (let i = 0; i < a.data.length; i += 4) s += Math.abs(a.data[i] - b.data[i]); return s / (a.data.length / 4); };
53
+ assert.ok(mad(f[29], f[32]) < 1, "frames 29..32 are the held turn");
54
+ } finally { rmSync(dir, { recursive: true, force: true }); }
55
+ });
56
+
57
+ test("auditLoop fails a full-frame strobe (negative control)", { skip: !ffmpeg || !ffprobe }, async () => {
58
+ const dir = mkdtempSync(path.join(tmpdir(), "agentvfx-loop-"));
59
+ try {
60
+ const src = path.join(dir, "strobe.mp4");
61
+ const r = spawnSync(ffmpeg, ["-y", "-v", "error", "-f", "lavfi", "-i", "color=c=black:s=160x90:r=30:d=1",
62
+ "-vf", "geq=lum='if(mod(N,2),235,16)':cb=128:cr=128", "-c:v", "libx264", "-pix_fmt", "yuv420p", src]);
63
+ assert.equal(r.status, 0, String(r.stderr));
64
+ const out = path.join(dir, "loop.mp4");
65
+ pingpong(src, out);
66
+ assert.equal((await auditLoop(out)).pass, false);
67
+ assert.throws(() => pingpong(src, out, { hold: 1.5 }), /hold/);
68
+ } finally { rmSync(dir, { recursive: true, force: true }); }
69
+ });
70
+
71
+ test("auditLoop reports a pass for a calm clip, played twice", { skip: !ffmpeg || !ffprobe }, async () => {
72
+ const dir = mkdtempSync(path.join(tmpdir(), "agentvfx-loop-"));
73
+ try {
74
+ const out = path.join(dir, "loop.mp4");
75
+ pingpong(makeClip(dir), out);
76
+ const a = await auditLoop(out);
77
+ assert.equal(a.pass, true);
78
+ assert.equal(a.limits.frames, 116);
79
+ } finally { rmSync(dir, { recursive: true, force: true }); }
80
+ });
@@ -0,0 +1,99 @@
1
+ // Psychedelic family tests (plan task 8 acceptance criteria).
2
+ // Every template: validates, renders 120 frames, determinism passes with a
3
+ // recorded flash audit. echo-flow and mosh-melt declare a persistent pass.
4
+ // hologram-scan flicker is visible in strips (frame-to-frame fill change).
5
+ import { test } from "node:test";
6
+ import assert from "node:assert/strict";
7
+ import { spawnSync } from "node:child_process";
8
+ import { mkdtempSync, rmSync } from "node:fs";
9
+ import { tmpdir } from "node:os";
10
+ import path from "node:path";
11
+ import { fileURLToPath } from "node:url";
12
+ import { loadLibrary } from "../engine/core/templates.mjs";
13
+ import { validateScore } from "../engine/core/validate.mjs";
14
+ import { runJob } from "../engine/node/job.mjs";
15
+
16
+ const lib = loadLibrary({ includeTest: true });
17
+ const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
18
+ const W = 320;
19
+ const H = 180;
20
+ const CLIP = "test-media/clip-01.mp4";
21
+
22
+ const CASES = [
23
+ ["tidal-bands", "tidal-classic"],
24
+ ["kaleido-fold", "kaleido-six"],
25
+ ["hologram-scan", "holo-cyan"],
26
+ ["echo-flow", "echo-trail"],
27
+ ["mosh-melt", "mosh-classic"],
28
+ ];
29
+
30
+ function scoreFor(template, preset, extra = {}) {
31
+ const v = validateScore(
32
+ { version: 1, template, preset, input: { video: CLIP }, durationSec: 4, seed: 11, out: "t", ...extra },
33
+ lib,
34
+ );
35
+ assert.equal(v.ok, true, JSON.stringify(v.errors));
36
+ return v.value;
37
+ }
38
+
39
+ for (const [template, preset] of CASES) {
40
+ test(`${template}/${preset}: validates, renders 120 frames, deterministic, flash audit recorded`, async () => {
41
+ const dir = mkdtempSync(path.join(tmpdir(), "agentvfx-psy-"));
42
+ try {
43
+ const gate = await runJob(scoreFor(template, preset), lib, { outDir: dir, width: W, height: H, replay: true, cwd: ROOT });
44
+ assert.equal(gate.render.frames, 120, `rendered ${gate.render.frames} frames`);
45
+ assert.equal(gate.determinism.checked, true);
46
+ assert.equal(gate.determinism.pass, true, JSON.stringify(gate.determinism.firstDifference));
47
+ assert.ok(gate.flash && typeof gate.flash.exceeds === "boolean", "flash audit missing");
48
+ assert.ok(gate.stills.sheet, "contact sheet missing");
49
+ assert.ok(gate.stills.strips.length >= 1, "strips missing");
50
+ } finally {
51
+ rmSync(dir, { recursive: true, force: true });
52
+ }
53
+ });
54
+ }
55
+
56
+ test("echo-flow and mosh-melt declare a persistent pass", () => {
57
+ for (const id of ["echo-flow", "mosh-melt"]) {
58
+ const t = lib.get(id);
59
+ assert.ok(t, `${id} missing from library`);
60
+ const persistent = (t.fx.PASSES ?? []).filter((p) => p.PERSISTENT === true);
61
+ assert.ok(persistent.length >= 1, `${id} has no PERSISTENT pass`);
62
+ }
63
+ });
64
+
65
+ test("hologram-scan flicker is visible: fill luminance swing >= 0.1 at peaks", async () => {
66
+ const dir = mkdtempSync(path.join(tmpdir(), "agentvfx-psy-"));
67
+ try {
68
+ const gate = await runJob(scoreFor("hologram-scan", "holo-storm"), lib, { outDir: dir, width: W, height: H, replay: false, cwd: ROOT });
69
+ const film = gate.render.film;
70
+ const p = spawnSync("ffmpeg", ["-v", "error", "-i", film, "-f", "rawvideo", "-pix_fmt", "rgb24", "pipe:1"], { maxBuffer: 1 << 30 });
71
+ assert.equal(p.status, 0, p.stderr?.toString());
72
+ const stride = W * H * 3;
73
+ const n = Math.floor(p.stdout.length / stride);
74
+ assert.ok(n >= 115, `decoded ${n} frames`);
75
+ const meanLuma = (k) => {
76
+ const o = k * stride;
77
+ let s = 0;
78
+ let c = 0;
79
+ for (let y = H >> 2; y < (3 * H) >> 2; y += 2) {
80
+ for (let x = W >> 2; x < (3 * W) >> 2; x += 2) {
81
+ const i = o + (y * W + x) * 3;
82
+ s += 0.2126 * p.stdout[i] + 0.7152 * p.stdout[i + 1] + 0.0722 * p.stdout[i + 2];
83
+ c++;
84
+ }
85
+ }
86
+ return s / (c * 255);
87
+ };
88
+ let peak = 0;
89
+ let prev = meanLuma(0);
90
+ for (let k = 1; k < n; k++) {
91
+ const m = meanLuma(k);
92
+ peak = Math.max(peak, Math.abs(m - prev));
93
+ prev = m;
94
+ }
95
+ assert.ok(peak >= 0.1, `flicker peak swing ${peak.toFixed(3)}`);
96
+ } finally {
97
+ rmSync(dir, { recursive: true, force: true });
98
+ }
99
+ });