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.
Files changed (474) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +2 -0
  3. package/README.md +48 -2
  4. package/assets/kokoro-plugin/package-lock.json +1139 -0
  5. package/dist/analyzer/analyze.d.ts +8 -0
  6. package/dist/analyzer/analyze.js +328 -0
  7. package/dist/analyzer/components.d.ts +18 -0
  8. package/dist/analyzer/components.js +266 -0
  9. package/dist/analyzer/dependencies.d.ts +13 -0
  10. package/dist/analyzer/dependencies.js +349 -0
  11. package/dist/analyzer/evidence.d.ts +15 -0
  12. package/dist/analyzer/evidence.js +73 -0
  13. package/dist/analyzer/hunks.d.ts +21 -0
  14. package/dist/analyzer/hunks.js +88 -0
  15. package/dist/analyzer/imports.d.ts +46 -0
  16. package/dist/analyzer/imports.js +87 -0
  17. package/dist/analyzer/index.d.ts +14 -0
  18. package/dist/analyzer/index.js +16 -0
  19. package/dist/analyzer/languages/go.d.ts +2 -0
  20. package/dist/analyzer/languages/go.js +76 -0
  21. package/dist/analyzer/languages/index.d.ts +18 -0
  22. package/dist/analyzer/languages/index.js +72 -0
  23. package/dist/analyzer/languages/javascript.d.ts +2 -0
  24. package/dist/analyzer/languages/javascript.js +336 -0
  25. package/dist/analyzer/languages/jvm.d.ts +2 -0
  26. package/dist/analyzer/languages/jvm.js +157 -0
  27. package/dist/analyzer/languages/others.d.ts +2 -0
  28. package/dist/analyzer/languages/others.js +40 -0
  29. package/dist/analyzer/languages/php.d.ts +2 -0
  30. package/dist/analyzer/languages/php.js +81 -0
  31. package/dist/analyzer/languages/python.d.ts +2 -0
  32. package/dist/analyzer/languages/python.js +180 -0
  33. package/dist/analyzer/languages/ruby.d.ts +2 -0
  34. package/dist/analyzer/languages/ruby.js +99 -0
  35. package/dist/analyzer/languages/rust.d.ts +2 -0
  36. package/dist/analyzer/languages/rust.js +164 -0
  37. package/dist/analyzer/languages/shared.d.ts +35 -0
  38. package/dist/analyzer/languages/shared.js +43 -0
  39. package/dist/analyzer/languages/types.d.ts +78 -0
  40. package/dist/analyzer/languages/types.js +2 -0
  41. package/dist/analyzer/pack-format.d.ts +27 -0
  42. package/dist/analyzer/pack-format.js +139 -0
  43. package/dist/analyzer/pack.d.ts +26 -0
  44. package/dist/analyzer/pack.js +498 -0
  45. package/dist/analyzer/relationships.d.ts +17 -0
  46. package/dist/analyzer/relationships.js +34 -0
  47. package/dist/analyzer/risk-rules.d.ts +287 -0
  48. package/dist/analyzer/risk-rules.js +373 -0
  49. package/dist/analyzer/risks.d.ts +36 -0
  50. package/dist/analyzer/risks.js +480 -0
  51. package/dist/analyzer/roles.d.ts +11 -0
  52. package/dist/analyzer/roles.js +280 -0
  53. package/dist/analyzer/scan.d.ts +26 -0
  54. package/dist/analyzer/scan.js +157 -0
  55. package/dist/analyzer/signals.d.ts +20 -0
  56. package/dist/analyzer/signals.js +51 -0
  57. package/dist/analyzer/symbol-changes.d.ts +11 -0
  58. package/dist/analyzer/symbol-changes.js +101 -0
  59. package/dist/analyzer/symbol-types.d.ts +17 -0
  60. package/dist/analyzer/symbol-types.js +9 -0
  61. package/dist/analyzer/symbols.d.ts +4 -0
  62. package/dist/analyzer/symbols.js +16 -0
  63. package/dist/analyzer/trivial.d.ts +13 -0
  64. package/dist/analyzer/trivial.js +137 -0
  65. package/dist/analyzer/util.d.ts +6 -0
  66. package/dist/analyzer/util.js +24 -0
  67. package/dist/cli/commands/authoring.d.ts +9 -0
  68. package/dist/cli/commands/authoring.js +98 -0
  69. package/dist/cli/commands/cache.d.ts +4 -0
  70. package/dist/cli/commands/cache.js +37 -0
  71. package/dist/cli/commands/doctor.d.ts +5 -0
  72. package/dist/cli/commands/doctor.js +37 -0
  73. package/dist/cli/commands/generate.d.ts +8 -0
  74. package/dist/cli/commands/generate.js +69 -0
  75. package/dist/cli/commands/jobs.d.ts +8 -0
  76. package/dist/cli/commands/jobs.js +70 -0
  77. package/dist/cli/commands/publish.d.ts +8 -0
  78. package/dist/cli/commands/publish.js +120 -0
  79. package/dist/cli/commands/serve.d.ts +4 -0
  80. package/dist/cli/commands/serve.js +69 -0
  81. package/dist/cli/commands/setup.d.ts +14 -0
  82. package/dist/cli/commands/setup.js +108 -0
  83. package/dist/cli/commands/shared.d.ts +18 -0
  84. package/dist/cli/commands/shared.js +24 -0
  85. package/dist/cli/files.d.ts +26 -0
  86. package/dist/cli/files.js +98 -0
  87. package/dist/cli/format.d.ts +55 -0
  88. package/dist/cli/format.js +295 -0
  89. package/dist/cli/inputs.d.ts +23 -0
  90. package/dist/cli/inputs.js +96 -0
  91. package/dist/cli/io.d.ts +19 -0
  92. package/dist/cli/io.js +31 -0
  93. package/dist/cli/main.d.ts +2 -0
  94. package/dist/cli/main.js +15 -0
  95. package/dist/cli/options.d.ts +105 -0
  96. package/dist/cli/options.js +324 -0
  97. package/dist/cli/program.d.ts +12 -0
  98. package/dist/cli/program.js +146 -0
  99. package/dist/cli/runtime.d.ts +59 -0
  100. package/dist/cli/runtime.js +83 -0
  101. package/dist/cli/style.d.ts +13 -0
  102. package/dist/cli/style.js +27 -0
  103. package/dist/core/binaries.d.ts +7 -0
  104. package/dist/core/binaries.js +33 -0
  105. package/dist/core/binary-paths.d.ts +5 -0
  106. package/dist/core/binary-paths.js +92 -0
  107. package/dist/core/cache.d.ts +14 -0
  108. package/dist/core/cache.js +43 -0
  109. package/dist/core/child-env.d.ts +9 -0
  110. package/dist/core/child-env.js +61 -0
  111. package/dist/core/concurrency.d.ts +13 -0
  112. package/dist/core/concurrency.js +58 -0
  113. package/dist/core/config.d.ts +223 -0
  114. package/dist/core/config.js +454 -0
  115. package/dist/core/context.d.ts +39 -0
  116. package/dist/core/context.js +44 -0
  117. package/dist/core/cost.d.ts +46 -0
  118. package/dist/core/cost.js +108 -0
  119. package/dist/core/diagram-metrics.d.ts +57 -0
  120. package/dist/core/diagram-metrics.js +63 -0
  121. package/dist/core/diff-view.d.ts +44 -0
  122. package/dist/core/diff-view.js +136 -0
  123. package/dist/core/errors.d.ts +47 -0
  124. package/dist/core/errors.js +94 -0
  125. package/dist/core/ids.d.ts +11 -0
  126. package/dist/core/ids.js +36 -0
  127. package/dist/core/json.d.ts +8 -0
  128. package/dist/core/json.js +17 -0
  129. package/dist/core/languages.d.ts +19 -0
  130. package/dist/core/languages.js +292 -0
  131. package/dist/core/logger.d.ts +29 -0
  132. package/dist/core/logger.js +68 -0
  133. package/dist/core/net.d.ts +16 -0
  134. package/dist/core/net.js +80 -0
  135. package/dist/core/path-policy.d.ts +20 -0
  136. package/dist/core/path-policy.js +202 -0
  137. package/dist/core/paths.d.ts +18 -0
  138. package/dist/core/paths.js +53 -0
  139. package/dist/core/posix.d.ts +12 -0
  140. package/dist/core/posix.js +50 -0
  141. package/dist/core/process.d.ts +22 -0
  142. package/dist/core/process.js +117 -0
  143. package/dist/core/providers.d.ts +204 -0
  144. package/dist/core/providers.js +2 -0
  145. package/dist/core/redact.d.ts +11 -0
  146. package/dist/core/redact.js +70 -0
  147. package/dist/core/render-plan.d.ts +307 -0
  148. package/dist/core/render-plan.js +7 -0
  149. package/dist/core/retry.d.ts +54 -0
  150. package/dist/core/retry.js +116 -0
  151. package/dist/core/run-folder.d.ts +74 -0
  152. package/dist/core/run-folder.js +129 -0
  153. package/dist/core/secrets.d.ts +56 -0
  154. package/dist/core/secrets.js +301 -0
  155. package/dist/core/storyboard-facts.d.ts +22 -0
  156. package/dist/core/storyboard-facts.js +61 -0
  157. package/dist/core/storyboard-schema.d.ts +1279 -0
  158. package/dist/core/storyboard-schema.js +342 -0
  159. package/dist/core/text.d.ts +43 -0
  160. package/dist/core/text.js +94 -0
  161. package/dist/core/types.d.ts +459 -0
  162. package/dist/core/types.js +17 -0
  163. package/dist/doctor/check.d.ts +6 -0
  164. package/dist/doctor/check.js +18 -0
  165. package/dist/doctor/deps.d.ts +2 -0
  166. package/dist/doctor/deps.js +90 -0
  167. package/dist/doctor/format.d.ts +9 -0
  168. package/dist/doctor/format.js +19 -0
  169. package/dist/doctor/github.d.ts +2 -0
  170. package/dist/doctor/github.js +13 -0
  171. package/dist/doctor/home.d.ts +2 -0
  172. package/dist/doctor/home.js +26 -0
  173. package/dist/doctor/index.d.ts +18 -0
  174. package/dist/doctor/index.js +81 -0
  175. package/dist/doctor/llm.d.ts +2 -0
  176. package/dist/doctor/llm.js +32 -0
  177. package/dist/doctor/publish.d.ts +2 -0
  178. package/dist/doctor/publish.js +16 -0
  179. package/dist/doctor/s3.d.ts +2 -0
  180. package/dist/doctor/s3.js +125 -0
  181. package/dist/doctor/speech.d.ts +2 -0
  182. package/dist/doctor/speech.js +112 -0
  183. package/dist/doctor/tools.d.ts +5 -0
  184. package/dist/doctor/tools.js +58 -0
  185. package/dist/doctor/types.d.ts +92 -0
  186. package/dist/doctor/types.js +2 -0
  187. package/dist/doctor/youtube.d.ts +2 -0
  188. package/dist/doctor/youtube.js +73 -0
  189. package/dist/github/client.d.ts +108 -0
  190. package/dist/github/client.js +499 -0
  191. package/dist/github/errors.d.ts +37 -0
  192. package/dist/github/errors.js +155 -0
  193. package/dist/github/index.d.ts +13 -0
  194. package/dist/github/index.js +9 -0
  195. package/dist/github/linked-issues.d.ts +37 -0
  196. package/dist/github/linked-issues.js +131 -0
  197. package/dist/github/model.d.ts +81 -0
  198. package/dist/github/model.js +114 -0
  199. package/dist/github/notify.d.ts +27 -0
  200. package/dist/github/notify.js +118 -0
  201. package/dist/github/pr-url.d.ts +27 -0
  202. package/dist/github/pr-url.js +122 -0
  203. package/dist/github/token.d.ts +16 -0
  204. package/dist/github/token.js +69 -0
  205. package/dist/index.d.ts +29 -0
  206. package/dist/index.js +19 -0
  207. package/dist/jobs/input-rules.d.ts +20 -0
  208. package/dist/jobs/input-rules.js +100 -0
  209. package/dist/jobs/model.d.ts +47 -0
  210. package/dist/jobs/model.js +18 -0
  211. package/dist/jobs/runner.d.ts +43 -0
  212. package/dist/jobs/runner.js +165 -0
  213. package/dist/jobs/store.d.ts +67 -0
  214. package/dist/jobs/store.js +314 -0
  215. package/dist/jobs/view.d.ts +48 -0
  216. package/dist/jobs/view.js +111 -0
  217. package/dist/jobs/worker.d.ts +24 -0
  218. package/dist/jobs/worker.js +47 -0
  219. package/dist/llm/anthropic.d.ts +11 -0
  220. package/dist/llm/anthropic.js +225 -0
  221. package/dist/llm/index.d.ts +10 -0
  222. package/dist/llm/index.js +27 -0
  223. package/dist/llm/openai-compatible.d.ts +33 -0
  224. package/dist/llm/openai-compatible.js +378 -0
  225. package/dist/llm/prices.d.ts +26 -0
  226. package/dist/llm/prices.js +41 -0
  227. package/dist/llm/shared.d.ts +30 -0
  228. package/dist/llm/shared.js +115 -0
  229. package/dist/narration/assemble.d.ts +36 -0
  230. package/dist/narration/assemble.js +282 -0
  231. package/dist/narration/audio.d.ts +61 -0
  232. package/dist/narration/audio.js +301 -0
  233. package/dist/narration/captions.d.ts +37 -0
  234. package/dist/narration/captions.js +195 -0
  235. package/dist/narration/chunking.d.ts +6 -0
  236. package/dist/narration/chunking.js +46 -0
  237. package/dist/narration/convert.d.ts +9 -0
  238. package/dist/narration/convert.js +90 -0
  239. package/dist/narration/elevenlabs.d.ts +5 -0
  240. package/dist/narration/elevenlabs.js +53 -0
  241. package/dist/narration/http-errors.d.ts +14 -0
  242. package/dist/narration/http-errors.js +74 -0
  243. package/dist/narration/index.d.ts +21 -0
  244. package/dist/narration/index.js +22 -0
  245. package/dist/narration/kokoro-install.d.ts +30 -0
  246. package/dist/narration/kokoro-install.js +284 -0
  247. package/dist/narration/kokoro-model.d.ts +54 -0
  248. package/dist/narration/kokoro-model.js +168 -0
  249. package/dist/narration/kokoro-plugin.d.ts +78 -0
  250. package/dist/narration/kokoro-plugin.js +245 -0
  251. package/dist/narration/kokoro.d.ts +22 -0
  252. package/dist/narration/kokoro.js +231 -0
  253. package/dist/narration/openai.d.ts +4 -0
  254. package/dist/narration/openai.js +54 -0
  255. package/dist/narration/pricing.d.ts +8 -0
  256. package/dist/narration/pricing.js +17 -0
  257. package/dist/narration/remote-speech.d.ts +53 -0
  258. package/dist/narration/remote-speech.js +100 -0
  259. package/dist/narration/say.d.ts +28 -0
  260. package/dist/narration/say.js +178 -0
  261. package/dist/narration/select.d.ts +27 -0
  262. package/dist/narration/select.js +80 -0
  263. package/dist/narration/silent.d.ts +2 -0
  264. package/dist/narration/silent.js +18 -0
  265. package/dist/narration/speakable.d.ts +20 -0
  266. package/dist/narration/speakable.js +398 -0
  267. package/dist/narration/synthesize.d.ts +25 -0
  268. package/dist/narration/synthesize.js +220 -0
  269. package/dist/narration/wav.d.ts +37 -0
  270. package/dist/narration/wav.js +170 -0
  271. package/dist/pipeline/authoring.d.ts +8 -0
  272. package/dist/pipeline/authoring.js +117 -0
  273. package/dist/pipeline/commands.d.ts +9 -0
  274. package/dist/pipeline/commands.js +21 -0
  275. package/dist/pipeline/fit-duration.d.ts +41 -0
  276. package/dist/pipeline/fit-duration.js +150 -0
  277. package/dist/pipeline/index.d.ts +9 -0
  278. package/dist/pipeline/index.js +9 -0
  279. package/dist/pipeline/inputs.d.ts +42 -0
  280. package/dist/pipeline/inputs.js +171 -0
  281. package/dist/pipeline/plan.d.ts +8 -0
  282. package/dist/pipeline/plan.js +85 -0
  283. package/dist/pipeline/planned-egress.d.ts +21 -0
  284. package/dist/pipeline/planned-egress.js +43 -0
  285. package/dist/pipeline/prepare.d.ts +26 -0
  286. package/dist/pipeline/prepare.js +84 -0
  287. package/dist/pipeline/presentation.d.ts +26 -0
  288. package/dist/pipeline/presentation.js +110 -0
  289. package/dist/pipeline/publish-run.d.ts +71 -0
  290. package/dist/pipeline/publish-run.js +295 -0
  291. package/dist/pipeline/run.d.ts +7 -0
  292. package/dist/pipeline/run.js +196 -0
  293. package/dist/pipeline/storyboard-choice.d.ts +34 -0
  294. package/dist/pipeline/storyboard-choice.js +129 -0
  295. package/dist/pipeline/types.d.ts +76 -0
  296. package/dist/pipeline/types.js +2 -0
  297. package/dist/publish/access-probe.d.ts +55 -0
  298. package/dist/publish/access-probe.js +249 -0
  299. package/dist/publish/bundle.d.ts +20 -0
  300. package/dist/publish/bundle.js +57 -0
  301. package/dist/publish/comment.d.ts +10 -0
  302. package/dist/publish/comment.js +184 -0
  303. package/dist/publish/content-types.d.ts +15 -0
  304. package/dist/publish/content-types.js +41 -0
  305. package/dist/publish/index.d.ts +18 -0
  306. package/dist/publish/index.js +30 -0
  307. package/dist/publish/keys.d.ts +10 -0
  308. package/dist/publish/keys.js +30 -0
  309. package/dist/publish/local.d.ts +33 -0
  310. package/dist/publish/local.js +143 -0
  311. package/dist/publish/privacy.d.ts +20 -0
  312. package/dist/publish/privacy.js +21 -0
  313. package/dist/publish/s3/bucket.d.ts +22 -0
  314. package/dist/publish/s3/bucket.js +82 -0
  315. package/dist/publish/s3/client.d.ts +33 -0
  316. package/dist/publish/s3/client.js +134 -0
  317. package/dist/publish/s3/failures.d.ts +22 -0
  318. package/dist/publish/s3/failures.js +110 -0
  319. package/dist/publish/s3/index.d.ts +5 -0
  320. package/dist/publish/s3/index.js +6 -0
  321. package/dist/publish/s3/links.d.ts +38 -0
  322. package/dist/publish/s3/links.js +60 -0
  323. package/dist/publish/s3/protected-links.d.ts +29 -0
  324. package/dist/publish/s3/protected-links.js +67 -0
  325. package/dist/publish/s3/publisher.d.ts +32 -0
  326. package/dist/publish/s3/publisher.js +123 -0
  327. package/dist/publish/s3/settings.d.ts +29 -0
  328. package/dist/publish/s3/settings.js +64 -0
  329. package/dist/publish/s3/upload.d.ts +29 -0
  330. package/dist/publish/s3/upload.js +145 -0
  331. package/dist/publish/severity.d.ts +9 -0
  332. package/dist/publish/severity.js +18 -0
  333. package/dist/publish/text.d.ts +23 -0
  334. package/dist/publish/text.js +94 -0
  335. package/dist/publish/types.d.ts +67 -0
  336. package/dist/publish/types.js +12 -0
  337. package/dist/publish/vtt.d.ts +9 -0
  338. package/dist/publish/vtt.js +43 -0
  339. package/dist/publish/watch-page.d.ts +4 -0
  340. package/dist/publish/watch-page.js +463 -0
  341. package/dist/publish/youtube/credentials.d.ts +33 -0
  342. package/dist/publish/youtube/credentials.js +162 -0
  343. package/dist/publish/youtube/description.d.ts +56 -0
  344. package/dist/publish/youtube/description.js +197 -0
  345. package/dist/publish/youtube/google-api.d.ts +95 -0
  346. package/dist/publish/youtube/google-api.js +339 -0
  347. package/dist/publish/youtube/index.d.ts +7 -0
  348. package/dist/publish/youtube/index.js +8 -0
  349. package/dist/publish/youtube/loopback.d.ts +13 -0
  350. package/dist/publish/youtube/loopback.js +144 -0
  351. package/dist/publish/youtube/oauth.d.ts +68 -0
  352. package/dist/publish/youtube/oauth.js +159 -0
  353. package/dist/publish/youtube/prompt.d.ts +27 -0
  354. package/dist/publish/youtube/prompt.js +94 -0
  355. package/dist/publish/youtube/publisher.d.ts +38 -0
  356. package/dist/publish/youtube/publisher.js +346 -0
  357. package/dist/publish/youtube/scopes.d.ts +32 -0
  358. package/dist/publish/youtube/scopes.js +55 -0
  359. package/dist/publish/youtube/sign-in.d.ts +37 -0
  360. package/dist/publish/youtube/sign-in.js +137 -0
  361. package/dist/publish/youtube/upload.d.ts +43 -0
  362. package/dist/publish/youtube/upload.js +210 -0
  363. package/dist/render/browser.d.ts +23 -0
  364. package/dist/render/browser.js +219 -0
  365. package/dist/render/chromium-renderer.d.ts +56 -0
  366. package/dist/render/chromium-renderer.js +519 -0
  367. package/dist/render/ffmpeg.d.ts +55 -0
  368. package/dist/render/ffmpeg.js +212 -0
  369. package/dist/render/fonts.d.ts +10 -0
  370. package/dist/render/fonts.js +42 -0
  371. package/dist/render/index.d.ts +9 -0
  372. package/dist/render/index.js +11 -0
  373. package/dist/render/page.d.ts +46 -0
  374. package/dist/render/page.js +123 -0
  375. package/dist/render/playwright.d.ts +3 -0
  376. package/dist/render/playwright.js +6 -0
  377. package/dist/render/runtime-bundle.d.ts +2 -0
  378. package/dist/render/runtime-bundle.js +72 -0
  379. package/dist/runtime/runtime.js +1626 -0
  380. package/dist/server/auth.d.ts +17 -0
  381. package/dist/server/auth.js +58 -0
  382. package/dist/server/http.d.ts +43 -0
  383. package/dist/server/http.js +119 -0
  384. package/dist/server/index.d.ts +46 -0
  385. package/dist/server/index.js +310 -0
  386. package/dist/server/queue.d.ts +30 -0
  387. package/dist/server/queue.js +76 -0
  388. package/dist/server/schema.d.ts +103 -0
  389. package/dist/server/schema.js +121 -0
  390. package/dist/server/source.d.ts +17 -0
  391. package/dist/server/source.js +100 -0
  392. package/dist/sources/assemble.d.ts +86 -0
  393. package/dist/sources/assemble.js +117 -0
  394. package/dist/sources/diff-parser.d.ts +14 -0
  395. package/dist/sources/diff-parser.js +84 -0
  396. package/dist/sources/git.d.ts +28 -0
  397. package/dist/sources/git.js +108 -0
  398. package/dist/sources/github.d.ts +20 -0
  399. package/dist/sources/github.js +192 -0
  400. package/dist/sources/hunk-selection.d.ts +25 -0
  401. package/dist/sources/hunk-selection.js +46 -0
  402. package/dist/sources/index.d.ts +23 -0
  403. package/dist/sources/index.js +62 -0
  404. package/dist/sources/limits.d.ts +27 -0
  405. package/dist/sources/limits.js +22 -0
  406. package/dist/sources/local.d.ts +34 -0
  407. package/dist/sources/local.js +555 -0
  408. package/dist/sources/reader.d.ts +13 -0
  409. package/dist/sources/reader.js +45 -0
  410. package/dist/sources/remote.d.ts +13 -0
  411. package/dist/sources/remote.js +41 -0
  412. package/dist/sources/repo-context.d.ts +34 -0
  413. package/dist/sources/repo-context.js +144 -0
  414. package/dist/sources/text.d.ts +25 -0
  415. package/dist/sources/text.js +71 -0
  416. package/dist/storyboard/authoring.d.ts +108 -0
  417. package/dist/storyboard/authoring.js +196 -0
  418. package/dist/storyboard/claims.d.ts +35 -0
  419. package/dist/storyboard/claims.js +318 -0
  420. package/dist/storyboard/coderef.d.ts +28 -0
  421. package/dist/storyboard/coderef.js +118 -0
  422. package/dist/storyboard/generate.d.ts +25 -0
  423. package/dist/storyboard/generate.js +194 -0
  424. package/dist/storyboard/heuristic-code.d.ts +91 -0
  425. package/dist/storyboard/heuristic-code.js +524 -0
  426. package/dist/storyboard/heuristic-context.d.ts +42 -0
  427. package/dist/storyboard/heuristic-context.js +102 -0
  428. package/dist/storyboard/heuristic-facts.d.ts +106 -0
  429. package/dist/storyboard/heuristic-facts.js +415 -0
  430. package/dist/storyboard/heuristic-overview.d.ts +4 -0
  431. package/dist/storyboard/heuristic-overview.js +151 -0
  432. package/dist/storyboard/heuristic-review.d.ts +10 -0
  433. package/dist/storyboard/heuristic-review.js +158 -0
  434. package/dist/storyboard/heuristic-scenes.d.ts +8 -0
  435. package/dist/storyboard/heuristic-scenes.js +357 -0
  436. package/dist/storyboard/heuristic-shared.d.ts +43 -0
  437. package/dist/storyboard/heuristic-shared.js +136 -0
  438. package/dist/storyboard/heuristic.d.ts +15 -0
  439. package/dist/storyboard/heuristic.js +324 -0
  440. package/dist/storyboard/identifiers.d.ts +51 -0
  441. package/dist/storyboard/identifiers.js +195 -0
  442. package/dist/storyboard/index.d.ts +10 -0
  443. package/dist/storyboard/index.js +10 -0
  444. package/dist/storyboard/prompts.d.ts +16 -0
  445. package/dist/storyboard/prompts.js +61 -0
  446. package/dist/storyboard/run.d.ts +82 -0
  447. package/dist/storyboard/run.js +332 -0
  448. package/dist/storyboard/text.d.ts +16 -0
  449. package/dist/storyboard/text.js +103 -0
  450. package/dist/storyboard/types.d.ts +47 -0
  451. package/dist/storyboard/types.js +2 -0
  452. package/dist/storyboard/urls.d.ts +15 -0
  453. package/dist/storyboard/urls.js +83 -0
  454. package/dist/storyboard/validate.d.ts +8 -0
  455. package/dist/storyboard/validate.js +525 -0
  456. package/dist/storyboard/visuals.d.ts +23 -0
  457. package/dist/storyboard/visuals.js +324 -0
  458. package/dist/version.d.ts +2 -0
  459. package/dist/version.js +3 -0
  460. package/dist/visuals/code.d.ts +68 -0
  461. package/dist/visuals/code.js +385 -0
  462. package/dist/visuals/highlight.d.ts +17 -0
  463. package/dist/visuals/highlight.js +85 -0
  464. package/dist/visuals/image.d.ts +12 -0
  465. package/dist/visuals/image.js +96 -0
  466. package/dist/visuals/index.d.ts +10 -0
  467. package/dist/visuals/index.js +10 -0
  468. package/dist/visuals/layout.d.ts +89 -0
  469. package/dist/visuals/layout.js +506 -0
  470. package/dist/visuals/plan.d.ts +33 -0
  471. package/dist/visuals/plan.js +511 -0
  472. package/dist/visuals/timeline.d.ts +31 -0
  473. package/dist/visuals/timeline.js +96 -0
  474. package/package.json +74 -4
