@vibeframe/cli 0.27.0
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.
- package/.turbo/turbo-build.log +4 -0
- package/.turbo/turbo-lint.log +21 -0
- package/.turbo/turbo-test.log +689 -0
- package/dist/agent/adapters/claude.d.ts +15 -0
- package/dist/agent/adapters/claude.d.ts.map +1 -0
- package/dist/agent/adapters/claude.js +119 -0
- package/dist/agent/adapters/claude.js.map +1 -0
- package/dist/agent/adapters/gemini.d.ts +15 -0
- package/dist/agent/adapters/gemini.d.ts.map +1 -0
- package/dist/agent/adapters/gemini.js +132 -0
- package/dist/agent/adapters/gemini.js.map +1 -0
- package/dist/agent/adapters/index.d.ts +27 -0
- package/dist/agent/adapters/index.d.ts.map +1 -0
- package/dist/agent/adapters/index.js +38 -0
- package/dist/agent/adapters/index.js.map +1 -0
- package/dist/agent/adapters/ollama.d.ts +20 -0
- package/dist/agent/adapters/ollama.d.ts.map +1 -0
- package/dist/agent/adapters/ollama.js +186 -0
- package/dist/agent/adapters/ollama.js.map +1 -0
- package/dist/agent/adapters/openai.d.ts +15 -0
- package/dist/agent/adapters/openai.d.ts.map +1 -0
- package/dist/agent/adapters/openai.js +92 -0
- package/dist/agent/adapters/openai.js.map +1 -0
- package/dist/agent/adapters/xai.d.ts +15 -0
- package/dist/agent/adapters/xai.d.ts.map +1 -0
- package/dist/agent/adapters/xai.js +95 -0
- package/dist/agent/adapters/xai.js.map +1 -0
- package/dist/agent/index.d.ts +69 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +180 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/memory/index.d.ts +70 -0
- package/dist/agent/memory/index.d.ts.map +1 -0
- package/dist/agent/memory/index.js +132 -0
- package/dist/agent/memory/index.js.map +1 -0
- package/dist/agent/prompts/system.d.ts +6 -0
- package/dist/agent/prompts/system.d.ts.map +1 -0
- package/dist/agent/prompts/system.js +103 -0
- package/dist/agent/prompts/system.js.map +1 -0
- package/dist/agent/tools/ai-editing.d.ts +15 -0
- package/dist/agent/tools/ai-editing.d.ts.map +1 -0
- package/dist/agent/tools/ai-editing.js +763 -0
- package/dist/agent/tools/ai-editing.js.map +1 -0
- package/dist/agent/tools/ai-generation.d.ts +13 -0
- package/dist/agent/tools/ai-generation.d.ts.map +1 -0
- package/dist/agent/tools/ai-generation.js +973 -0
- package/dist/agent/tools/ai-generation.js.map +1 -0
- package/dist/agent/tools/ai-pipeline.d.ts +14 -0
- package/dist/agent/tools/ai-pipeline.d.ts.map +1 -0
- package/dist/agent/tools/ai-pipeline.js +961 -0
- package/dist/agent/tools/ai-pipeline.js.map +1 -0
- package/dist/agent/tools/ai.d.ts +13 -0
- package/dist/agent/tools/ai.d.ts.map +1 -0
- package/dist/agent/tools/ai.js +19 -0
- package/dist/agent/tools/ai.js.map +1 -0
- package/dist/agent/tools/batch.d.ts +6 -0
- package/dist/agent/tools/batch.d.ts.map +1 -0
- package/dist/agent/tools/batch.js +383 -0
- package/dist/agent/tools/batch.js.map +1 -0
- package/dist/agent/tools/e2e.test.d.ts +26 -0
- package/dist/agent/tools/e2e.test.d.ts.map +1 -0
- package/dist/agent/tools/e2e.test.js +397 -0
- package/dist/agent/tools/e2e.test.js.map +1 -0
- package/dist/agent/tools/export.d.ts +6 -0
- package/dist/agent/tools/export.d.ts.map +1 -0
- package/dist/agent/tools/export.js +171 -0
- package/dist/agent/tools/export.js.map +1 -0
- package/dist/agent/tools/filesystem.d.ts +6 -0
- package/dist/agent/tools/filesystem.d.ts.map +1 -0
- package/dist/agent/tools/filesystem.js +212 -0
- package/dist/agent/tools/filesystem.js.map +1 -0
- package/dist/agent/tools/index.d.ts +65 -0
- package/dist/agent/tools/index.d.ts.map +1 -0
- package/dist/agent/tools/index.js +120 -0
- package/dist/agent/tools/index.js.map +1 -0
- package/dist/agent/tools/integration.test.d.ts +11 -0
- package/dist/agent/tools/integration.test.d.ts.map +1 -0
- package/dist/agent/tools/integration.test.js +659 -0
- package/dist/agent/tools/integration.test.js.map +1 -0
- package/dist/agent/tools/media.d.ts +6 -0
- package/dist/agent/tools/media.d.ts.map +1 -0
- package/dist/agent/tools/media.js +616 -0
- package/dist/agent/tools/media.js.map +1 -0
- package/dist/agent/tools/project.d.ts +6 -0
- package/dist/agent/tools/project.d.ts.map +1 -0
- package/dist/agent/tools/project.js +284 -0
- package/dist/agent/tools/project.js.map +1 -0
- package/dist/agent/tools/timeline.d.ts +6 -0
- package/dist/agent/tools/timeline.d.ts.map +1 -0
- package/dist/agent/tools/timeline.js +873 -0
- package/dist/agent/tools/timeline.js.map +1 -0
- package/dist/agent/types.d.ts +59 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +5 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/commands/agent.d.ts +21 -0
- package/dist/commands/agent.d.ts.map +1 -0
- package/dist/commands/agent.js +290 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/ai-analyze.d.ts +106 -0
- package/dist/commands/ai-analyze.d.ts.map +1 -0
- package/dist/commands/ai-analyze.js +327 -0
- package/dist/commands/ai-analyze.js.map +1 -0
- package/dist/commands/ai-animated-caption.d.ts +64 -0
- package/dist/commands/ai-animated-caption.d.ts.map +1 -0
- package/dist/commands/ai-animated-caption.js +272 -0
- package/dist/commands/ai-animated-caption.js.map +1 -0
- package/dist/commands/ai-audio.d.ts +20 -0
- package/dist/commands/ai-audio.d.ts.map +1 -0
- package/dist/commands/ai-audio.js +808 -0
- package/dist/commands/ai-audio.js.map +1 -0
- package/dist/commands/ai-broll.d.ts +15 -0
- package/dist/commands/ai-broll.d.ts.map +1 -0
- package/dist/commands/ai-broll.js +406 -0
- package/dist/commands/ai-broll.js.map +1 -0
- package/dist/commands/ai-edit-cli.d.ts +14 -0
- package/dist/commands/ai-edit-cli.d.ts.map +1 -0
- package/dist/commands/ai-edit-cli.js +579 -0
- package/dist/commands/ai-edit-cli.js.map +1 -0
- package/dist/commands/ai-edit.d.ts +398 -0
- package/dist/commands/ai-edit.d.ts.map +1 -0
- package/dist/commands/ai-edit.js +1019 -0
- package/dist/commands/ai-edit.js.map +1 -0
- package/dist/commands/ai-fill-gaps.d.ts +14 -0
- package/dist/commands/ai-fill-gaps.d.ts.map +1 -0
- package/dist/commands/ai-fill-gaps.js +451 -0
- package/dist/commands/ai-fill-gaps.js.map +1 -0
- package/dist/commands/ai-helpers.d.ts +20 -0
- package/dist/commands/ai-helpers.d.ts.map +1 -0
- package/dist/commands/ai-helpers.js +59 -0
- package/dist/commands/ai-helpers.js.map +1 -0
- package/dist/commands/ai-highlights.d.ts +127 -0
- package/dist/commands/ai-highlights.d.ts.map +1 -0
- package/dist/commands/ai-highlights.js +1026 -0
- package/dist/commands/ai-highlights.js.map +1 -0
- package/dist/commands/ai-image.d.ts +34 -0
- package/dist/commands/ai-image.d.ts.map +1 -0
- package/dist/commands/ai-image.js +653 -0
- package/dist/commands/ai-image.js.map +1 -0
- package/dist/commands/ai-motion.d.ts +50 -0
- package/dist/commands/ai-motion.d.ts.map +1 -0
- package/dist/commands/ai-motion.js +271 -0
- package/dist/commands/ai-motion.js.map +1 -0
- package/dist/commands/ai-narrate.d.ts +66 -0
- package/dist/commands/ai-narrate.d.ts.map +1 -0
- package/dist/commands/ai-narrate.js +329 -0
- package/dist/commands/ai-narrate.js.map +1 -0
- package/dist/commands/ai-review.d.ts +57 -0
- package/dist/commands/ai-review.d.ts.map +1 -0
- package/dist/commands/ai-review.js +251 -0
- package/dist/commands/ai-review.js.map +1 -0
- package/dist/commands/ai-script-pipeline-cli.d.ts +9 -0
- package/dist/commands/ai-script-pipeline-cli.d.ts.map +1 -0
- package/dist/commands/ai-script-pipeline-cli.js +1494 -0
- package/dist/commands/ai-script-pipeline-cli.js.map +1 -0
- package/dist/commands/ai-script-pipeline.d.ts +259 -0
- package/dist/commands/ai-script-pipeline.d.ts.map +1 -0
- package/dist/commands/ai-script-pipeline.js +1027 -0
- package/dist/commands/ai-script-pipeline.js.map +1 -0
- package/dist/commands/ai-suggest-edit.d.ts +14 -0
- package/dist/commands/ai-suggest-edit.d.ts.map +1 -0
- package/dist/commands/ai-suggest-edit.js +220 -0
- package/dist/commands/ai-suggest-edit.js.map +1 -0
- package/dist/commands/ai-video-fx.d.ts +14 -0
- package/dist/commands/ai-video-fx.d.ts.map +1 -0
- package/dist/commands/ai-video-fx.js +395 -0
- package/dist/commands/ai-video-fx.js.map +1 -0
- package/dist/commands/ai-video.d.ts +15 -0
- package/dist/commands/ai-video.d.ts.map +1 -0
- package/dist/commands/ai-video.js +785 -0
- package/dist/commands/ai-video.js.map +1 -0
- package/dist/commands/ai-viral.d.ts +15 -0
- package/dist/commands/ai-viral.d.ts.map +1 -0
- package/dist/commands/ai-viral.js +519 -0
- package/dist/commands/ai-viral.js.map +1 -0
- package/dist/commands/ai-visual-fx.d.ts +14 -0
- package/dist/commands/ai-visual-fx.d.ts.map +1 -0
- package/dist/commands/ai-visual-fx.js +505 -0
- package/dist/commands/ai-visual-fx.js.map +1 -0
- package/dist/commands/ai.d.ts +38 -0
- package/dist/commands/ai.d.ts.map +1 -0
- package/dist/commands/ai.js +225 -0
- package/dist/commands/ai.js.map +1 -0
- package/dist/commands/ai.test.d.ts +2 -0
- package/dist/commands/ai.test.d.ts.map +1 -0
- package/dist/commands/ai.test.js +554 -0
- package/dist/commands/ai.test.js.map +1 -0
- package/dist/commands/analyze.d.ts +16 -0
- package/dist/commands/analyze.d.ts.map +1 -0
- package/dist/commands/analyze.js +247 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/audio.d.ts +18 -0
- package/dist/commands/audio.d.ts.map +1 -0
- package/dist/commands/audio.js +539 -0
- package/dist/commands/audio.js.map +1 -0
- package/dist/commands/batch.d.ts +3 -0
- package/dist/commands/batch.d.ts.map +1 -0
- package/dist/commands/batch.js +366 -0
- package/dist/commands/batch.js.map +1 -0
- package/dist/commands/batch.test.d.ts +2 -0
- package/dist/commands/batch.test.d.ts.map +1 -0
- package/dist/commands/batch.test.js +203 -0
- package/dist/commands/batch.test.js.map +1 -0
- package/dist/commands/detect.d.ts +3 -0
- package/dist/commands/detect.d.ts.map +1 -0
- package/dist/commands/detect.js +273 -0
- package/dist/commands/detect.js.map +1 -0
- package/dist/commands/doctor.d.ts +6 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +191 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/edit-cmd.d.ts +26 -0
- package/dist/commands/edit-cmd.d.ts.map +1 -0
- package/dist/commands/edit-cmd.js +870 -0
- package/dist/commands/edit-cmd.js.map +1 -0
- package/dist/commands/export.d.ts +39 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +730 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/generate.d.ts +25 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +1885 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/media.d.ts +3 -0
- package/dist/commands/media.d.ts.map +1 -0
- package/dist/commands/media.js +165 -0
- package/dist/commands/media.js.map +1 -0
- package/dist/commands/output.d.ts +45 -0
- package/dist/commands/output.d.ts.map +1 -0
- package/dist/commands/output.js +122 -0
- package/dist/commands/output.js.map +1 -0
- package/dist/commands/pipeline.d.ts +19 -0
- package/dist/commands/pipeline.d.ts.map +1 -0
- package/dist/commands/pipeline.js +345 -0
- package/dist/commands/pipeline.js.map +1 -0
- package/dist/commands/project.d.ts +3 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +139 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/commands/project.test.d.ts +2 -0
- package/dist/commands/project.test.d.ts.map +1 -0
- package/dist/commands/project.test.js +105 -0
- package/dist/commands/project.test.js.map +1 -0
- package/dist/commands/sanitize.d.ts +21 -0
- package/dist/commands/sanitize.d.ts.map +1 -0
- package/dist/commands/sanitize.js +56 -0
- package/dist/commands/sanitize.js.map +1 -0
- package/dist/commands/schema.d.ts +11 -0
- package/dist/commands/schema.d.ts.map +1 -0
- package/dist/commands/schema.js +101 -0
- package/dist/commands/schema.js.map +1 -0
- package/dist/commands/setup.d.ts +6 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +440 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/timeline.d.ts +3 -0
- package/dist/commands/timeline.d.ts.map +1 -0
- package/dist/commands/timeline.js +469 -0
- package/dist/commands/timeline.js.map +1 -0
- package/dist/commands/timeline.test.d.ts +2 -0
- package/dist/commands/timeline.test.d.ts.map +1 -0
- package/dist/commands/timeline.test.js +320 -0
- package/dist/commands/timeline.test.js.map +1 -0
- package/dist/commands/validate.d.ts +32 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +63 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/config/config.test.d.ts +2 -0
- package/dist/config/config.test.d.ts.map +1 -0
- package/dist/config/config.test.js +164 -0
- package/dist/config/config.test.js.map +1 -0
- package/dist/config/index.d.ts +35 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +101 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/schema.d.ts +43 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +42 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/engine/index.d.ts +3 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +2 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/project.d.ts +84 -0
- package/dist/engine/project.d.ts.map +1 -0
- package/dist/engine/project.js +355 -0
- package/dist/engine/project.js.map +1 -0
- package/dist/engine/project.test.d.ts +2 -0
- package/dist/engine/project.test.d.ts.map +1 -0
- package/dist/engine/project.test.js +599 -0
- package/dist/engine/project.test.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/api-key.d.ts +36 -0
- package/dist/utils/api-key.d.ts.map +1 -0
- package/dist/utils/api-key.js +211 -0
- package/dist/utils/api-key.js.map +1 -0
- package/dist/utils/api-key.test.d.ts +2 -0
- package/dist/utils/api-key.test.d.ts.map +1 -0
- package/dist/utils/api-key.test.js +35 -0
- package/dist/utils/api-key.test.js.map +1 -0
- package/dist/utils/audio.d.ts +23 -0
- package/dist/utils/audio.d.ts.map +1 -0
- package/dist/utils/audio.js +79 -0
- package/dist/utils/audio.js.map +1 -0
- package/dist/utils/exec-safe.d.ts +22 -0
- package/dist/utils/exec-safe.d.ts.map +1 -0
- package/dist/utils/exec-safe.js +62 -0
- package/dist/utils/exec-safe.js.map +1 -0
- package/dist/utils/first-run.d.ts +13 -0
- package/dist/utils/first-run.d.ts.map +1 -0
- package/dist/utils/first-run.js +48 -0
- package/dist/utils/first-run.js.map +1 -0
- package/dist/utils/provider-resolver.d.ts +15 -0
- package/dist/utils/provider-resolver.d.ts.map +1 -0
- package/dist/utils/provider-resolver.js +42 -0
- package/dist/utils/provider-resolver.js.map +1 -0
- package/dist/utils/remotion.d.ts +210 -0
- package/dist/utils/remotion.d.ts.map +1 -0
- package/dist/utils/remotion.js +731 -0
- package/dist/utils/remotion.js.map +1 -0
- package/dist/utils/subtitle.d.ts +65 -0
- package/dist/utils/subtitle.d.ts.map +1 -0
- package/dist/utils/subtitle.js +135 -0
- package/dist/utils/subtitle.js.map +1 -0
- package/dist/utils/subtitle.test.d.ts +2 -0
- package/dist/utils/subtitle.test.d.ts.map +1 -0
- package/dist/utils/subtitle.test.js +175 -0
- package/dist/utils/subtitle.test.js.map +1 -0
- package/dist/utils/tty.d.ts +45 -0
- package/dist/utils/tty.d.ts.map +1 -0
- package/dist/utils/tty.js +172 -0
- package/dist/utils/tty.js.map +1 -0
- package/package.json +102 -0
- package/src/agent/adapters/claude.ts +143 -0
- package/src/agent/adapters/gemini.ts +159 -0
- package/src/agent/adapters/index.ts +61 -0
- package/src/agent/adapters/ollama.ts +231 -0
- package/src/agent/adapters/openai.ts +116 -0
- package/src/agent/adapters/xai.ts +119 -0
- package/src/agent/index.ts +251 -0
- package/src/agent/memory/index.ts +151 -0
- package/src/agent/prompts/system.ts +106 -0
- package/src/agent/tools/ai-editing.ts +845 -0
- package/src/agent/tools/ai-generation.ts +1073 -0
- package/src/agent/tools/ai-pipeline.ts +1055 -0
- package/src/agent/tools/ai.ts +21 -0
- package/src/agent/tools/batch.ts +429 -0
- package/src/agent/tools/e2e.test.ts +545 -0
- package/src/agent/tools/export.ts +184 -0
- package/src/agent/tools/filesystem.ts +237 -0
- package/src/agent/tools/index.ts +150 -0
- package/src/agent/tools/integration.test.ts +775 -0
- package/src/agent/tools/media.ts +697 -0
- package/src/agent/tools/project.ts +313 -0
- package/src/agent/tools/timeline.ts +951 -0
- package/src/agent/types.ts +68 -0
- package/src/commands/agent.ts +340 -0
- package/src/commands/ai-analyze.ts +429 -0
- package/src/commands/ai-animated-caption.ts +390 -0
- package/src/commands/ai-audio.ts +941 -0
- package/src/commands/ai-broll.ts +490 -0
- package/src/commands/ai-edit-cli.ts +658 -0
- package/src/commands/ai-edit.ts +1542 -0
- package/src/commands/ai-fill-gaps.ts +566 -0
- package/src/commands/ai-helpers.ts +65 -0
- package/src/commands/ai-highlights.ts +1303 -0
- package/src/commands/ai-image.ts +761 -0
- package/src/commands/ai-motion.ts +347 -0
- package/src/commands/ai-narrate.ts +451 -0
- package/src/commands/ai-review.ts +309 -0
- package/src/commands/ai-script-pipeline-cli.ts +1710 -0
- package/src/commands/ai-script-pipeline.ts +1365 -0
- package/src/commands/ai-suggest-edit.ts +264 -0
- package/src/commands/ai-video-fx.ts +445 -0
- package/src/commands/ai-video.ts +915 -0
- package/src/commands/ai-viral.ts +595 -0
- package/src/commands/ai-visual-fx.ts +601 -0
- package/src/commands/ai.test.ts +627 -0
- package/src/commands/ai.ts +307 -0
- package/src/commands/analyze.ts +282 -0
- package/src/commands/audio.ts +644 -0
- package/src/commands/batch.test.ts +279 -0
- package/src/commands/batch.ts +440 -0
- package/src/commands/detect.ts +329 -0
- package/src/commands/doctor.ts +237 -0
- package/src/commands/edit-cmd.ts +1014 -0
- package/src/commands/export.ts +918 -0
- package/src/commands/generate.ts +2146 -0
- package/src/commands/media.ts +177 -0
- package/src/commands/output.ts +142 -0
- package/src/commands/pipeline.ts +398 -0
- package/src/commands/project.test.ts +127 -0
- package/src/commands/project.ts +149 -0
- package/src/commands/sanitize.ts +60 -0
- package/src/commands/schema.ts +130 -0
- package/src/commands/setup.ts +509 -0
- package/src/commands/timeline.test.ts +499 -0
- package/src/commands/timeline.ts +529 -0
- package/src/commands/validate.ts +77 -0
- package/src/config/config.test.ts +197 -0
- package/src/config/index.ts +125 -0
- package/src/config/schema.ts +82 -0
- package/src/engine/index.ts +2 -0
- package/src/engine/project.test.ts +702 -0
- package/src/engine/project.ts +439 -0
- package/src/index.ts +146 -0
- package/src/utils/api-key.test.ts +41 -0
- package/src/utils/api-key.ts +247 -0
- package/src/utils/audio.ts +83 -0
- package/src/utils/exec-safe.ts +75 -0
- package/src/utils/first-run.ts +52 -0
- package/src/utils/provider-resolver.ts +56 -0
- package/src/utils/remotion.ts +951 -0
- package/src/utils/subtitle.test.ts +227 -0
- package/src/utils/subtitle.ts +169 -0
- package/src/utils/tty.ts +196 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ai-narrate
|
|
3
|
+
*
|
|
4
|
+
* Auto-narration pipeline and provider listing.
|
|
5
|
+
*
|
|
6
|
+
* CLI commands: narrate, providers
|
|
7
|
+
*
|
|
8
|
+
* Execute function:
|
|
9
|
+
* autoNarrate - Analyze video -> generate script -> TTS voiceover
|
|
10
|
+
*
|
|
11
|
+
* Extracted from ai.ts as part of modularisation.
|
|
12
|
+
* ai.ts calls registerNarrateCommands(aiCommand).
|
|
13
|
+
*
|
|
14
|
+
* @dependencies Gemini (video analysis), Claude/OpenAI (script generation),
|
|
15
|
+
* ElevenLabs (TTS), FFmpeg (duration probe)
|
|
16
|
+
*/
|
|
17
|
+
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
18
|
+
import { resolve, dirname, basename } from "node:path";
|
|
19
|
+
import { existsSync } from "node:fs";
|
|
20
|
+
import chalk from "chalk";
|
|
21
|
+
import ora from "ora";
|
|
22
|
+
import { providerRegistry, whisperProvider, geminiProvider, openaiProvider, claudeProvider, elevenLabsProvider, openaiImageProvider, runwayProvider, klingProvider, replicateProvider, GeminiProvider, OpenAIProvider, ClaudeProvider, ElevenLabsProvider, } from "@vibeframe/ai-providers";
|
|
23
|
+
import { Project } from "../engine/index.js";
|
|
24
|
+
import { getApiKey } from "../utils/api-key.js";
|
|
25
|
+
import { ffprobeDuration } from "../utils/exec-safe.js";
|
|
26
|
+
import { getAudioDuration } from "../utils/audio.js";
|
|
27
|
+
import { formatTime } from "./ai-helpers.js";
|
|
28
|
+
/**
|
|
29
|
+
* Generate narration for a video that doesn't have one.
|
|
30
|
+
*
|
|
31
|
+
* Pipeline:
|
|
32
|
+
* 1. Analyze video with Gemini Video Understanding
|
|
33
|
+
* 2. Generate narration script with Claude (fallback to OpenAI on 529)
|
|
34
|
+
* 3. Convert to speech with ElevenLabs TTS
|
|
35
|
+
*
|
|
36
|
+
* Saves both the audio file and script text to the output directory.
|
|
37
|
+
*
|
|
38
|
+
* @param options - Auto-narrate configuration
|
|
39
|
+
* @returns Result with audio path, script text, and timed segments
|
|
40
|
+
*/
|
|
41
|
+
export async function autoNarrate(options) {
|
|
42
|
+
const { videoPath, duration, outputDir, voice = "rachel", style = "informative", language = "en", scriptProvider = "claude", } = options;
|
|
43
|
+
// Validate API keys
|
|
44
|
+
const geminiApiKey = await getApiKey("GOOGLE_API_KEY", "Google");
|
|
45
|
+
if (!geminiApiKey) {
|
|
46
|
+
return { success: false, error: "GOOGLE_API_KEY required for video analysis. Run 'vibe setup' or set GOOGLE_API_KEY in .env" };
|
|
47
|
+
}
|
|
48
|
+
let claudeApiKey = null;
|
|
49
|
+
let openaiScriptApiKey = null;
|
|
50
|
+
if (scriptProvider === "openai") {
|
|
51
|
+
openaiScriptApiKey = await getApiKey("OPENAI_API_KEY", "OpenAI");
|
|
52
|
+
if (!openaiScriptApiKey) {
|
|
53
|
+
return { success: false, error: "OPENAI_API_KEY required for script generation. Run 'vibe setup' or set OPENAI_API_KEY in .env" };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
claudeApiKey = await getApiKey("ANTHROPIC_API_KEY", "Anthropic");
|
|
58
|
+
if (!claudeApiKey) {
|
|
59
|
+
return { success: false, error: "ANTHROPIC_API_KEY required for script generation. Run 'vibe setup' or set ANTHROPIC_API_KEY in .env" };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const elevenlabsApiKey = await getApiKey("ELEVENLABS_API_KEY", "ElevenLabs");
|
|
63
|
+
if (!elevenlabsApiKey) {
|
|
64
|
+
return { success: false, error: "ELEVENLABS_API_KEY required for TTS. Run 'vibe setup' or set ELEVENLABS_API_KEY in .env" };
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
// Step 1: Analyze video with Gemini
|
|
68
|
+
const gemini = new GeminiProvider();
|
|
69
|
+
await gemini.initialize({ apiKey: geminiApiKey });
|
|
70
|
+
const videoBuffer = await readFile(videoPath);
|
|
71
|
+
const analysisPrompt = `Analyze this video in detail for narration purposes. Describe:
|
|
72
|
+
1. What is happening visually (actions, movements, subjects)
|
|
73
|
+
2. The setting and environment
|
|
74
|
+
3. Any text or graphics visible
|
|
75
|
+
4. The mood and tone of the content
|
|
76
|
+
5. Key moments and their approximate timestamps
|
|
77
|
+
|
|
78
|
+
Provide a detailed description that could be used to write a voiceover narration.
|
|
79
|
+
Focus on what viewers need to know to understand and appreciate the video.`;
|
|
80
|
+
const analysisResult = await gemini.analyzeVideo(videoBuffer, analysisPrompt, {
|
|
81
|
+
fps: 0.5, // Lower FPS for cost optimization
|
|
82
|
+
lowResolution: duration > 60, // Use low res for longer videos
|
|
83
|
+
});
|
|
84
|
+
if (!analysisResult.success || !analysisResult.response) {
|
|
85
|
+
return { success: false, error: `Video analysis failed: ${analysisResult.error}` };
|
|
86
|
+
}
|
|
87
|
+
// Step 2: Generate narration script with Claude or OpenAI
|
|
88
|
+
let scriptResult;
|
|
89
|
+
if (scriptProvider === "openai") {
|
|
90
|
+
const gpt = new OpenAIProvider();
|
|
91
|
+
await gpt.initialize({ apiKey: openaiScriptApiKey });
|
|
92
|
+
scriptResult = await gpt.generateNarrationScript(analysisResult.response, duration, style, language);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
const claude = new ClaudeProvider();
|
|
96
|
+
await claude.initialize({ apiKey: claudeApiKey });
|
|
97
|
+
scriptResult = await claude.generateNarrationScript(analysisResult.response, duration, style, language);
|
|
98
|
+
// Auto-fallback to OpenAI on Claude overload (529)
|
|
99
|
+
if (!scriptResult.success && scriptResult.error?.includes("529")) {
|
|
100
|
+
const fallbackKey = await getApiKey("OPENAI_API_KEY", "OpenAI");
|
|
101
|
+
if (fallbackKey) {
|
|
102
|
+
console.error("⚠️ Claude overloaded, falling back to OpenAI...");
|
|
103
|
+
const gpt = new OpenAIProvider();
|
|
104
|
+
await gpt.initialize({ apiKey: fallbackKey });
|
|
105
|
+
scriptResult = await gpt.generateNarrationScript(analysisResult.response, duration, style, language);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (!scriptResult.success || !scriptResult.script) {
|
|
110
|
+
return { success: false, error: `Script generation failed: ${scriptResult.error}` };
|
|
111
|
+
}
|
|
112
|
+
// Step 3: Convert to speech with ElevenLabs
|
|
113
|
+
const elevenlabs = new ElevenLabsProvider();
|
|
114
|
+
await elevenlabs.initialize({ apiKey: elevenlabsApiKey });
|
|
115
|
+
const ttsResult = await elevenlabs.textToSpeech(scriptResult.script, {
|
|
116
|
+
voiceId: voice,
|
|
117
|
+
});
|
|
118
|
+
if (!ttsResult.success || !ttsResult.audioBuffer) {
|
|
119
|
+
return { success: false, error: `TTS generation failed: ${ttsResult.error}` };
|
|
120
|
+
}
|
|
121
|
+
// Ensure output directory exists
|
|
122
|
+
if (!existsSync(outputDir)) {
|
|
123
|
+
await mkdir(outputDir, { recursive: true });
|
|
124
|
+
}
|
|
125
|
+
// Save audio file
|
|
126
|
+
const audioPath = resolve(outputDir, "auto-narration.mp3");
|
|
127
|
+
await writeFile(audioPath, ttsResult.audioBuffer);
|
|
128
|
+
// Save script for reference
|
|
129
|
+
const scriptPath = resolve(outputDir, "narration-script.txt");
|
|
130
|
+
await writeFile(scriptPath, scriptResult.script, "utf-8");
|
|
131
|
+
return {
|
|
132
|
+
success: true,
|
|
133
|
+
audioPath,
|
|
134
|
+
script: scriptResult.script,
|
|
135
|
+
segments: scriptResult.segments,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
return {
|
|
140
|
+
success: false,
|
|
141
|
+
error: error instanceof Error ? error.message : "Unknown error in autoNarrate",
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// ==========================================
|
|
146
|
+
// CLI Command Registration
|
|
147
|
+
// ==========================================
|
|
148
|
+
export function registerNarrateCommands(ai) {
|
|
149
|
+
ai
|
|
150
|
+
.command("providers")
|
|
151
|
+
.description("List available AI providers")
|
|
152
|
+
.action(async () => {
|
|
153
|
+
// Register default providers
|
|
154
|
+
providerRegistry.register(whisperProvider);
|
|
155
|
+
providerRegistry.register(geminiProvider);
|
|
156
|
+
providerRegistry.register(openaiProvider);
|
|
157
|
+
providerRegistry.register(claudeProvider);
|
|
158
|
+
providerRegistry.register(elevenLabsProvider);
|
|
159
|
+
providerRegistry.register(openaiImageProvider);
|
|
160
|
+
providerRegistry.register(runwayProvider);
|
|
161
|
+
providerRegistry.register(klingProvider);
|
|
162
|
+
providerRegistry.register(replicateProvider);
|
|
163
|
+
console.log();
|
|
164
|
+
console.log(chalk.bold.cyan("Available AI Providers"));
|
|
165
|
+
console.log(chalk.dim("─".repeat(60)));
|
|
166
|
+
const providers = providerRegistry.getAll();
|
|
167
|
+
for (const provider of providers) {
|
|
168
|
+
const status = provider.isAvailable ? chalk.green("●") : chalk.red("○");
|
|
169
|
+
console.log();
|
|
170
|
+
console.log(`${status} ${chalk.bold(provider.name)} ${chalk.dim(`(${provider.id})`)}`);
|
|
171
|
+
console.log(` ${provider.description}`);
|
|
172
|
+
console.log(` ${chalk.dim("Capabilities:")} ${provider.capabilities.join(", ")}`);
|
|
173
|
+
}
|
|
174
|
+
console.log();
|
|
175
|
+
});
|
|
176
|
+
// Auto-Narrate command
|
|
177
|
+
ai
|
|
178
|
+
.command("narrate")
|
|
179
|
+
.description("Generate AI narration for a video file or project")
|
|
180
|
+
.argument("<input>", "Video file or project file (.vibe.json)")
|
|
181
|
+
.option("-o, --output <dir>", "Output directory for generated files", ".")
|
|
182
|
+
.option("-v, --voice <name>", "ElevenLabs voice name (rachel, adam, josh, etc.)", "rachel")
|
|
183
|
+
.option("-s, --style <style>", "Narration style: informative, energetic, calm, dramatic", "informative")
|
|
184
|
+
.option("-l, --language <lang>", "Language code (e.g., en, ko)", "en")
|
|
185
|
+
.option("-p, --provider <name>", "LLM for script generation: claude (default), openai", "claude")
|
|
186
|
+
.option("--add-to-project", "Add narration to project (only for .vibe.json input)")
|
|
187
|
+
.action(async (inputPath, options) => {
|
|
188
|
+
try {
|
|
189
|
+
const absPath = resolve(process.cwd(), inputPath);
|
|
190
|
+
if (!existsSync(absPath)) {
|
|
191
|
+
console.error(chalk.red(`File not found: ${absPath}`));
|
|
192
|
+
process.exit(1);
|
|
193
|
+
}
|
|
194
|
+
console.log();
|
|
195
|
+
console.log(chalk.bold.cyan("🎙️ Auto-Narrate Pipeline"));
|
|
196
|
+
console.log(chalk.dim("─".repeat(60)));
|
|
197
|
+
console.log();
|
|
198
|
+
const isProject = inputPath.endsWith(".vibe.json");
|
|
199
|
+
let videoPath;
|
|
200
|
+
let project = null;
|
|
201
|
+
let outputDir = resolve(process.cwd(), options.output);
|
|
202
|
+
if (isProject) {
|
|
203
|
+
// Load project to find video source
|
|
204
|
+
const content = await readFile(absPath, "utf-8");
|
|
205
|
+
const data = JSON.parse(content);
|
|
206
|
+
project = Project.fromJSON(data);
|
|
207
|
+
const sources = project.getSources();
|
|
208
|
+
const videoSource = sources.find((s) => s.type === "video");
|
|
209
|
+
if (!videoSource) {
|
|
210
|
+
console.error(chalk.red("No video source found in project"));
|
|
211
|
+
process.exit(1);
|
|
212
|
+
}
|
|
213
|
+
videoPath = resolve(dirname(absPath), videoSource.url);
|
|
214
|
+
if (!existsSync(videoPath)) {
|
|
215
|
+
console.error(chalk.red(`Video file not found: ${videoPath}`));
|
|
216
|
+
process.exit(1);
|
|
217
|
+
}
|
|
218
|
+
// Use project directory as output if not specified
|
|
219
|
+
if (options.output === ".") {
|
|
220
|
+
outputDir = dirname(absPath);
|
|
221
|
+
}
|
|
222
|
+
console.log(`📁 Project: ${chalk.bold(project.getMeta().name)}`);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
videoPath = absPath;
|
|
226
|
+
console.log(`🎬 Video: ${chalk.bold(basename(videoPath))}`);
|
|
227
|
+
}
|
|
228
|
+
// Get video duration
|
|
229
|
+
const durationSpinner = ora("📊 Analyzing video...").start();
|
|
230
|
+
let duration;
|
|
231
|
+
try {
|
|
232
|
+
duration = await ffprobeDuration(videoPath);
|
|
233
|
+
durationSpinner.succeed(chalk.green(`Duration: ${formatTime(duration)}`));
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
durationSpinner.fail(chalk.red("Failed to get video duration"));
|
|
237
|
+
process.exit(1);
|
|
238
|
+
}
|
|
239
|
+
// Validate style option
|
|
240
|
+
const validStyles = ["informative", "energetic", "calm", "dramatic"];
|
|
241
|
+
if (!validStyles.includes(options.style)) {
|
|
242
|
+
console.error(chalk.red(`Invalid style: ${options.style}`));
|
|
243
|
+
console.error(chalk.dim(`Valid styles: ${validStyles.join(", ")}`));
|
|
244
|
+
process.exit(1);
|
|
245
|
+
}
|
|
246
|
+
// Generate narration
|
|
247
|
+
const generateSpinner = ora("🤖 Generating narration...").start();
|
|
248
|
+
generateSpinner.text = "📹 Analyzing video with Gemini...";
|
|
249
|
+
const result = await autoNarrate({
|
|
250
|
+
videoPath,
|
|
251
|
+
duration,
|
|
252
|
+
outputDir,
|
|
253
|
+
voice: options.voice,
|
|
254
|
+
style: options.style,
|
|
255
|
+
language: options.language,
|
|
256
|
+
scriptProvider: options.provider,
|
|
257
|
+
});
|
|
258
|
+
if (!result.success) {
|
|
259
|
+
generateSpinner.fail(chalk.red(`Failed: ${result.error}`));
|
|
260
|
+
process.exit(1);
|
|
261
|
+
}
|
|
262
|
+
generateSpinner.succeed(chalk.green("Narration generated successfully"));
|
|
263
|
+
// Display result
|
|
264
|
+
console.log();
|
|
265
|
+
console.log(chalk.bold.cyan("Generated Files"));
|
|
266
|
+
console.log(chalk.dim("─".repeat(60)));
|
|
267
|
+
console.log(` 🎵 Audio: ${chalk.green(result.audioPath)}`);
|
|
268
|
+
console.log(` 📝 Script: ${chalk.green(resolve(outputDir, "narration-script.txt"))}`);
|
|
269
|
+
if (result.segments && result.segments.length > 0) {
|
|
270
|
+
console.log();
|
|
271
|
+
console.log(chalk.bold.cyan("Narration Segments"));
|
|
272
|
+
console.log(chalk.dim("─".repeat(60)));
|
|
273
|
+
for (const seg of result.segments.slice(0, 5)) {
|
|
274
|
+
console.log(` [${formatTime(seg.startTime)} - ${formatTime(seg.endTime)}] ${chalk.dim(seg.text.substring(0, 50))}${seg.text.length > 50 ? "..." : ""}`);
|
|
275
|
+
}
|
|
276
|
+
if (result.segments.length > 5) {
|
|
277
|
+
console.log(chalk.dim(` ... and ${result.segments.length - 5} more segments`));
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// Add to project if requested
|
|
281
|
+
if (options.addToProject && project && isProject) {
|
|
282
|
+
const addSpinner = ora("Adding narration to project...").start();
|
|
283
|
+
// Get audio duration
|
|
284
|
+
let audioDuration;
|
|
285
|
+
try {
|
|
286
|
+
audioDuration = await getAudioDuration(result.audioPath);
|
|
287
|
+
}
|
|
288
|
+
catch {
|
|
289
|
+
audioDuration = duration; // Fallback to video duration
|
|
290
|
+
}
|
|
291
|
+
// Add audio source
|
|
292
|
+
const audioSource = project.addSource({
|
|
293
|
+
name: "Auto-generated narration",
|
|
294
|
+
url: basename(result.audioPath),
|
|
295
|
+
type: "audio",
|
|
296
|
+
duration: audioDuration,
|
|
297
|
+
});
|
|
298
|
+
// Add audio clip to audio track
|
|
299
|
+
const audioTrack = project.getTracks().find((t) => t.type === "audio");
|
|
300
|
+
if (audioTrack) {
|
|
301
|
+
project.addClip({
|
|
302
|
+
sourceId: audioSource.id,
|
|
303
|
+
trackId: audioTrack.id,
|
|
304
|
+
startTime: 0,
|
|
305
|
+
duration: Math.min(audioDuration, duration),
|
|
306
|
+
sourceStartOffset: 0,
|
|
307
|
+
sourceEndOffset: Math.min(audioDuration, duration),
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
// Save updated project
|
|
311
|
+
await writeFile(absPath, JSON.stringify(project.toJSON(), null, 2), "utf-8");
|
|
312
|
+
addSpinner.succeed(chalk.green("Narration added to project"));
|
|
313
|
+
}
|
|
314
|
+
console.log();
|
|
315
|
+
console.log(chalk.bold.green("✅ Auto-narrate complete!"));
|
|
316
|
+
if (!options.addToProject && isProject) {
|
|
317
|
+
console.log();
|
|
318
|
+
console.log(chalk.dim("Tip: Use --add-to-project to automatically add the narration to your project"));
|
|
319
|
+
}
|
|
320
|
+
console.log();
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
console.error(chalk.red("Auto-narrate failed"));
|
|
324
|
+
console.error(error);
|
|
325
|
+
process.exit(1);
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
} // end registerNarrateCommands
|
|
329
|
+
//# sourceMappingURL=ai-narrate.js.map
|
|
@@ -0,0 +1 @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C;IACH,CAAC,CAAC,CAAC;AAEL,CAAC,CAAC,8BAA8B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ai-review
|
|
3
|
+
*
|
|
4
|
+
* AI-powered video quality review and auto-fix using Gemini.
|
|
5
|
+
*
|
|
6
|
+
* CLI command: review
|
|
7
|
+
*
|
|
8
|
+
* Execute function:
|
|
9
|
+
* executeReview - Analyze video quality across 5 categories and optionally auto-fix
|
|
10
|
+
*
|
|
11
|
+
* @dependencies Gemini (Google), FFmpeg (auto-fix filters)
|
|
12
|
+
*/
|
|
13
|
+
import { Command } from "commander";
|
|
14
|
+
import type { VideoReviewFeedback } from "./ai-edit.js";
|
|
15
|
+
/** Options for {@link executeReview}. */
|
|
16
|
+
export interface ReviewOptions {
|
|
17
|
+
/** Path to the video file to review */
|
|
18
|
+
videoPath: string;
|
|
19
|
+
/** Optional storyboard JSON for context-aware review */
|
|
20
|
+
storyboardPath?: string;
|
|
21
|
+
/** Automatically apply fixable corrections via FFmpeg */
|
|
22
|
+
autoApply?: boolean;
|
|
23
|
+
/** Run a verification pass after applying fixes */
|
|
24
|
+
verify?: boolean;
|
|
25
|
+
/** Gemini model shorthand (default: "flash") */
|
|
26
|
+
model?: "flash" | "flash-2.5" | "pro";
|
|
27
|
+
/** Output path for the fixed video (auto-apply mode) */
|
|
28
|
+
outputPath?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Result from {@link executeReview}. */
|
|
31
|
+
export interface ReviewResult {
|
|
32
|
+
/** Whether the review completed successfully */
|
|
33
|
+
success: boolean;
|
|
34
|
+
/** Structured review feedback with per-category scores */
|
|
35
|
+
feedback?: VideoReviewFeedback;
|
|
36
|
+
/** Descriptions of fixes that were auto-applied */
|
|
37
|
+
appliedFixes?: string[];
|
|
38
|
+
/** Post-fix verification quality score 1-10 */
|
|
39
|
+
verificationScore?: number;
|
|
40
|
+
/** Path to the reviewed/fixed output video */
|
|
41
|
+
outputPath?: string;
|
|
42
|
+
/** Error message on failure */
|
|
43
|
+
error?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Review video quality using Gemini AI and optionally auto-fix issues.
|
|
47
|
+
*
|
|
48
|
+
* Analyzes 5 quality categories (pacing, color, text readability, audio-visual
|
|
49
|
+
* sync, composition) and returns scored feedback. When auto-apply is enabled,
|
|
50
|
+
* applies fixable corrections via FFmpeg filters.
|
|
51
|
+
*
|
|
52
|
+
* @param options - Review configuration
|
|
53
|
+
* @returns Result with structured feedback and optional fix details
|
|
54
|
+
*/
|
|
55
|
+
export declare function executeReview(options: ReviewOptions): Promise<ReviewResult>;
|
|
56
|
+
export declare function registerReviewCommand(aiCommand: Command): void;
|
|
57
|
+
//# sourceMappingURL=ai-review.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-review.d.ts","sourceRoot":"","sources":["../../src/commands/ai-review.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,yCAAyC;AACzC,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,KAAK,CAAC;IACtC,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,yCAAyC;AACzC,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,+CAA+C;IAC/C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAyBD;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAiIjF;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAwF9D"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module ai-review
|
|
3
|
+
*
|
|
4
|
+
* AI-powered video quality review and auto-fix using Gemini.
|
|
5
|
+
*
|
|
6
|
+
* CLI command: review
|
|
7
|
+
*
|
|
8
|
+
* Execute function:
|
|
9
|
+
* executeReview - Analyze video quality across 5 categories and optionally auto-fix
|
|
10
|
+
*
|
|
11
|
+
* @dependencies Gemini (Google), FFmpeg (auto-fix filters)
|
|
12
|
+
*/
|
|
13
|
+
import { readFile, rename } from "node:fs/promises";
|
|
14
|
+
import { resolve } from "node:path";
|
|
15
|
+
import { existsSync } from "node:fs";
|
|
16
|
+
import chalk from "chalk";
|
|
17
|
+
import ora from "ora";
|
|
18
|
+
import { GeminiProvider } from "@vibeframe/ai-providers";
|
|
19
|
+
import { getApiKey, loadEnv } from "../utils/api-key.js";
|
|
20
|
+
import { execSafe } from "../utils/exec-safe.js";
|
|
21
|
+
function parseReviewFeedback(response) {
|
|
22
|
+
let cleaned = response.trim();
|
|
23
|
+
if (cleaned.startsWith("```json")) {
|
|
24
|
+
cleaned = cleaned.slice(7);
|
|
25
|
+
}
|
|
26
|
+
else if (cleaned.startsWith("```")) {
|
|
27
|
+
cleaned = cleaned.slice(3);
|
|
28
|
+
}
|
|
29
|
+
if (cleaned.endsWith("```")) {
|
|
30
|
+
cleaned = cleaned.slice(0, -3);
|
|
31
|
+
}
|
|
32
|
+
cleaned = cleaned.trim();
|
|
33
|
+
try {
|
|
34
|
+
const parsed = JSON.parse(cleaned);
|
|
35
|
+
if (typeof parsed.overallScore !== "number" || !parsed.categories) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return parsed;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Review video quality using Gemini AI and optionally auto-fix issues.
|
|
46
|
+
*
|
|
47
|
+
* Analyzes 5 quality categories (pacing, color, text readability, audio-visual
|
|
48
|
+
* sync, composition) and returns scored feedback. When auto-apply is enabled,
|
|
49
|
+
* applies fixable corrections via FFmpeg filters.
|
|
50
|
+
*
|
|
51
|
+
* @param options - Review configuration
|
|
52
|
+
* @returns Result with structured feedback and optional fix details
|
|
53
|
+
*/
|
|
54
|
+
export async function executeReview(options) {
|
|
55
|
+
const { videoPath, storyboardPath, autoApply = false, verify = false, model = "flash" } = options;
|
|
56
|
+
const absVideoPath = resolve(process.cwd(), videoPath);
|
|
57
|
+
if (!existsSync(absVideoPath)) {
|
|
58
|
+
return { success: false, error: `Video not found: ${absVideoPath}` };
|
|
59
|
+
}
|
|
60
|
+
const apiKey = process.env.GOOGLE_API_KEY || (await getApiKey("GOOGLE_API_KEY", "Google"));
|
|
61
|
+
if (!apiKey) {
|
|
62
|
+
return { success: false, error: "Google API key required for Gemini video review. Run 'vibe setup' or set GOOGLE_API_KEY in .env" };
|
|
63
|
+
}
|
|
64
|
+
let storyboardContext = "";
|
|
65
|
+
if (storyboardPath) {
|
|
66
|
+
const absStoryboardPath = resolve(process.cwd(), storyboardPath);
|
|
67
|
+
if (existsSync(absStoryboardPath)) {
|
|
68
|
+
const content = await readFile(absStoryboardPath, "utf-8");
|
|
69
|
+
storyboardContext = `\n\nOriginal storyboard for reference:\n${content}`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const modelMap = {
|
|
73
|
+
flash: "gemini-3-flash-preview",
|
|
74
|
+
"flash-2.5": "gemini-2.5-flash",
|
|
75
|
+
pro: "gemini-2.5-pro",
|
|
76
|
+
};
|
|
77
|
+
const modelId = modelMap[model] || modelMap.flash;
|
|
78
|
+
const reviewPrompt = `You are a professional video editor reviewing this video for quality. Analyze the video and return a JSON review with the following structure. Return ONLY valid JSON, no extra text.
|
|
79
|
+
|
|
80
|
+
{
|
|
81
|
+
"overallScore": <number 1-10>,
|
|
82
|
+
"categories": {
|
|
83
|
+
"pacing": { "score": <1-10>, "issues": ["..."], "fixable": <boolean> },
|
|
84
|
+
"color": { "score": <1-10>, "issues": ["..."], "fixable": <boolean>, "suggestedFilter": "<ffmpeg filter or null>" },
|
|
85
|
+
"textReadability": { "score": <1-10>, "issues": ["..."], "fixable": <boolean>, "suggestions": ["..."] },
|
|
86
|
+
"audioVisualSync": { "score": <1-10>, "issues": ["..."], "fixable": <boolean> },
|
|
87
|
+
"composition": { "score": <1-10>, "issues": ["..."], "fixable": <boolean> }
|
|
88
|
+
},
|
|
89
|
+
"autoFixable": [
|
|
90
|
+
{ "type": "color_grade"|"text_overlay_adjust"|"speed_adjust"|"crop", "description": "...", "ffmpegFilter": "..." }
|
|
91
|
+
],
|
|
92
|
+
"recommendations": ["..."]
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
Score each category 1-10. For fixable issues, provide an FFmpeg filter in autoFixable. Be specific and practical.${storyboardContext}`;
|
|
96
|
+
const gemini = new GeminiProvider();
|
|
97
|
+
await gemini.initialize({ apiKey });
|
|
98
|
+
const videoData = await readFile(absVideoPath);
|
|
99
|
+
const analysisResult = await gemini.analyzeVideo(videoData, reviewPrompt, {
|
|
100
|
+
model: modelId,
|
|
101
|
+
});
|
|
102
|
+
if (!analysisResult.success || !analysisResult.response) {
|
|
103
|
+
return { success: false, error: analysisResult.error || "Gemini video analysis failed" };
|
|
104
|
+
}
|
|
105
|
+
const feedback = parseReviewFeedback(analysisResult.response);
|
|
106
|
+
if (!feedback) {
|
|
107
|
+
return {
|
|
108
|
+
success: false,
|
|
109
|
+
error: "Failed to parse review feedback from Gemini response",
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const result = {
|
|
113
|
+
success: true,
|
|
114
|
+
feedback,
|
|
115
|
+
appliedFixes: [],
|
|
116
|
+
};
|
|
117
|
+
if (autoApply && feedback.autoFixable.length > 0) {
|
|
118
|
+
let currentInput = absVideoPath;
|
|
119
|
+
const outputBase = options.outputPath
|
|
120
|
+
? resolve(process.cwd(), options.outputPath)
|
|
121
|
+
: absVideoPath.replace(/(\.[^.]+)$/, "-reviewed$1");
|
|
122
|
+
for (const fix of feedback.autoFixable) {
|
|
123
|
+
if (fix.type === "color_grade" && fix.ffmpegFilter) {
|
|
124
|
+
try {
|
|
125
|
+
const tempOutput = outputBase.replace(/(\.[^.]+)$/, `-fix-${result.appliedFixes.length}$1`);
|
|
126
|
+
await execSafe("ffmpeg", ["-i", currentInput, "-vf", fix.ffmpegFilter, "-c:a", "copy", tempOutput, "-y"], { timeout: 600000, maxBuffer: 50 * 1024 * 1024 });
|
|
127
|
+
currentInput = tempOutput;
|
|
128
|
+
result.appliedFixes.push(`${fix.type}: ${fix.description}`);
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
// Skip failed fix, continue with others
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else if (fix.type === "text_overlay_adjust") {
|
|
135
|
+
result.appliedFixes.push(`${fix.type}: ${fix.description} (manual adjustment recommended)`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (currentInput !== absVideoPath) {
|
|
139
|
+
const finalOutput = outputBase;
|
|
140
|
+
try {
|
|
141
|
+
await rename(currentInput, finalOutput);
|
|
142
|
+
result.outputPath = finalOutput;
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
result.outputPath = currentInput;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (verify && result.outputPath) {
|
|
150
|
+
const verifyVideoData = await readFile(result.outputPath);
|
|
151
|
+
const verifyResult = await gemini.analyzeVideo(verifyVideoData, "Rate this video overall quality on a scale of 1-10. Return ONLY a JSON object: {\"score\": <number>}", { model: modelId });
|
|
152
|
+
if (verifyResult.success && verifyResult.response) {
|
|
153
|
+
try {
|
|
154
|
+
let cleaned = verifyResult.response.trim();
|
|
155
|
+
if (cleaned.startsWith("```json"))
|
|
156
|
+
cleaned = cleaned.slice(7);
|
|
157
|
+
if (cleaned.startsWith("```"))
|
|
158
|
+
cleaned = cleaned.slice(3);
|
|
159
|
+
if (cleaned.endsWith("```"))
|
|
160
|
+
cleaned = cleaned.slice(0, -3);
|
|
161
|
+
const parsed = JSON.parse(cleaned.trim());
|
|
162
|
+
result.verificationScore = parsed.score;
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
// Verification parse failed, not critical
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
export function registerReviewCommand(aiCommand) {
|
|
172
|
+
aiCommand
|
|
173
|
+
.command("review")
|
|
174
|
+
.description("Review video quality using Gemini AI and optionally auto-fix issues")
|
|
175
|
+
.argument("<video>", "Video file path")
|
|
176
|
+
.option("-s, --storyboard <path>", "Storyboard JSON file for context")
|
|
177
|
+
.option("--auto-apply", "Automatically apply fixable corrections")
|
|
178
|
+
.option("--verify", "Run verification pass after applying fixes")
|
|
179
|
+
.option("-m, --model <model>", "Gemini model: flash (default), flash-2.5, pro", "flash")
|
|
180
|
+
.option("-o, --output <path>", "Output video file path (for auto-apply)")
|
|
181
|
+
.action(async (videoPath, options) => {
|
|
182
|
+
try {
|
|
183
|
+
loadEnv();
|
|
184
|
+
const spinner = ora("Reviewing video with Gemini...").start();
|
|
185
|
+
const result = await executeReview({
|
|
186
|
+
videoPath,
|
|
187
|
+
storyboardPath: options.storyboard,
|
|
188
|
+
autoApply: options.autoApply,
|
|
189
|
+
verify: options.verify,
|
|
190
|
+
model: options.model,
|
|
191
|
+
outputPath: options.output,
|
|
192
|
+
});
|
|
193
|
+
if (!result.success) {
|
|
194
|
+
spinner.fail(chalk.red(result.error || "Video review failed"));
|
|
195
|
+
process.exit(1);
|
|
196
|
+
}
|
|
197
|
+
spinner.succeed(chalk.green("Video review complete"));
|
|
198
|
+
console.log();
|
|
199
|
+
const fb = result.feedback;
|
|
200
|
+
console.log(chalk.bold.cyan("Video Review"));
|
|
201
|
+
console.log(chalk.dim("─".repeat(60)));
|
|
202
|
+
console.log(`Overall Score: ${chalk.bold(fb.overallScore >= 7 ? chalk.green(String(fb.overallScore)) : fb.overallScore >= 5 ? chalk.yellow(String(fb.overallScore)) : chalk.red(String(fb.overallScore)))}/10`);
|
|
203
|
+
console.log();
|
|
204
|
+
const categories = [
|
|
205
|
+
["Pacing", fb.categories.pacing],
|
|
206
|
+
["Color", fb.categories.color],
|
|
207
|
+
["Text Readability", fb.categories.textReadability],
|
|
208
|
+
["Audio-Visual Sync", fb.categories.audioVisualSync],
|
|
209
|
+
["Composition", fb.categories.composition],
|
|
210
|
+
];
|
|
211
|
+
for (const [name, cat] of categories) {
|
|
212
|
+
const scoreColor = cat.score >= 7 ? chalk.green : cat.score >= 5 ? chalk.yellow : chalk.red;
|
|
213
|
+
const fixable = cat.fixable ? chalk.dim(" [fixable]") : "";
|
|
214
|
+
console.log(` ${name.padEnd(20)} ${scoreColor(String(cat.score).padStart(2))}/10${fixable}`);
|
|
215
|
+
if (cat.issues.length > 0) {
|
|
216
|
+
for (const issue of cat.issues) {
|
|
217
|
+
console.log(chalk.dim(` - ${issue}`));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (result.appliedFixes && result.appliedFixes.length > 0) {
|
|
222
|
+
console.log();
|
|
223
|
+
console.log(chalk.bold.green("Applied Fixes:"));
|
|
224
|
+
for (const fix of result.appliedFixes) {
|
|
225
|
+
console.log(chalk.green(` + ${fix}`));
|
|
226
|
+
}
|
|
227
|
+
if (result.outputPath) {
|
|
228
|
+
console.log(chalk.green(` Output: ${result.outputPath}`));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (result.verificationScore !== undefined) {
|
|
232
|
+
console.log();
|
|
233
|
+
console.log(chalk.bold(`Verification Score: ${result.verificationScore}/10`));
|
|
234
|
+
}
|
|
235
|
+
if (fb.recommendations.length > 0) {
|
|
236
|
+
console.log();
|
|
237
|
+
console.log(chalk.bold("Recommendations:"));
|
|
238
|
+
for (const rec of fb.recommendations) {
|
|
239
|
+
console.log(chalk.dim(` * ${rec}`));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
console.log();
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
console.error(chalk.red("Video review failed"));
|
|
246
|
+
console.error(error);
|
|
247
|
+
process.exit(1);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=ai-review.js.map
|