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,155 @@
1
+ /**
2
+ * How a failed GitHub request becomes a MergeStory error: the code, the message and the hint the
3
+ * user reads. These are pure functions of what the response said and whether a token was sent, so
4
+ * the client only has to do the request.
5
+ */
6
+ import { isMergeStoryError, MergeStoryError } from '../core/errors.js';
7
+ import { asArray, asString, isRecord } from '../core/json.js';
8
+ import { HttpError, parseRetryAfter } from '../core/retry.js';
9
+ /** A pause that GitHub asks for is waited out only when it is this short. */
10
+ const MAX_RETRY_AFTER_MS = 60_000;
11
+ /** A response that parsed but does not have the fields this client needs. */
12
+ export function unexpectedResponse(what) {
13
+ return new MergeStoryError('GITHUB_FAILED', `GitHub returned an unexpected ${what} response.`, {
14
+ hint: 'This can happen with a very old GitHub Enterprise Server. Check github.apiUrl, or try again.',
15
+ });
16
+ }
17
+ /** A response body that is not JSON. */
18
+ export function unreadableResponse(what, status) {
19
+ return new MergeStoryError('GITHUB_FAILED', `GitHub returned an unreadable ${what} response.`, {
20
+ hint: 'GitHub may be having problems, or a proxy changed the answer. Try again in a few minutes.',
21
+ details: { status },
22
+ });
23
+ }
24
+ /** The path of a request URL for logs and errors, without the name of the file being read. */
25
+ export function describePath(url) {
26
+ const { pathname } = new URL(url);
27
+ const index = pathname.indexOf('/contents/');
28
+ return index < 0 ? pathname : `${pathname.slice(0, index)}/contents/...`;
29
+ }
30
+ /** The error for a request that never got an HTTP answer, or got a server error after its retries. */
31
+ export function transportFailure(error, url) {
32
+ const host = new URL(url).host;
33
+ if (error instanceof HttpError) {
34
+ return new MergeStoryError('GITHUB_FAILED', `${host} answered with HTTP ${error.status}.`, {
35
+ hint: 'GitHub may be having problems. Try again in a few minutes.',
36
+ details: { status: error.status },
37
+ retryable: true,
38
+ cause: error,
39
+ });
40
+ }
41
+ if (isMergeStoryError(error) && error.code === 'INTERNAL') {
42
+ return new MergeStoryError('GITHUB_FAILED', `Could not reach ${host}. ${error.message}`, {
43
+ hint: 'Check your network connection and, for GitHub Enterprise, the github.apiUrl setting.',
44
+ retryable: true,
45
+ cause: error,
46
+ });
47
+ }
48
+ return error;
49
+ }
50
+ /**
51
+ * The error for a failed response, and how long to wait before repeating the request when
52
+ * GitHub asked for a short pause (secondary rate limit), otherwise null.
53
+ */
54
+ export function describeFailure(input) {
55
+ const { status, headers, method, url, authenticated } = input;
56
+ let message = '';
57
+ let errorCode = null;
58
+ try {
59
+ const parsed = JSON.parse(input.text);
60
+ if (isRecord(parsed)) {
61
+ message = asString(parsed.message) ?? '';
62
+ const first = asArray(parsed.errors)[0];
63
+ if (isRecord(first))
64
+ errorCode = asString(first.code);
65
+ }
66
+ }
67
+ catch {
68
+ // Not JSON (for example an HTML error page): the status is all we have.
69
+ }
70
+ message = input.redact(message).slice(0, 300);
71
+ const remaining = headers.get('x-ratelimit-remaining');
72
+ const reset = Number(headers.get('x-ratelimit-reset'));
73
+ const retryAfterMs = parseRetryAfter(headers.get('retry-after'));
74
+ const requestId = headers.get('x-github-request-id');
75
+ const details = { status, request: `${method} ${describePath(url)}` };
76
+ if (requestId)
77
+ details.requestId = requestId;
78
+ if (errorCode)
79
+ details.errorCode = errorCode;
80
+ const rateLimited = (status === 403 || status === 429) &&
81
+ (remaining === '0' || retryAfterMs !== null || /rate limit|abuse/i.test(message));
82
+ if (rateLimited) {
83
+ const upgrade = authenticated
84
+ ? ''
85
+ : ' Set GITHUB_TOKEN or run "gh auth login" to raise the limit from 60 to 5,000 requests per hour.';
86
+ if (remaining === '0' && Number.isFinite(reset) && reset > 0) {
87
+ const resetAt = new Date(reset * 1000);
88
+ const minutes = Math.max(1, Math.ceil((resetAt.getTime() - (input.now ?? Date.now())) / 60_000));
89
+ return {
90
+ error: new MergeStoryError('RATE_LIMITED', 'The GitHub API rate limit is used up.', {
91
+ hint: `The limit resets at ${resetAt.toISOString()} (in about ${minutes} min).${upgrade}`,
92
+ details: { ...details, resetAt: resetAt.toISOString() },
93
+ retryable: true,
94
+ }),
95
+ retryAfterMs: null,
96
+ };
97
+ }
98
+ const waitable = retryAfterMs !== null && retryAfterMs <= MAX_RETRY_AFTER_MS ? retryAfterMs : null;
99
+ return {
100
+ error: new MergeStoryError('RATE_LIMITED', 'GitHub asked for a pause between requests (secondary rate limit).', {
101
+ hint: `Wait a minute and run again.${upgrade}`,
102
+ details,
103
+ retryable: true,
104
+ }),
105
+ retryAfterMs: waitable,
106
+ };
107
+ }
108
+ const write = method !== 'GET' && !url.endsWith('/graphql') && !url.endsWith('/api/graphql');
109
+ const suffix = message ? ` (${message})` : '';
110
+ if (status === 401) {
111
+ return {
112
+ error: new MergeStoryError('GITHUB_AUTH', `GitHub rejected the token (HTTP 401).${suffix}`, {
113
+ hint: 'Set GITHUB_TOKEN to a valid token, or run "gh auth login". A fine-grained token needs ' +
114
+ '"Pull requests: read" and "Contents: read".',
115
+ details,
116
+ }),
117
+ retryAfterMs: null,
118
+ };
119
+ }
120
+ if (status === 403) {
121
+ const sso = headers.get('x-github-sso') !== null;
122
+ return {
123
+ error: new MergeStoryError('GITHUB_AUTH', `GitHub denied access (HTTP 403).${suffix}`, {
124
+ hint: sso
125
+ ? 'This organization requires SAML SSO. Authorize the token for it in your GitHub token settings.'
126
+ : write
127
+ ? 'The token needs "Pull requests: write" (or "Issues: write"). Tokens in pull requests from forks are read-only.'
128
+ : 'The token needs "Pull requests: read" and "Contents: read" for this repository.',
129
+ details,
130
+ }),
131
+ retryAfterMs: null,
132
+ };
133
+ }
134
+ if (status === 404) {
135
+ return {
136
+ error: new MergeStoryError('SOURCE_NOT_FOUND', `GitHub could not find ${describePath(url)}.${suffix}`, {
137
+ hint: authenticated
138
+ ? 'Check the URL. The token may not have access to this repository.'
139
+ : 'Check the URL. Private repositories need a token: set GITHUB_TOKEN or run "gh auth login".',
140
+ details,
141
+ }),
142
+ retryAfterMs: null,
143
+ };
144
+ }
145
+ return {
146
+ error: new MergeStoryError('GITHUB_FAILED', `GitHub returned HTTP ${status}.${suffix}`, {
147
+ hint: status === 422 && /too long/i.test(message)
148
+ ? 'The text is longer than GitHub allows (65,536 characters).'
149
+ : 'Check the request and try again. If it keeps failing, check https://www.githubstatus.com.',
150
+ details,
151
+ }),
152
+ retryAfterMs: null,
153
+ };
154
+ }
155
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Optional GitHub integration: reading pull requests, and (only when asked) writing one
3
+ * comment or one section of the description. The engine works without it.
4
+ */
5
+ export type { GitHubClientOptions } from './client.ts';
6
+ export { GITHUB_API_VERSION, GitHubClient, MAX_PR_FILES } from './client.ts';
7
+ export type { IssueReference } from './linked-issues.ts';
8
+ export { extractClosingReferences, findLinkedIssues } from './linked-issues.ts';
9
+ export type { GitHubComment, GitHubComparison, GitHubIssue, GitHubPrCommit, GitHubPrFile, GitHubPullRequest, GitHubRepo, GitHubTree, GitHubTreeEntry, } from './model.ts';
10
+ export type { CommentResult } from './notify.ts';
11
+ export { DESCRIPTION_END, DESCRIPTION_START, replaceMarkedSection, updatePullRequestDescription, upsertPullRequestComment, } from './notify.ts';
12
+ export type { PullRequestRef } from './pr-url.ts';
13
+ export { DEFAULT_API_URL, graphqlUrlFor, isValidOwnerName, isValidRepoName, parsePullRequestUrl, webHostFromApiUrl, } from './pr-url.ts';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Optional GitHub integration: reading pull requests, and (only when asked) writing one
3
+ * comment or one section of the description. The engine works without it.
4
+ */
5
+ export { GITHUB_API_VERSION, GitHubClient, MAX_PR_FILES } from './client.js';
6
+ export { extractClosingReferences, findLinkedIssues } from './linked-issues.js';
7
+ export { DESCRIPTION_END, DESCRIPTION_START, replaceMarkedSection, updatePullRequestDescription, upsertPullRequestComment, } from './notify.js';
8
+ export { DEFAULT_API_URL, graphqlUrlFor, isValidOwnerName, isValidRepoName, parsePullRequestUrl, webHostFromApiUrl, } from './pr-url.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Finding the issues a pull request closes: through GraphQL when there is a token, otherwise (or
3
+ * when that fails) from "fixes #n" references in the description.
4
+ */
5
+ import type { RunContext } from '../core/context.ts';
6
+ import type { GitHubClient } from './client.ts';
7
+ import { type GitHubIssue } from './model.ts';
8
+ export interface IssueReference {
9
+ owner: string;
10
+ repo: string;
11
+ number: number;
12
+ }
13
+ /** Whether a reference points into the pull request's own repository (names ignore case, like GitHub). */
14
+ export declare function isSameRepository(reference: IssueReference, pr: {
15
+ owner: string;
16
+ repo: string;
17
+ }): boolean;
18
+ /**
19
+ * Closing references in a pull request description, in order of appearance, without duplicates.
20
+ * Links on a different host than the pull request are ignored, and with `sameRepositoryOnly` so
21
+ * are references to other repositories. The limit applies after that filter.
22
+ */
23
+ export declare function extractClosingReferences(body: string, pr: {
24
+ owner: string;
25
+ repo: string;
26
+ webHost: string;
27
+ }, max: number, options?: {
28
+ sameRepositoryOnly?: boolean;
29
+ }): IssueReference[];
30
+ /**
31
+ * Issues the pull request closes, at most `maxIssues`. With a token this asks GraphQL, which also
32
+ * knows about manually linked issues. Without one, or when GraphQL fails, "fixes #n" style
33
+ * references in the description are looked up over REST. The description is written by the PR
34
+ * author, so with a token only references to this repository are followed: the token may read
35
+ * private repositories the author cannot see.
36
+ */
37
+ export declare function findLinkedIssues(client: GitHubClient, ctx: Pick<RunContext, 'signal' | 'logger'>, prBody: string, maxIssues: number): Promise<GitHubIssue[]>;
@@ -0,0 +1,131 @@
1
+ import { asArray, isRecord } from '../core/json.js';
2
+ import { toIssue } from './model.js';
3
+ /**
4
+ * "fixes #12", "Closes: owner/repo#7", "resolved https://github.com/o/r/issues/3". Like GitHub,
5
+ * each reference needs its own keyword.
6
+ */
7
+ const CLOSING_KEYWORD = /\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\b:?[ \t]+(?:https?:\/\/([^\s/]+)\/([\w.-]+)\/([\w.-]+)\/issues\/(\d+)|(?:([\w.-]+)\/([\w.-]+))?#(\d+))/gi;
8
+ /** Remove every `open ... close` span. An unclosed span is left alone. Runs in linear time. */
9
+ function removeSpans(text, open, close) {
10
+ let out = '';
11
+ let from = 0;
12
+ for (;;) {
13
+ const start = text.indexOf(open, from);
14
+ if (start < 0)
15
+ return out + text.slice(from);
16
+ const end = text.indexOf(close, start + open.length);
17
+ if (end < 0)
18
+ return out + text.slice(from);
19
+ out += `${text.slice(from, start)} `;
20
+ from = end + close.length;
21
+ }
22
+ }
23
+ /**
24
+ * GitHub ignores references inside code and HTML comments (PR templates often have both).
25
+ * Plain string search is used instead of lazy regular expressions, because a description is
26
+ * written by someone else and must not be able to make the matching slow.
27
+ */
28
+ function stripCode(text) {
29
+ const withoutBlocks = removeSpans(removeSpans(removeSpans(text, '<!--', '-->'), '```', '```'), '~~~', '~~~');
30
+ return withoutBlocks.replace(/`[^`\n]*`/g, ' ');
31
+ }
32
+ /** Whether a reference points into the pull request's own repository (names ignore case, like GitHub). */
33
+ export function isSameRepository(reference, pr) {
34
+ return (reference.owner.toLowerCase() === pr.owner.toLowerCase() &&
35
+ reference.repo.toLowerCase() === pr.repo.toLowerCase());
36
+ }
37
+ /**
38
+ * Closing references in a pull request description, in order of appearance, without duplicates.
39
+ * Links on a different host than the pull request are ignored, and with `sameRepositoryOnly` so
40
+ * are references to other repositories. The limit applies after that filter.
41
+ */
42
+ export function extractClosingReferences(body, pr, max, options = {}) {
43
+ const found = [];
44
+ const seen = new Set();
45
+ for (const match of stripCode(body).matchAll(CLOSING_KEYWORD)) {
46
+ let reference;
47
+ if (match[4] !== undefined) {
48
+ if (match[1].toLowerCase() !== pr.webHost.toLowerCase())
49
+ continue;
50
+ reference = { owner: match[2], repo: match[3], number: Number(match[4]) };
51
+ }
52
+ else {
53
+ reference = { owner: match[5] ?? pr.owner, repo: match[6] ?? pr.repo, number: Number(match[7]) };
54
+ }
55
+ if (!Number.isSafeInteger(reference.number) || reference.number < 1)
56
+ continue;
57
+ if (options.sameRepositoryOnly && !isSameRepository(reference, pr))
58
+ continue;
59
+ const key = `${reference.owner}/${reference.repo}#${reference.number}`.toLowerCase();
60
+ if (seen.has(key))
61
+ continue;
62
+ seen.add(key);
63
+ found.push(reference);
64
+ if (found.length >= max)
65
+ break;
66
+ }
67
+ return found;
68
+ }
69
+ async function closingIssuesFromGraphql(client, maxIssues) {
70
+ const query = 'query($owner:String!,$repo:String!,$number:Int!){repository(owner:$owner,name:$repo){pullRequest(number:$number){' +
71
+ `closingIssuesReferences(first:${maxIssues}){nodes{number title body url repository{nameWithOwner}}}}}}`;
72
+ const data = await client.graphql(query, {
73
+ owner: client.ref.owner,
74
+ repo: client.ref.repo,
75
+ number: client.ref.number,
76
+ });
77
+ if (!isRecord(data) || asArray(data.errors).length > 0 || !isRecord(data.data))
78
+ return null;
79
+ const repository = data.data.repository;
80
+ const pullRequest = isRecord(repository) ? repository.pullRequest : null;
81
+ const references = isRecord(pullRequest) ? pullRequest.closingIssuesReferences : null;
82
+ if (!isRecord(references))
83
+ return null;
84
+ const issues = [];
85
+ for (const node of asArray(references.nodes)) {
86
+ if (!isRecord(node) || !isRecord(node.repository))
87
+ continue;
88
+ // Only issues of this repository, as on the REST path: the token may read private repositories.
89
+ const [owner, repo] = String(node.repository.nameWithOwner).split('/');
90
+ if (!owner || !repo || !isSameRepository({ owner, repo, number: 0 }, client.ref))
91
+ continue;
92
+ const issue = toIssue({ ...node, html_url: node.url });
93
+ if (issue)
94
+ issues.push(issue);
95
+ }
96
+ return issues.slice(0, maxIssues);
97
+ }
98
+ /**
99
+ * Issues the pull request closes, at most `maxIssues`. With a token this asks GraphQL, which also
100
+ * knows about manually linked issues. Without one, or when GraphQL fails, "fixes #n" style
101
+ * references in the description are looked up over REST. The description is written by the PR
102
+ * author, so with a token only references to this repository are followed: the token may read
103
+ * private repositories the author cannot see.
104
+ */
105
+ export async function findLinkedIssues(client, ctx, prBody, maxIssues) {
106
+ if (client.authenticated) {
107
+ try {
108
+ const viaGraphql = await closingIssuesFromGraphql(client, maxIssues);
109
+ if (viaGraphql !== null)
110
+ return viaGraphql;
111
+ }
112
+ catch (error) {
113
+ if (ctx.signal.aborted)
114
+ throw error;
115
+ ctx.logger.debug('GraphQL lookup of linked issues failed; using the description instead');
116
+ }
117
+ }
118
+ const issues = [];
119
+ const references = extractClosingReferences(prBody, client.ref, maxIssues, {
120
+ sameRepositoryOnly: client.authenticated,
121
+ });
122
+ for (const reference of references) {
123
+ if (reference.number === client.ref.number && isSameRepository(reference, client.ref))
124
+ continue;
125
+ const issue = await client.getIssue(reference.owner, reference.repo, reference.number);
126
+ if (issue)
127
+ issues.push(issue);
128
+ }
129
+ return issues;
130
+ }
131
+ //# sourceMappingURL=linked-issues.js.map
@@ -0,0 +1,81 @@
1
+ import type { PullRequestRef } from './pr-url.ts';
2
+ export interface GitHubRepo {
3
+ owner: string;
4
+ name: string;
5
+ isPrivate: boolean | null;
6
+ defaultBranch: string | null;
7
+ htmlUrl: string | null;
8
+ }
9
+ export interface GitHubPullRequest {
10
+ number: number;
11
+ title: string;
12
+ body: string;
13
+ htmlUrl: string;
14
+ author: string | null;
15
+ baseRef: string;
16
+ baseSha: string;
17
+ headRef: string;
18
+ headSha: string;
19
+ labels: string[];
20
+ draft: boolean;
21
+ state: 'open' | 'closed' | 'merged';
22
+ changedFiles: number;
23
+ additions: number;
24
+ deletions: number;
25
+ commits: number;
26
+ }
27
+ export interface GitHubComparison {
28
+ mergeBaseSha: string;
29
+ status: string;
30
+ aheadBy: number;
31
+ behindBy: number;
32
+ }
33
+ export interface GitHubPrFile {
34
+ filename: string;
35
+ /** GitHub's own status word: added, removed, modified, renamed, copied, changed or unchanged. */
36
+ status: string;
37
+ additions: number;
38
+ deletions: number;
39
+ changes: number;
40
+ /** null when GitHub left the patch out (binary, too large, or over the response budget). */
41
+ patch: string | null;
42
+ previousFilename: string | null;
43
+ /**
44
+ * True when the entry has no patch and zero counts although it is a modified text file. GitHub
45
+ * does this when a page of files is too large, so the counts cannot be trusted.
46
+ */
47
+ suspect: boolean;
48
+ }
49
+ export interface GitHubPrCommit {
50
+ sha: string;
51
+ /** The full commit message. */
52
+ message: string;
53
+ }
54
+ export interface GitHubTreeEntry {
55
+ path: string;
56
+ type: 'blob' | 'tree' | 'commit';
57
+ }
58
+ export interface GitHubTree {
59
+ entries: GitHubTreeEntry[];
60
+ /** True when GitHub cut the listing short. */
61
+ truncated: boolean;
62
+ }
63
+ export interface GitHubIssue {
64
+ number: number;
65
+ title: string;
66
+ /** The whole body. Not cut here: the source masks secrets in all of it first, then caps it. */
67
+ body: string;
68
+ url: string;
69
+ }
70
+ export interface GitHubComment {
71
+ id: number;
72
+ url: string;
73
+ body: string;
74
+ authorLogin: string | null;
75
+ authorType: string | null;
76
+ }
77
+ export declare function toRepo(data: unknown, ref: PullRequestRef): GitHubRepo;
78
+ export declare function toPullRequest(data: unknown): GitHubPullRequest;
79
+ export declare function toPrFile(data: unknown): GitHubPrFile | null;
80
+ export declare function toComment(data: unknown): GitHubComment | null;
81
+ export declare function toIssue(data: unknown): GitHubIssue | null;
@@ -0,0 +1,114 @@
1
+ /** What the GitHub client hands out, and the readers that turn API responses into those shapes. */
2
+ import { isLikelyBinaryPath } from '../core/binary-paths.js';
3
+ import { asArray, asNumber, asString, isRecord } from '../core/json.js';
4
+ import { unexpectedResponse } from './errors.js';
5
+ /** A number from the API; `fallback` when the field is missing or not a finite number. */
6
+ function numberOr(value, fallback = 0) {
7
+ return asNumber(value) ?? fallback;
8
+ }
9
+ export function toRepo(data, ref) {
10
+ if (!isRecord(data))
11
+ throw unexpectedResponse('repository');
12
+ const owner = isRecord(data.owner) ? asString(data.owner.login) : null;
13
+ const visibility = asString(data.visibility);
14
+ let isPrivate = null;
15
+ if (typeof data.private === 'boolean')
16
+ isPrivate = data.private;
17
+ if (visibility !== null && visibility !== 'public')
18
+ isPrivate = true;
19
+ return {
20
+ owner: owner ?? ref.owner,
21
+ name: asString(data.name) ?? ref.repo,
22
+ isPrivate,
23
+ defaultBranch: asString(data.default_branch),
24
+ htmlUrl: asString(data.html_url),
25
+ };
26
+ }
27
+ export function toPullRequest(data) {
28
+ if (!isRecord(data))
29
+ throw unexpectedResponse('pull request');
30
+ const base = isRecord(data.base) ? data.base : {};
31
+ const head = isRecord(data.head) ? data.head : {};
32
+ const baseSha = asString(base.sha);
33
+ const headSha = asString(head.sha);
34
+ if (!baseSha || !headSha)
35
+ throw unexpectedResponse('pull request');
36
+ const merged = data.merged === true || asString(data.merged_at) !== null;
37
+ return {
38
+ number: numberOr(data.number),
39
+ title: asString(data.title) ?? '',
40
+ body: asString(data.body) ?? '',
41
+ htmlUrl: asString(data.html_url) ?? '',
42
+ author: isRecord(data.user) ? asString(data.user.login) : null,
43
+ baseRef: asString(base.ref) ?? '',
44
+ baseSha,
45
+ headRef: asString(head.ref) ?? '',
46
+ headSha,
47
+ labels: asArray(data.labels)
48
+ .map((label) => (isRecord(label) ? asString(label.name) : null))
49
+ .filter((name) => name !== null),
50
+ draft: data.draft === true,
51
+ state: merged ? 'merged' : data.state === 'closed' ? 'closed' : 'open',
52
+ changedFiles: numberOr(data.changed_files),
53
+ additions: numberOr(data.additions),
54
+ deletions: numberOr(data.deletions),
55
+ commits: numberOr(data.commits),
56
+ };
57
+ }
58
+ export function toPrFile(data) {
59
+ if (!isRecord(data))
60
+ return null;
61
+ const filename = asString(data.filename);
62
+ if (!filename)
63
+ return null;
64
+ const status = asString(data.status) ?? 'modified';
65
+ const additions = numberOr(data.additions);
66
+ const deletions = numberOr(data.deletions);
67
+ const changes = numberOr(data.changes, additions + deletions);
68
+ const patch = asString(data.patch);
69
+ const suspect = patch === null &&
70
+ status === 'modified' &&
71
+ changes === 0 &&
72
+ additions === 0 &&
73
+ deletions === 0 &&
74
+ !isLikelyBinaryPath(filename);
75
+ return {
76
+ filename,
77
+ status,
78
+ additions,
79
+ deletions,
80
+ changes,
81
+ patch: patch === '' ? null : patch,
82
+ previousFilename: asString(data.previous_filename),
83
+ suspect,
84
+ };
85
+ }
86
+ export function toComment(data) {
87
+ if (!isRecord(data))
88
+ return null;
89
+ const id = numberOr(data.id, -1);
90
+ if (id < 0)
91
+ return null;
92
+ const user = isRecord(data.user) ? data.user : {};
93
+ return {
94
+ id,
95
+ url: asString(data.html_url) ?? '',
96
+ body: asString(data.body) ?? '',
97
+ authorLogin: asString(user.login),
98
+ authorType: asString(user.type),
99
+ };
100
+ }
101
+ export function toIssue(data) {
102
+ if (!isRecord(data))
103
+ return null;
104
+ const number = numberOr(data.number, -1);
105
+ if (number < 1)
106
+ return null;
107
+ return {
108
+ number,
109
+ title: asString(data.title) ?? '',
110
+ body: asString(data.body) ?? '',
111
+ url: asString(data.html_url) ?? asString(data.url) ?? '',
112
+ };
113
+ }
114
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1,27 @@
1
+ /** Writing back to a pull request: one comment, or one section of the description. */
2
+ import type { RunContext } from '../core/context.ts';
3
+ import type { PullRequestRef } from './pr-url.ts';
4
+ export interface CommentResult {
5
+ url: string;
6
+ created: boolean;
7
+ }
8
+ export declare const DESCRIPTION_START = "<!-- mergestory:start -->";
9
+ export declare const DESCRIPTION_END = "<!-- mergestory:end -->";
10
+ /**
11
+ * Create or update the single MergeStory comment on a pull request (found by its HTML marker).
12
+ * The marker is added to the top of the text when it is missing, so the next run finds the
13
+ * comment again. Refuses to run in a dry run.
14
+ */
15
+ export declare function upsertPullRequestComment(ref: PullRequestRef, body: string, marker: string, ctx: RunContext): Promise<CommentResult>;
16
+ /**
17
+ * Put `section` between the MergeStory markers in a pull request description. An existing marked
18
+ * section is replaced; otherwise the section is added at the end after a blank line. Everything
19
+ * else is left as it was, including the description's line endings.
20
+ */
21
+ export declare function replaceMarkedSection(description: string, section: string): string;
22
+ /**
23
+ * Replace the MergeStory section of the PR description (between <!-- mergestory:start --> and
24
+ * <!-- mergestory:end -->), or append it. The rest of the description is left untouched, and
25
+ * nothing is written when the section is already up to date. Refuses to run in a dry run.
26
+ */
27
+ export declare function updatePullRequestDescription(ref: PullRequestRef, section: string, ctx: RunContext): Promise<void>;