@@ -0,0 +1,511 @@
1
+ /**
2
+ * Render plan builder: turns a validated storyboard, the timeline and the repository into a
3
+ * self-contained RenderPlan. Code is read from the repository here, never taken from the storyboard,
4
+ * and every string that reaches the screen is masked first.
5
+ */
6
+ import { QUALITY_PRESETS } from '../core/config.js';
7
+ import { assertNotAborted, MergeStoryError } from '../core/errors.js';
8
+ import { maskPrivateReport } from '../core/secrets.js';
9
+ import { BACKING_EVIDENCE_KINDS } from '../core/storyboard-facts.js';
10
+ import { STORYBOARD_LIMITS, } from '../core/storyboard-schema.js';
11
+ import { collapseLineRange } from '../core/text.js';
12
+ import { ENGINE_VERSION } from '../version.js';
13
+ import { CodeResolver } from './code.js';
14
+ import { loadScreenshot } from './image.js';
15
+ import { layoutArchitecture } from './layout.js';
16
+ /** Rows shown in the changed-files visual; the rest is summarised as a count. */
17
+ export const MAX_FILE_ROWS = 16;
18
+ const MAX_REFS = 3;
19
+ export const OUTRO_TAGLINE = 'Every change has a story.';
20
+ export const OUTRO_DISCLAIMER = 'This video explains the change. It does not replace code review.';
21
+ /** Secrets are always masked; e-mail addresses too unless privacy.maskEmails is off. */
22
+ function createScrubber(maskEmail) {
23
+ let masked = 0;
24
+ const text = (value) => {
25
+ const report = maskPrivateReport(value, { maskEmails: maskEmail });
26
+ masked += report.secrets + (report.emailsChanged ? 1 : 0);
27
+ return report.text;
28
+ };
29
+ return { text, maybe: (value) => (value === null ? null : text(value)), count: () => masked };
30
+ }
31
+ const beatIndex = (value) => (Number.isFinite(value) ? Math.max(0, Math.trunc(value)) : 0);
32
+ // ---------------------------------------------------------------------------
33
+ // Labels
34
+ // ---------------------------------------------------------------------------
35
+ function lastSegment(value) {
36
+ const parts = value.replace(/\\/g, '/').split('/').filter(Boolean);
37
+ return parts[parts.length - 1] ?? '';
38
+ }
39
+ /** "owner/name", or the repository name. Never a filesystem path. */
40
+ export function repoLabelFor(repo) {
41
+ const name = lastSegment(repo.name) || 'repository';
42
+ const owner = repo.owner ? lastSegment(repo.owner) : '';
43
+ return owner ? `${owner}/${name}` : name;
44
+ }
45
+ /** "PR #42", or the head branch for a local run. */
46
+ export function changeLabelFor(changeSet) {
47
+ if (changeSet.pr)
48
+ return `PR #${changeSet.pr.number}`;
49
+ const ref = changeSet.head.ref.trim().replace(/^refs\/(?:heads|remotes\/[^/]+)\//, '');
50
+ if (/^[0-9a-f]{40}$/i.test(ref))
51
+ return ref.slice(0, 7);
52
+ return ref || 'working changes';
53
+ }
54
+ /** "src/a.ts:8-12" for a code reference. A path is on-screen text too, so it is masked. */
55
+ const codeLabel = (ref, scrub) => scrub.text(collapseLineRange(`${ref.path}:${ref.startLine}-${ref.endLine}`));
56
+ function screenshotFor(env, id) {
57
+ let pending = env.images.get(id);
58
+ if (!pending) {
59
+ const input = env.inputs.screenshots.find((s) => s.id === id);
60
+ if (!input) {
61
+ throw new MergeStoryError('STORYBOARD_INVALID', `The storyboard uses an unknown screenshot id: ${id}`, {
62
+ hint: 'Screenshots must be passed with the run context; ids look like SS1.',
63
+ });
64
+ }
65
+ pending = loadScreenshot(input.path);
66
+ env.images.set(id, pending);
67
+ }
68
+ return pending;
69
+ }
70
+ function resolveFiles(visual, env, scrub) {
71
+ const { changeSet, analysis } = env;
72
+ const insights = new Map(analysis.files.map((f) => [f.fileId, f]));
73
+ const components = new Map();
74
+ for (const component of analysis.components) {
75
+ for (const fileId of component.fileIds)
76
+ components.set(fileId, component.name);
77
+ }
78
+ const highlight = new Set(visual.highlightPaths);
79
+ const entries = changeSet.files.map((file) => {
80
+ const insight = insights.get(file.id);
81
+ return {
82
+ file,
83
+ component: components.get(file.id) ?? 'Other',
84
+ highlighted: highlight.has(file.path) || (file.oldPath !== null && highlight.has(file.oldPath)),
85
+ trivial: insight?.trivial ?? false,
86
+ importance: insight?.importance ?? 0,
87
+ };
88
+ });
89
+ entries.sort((a, b) => Number(b.highlighted) - Number(a.highlighted) ||
90
+ Number(a.trivial) - Number(b.trivial) ||
91
+ b.importance - a.importance ||
92
+ b.file.additions + b.file.deletions - (a.file.additions + a.file.deletions) ||
93
+ a.file.path.localeCompare(b.file.path));
94
+ const shown = entries.slice(0, MAX_FILE_ROWS);
95
+ // Groups appear in the order of their best-ranked file; "Other" is always last.
96
+ const groups = new Map();
97
+ for (const entry of shown) {
98
+ const rows = groups.get(entry.component) ?? [];
99
+ rows.push({
100
+ path: scrub.text(entry.file.path),
101
+ status: entry.file.status,
102
+ additions: entry.file.additions,
103
+ deletions: entry.file.deletions,
104
+ highlighted: entry.highlighted,
105
+ trivial: entry.trivial,
106
+ });
107
+ groups.set(entry.component, rows);
108
+ }
109
+ const ordered = [...groups.entries()].sort(([a], [b]) => Number(a === 'Other') - Number(b === 'Other'));
110
+ const totals = { ...changeSet.stats };
111
+ return {
112
+ type: 'files',
113
+ caption: scrub.maybe(visual.caption),
114
+ totals,
115
+ groups: ordered.map(([component, files]) => ({ component: scrub.text(component), files })),
116
+ hiddenCount: Math.max(0, totals.files - shown.length),
117
+ };
118
+ }
119
+ function checklistRef(ref, scrub) {
120
+ return ref ? codeLabel(ref, scrub) : null;
121
+ }
122
+ /** Read the lines a code reference points at. The path in the header of the code view is masked too. */
123
+ async function resolveCodeRef(ref, mode, focus, env, scrub) {
124
+ const code = await env.resolver.resolve(ref, mode, focus);
125
+ return { ...code, path: scrub.text(code.path) };
126
+ }
127
+ /** Keep focus ranges that fall on lines that are actually shown, clamped to those lines. */
128
+ function clampFocus(focus, code) {
129
+ const numbers = code.lines
130
+ .map((line) => (code.side === 'head' ? line.newNumber : line.oldNumber))
131
+ .filter((n) => n !== null);
132
+ if (numbers.length === 0)
133
+ return [];
134
+ const low = Math.min(...numbers);
135
+ const high = Math.max(...numbers);
136
+ const out = [];
137
+ for (const range of focus) {
138
+ const startLine = Math.max(range.startLine, low);
139
+ const endLine = Math.min(range.endLine, high);
140
+ if (startLine > endLine)
141
+ continue;
142
+ out.push({ ...range, startLine, endLine });
143
+ }
144
+ return out;
145
+ }
146
+ async function resolvePanel(panel, env, scrub) {
147
+ const label = scrub.text(panel.label);
148
+ switch (panel.kind) {
149
+ case 'code': {
150
+ if (!panel.codeRef) {
151
+ throw new MergeStoryError('STORYBOARD_INVALID', `The "${panel.label}" panel is a code panel without a code reference.`, {
152
+ hint: 'Give the panel a codeRef, or change its kind.',
153
+ });
154
+ }
155
+ const code = await resolveCodeRef(panel.codeRef, 'snippet', [], env, scrub);
156
+ return { panel: { label, kind: 'code', code }, masked: code.masked };
157
+ }
158
+ case 'bullets':
159
+ return {
160
+ panel: { label, kind: 'bullets', bullets: panel.bullets.map((b) => scrub.text(b)) },
161
+ masked: false,
162
+ };
163
+ case 'terminal':
164
+ return {
165
+ panel: {
166
+ label,
167
+ kind: 'terminal',
168
+ terminal: panel.terminal.map((l) => ({
169
+ kind: l.kind,
170
+ text: scrub.text(l.text),
171
+ beat: beatIndex(l.beat),
172
+ })),
173
+ },
174
+ masked: false,
175
+ };
176
+ case 'screenshot': {
177
+ if (!panel.screenshotId) {
178
+ throw new MergeStoryError('STORYBOARD_INVALID', `The "${panel.label}" panel is a screenshot panel without a screenshot id.`, {
179
+ hint: 'Give the panel a screenshotId (for example SS1), or change its kind.',
180
+ });
181
+ }
182
+ const image = await screenshotFor(env, panel.screenshotId);
183
+ return { panel: { label, kind: 'screenshot', image }, masked: false };
184
+ }
185
+ default:
186
+ panel.kind;
187
+ throw new MergeStoryError('INTERNAL', 'A panel has an unknown kind.');
188
+ }
189
+ }
190
+ async function resolveVisual(visual, env, scrub) {
191
+ const base = {
192
+ codeMasked: false,
193
+ codeLabels: [],
194
+ simulated: null,
195
+ actual: false,
196
+ };
197
+ switch (visual.type) {
198
+ case 'title':
199
+ return {
200
+ ...base,
201
+ visual: {
202
+ type: 'title',
203
+ kicker: scrub.maybe(visual.kicker),
204
+ heading: scrub.text(visual.heading),
205
+ subheading: scrub.maybe(visual.subheading),
206
+ chips: visual.chips.slice(0, STORYBOARD_LIMITS.maxChips).map((c) => scrub.text(c)),
207
+ },
208
+ };
209
+ case 'mission':
210
+ return {
211
+ ...base,
212
+ visual: {
213
+ type: 'mission',
214
+ problem: scrub.text(visual.problem),
215
+ goal: scrub.text(visual.goal),
216
+ points: visual.points.map((p) => ({ text: scrub.text(p.text), beat: beatIndex(p.beat) })),
217
+ },
218
+ };
219
+ case 'files':
220
+ return { ...base, visual: resolveFiles(visual, env, scrub) };
221
+ case 'architecture': {
222
+ const clean = {
223
+ ...visual,
224
+ nodes: visual.nodes.map((n) => ({
225
+ ...n,
226
+ label: scrub.text(n.label),
227
+ detail: scrub.maybe(n.detail),
228
+ beat: beatIndex(n.beat),
229
+ })),
230
+ edges: visual.edges.map((e) => ({ ...e, label: scrub.maybe(e.label), beat: beatIndex(e.beat) })),
231
+ };
232
+ return {
233
+ ...base,
234
+ visual: { type: 'architecture', ...layoutArchitecture(clean) },
235
+ };
236
+ }
237
+ case 'flow':
238
+ return {
239
+ ...base,
240
+ visual: {
241
+ type: 'flow',
242
+ actors: visual.actors.map((a) => ({ id: a.id, label: scrub.text(a.label), kind: a.kind })),
243
+ steps: visual.steps.map((s) => ({
244
+ from: s.from,
245
+ to: s.to,
246
+ label: scrub.text(s.label),
247
+ detail: scrub.maybe(s.detail),
248
+ kind: s.kind,
249
+ beat: beatIndex(s.beat),
250
+ })),
251
+ },
252
+ };
253
+ case 'code': {
254
+ const focusIn = visual.focus.map((f) => ({ startLine: f.startLine, endLine: f.endLine }));
255
+ const code = await resolveCodeRef(visual.ref, visual.mode, focusIn, env, scrub);
256
+ const resolvedFocus = clampFocus(visual.focus.map((f) => ({
257
+ startLine: f.startLine,
258
+ endLine: f.endLine,
259
+ note: scrub.maybe(f.note),
260
+ beat: beatIndex(f.beat),
261
+ })), code);
262
+ const hasChanges = code.lines.some((l) => l.kind !== 'ctx');
263
+ return {
264
+ ...base,
265
+ codeMasked: code.masked,
266
+ codeLabels: [codeLabel(visual.ref, scrub)],
267
+ visual: {
268
+ type: 'code',
269
+ mode: visual.mode === 'diff' && hasChanges ? 'diff' : 'snippet',
270
+ code,
271
+ focus: resolvedFocus,
272
+ caption: scrub.maybe(visual.caption),
273
+ },
274
+ };
275
+ }
276
+ case 'before-after': {
277
+ const before = await resolvePanel(visual.before, env, scrub);
278
+ const after = await resolvePanel(visual.after, env, scrub);
279
+ const panels = [after, before];
280
+ const resolved = {
281
+ type: 'before-after',
282
+ before: before.panel,
283
+ after: after.panel,
284
+ caption: scrub.maybe(visual.caption),
285
+ };
286
+ return {
287
+ ...base,
288
+ visual: resolved,
289
+ codeMasked: panels.some((p) => p.masked),
290
+ codeLabels: [visual.after, visual.before].flatMap((p) => p.kind === 'code' && p.codeRef ? [codeLabel(p.codeRef, scrub)] : []),
291
+ simulated: panels.some((p) => p.panel.kind === 'terminal') ? 'Simulated output' : null,
292
+ actual: panels.some((p) => p.panel.kind === 'screenshot'),
293
+ };
294
+ }
295
+ case 'terminal':
296
+ return {
297
+ ...base,
298
+ simulated: 'Simulated output',
299
+ visual: {
300
+ type: 'terminal',
301
+ title: scrub.text(visual.title),
302
+ lines: visual.lines.map((l) => ({
303
+ kind: l.kind,
304
+ text: scrub.text(l.text),
305
+ beat: beatIndex(l.beat),
306
+ })),
307
+ },
308
+ };
309
+ case 'browser':
310
+ return {
311
+ ...base,
312
+ simulated: 'Simulated screen',
313
+ visual: {
314
+ type: 'browser',
315
+ url: scrub.text(visual.url),
316
+ pageTitle: scrub.text(visual.pageTitle),
317
+ blocks: visual.blocks.map((b) => ({
318
+ kind: b.kind,
319
+ text: scrub.text(b.text),
320
+ items: b.items.map((i) => scrub.text(i)),
321
+ emphasis: b.emphasis,
322
+ beat: beatIndex(b.beat),
323
+ })),
324
+ },
325
+ };
326
+ case 'checklist': {
327
+ const resolved = {
328
+ type: 'checklist',
329
+ items: visual.items.map((item) => ({
330
+ title: scrub.text(item.title),
331
+ detail: scrub.text(item.detail),
332
+ severity: item.severity,
333
+ refLabel: checklistRef(item.ref, scrub),
334
+ beat: beatIndex(item.beat),
335
+ })),
336
+ };
337
+ return { ...base, visual: resolved };
338
+ }
339
+ case 'bullets':
340
+ return {
341
+ ...base,
342
+ visual: {
343
+ type: 'bullets',
344
+ heading: scrub.maybe(visual.heading),
345
+ items: visual.items.map((i) => ({ text: scrub.text(i.text), beat: beatIndex(i.beat) })),
346
+ },
347
+ };
348
+ case 'screenshot':
349
+ return {
350
+ ...base,
351
+ actual: true,
352
+ visual: {
353
+ type: 'screenshot',
354
+ image: await screenshotFor(env, visual.screenshotId),
355
+ caption: scrub.maybe(visual.caption),
356
+ },
357
+ };
358
+ case 'summary':
359
+ return {
360
+ ...base,
361
+ visual: {
362
+ type: 'summary',
363
+ points: visual.points.map((p) => ({ text: scrub.text(p.text), beat: beatIndex(p.beat) })),
364
+ closing: scrub.maybe(visual.closing),
365
+ },
366
+ };
367
+ default:
368
+ visual;
369
+ throw new MergeStoryError('INTERNAL', 'A scene has an unknown visual type.');
370
+ }
371
+ }
372
+ // ---------------------------------------------------------------------------
373
+ // Scenes
374
+ // ---------------------------------------------------------------------------
375
+ /** Evidence ids cited by a scene: narration first, then the ids attached to visual elements. */
376
+ function citedEvidence(scene) {
377
+ const ids = scene.narration.flatMap((line) => line.evidence);
378
+ const visual = scene.visual;
379
+ if (visual.type === 'architecture')
380
+ ids.push(...visual.nodes.flatMap((n) => n.evidence));
381
+ else if (visual.type === 'flow')
382
+ ids.push(...visual.steps.flatMap((s) => s.evidence));
383
+ else if (visual.type === 'checklist')
384
+ ids.push(...visual.items.flatMap((i) => i.evidence));
385
+ return ids;
386
+ }
387
+ function sceneRefs(scene, codeLabels, evidence) {
388
+ const refs = [];
389
+ const add = (label) => {
390
+ if (refs.length < MAX_REFS && label && !refs.includes(label))
391
+ refs.push(label);
392
+ };
393
+ for (const label of codeLabels)
394
+ add(label);
395
+ for (const id of citedEvidence(scene)) {
396
+ const item = evidence.get(id);
397
+ if (item && BACKING_EVIDENCE_KINDS.includes(item.kind))
398
+ add(collapseLineRange(item.label));
399
+ }
400
+ return refs;
401
+ }
402
+ function sceneBadges(scene, resolved, masked) {
403
+ const badges = [];
404
+ if (resolved.simulated)
405
+ badges.push({ kind: 'simulated', text: resolved.simulated });
406
+ if (resolved.actual)
407
+ badges.push({ kind: 'actual', text: 'Actual screenshot' });
408
+ if (masked)
409
+ badges.push({ kind: 'masked', text: 'Sensitive data masked' });
410
+ if (scene.narration.some((line) => line.evidence.some((id) => /^T\d+$/.test(id)))) {
411
+ badges.push({ kind: 'reported', text: 'Reported results' });
412
+ }
413
+ return badges;
414
+ }
415
+ async function planScene(scene, timing, env, evidence) {
416
+ const scrub = createScrubber(env.config.privacy.maskEmails);
417
+ const resolved = await resolveVisual(scene.visual, env, scrub);
418
+ const beats = timing.beats.map((beat) => ({
419
+ index: beat.index,
420
+ startSec: beat.startSec,
421
+ durationSec: beat.durationSec,
422
+ text: scrub.text(scene.narration[beat.index]?.text ?? ''),
423
+ }));
424
+ const masked = resolved.codeMasked || scrub.count() > 0;
425
+ return {
426
+ id: scene.id,
427
+ role: scene.role,
428
+ title: scrub.text(scene.title),
429
+ startSec: timing.startSec,
430
+ durationSec: timing.durationSec,
431
+ transitionIn: {
432
+ type: timing.transitionSec > 0 ? scene.transition : 'none',
433
+ durationSec: timing.transitionSec,
434
+ },
435
+ beats,
436
+ visual: resolved.visual,
437
+ refs: sceneRefs(scene, resolved.codeLabels, evidence),
438
+ badges: sceneBadges(scene, resolved, masked),
439
+ };
440
+ }
441
+ /**
442
+ * Build the render plan: quality preset, theme, labels, captions, chapters, one planned scene per
443
+ * storyboard scene (code, diagrams and screenshots resolved) and the end card.
444
+ */
445
+ export async function buildRenderPlan(input, ctx) {
446
+ const { storyboard, timeline, changeSet, analysis, inputs, reader, config } = input;
447
+ const preset = QUALITY_PRESETS[config.quality];
448
+ const env = {
449
+ config,
450
+ changeSet,
451
+ analysis,
452
+ inputs,
453
+ resolver: new CodeResolver({ reader, changeSet, config, logger: ctx.logger }),
454
+ images: new Map(),
455
+ };
456
+ const evidence = new Map(analysis.evidence.map((item) => [item.id, item]));
457
+ const metaScrub = createScrubber(config.privacy.maskEmails);
458
+ const scenes = [];
459
+ for (const [index, scene] of storyboard.scenes.entries()) {
460
+ assertNotAborted(ctx.signal);
461
+ const timing = timeline.scenes.find((t) => t.sceneId === scene.id) ?? timeline.scenes[index];
462
+ if (!timing) {
463
+ throw new MergeStoryError('INTERNAL', `The timeline has no entry for scene "${scene.id}".`, {
464
+ hint: 'Build the timeline from the same storyboard that is used for the plan.',
465
+ });
466
+ }
467
+ scenes.push(await planScene(scene, timing, env, evidence));
468
+ }
469
+ const repoLabel = metaScrub.text(repoLabelFor(changeSet.repo));
470
+ const changeLabel = metaScrub.text(changeLabelFor(changeSet));
471
+ const headShort = changeSet.head.sha.slice(0, 7);
472
+ const plan = {
473
+ version: 1,
474
+ width: preset.width,
475
+ height: preset.height,
476
+ fps: preset.fps,
477
+ durationSec: timeline.durationSec,
478
+ theme: config.theme,
479
+ meta: {
480
+ title: metaScrub.text(storyboard.title),
481
+ repoLabel,
482
+ changeLabel,
483
+ headShort,
484
+ stats: { ...changeSet.stats },
485
+ engineVersion: ENGINE_VERSION,
486
+ },
487
+ captions: {
488
+ enabled: config.captions,
489
+ cues: input.cues
490
+ .filter((cue) => cue.endSec > cue.startSec && cue.text.trim() !== '')
491
+ .map((cue) => ({ startSec: cue.startSec, endSec: cue.endSec, text: metaScrub.text(cue.text) })),
492
+ },
493
+ chapters: scenes.map((scene) => ({ title: scene.title, startSec: scene.startSec })),
494
+ scenes,
495
+ outro: {
496
+ startSec: timeline.outro.startSec,
497
+ durationSec: timeline.outro.durationSec,
498
+ tagline: OUTRO_TAGLINE,
499
+ lines: [`${repoLabel} · ${changeLabel}`, `Commit ${headShort}`, OUTRO_DISCLAIMER],
500
+ },
501
+ };
502
+ ctx.logger.debug('Render plan built', {
503
+ scenes: scenes.length,
504
+ durationSec: plan.durationSec,
505
+ width: plan.width,
506
+ height: plan.height,
507
+ fps: plan.fps,
508
+ });
509
+ return plan;
510
+ }
511
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Timeline: scene and beat timings from the narration clip lengths.
3
+ *
4
+ * Each scene starts with a short lead-in, speaks its beats with a small gap between them and keeps
5
+ * a quiet tail. A scene is never shorter than its visual needs, and a scene's transition overlaps
6
+ * the end of the previous scene. The branded end card overlaps the last scene by half a second.
7
+ */
8
+ import { type Storyboard, type TransitionType, type VisualType } from '../core/storyboard-schema.ts';
9
+ import type { NarrationResult, Timeline } from '../core/types.ts';
10
+ export declare const TIMELINE_RULES: {
11
+ /** Silence before the first beat of the first scene (the title animates in). */
12
+ readonly firstLeadInSec: 0.8;
13
+ /** Silence before the first beat of every other scene; never shorter than the scene's transition. */
14
+ readonly leadInSec: 0.6;
15
+ /** Pause between two narration beats of one scene. */
16
+ readonly beatGapSec: 0.35;
17
+ /** Quiet time after the last beat of a scene. */
18
+ readonly tailSec: 0.9;
19
+ /** Length of the branded end card. */
20
+ readonly outroSec: 3.5;
21
+ /** How long the end card overlaps the last scene. */
22
+ readonly outroOverlapSec: 0.5;
23
+ /** A scene may be stretched to its target length by at most this factor. */
24
+ readonly maxStretch: 1.5;
25
+ };
26
+ /** Length of the transition into a scene, by type. */
27
+ export declare const TRANSITION_SECONDS: Record<TransitionType, number>;
28
+ /** Shortest a scene may be, by visual type. Visuals that need time to read are longer. */
29
+ export declare const MIN_SCENE_SECONDS: Record<VisualType, number>;
30
+ /** Scene and beat timings from narration clip durations (lead-in, gaps, minimum scene length, transitions, outro). */
31
+ export declare function buildTimeline(storyboard: Storyboard, narration: NarrationResult): Timeline;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Timeline: scene and beat timings from the narration clip lengths.
3
+ *
4
+ * Each scene starts with a short lead-in, speaks its beats with a small gap between them and keeps
5
+ * a quiet tail. A scene is never shorter than its visual needs, and a scene's transition overlaps
6
+ * the end of the previous scene. The branded end card overlaps the last scene by half a second.
7
+ */
8
+ import { STORYBOARD_LIMITS, } from '../core/storyboard-schema.js';
9
+ export const TIMELINE_RULES = {
10
+ /** Silence before the first beat of the first scene (the title animates in). */
11
+ firstLeadInSec: 0.8,
12
+ /** Silence before the first beat of every other scene; never shorter than the scene's transition. */
13
+ leadInSec: 0.6,
14
+ /** Pause between two narration beats of one scene. */
15
+ beatGapSec: 0.35,
16
+ /** Quiet time after the last beat of a scene. */
17
+ tailSec: 0.9,
18
+ /** Length of the branded end card. */
19
+ outroSec: 3.5,
20
+ /** How long the end card overlaps the last scene. */
21
+ outroOverlapSec: 0.5,
22
+ /** A scene may be stretched to its target length by at most this factor. */
23
+ maxStretch: 1.5,
24
+ };
25
+ /** Length of the transition into a scene, by type. */
26
+ export const TRANSITION_SECONDS = {
27
+ fade: 0.5,
28
+ slide: 0.6,
29
+ zoom: 0.6,
30
+ wipe: 0.7,
31
+ none: 0,
32
+ };
33
+ /** Shortest a scene may be, by visual type. Visuals that need time to read are longer. */
34
+ export const MIN_SCENE_SECONDS = {
35
+ title: 4,
36
+ code: 6,
37
+ architecture: 7,
38
+ flow: 7,
39
+ files: 5,
40
+ mission: 4.5,
41
+ 'before-after': 4.5,
42
+ terminal: 4.5,
43
+ browser: 4.5,
44
+ checklist: 4.5,
45
+ bullets: 4.5,
46
+ screenshot: 4.5,
47
+ summary: 4.5,
48
+ };
49
+ /** Round to milliseconds so floating point noise never reaches the plan. */
50
+ const ms = (value) => Math.round(value * 1000) / 1000;
51
+ /** Length of a beat when the narration has no clip for it: estimated from the word count. */
52
+ function estimatedSeconds(text) {
53
+ const words = text.trim().split(/\s+/).filter(Boolean).length;
54
+ return Math.max(1.2, words / STORYBOARD_LIMITS.wordsPerSecond);
55
+ }
56
+ function clipSeconds(clip, text) {
57
+ if (clip && Number.isFinite(clip.durationSec) && clip.durationSec > 0)
58
+ return clip.durationSec;
59
+ return estimatedSeconds(text);
60
+ }
61
+ /** Scene and beat timings from narration clip durations (lead-in, gaps, minimum scene length, transitions, outro). */
62
+ export function buildTimeline(storyboard, narration) {
63
+ const clips = new Map();
64
+ for (const clip of narration.clips)
65
+ clips.set(`${clip.sceneId}#${clip.beatIndex}`, clip);
66
+ const scenes = [];
67
+ let previousEnd = 0;
68
+ storyboard.scenes.forEach((scene, sceneIndex) => {
69
+ const transitionSec = sceneIndex === 0 ? 0 : (TRANSITION_SECONDS[scene.transition] ?? 0);
70
+ const leadIn = sceneIndex === 0 ? TIMELINE_RULES.firstLeadInSec : Math.max(TIMELINE_RULES.leadInSec, transitionSec);
71
+ const startSec = sceneIndex === 0 ? 0 : ms(previousEnd - transitionSec);
72
+ const beats = [];
73
+ let cursor = leadIn;
74
+ scene.narration.forEach((line, index) => {
75
+ const durationSec = ms(clipSeconds(clips.get(`${scene.id}#${index}`), line.text));
76
+ beats.push({ index, startSec: ms(startSec + cursor), durationSec });
77
+ cursor += durationSec + TIMELINE_RULES.beatGapSec;
78
+ });
79
+ // `cursor` is one gap past the last beat; a scene without narration just holds its lead-in.
80
+ const narrationEnd = beats.length > 0 ? cursor - TIMELINE_RULES.beatGapSec : leadIn;
81
+ const natural = Math.max(narrationEnd + TIMELINE_RULES.tailSec, MIN_SCENE_SECONDS[scene.visual.type] ?? 4.5);
82
+ const target = scene.targetSeconds;
83
+ const durationSec = ms(target !== null && Number.isFinite(target) && target > natural
84
+ ? Math.min(target, natural * TIMELINE_RULES.maxStretch)
85
+ : natural);
86
+ scenes.push({ sceneId: scene.id, startSec, durationSec, transitionSec, beats });
87
+ previousEnd = ms(startSec + durationSec);
88
+ });
89
+ const outroStart = ms(Math.max(0, previousEnd - TIMELINE_RULES.outroOverlapSec));
90
+ return {
91
+ durationSec: ms(outroStart + TIMELINE_RULES.outroSec),
92
+ scenes,
93
+ outro: { startSec: outroStart, durationSec: TIMELINE_RULES.outroSec },
94
+ };
95
+ }
96
+ //# sourceMappingURL=timeline.js.map