kasaframe 0.0.0-stage → 0.1.3

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 (442) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +148 -0
  3. package/README.md +92 -2
  4. package/app/package.json +12 -0
  5. package/app/server/engine.ts +533 -0
  6. package/app/server/main.ts +209 -0
  7. package/app/web/env.d.ts +2 -0
  8. package/app/web/icons.ts +31 -0
  9. package/app/web/index.html +21 -0
  10. package/app/web/main.ts +1195 -0
  11. package/app/web/style.css +463 -0
  12. package/bin/hooks.mjs +64 -0
  13. package/bin/kf.mjs +32 -0
  14. package/docs/AGENTS.md +286 -0
  15. package/music/README.md +37 -0
  16. package/package.json +44 -4
  17. package/packages/adapters/package.json +36 -0
  18. package/packages/adapters/src/css.ts +11 -0
  19. package/packages/adapters/src/gsap.ts +26 -0
  20. package/packages/adapters/src/index.ts +9 -0
  21. package/packages/adapters/src/lottie.ts +22 -0
  22. package/packages/adapters/src/media.ts +59 -0
  23. package/packages/adapters/src/page.ts +229 -0
  24. package/packages/adapters/src/project.ts +214 -0
  25. package/packages/adapters/src/react.ts +36 -0
  26. package/packages/adapters/src/svelte.ts +22 -0
  27. package/packages/adapters/src/three.ts +18 -0
  28. package/packages/adapters/src/vue.ts +27 -0
  29. package/packages/check/package.json +19 -0
  30. package/packages/check/src/check.ts +280 -0
  31. package/packages/check/src/cli.ts +70 -0
  32. package/packages/check/src/image.ts +146 -0
  33. package/packages/check/src/index.ts +9 -0
  34. package/packages/check/src/ocr.swift +37 -0
  35. package/packages/check/src/probe.ts +328 -0
  36. package/packages/check/src/report.ts +44 -0
  37. package/packages/check/src/rules/assets.ts +45 -0
  38. package/packages/check/src/rules/beats.ts +212 -0
  39. package/packages/check/src/rules/camera.ts +217 -0
  40. package/packages/check/src/rules/captions.ts +49 -0
  41. package/packages/check/src/rules/flash.ts +235 -0
  42. package/packages/check/src/rules/frames.ts +136 -0
  43. package/packages/check/src/rules/layout.ts +281 -0
  44. package/packages/check/src/rules/page.ts +87 -0
  45. package/packages/check/src/rules/runs.ts +20 -0
  46. package/packages/check/src/rules/text.ts +326 -0
  47. package/packages/check/src/scan.ts +240 -0
  48. package/packages/check/src/serve.ts +67 -0
  49. package/packages/check/src/types.ts +80 -0
  50. package/packages/check/src/video.ts +137 -0
  51. package/packages/cli/package.json +30 -0
  52. package/packages/cli/src/blur.ts +80 -0
  53. package/packages/cli/src/browser.ts +203 -0
  54. package/packages/cli/src/command.ts +44 -0
  55. package/packages/cli/src/commands/app.ts +25 -0
  56. package/packages/cli/src/commands/beats.ts +36 -0
  57. package/packages/cli/src/commands/bench.ts +123 -0
  58. package/packages/cli/src/commands/blender.ts +293 -0
  59. package/packages/cli/src/commands/check.ts +25 -0
  60. package/packages/cli/src/commands/direct.ts +210 -0
  61. package/packages/cli/src/commands/doctor.ts +30 -0
  62. package/packages/cli/src/commands/gen.ts +173 -0
  63. package/packages/cli/src/commands/look.ts +46 -0
  64. package/packages/cli/src/commands/lyrics.ts +157 -0
  65. package/packages/cli/src/commands/make.ts +1121 -0
  66. package/packages/cli/src/commands/music.ts +78 -0
  67. package/packages/cli/src/commands/narrate.ts +238 -0
  68. package/packages/cli/src/commands/new.ts +185 -0
  69. package/packages/cli/src/commands/preview.ts +43 -0
  70. package/packages/cli/src/commands/render.ts +250 -0
  71. package/packages/cli/src/commands/series.ts +110 -0
  72. package/packages/cli/src/commands/setup.ts +102 -0
  73. package/packages/cli/src/commands/sheet.ts +114 -0
  74. package/packages/cli/src/commands/skill.ts +43 -0
  75. package/packages/cli/src/commands/still.ts +40 -0
  76. package/packages/cli/src/commands/theme.ts +172 -0
  77. package/packages/cli/src/commands/transitions.ts +40 -0
  78. package/packages/cli/src/deps.ts +122 -0
  79. package/packages/cli/src/ffmpeg.ts +81 -0
  80. package/packages/cli/src/index.ts +8 -0
  81. package/packages/cli/src/kf.ts +64 -0
  82. package/packages/cli/src/lock.ts +72 -0
  83. package/packages/cli/src/mix.ts +131 -0
  84. package/packages/cli/src/out.ts +13 -0
  85. package/packages/cli/src/pool.ts +34 -0
  86. package/packages/cli/src/segments.ts +402 -0
  87. package/packages/cli/src/serve.ts +124 -0
  88. package/packages/clock/package.json +14 -0
  89. package/packages/clock/src/index.ts +25 -0
  90. package/packages/clock/src/install.ts +351 -0
  91. package/packages/clock/src/types.ts +45 -0
  92. package/packages/core/package.json +9 -0
  93. package/packages/core/src/beats.ts +283 -0
  94. package/packages/core/src/ease.ts +87 -0
  95. package/packages/core/src/frame.ts +99 -0
  96. package/packages/core/src/index.ts +27 -0
  97. package/packages/core/src/project.ts +157 -0
  98. package/packages/core/src/rand.ts +56 -0
  99. package/packages/core/src/spring.ts +52 -0
  100. package/packages/core/src/style.ts +100 -0
  101. package/packages/core/src/time.ts +88 -0
  102. package/packages/director/package.json +23 -0
  103. package/packages/director/src/assemble.ts +361 -0
  104. package/packages/director/src/brief.ts +122 -0
  105. package/packages/director/src/catalog.ts +49 -0
  106. package/packages/director/src/content.ts +343 -0
  107. package/packages/director/src/fallback.ts +58 -0
  108. package/packages/director/src/index.ts +13 -0
  109. package/packages/director/src/pattern.ts +90 -0
  110. package/packages/director/src/patterns/fill/cells.ts +115 -0
  111. package/packages/director/src/patterns/formula/stack.ts +93 -0
  112. package/packages/director/src/patterns/util.ts +58 -0
  113. package/packages/director/src/scene.ts +62 -0
  114. package/packages/director/src/select.ts +163 -0
  115. package/packages/director/src/transitions.ts +115 -0
  116. package/packages/gen/PROVIDERS.md +90 -0
  117. package/packages/gen/package.json +9 -0
  118. package/packages/gen/src/ask.ts +132 -0
  119. package/packages/gen/src/audio.ts +91 -0
  120. package/packages/gen/src/blender.ts +54 -0
  121. package/packages/gen/src/capabilities.ts +151 -0
  122. package/packages/gen/src/generate.ts +206 -0
  123. package/packages/gen/src/image/codex.ts +117 -0
  124. package/packages/gen/src/image/og.ts +133 -0
  125. package/packages/gen/src/index.ts +26 -0
  126. package/packages/gen/src/keys.ts +86 -0
  127. package/packages/gen/src/media.ts +150 -0
  128. package/packages/gen/src/music/elevenlabs.ts +41 -0
  129. package/packages/gen/src/music/index.ts +120 -0
  130. package/packages/gen/src/music/library.ts +73 -0
  131. package/packages/gen/src/music/lyria.ts +52 -0
  132. package/packages/gen/src/music/types.ts +28 -0
  133. package/packages/gen/src/plan.ts +106 -0
  134. package/packages/gen/src/registry.ts +54 -0
  135. package/packages/gen/src/seam.ts +103 -0
  136. package/packages/gen/src/tts/dashscope.ts +64 -0
  137. package/packages/gen/src/tts/elevenlabs.ts +84 -0
  138. package/packages/gen/src/tts/gemini.ts +73 -0
  139. package/packages/gen/src/tts/index.ts +241 -0
  140. package/packages/gen/src/tts/local.ts +42 -0
  141. package/packages/gen/src/tts/types.ts +44 -0
  142. package/packages/gen/src/types.ts +90 -0
  143. package/packages/gen/src/video/fal.ts +140 -0
  144. package/packages/gen/src/video/h3.ts +112 -0
  145. package/packages/gen/src/video/http.ts +44 -0
  146. package/packages/gen/src/video/ltx.ts +60 -0
  147. package/packages/gen/src/video/minimax.ts +55 -0
  148. package/packages/gen/src/video/veo.ts +71 -0
  149. package/packages/jizura/package.json +16 -0
  150. package/packages/jizura/src/deny.ts +73 -0
  151. package/packages/jizura/src/index.ts +7 -0
  152. package/packages/jizura/src/install.ts +269 -0
  153. package/packages/jizura/src/layer.ts +325 -0
  154. package/packages/jizura/src/lyrics.ts +81 -0
  155. package/packages/jizura/src/pin.ts +8 -0
  156. package/packages/jizura/src/vendor.ts +140 -0
  157. package/packages/jizura/src/vite.ts +63 -0
  158. package/packages/jizura/vendor/JIZURA_LICENSE.txt +21 -0
  159. package/packages/jizura/vendor/NOTICE +43 -0
  160. package/packages/jizura/vendor/engine.json +47 -0
  161. package/packages/jizura/vendor/fonts/BlackHanSans-Regular.woff2 +0 -0
  162. package/packages/jizura/vendor/fonts/DotGothic16-Regular.woff2 +0 -0
  163. package/packages/jizura/vendor/fonts/GowunBatang-Bold.woff2 +0 -0
  164. package/packages/jizura/vendor/fonts/IBMPlexMono-Medium.ttf +0 -0
  165. package/packages/jizura/vendor/fonts/IBMPlexMono-SemiBold.ttf +0 -0
  166. package/packages/jizura/vendor/fonts/NotoSansKR-VF.woff2 +0 -0
  167. package/packages/jizura/vendor/fonts/NotoSerifKR-VF.woff2 +0 -0
  168. package/packages/jizura/vendor/fonts/OFL-blackhansans.txt +93 -0
  169. package/packages/jizura/vendor/fonts/OFL-dotgothic16.txt +93 -0
  170. package/packages/jizura/vendor/fonts/OFL-gowunbatang.txt +94 -0
  171. package/packages/jizura/vendor/fonts/OFL-ibmplexmono.txt +93 -0
  172. package/packages/jizura/vendor/fonts/OFL-notosanskr.txt +93 -0
  173. package/packages/jizura/vendor/fonts/OFL-notoserifkr.txt +94 -0
  174. package/packages/jizura/vendor/fonts/fonts.json +52 -0
  175. package/packages/jizura/vendor/jizura_engine.js +35024 -0
  176. package/packages/motion/README.md +153 -0
  177. package/packages/motion/package.json +30 -0
  178. package/packages/motion/src/camera.ts +97 -0
  179. package/packages/motion/src/captions.ts +487 -0
  180. package/packages/motion/src/enter.ts +128 -0
  181. package/packages/motion/src/hangul.ts +129 -0
  182. package/packages/motion/src/impact.ts +100 -0
  183. package/packages/motion/src/index.ts +17 -0
  184. package/packages/motion/src/moves/brushWipe.ts +103 -0
  185. package/packages/motion/src/moves/cloneArray.ts +111 -0
  186. package/packages/motion/src/moves/curtains.ts +81 -0
  187. package/packages/motion/src/moves/dress.ts +191 -0
  188. package/packages/motion/src/moves/echoStack.ts +70 -0
  189. package/packages/motion/src/moves/fit.ts +70 -0
  190. package/packages/motion/src/moves/flood.ts +61 -0
  191. package/packages/motion/src/moves/ghostStack.ts +88 -0
  192. package/packages/motion/src/moves/gridFloor.ts +100 -0
  193. package/packages/motion/src/moves/imageSwarm.ts +113 -0
  194. package/packages/motion/src/moves/index.ts +38 -0
  195. package/packages/motion/src/moves/irisBlades.ts +113 -0
  196. package/packages/motion/src/moves/karaokeLine.ts +108 -0
  197. package/packages/motion/src/moves/ledBoard.ts +94 -0
  198. package/packages/motion/src/moves/liquidTab.ts +72 -0
  199. package/packages/motion/src/moves/markerWrite.ts +63 -0
  200. package/packages/motion/src/moves/menu.ts +138 -0
  201. package/packages/motion/src/moves/morphBox.ts +96 -0
  202. package/packages/motion/src/moves/neonSign.ts +78 -0
  203. package/packages/motion/src/moves/panelPop.ts +78 -0
  204. package/packages/motion/src/moves/paperTear.ts +75 -0
  205. package/packages/motion/src/moves/path.ts +64 -0
  206. package/packages/motion/src/moves/pathText.ts +107 -0
  207. package/packages/motion/src/moves/pointSphere.ts +109 -0
  208. package/packages/motion/src/moves/ransomLetters.ts +73 -0
  209. package/packages/motion/src/moves/shapeMorph.ts +143 -0
  210. package/packages/motion/src/moves/slamWords.ts +96 -0
  211. package/packages/motion/src/moves/sparkTrail.ts +130 -0
  212. package/packages/motion/src/moves/speedLines.ts +91 -0
  213. package/packages/motion/src/moves/splitFlap.ts +149 -0
  214. package/packages/motion/src/moves/stepWords.ts +128 -0
  215. package/packages/motion/src/moves/strikeOut.ts +98 -0
  216. package/packages/motion/src/moves/sunburst.ts +58 -0
  217. package/packages/motion/src/moves/tickerRows.ts +91 -0
  218. package/packages/motion/src/moves/tokenPicker.ts +115 -0
  219. package/packages/motion/src/moves/truchet.ts +85 -0
  220. package/packages/motion/src/moves/wordWall.ts +78 -0
  221. package/packages/motion/src/moves/worldRoll.ts +32 -0
  222. package/packages/motion/src/particles.ts +102 -0
  223. package/packages/motion/src/react/index.tsx +21 -0
  224. package/packages/motion/src/react/parts.tsx +431 -0
  225. package/packages/motion/src/react/time.tsx +97 -0
  226. package/packages/motion/src/text.ts +103 -0
  227. package/packages/motion/src/transition.ts +82 -0
  228. package/packages/motion/src/transition3d/cards.ts +65 -0
  229. package/packages/motion/src/transition3d/chain.ts +84 -0
  230. package/packages/motion/src/transition3d/dive.ts +181 -0
  231. package/packages/motion/src/transition3d/fold.ts +110 -0
  232. package/packages/motion/src/transition3d/gl.ts +219 -0
  233. package/packages/motion/src/transition3d/index.ts +235 -0
  234. package/packages/motion/src/transition3d/live.ts +70 -0
  235. package/packages/motion/src/transition3d/portal.ts +115 -0
  236. package/packages/motion/src/transition3d/react.tsx +29 -0
  237. package/packages/motion/src/transition3d/rig.ts +600 -0
  238. package/packages/motion/src/transition3d/shatter.ts +104 -0
  239. package/packages/motion/src/transition3d/space.ts +173 -0
  240. package/packages/motion/src/transition3d/whip.ts +78 -0
  241. package/packages/motion/src/transition3d/world.ts +737 -0
  242. package/packages/motion/src/transition3d/zoomOut.ts +114 -0
  243. package/packages/motion/src/transitions2d/catalog.ts +127 -0
  244. package/packages/motion/src/transitions2d/css.d.ts +2 -0
  245. package/packages/motion/src/transitions2d/cult-ui/LICENSE.md +9 -0
  246. package/packages/motion/src/transitions2d/cult-ui/RollingNumber.tsx +43 -0
  247. package/packages/motion/src/transitions2d/gl-transitions/LICENSE +25 -0
  248. package/packages/motion/src/transitions2d/gl-transitions/shaders.ts +1931 -0
  249. package/packages/motion/src/transitions2d/index.ts +2 -0
  250. package/packages/motion/src/transitions2d/kokonutui/LICENSE +21 -0
  251. package/packages/motion/src/transitions2d/kokonutui/MatrixText.css +16 -0
  252. package/packages/motion/src/transitions2d/kokonutui/MatrixText.tsx +94 -0
  253. package/packages/motion/src/transitions2d/magicui/HyperText.css +15 -0
  254. package/packages/motion/src/transitions2d/magicui/HyperText.tsx +115 -0
  255. package/packages/motion/src/transitions2d/magicui/LICENSE.md +21 -0
  256. package/packages/motion/src/transitions2d/magicui/MorphingText.css +25 -0
  257. package/packages/motion/src/transitions2d/magicui/MorphingText.tsx +130 -0
  258. package/packages/motion/src/transitions2d/magicui/WordRotate.tsx +42 -0
  259. package/packages/motion/src/transitions2d/react.ts +13 -0
  260. package/packages/motion/src/transitions2d/skiper-ui/ClipDiv.css +39 -0
  261. package/packages/motion/src/transitions2d/skiper-ui/ClipDiv.tsx +32 -0
  262. package/packages/motion/src/transitions2d/smoothui/LICENSE +21 -0
  263. package/packages/motion/src/transitions2d/smoothui/SharedAxisY.tsx +50 -0
  264. package/packages/motion/src/transitions2d/smoothui/TextMorph.tsx +90 -0
  265. package/packages/motion/src/transitions2d/smoothui/shaders.ts +223 -0
  266. package/packages/motion/src/transitions2d/unlumen/LICENSE +21 -0
  267. package/packages/motion/src/transitions2d/unlumen/ScrambleText.tsx +114 -0
  268. package/packages/motion/src/transitions2d/vengeance-ui/LICENSE +21 -0
  269. package/packages/motion/src/transitions2d/vengeance-ui/MorphText.css +69 -0
  270. package/packages/motion/src/transitions2d/vengeance-ui/MorphText.tsx +45 -0
  271. package/packages/motion/src/type.ts +131 -0
  272. package/packages/motion/src/ui.ts +172 -0
  273. package/packages/patterns/package.json +15 -0
  274. package/packages/patterns/src/bars/rank.ts +119 -0
  275. package/packages/patterns/src/before-after/shrink.ts +127 -0
  276. package/packages/patterns/src/before-after/strike.ts +125 -0
  277. package/packages/patterns/src/code/terminal.ts +133 -0
  278. package/packages/patterns/src/compare/bars.ts +142 -0
  279. package/packages/patterns/src/compare/duel.ts +103 -0
  280. package/packages/patterns/src/end/lockup.ts +85 -0
  281. package/packages/patterns/src/end/slam.ts +91 -0
  282. package/packages/patterns/src/flow/graph.ts +250 -0
  283. package/packages/patterns/src/hook-number/counter.ts +101 -0
  284. package/packages/patterns/src/hook-number/roll.ts +179 -0
  285. package/packages/patterns/src/hook-number/slam.ts +91 -0
  286. package/packages/patterns/src/index.ts +38 -0
  287. package/packages/patterns/src/kit.ts +449 -0
  288. package/packages/patterns/src/limit/gauge.ts +117 -0
  289. package/packages/patterns/src/list/cards.ts +131 -0
  290. package/packages/patterns/src/list/cycle.ts +22 -0
  291. package/packages/patterns/src/media/panels.ts +100 -0
  292. package/packages/patterns/src/objects.ts +234 -0
  293. package/packages/patterns/src/quote/karaoke.ts +126 -0
  294. package/packages/patterns/src/quote/slam.ts +22 -0
  295. package/packages/patterns/src/screen/focus.ts +85 -0
  296. package/packages/patterns/src/steps/path.ts +137 -0
  297. package/packages/patterns/src/steps/stack.ts +111 -0
  298. package/packages/patterns/src/term-reveal/chips.ts +92 -0
  299. package/packages/patterns/src/term-reveal/expand.ts +127 -0
  300. package/packages/patterns/src/timeline/axis.ts +144 -0
  301. package/packages/patterns/src/title/mask.ts +85 -0
  302. package/packages/patterns/src/title/slam.ts +23 -0
  303. package/packages/patterns/src/toggle-sim/switch.ts +92 -0
  304. package/packages/patterns/src/trend/columns.ts +108 -0
  305. package/packages/patterns/src/trend/draw.ts +140 -0
  306. package/packages/patterns/src/types.ts +67 -0
  307. package/packages/patterns/src/words/moves.ts +42 -0
  308. package/packages/patterns/src/words/slam.ts +4 -0
  309. package/packages/plan/package.json +15 -0
  310. package/packages/plan/src/asks.ts +256 -0
  311. package/packages/plan/src/brief.ts +383 -0
  312. package/packages/plan/src/captions.ts +78 -0
  313. package/packages/plan/src/detect.ts +93 -0
  314. package/packages/plan/src/index.ts +27 -0
  315. package/packages/plan/src/layout.ts +176 -0
  316. package/packages/plan/src/llm.ts +172 -0
  317. package/packages/plan/src/look.ts +222 -0
  318. package/packages/plan/src/plan.ts +179 -0
  319. package/packages/plan/src/request.ts +55 -0
  320. package/packages/plan/src/series.ts +76 -0
  321. package/packages/plan/src/studio.ts +53 -0
  322. package/packages/plan/src/templates.ts +42 -0
  323. package/packages/plan/src/themes.ts +48 -0
  324. package/packages/plan/src/types.ts +157 -0
  325. package/packages/studio/package.json +12 -0
  326. package/packages/studio/src/index.ts +1 -0
  327. package/packages/studio/src/plugin.ts +236 -0
  328. package/packages/studio/src/ui/main.ts +503 -0
  329. package/packages/studio/src/ui/studio.css +165 -0
  330. package/packages/studio/src/ui/timeline.ts +317 -0
  331. package/packages/themes/kit/THEME-MAKE.md +68 -0
  332. package/packages/themes/kit/THEME.md +30 -0
  333. package/packages/themes/kit/briefs/og-intro-15s/brief.json +16 -0
  334. package/packages/themes/kit/briefs/og-intro-15s/facts.ts +29 -0
  335. package/packages/themes/kit/briefs/og-intro-15s/logo.svg +12 -0
  336. package/packages/themes/kit/effects.ts +5 -0
  337. package/packages/themes/kit/sample/index.html +11 -0
  338. package/packages/themes/kit/sample/main.ts +9 -0
  339. package/packages/themes/kit/sample/scenes/scene.ts +15 -0
  340. package/packages/themes/package.json +19 -0
  341. package/packages/themes/src/factory.ts +296 -0
  342. package/packages/themes/src/fx.ts +14 -0
  343. package/packages/themes/src/index.ts +114 -0
  344. package/packages/themes/src/slotkit.ts +79 -0
  345. package/packages/themes/src/slots.ts +46 -0
  346. package/packages/themes/src/stage3d.ts +197 -0
  347. package/packages/themes/src/types.ts +58 -0
  348. package/presets/kawaii-pastel.json +94 -0
  349. package/presets/neutral-dark.json +82 -0
  350. package/presets/og.json +98 -0
  351. package/series/og-shorts.json +14 -0
  352. package/skills/kasaframe/SKILL.md +33 -0
  353. package/templates/_shared/project/index.html +11 -0
  354. package/templates/_shared/project/lib/react.ts +22 -0
  355. package/templates/_shared/project/lib/stage.ts +292 -0
  356. package/templates/_shared/project/main.ts +9 -0
  357. package/templates/_shared/scenes/default.ts +21 -0
  358. package/templates/_shared/scenes/drop.ts +33 -0
  359. package/templates/_shared/scenes/end.ts +26 -0
  360. package/templates/_shared/scenes/hook.ts +18 -0
  361. package/templates/_shared/scenes/seam.ts +41 -0
  362. package/templates/_shared/scenes/step.ts +49 -0
  363. package/templates/ad/preview.png +0 -0
  364. package/templates/ad/template.json +151 -0
  365. package/templates/demo/preview.png +0 -0
  366. package/templates/demo/template.json +141 -0
  367. package/templates/explainer/preview.png +0 -0
  368. package/templates/explainer/template.json +193 -0
  369. package/templates/launch/preview.png +0 -0
  370. package/templates/launch/template.json +163 -0
  371. package/templates/mv/preview.png +0 -0
  372. package/templates/mv/scenes/default.ts +98 -0
  373. package/templates/mv/template.json +178 -0
  374. package/templates/promo/preview.png +0 -0
  375. package/templates/promo/template.json +185 -0
  376. package/templates/shorts/preview.png +0 -0
  377. package/templates/shorts/scenes/hook.ts +37 -0
  378. package/templates/shorts/template.json +196 -0
  379. package/templates/square/preview.png +0 -0
  380. package/templates/square/template.json +133 -0
  381. package/themes/debug-hud/THEME.md +39 -0
  382. package/themes/debug-hud/effects.ts +389 -0
  383. package/themes/debug-hud/sample/assets/og/logo.svg +12 -0
  384. package/themes/debug-hud/sample/beats.json +1 -0
  385. package/themes/debug-hud/sample/index.html +11 -0
  386. package/themes/debug-hud/sample/kf.json +59 -0
  387. package/themes/debug-hud/sample/lib/hudkit.ts +49 -0
  388. package/themes/debug-hud/sample/lib/og.ts +29 -0
  389. package/themes/debug-hud/sample/main.ts +9 -0
  390. package/themes/debug-hud/sample/scenes/end.ts +62 -0
  391. package/themes/debug-hud/sample/scenes/gather.ts +67 -0
  392. package/themes/debug-hud/sample/scenes/models.ts +70 -0
  393. package/themes/debug-hud/sample/scenes/price.ts +79 -0
  394. package/themes/debug-hud/sample/style.json +91 -0
  395. package/themes/debug-hud/slots.ts +99 -0
  396. package/themes/debug-hud/still.png +0 -0
  397. package/themes/debug-hud/style.json +91 -0
  398. package/themes/debug-hud/theme.json +68 -0
  399. package/themes/og-measure/THEME.md +47 -0
  400. package/themes/og-measure/effects.ts +432 -0
  401. package/themes/og-measure/sample/assets/brand/og-logo-full.svg +12 -0
  402. package/themes/og-measure/sample/assets/brand/og-logo.svg +12 -0
  403. package/themes/og-measure/sample/assets/data/measure.json +353 -0
  404. package/themes/og-measure/sample/beats.json +1 -0
  405. package/themes/og-measure/sample/index.html +11 -0
  406. package/themes/og-measure/sample/kf.json +66 -0
  407. package/themes/og-measure/sample/lib/data.ts +62 -0
  408. package/themes/og-measure/sample/main.ts +9 -0
  409. package/themes/og-measure/sample/measure.ts +78 -0
  410. package/themes/og-measure/sample/scenes/end.ts +47 -0
  411. package/themes/og-measure/sample/scenes/gather.ts +51 -0
  412. package/themes/og-measure/sample/scenes/models.ts +34 -0
  413. package/themes/og-measure/sample/scenes/one.ts +39 -0
  414. package/themes/og-measure/sample/scenes/price.ts +56 -0
  415. package/themes/og-measure/sample/style.json +97 -0
  416. package/themes/og-measure/slots.ts +88 -0
  417. package/themes/og-measure/still.png +0 -0
  418. package/themes/og-measure/style.json +97 -0
  419. package/themes/og-measure/theme.json +79 -0
  420. package/themes/riso-zine/THEME.md +43 -0
  421. package/themes/riso-zine/effects.ts +321 -0
  422. package/themes/riso-zine/sample/assets/og/logo.svg +12 -0
  423. package/themes/riso-zine/sample/beats.json +1 -0
  424. package/themes/riso-zine/sample/index.html +11 -0
  425. package/themes/riso-zine/sample/kf.json +59 -0
  426. package/themes/riso-zine/sample/lib/og.ts +29 -0
  427. package/themes/riso-zine/sample/lib/shot.ts +86 -0
  428. package/themes/riso-zine/sample/lib/zine.ts +42 -0
  429. package/themes/riso-zine/sample/main.ts +9 -0
  430. package/themes/riso-zine/sample/scenes/end.ts +61 -0
  431. package/themes/riso-zine/sample/scenes/gather.ts +62 -0
  432. package/themes/riso-zine/sample/scenes/models.ts +52 -0
  433. package/themes/riso-zine/sample/scenes/price.ts +82 -0
  434. package/themes/riso-zine/sample/style.json +99 -0
  435. package/themes/riso-zine/slots.ts +81 -0
  436. package/themes/riso-zine/still.png +0 -0
  437. package/themes/riso-zine/style.json +99 -0
  438. package/themes/riso-zine/theme.json +75 -0
  439. package/tools/beats/beats.py +372 -0
  440. package/tools/beats/requirements.txt +3 -0
  441. package/tools/lyrics/align.py +164 -0
  442. package/tools/lyrics/requirements.txt +9 -0
