kasaframe 0.0.0-stage → 0.1.1

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 (338) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +146 -0
  3. package/README.md +77 -2
  4. package/app/package.json +12 -0
  5. package/app/server/engine.ts +415 -0
  6. package/app/server/main.ts +205 -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 +1013 -0
  11. package/app/web/style.css +430 -0
  12. package/bin/hooks.mjs +51 -0
  13. package/bin/kf.mjs +14 -0
  14. package/docs/AGENTS.md +238 -0
  15. package/music/README.md +13 -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 +273 -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 +42 -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 +135 -0
  43. package/packages/check/src/rules/layout.ts +257 -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 +29 -0
  52. package/packages/cli/src/blur.ts +68 -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/blender.ts +270 -0
  58. package/packages/cli/src/commands/check.ts +25 -0
  59. package/packages/cli/src/commands/doctor.ts +22 -0
  60. package/packages/cli/src/commands/gen.ts +173 -0
  61. package/packages/cli/src/commands/look.ts +39 -0
  62. package/packages/cli/src/commands/lyrics.ts +111 -0
  63. package/packages/cli/src/commands/make.ts +542 -0
  64. package/packages/cli/src/commands/new.ts +176 -0
  65. package/packages/cli/src/commands/preview.ts +43 -0
  66. package/packages/cli/src/commands/render.ts +216 -0
  67. package/packages/cli/src/commands/setup.ts +63 -0
  68. package/packages/cli/src/commands/sheet.ts +114 -0
  69. package/packages/cli/src/commands/skill.ts +43 -0
  70. package/packages/cli/src/commands/still.ts +40 -0
  71. package/packages/cli/src/commands/theme.ts +85 -0
  72. package/packages/cli/src/commands/transitions.ts +40 -0
  73. package/packages/cli/src/deps.ts +122 -0
  74. package/packages/cli/src/ffmpeg.ts +81 -0
  75. package/packages/cli/src/index.ts +8 -0
  76. package/packages/cli/src/kf.ts +53 -0
  77. package/packages/cli/src/lock.ts +72 -0
  78. package/packages/cli/src/out.ts +13 -0
  79. package/packages/cli/src/serve.ts +124 -0
  80. package/packages/clock/package.json +14 -0
  81. package/packages/clock/src/index.ts +25 -0
  82. package/packages/clock/src/install.ts +351 -0
  83. package/packages/clock/src/types.ts +45 -0
  84. package/packages/core/package.json +9 -0
  85. package/packages/core/src/beats.ts +283 -0
  86. package/packages/core/src/ease.ts +87 -0
  87. package/packages/core/src/frame.ts +99 -0
  88. package/packages/core/src/index.ts +27 -0
  89. package/packages/core/src/project.ts +146 -0
  90. package/packages/core/src/rand.ts +56 -0
  91. package/packages/core/src/spring.ts +52 -0
  92. package/packages/core/src/style.ts +100 -0
  93. package/packages/core/src/time.ts +88 -0
  94. package/packages/gen/PROVIDERS.md +55 -0
  95. package/packages/gen/package.json +9 -0
  96. package/packages/gen/src/generate.ts +204 -0
  97. package/packages/gen/src/image/og.ts +133 -0
  98. package/packages/gen/src/index.ts +18 -0
  99. package/packages/gen/src/keys.ts +60 -0
  100. package/packages/gen/src/media.ts +150 -0
  101. package/packages/gen/src/plan.ts +106 -0
  102. package/packages/gen/src/registry.ts +51 -0
  103. package/packages/gen/src/seam.ts +103 -0
  104. package/packages/gen/src/types.ts +86 -0
  105. package/packages/gen/src/video/fal.ts +140 -0
  106. package/packages/gen/src/video/h3.ts +107 -0
  107. package/packages/gen/src/video/http.ts +44 -0
  108. package/packages/gen/src/video/ltx.ts +60 -0
  109. package/packages/gen/src/video/minimax.ts +55 -0
  110. package/packages/gen/src/video/veo.ts +71 -0
  111. package/packages/jizura/package.json +16 -0
  112. package/packages/jizura/src/deny.ts +73 -0
  113. package/packages/jizura/src/index.ts +7 -0
  114. package/packages/jizura/src/install.ts +226 -0
  115. package/packages/jizura/src/layer.ts +282 -0
  116. package/packages/jizura/src/lyrics.ts +81 -0
  117. package/packages/jizura/src/pin.ts +5 -0
  118. package/packages/jizura/src/vite.ts +36 -0
  119. package/packages/motion/README.md +142 -0
  120. package/packages/motion/package.json +29 -0
  121. package/packages/motion/src/camera.ts +97 -0
  122. package/packages/motion/src/captions.ts +479 -0
  123. package/packages/motion/src/enter.ts +128 -0
  124. package/packages/motion/src/hangul.ts +129 -0
  125. package/packages/motion/src/impact.ts +100 -0
  126. package/packages/motion/src/index.ts +17 -0
  127. package/packages/motion/src/moves/brushWipe.ts +90 -0
  128. package/packages/motion/src/moves/cloneArray.ts +111 -0
  129. package/packages/motion/src/moves/curtains.ts +81 -0
  130. package/packages/motion/src/moves/echoStack.ts +70 -0
  131. package/packages/motion/src/moves/fit.ts +34 -0
  132. package/packages/motion/src/moves/flood.ts +61 -0
  133. package/packages/motion/src/moves/ghostStack.ts +79 -0
  134. package/packages/motion/src/moves/gridFloor.ts +100 -0
  135. package/packages/motion/src/moves/imageSwarm.ts +109 -0
  136. package/packages/motion/src/moves/index.ts +19 -0
  137. package/packages/motion/src/moves/irisBlades.ts +113 -0
  138. package/packages/motion/src/moves/karaokeLine.ts +94 -0
  139. package/packages/motion/src/moves/ledBoard.ts +94 -0
  140. package/packages/motion/src/moves/liquidTab.ts +72 -0
  141. package/packages/motion/src/moves/markerWrite.ts +63 -0
  142. package/packages/motion/src/moves/morphBox.ts +96 -0
  143. package/packages/motion/src/moves/neonSign.ts +77 -0
  144. package/packages/motion/src/moves/panelPop.ts +78 -0
  145. package/packages/motion/src/moves/paperTear.ts +75 -0
  146. package/packages/motion/src/moves/path.ts +64 -0
  147. package/packages/motion/src/moves/pathText.ts +107 -0
  148. package/packages/motion/src/moves/pointSphere.ts +109 -0
  149. package/packages/motion/src/moves/ransomLetters.ts +73 -0
  150. package/packages/motion/src/moves/shapeMorph.ts +143 -0
  151. package/packages/motion/src/moves/slamWords.ts +89 -0
  152. package/packages/motion/src/moves/sparkTrail.ts +114 -0
  153. package/packages/motion/src/moves/speedLines.ts +91 -0
  154. package/packages/motion/src/moves/splitFlap.ts +147 -0
  155. package/packages/motion/src/moves/stepWords.ts +117 -0
  156. package/packages/motion/src/moves/strikeOut.ts +98 -0
  157. package/packages/motion/src/moves/sunburst.ts +58 -0
  158. package/packages/motion/src/moves/tickerRows.ts +87 -0
  159. package/packages/motion/src/moves/tokenPicker.ts +114 -0
  160. package/packages/motion/src/moves/truchet.ts +85 -0
  161. package/packages/motion/src/moves/wordWall.ts +76 -0
  162. package/packages/motion/src/moves/worldRoll.ts +31 -0
  163. package/packages/motion/src/particles.ts +102 -0
  164. package/packages/motion/src/react/index.tsx +21 -0
  165. package/packages/motion/src/react/parts.tsx +431 -0
  166. package/packages/motion/src/react/time.tsx +97 -0
  167. package/packages/motion/src/text.ts +103 -0
  168. package/packages/motion/src/transition.ts +82 -0
  169. package/packages/motion/src/transition3d/cards.ts +65 -0
  170. package/packages/motion/src/transition3d/chain.ts +84 -0
  171. package/packages/motion/src/transition3d/dive.ts +181 -0
  172. package/packages/motion/src/transition3d/fold.ts +110 -0
  173. package/packages/motion/src/transition3d/gl.ts +219 -0
  174. package/packages/motion/src/transition3d/index.ts +228 -0
  175. package/packages/motion/src/transition3d/live.ts +70 -0
  176. package/packages/motion/src/transition3d/portal.ts +115 -0
  177. package/packages/motion/src/transition3d/react.tsx +29 -0
  178. package/packages/motion/src/transition3d/rig.ts +502 -0
  179. package/packages/motion/src/transition3d/shatter.ts +101 -0
  180. package/packages/motion/src/transition3d/whip.ts +65 -0
  181. package/packages/motion/src/transition3d/world.ts +683 -0
  182. package/packages/motion/src/transition3d/zoomOut.ts +114 -0
  183. package/packages/motion/src/transitions2d/catalog.ts +127 -0
  184. package/packages/motion/src/transitions2d/css.d.ts +2 -0
  185. package/packages/motion/src/transitions2d/cult-ui/LICENSE.md +9 -0
  186. package/packages/motion/src/transitions2d/cult-ui/RollingNumber.tsx +43 -0
  187. package/packages/motion/src/transitions2d/gl-transitions/LICENSE +25 -0
  188. package/packages/motion/src/transitions2d/gl-transitions/shaders.ts +1931 -0
  189. package/packages/motion/src/transitions2d/index.ts +2 -0
  190. package/packages/motion/src/transitions2d/kokonutui/LICENSE +21 -0
  191. package/packages/motion/src/transitions2d/kokonutui/MatrixText.css +16 -0
  192. package/packages/motion/src/transitions2d/kokonutui/MatrixText.tsx +94 -0
  193. package/packages/motion/src/transitions2d/magicui/HyperText.css +15 -0
  194. package/packages/motion/src/transitions2d/magicui/HyperText.tsx +115 -0
  195. package/packages/motion/src/transitions2d/magicui/LICENSE.md +21 -0
  196. package/packages/motion/src/transitions2d/magicui/MorphingText.css +25 -0
  197. package/packages/motion/src/transitions2d/magicui/MorphingText.tsx +130 -0
  198. package/packages/motion/src/transitions2d/magicui/WordRotate.tsx +42 -0
  199. package/packages/motion/src/transitions2d/react.ts +13 -0
  200. package/packages/motion/src/transitions2d/skiper-ui/ClipDiv.css +39 -0
  201. package/packages/motion/src/transitions2d/skiper-ui/ClipDiv.tsx +32 -0
  202. package/packages/motion/src/transitions2d/smoothui/LICENSE +21 -0
  203. package/packages/motion/src/transitions2d/smoothui/SharedAxisY.tsx +50 -0
  204. package/packages/motion/src/transitions2d/smoothui/TextMorph.tsx +90 -0
  205. package/packages/motion/src/transitions2d/smoothui/shaders.ts +223 -0
  206. package/packages/motion/src/transitions2d/unlumen/LICENSE +21 -0
  207. package/packages/motion/src/transitions2d/unlumen/ScrambleText.tsx +114 -0
  208. package/packages/motion/src/transitions2d/vengeance-ui/LICENSE +21 -0
  209. package/packages/motion/src/transitions2d/vengeance-ui/MorphText.css +69 -0
  210. package/packages/motion/src/transitions2d/vengeance-ui/MorphText.tsx +45 -0
  211. package/packages/motion/src/type.ts +131 -0
  212. package/packages/motion/src/ui.ts +172 -0
  213. package/packages/plan/package.json +15 -0
  214. package/packages/plan/src/brief.ts +254 -0
  215. package/packages/plan/src/captions.ts +75 -0
  216. package/packages/plan/src/detect.ts +93 -0
  217. package/packages/plan/src/index.ts +23 -0
  218. package/packages/plan/src/layout.ts +176 -0
  219. package/packages/plan/src/llm.ts +110 -0
  220. package/packages/plan/src/look.ts +220 -0
  221. package/packages/plan/src/plan.ts +125 -0
  222. package/packages/plan/src/request.ts +55 -0
  223. package/packages/plan/src/studio.ts +53 -0
  224. package/packages/plan/src/templates.ts +42 -0
  225. package/packages/plan/src/themes.ts +48 -0
  226. package/packages/plan/src/types.ts +106 -0
  227. package/packages/studio/package.json +12 -0
  228. package/packages/studio/src/index.ts +1 -0
  229. package/packages/studio/src/plugin.ts +236 -0
  230. package/packages/studio/src/ui/main.ts +503 -0
  231. package/packages/studio/src/ui/studio.css +165 -0
  232. package/packages/studio/src/ui/timeline.ts +317 -0
  233. package/packages/themes/kit/THEME-MAKE.md +68 -0
  234. package/packages/themes/kit/THEME.md +30 -0
  235. package/packages/themes/kit/briefs/og-intro-15s/brief.json +16 -0
  236. package/packages/themes/kit/briefs/og-intro-15s/facts.ts +29 -0
  237. package/packages/themes/kit/briefs/og-intro-15s/logo.svg +12 -0
  238. package/packages/themes/kit/effects.ts +5 -0
  239. package/packages/themes/kit/sample/index.html +11 -0
  240. package/packages/themes/kit/sample/main.ts +9 -0
  241. package/packages/themes/kit/sample/scenes/scene.ts +15 -0
  242. package/packages/themes/package.json +16 -0
  243. package/packages/themes/src/factory.ts +296 -0
  244. package/packages/themes/src/fx.ts +14 -0
  245. package/packages/themes/src/index.ts +105 -0
  246. package/packages/themes/src/stage3d.ts +177 -0
  247. package/packages/themes/src/types.ts +58 -0
  248. package/presets/kawaii-pastel.json +94 -0
  249. package/presets/neutral-dark.json +82 -0
  250. package/presets/og.json +98 -0
  251. package/skills/kasaframe/SKILL.md +32 -0
  252. package/templates/_shared/project/index.html +11 -0
  253. package/templates/_shared/project/lib/react.ts +22 -0
  254. package/templates/_shared/project/lib/stage.ts +272 -0
  255. package/templates/_shared/project/main.ts +9 -0
  256. package/templates/_shared/scenes/default.ts +18 -0
  257. package/templates/_shared/scenes/drop.ts +30 -0
  258. package/templates/_shared/scenes/end.ts +23 -0
  259. package/templates/_shared/scenes/hook.ts +16 -0
  260. package/templates/_shared/scenes/seam.ts +41 -0
  261. package/templates/_shared/scenes/step.ts +40 -0
  262. package/templates/ad/preview.png +0 -0
  263. package/templates/ad/template.json +132 -0
  264. package/templates/demo/preview.png +0 -0
  265. package/templates/demo/template.json +130 -0
  266. package/templates/explainer/preview.png +0 -0
  267. package/templates/explainer/template.json +142 -0
  268. package/templates/launch/preview.png +0 -0
  269. package/templates/launch/template.json +130 -0
  270. package/templates/mv/preview.png +0 -0
  271. package/templates/mv/scenes/default.ts +95 -0
  272. package/templates/mv/template.json +176 -0
  273. package/templates/promo/preview.png +0 -0
  274. package/templates/promo/template.json +144 -0
  275. package/templates/shorts/preview.png +0 -0
  276. package/templates/shorts/scenes/hook.ts +34 -0
  277. package/templates/shorts/template.json +127 -0
  278. package/templates/square/preview.png +0 -0
  279. package/templates/square/template.json +113 -0
  280. package/themes/debug-hud/THEME.md +39 -0
  281. package/themes/debug-hud/effects.ts +389 -0
  282. package/themes/debug-hud/sample/assets/og/logo.svg +12 -0
  283. package/themes/debug-hud/sample/beats.json +1 -0
  284. package/themes/debug-hud/sample/index.html +11 -0
  285. package/themes/debug-hud/sample/kf.json +59 -0
  286. package/themes/debug-hud/sample/lib/hudkit.ts +49 -0
  287. package/themes/debug-hud/sample/lib/og.ts +29 -0
  288. package/themes/debug-hud/sample/main.ts +9 -0
  289. package/themes/debug-hud/sample/scenes/end.ts +62 -0
  290. package/themes/debug-hud/sample/scenes/gather.ts +67 -0
  291. package/themes/debug-hud/sample/scenes/models.ts +70 -0
  292. package/themes/debug-hud/sample/scenes/price.ts +79 -0
  293. package/themes/debug-hud/sample/style.json +91 -0
  294. package/themes/debug-hud/still.png +0 -0
  295. package/themes/debug-hud/style.json +91 -0
  296. package/themes/debug-hud/theme.json +68 -0
  297. package/themes/og-measure/THEME.md +47 -0
  298. package/themes/og-measure/effects.ts +432 -0
  299. package/themes/og-measure/sample/assets/brand/og-logo-full.svg +12 -0
  300. package/themes/og-measure/sample/assets/brand/og-logo.svg +12 -0
  301. package/themes/og-measure/sample/assets/data/measure.json +353 -0
  302. package/themes/og-measure/sample/beats.json +1 -0
  303. package/themes/og-measure/sample/index.html +11 -0
  304. package/themes/og-measure/sample/kf.json +66 -0
  305. package/themes/og-measure/sample/lib/data.ts +62 -0
  306. package/themes/og-measure/sample/main.ts +9 -0
  307. package/themes/og-measure/sample/measure.ts +78 -0
  308. package/themes/og-measure/sample/scenes/end.ts +47 -0
  309. package/themes/og-measure/sample/scenes/gather.ts +51 -0
  310. package/themes/og-measure/sample/scenes/models.ts +34 -0
  311. package/themes/og-measure/sample/scenes/one.ts +39 -0
  312. package/themes/og-measure/sample/scenes/price.ts +56 -0
  313. package/themes/og-measure/sample/style.json +97 -0
  314. package/themes/og-measure/still.png +0 -0
  315. package/themes/og-measure/style.json +97 -0
  316. package/themes/og-measure/theme.json +79 -0
  317. package/themes/riso-zine/THEME.md +43 -0
  318. package/themes/riso-zine/effects.ts +321 -0
  319. package/themes/riso-zine/sample/assets/og/logo.svg +12 -0
  320. package/themes/riso-zine/sample/beats.json +1 -0
  321. package/themes/riso-zine/sample/index.html +11 -0
  322. package/themes/riso-zine/sample/kf.json +59 -0
  323. package/themes/riso-zine/sample/lib/og.ts +29 -0
  324. package/themes/riso-zine/sample/lib/shot.ts +86 -0
  325. package/themes/riso-zine/sample/lib/zine.ts +42 -0
  326. package/themes/riso-zine/sample/main.ts +9 -0
  327. package/themes/riso-zine/sample/scenes/end.ts +61 -0
  328. package/themes/riso-zine/sample/scenes/gather.ts +62 -0
  329. package/themes/riso-zine/sample/scenes/models.ts +52 -0
  330. package/themes/riso-zine/sample/scenes/price.ts +82 -0
  331. package/themes/riso-zine/sample/style.json +99 -0
  332. package/themes/riso-zine/still.png +0 -0
  333. package/themes/riso-zine/style.json +99 -0
  334. package/themes/riso-zine/theme.json +75 -0
  335. package/tools/beats/beats.py +372 -0
  336. package/tools/beats/requirements.txt +3 -0
  337. package/tools/lyrics/align.py +164 -0
  338. package/tools/lyrics/requirements.txt +9 -0
