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,129 @@
1
+ /**
2
+ * The run folder: where a run keeps its files, and how the two files that later steps read back
3
+ * (publish-input.json and result.json) are written and checked. Every other module asks this one
4
+ * for a path instead of spelling the name out.
5
+ */
6
+ import { existsSync } from 'node:fs';
7
+ import { readFile, rename, writeFile } from 'node:fs/promises';
8
+ import { join } from 'node:path';
9
+ import { z } from 'zod';
10
+ import { MergeStoryError } from './errors.js';
11
+ import { randomToken } from './ids.js';
12
+ import { isRecord } from './json.js';
13
+ /** The fixed names inside a run folder. The files that publishing uploads are always these. */
14
+ export const RUN_FILE = {
15
+ analysis: 'analysis.json',
16
+ evidence: 'evidence.md',
17
+ guide: 'AUTHORING.md',
18
+ schema: 'storyboard.schema.json',
19
+ storyboard: 'storyboard.json',
20
+ grounding: 'grounding.json',
21
+ renderPlan: 'render-plan.json',
22
+ audio: 'audio.wav',
23
+ captions: 'captions.vtt',
24
+ captionsSrt: 'captions.srt',
25
+ video: 'video.mp4',
26
+ poster: 'poster.jpg',
27
+ /** Everything needed to publish the run again later. */
28
+ publishInput: 'publish-input.json',
29
+ /** The result of the run, as printed. */
30
+ result: 'result.json',
31
+ };
32
+ /** Folders inside a run folder. */
33
+ export const RUN_DIR = { watch: 'watch', publish: 'publish' };
34
+ /** The name of the watch page inside the watch and publish folders. */
35
+ export const WATCH_PAGE_FILE = 'index.html';
36
+ /** The paths of a run folder's files. */
37
+ export function runFolder(runDir) {
38
+ const paths = Object.fromEntries(Object.entries(RUN_FILE).map(([key, name]) => [key, join(runDir, name)]));
39
+ const watchDir = join(runDir, RUN_DIR.watch);
40
+ return { ...paths, watchDir, watchPage: join(watchDir, WATCH_PAGE_FILE) };
41
+ }
42
+ /** The `files` of a result for a run folder. `poster` is null when the run has no poster image. */
43
+ export function resultFiles(runDir) {
44
+ const folder = runFolder(runDir);
45
+ return {
46
+ video: folder.video,
47
+ poster: existsSync(folder.poster) ? folder.poster : null,
48
+ captions: folder.captions,
49
+ storyboard: folder.storyboard,
50
+ watchPage: folder.watchPage,
51
+ };
52
+ }
53
+ /** Write a JSON file in one step, so that a run that is stopped halfway never leaves half a file. */
54
+ export async function writeRunJson(path, value) {
55
+ const temporary = `${path}.${randomToken(4)}.tmp`;
56
+ await writeFile(temporary, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600 });
57
+ await rename(temporary, path);
58
+ }
59
+ function notARunFile(name, why) {
60
+ return new MergeStoryError('SOURCE_INVALID', `${name} is not a MergeStory run file (${why}).`, {
61
+ hint: 'Pass a run folder that `mergestory generate` wrote.',
62
+ });
63
+ }
64
+ /** Check a value that was read from a run file. `name` is the file name, for the error. */
65
+ export function parseRunJson(value, schema, name) {
66
+ const parsed = schema.safeParse(value);
67
+ if (!parsed.success)
68
+ throw notARunFile(name, parsed.error.issues[0]?.message ?? 'unexpected content');
69
+ return parsed.data;
70
+ }
71
+ /** Read a run file and check its shape. A missing file, bad JSON and a wrong shape are all SOURCE_INVALID. */
72
+ export async function readRunJson(path, schema, name) {
73
+ let text;
74
+ try {
75
+ text = await readFile(path, 'utf8');
76
+ }
77
+ catch (err) {
78
+ throw new MergeStoryError('SOURCE_INVALID', `${name} cannot be read.`, {
79
+ hint: 'Pass a run folder that `mergestory generate` wrote.',
80
+ cause: err,
81
+ });
82
+ }
83
+ let value;
84
+ try {
85
+ value = JSON.parse(text);
86
+ }
87
+ catch {
88
+ throw notARunFile(name, 'not valid JSON');
89
+ }
90
+ return parseRunJson(value, schema, name);
91
+ }
92
+ /** The data of the watch page, as far as publishing needs to trust it. */
93
+ function isWatchData(value) {
94
+ return (isRecord(value) &&
95
+ typeof value.title === 'string' &&
96
+ typeof value.summary === 'string' &&
97
+ ['chapters', 'checklist', 'claims', 'uncertainties'].every((key) => Array.isArray(value[key])));
98
+ }
99
+ /**
100
+ * publish-input.json: what publishing needs to know about a run. The folder may come from
101
+ * somewhere else, so the shape is checked and nothing in it is trusted to name files: the files
102
+ * are always the fixed names inside the folder (see RUN_FILE). Fields that older versions wrote
103
+ * and that are not listed here are ignored.
104
+ */
105
+ export const PublishInputSchema = z.looseObject({
106
+ version: z.literal(1, { error: 'unknown version' }),
107
+ runId: z.string({ error: 'no run id' }).min(1, 'no run id').max(200, 'no run id'),
108
+ source: z.enum(['github', 'local'], { error: 'unknown source' }),
109
+ prUrl: z.string({ error: 'bad pull request link' }).nullable(),
110
+ repoIsPrivate: z.boolean({ error: 'bad repository privacy' }).nullable(),
111
+ headSha: z.string({ error: 'no commit or language' }),
112
+ /** Narration language (BCP 47). */
113
+ language: z.string({ error: 'no commit or language' }),
114
+ watch: z.custom(isWatchData, { error: 'no watch page data' }),
115
+ }, { error: () => 'unknown version' });
116
+ const ResultShape = z.looseObject({
117
+ ok: z.literal(true),
118
+ cost: z.looseObject({ records: z.array(z.unknown()) }),
119
+ egress: z.array(z.unknown()),
120
+ warnings: z.array(z.unknown()),
121
+ files: z.looseObject({}),
122
+ });
123
+ /** result.json: the shape is checked, and the rest is trusted because this program wrote it. */
124
+ export const StoredResultSchema = z.custom((value) => ResultShape.safeParse(value).success);
125
+ /** The part of render-plan.json that publishing reads: whether the captions are drawn into the video. */
126
+ export const RenderPlanCaptionsSchema = z.looseObject({
127
+ captions: z.looseObject({ enabled: z.boolean() }),
128
+ });
129
+ //# sourceMappingURL=run-folder.js.map
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Secret detection for repository content.
3
+ *
4
+ * Applied to every code line shown in a video, every on-screen string, every narration line,
5
+ * and to the diff before it is sent to an LLM provider. Detection is deliberately eager:
6
+ * masking a harmless string costs little, showing a live credential in a shared video costs a lot.
7
+ */
8
+ export interface SecretMatch {
9
+ rule: string;
10
+ start: number;
11
+ end: number;
12
+ }
13
+ /** A credential known by its form alone: the whole match is the secret. */
14
+ export interface TokenShape {
15
+ name: string;
16
+ /** A global regular expression. */
17
+ pattern: RegExp;
18
+ }
19
+ /**
20
+ * Tokens with a known prefix and form, masked wherever they appear. The log redactor in redact.ts
21
+ * builds its token rules from this list too, so a token that is masked in a video is also kept out
22
+ * of the logs.
23
+ */
24
+ export declare const TOKEN_SHAPES: readonly TokenShape[];
25
+ /** Find secrets in a string. Overlapping matches are merged. */
26
+ export declare function findSecrets(text: string): SecretMatch[];
27
+ export declare const MASK_CHAR = "\u2022";
28
+ /** Replace every detected secret with mask characters (length capped so masks do not leak length). */
29
+ export declare function maskSecrets(text: string): {
30
+ text: string;
31
+ masked: number;
32
+ };
33
+ /**
34
+ * Files that hold credentials, whose content is never shown in a video and never sent to a provider.
35
+ * Everything else is shown as it is: explaining the real code is the point of the video.
36
+ */
37
+ export declare function isSensitivePath(path: string): boolean;
38
+ /** Mask e-mail addresses (personal data) in on-screen text and narration. */
39
+ export declare function maskEmails(text: string): string;
40
+ export interface PrivateMaskOptions {
41
+ /** Also mask e-mail addresses (the privacy.maskEmails setting). */
42
+ maskEmails: boolean;
43
+ }
44
+ export interface PrivateMaskReport {
45
+ text: string;
46
+ /** Secrets found by maskSecrets. */
47
+ secrets: number;
48
+ /** Whether masking secrets changed the text; text that is already masked can match again without changing. */
49
+ secretsChanged: boolean;
50
+ /** Whether masking e-mail addresses changed the text. */
51
+ emailsChanged: boolean;
52
+ }
53
+ /** maskPrivate, plus what each step did, for callers that count what they masked. */
54
+ export declare function maskPrivateReport(text: string, options: PrivateMaskOptions): PrivateMaskReport;
55
+ /** Mask secrets, then e-mail addresses when `maskEmails` is set. */
56
+ export declare function maskPrivate(text: string, options: PrivateMaskOptions): string;
@@ -0,0 +1,301 @@
1
+ /**
2
+ * Secret detection for repository content.
3
+ *
4
+ * Applied to every code line shown in a video, every on-screen string, every narration line,
5
+ * and to the diff before it is sent to an LLM provider. Detection is deliberately eager:
6
+ * masking a harmless string costs little, showing a live credential in a shared video costs a lot.
7
+ */
8
+ /**
9
+ * Tokens with a known prefix and form, masked wherever they appear. The log redactor in redact.ts
10
+ * builds its token rules from this list too, so a token that is masked in a video is also kept out
11
+ * of the logs.
12
+ */
13
+ export const TOKEN_SHAPES = [
14
+ {
15
+ name: 'private-key',
16
+ pattern: /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY-----|$)/g,
17
+ },
18
+ { name: 'aws-access-key-id', pattern: /\b(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA|ANVA|AIPA)[0-9A-Z]{16}\b/g },
19
+ { name: 'github-token', pattern: /\b(?:gh[pousr]_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{30,})/g },
20
+ { name: 'gitlab-token', pattern: /\bglpat-[A-Za-z0-9_-]{20,}\b/g },
21
+ { name: 'anthropic-key', pattern: /\bsk-ant-[A-Za-z0-9_-]{16,}/g },
22
+ { name: 'openai-key', pattern: /\bsk-(?:proj-|svcacct-|admin-)?[A-Za-z0-9_-]{20,}/g },
23
+ { name: 'stripe-key', pattern: /\b(?:sk|rk|pk)_(?:live|test)_[A-Za-z0-9]{16,}\b/g },
24
+ { name: 'slack-token', pattern: /\bxox[abposr]-[A-Za-z0-9-]{10,}/g },
25
+ { name: 'slack-webhook', pattern: /https:\/\/hooks\.slack\.com\/services\/[A-Za-z0-9/_-]+/g },
26
+ { name: 'google-api-key', pattern: /\bAIza[0-9A-Za-z_-]{35}\b/g },
27
+ { name: 'npm-token', pattern: /\bnpm_[A-Za-z0-9]{36}\b/g },
28
+ { name: 'sendgrid-key', pattern: /\bSG\.[A-Za-z0-9_-]{16,}\.[A-Za-z0-9_-]{16,}\b/g },
29
+ { name: 'twilio-key', pattern: /\bSK[0-9a-fA-F]{32}\b/g },
30
+ { name: 'jwt', pattern: /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g },
31
+ // Authorization header values. Only the credential is masked, so "Bearer" or "Basic" stays readable.
32
+ // Right after an Authorization header any value counts. Elsewhere a Bearer value must look like a token
33
+ // (a digit or sign inside it, mixed case, or 32 letters) and a Basic value needs a digit or base64 sign,
34
+ // so prose such as "Bearer authentication" or "Basic authentication" stays.
35
+ {
36
+ name: 'authorization-header',
37
+ pattern: /(?<=\b[Aa]uthorization["']?\s{0,8}[:=]\s{0,8}["']?(?:[Bb]earer|[Bb]asic)\s{1,8})[A-Za-z0-9._~+/-]{8,}=*|(?<=\b[Bb]earer\s{1,8})(?=[A-Za-z]*[0-9._~+/-][A-Za-z0-9._~+/-]|[A-Za-z]*[a-z][A-Z]|[A-Za-z]{32})[A-Za-z0-9._~+/-]{12,}=*|(?<=\b[Bb]asic\s{1,8})(?=[A-Za-z]*[0-9+/=])[A-Za-z0-9+/]{12,}={0,2}/g,
38
+ },
39
+ // Key headers written as text, such as -H "X-Api-Key: ..." in a curl command.
40
+ {
41
+ name: 'api-key-header',
42
+ pattern: /(?<=\b(?:x-)?(?:api-key|auth-token|access-token)["']?[ \t]{0,8}:[ \t]{0,8}["']?)[A-Za-z0-9._~+/=-]{8,}/gi,
43
+ },
44
+ ];
45
+ const RULES = [
46
+ ...TOKEN_SHAPES,
47
+ // scheme://user:password@host -> mask the password
48
+ {
49
+ name: 'url-credentials',
50
+ pattern: /\b[a-z][a-z0-9+.-]{0,30}:\/\/[^\s/:@'"]{1,256}:([^\s@'"/]{3,256})@/gi,
51
+ group: 1,
52
+ },
53
+ ];
54
+ /*
55
+ * Assignments such as `password = "..."`, `apiKey: '...'` or `SECRET_TOKEN=...` are matched in two
56
+ * steps: a pattern with bounded repetition finds "name, operator, value", and plain code then checks
57
+ * the name and the value. One combined pattern with open-ended repetition around the keyword would
58
+ * backtrack catastrophically on long runs of word characters (minified files, generated data).
59
+ */
60
+ const ASSIGNMENT = /(?<![\w.$-])([A-Za-z_$][\w.$-]{0,63})["']?[ \t]{0,8}(?:=>|:=|[:=])[ \t]{0,8}["'`]([^"'`\s]{6,512})["'`]/g;
61
+ const ENV_ASSIGNMENT = /^[ \t]*(?:export[ \t]+)?([A-Z][A-Z0-9_]{0,63})[ \t]*=[ \t]*([^\s#'"]{6,512})/gm;
62
+ /** Names that always hold a secret: any non-placeholder value is masked. */
63
+ const STRONG_NAME = /(pass(word|wd)?|secret|api[_-]?key|access[_-]?key|private[_-]?key|credential)/i;
64
+ /** Names that often but not always hold one (tokenType, KEY_PREFIX): only secret-looking values are masked. */
65
+ const WEAK_NAME = /(token|auth(?!or)|key)/i;
66
+ const PLACEHOLDER = /^(?:changeme|change[_-]?me|example|dummy|placeholder|redacted|password|secret|none|null|undefined|true|false|xxx+|\*+|•+)$/i;
67
+ /** Placeholders, templates and references to the environment are not secrets. */
68
+ function isPlaceholder(value) {
69
+ if (value.length < 8 || PLACEHOLDER.test(value))
70
+ return true;
71
+ if (/^\$\{.*\}$|^\{\{.*\}\}$|^<.*>$|^%.*%$/.test(value))
72
+ return true; // ${VAR}, {{var}}, <value>, %VAR%
73
+ return /^(?:process\.env|os\.environ|env\.|import\.meta\.env)/.test(value);
74
+ }
75
+ /** Whether an assigned value should be masked, given the name it is assigned to. */
76
+ function shouldMask(name, value) {
77
+ if (isPlaceholder(value))
78
+ return false;
79
+ if (STRONG_NAME.test(name))
80
+ return true;
81
+ if (!WEAK_NAME.test(name))
82
+ return false;
83
+ const classes = [/[a-z]/, /[A-Z]/, /[0-9]/, /[^A-Za-z0-9]/].filter((r) => r.test(value)).length;
84
+ return classes >= 2 || value.length >= 20;
85
+ }
86
+ /*
87
+ * Unquoted values in configuration files: YAML (`password: x`, `- POSTGRES_PASSWORD=x`), Java
88
+ * properties (`spring.datasource.password=x`), INI (`aws_secret_access_key = x`) and kubeconfig
89
+ * (`client-key-data: <base64>`). The value runs to the end of the line (a ` #` comment aside), so
90
+ * only lines that hold nothing else match, and values of any length are masked whole.
91
+ */
92
+ const UNQUOTED_ASSIGNMENT = /^[ \t]*(?:-[ \t]{1,8})?(?:export[ \t]{1,8})?([A-Za-z_][\w.-]{0,63})[ \t]{0,8}(?::[ \t]{1,8}|=[ \t]{0,8})([^\s"'`]\S*)(?:[ \t]+#[^\r\n]*)?[ \t]*$/dgm;
93
+ /** Names for a setting about a secret, not the secret: secretName, password_file, api_key_header. */
94
+ const REFERENCE_NAME = /(?:name|file|path|ref|type|header|url|uri|endpoint|helper|provider|backend|store|source|arn)$/i;
95
+ /** Environment-style names (POSTGRES_PASSWORD), whose values are values even when written like a variable. */
96
+ const ENV_NAME = /^[A-Z][A-Z0-9_]*$/;
97
+ /** A variable, member, call, index or type: `hashedPassword`, `config.apiKey`, `getSecret()`, `Option<String>`. */
98
+ const CODE_VALUE = /^[&*!]*[A-Za-z_$][\w$]*(?:(?:\?\.|\.|::|->)[A-Za-z_$][\w$]*|\[[^\]\s]*\]|\([^)\s]*\)|<\S*)*[!?]?$/;
99
+ /** Whether an unquoted value is code that names a secret rather than the secret itself. */
100
+ function readsLikeCode(name, value) {
101
+ const ended = /[,;]$/.test(value);
102
+ const bare = ended ? value.slice(0, -1) : value;
103
+ if (bare.length > 256 || !CODE_VALUE.test(bare))
104
+ return false;
105
+ // A property or a statement (`password: hashedPassword,`), or a variable of the same name
106
+ // (`this.credentials = credentials`).
107
+ if (ended || bare.toLowerCase() === name.slice(name.lastIndexOf('.') + 1).toLowerCase())
108
+ return true;
109
+ // POSTGRES_PASSWORD: my_db_password in a compose file is a value.
110
+ if (ENV_NAME.test(name))
111
+ return false;
112
+ if (/[.:[(<>]/.test(bare))
113
+ return true;
114
+ // A single word is a variable when it is written like one (hashedPassword, db_password) and has
115
+ // no digits. A word like Pr0dPassw0rd or postgres is taken for the value it most likely is.
116
+ return !/[0-9]/.test(bare) && /[a-z][A-Z]|_|\$|^[&*]/.test(bare);
117
+ }
118
+ /** A generated token: long, made of token characters (base64, hex, URL-safe), and random or hex. */
119
+ function looksLikeToken(value) {
120
+ if (value.length < 16 || !/^[A-Za-z0-9+/=_.~-]+$/.test(value))
121
+ return false;
122
+ return looksRandom(value) || (/^[a-f0-9]+$/i.test(value) && /[0-9]/.test(value) && /[a-f]/i.test(value));
123
+ }
124
+ /**
125
+ * Whether an unquoted value should be masked. Strong names mask any value that is not a
126
+ * placeholder or code; weak names (token, key) only mask values that look generated.
127
+ */
128
+ function shouldMaskUnquoted(name, value) {
129
+ // `password: undefined,` in code: the trailing comma or semicolon is not part of the value.
130
+ const bare = value.replace(/[,;]$/, '');
131
+ if (REFERENCE_NAME.test(name) || isPlaceholder(bare) || readsLikeCode(name, value))
132
+ return false;
133
+ if (STRONG_NAME.test(name))
134
+ return true;
135
+ return WEAK_NAME.test(name) && looksLikeToken(bare);
136
+ }
137
+ /** Long high-entropy literals inside quotes, e.g. hard-coded keys without a telling name. */
138
+ const QUOTED_LITERAL = /["'`]([A-Za-z0-9+/=_-]{32,512})["'`]/g;
139
+ function shannonEntropy(value) {
140
+ const counts = new Map();
141
+ for (const ch of value)
142
+ counts.set(ch, (counts.get(ch) ?? 0) + 1);
143
+ let entropy = 0;
144
+ for (const count of counts.values()) {
145
+ const p = count / value.length;
146
+ entropy -= p * Math.log2(p);
147
+ }
148
+ return entropy;
149
+ }
150
+ function looksRandom(value) {
151
+ if (/^[a-f0-9]{40}$/i.test(value) || /^[a-f0-9]{64}$/i.test(value)) {
152
+ // Commit SHAs and checksums are common and harmless in code; only mask when clearly not hex-only digests.
153
+ return false;
154
+ }
155
+ const classes = [/[a-z]/, /[A-Z]/, /[0-9]/].filter((r) => r.test(value)).length;
156
+ return classes >= 2 && shannonEntropy(value) >= 4.0;
157
+ }
158
+ /** Find secrets in a string. Overlapping matches are merged. */
159
+ export function findSecrets(text) {
160
+ const matches = [];
161
+ for (const rule of RULES) {
162
+ rule.pattern.lastIndex = 0;
163
+ for (const m of text.matchAll(rule.pattern)) {
164
+ const full = m[0];
165
+ const index = m.index ?? 0;
166
+ if (rule.group && m[rule.group] !== undefined) {
167
+ const secret = m[rule.group];
168
+ const offset = full.lastIndexOf(secret);
169
+ matches.push({ rule: rule.name, start: index + offset, end: index + offset + secret.length });
170
+ }
171
+ else {
172
+ matches.push({ rule: rule.name, start: index, end: index + full.length });
173
+ }
174
+ }
175
+ }
176
+ ASSIGNMENT.lastIndex = 0;
177
+ for (const m of text.matchAll(ASSIGNMENT)) {
178
+ const [full, name, value] = m;
179
+ if (!shouldMask(name, value))
180
+ continue;
181
+ const start = (m.index ?? 0) + full.lastIndexOf(value);
182
+ matches.push({ rule: 'assigned-secret', start, end: start + value.length });
183
+ }
184
+ ENV_ASSIGNMENT.lastIndex = 0;
185
+ for (const m of text.matchAll(ENV_ASSIGNMENT)) {
186
+ const [full, name, value] = m;
187
+ if (!shouldMask(name, value))
188
+ continue;
189
+ const start = (m.index ?? 0) + full.lastIndexOf(value);
190
+ matches.push({ rule: 'env-secret', start, end: start + value.length });
191
+ }
192
+ UNQUOTED_ASSIGNMENT.lastIndex = 0;
193
+ for (const m of text.matchAll(UNQUOTED_ASSIGNMENT)) {
194
+ const [, name, value] = m;
195
+ const at = m.indices?.[2];
196
+ if (!at || !shouldMaskUnquoted(name, value))
197
+ continue;
198
+ matches.push({ rule: 'unquoted-secret', start: at[0], end: at[1] });
199
+ }
200
+ QUOTED_LITERAL.lastIndex = 0;
201
+ for (const m of text.matchAll(QUOTED_LITERAL)) {
202
+ const literal = m[1];
203
+ if (looksRandom(literal)) {
204
+ const start = (m.index ?? 0) + 1;
205
+ matches.push({ rule: 'high-entropy-literal', start, end: start + literal.length });
206
+ }
207
+ }
208
+ return mergeRanges(matches);
209
+ }
210
+ function mergeRanges(matches) {
211
+ const sorted = [...matches].sort((a, b) => a.start - b.start || b.end - a.end);
212
+ const out = [];
213
+ for (const m of sorted) {
214
+ const last = out[out.length - 1];
215
+ if (last && m.start <= last.end) {
216
+ last.end = Math.max(last.end, m.end);
217
+ }
218
+ else {
219
+ out.push({ ...m });
220
+ }
221
+ }
222
+ return out;
223
+ }
224
+ export const MASK_CHAR = '•';
225
+ /** Replace every detected secret with mask characters (length capped so masks do not leak length). */
226
+ export function maskSecrets(text) {
227
+ const found = findSecrets(text);
228
+ if (found.length === 0)
229
+ return { text, masked: 0 };
230
+ let out = '';
231
+ let cursor = 0;
232
+ for (const m of found) {
233
+ out += text.slice(cursor, m.start) + MASK_CHAR.repeat(8);
234
+ cursor = m.end;
235
+ }
236
+ out += text.slice(cursor);
237
+ return { text: out, masked: found.length };
238
+ }
239
+ /** Example env files document variables without real values, so they are explained like any other file. */
240
+ const ENV_TEMPLATE = /(^|\/)\.env\.(example|sample|template|dist|defaults)$/i;
241
+ const SENSITIVE_PATH_PATTERNS = [
242
+ /(^|\/)\.env(\.[^/]*)?$/i,
243
+ /(^|\/)\.envrc$/i,
244
+ /\.(pem|key|p12|pfx|p8|jks|keystore|asc|gpg|ppk)$/i,
245
+ /(^|\/)id_(rsa|dsa|ecdsa|ed25519)(\.pub)?$/i,
246
+ /(^|\/)\.npmrc$/i,
247
+ /(^|\/)\.pypirc$/i,
248
+ /(^|\/)\.netrc$/i,
249
+ /(^|\/)\.htpasswd$/i,
250
+ /(^|\/)\.pgpass$/i,
251
+ /(^|\/)\.my\.cnf$/i,
252
+ /(^|\/)\.s3cfg$/i,
253
+ /(^|\/)\.git-credentials$/i,
254
+ /(^|\/)\.vault-token$/i,
255
+ /(^|\/)\.dockercfg$/i,
256
+ /(^|\/)credentials(\.json|\.ya?ml|\.toml)?$/i,
257
+ /(^|\/)credentials\.tfrc\.json$/i,
258
+ /(^|\/)secrets?\.(json|ya?ml|toml|env)$/i,
259
+ /(^|\/)\.aws\/(credentials|config)$/i,
260
+ /(^|\/)\.docker\/config\.json$/i,
261
+ /(^|\/)\.kube\/config$/i,
262
+ // kubeconfig, kubeconfig-prod.yaml, staging.kubeconfig; not kubeconfig.go or kubeconfig_test.go.
263
+ /(^|\/)kubeconfig([-_][^/.]*)?(\.(ya?ml|json|conf))?$/i,
264
+ /\.kubeconfig$/i,
265
+ /(^|\/)gh\/hosts\.ya?ml$/i,
266
+ /service[-_]?account.*\.json$/i,
267
+ /\.tfstate(\.backup)?$/i,
268
+ /\.tfvars(\.json)?$/i,
269
+ ];
270
+ /**
271
+ * Files that hold credentials, whose content is never shown in a video and never sent to a provider.
272
+ * Everything else is shown as it is: explaining the real code is the point of the video.
273
+ */
274
+ export function isSensitivePath(path) {
275
+ if (ENV_TEMPLATE.test(path))
276
+ return false;
277
+ return SENSITIVE_PATH_PATTERNS.some((p) => p.test(path));
278
+ }
279
+ const EMAIL = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g;
280
+ /** Mask e-mail addresses (personal data) in on-screen text and narration. */
281
+ export function maskEmails(text) {
282
+ EMAIL.lastIndex = 0;
283
+ return text.replace(EMAIL, (email) => {
284
+ const at = email.indexOf('@');
285
+ return `${email[0]}${MASK_CHAR.repeat(3)}@${email.slice(at + 1)}`;
286
+ });
287
+ }
288
+ /** maskPrivate, plus what each step did, for callers that count what they masked. */
289
+ export function maskPrivateReport(text, options) {
290
+ const secret = maskSecrets(text);
291
+ const secretsChanged = secret.text !== text;
292
+ if (!options.maskEmails)
293
+ return { text: secret.text, secrets: secret.masked, secretsChanged, emailsChanged: false };
294
+ const masked = maskEmails(secret.text);
295
+ return { text: masked, secrets: secret.masked, secretsChanged, emailsChanged: masked !== secret.text };
296
+ }
297
+ /** Mask secrets, then e-mail addresses when `maskEmails` is set. */
298
+ export function maskPrivate(text, options) {
299
+ return maskPrivateReport(text, options).text;
300
+ }
301
+ //# sourceMappingURL=secrets.js.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Facts about a storyboard that more than one stage depends on: which visuals are simulated,
3
+ * which elements sit on a narration beat, which evidence backs a claim, and how long speech takes.
4
+ * They live here so the stages that validate, trim, plan and estimate agree.
5
+ */
6
+ import { type Storyboard, type Visual } from './storyboard-schema.ts';
7
+ /** Evidence kinds that show a change exists: a changed file, hunk or symbol. */
8
+ export declare const BACKING_EVIDENCE_KINDS: readonly string[];
9
+ /** Visuals that show invented behaviour (labelled "simulated" in the video). */
10
+ export declare function isSimulated(visual: Visual): boolean;
11
+ /** Elements that appear on a narration beat. Used to keep beat indexes in range. */
12
+ export declare function beatHolders(visual: Visual): {
13
+ beat: number;
14
+ }[];
15
+ /** Narration lines that cite at least one evidence id. */
16
+ export declare function groundedLines(storyboard: Storyboard): number;
17
+ /** Words in all the narration of a storyboard. */
18
+ export declare function narrationWords(storyboard: Storyboard): number;
19
+ /** Words of narration that fit a target length, at the engine's speaking rate. */
20
+ export declare function wordBudget(targetSec: number): number;
21
+ /** Estimated speaking time of a line: words at the speaking rate plus a quarter of a second. */
22
+ export declare function speechSeconds(text: string): number;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Facts about a storyboard that more than one stage depends on: which visuals are simulated,
3
+ * which elements sit on a narration beat, which evidence backs a claim, and how long speech takes.
4
+ * They live here so the stages that validate, trim, plan and estimate agree.
5
+ */
6
+ import { SIMULATED_VISUALS, STORYBOARD_LIMITS } from './storyboard-schema.js';
7
+ import { countWords } from './text.js';
8
+ /** Evidence kinds that show a change exists: a changed file, hunk or symbol. */
9
+ export const BACKING_EVIDENCE_KINDS = ['file', 'hunk', 'symbol'];
10
+ /** Silence added to every estimated line, as the breath between two lines. */
11
+ const LINE_PAUSE_SEC = 0.25;
12
+ /** Visuals that show invented behaviour (labelled "simulated" in the video). */
13
+ export function isSimulated(visual) {
14
+ return (SIMULATED_VISUALS.includes(visual.type) ||
15
+ (visual.type === 'before-after' &&
16
+ (visual.before.kind === 'terminal' || visual.after.kind === 'terminal')));
17
+ }
18
+ /** Elements that appear on a narration beat. Used to keep beat indexes in range. */
19
+ export function beatHolders(visual) {
20
+ switch (visual.type) {
21
+ case 'mission':
22
+ case 'summary':
23
+ return visual.points;
24
+ case 'architecture':
25
+ return [...visual.nodes, ...visual.edges];
26
+ case 'flow':
27
+ return visual.steps;
28
+ case 'code':
29
+ return visual.focus;
30
+ case 'before-after':
31
+ return [...visual.before.terminal, ...visual.after.terminal];
32
+ case 'terminal':
33
+ return visual.lines;
34
+ case 'browser':
35
+ return visual.blocks;
36
+ case 'checklist':
37
+ case 'bullets':
38
+ return visual.items;
39
+ case 'title':
40
+ case 'files':
41
+ case 'screenshot':
42
+ return [];
43
+ }
44
+ }
45
+ /** Narration lines that cite at least one evidence id. */
46
+ export function groundedLines(storyboard) {
47
+ return storyboard.scenes.reduce((sum, scene) => sum + scene.narration.filter((line) => line.evidence.length > 0).length, 0);
48
+ }
49
+ /** Words in all the narration of a storyboard. */
50
+ export function narrationWords(storyboard) {
51
+ return storyboard.scenes.reduce((sum, scene) => sum + scene.narration.reduce((n, line) => n + countWords(line.text), 0), 0);
52
+ }
53
+ /** Words of narration that fit a target length, at the engine's speaking rate. */
54
+ export function wordBudget(targetSec) {
55
+ return Math.round(targetSec * STORYBOARD_LIMITS.wordsPerSecond);
56
+ }
57
+ /** Estimated speaking time of a line: words at the speaking rate plus a quarter of a second. */
58
+ export function speechSeconds(text) {
59
+ return countWords(text) / STORYBOARD_LIMITS.wordsPerSecond + LINE_PAUSE_SEC;
60
+ }
61
+ //# sourceMappingURL=storyboard-facts.js.map