@@ -0,0 +1,140 @@
1
+ import { applyStyle, clamp } from "@kasaframe/core";
2
+ import { fitSize } from "@kasaframe/motion/moves";
3
+ import { partial } from "@kasaframe/themes/slotkit";
4
+ import { ACCENT_TEXT, area, decimalsOf, fmt, moving, node, slotsOf } from "../kit.ts";
5
+ import type { Pattern } from "../types.ts";
6
+
7
+ export interface TrendContent {
8
+ points: { x: string; y: number }[];
9
+ unit?: string;
10
+ mark?: { x: string; label: string };
11
+ }
12
+
13
+ const SVG = "http://www.w3.org/2000/svg";
14
+
15
+ /**
16
+ * 변화 — 선이 고른 빠르기로 그어지며 아래 면이 같이 찬다. 머리의 읽음값은 지나친 점의 값만 찍는다(점 사이 지어낸 값 없음).
17
+ * 짚을 점(mark)에 닿으면 세로 줄과 딱지가 서고, 끝 점에 닿으면 끝 값이 크게 앉는다.
18
+ */
19
+ const pattern: Pattern<TrendContent> = {
20
+ id: "trend.draw",
21
+ type: "trend",
22
+ does: "선이 그어지며 아래 면이 차고, 머리 읽음값이 지나친 점의 값을 찍고, 짚을 점에 줄과 딱지가 선다",
23
+ energy: ["mid"],
24
+ family: "draw",
25
+ camera: ["none"],
26
+ bg: "stage",
27
+ aspects: ["16:9", "9:16", "1:1"],
28
+ dur: { min: 2.6, max: 9 },
29
+ themes: { "og-measure": 0.5, "debug-hud": 0.5 },
30
+ fits(c) {
31
+ const pts = c?.points;
32
+ if (!Array.isArray(pts) || pts.length < 3) return "points 가 셋보다 적다";
33
+ if (pts.length > 24) return "points 가 스물넷을 넘는다";
34
+ for (const [i, p] of pts.entries()) if (!Number.isFinite(p?.y) || typeof p.x !== "string") return `points[${i}] 가 {x: 글, y: 수} 가 아니다`;
35
+ if (c.mark && !pts.some((p) => p.x === c.mark!.x)) return `mark.x "${c.mark.x}" 가 points 에 없다`;
36
+ return true;
37
+ },
38
+ build(root, ctx, c, kit) {
39
+ const slots = slotsOf(kit);
40
+ const { w, h, vertical, u } = area(ctx, kit);
41
+ const pts = c.points;
42
+ const n = pts.length;
43
+ const unit = c.unit ?? "";
44
+ const dec = Math.max(...pts.map((p) => decimalsOf(p.y)));
45
+ const lo = Math.min(0, ...pts.map((p) => p.y));
46
+ const hi = Math.max(...pts.map((p) => p.y));
47
+ const last = `${fmt(pts[n - 1].y, dec)}${unit ? ` ${unit}` : ""}`;
48
+ const bigPx = fitSize(last, w * 0.5, h, { hShare: vertical ? 0.1 : 0.16, max: Math.round(200 * u), min: Math.round(56 * u) });
49
+ const axisPx = Math.round(Math.max(28 * u, bigPx * 0.26));
50
+
51
+ const cx = w * 0.04;
52
+ const cw = w * 0.92;
53
+ const ctop = bigPx * 1.5;
54
+ const ch = h * 0.94 - ctop - axisPx * 1.8;
55
+ const xy = pts.map((p, i): [number, number] => [cx + (cw * i) / (n - 1), ctop + ch * (1 - (p.y - lo) / (hi - lo || 1))]);
56
+
57
+ const host = node(root, "position:absolute;inset:0");
58
+ const big = node(host, `position:absolute;right:${w * 0.04}px;top:0;font-family:var(--kf-font-display);font-size:${bigPx}px;font-weight:${ctx.style.type?.weightDisplay ?? 800};color:${ACCENT_TEXT};line-height:1.1;white-space:nowrap;font-variant-numeric:tabular-nums`);
59
+ kit.stage?.hero(big);
60
+ const svg = host.ownerDocument.createElementNS(SVG, "svg");
61
+ svg.setAttribute("style", "position:absolute;inset:0;width:100%;height:100%;overflow:visible");
62
+ host.append(svg);
63
+ const base = host.ownerDocument.createElementNS(SVG, "line");
64
+ for (const [k, v] of Object.entries({ x1: cx, y1: ctop + ch, x2: cx + cw, y2: ctop + ch })) base.setAttribute(k, String(v));
65
+ base.setAttribute("stroke", "var(--kf-line)");
66
+ base.setAttribute("stroke-width", String(Math.max(2, Math.round(3 * u))));
67
+ const fillPoly = host.ownerDocument.createElementNS(SVG, "polygon");
68
+ fillPoly.setAttribute("fill", "var(--kf-accent)");
69
+ fillPoly.setAttribute("opacity", "0.28");
70
+ const linePoly = host.ownerDocument.createElementNS(SVG, "polyline");
71
+ linePoly.setAttribute("fill", "none");
72
+ linePoly.setAttribute("stroke", "var(--kf-accent)");
73
+ linePoly.setAttribute("stroke-width", String(Math.round(10 * u)));
74
+ linePoly.setAttribute("stroke-linejoin", "round");
75
+ linePoly.setAttribute("stroke-linecap", "round");
76
+ svg.append(base, fillPoly, linePoly);
77
+ const dotR = Math.round(12 * u);
78
+ const dots = xy.map(([x, y]) => {
79
+ const d = host.ownerDocument.createElementNS(SVG, "circle");
80
+ d.setAttribute("cx", String(x));
81
+ d.setAttribute("cy", String(y));
82
+ d.setAttribute("r", String(dotR));
83
+ d.setAttribute("fill", "var(--kf-bg)");
84
+ d.setAttribute("stroke", "var(--kf-accent)");
85
+ d.setAttribute("stroke-width", String(Math.round(5 * u)));
86
+ d.setAttribute("visibility", "hidden");
87
+ svg.append(d);
88
+ return d;
89
+ });
90
+ const head = node(host, `position:absolute;left:0;top:0;padding:0.1em 0.35em;font-family:var(--kf-font-mono);font-size:${axisPx}px;font-weight:700;color:var(--kf-on-accent);background:var(--kf-accent);white-space:nowrap;font-variant-numeric:tabular-nums`);
91
+ const xl = [0, n - 1].map((i) => node(host, `position:absolute;top:${ctop + ch + axisPx * 0.4}px;left:${xy[i][0]}px;transform:translateX(${i ? "-100%" : "0"});font-family:var(--kf-font-mono);font-size:${axisPx}px;color:var(--kf-dim, var(--kf-ink));white-space:nowrap`, pts[i].x));
92
+ const mi = c.mark ? pts.findIndex((p) => p.x === c.mark!.x) : -1;
93
+ const markEl = mi >= 0 ? (() => {
94
+ const [x, y] = xy[mi];
95
+ const rule = node(host, `position:absolute;left:${x - 2}px;top:${ctop}px;width:4px;height:${ch}px;background:var(--kf-ink);opacity:.5;transform-origin:50% 100%`);
96
+ const chip = node(host, `position:absolute;left:${x}px;top:${Math.max(ctop, y - axisPx * 3.2)}px;transform:translateX(${mi > n / 2 ? "-105%" : "5%"});padding:0.12em 0.4em;font-family:var(--kf-font-sans);font-size:${Math.round(axisPx * 1.2)}px;font-weight:700;color:var(--kf-on-accent);background:var(--kf-accent);white-space:nowrap`);
97
+ return { rule, chip };
98
+ })() : null;
99
+
100
+ const drawFrom = 0.1;
101
+ // 끝 값이 앉는 몫(쓰기 0.3초 + 앉기)만 남기고 선이 장면을 거의 다 쓴다
102
+ const drawEnd = ctx.dur - 0.25;
103
+ const at = (i: number) => drawFrom + ((drawEnd - drawFrom) * i) / (n - 1);
104
+ const markAt = mi >= 0 ? at(mi) : Infinity;
105
+ const writeMark = markEl ? slots.write(markEl.chip, { ctx, text: c.mark!.label, at: markAt, dur: 0.3, seed: `${kit.seed}:mark` }) : null;
106
+ const writeBig = slots.write(big, { ctx, text: last, at: drawEnd - 0.2, dur: 0.3, seed: `${kit.seed}:big` });
107
+ const landed = slots.land(big, { ctx, at: drawEnd + 0.1, seed: `${kit.seed}:land` });
108
+
109
+ return (t: number) => {
110
+ moving("trend.draw", ctx);
111
+ // 고른 빠르기로 — 점 사이 거리가 아니라 점 차례로 시각을 나눠 점마다 같은 몫
112
+ const q = clamp((t - drawFrom) / (drawEnd - drawFrom)) * (n - 1);
113
+ const k = Math.floor(q);
114
+ const f = q - k;
115
+ const drawn: [number, number][] = xy.slice(0, k + 1).map((p) => [p[0], p[1]]);
116
+ if (k < n - 1) drawn.push(...partial([xy[k], xy[k + 1]], f).slice(1));
117
+ const ptsAttr = drawn.map((p) => `${p[0].toFixed(1)},${p[1].toFixed(1)}`).join(" ");
118
+ linePoly.setAttribute("points", t >= drawFrom ? ptsAttr : "");
119
+ const tail = drawn[drawn.length - 1];
120
+ fillPoly.setAttribute("points", t >= drawFrom ? `${cx},${ctop + ch} ${ptsAttr} ${tail[0].toFixed(1)},${ctop + ch}` : "");
121
+ dots.forEach((d, i) => d.setAttribute("visibility", t >= at(i) ? "visible" : "hidden"));
122
+ const passed = Math.min(n - 1, Math.max(0, Math.floor(q + 1e-6)));
123
+ head.textContent = `${fmt(pts[passed].y, dec)}${unit ? ` ${unit}` : ""}`;
124
+ head.style.transform = `translate(${tail[0].toFixed(1)}px, ${(tail[1] - dotR * 2).toFixed(1)}px) translate(${tail[0] > cx + cw * 0.8 ? "-100%" : "-50%"}, -100%)`;
125
+ head.style.visibility = t >= drawFrom && t < drawEnd + 0.3 ? "visible" : "hidden";
126
+ for (const e of xl) e.style.visibility = t >= drawFrom ? "visible" : "hidden";
127
+ if (markEl) {
128
+ markEl.rule.style.visibility = t >= markAt ? "visible" : "hidden";
129
+ markEl.chip.style.visibility = t >= markAt ? "visible" : "hidden";
130
+ applyStyle(markEl.rule, { scaleY: clamp((t - markAt) / 0.25) });
131
+ writeMark?.(t);
132
+ }
133
+ writeBig(t);
134
+ applyStyle(big, landed(t));
135
+ big.style.visibility = t >= drawEnd - 0.2 ? "visible" : "hidden";
136
+ };
137
+ },
138
+ };
139
+
140
+ export default pattern;
@@ -0,0 +1,67 @@
1
+ import type { SceneCtx, Style } from "@kasaframe/core";
2
+ import type { ThemeSlots } from "@kasaframe/themes/slots";
3
+
4
+ // 감독 packages/director/src/pattern.ts 와 같은 꼴(구조로 맞춘다). 감독이 패키지로 서면 그쪽 꼴을 import type 으로 받는다 — slots 만 테마 슬롯 꼴로 좁힌다.
5
+
6
+ export type Energy = "low" | "mid" | "high";
7
+ export type Family = "slam" | "flap" | "grow" | "draw" | "type" | "pop" | "mask" | "flow" | "stack" | "morph";
8
+ export type CameraKind = "none" | "pushIn" | "pullOut" | "follow" | "impact";
9
+ export type AspectName = "16:9" | "9:16" | "1:1";
10
+ export type TextPolicy = "none" | "terms-only" | "captions" | "lyrics";
11
+
12
+ export interface FitInfo {
13
+ aspect: AspectName;
14
+ dur: number;
15
+ policy: TextPolicy;
16
+ }
17
+
18
+ export interface StageLike {
19
+ box: HTMLDivElement;
20
+ cam: HTMLDivElement;
21
+ safeW: number;
22
+ safeH: number;
23
+ vertical: boolean;
24
+ camera: {
25
+ pushIn(at: number, o?: { to?: unknown; scale?: number; dur?: number }): unknown;
26
+ pullOut(at: number, o?: { to?: unknown; scale?: number; dur?: number }): unknown;
27
+ follow(target: unknown, from: number, to: number, o?: { scale?: number }): unknown;
28
+ impact(at: number, o?: { amount?: number; dur?: number }): unknown;
29
+ };
30
+ hero(el: HTMLElement): HTMLElement;
31
+ }
32
+
33
+ export interface SpokenWord {
34
+ text: string;
35
+ from: number;
36
+ to: number;
37
+ }
38
+
39
+ export interface Kit {
40
+ seed: string;
41
+ hits: number[];
42
+ say: SpokenWord[];
43
+ slots: ThemeSlots;
44
+ stage: StageLike;
45
+ policy: TextPolicy;
46
+ first: boolean;
47
+ last: boolean;
48
+ loop: boolean;
49
+ }
50
+
51
+ export interface Pattern<C = any> {
52
+ id: string;
53
+ type: string;
54
+ does: string;
55
+ energy: Energy[];
56
+ family: Family;
57
+ camera: CameraKind[];
58
+ bg: "stage" | "own";
59
+ aspects: AspectName[];
60
+ dur: { min: number; max: number };
61
+ themes?: Record<string, number>;
62
+ purposes?: { prefer?: string[]; avoid?: string[] };
63
+ fits?(content: C, info: FitInfo): true | string;
64
+ build(root: HTMLElement, ctx: SceneCtx, content: C, kit: Kit): (t: number) => void;
65
+ }
66
+
67
+ export type { SceneCtx, Style, ThemeSlots };
@@ -0,0 +1,42 @@
1
+ import { dressText } from "@kasaframe/motion/moves";
2
+ import { area, moving, node } from "../kit.ts";
3
+ import type { Energy, Family, Pattern } from "../types.ts";
4
+
5
+ export interface WordsContent {
6
+ words: string[];
7
+ }
8
+
9
+ // 낱말 리듬은 연출 수 메뉴(@kasaframe/motion/moves dress)의 글 수가 이미 박에 맞춰 검사를 넘긴 값으로 그린다 — 패턴은 고를 수 있는 이름과
10
+ // 고르는 표(에너지·계열)만 붙인다. 수마다 낱말 수·길이 한계가 다르다. ghostStack·splitFlap 은 세로 밝은 테마에서 멈춤 검사를 못 넘어 아직 안 건다
11
+ function wordsPattern(o: { name: string; move: string; does: string; energy: Energy[]; family: Family; max: number; maxLen: number }): Pattern<WordsContent> {
12
+ return {
13
+ id: `words.${o.name}`,
14
+ type: "words",
15
+ does: o.does,
16
+ energy: o.energy,
17
+ family: o.family,
18
+ camera: ["none"],
19
+ bg: "stage",
20
+ aspects: ["16:9", "9:16", "1:1"],
21
+ dur: { min: 1.2, max: 9 },
22
+ fits(c) {
23
+ const ws = (c?.words ?? []).filter((x) => typeof x === "string" && x.trim());
24
+ if (!ws.length) return "words 가 비었다";
25
+ if (ws.length > o.max) return `낱말이 ${o.max}개를 넘는다`;
26
+ if (ws.some((x) => [...x].length > o.maxLen)) return `낱말 하나가 ${o.maxLen}자를 넘는다`;
27
+ return true;
28
+ },
29
+ build(root, ctx, c, kit) {
30
+ const { w, h } = area(ctx, kit);
31
+ const host = node(root, "position:absolute;inset:0");
32
+ const paint = dressText(o.move, host, ctx, { words: c.words, w, h, ready: kit.first }) ?? (() => {});
33
+ kit.stage?.hero(host);
34
+ return (t: number) => {
35
+ moving(`words.${o.name}`, ctx);
36
+ paint(t);
37
+ };
38
+ },
39
+ };
40
+ }
41
+
42
+ export const wordsSlam = wordsPattern({ name: "slam", move: "slamWords", does: "박마다 낱말 하나가 화면 띠를 꽉 채우며 쾅 — 판과 글색이 뒤집힌다", energy: ["high"], family: "slam", max: 6, maxLen: 10 });
@@ -0,0 +1,4 @@
1
+ import { wordsSlam } from "./moves.ts";
2
+
3
+ // 장면 파일이 @kasaframe/patterns/words/slam 로 가져간다
4
+ export default wordsSlam;
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@kasaframe/plan",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./src/index.ts"
8
+ },
9
+ "dependencies": {
10
+ "@kasaframe/core": "*",
11
+ "@kasaframe/gen": "*",
12
+ "@kasaframe/motion": "*",
13
+ "@kasaframe/themes": "*"
14
+ }
15
+ }
@@ -0,0 +1,256 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { byMood, estimateImageUsd, howToGet, listLibrary, musicQuestion, ttsProviders, videoProviders, voiceQuestion, WAIT, type CapabilityReport, type Choice, type Question, type VideoRequest } from "@kasaframe/gen";
5
+ import { listThemes, sheetDir, themeDims, themeSample } from "@kasaframe/themes";
6
+ import { loadSeries } from "./series.ts";
7
+ import { loadTemplate } from "./templates.ts";
8
+ import { suggestThemes, themeFromRequest } from "./themes.ts";
9
+ import type { Plan } from "./types.ts";
10
+
11
+ // 계획이 쓰려는 능력을 지금 있는 능력에 맞춘다 — 돈이 들거나 없거나 제한이 걸린 것만 묻고, 나머지는 바로 정한다(auto)
12
+ export interface PlanQuestions {
13
+ questions: Question[];
14
+ auto: Record<string, string>; // 물을 것 없이 정해진 답(공짜로 있는 능력)
15
+ }
16
+
17
+ export { WAIT };
18
+
19
+ // 없는 능력 — 조용히 대체하지 않는다. ① 넣는 법(권장) ② 지금 쓸 수 있는 다른 엔진 ③ 빼기를 나란히 두고 사람이 고른다
20
+ function missing(q: Omit<Question, "default" | "skip" | "missing" | "choices">, install: Choice, others: Choice[], drop: Choice): Question {
21
+ return { ...q, choices: [install, ...others, drop], default: WAIT, skip: drop.value, missing: true };
22
+ }
23
+
24
+ const money = (n: number) => (n < 0.1 ? `$${n.toFixed(3)}` : `$${n.toFixed(2)}`);
25
+ const ids = (xs: { id: string }[]) => xs.map((x) => x.id).join("·");
26
+
27
+ function imageQuestion(plan: Plan, caps: CapabilityReport): { q?: Question; auto?: string } {
28
+ const imgs = plan.gen.filter((g) => g.kind === "img");
29
+ if (!imgs.length) return {};
30
+ const ready = caps.providers.filter((p) => p.ready);
31
+ const og = ready.find((p) => p.id.startsWith("og-"));
32
+ const codex = ready.find((p) => p.id === "codex-imagegen");
33
+ const none: Choice = { value: "none", label: "그림 없이", note: "받은 자산·도형·실제 화면 오리기로 장면을 채운다" };
34
+ if (og) {
35
+ const usd = imgs.reduce((n, g) => n + estimateImageUsd({ prompt: "", size: g.size ?? `${plan.width}x${plan.height}`, quality: g.quality ?? "high", refs: g.refs }), 0);
36
+ return {
37
+ q: {
38
+ id: "image",
39
+ cap: "image",
40
+ header: "그림 생성",
41
+ ask: `그림 ${imgs.length}장(${ids(imgs)})을 OG gpt-image 로 만들까? 견적 최대 ${money(usd)}`,
42
+ choices: [
43
+ { value: og.id, label: `OG ${og.id.replace(/^og-/, "")}`, costUsd: usd, note: "장당 20–30초" },
44
+ ...(codex ? [{ value: codex.id, label: "codex imagegen", costUsd: 0, note: "ChatGPT 요금제 안 — 장당 1–2분" }] : []),
45
+ none,
46
+ ],
47
+ default: og.id,
48
+ skip: "none",
49
+ flag: "--image",
50
+ },
51
+ };
52
+ }
53
+ // 기본 그림 모델(OG)이 없다 — codex 가 있어도 조용히 넘어가지 않고 다른 엔진 보기로 둔다
54
+ return {
55
+ q: missing(
56
+ { id: "image", cap: "image", header: "그림 모델", ask: `그림 ${imgs.length}장(${ids(imgs)})을 만들 기본 그림 모델(OG gpt-image)이 없다`, flag: "--image" },
57
+ { value: WAIT, label: "키를 넣고 다시", note: `${howToGet("opengateway")}${codex ? "" : " · 또는 0원 codex: npm i -g @openai/codex && codex login(ChatGPT 계정)"}` },
58
+ codex ? [{ value: codex.id, label: "codex imagegen 으로", costUsd: 0, note: "ChatGPT 로그인 — 0원, 장당 1–2분" }] : [],
59
+ none,
60
+ ),
61
+ };
62
+ }
63
+
64
+ function videoQuestion(plan: Plan, caps: CapabilityReport): { q?: Question; auto?: string } {
65
+ const vids = plan.gen.filter((g) => g.kind === "vid");
66
+ if (!vids.length) return {};
67
+ const scene = (id?: string) => plan.scenes.find((s) => s.id === id);
68
+ const reqs: VideoRequest[] = vids.map((g) => ({
69
+ prompt: g.prompt,
70
+ duration: g.seam ? (scene(g.scene)?.dur ?? 5) : (g.dur ?? 5),
71
+ aspect: plan.aspect,
72
+ ...(g.seam || g.first ? { firstFrame: "x" } : {}),
73
+ ...(g.seam || g.last ? { lastFrame: "y" } : {}),
74
+ }));
75
+ const ready = new Set(caps.providers.filter((p) => p.ready).map((p) => p.id));
76
+ const restrict = new Map(caps.providers.map((p) => [p.id, p.restrict]));
77
+ const options = videoProviders()
78
+ .filter((p) => ready.has(p.id))
79
+ .filter((p) => reqs.every((r) => !r.lastFrame || p.firstLast))
80
+ .map((p) => ({ p, usd: reqs.reduce((n, r) => n + p.estimateUsd(r), 0), restrict: restrict.get(p.id) }))
81
+ .sort((a, b) => a.usd - b.usd);
82
+ const open = options.filter((o) => !o.restrict);
83
+ const limited = options.filter((o) => o.restrict);
84
+ const what = `영상 모델 컷 ${vids.length}개(${vids.map((g) => `${g.id}${g.seam ? " 이음매" : ""}`).join("·")})`;
85
+ const none: Choice = { value: "none", label: "영상 모델 없이", note: "이음매는 three 3D 전환, 움직임 컷은 그림·모션그래픽으로" };
86
+ if (!options.length) {
87
+ return {
88
+ q: missing(
89
+ { id: "video", cap: "video", header: "영상 모델", ask: `${what}를 만들 영상 모델이 없다`, flag: "--video" },
90
+ { value: WAIT, label: "키를 넣고 다시", note: `${howToGet("fal")} · 또는 ${howToGet("gemini")} · 사내 ${howToGet("h3")}` },
91
+ [],
92
+ none,
93
+ ),
94
+ };
95
+ }
96
+ // 돈도 제한도 없는 길이 있으면 묻지 않는다(아직 그런 공급자는 없다 — H3 는 0원이지만 지역 제한이 걸린다)
97
+ if (open[0] && open[0].usd === 0) return { auto: open[0].p.id };
98
+ const choices: Choice[] = [
99
+ ...open.slice(0, 2).map((o) => ({ value: o.p.id, label: o.p.id, costUsd: o.usd })),
100
+ ...limited.slice(0, 1).map((o) => ({ value: o.p.id, label: `${o.p.id}(사내 파드)`, costUsd: o.usd, note: o.restrict })),
101
+ none,
102
+ ];
103
+ return {
104
+ q: {
105
+ id: "video",
106
+ cap: "video",
107
+ header: "영상 모델",
108
+ ask: open.length ? `${what} — ${open[0].p.id} 로 만들까? 견적 ${money(open[0].usd)}` : `${what} — 쓸 수 있는 건 지역 제한이 걸린 것뿐이다`,
109
+ choices: choices.slice(0, 4),
110
+ // 제한 걸린 길은 사람이 짚어야만 — --yes 로 회사·바깥 결과물에 섞이지 않게
111
+ default: open[0]?.p.id ?? "none",
112
+ skip: "none",
113
+ flag: "--video",
114
+ },
115
+ };
116
+ }
117
+
118
+ function blenderQuestion(plan: Plan, caps: CapabilityReport): { q?: Question; auto?: string } {
119
+ if (!plan.shots?.length) return {};
120
+ const b = caps.providers.find((p) => p.id === "blender");
121
+ if (b?.ready) return { auto: "blender" };
122
+ return {
123
+ q: missing(
124
+ { id: "blender", cap: "blender", header: "3D 샷", ask: `주인공 3D 장면(${plan.shots.map((s) => s.scene).join("·")})을 구울 Blender 가 없다 — ${b?.detail ?? "못 찾음"}`, flag: "--blender" },
125
+ { value: WAIT, label: "Blender 를 깔고 다시", note: `${b?.fix ?? "blender.org 에서 4.3 이상"} — 확인은 kf doctor 「생성 능력」` },
126
+ [{ value: "three", label: "three.js 로", note: "장면 안에서 stage3d 로 3D 를 짓는다(툰 셰이딩·라인아트는 없다)" }],
127
+ { value: "none", label: "3D 없이", note: "2D 모션그래픽 장면으로" },
128
+ ),
129
+ };
130
+ }
131
+
132
+ // 목소리 — 틀이 내레이션을 켰을 때만. 시리즈가 박은 목소리는 사람이 미리 준 답이라 그 엔진이 있으면 묻지 않는다.
133
+ // 그 밖엔 늘 묻는다(목소리는 결이라 돈이 안 들어도) — 보기 차례는 voiceQuestion(로컬 Qwen3·ElevenLabs·자막만·그 밖)
134
+ function voicePart(plan: Plan, caps: CapabilityReport): { q?: Question; auto?: string } {
135
+ const n = loadTemplate(plan.purpose).narration;
136
+ if (!n?.on || plan.voice) return {};
137
+ const ready = caps.providers.filter((p) => p.ready).map((p) => p.id);
138
+ const want = plan.series ? loadSeries(plan.series).voice : undefined;
139
+ if (!want) return n.voice === "none" ? { auto: "none" } : { q: voiceQuestion({ voices: n.voices, ready }) };
140
+ if (want === "none") return { auto: "none" };
141
+ const engine = want.split(":")[0];
142
+ if (ready.includes(engine)) return { auto: want };
143
+ const p = ttsProviders().find((x) => x.id === engine);
144
+ const others = ttsProviders().filter((x) => ready.includes(x.id)).slice(0, 2);
145
+ return {
146
+ q: missing(
147
+ { id: "voice", cap: "voice", header: "목소리", ask: `시리즈 목소리 ${want}(${p?.label ?? engine})을 이 기계에서 못 쓴다`, flag: "--voice", accepts: (v: string) => v === "none" || ready.includes(v.split(":")[0]) },
148
+ { value: WAIT, label: `${p?.label ?? engine} 키를 넣고 다시`, note: howToGet(p?.keyName ?? engine) },
149
+ others.map((x) => {
150
+ const v = n.voices[x.id] ?? x.defaultVoice;
151
+ return { value: `${x.id}:${v}`, label: `${x.label} ${v} 로`, costUsd: x.estimateUsd("가".repeat(300)), note: `시리즈 목소리(${want})와 다르다 — 같은 시리즈의 다른 영상과 목소리가 달라진다` };
152
+ }),
153
+ { value: "none", label: "목소리 없이 — 자막만", costUsd: 0 },
154
+ ),
155
+ };
156
+ }
157
+
158
+ // 테마 — 시리즈가 정했거나 요청이 「리소 느낌」처럼 짚었으면 묻지 않는다(kf new 의 auto 가 그대로 짚은 테마를 쓴다).
159
+ // 보기는 「알아서」(= auto, 권장)와 이 용도·화면비의 approved 테마 전부(요청에 맞는 차례) — theme.json status 만 approved 로 바꾸면 들어온다
160
+ function themePart(plan: Plan): { q?: Question; auto?: string } {
161
+ if ((plan.series && loadSeries(plan.series).theme) || themeFromRequest(plan.request, plan.purpose)) return {};
162
+ const ranked = suggestThemes(plan.request, plan.purpose, plan.aspect, Infinity);
163
+ if (!ranked.length) return {};
164
+ const byId = new Map(listThemes({ status: "approved" }).map((t) => [t.id, t]));
165
+ const grid = join(sheetDir, "sheet.png");
166
+ const first = byId.get(ranked[0].id)!;
167
+ return {
168
+ q: {
169
+ id: "theme",
170
+ cap: "theme",
171
+ header: "테마",
172
+ ask: `테마는? ${existsSync(grid) ? `같은 문장 한 장면을 테마마다 찍은 견본 시트 ${grid}` : "보기마다 견본 그림 경로"}`,
173
+ choices: [
174
+ { value: "auto", label: "알아서", note: `요청 낱말에 맞는 approved 테마를 고른다 — 지금이면 ${first.name}` },
175
+ ...ranked.map(({ id }) => {
176
+ const t = byId.get(id)!;
177
+ const sample = themeSample(t);
178
+ return { value: t.id, label: `${t.name} · ${themeDims(t)}`, note: `${t.metaphor}${sample ? ` — 견본 ${sample}` : ""}` };
179
+ }),
180
+ ],
181
+ default: "auto",
182
+ skip: "auto",
183
+ flag: "--theme",
184
+ // 보기 밖이라도 사람이 짚은 review 테마·none(프리셋만)은 받는다 — kf new --theme 과 같은 범위
185
+ accepts: (v: string) => v === "none" || listThemes({ status: ["approved", "review"] }).some((t) => t.id === v),
186
+ },
187
+ };
188
+ }
189
+
190
+ // 곡 — 틀이 분위기를 정한 용도만. 시리즈 곡·분위기 맞는 곡 모음 곡(0원·늘 같은 곡)은 묻지 않는다.
191
+ // 없으면 생성(돈)·곡 넣기·없음을 묻고, 생성 키도 없으면 다른 분위기 곡·「곡 없이」로 조용히 넘어가지 않고 missing 으로 묻는다
192
+ function musicPart(plan: Plan, caps: CapabilityReport): { q?: Question; auto?: string } {
193
+ // 시리즈가 정한 분위기가 틀 분위기를 덮는다 — 같은 시리즈면 같은 곡
194
+ const mood = plan.mood ?? loadTemplate(plan.purpose).mood;
195
+ if (!mood || plan.music) return {};
196
+ const file = plan.series ? loadSeries(plan.series).music?.file : undefined;
197
+ if (file) return { auto: fileURLToPath(new URL(`../../../${file}`, import.meta.url)) };
198
+ const lib = byMood(mood);
199
+ if (lib.length) return { auto: lib[0].path };
200
+ const ready = caps.providers.filter((p) => p.ready && p.id !== "library").map((p) => p.id);
201
+ const put: Choice = { value: WAIT, label: "곡을 넣고 다시", note: `kf music add <곡> --mood ${mood} --source <원본> --license "<라이선스>" 로 곡 모음에 넣거나 --music <곡 파일>` };
202
+ const q = musicQuestion({ mood, duration: plan.duration, ready });
203
+ if (ready.length) return { q: { ...q, choices: [q.choices[0], put, ...q.choices.slice(1)].slice(0, 4) } };
204
+ const { default: _d, skip: _s, choices: _c, ...head } = q;
205
+ return {
206
+ q: missing(
207
+ { ...head, ask: `분위기 ${mood} 에 맞는 곡이 곡 모음에 없고 음악 생성 키도 없다` },
208
+ { ...put, label: "곡이나 생성 키를 넣고 다시", note: `${put.note} · 생성은 ${howToGet("gemini")}(Lyria 3.5, 유료 등급) 또는 ${howToGet("elevenlabs")}(Eleven Music)` },
209
+ listLibrary().filter((t) => t.license && t.mood.length).slice(0, 1).map((t) => ({ value: t.path, label: `곡 모음 「${t.title}」로`, costUsd: 0, note: `틀 분위기(${mood})와 다른 곡(${t.mood.join("·")}) — ${t.license}` })),
210
+ { value: "none", label: "곡 없이", costUsd: 0 },
211
+ ),
212
+ };
213
+ }
214
+
215
+ export function planQuestions(plan: Plan, caps: CapabilityReport[]): PlanQuestions {
216
+ const by = (c: string) => caps.find((x) => x.cap === c) ?? { cap: c, label: c, providers: [], best: null };
217
+ const parts: [string, { q?: Question; auto?: string }][] = [
218
+ ["theme", themePart(plan)],
219
+ ["image", imageQuestion(plan, by("image") as CapabilityReport)],
220
+ ["video", videoQuestion(plan, by("video") as CapabilityReport)],
221
+ ["blender", blenderQuestion(plan, by("blender") as CapabilityReport)],
222
+ ["voice", voicePart(plan, by("voice") as CapabilityReport)],
223
+ ["music", musicPart(plan, by("music") as CapabilityReport)],
224
+ ];
225
+ const out: PlanQuestions = { questions: [], auto: {} };
226
+ for (const [id, r] of parts) {
227
+ if (r.q) out.questions.push(r.q);
228
+ else if (r.auto) out.auto[id] = r.auto;
229
+ }
230
+ return out;
231
+ }
232
+
233
+ // 답대로 계획을 고친다 — 빼기로 한 능력의 만들 거리를 지우고, 고른 공급자를 적는다. wait 를 고른 질문은 stop 으로 돌려준다
234
+ export function applyAnswers(plan: Plan, answers: Record<string, string>, questions: Question[] = []): { plan: Plan; stop: string[] } {
235
+ const stop = questions.filter((q) => answers[q.id] === WAIT).map((q) => `${q.ask} — ${q.choices.find((c) => c.value === WAIT)?.note ?? ""}`);
236
+ const p: Plan = { ...plan, answers: { ...(plan.answers ?? {}), ...answers } };
237
+ const drop = (kind: "img" | "vid") => {
238
+ const gone = new Set(p.gen.filter((g) => g.kind === kind).map((g) => g.id));
239
+ p.gen = p.gen.filter((g) => g.kind !== kind);
240
+ p.scenes = p.scenes.map((s) => ({ ...s, assets: s.assets.filter((a) => !gone.has(a.replace(/^gen:(img|vid):/, ""))) }));
241
+ // 지운 그림을 첫 프레임으로 기다리던 영상은 글만으로 간다
242
+ if (kind === "img") p.gen = p.gen.map((g) => (g.first && gone.has(g.first.replace(/^assets\/gen\/|\.png$/g, "")) ? { ...g, first: undefined } : g));
243
+ };
244
+ const pick = (kind: "img" | "vid", v?: string) => {
245
+ if (!v || v === WAIT) return;
246
+ if (v === "none") drop(kind);
247
+ else p.gen = p.gen.map((g) => (g.kind === kind ? { ...g, provider: v } : g));
248
+ };
249
+ pick("img", answers.image);
250
+ pick("vid", answers.video);
251
+ // 목소리·곡은 kf narrate 가 읽는 칸으로 — 곡 파일 경로는 kf new 가 곡으로 깔고, gen:·none 은 narrate 가 처리한다
252
+ if (answers.voice && answers.voice !== WAIT) p.voice = answers.voice;
253
+ if (answers.blender === "none") p.shots = [];
254
+ else if (answers.blender === "three") p.shots = (p.shots ?? []).map((s) => ({ ...s, tool: "three" }));
255
+ return { plan: p, stop };
256
+ }