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,171 @@
1
+ /**
2
+ * Checks caller-supplied context (task, notes, test results, screenshots) and assigns evidence ids.
3
+ * This is the one input contract: the library, the command line and the HTTP API all end up here.
4
+ */
5
+ import { readFile, stat } from 'node:fs/promises';
6
+ import { resolve } from 'node:path';
7
+ import { z } from 'zod';
8
+ import { MergeStoryError } from '../core/errors.js';
9
+ import { detectImage, MAX_SCREENSHOT_BYTES } from '../visuals/image.js';
10
+ /** Limits of the context. Longer lists and texts are cut or refused here, so every caller sees the same ones. */
11
+ export const MAX_TEXT = 64 * 1024;
12
+ export const MAX_SCREENSHOTS = 6;
13
+ /** Test results that reach the evidence. A longer list is cut, with a warning. */
14
+ export const MAX_TESTS = 10;
15
+ /** Most entries accepted in a list of test results at all. */
16
+ export const MAX_TEST_ENTRIES = 200;
17
+ const MAX_TEST_COMMAND = 300;
18
+ const MAX_TEST_SUMMARY = 1000;
19
+ const MAX_CAPTION = 200;
20
+ export const TEST_SOURCES = ['agent', 'ci', 'user'];
21
+ const TEST_KEYS = ['command', 'passed', 'summary', 'source'];
22
+ /**
23
+ * One test result the caller reports. Strict on purpose: a typo such as "pass" for "passed", or the
24
+ * string "false" for false, must never turn into a made-up result. The messages complete the
25
+ * sentence "entry 3 ...".
26
+ */
27
+ export const TestResultSchema = z.strictObject({
28
+ command: z
29
+ .string({ error: 'needs a "command" string.' })
30
+ .refine((command) => command.trim() !== '', { error: 'needs a "command" string.' }),
31
+ passed: z.boolean({ error: 'needs "passed" set to true or false.' }),
32
+ summary: z.string({ error: 'needs a "summary" string.' }),
33
+ source: z
34
+ .enum(TEST_SOURCES, {
35
+ error: (issue) => `has source "${String(issue.input)}". Use one of: ${TEST_SOURCES.join(', ')}.`,
36
+ })
37
+ .default('agent'),
38
+ }, {
39
+ error: (issue) => issue.code === 'unrecognized_keys'
40
+ ? `has unknown field "${issue.keys[0]}". Allowed: ${TEST_KEYS.join(', ')}.`
41
+ : 'is not an object.',
42
+ });
43
+ /** Check a list of test results. `label` names the input in the error ("--tests-file", "tests"). */
44
+ export function checkTestResults(value, label = 'tests') {
45
+ const fail = (message) => {
46
+ throw new MergeStoryError('USAGE', `${label}: ${message}`, {
47
+ hint: 'Expected a JSON array like [{"command": "npm test", "passed": true, "summary": "42 passed"}].',
48
+ });
49
+ };
50
+ if (!Array.isArray(value))
51
+ return fail('expected a JSON array of test results.');
52
+ if (value.length > MAX_TEST_ENTRIES) {
53
+ return fail(`${value.length} entries is too many (at most ${MAX_TEST_ENTRIES}).`);
54
+ }
55
+ return value.map((entry, index) => {
56
+ const parsed = TestResultSchema.safeParse(entry);
57
+ if (parsed.success)
58
+ return parsed.data;
59
+ // An unknown field is reported before a missing one, as it is easier to act on.
60
+ const issue = parsed.error.issues.find((i) => i.code === 'unrecognized_keys') ?? parsed.error.issues[0];
61
+ return fail(`entry ${index + 1} ${issue?.message ?? 'is not valid.'}`);
62
+ });
63
+ }
64
+ function normalizeContextText(value, what) {
65
+ if (value === null || value === undefined)
66
+ return null;
67
+ const text = value.replace(/\r\n/g, '\n').trim();
68
+ if (!text)
69
+ return null;
70
+ if (text.length > MAX_TEXT) {
71
+ throw new MergeStoryError('USAGE', `The ${what} is too long (${text.length} characters, limit ${MAX_TEXT}).`, {
72
+ hint: `Shorten the ${what}; a few paragraphs are enough.`,
73
+ });
74
+ }
75
+ return text;
76
+ }
77
+ /** "5.2 MB", rounded up, for a size that is over the screenshot limit. */
78
+ function megabytes(bytes) {
79
+ return `${Math.ceil((bytes / (1024 * 1024)) * 10) / 10} MB`;
80
+ }
81
+ /**
82
+ * Check a screenshot the way the video does: PNG or JPEG by content (never by file name), at most
83
+ * 4 MiB and 40 megapixels. A file that the video could not draw is refused here, at once, and not
84
+ * after narration has been paid for. Returns the absolute path. `label` names the input in errors.
85
+ */
86
+ export async function checkScreenshotFile(path, cwd, label = 'Screenshot') {
87
+ const absolute = resolve(cwd, path);
88
+ const info = await stat(absolute).catch(() => null);
89
+ if (!info) {
90
+ throw new MergeStoryError('USAGE', `${label}: file not found: ${path}`, {
91
+ hint: 'Pass an existing PNG or JPEG file.',
92
+ });
93
+ }
94
+ if (!info.isFile())
95
+ throw new MergeStoryError('USAGE', `${label}: ${path} is not a regular file.`);
96
+ const tooLarge = (size) => new MergeStoryError('USAGE', `${label}: ${path} is ${megabytes(size)}, the limit is ${megabytes(MAX_SCREENSHOT_BYTES)}.`, { hint: 'Resize or compress the image first.' });
97
+ if (info.size > MAX_SCREENSHOT_BYTES)
98
+ throw tooLarge(info.size);
99
+ const bytes = await readFile(absolute).catch(() => null);
100
+ if (bytes === null)
101
+ throw new MergeStoryError('USAGE', `${label}: cannot read ${path}.`);
102
+ // The file may have grown since it was measured.
103
+ if (bytes.length > MAX_SCREENSHOT_BYTES)
104
+ throw tooLarge(bytes.length);
105
+ if (!detectImage(bytes)) {
106
+ throw new MergeStoryError('USAGE', `${label}: ${path} is not a PNG or JPEG image (up to 40 megapixels).`, {
107
+ hint: 'Convert it to PNG or JPEG first. Other formats, such as WebP and GIF, are not supported.',
108
+ });
109
+ }
110
+ return absolute;
111
+ }
112
+ export async function buildContextInputs(options, cwd, warn = () => { }) {
113
+ if ((options?.tests?.length ?? 0) > MAX_TESTS)
114
+ warn(`Only the first ${MAX_TESTS} test results are used.`);
115
+ if ((options?.screenshots?.length ?? 0) > MAX_SCREENSHOTS)
116
+ warn(`Only the first ${MAX_SCREENSHOTS} screenshots are used.`);
117
+ const tests = checkTestResults((options?.tests ?? []).slice(0, MAX_TESTS)).map((t, i) => ({
118
+ id: `T${i + 1}`,
119
+ command: t.command.slice(0, MAX_TEST_COMMAND),
120
+ passed: t.passed,
121
+ summary: t.summary.slice(0, MAX_TEST_SUMMARY),
122
+ source: t.source,
123
+ }));
124
+ const screenshots = [];
125
+ for (const [i, shot] of (options?.screenshots ?? []).slice(0, MAX_SCREENSHOTS).entries()) {
126
+ screenshots.push({
127
+ id: `SS${i + 1}`,
128
+ path: await checkScreenshotFile(shot.path, cwd),
129
+ caption: (shot.caption ?? '').slice(0, MAX_CAPTION),
130
+ moment: shot.moment ?? 'other',
131
+ });
132
+ }
133
+ return {
134
+ task: normalizeContextText(options?.task, 'task description'),
135
+ notes: normalizeContextText(options?.notes, 'implementation notes'),
136
+ tests,
137
+ screenshots,
138
+ };
139
+ }
140
+ /** Ids of the screenshots that a storyboard shows. */
141
+ function shownScreenshots(storyboard) {
142
+ const shown = new Set();
143
+ for (const { visual } of storyboard.scenes) {
144
+ if (visual.type === 'screenshot')
145
+ shown.add(visual.screenshotId);
146
+ if (visual.type === 'before-after') {
147
+ for (const panel of [visual.before, visual.after]) {
148
+ if (panel.kind === 'screenshot' && panel.screenshotId)
149
+ shown.add(panel.screenshotId);
150
+ }
151
+ }
152
+ }
153
+ return shown;
154
+ }
155
+ /**
156
+ * A warning when screenshots were supplied but the storyboard does not show them all, or null.
157
+ * The offline storyboard never uses screenshots, which is worth saying because the person did
158
+ * pass them on purpose.
159
+ */
160
+ export function unusedScreenshotWarning(storyboard, inputs, source) {
161
+ const shown = shownScreenshots(storyboard);
162
+ const unused = inputs.screenshots.filter((shot) => !shown.has(shot.id));
163
+ if (unused.length === 0)
164
+ return null;
165
+ const names = unused.map((shot) => (shot.caption ? `${shot.id} ("${shot.caption}")` : shot.id)).join(', ');
166
+ const reason = source === 'heuristic'
167
+ ? ' The offline storyboard never uses screenshots: write the storyboard yourself (--storyboard) or use --llm to show them.'
168
+ : '';
169
+ return `${unused.length === 1 ? 'The screenshot' : 'The screenshots'} ${names} ${unused.length === 1 ? 'is' : 'are'} not shown in the video.${reason}`;
170
+ }
171
+ //# sourceMappingURL=inputs.js.map
@@ -0,0 +1,8 @@
1
+ /** The dry-run plan: what a real run would do, spend and send, without doing any of it. */
2
+ import { type MergeStoryError } from '../core/errors.ts';
3
+ import type { Storyboard } from '../core/storyboard-schema.ts';
4
+ import type { PlanResult } from '../core/types.ts';
5
+ import type { Prepared } from './prepare.ts';
6
+ import type { StoryboardChoice } from './storyboard-choice.ts';
7
+ /** The plan for a run that has chosen its storyboard. `warnings` are the ones found so far. */
8
+ export declare function planResult(p: Prepared, choice: StoryboardChoice, storyboard: Storyboard, warnings: string[], publishProblem: MergeStoryError | null): Promise<PlanResult>;
@@ -0,0 +1,85 @@
1
+ /** The dry-run plan: what a real run would do, spend and send, without doing any of it. */
2
+ import { describeProblem } from '../core/errors.js';
3
+ import { estimateNarrationCost, kokoroInstallNote, selectTtsProvider } from '../narration/index.js';
4
+ import { estimateVideoSeconds } from './fit-duration.js';
5
+ import { planEgress } from './planned-egress.js';
6
+ /** Rough size of a finished video, per second of it, for the plan of what an upload would send. */
7
+ const ESTIMATED_VIDEO_BYTES_PER_SEC = 120_000;
8
+ /** The plan for a run that has chosen its storyboard. `warnings` are the ones found so far. */
9
+ export async function planResult(p, choice, storyboard, warnings, publishProblem) {
10
+ const { ctx } = p;
11
+ const tts = await selectTtsProvider(ctx);
12
+ const speech = estimateNarrationCost(storyboard, tts, ctx);
13
+ const estimatedDurationSec = Math.round(estimateVideoSeconds(storyboard, {
14
+ language: p.config.language,
15
+ maskEmails: p.config.privacy.maskEmails,
16
+ }));
17
+ const planned = choice.source === 'llm' ? choice.plannedLlm : null;
18
+ const records = [];
19
+ if (choice.source === 'llm' && planned) {
20
+ records.push({
21
+ provider: choice.provider.id,
22
+ kind: 'llm',
23
+ model: choice.provider.model,
24
+ inputTokens: planned.inputTokens,
25
+ outputTokens: planned.outputTokens,
26
+ costUsd: planned.costUsd ?? 0,
27
+ estimated: true,
28
+ });
29
+ }
30
+ records.push({
31
+ provider: tts.id,
32
+ kind: 'tts',
33
+ model: tts.model(ctx),
34
+ characters: speech.characters,
35
+ costUsd: speech.costUsd,
36
+ estimated: true,
37
+ });
38
+ const totalUsd = records.reduce((s, r) => s + r.costUsd, 0);
39
+ const notes = [...warnings];
40
+ // A dry run never installs: it says what the first real run downloads.
41
+ const install = tts.id === 'kokoro' ? await kokoroInstallNote(ctx) : null;
42
+ if (install)
43
+ notes.push(install);
44
+ if (publishProblem) {
45
+ notes.push(`Publishing would fail: ${describeProblem(publishProblem)} A real run stops before it spends anything.`);
46
+ }
47
+ if (totalUsd > p.config.budgetUsd) {
48
+ notes.push(`Estimated cost $${totalUsd.toFixed(4)} is above the budget of $${p.config.budgetUsd.toFixed(2)}.`);
49
+ }
50
+ const egress = await planEgress({
51
+ ctx,
52
+ changeSet: p.changeSet,
53
+ llm: choice.source === 'llm' && planned
54
+ ? { host: choice.provider.endpointHost, promptBytes: planned.promptBytes }
55
+ : null,
56
+ tts,
57
+ narrationChars: speech.characters,
58
+ estimatedVideoBytes: estimatedDurationSec * ESTIMATED_VIDEO_BYTES_PER_SEC,
59
+ publishBlocked: publishProblem !== null,
60
+ });
61
+ notes.push(...egress.warnings);
62
+ return {
63
+ ok: true,
64
+ dryRun: true,
65
+ runId: ctx.runId,
66
+ runDir: ctx.runDir,
67
+ title: storyboard.title,
68
+ storyboardSource: choice.source,
69
+ estimatedDurationSec,
70
+ scenes: storyboard.scenes.map((s) => ({ id: s.id, role: s.role, title: s.title, visual: s.visual.type })),
71
+ providers: {
72
+ llm: choice.source === 'llm'
73
+ ? `${choice.provider.id}:${choice.provider.model}`
74
+ : choice.source === 'agent'
75
+ ? 'agent-supplied'
76
+ : 'none (offline)',
77
+ tts: tts.id,
78
+ publish: p.config.publish.provider,
79
+ },
80
+ estimatedCost: { totalUsd: Math.round(totalUsd * 1e6) / 1e6, budgetUsd: p.config.budgetUsd, records },
81
+ plannedEgress: egress.egress,
82
+ warnings: notes,
83
+ };
84
+ }
85
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1,21 @@
1
+ import type { RunContext } from '../core/context.ts';
2
+ import type { TtsProvider } from '../core/providers.ts';
3
+ import type { ChangeSet, EgressRecord } from '../core/types.ts';
4
+ export interface EgressPlanInput {
5
+ ctx: RunContext;
6
+ changeSet: Pick<ChangeSet, 'source' | 'pr'>;
7
+ /** The model that would write the storyboard, or null when none is called. */
8
+ llm: {
9
+ host: string;
10
+ promptBytes: number;
11
+ } | null;
12
+ tts: Pick<TtsProvider, 'plannedEgress'>;
13
+ narrationChars: number;
14
+ estimatedVideoBytes: number;
15
+ /** Publishing would fail before anything is sent (the publisher's check found a problem). */
16
+ publishBlocked: boolean;
17
+ }
18
+ export declare function planEgress(input: EgressPlanInput): Promise<{
19
+ egress: EgressRecord[];
20
+ warnings: string[];
21
+ }>;
@@ -0,0 +1,43 @@
1
+ import { parsePullRequestUrl } from '../github/pr-url.js';
2
+ import { createPublisher } from '../publish/index.js';
3
+ import { modelEgress } from '../storyboard/generate.js';
4
+ import { decidePullRequestUpdate } from './publish-run.js';
5
+ /** The host that the pull request is updated on: the API of the pull request's own host, as in the real run. */
6
+ function pullRequestHost(prUrl, config) {
7
+ try {
8
+ return new URL(parsePullRequestUrl(prUrl, config.github.apiUrl).apiUrl).host;
9
+ }
10
+ catch {
11
+ return new URL(config.github.apiUrl).host;
12
+ }
13
+ }
14
+ export async function planEgress(input) {
15
+ const { ctx, changeSet, tts } = input;
16
+ const { config } = ctx;
17
+ const egress = [];
18
+ const warnings = [];
19
+ const model = input.llm ? modelEgress(config, input.llm.host, input.llm.promptBytes) : null;
20
+ if (model)
21
+ egress.push(model);
22
+ egress.push(...(await tts.plannedEgress(ctx, input.narrationChars)));
23
+ const publisher = createPublisher(config);
24
+ if (publisher && !input.publishBlocked) {
25
+ egress.push(...publisher.plannedEgress(input.estimatedVideoBytes));
26
+ }
27
+ const update = decidePullRequestUpdate(config, { source: changeSet.source, prUrl: changeSet.pr?.url ?? null }, publisher?.id ?? null);
28
+ if (update.kind === 'not-a-pull-request') {
29
+ warnings.push('The pull request would not be updated: this change does not come from a GitHub pull request.');
30
+ }
31
+ else if (update.kind === 'video-stays-local') {
32
+ warnings.push('The pull request would not be updated: the video stays on this machine. Publish it first (for example --publish s3).');
33
+ }
34
+ else if (update.kind === 'update' && !input.publishBlocked) {
35
+ const destination = pullRequestHost(update.prUrl, config);
36
+ if (config.github.comment)
37
+ egress.push({ destination, purpose: 'pull request comment', bytes: 4000, contains: ['comment'] });
38
+ if (config.github.updateDescription)
39
+ egress.push({ destination, purpose: 'pull request description', bytes: 4000, contains: ['comment'] });
40
+ }
41
+ return { egress, warnings };
42
+ }
43
+ //# sourceMappingURL=planned-egress.js.map
@@ -0,0 +1,26 @@
1
+ import { type Config } from '../core/config.ts';
2
+ import { type RunContext } from '../core/context.ts';
3
+ import { MergeStoryError } from '../core/errors.ts';
4
+ import type { Analysis, ChangeSet, ContextInputs, RepoReader } from '../core/types.ts';
5
+ import type { GenerateHooks, GenerateOptions } from './types.ts';
6
+ export interface Prepared {
7
+ ctx: RunContext;
8
+ config: Config;
9
+ changeSet: ChangeSet;
10
+ reader: RepoReader;
11
+ inputs: ContextInputs;
12
+ analysis: Analysis;
13
+ targetSec: number;
14
+ /** A publish setting that would make the upload fail. Only looked for when asked (see PrepareSettings). */
15
+ publishProblem: MergeStoryError | null;
16
+ }
17
+ export interface PrepareSettings {
18
+ /** Look for publish settings that would fail, and (unless this is a dry run) stop on the first one. */
19
+ checkPublishing?: boolean;
20
+ /** Write analysis.json (and so create the run folder). On by default; off for a caller that only reads the change. */
21
+ writeAnalysis?: boolean;
22
+ }
23
+ /** Read the change, check the context, analyse, and write analysis.json into the run folder. */
24
+ export declare function prepare(options: Omit<GenerateOptions, 'storyboard'>, hooks: GenerateHooks, outDirOverride?: string | null, settings?: PrepareSettings): Promise<Prepared>;
25
+ /** The evidence pack for the model or for an author, cut to `maxTokens`. */
26
+ export declare function packFor(p: Prepared, maxTokens: number): import("../analyzer/pack.ts").EvidencePack;
@@ -0,0 +1,84 @@
1
+ /** The first half of every run: read the change, check the context and analyse it. */
2
+ import { analyze, buildEvidencePack, targetDuration } from '../analyzer/index.js';
3
+ import { resolveConfig } from '../core/config.js';
4
+ import { createRunContext } from '../core/context.js';
5
+ import { assertNotAborted, MergeStoryError } from '../core/errors.js';
6
+ import { newRunId } from '../core/ids.js';
7
+ import { ensureDir, runDirFor } from '../core/paths.js';
8
+ import { runFolder, writeRunJson } from '../core/run-folder.js';
9
+ import { createPublisher } from '../publish/index.js';
10
+ import { createSourceProvider, detectSourceInput } from '../sources/index.js';
11
+ import { buildContextInputs } from './inputs.js';
12
+ import { changeLabel } from './presentation.js';
13
+ function sourceInputFrom(options, cwd) {
14
+ if (typeof options.source !== 'string')
15
+ return options.source;
16
+ return detectSourceInput(options.source, { base: options.base ?? null, head: options.head ?? null, cwd });
17
+ }
18
+ function describeSource(input) {
19
+ return input.kind === 'github'
20
+ ? input.url
21
+ : `local repository (${input.base ?? 'merge base'}..${input.head ?? 'HEAD'})`;
22
+ }
23
+ /** Read the change, check the context, analyse, and write analysis.json into the run folder. */
24
+ export async function prepare(options, hooks, outDirOverride, settings = {}) {
25
+ const cwd = process.cwd();
26
+ const config = resolveConfig({ overrides: options.config, configPath: options.configPath });
27
+ const runId = options.runId ?? newRunId();
28
+ // The folder is created once there is something to put in it, so a run that fails early leaves nothing behind.
29
+ const runDir = runDirFor(runId, outDirOverride ?? config.outDir, config.home);
30
+ const ctx = createRunContext({
31
+ config,
32
+ runId,
33
+ runDir,
34
+ dryRun: options.dryRun ?? false,
35
+ ...(options.logger ? { logger: options.logger } : {}),
36
+ ...(options.signal ? { signal: options.signal } : {}),
37
+ ...(hooks.onProgress ? { onProgress: hooks.onProgress } : {}),
38
+ });
39
+ const input = sourceInputFrom(options, cwd);
40
+ ctx.progress({ stage: 'source', status: 'start', message: `Reading ${describeSource(input)}` });
41
+ const { changeSet, reader } = await createSourceProvider(input).load(input, ctx);
42
+ ctx.progress({
43
+ stage: 'source',
44
+ status: 'done',
45
+ message: `${changeLabel(changeSet)}: ${changeSet.stats.files} files, +${changeSet.stats.additions} -${changeSet.stats.deletions}`,
46
+ });
47
+ if (changeSet.files.length === 0) {
48
+ throw new MergeStoryError('SOURCE_INVALID', 'There are no changes to explain.', {
49
+ hint: 'Check the base and head refs. Only committed changes are included for local repositories.',
50
+ });
51
+ }
52
+ assertNotAborted(ctx.signal);
53
+ // A setting that would make the upload fail is found now, before anything is written, spent or rendered.
54
+ const publishProblem = settings.checkPublishing
55
+ ? ((await createPublisher(config)?.check(ctx, changeSet.repo.isPrivate)) ?? null)
56
+ : null;
57
+ if (publishProblem && !ctx.dryRun)
58
+ throw publishProblem;
59
+ const inputs = await buildContextInputs(options.context, cwd, (message) => ctx.progress({ stage: 'source', status: 'warn', message }));
60
+ ctx.progress({ stage: 'analyze', status: 'start', message: 'Analysing the change' });
61
+ const analysis = await analyze(changeSet, reader, inputs, ctx);
62
+ const targetSec = targetDuration(analysis, config);
63
+ ctx.progress({
64
+ stage: 'analyze',
65
+ status: 'done',
66
+ message: `Size ${analysis.size.toUpperCase()}, ${analysis.components.length} components, ${analysis.risks.length} review signals, target ${targetSec}s`,
67
+ });
68
+ if (settings.writeAnalysis ?? true) {
69
+ await ensureDir(runDir);
70
+ await writeRunJson(runFolder(runDir).analysis, analysis);
71
+ }
72
+ return { ctx, config, changeSet, reader, inputs, analysis, targetSec, publishProblem };
73
+ }
74
+ /** The evidence pack for the model or for an author, cut to `maxTokens`. */
75
+ export function packFor(p, maxTokens) {
76
+ return buildEvidencePack(p.changeSet, p.analysis, p.inputs, {
77
+ maxTokens,
78
+ llmContext: p.config.privacy.llmContext,
79
+ targetDurationSec: p.targetSec,
80
+ style: p.config.style,
81
+ language: p.config.language,
82
+ });
83
+ }
84
+ //# sourceMappingURL=prepare.js.map
@@ -0,0 +1,26 @@
1
+ /** Builds the data for the watch page and the PR comment from a validated storyboard. */
2
+ import type { Storyboard } from '../core/storyboard-schema.ts';
3
+ import type { Analysis, ChangeSet, Chapter, CodeRef, PublishResult } from '../core/types.ts';
4
+ import type { CommentData, WatchPageData } from '../publish/index.ts';
5
+ export declare function changeLabel(changeSet: ChangeSet): string;
6
+ export declare function repoLabel(changeSet: ChangeSet): string;
7
+ /** Link to a line range at the exact commit, when the repository has a known web URL. */
8
+ export declare function codeRefUrl(changeSet: ChangeSet, ref: CodeRef): string | null;
9
+ export declare function reviewChecklist(storyboard: Storyboard, changeSet: ChangeSet): WatchPageData['checklist'];
10
+ export interface PresentationInput {
11
+ storyboard: Storyboard;
12
+ storyboardSource: 'llm' | 'agent' | 'heuristic';
13
+ changeSet: ChangeSet;
14
+ analysis: Analysis;
15
+ chapters: Chapter[];
16
+ durationSec: number;
17
+ generator: {
18
+ llm: string | null;
19
+ tts: string;
20
+ };
21
+ generatedAt: string;
22
+ /** true when the captions are drawn into the video, so the page's own caption track starts off. */
23
+ captionsBurnedIn: boolean;
24
+ }
25
+ export declare function buildWatchPageData(input: PresentationInput): WatchPageData;
26
+ export declare function buildCommentData(watch: WatchPageData, publish: PublishResult, headSha: string): CommentData;
@@ -0,0 +1,110 @@
1
+ /** Builds the data for the watch page and the PR comment from a validated storyboard. */
2
+ import { isSimulated } from '../core/storyboard-facts.js';
3
+ import { collapseLineRange } from '../core/text.js';
4
+ import { ENGINE_VERSION } from '../version.js';
5
+ export function changeLabel(changeSet) {
6
+ return changeSet.pr ? `PR #${changeSet.pr.number}` : changeSet.head.ref;
7
+ }
8
+ export function repoLabel(changeSet) {
9
+ return changeSet.repo.owner ? `${changeSet.repo.owner}/${changeSet.repo.name}` : changeSet.repo.name;
10
+ }
11
+ /** Link to a line range at the exact commit, when the repository has a known web URL. */
12
+ export function codeRefUrl(changeSet, ref) {
13
+ if (!changeSet.repo.webUrl)
14
+ return null;
15
+ const sha = ref.side === 'head' ? changeSet.head.sha : changeSet.base.sha;
16
+ const path = ref.path.split('/').map(encodeURIComponent).join('/');
17
+ return `${changeSet.repo.webUrl}/blob/${sha}/${path}#L${ref.startLine}-L${ref.endLine}`;
18
+ }
19
+ function refLink(changeSet, ref) {
20
+ if (!ref)
21
+ return null;
22
+ return {
23
+ label: collapseLineRange(`${ref.path}:${ref.startLine}-${ref.endLine}`),
24
+ url: codeRefUrl(changeSet, ref),
25
+ };
26
+ }
27
+ function evidenceLinks(ids, analysis) {
28
+ const byId = new Map(analysis.evidence.map((e) => [e.id, e]));
29
+ const links = [];
30
+ for (const id of ids) {
31
+ const item = byId.get(id);
32
+ if (item)
33
+ links.push({ label: collapseLineRange(item.label), url: item.url });
34
+ }
35
+ return links;
36
+ }
37
+ export function reviewChecklist(storyboard, changeSet) {
38
+ const fromBoard = storyboard.reviewChecklist.map((item) => ({
39
+ title: item.title,
40
+ detail: item.detail,
41
+ severity: item.severity,
42
+ ref: refLink(changeSet, item.ref),
43
+ }));
44
+ if (fromBoard.length > 0)
45
+ return fromBoard;
46
+ const items = [];
47
+ for (const scene of storyboard.scenes) {
48
+ if (scene.visual.type !== 'checklist')
49
+ continue;
50
+ for (const item of scene.visual.items) {
51
+ items.push({
52
+ title: item.title,
53
+ detail: item.detail,
54
+ severity: item.severity,
55
+ ref: refLink(changeSet, item.ref),
56
+ });
57
+ }
58
+ }
59
+ return items;
60
+ }
61
+ export function buildWatchPageData(input) {
62
+ const { storyboard, changeSet, analysis } = input;
63
+ const claims = [];
64
+ for (const scene of storyboard.scenes) {
65
+ for (const line of scene.narration) {
66
+ claims.push({
67
+ chapter: scene.title,
68
+ text: line.text,
69
+ evidence: evidenceLinks(line.evidence, analysis),
70
+ });
71
+ }
72
+ }
73
+ const hasSimulated = storyboard.scenes.some((s) => isSimulated(s.visual));
74
+ return {
75
+ title: storyboard.title,
76
+ summary: storyboard.summary,
77
+ repoLabel: repoLabel(changeSet),
78
+ changeLabel: changeLabel(changeSet),
79
+ changeUrl: changeSet.pr?.url ?? null,
80
+ headSha: changeSet.head.sha,
81
+ durationSec: input.durationSec,
82
+ chapters: input.chapters,
83
+ checklist: reviewChecklist(storyboard, changeSet),
84
+ claims,
85
+ uncertainties: storyboard.uncertainties,
86
+ storyboardSource: input.storyboardSource,
87
+ generator: input.generator,
88
+ hasSimulatedVisuals: hasSimulated,
89
+ generatedAt: input.generatedAt,
90
+ engineVersion: ENGINE_VERSION,
91
+ captionsDefault: !input.captionsBurnedIn,
92
+ language: storyboard.language,
93
+ };
94
+ }
95
+ export function buildCommentData(watch, publish, headSha) {
96
+ return {
97
+ title: watch.title,
98
+ summary: watch.summary,
99
+ watchUrl: publish.watchUrl ?? publish.videoUrl,
100
+ posterUrl: publish.posterUrl,
101
+ durationSec: watch.durationSec,
102
+ chapters: watch.chapters,
103
+ checklist: watch.checklist,
104
+ headSha,
105
+ linkExpiresAt: publish.expiresAt,
106
+ visibility: publish.visibility,
107
+ provider: publish.provider,
108
+ };
109
+ }
110
+ //# sourceMappingURL=presentation.js.map
@@ -0,0 +1,71 @@
1
+ import { type Config } from '../core/config.ts';
2
+ import { type RunContext } from '../core/context.ts';
3
+ import { MergeStoryError } from '../core/errors.ts';
4
+ import { type StoredPublishInput } from '../core/run-folder.ts';
5
+ import type { GenerateResult, PublishResult } from '../core/types.ts';
6
+ import type { GenerateHooks, PublishRunOptions } from './types.ts';
7
+ /** The files to upload. */
8
+ export interface RunFiles {
9
+ video: string;
10
+ poster: string | null;
11
+ captions: string | null;
12
+ }
13
+ export interface PublishOutcome {
14
+ publish: PublishResult | null;
15
+ notify: GenerateResult['notify'];
16
+ warnings: string[];
17
+ /** Set when the upload failed. Nothing was published; the caller keeps the run and reports this. */
18
+ failure: MergeStoryError | null;
19
+ }
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 declare function runFilesIn(runDir: string): Promise<RunFiles>;
25
+ /**
26
+ * What happens to the pull request after publishing. The real run and the dry-run plan decide it here
27
+ * and each word the outcome for their own reader.
28
+ */
29
+ type PullRequestUpdate = {
30
+ kind: 'update';
31
+ prUrl: string;
32
+ }
33
+ /** Neither a comment nor a description update was asked for. */
34
+ | {
35
+ kind: 'not-requested';
36
+ } | {
37
+ kind: 'not-a-pull-request';
38
+ }
39
+ /** A link to a file on this machine is useless to reviewers and would expose a local path. */
40
+ | {
41
+ kind: 'video-stays-local';
42
+ };
43
+ /**
44
+ * `publishedWith` is the publisher that the video goes through (its id, or the provider of the result),
45
+ * or null when nothing is published.
46
+ */
47
+ export declare function decidePullRequestUpdate(config: Pick<Config, 'github'>, change: {
48
+ source: 'github' | 'local';
49
+ prUrl: string | null;
50
+ }, publishedWith: string | null): PullRequestUpdate;
51
+ /**
52
+ * Upload with the configured publisher (if any), then update the pull request when asked. A failed
53
+ * upload does not throw: it comes back as `failure`, so the caller can save the run first. A failed
54
+ * pull request update is a warning, because the video is already published.
55
+ */
56
+ export declare function publishAndNotify(ctx: RunContext, stored: StoredPublishInput, files: RunFiles): Promise<PublishOutcome>;
57
+ /**
58
+ * Redact a result before it is stored, but keep the published links intact: they are what the
59
+ * user asked for, and a presigned link with its signature removed no longer works.
60
+ */
61
+ export declare function redactResultForDisk<T extends {
62
+ publish: PublishResult | null;
63
+ }>(result: T): T;
64
+ /** Write result.json (see writeRunJson). */
65
+ export declare function saveResult(runDir: string, result: GenerateResult): Promise<void>;
66
+ /**
67
+ * Publish a run that was rendered earlier (mergestory publish). Lets a person or an agent review
68
+ * the local video first and upload or comment only after approval. No rendering happens here.
69
+ */
70
+ export declare function publishRun(options: PublishRunOptions, hooks?: GenerateHooks): Promise<GenerateResult>;
71
+ export {};