mergestory 0.0.0-stage → 1.0.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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +48 -2
- package/assets/kokoro-plugin/package-lock.json +1139 -0
- package/dist/analyzer/analyze.d.ts +8 -0
- package/dist/analyzer/analyze.js +328 -0
- package/dist/analyzer/components.d.ts +18 -0
- package/dist/analyzer/components.js +266 -0
- package/dist/analyzer/dependencies.d.ts +13 -0
- package/dist/analyzer/dependencies.js +349 -0
- package/dist/analyzer/evidence.d.ts +15 -0
- package/dist/analyzer/evidence.js +73 -0
- package/dist/analyzer/hunks.d.ts +21 -0
- package/dist/analyzer/hunks.js +88 -0
- package/dist/analyzer/imports.d.ts +46 -0
- package/dist/analyzer/imports.js +87 -0
- package/dist/analyzer/index.d.ts +14 -0
- package/dist/analyzer/index.js +16 -0
- package/dist/analyzer/languages/go.d.ts +2 -0
- package/dist/analyzer/languages/go.js +76 -0
- package/dist/analyzer/languages/index.d.ts +18 -0
- package/dist/analyzer/languages/index.js +72 -0
- package/dist/analyzer/languages/javascript.d.ts +2 -0
- package/dist/analyzer/languages/javascript.js +336 -0
- package/dist/analyzer/languages/jvm.d.ts +2 -0
- package/dist/analyzer/languages/jvm.js +157 -0
- package/dist/analyzer/languages/others.d.ts +2 -0
- package/dist/analyzer/languages/others.js +40 -0
- package/dist/analyzer/languages/php.d.ts +2 -0
- package/dist/analyzer/languages/php.js +81 -0
- package/dist/analyzer/languages/python.d.ts +2 -0
- package/dist/analyzer/languages/python.js +180 -0
- package/dist/analyzer/languages/ruby.d.ts +2 -0
- package/dist/analyzer/languages/ruby.js +99 -0
- package/dist/analyzer/languages/rust.d.ts +2 -0
- package/dist/analyzer/languages/rust.js +164 -0
- package/dist/analyzer/languages/shared.d.ts +35 -0
- package/dist/analyzer/languages/shared.js +43 -0
- package/dist/analyzer/languages/types.d.ts +78 -0
- package/dist/analyzer/languages/types.js +2 -0
- package/dist/analyzer/pack-format.d.ts +27 -0
- package/dist/analyzer/pack-format.js +139 -0
- package/dist/analyzer/pack.d.ts +26 -0
- package/dist/analyzer/pack.js +498 -0
- package/dist/analyzer/relationships.d.ts +17 -0
- package/dist/analyzer/relationships.js +34 -0
- package/dist/analyzer/risk-rules.d.ts +287 -0
- package/dist/analyzer/risk-rules.js +373 -0
- package/dist/analyzer/risks.d.ts +36 -0
- package/dist/analyzer/risks.js +480 -0
- package/dist/analyzer/roles.d.ts +11 -0
- package/dist/analyzer/roles.js +280 -0
- package/dist/analyzer/scan.d.ts +26 -0
- package/dist/analyzer/scan.js +157 -0
- package/dist/analyzer/signals.d.ts +20 -0
- package/dist/analyzer/signals.js +51 -0
- package/dist/analyzer/symbol-changes.d.ts +11 -0
- package/dist/analyzer/symbol-changes.js +101 -0
- package/dist/analyzer/symbol-types.d.ts +17 -0
- package/dist/analyzer/symbol-types.js +9 -0
- package/dist/analyzer/symbols.d.ts +4 -0
- package/dist/analyzer/symbols.js +16 -0
- package/dist/analyzer/trivial.d.ts +13 -0
- package/dist/analyzer/trivial.js +137 -0
- package/dist/analyzer/util.d.ts +6 -0
- package/dist/analyzer/util.js +24 -0
- package/dist/cli/commands/authoring.d.ts +9 -0
- package/dist/cli/commands/authoring.js +98 -0
- package/dist/cli/commands/cache.d.ts +4 -0
- package/dist/cli/commands/cache.js +37 -0
- package/dist/cli/commands/doctor.d.ts +5 -0
- package/dist/cli/commands/doctor.js +37 -0
- package/dist/cli/commands/generate.d.ts +8 -0
- package/dist/cli/commands/generate.js +69 -0
- package/dist/cli/commands/jobs.d.ts +8 -0
- package/dist/cli/commands/jobs.js +70 -0
- package/dist/cli/commands/publish.d.ts +8 -0
- package/dist/cli/commands/publish.js +120 -0
- package/dist/cli/commands/serve.d.ts +4 -0
- package/dist/cli/commands/serve.js +69 -0
- package/dist/cli/commands/setup.d.ts +14 -0
- package/dist/cli/commands/setup.js +108 -0
- package/dist/cli/commands/shared.d.ts +18 -0
- package/dist/cli/commands/shared.js +24 -0
- package/dist/cli/files.d.ts +26 -0
- package/dist/cli/files.js +98 -0
- package/dist/cli/format.d.ts +55 -0
- package/dist/cli/format.js +295 -0
- package/dist/cli/inputs.d.ts +23 -0
- package/dist/cli/inputs.js +96 -0
- package/dist/cli/io.d.ts +19 -0
- package/dist/cli/io.js +31 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +15 -0
- package/dist/cli/options.d.ts +105 -0
- package/dist/cli/options.js +324 -0
- package/dist/cli/program.d.ts +12 -0
- package/dist/cli/program.js +146 -0
- package/dist/cli/runtime.d.ts +59 -0
- package/dist/cli/runtime.js +83 -0
- package/dist/cli/style.d.ts +13 -0
- package/dist/cli/style.js +27 -0
- package/dist/core/binaries.d.ts +7 -0
- package/dist/core/binaries.js +33 -0
- package/dist/core/binary-paths.d.ts +5 -0
- package/dist/core/binary-paths.js +92 -0
- package/dist/core/cache.d.ts +14 -0
- package/dist/core/cache.js +43 -0
- package/dist/core/child-env.d.ts +9 -0
- package/dist/core/child-env.js +61 -0
- package/dist/core/concurrency.d.ts +13 -0
- package/dist/core/concurrency.js +58 -0
- package/dist/core/config.d.ts +223 -0
- package/dist/core/config.js +454 -0
- package/dist/core/context.d.ts +39 -0
- package/dist/core/context.js +44 -0
- package/dist/core/cost.d.ts +46 -0
- package/dist/core/cost.js +108 -0
- package/dist/core/diagram-metrics.d.ts +57 -0
- package/dist/core/diagram-metrics.js +63 -0
- package/dist/core/diff-view.d.ts +44 -0
- package/dist/core/diff-view.js +136 -0
- package/dist/core/errors.d.ts +47 -0
- package/dist/core/errors.js +94 -0
- package/dist/core/ids.d.ts +11 -0
- package/dist/core/ids.js +36 -0
- package/dist/core/json.d.ts +8 -0
- package/dist/core/json.js +17 -0
- package/dist/core/languages.d.ts +19 -0
- package/dist/core/languages.js +292 -0
- package/dist/core/logger.d.ts +29 -0
- package/dist/core/logger.js +68 -0
- package/dist/core/net.d.ts +16 -0
- package/dist/core/net.js +80 -0
- package/dist/core/path-policy.d.ts +20 -0
- package/dist/core/path-policy.js +202 -0
- package/dist/core/paths.d.ts +18 -0
- package/dist/core/paths.js +53 -0
- package/dist/core/posix.d.ts +12 -0
- package/dist/core/posix.js +50 -0
- package/dist/core/process.d.ts +22 -0
- package/dist/core/process.js +117 -0
- package/dist/core/providers.d.ts +204 -0
- package/dist/core/providers.js +2 -0
- package/dist/core/redact.d.ts +11 -0
- package/dist/core/redact.js +70 -0
- package/dist/core/render-plan.d.ts +307 -0
- package/dist/core/render-plan.js +7 -0
- package/dist/core/retry.d.ts +54 -0
- package/dist/core/retry.js +116 -0
- package/dist/core/run-folder.d.ts +74 -0
- package/dist/core/run-folder.js +129 -0
- package/dist/core/secrets.d.ts +56 -0
- package/dist/core/secrets.js +301 -0
- package/dist/core/storyboard-facts.d.ts +22 -0
- package/dist/core/storyboard-facts.js +61 -0
- package/dist/core/storyboard-schema.d.ts +1279 -0
- package/dist/core/storyboard-schema.js +342 -0
- package/dist/core/text.d.ts +43 -0
- package/dist/core/text.js +94 -0
- package/dist/core/types.d.ts +459 -0
- package/dist/core/types.js +17 -0
- package/dist/doctor/check.d.ts +6 -0
- package/dist/doctor/check.js +18 -0
- package/dist/doctor/deps.d.ts +2 -0
- package/dist/doctor/deps.js +90 -0
- package/dist/doctor/format.d.ts +9 -0
- package/dist/doctor/format.js +19 -0
- package/dist/doctor/github.d.ts +2 -0
- package/dist/doctor/github.js +13 -0
- package/dist/doctor/home.d.ts +2 -0
- package/dist/doctor/home.js +26 -0
- package/dist/doctor/index.d.ts +18 -0
- package/dist/doctor/index.js +81 -0
- package/dist/doctor/llm.d.ts +2 -0
- package/dist/doctor/llm.js +32 -0
- package/dist/doctor/publish.d.ts +2 -0
- package/dist/doctor/publish.js +16 -0
- package/dist/doctor/s3.d.ts +2 -0
- package/dist/doctor/s3.js +125 -0
- package/dist/doctor/speech.d.ts +2 -0
- package/dist/doctor/speech.js +112 -0
- package/dist/doctor/tools.d.ts +5 -0
- package/dist/doctor/tools.js +58 -0
- package/dist/doctor/types.d.ts +92 -0
- package/dist/doctor/types.js +2 -0
- package/dist/doctor/youtube.d.ts +2 -0
- package/dist/doctor/youtube.js +73 -0
- package/dist/github/client.d.ts +108 -0
- package/dist/github/client.js +499 -0
- package/dist/github/errors.d.ts +37 -0
- package/dist/github/errors.js +155 -0
- package/dist/github/index.d.ts +13 -0
- package/dist/github/index.js +9 -0
- package/dist/github/linked-issues.d.ts +37 -0
- package/dist/github/linked-issues.js +131 -0
- package/dist/github/model.d.ts +81 -0
- package/dist/github/model.js +114 -0
- package/dist/github/notify.d.ts +27 -0
- package/dist/github/notify.js +118 -0
- package/dist/github/pr-url.d.ts +27 -0
- package/dist/github/pr-url.js +122 -0
- package/dist/github/token.d.ts +16 -0
- package/dist/github/token.js +69 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +19 -0
- package/dist/jobs/input-rules.d.ts +20 -0
- package/dist/jobs/input-rules.js +100 -0
- package/dist/jobs/model.d.ts +47 -0
- package/dist/jobs/model.js +18 -0
- package/dist/jobs/runner.d.ts +43 -0
- package/dist/jobs/runner.js +165 -0
- package/dist/jobs/store.d.ts +67 -0
- package/dist/jobs/store.js +314 -0
- package/dist/jobs/view.d.ts +48 -0
- package/dist/jobs/view.js +111 -0
- package/dist/jobs/worker.d.ts +24 -0
- package/dist/jobs/worker.js +47 -0
- package/dist/llm/anthropic.d.ts +11 -0
- package/dist/llm/anthropic.js +225 -0
- package/dist/llm/index.d.ts +10 -0
- package/dist/llm/index.js +27 -0
- package/dist/llm/openai-compatible.d.ts +33 -0
- package/dist/llm/openai-compatible.js +378 -0
- package/dist/llm/prices.d.ts +26 -0
- package/dist/llm/prices.js +41 -0
- package/dist/llm/shared.d.ts +30 -0
- package/dist/llm/shared.js +115 -0
- package/dist/narration/assemble.d.ts +36 -0
- package/dist/narration/assemble.js +282 -0
- package/dist/narration/audio.d.ts +61 -0
- package/dist/narration/audio.js +301 -0
- package/dist/narration/captions.d.ts +37 -0
- package/dist/narration/captions.js +195 -0
- package/dist/narration/chunking.d.ts +6 -0
- package/dist/narration/chunking.js +46 -0
- package/dist/narration/convert.d.ts +9 -0
- package/dist/narration/convert.js +90 -0
- package/dist/narration/elevenlabs.d.ts +5 -0
- package/dist/narration/elevenlabs.js +53 -0
- package/dist/narration/http-errors.d.ts +14 -0
- package/dist/narration/http-errors.js +74 -0
- package/dist/narration/index.d.ts +21 -0
- package/dist/narration/index.js +22 -0
- package/dist/narration/kokoro-install.d.ts +30 -0
- package/dist/narration/kokoro-install.js +284 -0
- package/dist/narration/kokoro-model.d.ts +54 -0
- package/dist/narration/kokoro-model.js +168 -0
- package/dist/narration/kokoro-plugin.d.ts +78 -0
- package/dist/narration/kokoro-plugin.js +245 -0
- package/dist/narration/kokoro.d.ts +22 -0
- package/dist/narration/kokoro.js +231 -0
- package/dist/narration/openai.d.ts +4 -0
- package/dist/narration/openai.js +54 -0
- package/dist/narration/pricing.d.ts +8 -0
- package/dist/narration/pricing.js +17 -0
- package/dist/narration/remote-speech.d.ts +53 -0
- package/dist/narration/remote-speech.js +100 -0
- package/dist/narration/say.d.ts +28 -0
- package/dist/narration/say.js +178 -0
- package/dist/narration/select.d.ts +27 -0
- package/dist/narration/select.js +80 -0
- package/dist/narration/silent.d.ts +2 -0
- package/dist/narration/silent.js +18 -0
- package/dist/narration/speakable.d.ts +20 -0
- package/dist/narration/speakable.js +398 -0
- package/dist/narration/synthesize.d.ts +25 -0
- package/dist/narration/synthesize.js +220 -0
- package/dist/narration/wav.d.ts +37 -0
- package/dist/narration/wav.js +170 -0
- package/dist/pipeline/authoring.d.ts +8 -0
- package/dist/pipeline/authoring.js +117 -0
- package/dist/pipeline/commands.d.ts +9 -0
- package/dist/pipeline/commands.js +21 -0
- package/dist/pipeline/fit-duration.d.ts +41 -0
- package/dist/pipeline/fit-duration.js +150 -0
- package/dist/pipeline/index.d.ts +9 -0
- package/dist/pipeline/index.js +9 -0
- package/dist/pipeline/inputs.d.ts +42 -0
- package/dist/pipeline/inputs.js +171 -0
- package/dist/pipeline/plan.d.ts +8 -0
- package/dist/pipeline/plan.js +85 -0
- package/dist/pipeline/planned-egress.d.ts +21 -0
- package/dist/pipeline/planned-egress.js +43 -0
- package/dist/pipeline/prepare.d.ts +26 -0
- package/dist/pipeline/prepare.js +84 -0
- package/dist/pipeline/presentation.d.ts +26 -0
- package/dist/pipeline/presentation.js +110 -0
- package/dist/pipeline/publish-run.d.ts +71 -0
- package/dist/pipeline/publish-run.js +295 -0
- package/dist/pipeline/run.d.ts +7 -0
- package/dist/pipeline/run.js +196 -0
- package/dist/pipeline/storyboard-choice.d.ts +34 -0
- package/dist/pipeline/storyboard-choice.js +129 -0
- package/dist/pipeline/types.d.ts +76 -0
- package/dist/pipeline/types.js +2 -0
- package/dist/publish/access-probe.d.ts +55 -0
- package/dist/publish/access-probe.js +249 -0
- package/dist/publish/bundle.d.ts +20 -0
- package/dist/publish/bundle.js +57 -0
- package/dist/publish/comment.d.ts +10 -0
- package/dist/publish/comment.js +184 -0
- package/dist/publish/content-types.d.ts +15 -0
- package/dist/publish/content-types.js +41 -0
- package/dist/publish/index.d.ts +18 -0
- package/dist/publish/index.js +30 -0
- package/dist/publish/keys.d.ts +10 -0
- package/dist/publish/keys.js +30 -0
- package/dist/publish/local.d.ts +33 -0
- package/dist/publish/local.js +143 -0
- package/dist/publish/privacy.d.ts +20 -0
- package/dist/publish/privacy.js +21 -0
- package/dist/publish/s3/bucket.d.ts +22 -0
- package/dist/publish/s3/bucket.js +82 -0
- package/dist/publish/s3/client.d.ts +33 -0
- package/dist/publish/s3/client.js +134 -0
- package/dist/publish/s3/failures.d.ts +22 -0
- package/dist/publish/s3/failures.js +110 -0
- package/dist/publish/s3/index.d.ts +5 -0
- package/dist/publish/s3/index.js +6 -0
- package/dist/publish/s3/links.d.ts +38 -0
- package/dist/publish/s3/links.js +60 -0
- package/dist/publish/s3/protected-links.d.ts +29 -0
- package/dist/publish/s3/protected-links.js +67 -0
- package/dist/publish/s3/publisher.d.ts +32 -0
- package/dist/publish/s3/publisher.js +123 -0
- package/dist/publish/s3/settings.d.ts +29 -0
- package/dist/publish/s3/settings.js +64 -0
- package/dist/publish/s3/upload.d.ts +29 -0
- package/dist/publish/s3/upload.js +145 -0
- package/dist/publish/severity.d.ts +9 -0
- package/dist/publish/severity.js +18 -0
- package/dist/publish/text.d.ts +23 -0
- package/dist/publish/text.js +94 -0
- package/dist/publish/types.d.ts +67 -0
- package/dist/publish/types.js +12 -0
- package/dist/publish/vtt.d.ts +9 -0
- package/dist/publish/vtt.js +43 -0
- package/dist/publish/watch-page.d.ts +4 -0
- package/dist/publish/watch-page.js +463 -0
- package/dist/publish/youtube/credentials.d.ts +33 -0
- package/dist/publish/youtube/credentials.js +162 -0
- package/dist/publish/youtube/description.d.ts +56 -0
- package/dist/publish/youtube/description.js +197 -0
- package/dist/publish/youtube/google-api.d.ts +95 -0
- package/dist/publish/youtube/google-api.js +339 -0
- package/dist/publish/youtube/index.d.ts +7 -0
- package/dist/publish/youtube/index.js +8 -0
- package/dist/publish/youtube/loopback.d.ts +13 -0
- package/dist/publish/youtube/loopback.js +144 -0
- package/dist/publish/youtube/oauth.d.ts +68 -0
- package/dist/publish/youtube/oauth.js +159 -0
- package/dist/publish/youtube/prompt.d.ts +27 -0
- package/dist/publish/youtube/prompt.js +94 -0
- package/dist/publish/youtube/publisher.d.ts +38 -0
- package/dist/publish/youtube/publisher.js +346 -0
- package/dist/publish/youtube/scopes.d.ts +32 -0
- package/dist/publish/youtube/scopes.js +55 -0
- package/dist/publish/youtube/sign-in.d.ts +37 -0
- package/dist/publish/youtube/sign-in.js +137 -0
- package/dist/publish/youtube/upload.d.ts +43 -0
- package/dist/publish/youtube/upload.js +210 -0
- package/dist/render/browser.d.ts +23 -0
- package/dist/render/browser.js +219 -0
- package/dist/render/chromium-renderer.d.ts +56 -0
- package/dist/render/chromium-renderer.js +519 -0
- package/dist/render/ffmpeg.d.ts +55 -0
- package/dist/render/ffmpeg.js +212 -0
- package/dist/render/fonts.d.ts +10 -0
- package/dist/render/fonts.js +42 -0
- package/dist/render/index.d.ts +9 -0
- package/dist/render/index.js +11 -0
- package/dist/render/page.d.ts +46 -0
- package/dist/render/page.js +123 -0
- package/dist/render/playwright.d.ts +3 -0
- package/dist/render/playwright.js +6 -0
- package/dist/render/runtime-bundle.d.ts +2 -0
- package/dist/render/runtime-bundle.js +72 -0
- package/dist/runtime/runtime.js +1626 -0
- package/dist/server/auth.d.ts +17 -0
- package/dist/server/auth.js +58 -0
- package/dist/server/http.d.ts +43 -0
- package/dist/server/http.js +119 -0
- package/dist/server/index.d.ts +46 -0
- package/dist/server/index.js +310 -0
- package/dist/server/queue.d.ts +30 -0
- package/dist/server/queue.js +76 -0
- package/dist/server/schema.d.ts +103 -0
- package/dist/server/schema.js +121 -0
- package/dist/server/source.d.ts +17 -0
- package/dist/server/source.js +100 -0
- package/dist/sources/assemble.d.ts +86 -0
- package/dist/sources/assemble.js +117 -0
- package/dist/sources/diff-parser.d.ts +14 -0
- package/dist/sources/diff-parser.js +84 -0
- package/dist/sources/git.d.ts +28 -0
- package/dist/sources/git.js +108 -0
- package/dist/sources/github.d.ts +20 -0
- package/dist/sources/github.js +192 -0
- package/dist/sources/hunk-selection.d.ts +25 -0
- package/dist/sources/hunk-selection.js +46 -0
- package/dist/sources/index.d.ts +23 -0
- package/dist/sources/index.js +62 -0
- package/dist/sources/limits.d.ts +27 -0
- package/dist/sources/limits.js +22 -0
- package/dist/sources/local.d.ts +34 -0
- package/dist/sources/local.js +555 -0
- package/dist/sources/reader.d.ts +13 -0
- package/dist/sources/reader.js +45 -0
- package/dist/sources/remote.d.ts +13 -0
- package/dist/sources/remote.js +41 -0
- package/dist/sources/repo-context.d.ts +34 -0
- package/dist/sources/repo-context.js +144 -0
- package/dist/sources/text.d.ts +25 -0
- package/dist/sources/text.js +71 -0
- package/dist/storyboard/authoring.d.ts +108 -0
- package/dist/storyboard/authoring.js +196 -0
- package/dist/storyboard/claims.d.ts +35 -0
- package/dist/storyboard/claims.js +318 -0
- package/dist/storyboard/coderef.d.ts +28 -0
- package/dist/storyboard/coderef.js +118 -0
- package/dist/storyboard/generate.d.ts +25 -0
- package/dist/storyboard/generate.js +194 -0
- package/dist/storyboard/heuristic-code.d.ts +91 -0
- package/dist/storyboard/heuristic-code.js +524 -0
- package/dist/storyboard/heuristic-context.d.ts +42 -0
- package/dist/storyboard/heuristic-context.js +102 -0
- package/dist/storyboard/heuristic-facts.d.ts +106 -0
- package/dist/storyboard/heuristic-facts.js +415 -0
- package/dist/storyboard/heuristic-overview.d.ts +4 -0
- package/dist/storyboard/heuristic-overview.js +151 -0
- package/dist/storyboard/heuristic-review.d.ts +10 -0
- package/dist/storyboard/heuristic-review.js +158 -0
- package/dist/storyboard/heuristic-scenes.d.ts +8 -0
- package/dist/storyboard/heuristic-scenes.js +357 -0
- package/dist/storyboard/heuristic-shared.d.ts +43 -0
- package/dist/storyboard/heuristic-shared.js +136 -0
- package/dist/storyboard/heuristic.d.ts +15 -0
- package/dist/storyboard/heuristic.js +324 -0
- package/dist/storyboard/identifiers.d.ts +51 -0
- package/dist/storyboard/identifiers.js +195 -0
- package/dist/storyboard/index.d.ts +10 -0
- package/dist/storyboard/index.js +10 -0
- package/dist/storyboard/prompts.d.ts +16 -0
- package/dist/storyboard/prompts.js +61 -0
- package/dist/storyboard/run.d.ts +82 -0
- package/dist/storyboard/run.js +332 -0
- package/dist/storyboard/text.d.ts +16 -0
- package/dist/storyboard/text.js +103 -0
- package/dist/storyboard/types.d.ts +47 -0
- package/dist/storyboard/types.js +2 -0
- package/dist/storyboard/urls.d.ts +15 -0
- package/dist/storyboard/urls.js +83 -0
- package/dist/storyboard/validate.d.ts +8 -0
- package/dist/storyboard/validate.js +525 -0
- package/dist/storyboard/visuals.d.ts +23 -0
- package/dist/storyboard/visuals.js +324 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +3 -0
- package/dist/visuals/code.d.ts +68 -0
- package/dist/visuals/code.js +385 -0
- package/dist/visuals/highlight.d.ts +17 -0
- package/dist/visuals/highlight.js +85 -0
- package/dist/visuals/image.d.ts +12 -0
- package/dist/visuals/image.js +96 -0
- package/dist/visuals/index.d.ts +10 -0
- package/dist/visuals/index.js +10 -0
- package/dist/visuals/layout.d.ts +89 -0
- package/dist/visuals/layout.js +506 -0
- package/dist/visuals/plan.d.ts +33 -0
- package/dist/visuals/plan.js +511 -0
- package/dist/visuals/timeline.d.ts +31 -0
- package/dist/visuals/timeline.js +96 -0
- package/package.json +74 -4
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publishing a rendered run, either at the end of generate() or later with publishRun(),
|
|
3
|
+
* so a video can be reviewed locally before anything leaves the machine.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync } from 'node:fs';
|
|
6
|
+
import { realpath } from 'node:fs/promises';
|
|
7
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
8
|
+
import { resolveConfig } from '../core/config.js';
|
|
9
|
+
import { createRunContext } from '../core/context.js';
|
|
10
|
+
import { describeProblem, MergeStoryError, toMergeStoryError } from '../core/errors.js';
|
|
11
|
+
import { RUN_ID_PATTERN } from '../core/ids.js';
|
|
12
|
+
import { homeLayout } from '../core/paths.js';
|
|
13
|
+
import { isInside } from '../core/posix.js';
|
|
14
|
+
import { globalRedactor } from '../core/redact.js';
|
|
15
|
+
import { PublishInputSchema, RenderPlanCaptionsSchema, RUN_FILE, readRunJson, resultFiles, runFolder, StoredResultSchema, writeRunJson, } from '../core/run-folder.js';
|
|
16
|
+
import { GitHubClient, parsePullRequestUrl, updatePullRequestDescription, upsertPullRequestComment, } from '../github/index.js';
|
|
17
|
+
import { BUNDLE_CONTAINS, buildDescriptionSection, buildPrComment, buildWatchPage, COMMENT_MARKER, createPublisher, } from '../publish/index.js';
|
|
18
|
+
import { publishCommand } from './commands.js';
|
|
19
|
+
import { buildCommentData } from './presentation.js';
|
|
20
|
+
/**
|
|
21
|
+
* The upload files of a run folder: the fixed names inside it. A name that leads outside the folder
|
|
22
|
+
* (a link to some other file) is refused, because whatever it points at would be uploaded.
|
|
23
|
+
*/
|
|
24
|
+
export async function runFilesIn(runDir) {
|
|
25
|
+
const root = await realpath(runDir);
|
|
26
|
+
const find = async (name) => {
|
|
27
|
+
let real;
|
|
28
|
+
try {
|
|
29
|
+
real = await realpath(join(runDir, name));
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
if (!isInside(root, real)) {
|
|
35
|
+
throw new MergeStoryError('PRIVACY_BLOCKED', `${name} in the run folder leads outside the folder, so it was not uploaded.`, { hint: 'A run folder holds only its own files. Render the video again with `mergestory generate`.' });
|
|
36
|
+
}
|
|
37
|
+
return real;
|
|
38
|
+
};
|
|
39
|
+
const video = await find(RUN_FILE.video);
|
|
40
|
+
if (!video) {
|
|
41
|
+
throw new MergeStoryError('SOURCE_NOT_FOUND', `This run has no ${RUN_FILE.video}.`, {
|
|
42
|
+
hint: 'Render the video first with `mergestory generate`.',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return { video, poster: await find(RUN_FILE.poster), captions: await find(RUN_FILE.captions) };
|
|
46
|
+
}
|
|
47
|
+
/** Prefixes of the warnings that the publish step adds. A new attempt replaces the ones of an earlier attempt. */
|
|
48
|
+
const PUBLISH_WARNING_PREFIXES = ['Skipped the PR update:', 'The pull request was not updated:'];
|
|
49
|
+
/**
|
|
50
|
+
* `publishedWith` is the publisher that the video goes through (its id, or the provider of the result),
|
|
51
|
+
* or null when nothing is published.
|
|
52
|
+
*/
|
|
53
|
+
export function decidePullRequestUpdate(config, change, publishedWith) {
|
|
54
|
+
if (!config.github.comment && !config.github.updateDescription)
|
|
55
|
+
return { kind: 'not-requested' };
|
|
56
|
+
if (change.source !== 'github' || !change.prUrl)
|
|
57
|
+
return { kind: 'not-a-pull-request' };
|
|
58
|
+
if (publishedWith === null || publishedWith === 'local')
|
|
59
|
+
return { kind: 'video-stays-local' };
|
|
60
|
+
return { kind: 'update', prUrl: change.prUrl };
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Upload with the configured publisher (if any), then update the pull request when asked. A failed
|
|
64
|
+
* upload does not throw: it comes back as `failure`, so the caller can save the run first. A failed
|
|
65
|
+
* pull request update is a warning, because the video is already published.
|
|
66
|
+
*/
|
|
67
|
+
export async function publishAndNotify(ctx, stored, files) {
|
|
68
|
+
const { config } = ctx;
|
|
69
|
+
const warnings = [];
|
|
70
|
+
let publish = null;
|
|
71
|
+
try {
|
|
72
|
+
const publisher = createPublisher(config);
|
|
73
|
+
if (publisher) {
|
|
74
|
+
ctx.progress({ stage: 'publish', status: 'start', message: `Publishing with ${publisher.id}` });
|
|
75
|
+
const { watch } = stored;
|
|
76
|
+
const bundle = {
|
|
77
|
+
files: [
|
|
78
|
+
{ name: RUN_FILE.video, path: files.video },
|
|
79
|
+
...(files.poster ? [{ name: RUN_FILE.poster, path: files.poster }] : []),
|
|
80
|
+
...(files.captions ? [{ name: RUN_FILE.captions, path: files.captions }] : []),
|
|
81
|
+
],
|
|
82
|
+
buildWatchPage: (urls) => buildWatchPage(watch, urls),
|
|
83
|
+
contains: [...BUNDLE_CONTAINS],
|
|
84
|
+
repoIsPrivate: stored.repoIsPrivate,
|
|
85
|
+
meta: {
|
|
86
|
+
title: watch.title,
|
|
87
|
+
summary: watch.summary,
|
|
88
|
+
language: stored.language,
|
|
89
|
+
durationSec: watch.durationSec,
|
|
90
|
+
chapters: watch.chapters,
|
|
91
|
+
checklist: watch.checklist.map((item) => ({ title: item.title, severity: item.severity })),
|
|
92
|
+
changeUrl: watch.changeUrl,
|
|
93
|
+
repoLabel: watch.repoLabel,
|
|
94
|
+
changeLabel: watch.changeLabel,
|
|
95
|
+
headSha: stored.headSha,
|
|
96
|
+
engineVersion: watch.engineVersion,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
publish = await publisher.publish(bundle, ctx);
|
|
100
|
+
ctx.progress({ stage: 'publish', status: 'done', message: `Published to ${publish.location}` });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
return { publish: null, notify: null, warnings, failure: toMergeStoryError(err, 'PUBLISH_FAILED') };
|
|
105
|
+
}
|
|
106
|
+
let notify = null;
|
|
107
|
+
const update = decidePullRequestUpdate(config, { source: stored.source, prUrl: stored.prUrl }, publish?.provider ?? null);
|
|
108
|
+
if (update.kind === 'not-a-pull-request') {
|
|
109
|
+
warnings.push('Skipped the PR update: this run was not made from a GitHub pull request.');
|
|
110
|
+
}
|
|
111
|
+
else if (update.kind === 'video-stays-local') {
|
|
112
|
+
warnings.push('Skipped the PR update: the video is only on this machine. Publish it first (for example --publish s3).');
|
|
113
|
+
}
|
|
114
|
+
else if (update.kind === 'update' && publish) {
|
|
115
|
+
// The address is shown, because a run folder can name any pull request.
|
|
116
|
+
ctx.progress({
|
|
117
|
+
stage: 'notify',
|
|
118
|
+
status: 'start',
|
|
119
|
+
message: `Updating the pull request ${update.prUrl}`,
|
|
120
|
+
});
|
|
121
|
+
notify = { commentUrl: null, descriptionUpdated: false };
|
|
122
|
+
try {
|
|
123
|
+
const ref = parsePullRequestUrl(update.prUrl, config.github.apiUrl);
|
|
124
|
+
const commentData = buildCommentData(stored.watch, publish, stored.headSha);
|
|
125
|
+
if (config.github.comment) {
|
|
126
|
+
notify.commentUrl = (await upsertPullRequestComment(ref, buildPrComment(commentData), COMMENT_MARKER, ctx)).url;
|
|
127
|
+
}
|
|
128
|
+
if (config.github.updateDescription) {
|
|
129
|
+
await updatePullRequestDescription(ref, buildDescriptionSection(commentData), ctx);
|
|
130
|
+
notify.descriptionUpdated = true;
|
|
131
|
+
}
|
|
132
|
+
ctx.progress({ stage: 'notify', status: 'done', message: 'Pull request updated' });
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
// The video is already up, so its link is kept and printed. Only the update is reported as failed.
|
|
136
|
+
const message = `The pull request was not updated: ${describeProblem(toMergeStoryError(err, 'NOTIFY_FAILED'))} The video itself is published. ` +
|
|
137
|
+
`To try the update again, run: ${publishCommand(ctx.runDir, config)} (this uploads the video again).`;
|
|
138
|
+
warnings.push(message);
|
|
139
|
+
ctx.progress({ stage: 'notify', status: 'warn', message });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return { publish, notify, warnings, failure: null };
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Redact a result before it is stored, but keep the published links intact: they are what the
|
|
146
|
+
* user asked for, and a presigned link with its signature removed no longer works.
|
|
147
|
+
*/
|
|
148
|
+
export function redactResultForDisk(result) {
|
|
149
|
+
const redacted = globalRedactor.redactValue(result);
|
|
150
|
+
return { ...redacted, publish: result.publish };
|
|
151
|
+
}
|
|
152
|
+
/** Write result.json (see writeRunJson). */
|
|
153
|
+
export async function saveResult(runDir, result) {
|
|
154
|
+
await writeRunJson(runFolder(runDir).result, redactResultForDisk(result));
|
|
155
|
+
}
|
|
156
|
+
function resolveRunDir(run, home) {
|
|
157
|
+
const asPath = isAbsolute(run) ? run : resolve(process.cwd(), run);
|
|
158
|
+
if (existsSync(join(asPath, RUN_FILE.publishInput)))
|
|
159
|
+
return asPath;
|
|
160
|
+
if (RUN_ID_PATTERN.test(run)) {
|
|
161
|
+
const dir = join(homeLayout(home).runs, run);
|
|
162
|
+
if (existsSync(join(dir, RUN_FILE.publishInput)))
|
|
163
|
+
return dir;
|
|
164
|
+
}
|
|
165
|
+
throw new MergeStoryError('SOURCE_NOT_FOUND', `No rendered run found for "${run}".`, {
|
|
166
|
+
hint: 'Pass the run folder (runDir in the generate result) or its run id.',
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The stored input of a run folder. Folders made before the watch data held the caption language and
|
|
171
|
+
* the caption default are completed: the language is the narration language of the run, and the
|
|
172
|
+
* page's own caption track starts off when the render plan says that the captions are drawn into
|
|
173
|
+
* the video. When neither is stored, the page keeps its defaults.
|
|
174
|
+
*/
|
|
175
|
+
async function readStoredInput(runDir) {
|
|
176
|
+
const folder = runFolder(runDir);
|
|
177
|
+
const stored = await readRunJson(folder.publishInput, PublishInputSchema, RUN_FILE.publishInput);
|
|
178
|
+
const { watch } = stored;
|
|
179
|
+
const completed = { ...watch, language: watch.language ?? stored.language };
|
|
180
|
+
if (watch.captionsDefault === undefined) {
|
|
181
|
+
const drawn = await readRunJson(folder.renderPlan, RenderPlanCaptionsSchema, RUN_FILE.renderPlan).catch(() => null);
|
|
182
|
+
if (drawn?.captions.enabled)
|
|
183
|
+
completed.captionsDefault = false;
|
|
184
|
+
}
|
|
185
|
+
return { ...stored, watch: completed };
|
|
186
|
+
}
|
|
187
|
+
/** The result of the earlier run, or one rebuilt from publish-input.json when result.json is gone or unreadable. */
|
|
188
|
+
async function readPreviousResult(runDir, stored, budgetUsd) {
|
|
189
|
+
const folder = runFolder(runDir);
|
|
190
|
+
const previous = await readRunJson(folder.result, StoredResultSchema, RUN_FILE.result).catch(() => null);
|
|
191
|
+
if (previous)
|
|
192
|
+
return previous;
|
|
193
|
+
const { watch } = stored;
|
|
194
|
+
return {
|
|
195
|
+
ok: true,
|
|
196
|
+
runId: stored.runId,
|
|
197
|
+
runDir,
|
|
198
|
+
title: watch.title,
|
|
199
|
+
summary: watch.summary,
|
|
200
|
+
durationSec: watch.durationSec,
|
|
201
|
+
chapters: watch.chapters,
|
|
202
|
+
storyboardSource: watch.storyboardSource,
|
|
203
|
+
files: resultFiles(runDir),
|
|
204
|
+
publish: null,
|
|
205
|
+
notify: null,
|
|
206
|
+
grounding: { groundedClaims: watch.claims.length, fixes: [], warnings: [] },
|
|
207
|
+
cost: { totalUsd: 0, budgetUsd, records: [] },
|
|
208
|
+
egress: [],
|
|
209
|
+
warnings: [
|
|
210
|
+
`The earlier result of this run (${RUN_FILE.result}) was not found, so its cost and transfers are not listed.`,
|
|
211
|
+
],
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/** Whether a public link, or a public description, depends on the repository being public. */
|
|
215
|
+
function dependsOnPublicRepository(config) {
|
|
216
|
+
const { publish } = config;
|
|
217
|
+
return ((publish.provider === 's3' && publish.visibility === 'public') ||
|
|
218
|
+
(publish.provider === 'youtube' && publish.youtube.privacyStatus !== 'private'));
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* The privacy of the repository, for the checks that guard public links. A run file that says
|
|
222
|
+
* "public" is only believed when GitHub says so now, because nothing proves who wrote the file.
|
|
223
|
+
* Private stays private, and anything that cannot be confirmed counts as unknown.
|
|
224
|
+
*/
|
|
225
|
+
async function confirmedPrivacy(ctx, stored) {
|
|
226
|
+
if (stored.repoIsPrivate !== false)
|
|
227
|
+
return stored.repoIsPrivate;
|
|
228
|
+
if (!dependsOnPublicRepository(ctx.config) || stored.source !== 'github' || !stored.prUrl)
|
|
229
|
+
return null;
|
|
230
|
+
try {
|
|
231
|
+
const ref = parsePullRequestUrl(stored.prUrl, ctx.config.github.apiUrl);
|
|
232
|
+
const client = await GitHubClient.create(ref, ctx, { stage: 'publish' });
|
|
233
|
+
return (await client.getRepo()).isPrivate;
|
|
234
|
+
}
|
|
235
|
+
catch (err) {
|
|
236
|
+
ctx.logger.debug('Could not confirm that the repository is public', {
|
|
237
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
238
|
+
});
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Publish a run that was rendered earlier (mergestory publish). Lets a person or an agent review
|
|
244
|
+
* the local video first and upload or comment only after approval. No rendering happens here.
|
|
245
|
+
*/
|
|
246
|
+
export async function publishRun(options, hooks = {}) {
|
|
247
|
+
const config = resolveConfig({ overrides: options.config, configPath: options.configPath });
|
|
248
|
+
const runDir = resolveRunDir(options.run, config.home);
|
|
249
|
+
const folder = runFolder(runDir);
|
|
250
|
+
const stored = await readStoredInput(runDir);
|
|
251
|
+
const files = await runFilesIn(runDir);
|
|
252
|
+
const previous = await readPreviousResult(runDir, stored, config.budgetUsd);
|
|
253
|
+
const ctx = createRunContext({
|
|
254
|
+
config,
|
|
255
|
+
runId: stored.runId,
|
|
256
|
+
runDir,
|
|
257
|
+
...(options.logger ? { logger: options.logger } : {}),
|
|
258
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
259
|
+
...(hooks.onProgress ? { onProgress: hooks.onProgress } : {}),
|
|
260
|
+
});
|
|
261
|
+
const trusted = { ...stored, repoIsPrivate: await confirmedPrivacy(ctx, stored) };
|
|
262
|
+
const outcome = await publishAndNotify(ctx, trusted, files);
|
|
263
|
+
const spent = ctx.cost.report();
|
|
264
|
+
const merged = {
|
|
265
|
+
cost: {
|
|
266
|
+
...spent,
|
|
267
|
+
totalUsd: previous.cost.totalUsd + spent.totalUsd,
|
|
268
|
+
records: [...previous.cost.records, ...spent.records],
|
|
269
|
+
},
|
|
270
|
+
egress: [...previous.egress, ...ctx.egress.list()],
|
|
271
|
+
};
|
|
272
|
+
const result = {
|
|
273
|
+
...previous,
|
|
274
|
+
// The folder may have been moved since the run was made.
|
|
275
|
+
runDir,
|
|
276
|
+
files: {
|
|
277
|
+
...previous.files,
|
|
278
|
+
...resultFiles(runDir),
|
|
279
|
+
captions: files.captions ? folder.captions : previous.files.captions,
|
|
280
|
+
},
|
|
281
|
+
publish: outcome.publish ?? previous.publish,
|
|
282
|
+
notify: outcome.notify ?? previous.notify,
|
|
283
|
+
...merged,
|
|
284
|
+
warnings: [
|
|
285
|
+
...previous.warnings.filter((w) => !PUBLISH_WARNING_PREFIXES.some((prefix) => w.startsWith(prefix))),
|
|
286
|
+
...outcome.warnings,
|
|
287
|
+
],
|
|
288
|
+
};
|
|
289
|
+
// A failed upload still leaves its mark: what was sent before it failed is recorded.
|
|
290
|
+
await saveResult(runDir, outcome.failure ? { ...previous, ...merged } : result);
|
|
291
|
+
if (outcome.failure)
|
|
292
|
+
throw outcome.failure;
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=publish-run.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GenerateResult, PlanResult } from '../core/types.ts';
|
|
2
|
+
import type { GenerateHooks, GenerateOptions } from './types.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Make the video for a pull request or a local change: analyse it, write and ground the storyboard,
|
|
5
|
+
* narrate, render, then publish and notify when that is configured. With `dryRun` it only plans.
|
|
6
|
+
*/
|
|
7
|
+
export declare function generate(options: GenerateOptions, hooks?: GenerateHooks): Promise<GenerateResult | PlanResult>;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/** generate(): the whole pipeline, from the change to the published video. */
|
|
2
|
+
import { writeFile } from 'node:fs/promises';
|
|
3
|
+
import { assertNotAborted, MergeStoryError } from '../core/errors.js';
|
|
4
|
+
import { RUN_FILE, resultFiles, runFolder, writeRunJson, } from '../core/run-folder.js';
|
|
5
|
+
import { groundedLines } from '../core/storyboard-facts.js';
|
|
6
|
+
import { assembleNarrationTrack, buildCaptionCues, selectTtsProvider, synthesizeNarration, toSrt, toWebVtt, } from '../narration/index.js';
|
|
7
|
+
import { buildWatchPage, classifyBundle, writeWatchFolder } from '../publish/index.js';
|
|
8
|
+
import { createRenderer } from '../render/index.js';
|
|
9
|
+
import { buildRenderPlan, buildTimeline } from '../visuals/index.js';
|
|
10
|
+
import { publishCommand } from './commands.js';
|
|
11
|
+
import { describeFit } from './fit-duration.js';
|
|
12
|
+
import { unusedScreenshotWarning } from './inputs.js';
|
|
13
|
+
import { planResult } from './plan.js';
|
|
14
|
+
import { prepare } from './prepare.js';
|
|
15
|
+
import { buildWatchPageData } from './presentation.js';
|
|
16
|
+
import { publishAndNotify, saveResult } from './publish-run.js';
|
|
17
|
+
import { chooseStoryboard, fitStoryboard } from './storyboard-choice.js';
|
|
18
|
+
/**
|
|
19
|
+
* The error of a failed upload, with what the person needs to go on: the video was rendered and is
|
|
20
|
+
* kept, and one command uploads it without rendering again.
|
|
21
|
+
*/
|
|
22
|
+
function failedAfterRender(error, runDir, config) {
|
|
23
|
+
const saved = `The video was rendered and is saved in ${runDir}. To upload it without rendering again, run: ${publishCommand(runDir, config)}`;
|
|
24
|
+
return new MergeStoryError(error.code, error.message, {
|
|
25
|
+
hint: error.hint ? `${error.hint} ${saved}` : saved,
|
|
26
|
+
details: { ...error.details, runDir },
|
|
27
|
+
retryable: error.retryable,
|
|
28
|
+
cause: error,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Make the video for a pull request or a local change: analyse it, write and ground the storyboard,
|
|
33
|
+
* narrate, render, then publish and notify when that is configured. With `dryRun` it only plans.
|
|
34
|
+
*/
|
|
35
|
+
export async function generate(options, hooks = {}) {
|
|
36
|
+
const p = await prepare(options, hooks, undefined, { checkPublishing: true });
|
|
37
|
+
const { ctx, config, changeSet, publishProblem } = p;
|
|
38
|
+
const folder = runFolder(ctx.runDir);
|
|
39
|
+
const warnings = [];
|
|
40
|
+
const choice = await chooseStoryboard(p, options.storyboard);
|
|
41
|
+
const { validation } = choice;
|
|
42
|
+
const fit = fitStoryboard(p, choice.storyboard);
|
|
43
|
+
const { storyboard } = fit;
|
|
44
|
+
const groundedClaims = groundedLines(storyboard);
|
|
45
|
+
const groundingWarnings = validation.warnings.map((w) => `${w.path}: ${w.message}`);
|
|
46
|
+
await writeRunJson(folder.storyboard, storyboard);
|
|
47
|
+
await writeRunJson(folder.grounding, {
|
|
48
|
+
groundedClaims,
|
|
49
|
+
fixes: validation.fixes,
|
|
50
|
+
warnings: validation.warnings,
|
|
51
|
+
});
|
|
52
|
+
warnings.push(...groundingWarnings);
|
|
53
|
+
const notices = [
|
|
54
|
+
...describeFit(fit, config.maxDurationSec),
|
|
55
|
+
...[unusedScreenshotWarning(storyboard, p.inputs, choice.source)].filter((w) => w !== null),
|
|
56
|
+
];
|
|
57
|
+
for (const message of notices)
|
|
58
|
+
ctx.progress({ stage: 'validate', status: 'warn', message });
|
|
59
|
+
warnings.push(...notices);
|
|
60
|
+
ctx.progress({
|
|
61
|
+
stage: 'validate',
|
|
62
|
+
status: 'done',
|
|
63
|
+
message: `${groundedClaims} grounded narration lines, ${validation.fixes.length} automatic fixes`,
|
|
64
|
+
});
|
|
65
|
+
assertNotAborted(ctx.signal);
|
|
66
|
+
if (ctx.dryRun)
|
|
67
|
+
return planResult(p, choice, storyboard, warnings, publishProblem);
|
|
68
|
+
// Narration and timing
|
|
69
|
+
const tts = await selectTtsProvider(ctx);
|
|
70
|
+
ctx.progress({ stage: 'narrate', status: 'start', message: `Narrating with ${tts.id}` });
|
|
71
|
+
const narration = await synthesizeNarration(storyboard, tts, ctx);
|
|
72
|
+
const timeline = buildTimeline(storyboard, narration);
|
|
73
|
+
const cues = buildCaptionCues(storyboard, timeline, { maskEmails: config.privacy.maskEmails });
|
|
74
|
+
const audioPath = await assembleNarrationTrack(narration, timeline, folder.audio, ctx, {
|
|
75
|
+
loudness: config.render.normalizeLoudness,
|
|
76
|
+
});
|
|
77
|
+
await writeFile(folder.captions, toWebVtt(cues), { mode: 0o600 });
|
|
78
|
+
await writeFile(folder.captionsSrt, toSrt(cues), { mode: 0o600 });
|
|
79
|
+
ctx.progress({
|
|
80
|
+
stage: 'narrate',
|
|
81
|
+
status: 'done',
|
|
82
|
+
message: `${narration.clips.length} lines, ${timeline.durationSec.toFixed(1)}s`,
|
|
83
|
+
});
|
|
84
|
+
if (!audioPath) {
|
|
85
|
+
warnings.push(config.tts.provider === 'none'
|
|
86
|
+
? 'The video has no voice-over (speech is switched off); captions are included.'
|
|
87
|
+
: 'The video has no voice-over (no speech provider available); captions are included.');
|
|
88
|
+
}
|
|
89
|
+
if (fit.fits && timeline.durationSec > config.maxDurationSec) {
|
|
90
|
+
// Only the estimate is kept within the maximum. A real voice can be slower than the estimate.
|
|
91
|
+
warnings.push(`The finished video is ${Math.round(timeline.durationSec)} s, over the maximum of ${config.maxDurationSec} s (--max-duration): ` +
|
|
92
|
+
`the voice speaks more slowly than the ${Math.round(fit.afterSec)} s estimate that the storyboard was fitted to.`);
|
|
93
|
+
}
|
|
94
|
+
assertNotAborted(ctx.signal);
|
|
95
|
+
// Visuals and rendering
|
|
96
|
+
ctx.progress({ stage: 'visuals', status: 'start', message: 'Resolving code, diagrams and timing' });
|
|
97
|
+
const plan = await buildRenderPlan({
|
|
98
|
+
storyboard,
|
|
99
|
+
timeline,
|
|
100
|
+
cues,
|
|
101
|
+
changeSet,
|
|
102
|
+
analysis: p.analysis,
|
|
103
|
+
inputs: p.inputs,
|
|
104
|
+
reader: p.reader,
|
|
105
|
+
config,
|
|
106
|
+
}, ctx);
|
|
107
|
+
await writeRunJson(folder.renderPlan, plan);
|
|
108
|
+
ctx.progress({ stage: 'visuals', status: 'done', message: `${plan.scenes.length} scenes` });
|
|
109
|
+
assertNotAborted(ctx.signal);
|
|
110
|
+
ctx.progress({
|
|
111
|
+
stage: 'render',
|
|
112
|
+
status: 'start',
|
|
113
|
+
message: `Rendering ${plan.width}x${plan.height} at ${plan.fps} fps`,
|
|
114
|
+
});
|
|
115
|
+
const rendered = await createRenderer(config).render({ plan, audioPath, outDir: ctx.runDir, quality: config.quality }, ctx);
|
|
116
|
+
ctx.progress({
|
|
117
|
+
stage: 'render',
|
|
118
|
+
status: 'done',
|
|
119
|
+
message: `${rendered.durationSec.toFixed(1)}s video, ${(rendered.sizeBytes / 1e6).toFixed(1)} MB`,
|
|
120
|
+
});
|
|
121
|
+
assertNotAborted(ctx.signal);
|
|
122
|
+
// Watch page (always written locally) and publishing
|
|
123
|
+
const generatedAt = new Date().toISOString();
|
|
124
|
+
const generator = {
|
|
125
|
+
llm: choice.source === 'llm' ? `${choice.provider.id} ${choice.provider.model}` : null,
|
|
126
|
+
tts: tts.id,
|
|
127
|
+
};
|
|
128
|
+
const localWatchData = buildWatchPageData({
|
|
129
|
+
storyboard,
|
|
130
|
+
storyboardSource: choice.source,
|
|
131
|
+
changeSet,
|
|
132
|
+
analysis: p.analysis,
|
|
133
|
+
chapters: plan.chapters,
|
|
134
|
+
durationSec: rendered.durationSec,
|
|
135
|
+
generator,
|
|
136
|
+
generatedAt,
|
|
137
|
+
captionsBurnedIn: config.captions,
|
|
138
|
+
});
|
|
139
|
+
await writeWatchFolder({
|
|
140
|
+
dir: folder.watchDir,
|
|
141
|
+
files: await classifyBundle({
|
|
142
|
+
files: [
|
|
143
|
+
{ name: RUN_FILE.video, path: rendered.videoPath },
|
|
144
|
+
...(rendered.posterPath ? [{ name: RUN_FILE.poster, path: rendered.posterPath }] : []),
|
|
145
|
+
{ name: RUN_FILE.captions, path: folder.captions },
|
|
146
|
+
],
|
|
147
|
+
}),
|
|
148
|
+
buildPage: (urls) => buildWatchPage(localWatchData, urls),
|
|
149
|
+
// The cues are at hand, so the page does not read them back from the caption file.
|
|
150
|
+
captionCues: cues,
|
|
151
|
+
pageMode: 0o600,
|
|
152
|
+
});
|
|
153
|
+
// No file paths here: the files are always the fixed names in the run folder (see runFolder).
|
|
154
|
+
const stored = {
|
|
155
|
+
version: 1,
|
|
156
|
+
runId: ctx.runId,
|
|
157
|
+
source: changeSet.source,
|
|
158
|
+
prUrl: changeSet.pr?.url ?? null,
|
|
159
|
+
repoIsPrivate: changeSet.repo.isPrivate,
|
|
160
|
+
headSha: changeSet.head.sha,
|
|
161
|
+
language: storyboard.language,
|
|
162
|
+
watch: localWatchData,
|
|
163
|
+
};
|
|
164
|
+
await writeRunJson(folder.publishInput, stored);
|
|
165
|
+
const resultFor = (outcome) => ({
|
|
166
|
+
ok: true,
|
|
167
|
+
runId: ctx.runId,
|
|
168
|
+
runDir: ctx.runDir,
|
|
169
|
+
title: storyboard.title,
|
|
170
|
+
summary: storyboard.summary,
|
|
171
|
+
durationSec: rendered.durationSec,
|
|
172
|
+
chapters: plan.chapters,
|
|
173
|
+
storyboardSource: choice.source,
|
|
174
|
+
files: { ...resultFiles(ctx.runDir), poster: rendered.posterPath ? folder.poster : null },
|
|
175
|
+
publish: outcome.publish,
|
|
176
|
+
notify: outcome.notify,
|
|
177
|
+
grounding: { groundedClaims, fixes: validation.fixes, warnings: groundingWarnings },
|
|
178
|
+
cost: ctx.cost.report(),
|
|
179
|
+
egress: ctx.egress.list(),
|
|
180
|
+
warnings: [...warnings, ...outcome.warnings],
|
|
181
|
+
});
|
|
182
|
+
// From here on the run is usable: `mergestory publish` can upload it even if publishing fails now.
|
|
183
|
+
await saveResult(ctx.runDir, resultFor({ publish: null, notify: null, warnings: [] }));
|
|
184
|
+
const outcome = await publishAndNotify(ctx, stored, {
|
|
185
|
+
video: rendered.videoPath,
|
|
186
|
+
poster: rendered.posterPath,
|
|
187
|
+
captions: folder.captions,
|
|
188
|
+
});
|
|
189
|
+
const result = resultFor(outcome);
|
|
190
|
+
// Also after a failed upload: what was sent before it failed is part of the record.
|
|
191
|
+
await saveResult(ctx.runDir, result);
|
|
192
|
+
if (outcome.failure)
|
|
193
|
+
throw failedAfterRender(outcome.failure, ctx.runDir, config);
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The storyboard stage: use the one the caller wrote, ask the model, or build the offline one.
|
|
3
|
+
* Whatever the source, the result has passed the grounding validator.
|
|
4
|
+
*/
|
|
5
|
+
import type { LlmProvider } from '../core/providers.ts';
|
|
6
|
+
import { type Storyboard } from '../core/storyboard-schema.ts';
|
|
7
|
+
import { type ValidationResult } from '../storyboard/index.ts';
|
|
8
|
+
import { type FitResult } from './fit-duration.ts';
|
|
9
|
+
import { type Prepared } from './prepare.ts';
|
|
10
|
+
/** What a dry run works out about the model call that it does not make. */
|
|
11
|
+
export interface PlannedLlm {
|
|
12
|
+
inputTokens: number;
|
|
13
|
+
outputTokens: number;
|
|
14
|
+
costUsd: number | null;
|
|
15
|
+
promptBytes: number;
|
|
16
|
+
}
|
|
17
|
+
/** The storyboard and where it came from. Only a model storyboard has a provider. */
|
|
18
|
+
export type StoryboardChoice = {
|
|
19
|
+
storyboard: Storyboard;
|
|
20
|
+
validation: ValidationResult;
|
|
21
|
+
} & ({
|
|
22
|
+
source: 'agent';
|
|
23
|
+
} | {
|
|
24
|
+
source: 'heuristic';
|
|
25
|
+
} | {
|
|
26
|
+
source: 'llm';
|
|
27
|
+
provider: LlmProvider;
|
|
28
|
+
/** Set in dry runs: the model was not called; the offline storyboard stands in for planning. */
|
|
29
|
+
plannedLlm: PlannedLlm | null;
|
|
30
|
+
});
|
|
31
|
+
/** Get the storyboard for this run. `supplied` is a storyboard that the caller wrote, if any. */
|
|
32
|
+
export declare function chooseStoryboard(p: Prepared, supplied: unknown): Promise<StoryboardChoice>;
|
|
33
|
+
/** Trim the storyboard to the maximum length (see fit-duration.ts for what that does and guarantees). */
|
|
34
|
+
export declare function fitStoryboard(p: Prepared, storyboard: Storyboard): FitResult;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The storyboard stage: use the one the caller wrote, ask the model, or build the offline one.
|
|
3
|
+
* Whatever the source, the result has passed the grounding validator.
|
|
4
|
+
*/
|
|
5
|
+
import { writeFile } from 'node:fs/promises';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { MergeStoryError, toMergeStoryError } from '../core/errors.js';
|
|
8
|
+
import { RUN_FILE } from '../core/run-folder.js';
|
|
9
|
+
import { BACKING_EVIDENCE_KINDS } from '../core/storyboard-facts.js';
|
|
10
|
+
import { storyboardJsonSchemaForLlm } from '../core/storyboard-schema.js';
|
|
11
|
+
import { createLlmProvider } from '../llm/index.js';
|
|
12
|
+
import { buildSystemPrompt, estimateStoryboardCost, generateStoryboard, heuristicStoryboard, validateStoryboard, } from '../storyboard/index.js';
|
|
13
|
+
import { fitToMaxDuration } from './fit-duration.js';
|
|
14
|
+
import { packFor } from './prepare.js';
|
|
15
|
+
function validationDeps(p) {
|
|
16
|
+
return {
|
|
17
|
+
changeSet: p.changeSet,
|
|
18
|
+
analysis: p.analysis,
|
|
19
|
+
inputs: p.inputs,
|
|
20
|
+
reader: p.reader,
|
|
21
|
+
config: p.config,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async function offlineStoryboard(p) {
|
|
25
|
+
const draft = heuristicStoryboard(p.changeSet, p.analysis, p.inputs, p.config, p.targetSec);
|
|
26
|
+
const validation = await validateStoryboard(draft, { ...validationDeps(p), offline: true });
|
|
27
|
+
if (!validation.storyboard) {
|
|
28
|
+
throw new MergeStoryError('INTERNAL', 'The offline storyboard did not pass validation.', {
|
|
29
|
+
details: { errors: validation.errors.slice(0, 10) },
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return { storyboard: validation.storyboard, validation };
|
|
33
|
+
}
|
|
34
|
+
/** The storyboard that the caller wrote, checked. */
|
|
35
|
+
async function suppliedStoryboard(p, supplied) {
|
|
36
|
+
const validation = await validateStoryboard(supplied, validationDeps(p));
|
|
37
|
+
if (!validation.storyboard) {
|
|
38
|
+
throw new MergeStoryError('GROUNDING_FAILED', `The supplied storyboard has ${validation.errors.length} problem(s) that block rendering.`, {
|
|
39
|
+
hint: 'Fix the listed problems and run again. `mergestory validate <storyboard.json> <source>` checks without rendering.',
|
|
40
|
+
details: { errors: validation.errors.slice(0, 40), warnings: validation.warnings.slice(0, 20) },
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
p.ctx.progress({ stage: 'storyboard', status: 'done', message: 'Using the supplied storyboard' });
|
|
44
|
+
return { storyboard: validation.storyboard, validation, source: 'agent' };
|
|
45
|
+
}
|
|
46
|
+
/** A model storyboard, or (in a dry run) the plan for one. Falls back to the offline storyboard when the model fails. */
|
|
47
|
+
async function modelStoryboard(p, provider) {
|
|
48
|
+
const { ctx } = p;
|
|
49
|
+
const pack = packFor(p, p.config.llm.maxInputTokens);
|
|
50
|
+
await writeFile(join(ctx.runDir, RUN_FILE.evidence), pack.markdown, { mode: 0o600 });
|
|
51
|
+
if (ctx.dryRun) {
|
|
52
|
+
const estimate = estimateStoryboardCost(provider, pack, p.config, ctx);
|
|
53
|
+
const out = await offlineStoryboard(p);
|
|
54
|
+
ctx.progress({
|
|
55
|
+
stage: 'storyboard',
|
|
56
|
+
status: 'skip',
|
|
57
|
+
message: `Dry run: ${provider.id} would be called (${provider.model})`,
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
...out,
|
|
61
|
+
source: 'llm',
|
|
62
|
+
provider,
|
|
63
|
+
plannedLlm: {
|
|
64
|
+
...estimate,
|
|
65
|
+
// The model receives the system prompt and the schema as well as the evidence pack.
|
|
66
|
+
promptBytes: Buffer.byteLength(pack.markdown) +
|
|
67
|
+
Buffer.byteLength(buildSystemPrompt(p.config)) +
|
|
68
|
+
Buffer.byteLength(JSON.stringify(storyboardJsonSchemaForLlm())),
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const result = await generateStoryboard({ provider, pack, deps: validationDeps(p), targetSec: p.targetSec }, ctx);
|
|
74
|
+
ctx.progress({
|
|
75
|
+
stage: 'storyboard',
|
|
76
|
+
status: 'done',
|
|
77
|
+
message: `Storyboard from ${provider.model}${result.cached ? ' (cached)' : ''}, ${result.attempts} attempt(s)`,
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
storyboard: result.storyboard,
|
|
81
|
+
validation: result.validation,
|
|
82
|
+
source: 'llm',
|
|
83
|
+
provider,
|
|
84
|
+
plannedLlm: null,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
const error = toMergeStoryError(err, 'LLM_FAILED');
|
|
89
|
+
if (error.code === 'BUDGET_EXCEEDED' || error.code === 'ABORTED' || error.code === 'CONFIG_INVALID')
|
|
90
|
+
throw error;
|
|
91
|
+
ctx.progress({
|
|
92
|
+
stage: 'storyboard',
|
|
93
|
+
status: 'warn',
|
|
94
|
+
message: `LLM storyboard failed (${error.message}); using the offline storyboard instead`,
|
|
95
|
+
});
|
|
96
|
+
return { ...(await offlineStoryboard(p)), source: 'heuristic' };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** Get the storyboard for this run. `supplied` is a storyboard that the caller wrote, if any. */
|
|
100
|
+
export async function chooseStoryboard(p, supplied) {
|
|
101
|
+
const { ctx } = p;
|
|
102
|
+
ctx.progress({ stage: 'storyboard', status: 'start', message: 'Building the storyboard' });
|
|
103
|
+
if (supplied !== undefined)
|
|
104
|
+
return suppliedStoryboard(p, supplied);
|
|
105
|
+
const provider = createLlmProvider(p.config, ctx.secrets);
|
|
106
|
+
if (provider)
|
|
107
|
+
return modelStoryboard(p, provider);
|
|
108
|
+
const out = await offlineStoryboard(p);
|
|
109
|
+
ctx.progress({
|
|
110
|
+
stage: 'storyboard',
|
|
111
|
+
status: 'done',
|
|
112
|
+
message: 'Built an offline storyboard (no LLM configured)',
|
|
113
|
+
});
|
|
114
|
+
return { ...out, source: 'heuristic' };
|
|
115
|
+
}
|
|
116
|
+
/** Ids of the changed files, hunks and symbols: what shows that simulated behaviour exists in the change. */
|
|
117
|
+
function backingEvidence(analysis) {
|
|
118
|
+
return new Set(analysis.evidence.filter((item) => BACKING_EVIDENCE_KINDS.includes(item.kind)).map((item) => item.id));
|
|
119
|
+
}
|
|
120
|
+
/** Trim the storyboard to the maximum length (see fit-duration.ts for what that does and guarantees). */
|
|
121
|
+
export function fitStoryboard(p, storyboard) {
|
|
122
|
+
return fitToMaxDuration(storyboard, {
|
|
123
|
+
maxSec: p.config.maxDurationSec,
|
|
124
|
+
language: p.config.language,
|
|
125
|
+
maskEmails: p.config.privacy.maskEmails,
|
|
126
|
+
backingEvidence: backingEvidence(p.analysis),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=storyboard-choice.js.map
|