@@ -0,0 +1,173 @@
1
+ import { join, resolve } from "node:path";
2
+ import {
3
+ DEFAULT_MAX_USD,
4
+ estimateImageUsd,
5
+ genImage,
6
+ genVideo,
7
+ hasKey,
8
+ imageProviders,
9
+ NeedsApproval,
10
+ planVideo,
11
+ resolvePlan,
12
+ seam,
13
+ videoProviders,
14
+ whereToPut,
15
+ type Asset,
16
+ type GenContext,
17
+ } from "@kasaframe/gen";
18
+ import type { Command } from "../command.ts";
19
+ import { num, parseFlags } from "../command.ts";
20
+
21
+ const USAGE = `kf gen models
22
+ kf gen img "<프롬프트>" --id <이름> [--size 1920x1080] [--transparent] [--ref a.png,b.png] [--quality high] [--provider og-gpt-image-2.5-sunburst]
23
+ kf gen vid "<프롬프트>" --id <이름> [--first a.png] [--last b.png] [--dur 5] [--aspect 16:9] [--provider wan-2.2-turbo] [--max-usd 1] [--yes]
24
+ kf gen seam <폴더> <이음매 장면 id> "<프롬프트>" [--provider ...] [--first a.png] [--last b.png] [--smooth] [--yes]
25
+ kf gen plan <폴더> [--yes]
26
+
27
+ 공통: --project <폴더>(결과는 <폴더>/assets/gen) · --out <폴더> · --max-usd <영상 하나 상한, 기본 ${DEFAULT_MAX_USD}>
28
+ 영상은 --yes 가 없으면 견적만 내고 종료 코드 3. 같은 입력은 캐시(~/.cache/kasaframe/gen)에서 꺼내 돈이 안 든다.`;
29
+
30
+ function usage(): number {
31
+ console.error(USAGE);
32
+ return 2;
33
+ }
34
+
35
+ function ctxOf(opts: Record<string, string | boolean | undefined>, outDir: string): GenContext {
36
+ return {
37
+ outDir,
38
+ maxUsd: num(opts["max-usd"], DEFAULT_MAX_USD),
39
+ approve: opts.yes === true,
40
+ log: (l) => console.error(l),
41
+ };
42
+ }
43
+
44
+ function outDirOf(opts: Record<string, string | boolean | undefined>): string {
45
+ if (typeof opts.out === "string") return resolve(opts.out);
46
+ if (typeof opts.project === "string") return join(resolve(opts.project), "assets", "gen");
47
+ return resolve("assets/gen");
48
+ }
49
+
50
+ function report(a: Asset): void {
51
+ const m = a.meta;
52
+ const cost = a.cached ? "캐시(0)" : `$${m.costUsd.toFixed(4)}${m.costEstimated ? "(단가표)" : ""}`;
53
+ const size = m.duration ? `${m.width}x${m.height} ${m.duration.toFixed(2)}초` : `${m.width}x${m.height}`;
54
+ console.log(`${a.path}\n ${m.provider} · ${size} · ${cost} · ${(m.elapsedMs / 1000).toFixed(1)}초${m.notes?.length ? ` · ${m.notes.join(" ")}` : ""}`);
55
+ }
56
+
57
+ function models(): number {
58
+ const sample = { prompt: "", duration: 5, aspect: "16:9", firstFrame: "x", lastFrame: "y", resolution: "720p" };
59
+ console.log("그림");
60
+ for (const p of imageProviders()) {
61
+ const est = estimateImageUsd({ prompt: "", size: "1920x1080", quality: "high" });
62
+ console.log(` ${p.id.padEnd(30)} 1920x1080 high 최대 $${est.toFixed(3)} 키 ${hasKey(p.keyName) ? "있음" : `없음 — ${whereToPut(p.keyName)}`}`);
63
+ }
64
+ console.log("\n영상 (5초 720p 끝 프레임 포함 견적)");
65
+ for (const p of videoProviders()) {
66
+ const key = hasKey(p.keyName) ? "있음" : `없음 — ${whereToPut(p.keyName)}`;
67
+ console.log(` ${p.id.padEnd(30)} $${p.estimateUsd(sample).toFixed(3).padEnd(6)} 길이 ${p.durations[0]}–${p.durations[p.durations.length - 1]}초 키 ${key}`);
68
+ console.log(` ${"".padEnd(30)} ${p.license} · ${p.region}`);
69
+ }
70
+ return 0;
71
+ }
72
+
73
+ async function guarded(f: () => Promise<number>): Promise<number> {
74
+ try {
75
+ return await f();
76
+ } catch (e) {
77
+ if (e instanceof NeedsApproval) {
78
+ console.error(`승인 필요: ${e.message}\n 돈을 쓰려면 같은 명령에 --yes (상한은 --max-usd)`);
79
+ return 3;
80
+ }
81
+ throw e;
82
+ }
83
+ }
84
+
85
+ const cmd: Command = {
86
+ summary: "그림·영상 생성(OG gpt-image · fal Wan/Kling · MiniMax · Veo · LTX) — 캐시·예산·이음매 전환",
87
+ usage: USAGE,
88
+ async run(argv) {
89
+ const [sub, ...rest] = argv;
90
+ const { args, opts } = parseFlags(rest);
91
+ if (sub === "models") return models();
92
+
93
+ if (sub === "img") {
94
+ const prompt = args[0];
95
+ if (!prompt || typeof opts.id !== "string") return usage();
96
+ return guarded(async () => {
97
+ const refs = typeof opts.ref === "string" ? opts.ref.split(",").map((r) => resolve(r)) : undefined;
98
+ const a = await genImage(
99
+ opts.id as string,
100
+ { prompt, size: typeof opts.size === "string" ? opts.size : "1920x1080", transparent: opts.transparent === true, refs, quality: opts.quality as string | undefined },
101
+ ctxOf(opts, outDirOf(opts)),
102
+ opts.provider as string | undefined,
103
+ );
104
+ report(a);
105
+ return 0;
106
+ });
107
+ }
108
+
109
+ if (sub === "vid") {
110
+ const prompt = args[0];
111
+ if (!prompt || typeof opts.id !== "string") return usage();
112
+ return guarded(async () => {
113
+ const req = {
114
+ prompt,
115
+ firstFrame: typeof opts.first === "string" ? resolve(opts.first) : undefined,
116
+ lastFrame: typeof opts.last === "string" ? resolve(opts.last) : undefined,
117
+ duration: num(opts.dur, 5),
118
+ aspect: typeof opts.aspect === "string" ? opts.aspect : "16:9",
119
+ resolution: opts.resolution as string | undefined,
120
+ seed: typeof opts.seed === "string" ? Number(opts.seed) : undefined,
121
+ };
122
+ const ctx = ctxOf(opts, outDirOf(opts));
123
+ const plan = planVideo(req, ctx, opts.provider as string | undefined);
124
+ console.error(`${plan.provider.id} 견적 $${plan.estimateUsd.toFixed(3)}${plan.cached ? " (캐시 있음 — 0원)" : ""}`);
125
+ report(await genVideo(opts.id as string, req, ctx, opts.provider as string | undefined));
126
+ return 0;
127
+ });
128
+ }
129
+
130
+ if (sub === "seam") {
131
+ const [project, scene, prompt] = args;
132
+ if (!project || !scene || !prompt) return usage();
133
+ return guarded(async () => {
134
+ const a = await seam(
135
+ {
136
+ project,
137
+ scene,
138
+ prompt,
139
+ provider: opts.provider as string | undefined,
140
+ first: typeof opts.first === "string" ? resolve(opts.first) : undefined,
141
+ last: typeof opts.last === "string" ? resolve(opts.last) : undefined,
142
+ smooth: opts.smooth === true,
143
+ resolution: opts.resolution as string | undefined,
144
+ },
145
+ ctxOf(opts, join(resolve(project), "assets", "gen")),
146
+ );
147
+ report(a);
148
+ return 0;
149
+ });
150
+ }
151
+
152
+ if (sub === "plan") {
153
+ const project = args[0];
154
+ if (!project) return usage();
155
+ const { outDir: _, ...ctx } = ctxOf(opts, "");
156
+ const reports = await resolvePlan(project, ctx);
157
+ let spent = 0;
158
+ let waiting = 0;
159
+ for (const r of reports) {
160
+ spent += r.costUsd ?? 0;
161
+ if (r.status === "needs-approval") waiting += r.estimateUsd ?? 0;
162
+ const tail = r.status === "made" || r.status === "cached" ? r.path : r.error;
163
+ console.log(`${r.status.padEnd(15)} ${r.kind} ${r.id.padEnd(20)} ${tail ?? ""}`);
164
+ }
165
+ console.log(`\n쓴 돈 $${spent.toFixed(4)}${waiting ? ` · 승인 기다리는 영상 견적 $${waiting.toFixed(3)} (--yes)` : ""}`);
166
+ if (reports.some((r) => r.status === "error")) return 1;
167
+ return reports.some((r) => r.status === "needs-approval") ? 3 : 0;
168
+ }
169
+
170
+ return usage();
171
+ },
172
+ };
173
+ export default cmd;
@@ -0,0 +1,39 @@
1
+ import { writeFileSync } from "node:fs";
2
+ import { dirname, join, resolve } from "node:path";
3
+ import { DEFAULT_EYES, formatLook, look, lookSheet } from "@kasaframe/plan";
4
+ import { type Command, parseFlags } from "../command.ts";
5
+
6
+ const cmd: Command = {
7
+ summary: "세션이 직접 볼 것 — 장면 모음 한 장과 장면별 확인표의 경로(외부 모델 0). 눈 없는 세션은 --vision-model",
8
+ usage: `kf look <폴더 | 영상.mp4> [--vision-model ${DEFAULT_EYES} [--ask "<볼 것>"]] [--json]
9
+
10
+ 기본: 장면 모음(kf sheet — 장면마다 가운데 한 장, 4열)과 장면별 확인표(look.md)를 만들고 경로를 찍는다.
11
+ 세션이 그림을 Read 로 직접 보고 확인표를 따라 고친다. 외부 모델을 부르지 않는다(돈 0). 폴더면 out/, mp4 면 옆에 둔다.
12
+ 정지 그림이라 0.1초 멈춤·박·섬광·카메라 이동은 kf check 가 본다.
13
+
14
+ --vision-model 그림을 못 보는 세션(Claude Code 를 OG 로 딥시크 같은 모델에 붙이면 OG /v1/messages 가 그림을 버린다)용.
15
+ 그 모델이 OG chat/completions 로 장면 모음을 보고 장면별 글 보고(한 번에 1센트 안팎) — JSON 은 out/look.json,
16
+ 문제 장면이 있으면 종료 코드 1
17
+ --ask --vision-model 에게 따로 물을 것`,
18
+ async run(argv) {
19
+ const { args, opts } = parseFlags(argv);
20
+ if (!args[0]) {
21
+ console.error("kf look: 폴더나 mp4 를 준다 — kf look --help");
22
+ return 2;
23
+ }
24
+ const target = resolve(args[0]);
25
+ const model = typeof opts["vision-model"] === "string" ? opts["vision-model"] : undefined;
26
+ if (!model) {
27
+ if (typeof opts.ask === "string") console.error("kf look: --ask 는 --vision-model 과 함께 쓴다 — 기본은 세션이 직접 본다");
28
+ const s = lookSheet(target);
29
+ console.log(opts.json ? JSON.stringify(s, null, 2) : `장면 모음: ${s.sheet}\n확인표: ${s.checklist}\n— 장면 ${s.scenes}개. 그림을 Read 로 직접 보고 확인표대로 고친다`);
30
+ return 0;
31
+ }
32
+ const r = await look(target, { ask: typeof opts.ask === "string" ? opts.ask : undefined, model });
33
+ const out = /\.(mp4|mov|webm|m4v)$/i.test(target) ? join(dirname(target), "look.json") : join(target, "out", "look.json");
34
+ writeFileSync(out, `${JSON.stringify(r, null, 2)}\n`);
35
+ console.log(opts.json ? JSON.stringify(r, null, 2) : formatLook(r));
36
+ return r.scenes.some((s) => !s.ok) ? 1 : 0;
37
+ },
38
+ };
39
+ export default cmd;
@@ -0,0 +1,111 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { dirname, join, resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { parseLyrics, toLrc } from "@kasaframe/jizura/lyrics";
6
+ import { type Command, num, parseFlags } from "../command.ts";
7
+ import { pyVenv, venvPython } from "../deps.ts";
8
+
9
+ const tools = fileURLToPath(new URL("../../../../tools/lyrics/", import.meta.url));
10
+ const script = join(tools, "align.py");
11
+ const requirements = join(tools, "requirements.txt");
12
+ // torch·demucs 가 무거워(2GB 안팎) beats 의 librosa venv 와 따로 둔다
13
+ const venv = () => pyVenv("lyrics");
14
+ const python = () => process.env.KF_LYRICS_PYTHON ?? venvPython(venv());
15
+
16
+ /** kf doctor 한 줄 */
17
+ export function lyricsCheck() {
18
+ const py = python();
19
+ const r = existsSync(py) || process.env.KF_LYRICS_PYTHON ? spawnSync(py, ["-c", "import demucs, stable_whisper; print(stable_whisper.__version__)"], { encoding: "utf8" }) : null;
20
+ const ok = r?.status === 0;
21
+ return {
22
+ name: "가사 정렬(demucs+stable-ts)",
23
+ ok,
24
+ required: false,
25
+ detail: ok ? `${py} · stable-ts ${r!.stdout.trim()}` : "없음 — kf lyrics align(공식 가사에 시각 붙이기)만 못 쓴다",
26
+ fix: ok ? undefined : "kf setup lyrics (torch·demucs·whisper 2GB 안팎, 첫 정렬 때 whisper 모델 1.6GB 를 더 받는다)",
27
+ };
28
+ }
29
+
30
+ const which = (cmd: string) => spawnSync(cmd, ["--version"], { stdio: "ignore" }).status === 0;
31
+
32
+ /** kf setup lyrics — uv 가 있으면 uv 로(빠르고 파이썬 3.12 를 스스로 받는다), 없으면 python3.12·3.11 venv + pip */
33
+ export function setupLyrics(): boolean {
34
+ const dir = venv();
35
+ const step = (cmd: string, args: string[]) => {
36
+ console.log(`\n가사 정렬: ${cmd} ${args.join(" ")}`);
37
+ return spawnSync(cmd, args, { stdio: "inherit" }).status === 0;
38
+ };
39
+ if (which("uv")) {
40
+ return (existsSync(venvPython(dir)) || step("uv", ["venv", "--python", "3.12", dir])) && step("uv", ["pip", "install", "--python", venvPython(dir), "-r", requirements]);
41
+ }
42
+ const py = ["python3.12", "python3.11"].find(which);
43
+ if (!py) {
44
+ console.error("가사 정렬: python3.12(또는 3.11)이 없다 — torch 가 3.13 이하에서 선다. uv 를 깔면(https://docs.astral.sh/uv) 파이썬까지 알아서 받는다");
45
+ return false;
46
+ }
47
+ return (existsSync(venvPython(dir)) || step(py, ["-m", "venv", dir])) && step(venvPython(dir), ["-m", "pip", "install", "-r", requirements]);
48
+ }
49
+
50
+ function writeLrc(json: string, lrcPath: string): void {
51
+ const lyrics = parseLyrics(JSON.parse(readFileSync(json, "utf8")));
52
+ writeFileSync(lrcPath, toLrc(lyrics));
53
+ }
54
+
55
+ const cmd: Command = {
56
+ summary: "가사 — 공식 가사에 줄·어절 시각을 붙여 lyrics.json + LRC (보컬 분리 + whisper 강제 정렬)",
57
+ usage: `kf lyrics align <곡> --text 공식가사.txt [--lang ko|ja] [--out lyrics.json] [--from 초 --duration 초] [--model large-v3-turbo] [--vocals]
58
+ kf lyrics lrc <lyrics.json> [--out x.lrc]
59
+
60
+ align 글자는 공식 가사(한 줄 = 가사 한 줄)가 정본이고 시각만 붙인다. 곡의 일부만 쓰면 --from·--duration(시각은 --from 을 0 으로 —
61
+ beats.json 과 같다). 보컬만 있는 소리면 --vocals(분리를 건너뛴다). 옆에 같은 이름 .lrc 도 쓴다(2.5초 넘는 빈 자리는 [間奏]).
62
+ MMS 강제 정렬은 가중치가 비상업(CC-BY-NC)이라 쓰지 않는다. 깔기: kf setup lyrics (KF_LYRICS_PYTHON 으로 바꿀 수 있다)
63
+ 모델·장치: --model(기본 large-v3-turbo) · WHISPER_DEVICE(기본 cpu — mps 는 정렬에서 깨질 때가 있다)
64
+ lrc lyrics.json → LRC(JIZURA·노래방 형식)`,
65
+ async run(argv) {
66
+ const { args, opts } = parseFlags(argv);
67
+ const [sub, input] = args;
68
+ if (sub === "lrc") {
69
+ if (!input || !existsSync(input)) {
70
+ console.error("kf lyrics lrc: lyrics.json 경로가 필요하다");
71
+ return 2;
72
+ }
73
+ const out = typeof opts.out === "string" ? opts.out : input.replace(/\.json$/, "") + ".lrc";
74
+ writeLrc(input, out);
75
+ console.log(out);
76
+ return 0;
77
+ }
78
+ if (sub !== "align") {
79
+ console.error("kf lyrics: align 또는 lrc. kf lyrics --help");
80
+ return 2;
81
+ }
82
+ if (!input || !existsSync(input)) {
83
+ console.error(`kf lyrics align: 곡이 없다: ${input ?? "(안 줌)"}`);
84
+ return 2;
85
+ }
86
+ if (typeof opts.text !== "string" || !existsSync(opts.text)) {
87
+ console.error("kf lyrics align: --text 공식가사.txt 가 필요하다(한 줄 = 가사 한 줄)");
88
+ return 2;
89
+ }
90
+ const lang = typeof opts.lang === "string" ? opts.lang : "ko";
91
+ const out = resolve(typeof opts.out === "string" ? opts.out : "lyrics.json");
92
+ const check = lyricsCheck();
93
+ if (!check.ok) {
94
+ console.error(`kf lyrics align: ${check.detail}\n → ${check.fix}`);
95
+ return 1;
96
+ }
97
+ const pyArgs = [script, "--audio", resolve(input), "--text", resolve(opts.text), "--lang", lang, "--out", out];
98
+ if (opts.from !== undefined) pyArgs.push("--from", String(num(opts.from, 0)));
99
+ if (opts.duration !== undefined) pyArgs.push("--duration", String(num(opts.duration, 0)));
100
+ if (typeof opts.model === "string") pyArgs.push("--model", opts.model);
101
+ if (opts.vocals) pyArgs.push("--no-separate");
102
+ const r = spawnSync(python(), pyArgs, { stdio: "inherit", cwd: dirname(out) });
103
+ if (r.status !== 0) return r.status ?? 1;
104
+ const lrc = out.replace(/\.json$/, "") + ".lrc";
105
+ writeLrc(out, lrc);
106
+ console.log(out);
107
+ console.log(lrc);
108
+ return 0;
109
+ },
110
+ };
111
+ export default cmd;