@dxos/plugin-github 0.7.4 → 0.13.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 (628) hide show
  1. package/LICENSE +102 -5
  2. package/PLUGIN.mdl +784 -0
  3. package/dist/lib/GitHubCapabilities.mjs +10 -0
  4. package/dist/lib/GitHubCapabilities.mjs.map +1 -0
  5. package/dist/lib/GitHubEvents.mjs +15 -0
  6. package/dist/lib/GitHubEvents.mjs.map +1 -0
  7. package/dist/lib/GitHubOperation.mjs +358 -0
  8. package/dist/lib/GitHubOperation.mjs.map +1 -0
  9. package/dist/lib/GitHubPlugin.mjs +16 -0
  10. package/dist/lib/GitHubPlugin.mjs.map +1 -0
  11. package/dist/lib/Walkthrough.mjs +59 -0
  12. package/dist/lib/Walkthrough.mjs.map +1 -0
  13. package/dist/lib/capabilities.browser.mjs +54 -0
  14. package/dist/lib/capabilities.browser.mjs.map +1 -0
  15. package/dist/lib/capabilities.mjs +54 -0
  16. package/dist/lib/capabilities.mjs.map +1 -0
  17. package/dist/lib/capabilities.node.mjs +30 -0
  18. package/dist/lib/capabilities.node.mjs.map +1 -0
  19. package/dist/lib/capabilities.tauri.mjs +54 -0
  20. package/dist/lib/capabilities.tauri.mjs.map +1 -0
  21. package/dist/lib/capabilities.workerd.mjs +30 -0
  22. package/dist/lib/capabilities.workerd.mjs.map +1 -0
  23. package/dist/lib/chunk-ImportPullRequestDialog.mjs +116 -0
  24. package/dist/lib/chunk-ImportPullRequestDialog.mjs.map +1 -0
  25. package/dist/lib/chunk-PLUGIN.mjs +6 -0
  26. package/dist/lib/chunk-PLUGIN.mjs.map +1 -0
  27. package/dist/lib/chunk-PullRequestArticle.mjs +1486 -0
  28. package/dist/lib/chunk-PullRequestArticle.mjs.map +1 -0
  29. package/dist/lib/chunk-PullRequestArticle2.mjs +2 -0
  30. package/dist/lib/chunk-PullRequestCardMenu.mjs +123 -0
  31. package/dist/lib/chunk-PullRequestCardMenu.mjs.map +1 -0
  32. package/dist/lib/chunk-PullRequestsArticle.mjs +594 -0
  33. package/dist/lib/chunk-PullRequestsArticle.mjs.map +1 -0
  34. package/dist/lib/chunk-WalkthroughArticle.mjs +26 -0
  35. package/dist/lib/chunk-WalkthroughArticle.mjs.map +1 -0
  36. package/dist/lib/chunk-add-pull-request-comment.mjs +19 -0
  37. package/dist/lib/chunk-add-pull-request-comment.mjs.map +1 -0
  38. package/dist/lib/chunk-add-pull-request-review-comment.mjs +25 -0
  39. package/dist/lib/chunk-add-pull-request-review-comment.mjs.map +1 -0
  40. package/dist/lib/chunk-app-graph-builder.mjs +39 -0
  41. package/dist/lib/chunk-app-graph-builder.mjs.map +1 -0
  42. package/dist/lib/chunk-connector.mjs +70 -0
  43. package/dist/lib/chunk-connector.mjs.map +1 -0
  44. package/dist/lib/chunk-constants.mjs +11 -0
  45. package/dist/lib/chunk-constants.mjs.map +1 -0
  46. package/dist/lib/chunk-errors.mjs +29 -0
  47. package/dist/lib/chunk-errors.mjs.map +1 -0
  48. package/dist/lib/chunk-generate-walkthrough.mjs +86 -0
  49. package/dist/lib/chunk-generate-walkthrough.mjs.map +1 -0
  50. package/dist/lib/chunk-generate.mjs +719 -0
  51. package/dist/lib/chunk-generate.mjs.map +1 -0
  52. package/dist/lib/chunk-get-pull-request-diff.mjs +25 -0
  53. package/dist/lib/chunk-get-pull-request-diff.mjs.map +1 -0
  54. package/dist/lib/chunk-get-pull-request-status.mjs +29 -0
  55. package/dist/lib/chunk-get-pull-request-status.mjs.map +1 -0
  56. package/dist/lib/chunk-get-repositories.mjs +32 -0
  57. package/dist/lib/chunk-get-repositories.mjs.map +1 -0
  58. package/dist/lib/chunk-github-api.mjs +375 -0
  59. package/dist/lib/chunk-github-api.mjs.map +1 -0
  60. package/dist/lib/chunk-github-link.mjs +59 -0
  61. package/dist/lib/chunk-github-link.mjs.map +1 -0
  62. package/dist/lib/chunk-import-pull-request-from-snapshot.mjs +25 -0
  63. package/dist/lib/chunk-import-pull-request-from-snapshot.mjs.map +1 -0
  64. package/dist/lib/chunk-import-pull-request.mjs +96 -0
  65. package/dist/lib/chunk-import-pull-request.mjs.map +1 -0
  66. package/dist/lib/chunk-link-resolver.mjs +109 -0
  67. package/dist/lib/chunk-link-resolver.mjs.map +1 -0
  68. package/dist/lib/chunk-markdown-extension.mjs +92 -0
  69. package/dist/lib/chunk-markdown-extension.mjs.map +1 -0
  70. package/dist/lib/chunk-materialize-target.mjs +36 -0
  71. package/dist/lib/chunk-materialize-target.mjs.map +1 -0
  72. package/dist/lib/chunk-operation-handler.mjs +12 -0
  73. package/dist/lib/chunk-operation-handler.mjs.map +1 -0
  74. package/dist/lib/chunk-page-action.mjs +22 -0
  75. package/dist/lib/chunk-page-action.mjs.map +1 -0
  76. package/dist/lib/chunk-pull-request.mjs +58 -0
  77. package/dist/lib/chunk-pull-request.mjs.map +1 -0
  78. package/dist/lib/chunk-pull-request2.mjs +110 -0
  79. package/dist/lib/chunk-pull-request2.mjs.map +1 -0
  80. package/dist/lib/chunk-react-surface.mjs +233 -0
  81. package/dist/lib/chunk-react-surface.mjs.map +1 -0
  82. package/dist/lib/chunk-rolldown-runtime.mjs +13 -0
  83. package/dist/lib/chunk-schema.mjs +15 -0
  84. package/dist/lib/chunk-schema.mjs.map +1 -0
  85. package/dist/lib/chunk-skill-definition.mjs +10 -0
  86. package/dist/lib/chunk-skill-definition.mjs.map +1 -0
  87. package/dist/lib/chunk-submit-pull-request-approval.mjs +56 -0
  88. package/dist/lib/chunk-submit-pull-request-approval.mjs.map +1 -0
  89. package/dist/lib/chunk-sync-pull-request.mjs +24 -0
  90. package/dist/lib/chunk-sync-pull-request.mjs.map +1 -0
  91. package/dist/lib/chunk-sync.mjs +481 -0
  92. package/dist/lib/chunk-sync.mjs.map +1 -0
  93. package/dist/lib/chunk-useOpenObject.mjs +43 -0
  94. package/dist/lib/chunk-useOpenObject.mjs.map +1 -0
  95. package/dist/lib/extensions.mjs +132 -0
  96. package/dist/lib/extensions.mjs.map +1 -0
  97. package/dist/lib/index.mjs +4 -0
  98. package/dist/lib/meta.mjs +47 -0
  99. package/dist/lib/meta.mjs.map +1 -0
  100. package/dist/lib/ns/Extensions.mjs +18 -0
  101. package/dist/lib/ns/Extensions.mjs.map +1 -0
  102. package/dist/lib/operations.mjs +22 -0
  103. package/dist/lib/operations.mjs.map +1 -0
  104. package/dist/lib/plugin.mjs +9 -0
  105. package/dist/lib/plugin.mjs.map +1 -0
  106. package/dist/lib/skills.mjs +44 -0
  107. package/dist/lib/skills.mjs.map +1 -0
  108. package/dist/lib/testing.mjs +189 -0
  109. package/dist/lib/testing.mjs.map +1 -0
  110. package/dist/lib/translations.mjs +136 -0
  111. package/dist/lib/translations.mjs.map +1 -0
  112. package/dist/lib/types.mjs +5 -0
  113. package/dist/types/dx.config.d.ts +28 -0
  114. package/dist/types/dx.config.d.ts.map +1 -0
  115. package/dist/types/src/Extensions.d.ts +2 -0
  116. package/dist/types/src/Extensions.d.ts.map +1 -0
  117. package/dist/types/src/GitHubPlugin.d.ts +37 -0
  118. package/dist/types/src/GitHubPlugin.d.ts.map +1 -0
  119. package/dist/types/src/GitHubPlugin.workerd.test.d.ts +2 -0
  120. package/dist/types/src/GitHubPlugin.workerd.test.d.ts.map +1 -0
  121. package/dist/types/src/approval.d.ts +21 -0
  122. package/dist/types/src/approval.d.ts.map +1 -0
  123. package/dist/types/src/approval.test.d.ts +2 -0
  124. package/dist/types/src/approval.test.d.ts.map +1 -0
  125. package/dist/types/src/capabilities/app-graph-builder.d.ts +9 -0
  126. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  127. package/dist/types/src/capabilities/connector.d.ts +17 -0
  128. package/dist/types/src/capabilities/connector.d.ts.map +1 -0
  129. package/dist/types/src/capabilities/gen/browser.d.ts +13 -0
  130. package/dist/types/src/capabilities/gen/browser.d.ts.map +1 -0
  131. package/dist/types/src/capabilities/gen/node.d.ts +13 -0
  132. package/dist/types/src/capabilities/gen/node.d.ts.map +1 -0
  133. package/dist/types/src/capabilities/gen/tauri.d.ts +13 -0
  134. package/dist/types/src/capabilities/gen/tauri.d.ts.map +1 -0
  135. package/dist/types/src/capabilities/gen/workerd.d.ts +13 -0
  136. package/dist/types/src/capabilities/gen/workerd.d.ts.map +1 -0
  137. package/dist/types/src/capabilities/index.d.ts +13 -0
  138. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  139. package/dist/types/src/capabilities/link-resolver.d.ts +10 -0
  140. package/dist/types/src/capabilities/link-resolver.d.ts.map +1 -0
  141. package/dist/types/src/capabilities/markdown-extension.d.ts +14 -0
  142. package/dist/types/src/capabilities/markdown-extension.d.ts.map +1 -0
  143. package/dist/types/src/capabilities/operation-handler.d.ts +5 -0
  144. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  145. package/dist/types/src/capabilities/page-action.d.ts +5 -0
  146. package/dist/types/src/capabilities/page-action.d.ts.map +1 -0
  147. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  148. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  149. package/dist/types/src/capabilities/schema.d.ts +12 -0
  150. package/dist/types/src/capabilities/schema.d.ts.map +1 -0
  151. package/dist/types/src/capabilities/skill-definition.d.ts +5 -0
  152. package/dist/types/src/capabilities/skill-definition.d.ts.map +1 -0
  153. package/dist/types/src/cards/GitHubCard.d.ts +11 -0
  154. package/dist/types/src/cards/GitHubCard.d.ts.map +1 -0
  155. package/dist/types/src/cards/GitHubCard.stories.d.ts +45 -0
  156. package/dist/types/src/cards/GitHubCard.stories.d.ts.map +1 -0
  157. package/dist/types/src/cards/PullRequestCard.d.ts +9 -0
  158. package/dist/types/src/cards/PullRequestCard.d.ts.map +1 -0
  159. package/dist/types/src/cards/index.d.ts +3 -0
  160. package/dist/types/src/cards/index.d.ts.map +1 -0
  161. package/dist/types/src/components/CommentComposer/CommentComposer.d.ts +30 -0
  162. package/dist/types/src/components/CommentComposer/CommentComposer.d.ts.map +1 -0
  163. package/dist/types/src/components/CommentComposer/index.d.ts +2 -0
  164. package/dist/types/src/components/CommentComposer/index.d.ts.map +1 -0
  165. package/dist/types/src/components/PullRequestFiles/DiffStat.d.ts +8 -0
  166. package/dist/types/src/components/PullRequestFiles/DiffStat.d.ts.map +1 -0
  167. package/dist/types/src/components/PullRequestFiles/FileTree.d.ts +17 -0
  168. package/dist/types/src/components/PullRequestFiles/FileTree.d.ts.map +1 -0
  169. package/dist/types/src/components/PullRequestFiles/PullRequestFiles.d.ts +23 -0
  170. package/dist/types/src/components/PullRequestFiles/PullRequestFiles.d.ts.map +1 -0
  171. package/dist/types/src/components/PullRequestFiles/files.d.ts +39 -0
  172. package/dist/types/src/components/PullRequestFiles/files.d.ts.map +1 -0
  173. package/dist/types/src/components/PullRequestFiles/files.test.d.ts +2 -0
  174. package/dist/types/src/components/PullRequestFiles/files.test.d.ts.map +1 -0
  175. package/dist/types/src/components/PullRequestFiles/index.d.ts +5 -0
  176. package/dist/types/src/components/PullRequestFiles/index.d.ts.map +1 -0
  177. package/dist/types/src/components/PullRequestOverview/ArtifactPill.d.ts +21 -0
  178. package/dist/types/src/components/PullRequestOverview/ArtifactPill.d.ts.map +1 -0
  179. package/dist/types/src/components/PullRequestOverview/CheckRunList.d.ts +15 -0
  180. package/dist/types/src/components/PullRequestOverview/CheckRunList.d.ts.map +1 -0
  181. package/dist/types/src/components/PullRequestOverview/PullRequestDetails.d.ts +10 -0
  182. package/dist/types/src/components/PullRequestOverview/PullRequestDetails.d.ts.map +1 -0
  183. package/dist/types/src/components/PullRequestOverview/PullRequestOverview.d.ts +16 -0
  184. package/dist/types/src/components/PullRequestOverview/PullRequestOverview.d.ts.map +1 -0
  185. package/dist/types/src/components/PullRequestOverview/RelatedCards.d.ts +28 -0
  186. package/dist/types/src/components/PullRequestOverview/RelatedCards.d.ts.map +1 -0
  187. package/dist/types/src/components/PullRequestOverview/index.d.ts +6 -0
  188. package/dist/types/src/components/PullRequestOverview/index.d.ts.map +1 -0
  189. package/dist/types/src/components/PullRequestStatus/PullRequestStatus.d.ts +20 -0
  190. package/dist/types/src/components/PullRequestStatus/PullRequestStatus.d.ts.map +1 -0
  191. package/dist/types/src/components/PullRequestStatus/index.d.ts +2 -0
  192. package/dist/types/src/components/PullRequestStatus/index.d.ts.map +1 -0
  193. package/dist/types/src/components/WalkthroughView/WalkthroughView.d.ts +18 -0
  194. package/dist/types/src/components/WalkthroughView/WalkthroughView.d.ts.map +1 -0
  195. package/dist/types/src/components/WalkthroughView/extensions.d.ts +16 -0
  196. package/dist/types/src/components/WalkthroughView/extensions.d.ts.map +1 -0
  197. package/dist/types/src/components/WalkthroughView/index.d.ts +3 -0
  198. package/dist/types/src/components/WalkthroughView/index.d.ts.map +1 -0
  199. package/dist/types/src/components/index.d.ts +5 -8
  200. package/dist/types/src/components/index.d.ts.map +1 -1
  201. package/dist/types/src/constants.d.ts +7 -0
  202. package/dist/types/src/constants.d.ts.map +1 -0
  203. package/dist/types/src/containers/ImportPullRequestDialog/ImportPullRequestDialog.d.ts +6 -0
  204. package/dist/types/src/containers/ImportPullRequestDialog/ImportPullRequestDialog.d.ts.map +1 -0
  205. package/dist/types/src/containers/ImportPullRequestDialog/index.d.ts +3 -0
  206. package/dist/types/src/containers/ImportPullRequestDialog/index.d.ts.map +1 -0
  207. package/dist/types/src/containers/PullRequestArticle/PullRequestArticle.d.ts +15 -0
  208. package/dist/types/src/containers/PullRequestArticle/PullRequestArticle.d.ts.map +1 -0
  209. package/dist/types/src/containers/PullRequestArticle/failure.d.ts +10 -0
  210. package/dist/types/src/containers/PullRequestArticle/failure.d.ts.map +1 -0
  211. package/dist/types/src/containers/PullRequestArticle/failure.test.d.ts +2 -0
  212. package/dist/types/src/containers/PullRequestArticle/failure.test.d.ts.map +1 -0
  213. package/dist/types/src/containers/PullRequestArticle/index.d.ts +2 -0
  214. package/dist/types/src/containers/PullRequestArticle/index.d.ts.map +1 -0
  215. package/dist/types/src/containers/PullRequestCardMenu/PullRequestCardMenu.d.ts +14 -0
  216. package/dist/types/src/containers/PullRequestCardMenu/PullRequestCardMenu.d.ts.map +1 -0
  217. package/dist/types/src/containers/PullRequestCardMenu/index.d.ts +2 -0
  218. package/dist/types/src/containers/PullRequestCardMenu/index.d.ts.map +1 -0
  219. package/dist/types/src/containers/PullRequestsArticle/PullRequestsArticle.d.ts +13 -0
  220. package/dist/types/src/containers/PullRequestsArticle/PullRequestsArticle.d.ts.map +1 -0
  221. package/dist/types/src/containers/PullRequestsArticle/arrange.d.ts +44 -0
  222. package/dist/types/src/containers/PullRequestsArticle/arrange.d.ts.map +1 -0
  223. package/dist/types/src/containers/PullRequestsArticle/arrange.test.d.ts +2 -0
  224. package/dist/types/src/containers/PullRequestsArticle/arrange.test.d.ts.map +1 -0
  225. package/dist/types/src/containers/PullRequestsArticle/format.d.ts +3 -0
  226. package/dist/types/src/containers/PullRequestsArticle/format.d.ts.map +1 -0
  227. package/dist/types/src/containers/PullRequestsArticle/index.d.ts +2 -0
  228. package/dist/types/src/containers/PullRequestsArticle/index.d.ts.map +1 -0
  229. package/dist/types/src/containers/WalkthroughArticle/WalkthroughArticle.d.ts +13 -0
  230. package/dist/types/src/containers/WalkthroughArticle/WalkthroughArticle.d.ts.map +1 -0
  231. package/dist/types/src/containers/WalkthroughArticle/index.d.ts +2 -0
  232. package/dist/types/src/containers/WalkthroughArticle/index.d.ts.map +1 -0
  233. package/dist/types/src/containers/index.d.ts +7 -0
  234. package/dist/types/src/containers/index.d.ts.map +1 -0
  235. package/dist/types/src/errors.d.ts +157 -0
  236. package/dist/types/src/errors.d.ts.map +1 -0
  237. package/dist/types/src/extensions/index.d.ts +3 -0
  238. package/dist/types/src/extensions/index.d.ts.map +1 -0
  239. package/dist/types/src/extensions/links.d.ts +21 -0
  240. package/dist/types/src/extensions/links.d.ts.map +1 -0
  241. package/dist/types/src/extensions/links.test.d.ts +2 -0
  242. package/dist/types/src/extensions/links.test.d.ts.map +1 -0
  243. package/dist/types/src/extensions/references.d.ts +23 -0
  244. package/dist/types/src/extensions/references.d.ts.map +1 -0
  245. package/dist/types/src/extensions/references.test.d.ts +2 -0
  246. package/dist/types/src/extensions/references.test.d.ts.map +1 -0
  247. package/dist/types/src/github-link.d.ts +29 -0
  248. package/dist/types/src/github-link.d.ts.map +1 -0
  249. package/dist/types/src/hooks/index.d.ts +5 -2
  250. package/dist/types/src/hooks/index.d.ts.map +1 -1
  251. package/dist/types/src/hooks/useOpenObject.d.ts +9 -0
  252. package/dist/types/src/hooks/useOpenObject.d.ts.map +1 -0
  253. package/dist/types/src/hooks/usePullRequestChecks.d.ts +10 -0
  254. package/dist/types/src/hooks/usePullRequestChecks.d.ts.map +1 -0
  255. package/dist/types/src/hooks/usePullRequestDiff.d.ts +12 -0
  256. package/dist/types/src/hooks/usePullRequestDiff.d.ts.map +1 -0
  257. package/dist/types/src/hooks/usePullRequestFiles.d.ts +22 -0
  258. package/dist/types/src/hooks/usePullRequestFiles.d.ts.map +1 -0
  259. package/dist/types/src/hooks/useSyncPullRequest.d.ts +10 -0
  260. package/dist/types/src/hooks/useSyncPullRequest.d.ts.map +1 -0
  261. package/dist/types/src/index.d.ts +3 -3
  262. package/dist/types/src/index.d.ts.map +1 -1
  263. package/dist/types/src/meta.d.ts +34 -11
  264. package/dist/types/src/meta.d.ts.map +1 -1
  265. package/dist/types/src/operations/add-pull-request-comment.d.ts +5 -0
  266. package/dist/types/src/operations/add-pull-request-comment.d.ts.map +1 -0
  267. package/dist/types/src/operations/add-pull-request-review-comment.d.ts +5 -0
  268. package/dist/types/src/operations/add-pull-request-review-comment.d.ts.map +1 -0
  269. package/dist/types/src/operations/generate-walkthrough.d.ts +11 -0
  270. package/dist/types/src/operations/generate-walkthrough.d.ts.map +1 -0
  271. package/dist/types/src/operations/get-pull-request-diff.d.ts +5 -0
  272. package/dist/types/src/operations/get-pull-request-diff.d.ts.map +1 -0
  273. package/dist/types/src/operations/get-pull-request-status.d.ts +5 -0
  274. package/dist/types/src/operations/get-pull-request-status.d.ts.map +1 -0
  275. package/dist/types/src/operations/get-repositories.d.ts +13 -0
  276. package/dist/types/src/operations/get-repositories.d.ts.map +1 -0
  277. package/dist/types/src/operations/import-pull-request-from-snapshot.d.ts +12 -0
  278. package/dist/types/src/operations/import-pull-request-from-snapshot.d.ts.map +1 -0
  279. package/dist/types/src/operations/import-pull-request.d.ts +63 -0
  280. package/dist/types/src/operations/import-pull-request.d.ts.map +1 -0
  281. package/dist/types/src/operations/import-pull-request.test.d.ts +2 -0
  282. package/dist/types/src/operations/import-pull-request.test.d.ts.map +1 -0
  283. package/dist/types/src/operations/index.d.ts +3 -0
  284. package/dist/types/src/operations/index.d.ts.map +1 -0
  285. package/dist/types/src/operations/materialize-target.d.ts +12 -0
  286. package/dist/types/src/operations/materialize-target.d.ts.map +1 -0
  287. package/dist/types/src/operations/pull-request.d.ts +48 -0
  288. package/dist/types/src/operations/pull-request.d.ts.map +1 -0
  289. package/dist/types/src/operations/pull-request.test.d.ts +2 -0
  290. package/dist/types/src/operations/pull-request.test.d.ts.map +1 -0
  291. package/dist/types/src/operations/submit-pull-request-approval.d.ts +5 -0
  292. package/dist/types/src/operations/submit-pull-request-approval.d.ts.map +1 -0
  293. package/dist/types/src/operations/sync-pull-request.d.ts +5 -0
  294. package/dist/types/src/operations/sync-pull-request.d.ts.map +1 -0
  295. package/dist/types/src/operations/sync.d.ts +123 -0
  296. package/dist/types/src/operations/sync.d.ts.map +1 -0
  297. package/dist/types/src/operations/sync.test.d.ts +2 -0
  298. package/dist/types/src/operations/sync.test.d.ts.map +1 -0
  299. package/dist/types/src/plugin.d.ts +4 -0
  300. package/dist/types/src/plugin.d.ts.map +1 -0
  301. package/dist/types/src/plugin.test.d.ts +2 -0
  302. package/dist/types/src/plugin.test.d.ts.map +1 -0
  303. package/dist/types/src/pull-request-body.d.ts +37 -0
  304. package/dist/types/src/pull-request-body.d.ts.map +1 -0
  305. package/dist/types/src/pull-request-body.test.d.ts +2 -0
  306. package/dist/types/src/pull-request-body.test.d.ts.map +1 -0
  307. package/dist/types/src/pull-request.d.ts +28 -0
  308. package/dist/types/src/pull-request.d.ts.map +1 -0
  309. package/dist/types/src/pull-request.test.d.ts +2 -0
  310. package/dist/types/src/pull-request.test.d.ts.map +1 -0
  311. package/dist/types/src/services/github-api.d.ts +332 -0
  312. package/dist/types/src/services/github-api.d.ts.map +1 -0
  313. package/dist/types/src/services/index.d.ts +2 -0
  314. package/dist/types/src/services/index.d.ts.map +1 -0
  315. package/dist/types/src/skills/GitHubSkill.d.ts +12 -0
  316. package/dist/types/src/skills/GitHubSkill.d.ts.map +1 -0
  317. package/dist/types/src/skills/index.d.ts +2 -0
  318. package/dist/types/src/skills/index.d.ts.map +1 -0
  319. package/dist/types/src/stories/Generate.stories.d.ts +27 -0
  320. package/dist/types/src/stories/Generate.stories.d.ts.map +1 -0
  321. package/dist/types/src/stories/Links.stories.d.ts +23 -0
  322. package/dist/types/src/stories/Links.stories.d.ts.map +1 -0
  323. package/dist/types/src/stories/PullRequestArticle.stories.d.ts +359 -0
  324. package/dist/types/src/stories/PullRequestArticle.stories.d.ts.map +1 -0
  325. package/dist/types/src/stories/PullRequestFiles.stories.d.ts +365 -0
  326. package/dist/types/src/stories/PullRequestFiles.stories.d.ts.map +1 -0
  327. package/dist/types/src/stories/PullRequestOverview.stories.d.ts +367 -0
  328. package/dist/types/src/stories/PullRequestOverview.stories.d.ts.map +1 -0
  329. package/dist/types/src/stories/PullRequestsArticle.stories.d.ts +357 -0
  330. package/dist/types/src/stories/PullRequestsArticle.stories.d.ts.map +1 -0
  331. package/dist/types/src/stories/Walkthrough.stories.d.ts +380 -0
  332. package/dist/types/src/stories/Walkthrough.stories.d.ts.map +1 -0
  333. package/dist/types/src/stories/github.d.ts +23 -0
  334. package/dist/types/src/stories/github.d.ts.map +1 -0
  335. package/dist/types/src/stories/github.test.d.ts +2 -0
  336. package/dist/types/src/stories/github.test.d.ts.map +1 -0
  337. package/dist/types/src/stories/walkthrough-fixture.d.ts +8 -0
  338. package/dist/types/src/stories/walkthrough-fixture.d.ts.map +1 -0
  339. package/dist/types/src/testing/fixtures.d.ts +14 -0
  340. package/dist/types/src/testing/fixtures.d.ts.map +1 -0
  341. package/dist/types/src/testing/index.d.ts +4 -0
  342. package/dist/types/src/testing/index.d.ts.map +1 -0
  343. package/dist/types/src/testing/plugin.d.ts +4 -0
  344. package/dist/types/src/testing/plugin.d.ts.map +1 -0
  345. package/dist/types/src/testing/pull-request-13348.d.ts +6 -0
  346. package/dist/types/src/testing/pull-request-13348.d.ts.map +1 -0
  347. package/dist/types/src/translations.d.ts +339 -53
  348. package/dist/types/src/translations.d.ts.map +1 -1
  349. package/dist/types/src/types/GitHubCapabilities.d.ts +13 -0
  350. package/dist/types/src/types/GitHubCapabilities.d.ts.map +1 -0
  351. package/dist/types/src/types/GitHubEvents.d.ts +8 -0
  352. package/dist/types/src/types/GitHubEvents.d.ts.map +1 -0
  353. package/dist/types/src/types/GitHubOperation.d.ts +270 -0
  354. package/dist/types/src/types/GitHubOperation.d.ts.map +1 -0
  355. package/dist/types/src/types/PullRequestsView.d.ts +35 -0
  356. package/dist/types/src/types/PullRequestsView.d.ts.map +1 -0
  357. package/dist/types/src/types/Walkthrough.d.ts +31 -0
  358. package/dist/types/src/types/Walkthrough.d.ts.map +1 -0
  359. package/dist/types/src/types/Walkthrough.test.d.ts +2 -0
  360. package/dist/types/src/types/Walkthrough.test.d.ts.map +1 -0
  361. package/dist/types/src/types/index.d.ts +5 -0
  362. package/dist/types/src/types/index.d.ts.map +1 -0
  363. package/dist/types/src/walkthrough/fill.d.ts +28 -0
  364. package/dist/types/src/walkthrough/fill.d.ts.map +1 -0
  365. package/dist/types/src/walkthrough/fill.test.d.ts +2 -0
  366. package/dist/types/src/walkthrough/fill.test.d.ts.map +1 -0
  367. package/dist/types/src/walkthrough/generate.d.ts +67 -0
  368. package/dist/types/src/walkthrough/generate.d.ts.map +1 -0
  369. package/dist/types/src/walkthrough/generate.test.d.ts +2 -0
  370. package/dist/types/src/walkthrough/generate.test.d.ts.map +1 -0
  371. package/dist/types/src/walkthrough/generated.d.ts +20 -0
  372. package/dist/types/src/walkthrough/generated.d.ts.map +1 -0
  373. package/dist/types/src/walkthrough/generated.test.d.ts +2 -0
  374. package/dist/types/src/walkthrough/generated.test.d.ts.map +1 -0
  375. package/dist/types/src/walkthrough/headings.d.ts +8 -0
  376. package/dist/types/src/walkthrough/headings.d.ts.map +1 -0
  377. package/dist/types/src/walkthrough/headings.test.d.ts +2 -0
  378. package/dist/types/src/walkthrough/headings.test.d.ts.map +1 -0
  379. package/dist/types/src/walkthrough/index.d.ts +9 -0
  380. package/dist/types/src/walkthrough/index.d.ts.map +1 -0
  381. package/dist/types/src/walkthrough/patch.d.ts +48 -0
  382. package/dist/types/src/walkthrough/patch.d.ts.map +1 -0
  383. package/dist/types/src/walkthrough/plan.d.ts +55 -0
  384. package/dist/types/src/walkthrough/plan.d.ts.map +1 -0
  385. package/dist/types/src/walkthrough/plan.test.d.ts +2 -0
  386. package/dist/types/src/walkthrough/plan.test.d.ts.map +1 -0
  387. package/dist/types/src/walkthrough/prompt.d.ts +33 -0
  388. package/dist/types/src/walkthrough/prompt.d.ts.map +1 -0
  389. package/dist/types/src/walkthrough/prompt.test.d.ts +2 -0
  390. package/dist/types/src/walkthrough/prompt.test.d.ts.map +1 -0
  391. package/dist/types/src/walkthrough/score.d.ts +43 -0
  392. package/dist/types/src/walkthrough/score.d.ts.map +1 -0
  393. package/dist/types/src/walkthrough/score.test.d.ts +2 -0
  394. package/dist/types/src/walkthrough/score.test.d.ts.map +1 -0
  395. package/dist/types/tsconfig.tsbuildinfo +1 -0
  396. package/dx.config.ts +39 -0
  397. package/package.json +167 -48
  398. package/src/Extensions.ts +7 -0
  399. package/src/GitHubPlugin.ts +15 -0
  400. package/src/GitHubPlugin.workerd.test.ts +23 -0
  401. package/src/approval.test.ts +40 -0
  402. package/src/approval.ts +39 -0
  403. package/src/capabilities/app-graph-builder.ts +47 -0
  404. package/src/capabilities/connector.ts +95 -0
  405. package/src/capabilities/gen/browser.ts +82 -0
  406. package/src/capabilities/gen/node.ts +43 -0
  407. package/src/capabilities/gen/tauri.ts +82 -0
  408. package/src/capabilities/gen/workerd.ts +43 -0
  409. package/src/capabilities/index.ts +71 -0
  410. package/src/capabilities/link-resolver.ts +137 -0
  411. package/src/capabilities/markdown-extension.ts +146 -0
  412. package/src/capabilities/operation-handler.ts +16 -0
  413. package/src/capabilities/page-action.ts +32 -0
  414. package/src/capabilities/react-surface.ts +98 -0
  415. package/src/capabilities/schema.ts +16 -0
  416. package/src/capabilities/skill-definition.ts +14 -0
  417. package/src/cards/GitHubCard.stories.tsx +165 -0
  418. package/src/cards/GitHubCard.tsx +93 -0
  419. package/src/cards/PullRequestCard.tsx +23 -0
  420. package/src/cards/index.ts +6 -0
  421. package/src/components/CommentComposer/CommentComposer.tsx +109 -0
  422. package/src/components/CommentComposer/index.ts +5 -0
  423. package/src/components/PullRequestFiles/DiffStat.tsx +15 -0
  424. package/src/components/PullRequestFiles/FileTree.tsx +102 -0
  425. package/src/components/PullRequestFiles/PullRequestFiles.tsx +87 -0
  426. package/src/components/PullRequestFiles/files.test.ts +59 -0
  427. package/src/components/PullRequestFiles/files.ts +115 -0
  428. package/src/components/PullRequestFiles/index.ts +8 -0
  429. package/src/components/PullRequestOverview/ArtifactPill.tsx +82 -0
  430. package/src/components/PullRequestOverview/CheckRunList.tsx +120 -0
  431. package/src/components/PullRequestOverview/PullRequestDetails.tsx +15 -0
  432. package/src/components/PullRequestOverview/PullRequestOverview.tsx +110 -0
  433. package/src/components/PullRequestOverview/RelatedCards.tsx +147 -0
  434. package/src/components/PullRequestOverview/index.ts +9 -0
  435. package/src/components/PullRequestStatus/PullRequestStatus.tsx +81 -0
  436. package/src/components/PullRequestStatus/index.ts +5 -0
  437. package/src/components/WalkthroughView/WalkthroughView.tsx +62 -0
  438. package/src/components/WalkthroughView/extensions.ts +53 -0
  439. package/src/components/WalkthroughView/index.ts +6 -0
  440. package/src/components/index.ts +6 -9
  441. package/src/constants.ts +12 -0
  442. package/src/containers/ImportPullRequestDialog/ImportPullRequestDialog.tsx +160 -0
  443. package/src/containers/ImportPullRequestDialog/index.ts +7 -0
  444. package/src/containers/PullRequestArticle/PullRequestArticle.tsx +573 -0
  445. package/src/containers/PullRequestArticle/failure.test.ts +42 -0
  446. package/src/containers/PullRequestArticle/failure.ts +16 -0
  447. package/src/containers/PullRequestArticle/index.ts +5 -0
  448. package/src/containers/PullRequestCardMenu/PullRequestCardMenu.tsx +134 -0
  449. package/src/containers/PullRequestCardMenu/index.ts +5 -0
  450. package/src/containers/PullRequestsArticle/PullRequestsArticle.tsx +361 -0
  451. package/src/containers/PullRequestsArticle/arrange.test.ts +122 -0
  452. package/src/containers/PullRequestsArticle/arrange.ts +245 -0
  453. package/src/containers/PullRequestsArticle/format.ts +31 -0
  454. package/src/containers/PullRequestsArticle/index.ts +5 -0
  455. package/src/containers/WalkthroughArticle/WalkthroughArticle.tsx +31 -0
  456. package/src/containers/WalkthroughArticle/index.ts +5 -0
  457. package/src/containers/index.ts +11 -0
  458. package/src/errors.ts +61 -0
  459. package/src/extensions/index.ts +6 -0
  460. package/src/extensions/links.test.ts +133 -0
  461. package/src/extensions/links.ts +91 -0
  462. package/src/extensions/references.test.ts +83 -0
  463. package/src/extensions/references.ts +100 -0
  464. package/src/github-link.ts +70 -0
  465. package/src/hooks/index.ts +6 -3
  466. package/src/hooks/useOpenObject.ts +48 -0
  467. package/src/hooks/usePullRequestChecks.ts +81 -0
  468. package/src/hooks/usePullRequestDiff.ts +57 -0
  469. package/src/hooks/usePullRequestFiles.ts +98 -0
  470. package/src/hooks/useSyncPullRequest.ts +51 -0
  471. package/src/index.ts +4 -6
  472. package/src/meta.ts +8 -13
  473. package/src/operations/add-pull-request-comment.ts +31 -0
  474. package/src/operations/add-pull-request-review-comment.ts +32 -0
  475. package/src/operations/generate-walkthrough.ts +124 -0
  476. package/src/operations/get-pull-request-diff.ts +37 -0
  477. package/src/operations/get-pull-request-status.ts +44 -0
  478. package/src/operations/get-repositories.ts +53 -0
  479. package/src/operations/import-pull-request-from-snapshot.ts +48 -0
  480. package/src/operations/import-pull-request.test.ts +151 -0
  481. package/src/operations/import-pull-request.ts +141 -0
  482. package/src/operations/index.ts +29 -0
  483. package/src/operations/materialize-target.ts +60 -0
  484. package/src/operations/pull-request.test.ts +120 -0
  485. package/src/operations/pull-request.ts +141 -0
  486. package/src/operations/submit-pull-request-approval.ts +41 -0
  487. package/src/operations/sync-pull-request.ts +37 -0
  488. package/src/operations/sync.test.ts +453 -0
  489. package/src/operations/sync.ts +807 -0
  490. package/src/plugin.test.ts +40 -0
  491. package/src/plugin.ts +37 -0
  492. package/src/pull-request-body.test.ts +61 -0
  493. package/src/pull-request-body.ts +144 -0
  494. package/src/pull-request.test.ts +67 -0
  495. package/src/pull-request.ts +80 -0
  496. package/src/services/github-api.ts +735 -0
  497. package/src/services/index.ts +5 -0
  498. package/src/skills/GitHubSkill.ts +46 -0
  499. package/src/skills/index.ts +5 -0
  500. package/src/stories/Generate.stories.tsx +152 -0
  501. package/src/stories/Links.stories.tsx +153 -0
  502. package/src/stories/PullRequestArticle.stories.tsx +107 -0
  503. package/src/stories/PullRequestFiles.stories.tsx +69 -0
  504. package/src/stories/PullRequestOverview.stories.tsx +113 -0
  505. package/src/stories/PullRequestsArticle.stories.tsx +170 -0
  506. package/src/stories/Walkthrough.stories.tsx +110 -0
  507. package/src/stories/github.test.ts +65 -0
  508. package/src/stories/github.ts +70 -0
  509. package/src/stories/walkthrough-fixture.ts +115 -0
  510. package/src/testing/fixtures.ts +99 -0
  511. package/src/testing/index.ts +7 -0
  512. package/src/testing/plugin.ts +25 -0
  513. package/src/testing/pull-request-13348.ts +104 -0
  514. package/src/testing/pull-request-13363.patch +2981 -0
  515. package/src/translations.ts +135 -63
  516. package/src/types/GitHubCapabilities.ts +27 -0
  517. package/src/types/GitHubEvents.ts +16 -0
  518. package/src/types/GitHubOperation.ts +371 -0
  519. package/src/types/PullRequestsView.ts +45 -0
  520. package/src/types/Walkthrough.test.ts +75 -0
  521. package/src/types/Walkthrough.ts +66 -0
  522. package/src/types/index.ts +8 -0
  523. package/src/vite-env.d.ts +15 -0
  524. package/src/walkthrough/fill.test.ts +337 -0
  525. package/src/walkthrough/fill.ts +246 -0
  526. package/src/walkthrough/generate.test.ts +219 -0
  527. package/src/walkthrough/generate.ts +248 -0
  528. package/src/walkthrough/generated.test.ts +70 -0
  529. package/src/walkthrough/generated.ts +70 -0
  530. package/src/walkthrough/headings.test.ts +40 -0
  531. package/src/walkthrough/headings.ts +39 -0
  532. package/src/walkthrough/index.ts +12 -0
  533. package/src/walkthrough/patch.ts +154 -0
  534. package/src/walkthrough/plan.test.ts +178 -0
  535. package/src/walkthrough/plan.ts +251 -0
  536. package/src/walkthrough/prompt.test.ts +100 -0
  537. package/src/walkthrough/prompt.ts +147 -0
  538. package/src/walkthrough/score.test.ts +272 -0
  539. package/src/walkthrough/score.ts +430 -0
  540. package/README.md +0 -15
  541. package/dist/lib/browser/chunk-S4MPSBA5.mjs +0 -21
  542. package/dist/lib/browser/chunk-S4MPSBA5.mjs.map +0 -7
  543. package/dist/lib/browser/index.css +0 -7
  544. package/dist/lib/browser/index.css.map +0 -7
  545. package/dist/lib/browser/index.mjs +0 -1535
  546. package/dist/lib/browser/index.mjs.map +0 -7
  547. package/dist/lib/browser/meta.json +0 -1
  548. package/dist/lib/browser/meta.mjs +0 -11
  549. package/dist/lib/browser/meta.mjs.map +0 -7
  550. package/dist/types/src/GithubPlugin.d.ts +0 -4
  551. package/dist/types/src/GithubPlugin.d.ts.map +0 -1
  552. package/dist/types/src/components/EmbeddedMain/EmbeddedMain.d.ts +0 -4
  553. package/dist/types/src/components/EmbeddedMain/EmbeddedMain.d.ts.map +0 -1
  554. package/dist/types/src/components/EmbeddedMain/GfmPreview.d.ts +0 -9
  555. package/dist/types/src/components/EmbeddedMain/GfmPreview.d.ts.map +0 -1
  556. package/dist/types/src/components/EmbeddedMain/index.d.ts +0 -2
  557. package/dist/types/src/components/EmbeddedMain/index.d.ts.map +0 -1
  558. package/dist/types/src/components/ExportDialog.d.ts +0 -8
  559. package/dist/types/src/components/ExportDialog.d.ts.map +0 -1
  560. package/dist/types/src/components/GithubApiProviders/GitHubSettings.d.ts +0 -3
  561. package/dist/types/src/components/GithubApiProviders/GitHubSettings.d.ts.map +0 -1
  562. package/dist/types/src/components/GithubApiProviders/OctokitProvider.d.ts +0 -15
  563. package/dist/types/src/components/GithubApiProviders/OctokitProvider.d.ts.map +0 -1
  564. package/dist/types/src/components/GithubApiProviders/index.d.ts +0 -3
  565. package/dist/types/src/components/GithubApiProviders/index.d.ts.map +0 -1
  566. package/dist/types/src/components/GithubEchoResolverProviders/DocumentTreeItem.d.ts +0 -6
  567. package/dist/types/src/components/GithubEchoResolverProviders/DocumentTreeItem.d.ts.map +0 -1
  568. package/dist/types/src/components/GithubEchoResolverProviders/ResolverContext.d.ts +0 -7
  569. package/dist/types/src/components/GithubEchoResolverProviders/ResolverContext.d.ts.map +0 -1
  570. package/dist/types/src/components/GithubEchoResolverProviders/ResolverDialog.d.ts +0 -6
  571. package/dist/types/src/components/GithubEchoResolverProviders/ResolverDialog.d.ts.map +0 -1
  572. package/dist/types/src/components/GithubEchoResolverProviders/ResolverProps.d.ts +0 -16
  573. package/dist/types/src/components/GithubEchoResolverProviders/ResolverProps.d.ts.map +0 -1
  574. package/dist/types/src/components/GithubEchoResolverProviders/ResolverTree.d.ts +0 -3
  575. package/dist/types/src/components/GithubEchoResolverProviders/ResolverTree.d.ts.map +0 -1
  576. package/dist/types/src/components/GithubEchoResolverProviders/SpacePickerTreeItem.d.ts +0 -11
  577. package/dist/types/src/components/GithubEchoResolverProviders/SpacePickerTreeItem.d.ts.map +0 -1
  578. package/dist/types/src/components/GithubEchoResolverProviders/index.d.ts +0 -3
  579. package/dist/types/src/components/GithubEchoResolverProviders/index.d.ts.map +0 -1
  580. package/dist/types/src/components/GithubEchoResolverProviders/spaceResolvers.d.ts +0 -6
  581. package/dist/types/src/components/GithubEchoResolverProviders/spaceResolvers.d.ts.map +0 -1
  582. package/dist/types/src/components/ImportDialog.d.ts +0 -7
  583. package/dist/types/src/components/ImportDialog.d.ts.map +0 -1
  584. package/dist/types/src/components/Issue.d.ts +0 -5
  585. package/dist/types/src/components/Issue.d.ts.map +0 -1
  586. package/dist/types/src/components/Loading/Loading.d.ts +0 -15
  587. package/dist/types/src/components/Loading/Loading.d.ts.map +0 -1
  588. package/dist/types/src/components/Loading/Loading.stories.d.ts +0 -40
  589. package/dist/types/src/components/Loading/Loading.stories.d.ts.map +0 -1
  590. package/dist/types/src/components/Loading/index.d.ts +0 -2
  591. package/dist/types/src/components/Loading/index.d.ts.map +0 -1
  592. package/dist/types/src/components/MarkdownActions.d.ts +0 -7
  593. package/dist/types/src/components/MarkdownActions.d.ts.map +0 -1
  594. package/dist/types/src/components/UrlDialog.d.ts +0 -6
  595. package/dist/types/src/components/UrlDialog.d.ts.map +0 -1
  596. package/dist/types/src/hooks/useDocGhId.d.ts +0 -6
  597. package/dist/types/src/hooks/useDocGhId.d.ts.map +0 -1
  598. package/dist/types/src/hooks/useGhIdFromUrl.d.ts +0 -2
  599. package/dist/types/src/hooks/useGhIdFromUrl.d.ts.map +0 -1
  600. package/dist/types/src/types.d.ts +0 -30
  601. package/dist/types/src/types.d.ts.map +0 -1
  602. package/src/GithubPlugin.tsx +0 -127
  603. package/src/components/EmbeddedMain/EmbeddedMain.tsx +0 -294
  604. package/src/components/EmbeddedMain/GfmPreview.tsx +0 -110
  605. package/src/components/EmbeddedMain/embedded.css +0 -3
  606. package/src/components/EmbeddedMain/index.ts +0 -5
  607. package/src/components/ExportDialog.tsx +0 -157
  608. package/src/components/GithubApiProviders/GitHubSettings.tsx +0 -72
  609. package/src/components/GithubApiProviders/OctokitProvider.tsx +0 -60
  610. package/src/components/GithubApiProviders/index.ts +0 -6
  611. package/src/components/GithubEchoResolverProviders/DocumentTreeItem.tsx +0 -26
  612. package/src/components/GithubEchoResolverProviders/ResolverContext.tsx +0 -137
  613. package/src/components/GithubEchoResolverProviders/ResolverDialog.tsx +0 -34
  614. package/src/components/GithubEchoResolverProviders/ResolverProps.ts +0 -23
  615. package/src/components/GithubEchoResolverProviders/ResolverTree.tsx +0 -86
  616. package/src/components/GithubEchoResolverProviders/SpacePickerTreeItem.tsx +0 -105
  617. package/src/components/GithubEchoResolverProviders/index.ts +0 -6
  618. package/src/components/GithubEchoResolverProviders/spaceResolvers.ts +0 -86
  619. package/src/components/ImportDialog.tsx +0 -72
  620. package/src/components/Issue.tsx +0 -62
  621. package/src/components/Loading/Loading.stories.tsx +0 -32
  622. package/src/components/Loading/Loading.tsx +0 -70
  623. package/src/components/Loading/index.ts +0 -5
  624. package/src/components/MarkdownActions.tsx +0 -136
  625. package/src/components/UrlDialog.tsx +0 -52
  626. package/src/hooks/useDocGhId.ts +0 -38
  627. package/src/hooks/useGhIdFromUrl.ts +0 -26
  628. package/src/types.ts +0 -51
@@ -0,0 +1,719 @@
1
+ import { Walkthrough } from "#types";
2
+ import * as Effect from "effect/Effect";
3
+ import { Database, Filter, Obj, Ref } from "@dxos/echo";
4
+ import * as Progress from "@dxos/app-toolkit/Progress";
5
+ //#region src/walkthrough/patch.ts
6
+ var FILE_HEADER = /^diff --git a\/(.+?) b\/(.+)$/;
7
+ var HUNK_HEADER = /^@@+\s+-(\d+)(?:,(\d+))?\s+\+(\d+)(?:,(\d+))?\s+@@/;
8
+ /**
9
+ * Splits a multi-file unified diff — what `GET /repos/…/pulls/N` returns under the `diff` media type
10
+ * — into files and hunks. Hunk bodies are carried verbatim rather than re-derived, so a chunk filled
11
+ * from one is byte-identical to what git produced.
12
+ */
13
+ var parsePatch = (patch) => {
14
+ const files = [];
15
+ let file;
16
+ let hunk;
17
+ for (const raw of patch.split("\n")) {
18
+ const line = raw.endsWith("\r") ? raw.slice(0, -1) : raw;
19
+ const header = FILE_HEADER.exec(line);
20
+ if (header) {
21
+ file = {
22
+ path: header[2],
23
+ preamble: [line],
24
+ hunks: [],
25
+ added: 0,
26
+ removed: 0
27
+ };
28
+ files.push(file);
29
+ hunk = void 0;
30
+ continue;
31
+ }
32
+ if (!file) continue;
33
+ const hunkHeader = HUNK_HEADER.exec(line);
34
+ if (hunkHeader) {
35
+ const beforeStart = Number(hunkHeader[1]);
36
+ const beforeCount = hunkHeader[2] === void 0 ? 1 : Number(hunkHeader[2]);
37
+ const afterStart = Number(hunkHeader[3]);
38
+ hunk = {
39
+ header: line,
40
+ lines: [],
41
+ afterStart,
42
+ afterEnd: afterStart + (hunkHeader[4] === void 0 ? 1 : Number(hunkHeader[4])) - 1,
43
+ beforeStart,
44
+ beforeEnd: beforeStart + beforeCount - 1,
45
+ added: 0,
46
+ removed: 0
47
+ };
48
+ file.hunks.push(hunk);
49
+ continue;
50
+ }
51
+ if (!hunk) {
52
+ file.preamble.push(line);
53
+ continue;
54
+ }
55
+ if (line.startsWith("\\")) {
56
+ hunk.lines.push(line);
57
+ continue;
58
+ }
59
+ if (line.startsWith("+")) {
60
+ hunk.added++;
61
+ file.added++;
62
+ } else if (line.startsWith("-")) {
63
+ hunk.removed++;
64
+ file.removed++;
65
+ }
66
+ hunk.lines.push(line);
67
+ }
68
+ const trailing = files.at(-1)?.hunks.at(-1);
69
+ if (trailing?.lines.at(-1) === "") trailing.lines.pop();
70
+ const merged = /* @__PURE__ */ new Map();
71
+ for (const file of files) {
72
+ const existing = merged.get(file.path);
73
+ if (existing) {
74
+ existing.hunks.push(...file.hunks);
75
+ existing.added += file.added;
76
+ existing.removed += file.removed;
77
+ } else merged.set(file.path, file);
78
+ }
79
+ return [...merged.values()];
80
+ };
81
+ /** The hunk text a diff fence holds: the `@@` header and its body, as git wrote them. */
82
+ var renderHunks = (hunks) => hunks.map((hunk) => [hunk.header, ...hunk.lines].join("\n")).join("\n");
83
+ /**
84
+ * Whether a hunk shows any of `[start, end]` of the post-change file.
85
+ *
86
+ * A pure removal spans nothing after the change (`afterEnd === afterStart - 1`), so it is treated as
87
+ * occupying the single position the lines were removed from — otherwise no range could ever select
88
+ * it, including the one this module's own {@link hunkRange} reports for it.
89
+ */
90
+ var hunkOverlaps = (hunk, start, end) => hunk.afterStart <= end && Math.max(hunk.afterEnd, hunk.afterStart) >= start;
91
+ /**
92
+ * The span a set of hunks covers, for a fence's `lines=` attribute.
93
+ *
94
+ * Measured after the change, except where nothing survives it: a deleted file's post-image is empty
95
+ * and would otherwise read as `Lines 0`, so its range is quoted from the pre-image instead.
96
+ */
97
+ var hunkRange = (hunks) => {
98
+ if (hunks.length === 0) return;
99
+ const survives = hunks.some((hunk) => hunk.afterEnd >= hunk.afterStart);
100
+ const start = Math.min(...hunks.map((hunk) => survives ? hunk.afterStart : hunk.beforeStart));
101
+ const end = Math.max(...hunks.map((hunk) => survives ? Math.max(hunk.afterEnd, hunk.afterStart) : hunk.beforeEnd));
102
+ return start >= end ? `${start}` : `${start}-${end}`;
103
+ };
104
+ //#endregion
105
+ //#region src/walkthrough/headings.ts
106
+ var FENCE = /^\s{0,3}(`{3,}|~{3,})/;
107
+ /** A closing fence carries nothing after its marker: a line with an info string only opens one. */
108
+ var CLOSING_FENCE = /^\s{0,3}(`{3,}|~{3,})[ \t]*$/;
109
+ var HEADING = /^\s{0,3}#{1,6}(\s|$)/;
110
+ /**
111
+ * Puts a blank line before every heading outside a code fence.
112
+ *
113
+ * A heading may legally interrupt a paragraph, so the model and the chapter join both emit one on
114
+ * the very next line — which the walkthrough's source-level editor shows flush against the prose.
115
+ */
116
+ var spaceHeadings = (markdown) => {
117
+ const lines = markdown.split("\n");
118
+ const result = [];
119
+ let fence;
120
+ for (const line of lines) {
121
+ const crlf = line.endsWith("\r");
122
+ const text = crlf ? line.slice(0, -1) : line;
123
+ const marker = text.match(FENCE)?.[1];
124
+ if (fence) {
125
+ const closer = text.match(CLOSING_FENCE)?.[1];
126
+ if (closer && closer[0] === fence[0] && closer.length >= fence.length) fence = void 0;
127
+ } else if (marker) fence = marker;
128
+ else if (HEADING.test(text) && result.length > 0 && result[result.length - 1].trim() !== "") result.push(crlf ? "\r" : "");
129
+ result.push(line);
130
+ }
131
+ return result.join("\n");
132
+ };
133
+ //#endregion
134
+ //#region src/walkthrough/generated.ts
135
+ /**
136
+ * Files a reviewer does not read, and a walkthrough should not spend prose or a fence on: machine
137
+ * output, vendored blobs, and anything whose diff is a consequence of another file in the same
138
+ * change.
139
+ *
140
+ * Detection is by path and by patch shape rather than by a `.gitattributes` lookup, because the
141
+ * walkthrough only ever has the patch.
142
+ */
143
+ /** Lockfiles: the largest hunk in most pull requests and the one nobody reads. */
144
+ var LOCKFILES = [
145
+ "pnpm-lock.yaml",
146
+ "package-lock.json",
147
+ "yarn.lock",
148
+ "bun.lockb",
149
+ "npm-shrinkwrap.json",
150
+ "Cargo.lock",
151
+ "poetry.lock",
152
+ "composer.lock",
153
+ "Gemfile.lock",
154
+ "go.sum",
155
+ "flake.lock",
156
+ "uv.lock"
157
+ ];
158
+ /** Directories whose contents are built, vendored or cached rather than written. */
159
+ var GENERATED_DIRECTORIES = /(^|\/)(dist|build|out|coverage|node_modules|vendor|__snapshots__|\.turbo)\//;
160
+ /** Suffixes that are compiled, minified, generated from a schema, or not text at all. */
161
+ var GENERATED_SUFFIX = /(\.min\.(js|css)|\.map|\.snap|\.d\.ts|[._-]pb\.(ts|js)|\.pb\.go|_pb2\.py|\.gen\.(ts|js|go)|\.generated\.[a-z]+)$/i;
162
+ /** Binary by extension. A patch shows these as "Binary files … differ", with nothing to read. */
163
+ var BINARY_SUFFIX = /\.(png|jpe?g|gif|webp|avif|ico|icns|bmp|tiff?|svgz|pdf|woff2?|ttf|otf|eot|zip|gz|tgz|bz2|xz|7z|rar|wasm|so|dylib|dll|exe|bin|dat|db|sqlite3?|mp[34]|mov|mp4|webm|wav|ogg|jar|class|pyc|node)$/i;
164
+ /**
165
+ * Whether a path is machine-written or unreadable.
166
+ *
167
+ * `.changeset/` entries count: the changeset is a consequence of the change the walkthrough already
168
+ * describes, and a section about it tells the reader nothing the rest of the document did not.
169
+ */
170
+ var isGeneratedPath = (path) => {
171
+ const name = path.split("/").pop() ?? path;
172
+ return LOCKFILES.includes(name) || GENERATED_DIRECTORIES.test(path) || GENERATED_SUFFIX.test(path) || BINARY_SUFFIX.test(path) || path.startsWith(".changeset/") || path.includes("/.changeset/");
173
+ };
174
+ /** A file git could not diff as text, whatever its extension says. */
175
+ var isBinaryPatch = (preamble) => preamble.some((line) => line.startsWith("Binary files ") || line.startsWith("GIT binary patch"));
176
+ /**
177
+ * Whether this file is one the walkthrough should leave alone.
178
+ *
179
+ * A hunk count of zero is NOT generated on its own: a rename or a mode change is still a change a
180
+ * reviewer has to know about, and {@link fillWalkthrough} reports it separately.
181
+ */
182
+ var isGeneratedFile = (file) => isGeneratedPath(file.path) || isBinaryPatch(file.preamble);
183
+ //#endregion
184
+ //#region src/walkthrough/fill.ts
185
+ /**
186
+ * Opening fence plus its info line; the body is whatever follows up to the matching close. Built per
187
+ * call rather than shared: a `/g` regex carries `lastIndex` between uses.
188
+ *
189
+ * At most three spaces of indent, because four makes it an indented code block in CommonMark rather
190
+ * than a fence.
191
+ */
192
+ var fencePattern = () => /^( {0,3})(`{3,}|~{3,})[ \t]*diff\b([^\n]*)$/gm;
193
+ var parseAttributes = (info) => {
194
+ const attributes = {};
195
+ for (const token of info.trim().match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) ?? []) {
196
+ const separator = token.indexOf("=");
197
+ if (separator > 0) attributes[token.slice(0, separator)] = token.slice(separator + 1).replace(/^["']|["']$/g, "");
198
+ else if (!attributes.file) attributes.file = token.replace(/^["']|["']$/g, "");
199
+ }
200
+ return attributes;
201
+ };
202
+ var findPlaceholders = (body) => {
203
+ const placeholders = [];
204
+ const pattern = fencePattern();
205
+ let match;
206
+ while (match = pattern.exec(body)) {
207
+ const [opening, indent, fence, info] = match;
208
+ const bodyStart = match.index + opening.length + 1;
209
+ const close = new RegExp(`^[ \\t]*${fence[0]}{${fence.length},}[ \\t]*$`, "m");
210
+ close.lastIndex = 0;
211
+ const rest = body.slice(bodyStart);
212
+ const closeMatch = close.exec(rest);
213
+ const contents = closeMatch ? rest.slice(0, closeMatch.index) : rest;
214
+ const to = closeMatch ? bodyStart + closeMatch.index + closeMatch[0].length : body.length;
215
+ placeholders.push({
216
+ from: match.index,
217
+ to,
218
+ fence,
219
+ indent,
220
+ attributes: parseAttributes(info),
221
+ empty: contents.trim().length === 0
222
+ });
223
+ pattern.lastIndex = to;
224
+ }
225
+ return placeholders;
226
+ };
227
+ /** The hunks a fence asks for: those overlapping its `lines=`, or the whole file without one. */
228
+ var selectHunks = (file, lines) => {
229
+ const range = lines?.match(/^(\d+)(?:\s*[-–]\s*(\d+))?$/);
230
+ if (!range) return file.hunks;
231
+ const start = Number(range[1]);
232
+ const end = range[2] === void 0 ? start : Number(range[2]);
233
+ const selected = file.hunks.filter((hunk) => hunkOverlaps(hunk, start, end));
234
+ return selected.length > 0 ? selected : file.hunks;
235
+ };
236
+ var buildFence = (fence, attributes, contents, indent = "") => {
237
+ const info = Object.entries(attributes).filter(([, value]) => value.length > 0).map(([key, value]) => `${key}=${/\s/.test(value) ? `"${value}"` : value}`).join(" ");
238
+ return [
239
+ `${fence}diff${info ? ` ${info}` : ""}`,
240
+ ...contents.split("\n"),
241
+ fence
242
+ ].map((line) => line.length > 0 ? indent + line : line).join("\n");
243
+ };
244
+ /**
245
+ * Fills the walkthrough's empty diff fences from the pull request's own patch, then reports what the
246
+ * prose never mentioned.
247
+ *
248
+ * The model is asked for placeholders — a path and a line range — rather than diff content, because
249
+ * a model that transcribes a diff gets lines subtly wrong and the result is a review artefact that
250
+ * lies about the change. Here the bytes come from git and only the selection is the model's.
251
+ */
252
+ var fillWalkthrough = (body, patch) => {
253
+ const files = parsePatch(patch);
254
+ const byPath = new Map(files.map((file) => [file.path, file]));
255
+ const generated = files.filter((file) => isGeneratedFile(file)).map((file) => file.path);
256
+ const generatedPaths = new Set(generated);
257
+ const used = /* @__PURE__ */ new Set();
258
+ const unresolved = [];
259
+ let filled = "";
260
+ let cursor = 0;
261
+ for (const placeholder of findPlaceholders(body)) {
262
+ const { file: path, ...rest } = placeholder.attributes;
263
+ const file = path ? byPath.get(path) : void 0;
264
+ const verbatim = body.slice(placeholder.from, placeholder.to);
265
+ filled += body.slice(cursor, placeholder.from);
266
+ cursor = placeholder.to;
267
+ if (!placeholder.empty) {
268
+ filled += verbatim;
269
+ continue;
270
+ }
271
+ if (!path) {
272
+ unresolved.push("(a fence with no file)");
273
+ filled += verbatim;
274
+ continue;
275
+ }
276
+ if (!file) {
277
+ unresolved.push(path);
278
+ filled += verbatim;
279
+ continue;
280
+ }
281
+ if (generatedPaths.has(path)) continue;
282
+ const hunks = selectHunks(file, rest.lines);
283
+ if (hunks.length === 0) {
284
+ filled += verbatim;
285
+ continue;
286
+ }
287
+ for (const hunk of hunks) used.add(hunk);
288
+ filled += buildFence(placeholder.fence, {
289
+ file: path,
290
+ ...rest,
291
+ lines: hunkRange(hunks) ?? rest.lines ?? ""
292
+ }, renderHunks(hunks), placeholder.indent);
293
+ }
294
+ filled += body.slice(cursor);
295
+ const missed = files.map((file) => ({
296
+ path: file.path,
297
+ hunks: file.hunks.filter((hunk) => !used.has(hunk))
298
+ })).filter((file) => file.hunks.length > 0 && !generatedPaths.has(file.path));
299
+ const textless = files.filter((file) => file.hunks.length === 0 && !generatedPaths.has(file.path)).map((file) => file.path);
300
+ const total = files.filter((file) => !generatedPaths.has(file.path)).reduce((count, file) => count + file.hunks.length, 0);
301
+ const appendix = renderMissed(missed, textless, generated);
302
+ return {
303
+ body: appendix ? filled.trimEnd() + "\n" + appendix : filled,
304
+ missed,
305
+ textless,
306
+ generated,
307
+ unresolved,
308
+ covered: used.size,
309
+ total
310
+ };
311
+ };
312
+ /** The trailing section: everything the walkthrough did not account for, so the diff stays whole. */
313
+ var renderMissed = (missed, textless, generated) => {
314
+ if (missed.length === 0 && textless.length === 0 && generated.length === 0) return "";
315
+ const hunks = missed.reduce((count, file) => count + file.hunks.length, 0);
316
+ const lines = [
317
+ "",
318
+ "## Also changed",
319
+ ""
320
+ ];
321
+ if (missed.length > 0) lines.push(`${hunks} ${hunks === 1 ? "hunk" : "hunks"} across ${missed.length} ${missed.length === 1 ? "file" : "files"} the walkthrough above does not describe.`, "");
322
+ for (const file of missed) lines.push(buildFence("```", {
323
+ file: file.path,
324
+ lines: hunkRange(file.hunks) ?? ""
325
+ }, renderHunks(file.hunks)), "");
326
+ if (textless.length > 0) lines.push(`Changed with no lines to show (renamed or mode-only): ${textless.join(", ")}.`, "");
327
+ if (generated.length > 0) lines.push(`Generated or binary, not shown: ${generated.join(", ")}.`, "");
328
+ return lines.join("\n");
329
+ };
330
+ //#endregion
331
+ //#region src/walkthrough/plan.ts
332
+ /**
333
+ * Diffs longer than this get the two-stage treatment.
334
+ *
335
+ * Twice the one-shot budget: below that, trimming drops a file or two and the single prompt still
336
+ * sees the shape of the change, and a second model call would buy nothing.
337
+ */
338
+ var DEFAULT_CHAPTER_THRESHOLD_CHARS = 32e3;
339
+ var PLANNER_SYSTEM_PROMPT = [
340
+ "You plan the chapters of a walkthrough: the document that takes a reviewer through a pull",
341
+ "request in the order it is best understood.",
342
+ "",
343
+ "You see the files and their sizes, never their contents. Decide the ORDER a reviewer should meet",
344
+ "this change in, and which files belong together.",
345
+ "",
346
+ "Rules:",
347
+ "- The core of the change comes first. Mechanical consequences (call sites, tests, docs) come",
348
+ " after the thing that forced them.",
349
+ "- A chapter is a reason, not a directory. Files that change for the same reason belong together",
350
+ " however far apart they sit in the tree.",
351
+ "- Every file in the list belongs to exactly one chapter. Do not invent files.",
352
+ "- Between three and seven chapters. Fewer on a change with one idea, more on a change that",
353
+ " genuinely does several things.",
354
+ "",
355
+ "Answer with JSON and nothing else:",
356
+ "{\"title\": \"…\", \"overview\": \"…\", \"chapters\": [{\"title\": \"…\", \"summary\": \"…\", \"files\": [\"…\"]}]}",
357
+ "",
358
+ "`title` is the H1 for the document: what the change does, in one line. `overview` is two or",
359
+ "three sentences on what it does and why, for the reader who has not seen the diff. Each",
360
+ "chapter's `summary` is one sentence telling that chapter's writer what to explain."
361
+ ].join("\n");
362
+ /** The file list the planner sees: path, size of change, and nothing else. */
363
+ var buildPlannerPrompt = (facts, diff) => {
364
+ const files = parsePatch(diff).filter((file) => !isGeneratedFile(file));
365
+ const lines = [
366
+ `Repository: ${facts.owner}/${facts.repo}`,
367
+ `Pull request: #${facts.number}`,
368
+ `Title: ${facts.title}`
369
+ ];
370
+ if (facts.description?.trim()) lines.push("", "Description as written by the author:", facts.description.trim());
371
+ lines.push("", `Files changed (${files.length}):`, "");
372
+ for (const file of files) lines.push(`${file.path} (+${file.added}/-${file.removed}, ${file.hunks.length} hunks)`);
373
+ return lines.join("\n");
374
+ };
375
+ /**
376
+ * Reads the planner's answer.
377
+ *
378
+ * Tolerant of a fenced block or surrounding prose, because a refusal to parse costs the whole run
379
+ * and the recovery — falling back to one-shot — is worse than reading a fence.
380
+ */
381
+ var parsePlan = (response, paths) => {
382
+ const text = (response.match(/^[ \t]*(`{3,})[^\n]*\n([\s\S]*?)^[ \t]*\1`*[ \t]*$/m)?.[2] ?? response).trim();
383
+ const start = text.indexOf("{");
384
+ const end = text.lastIndexOf("}");
385
+ if (start < 0 || end <= start) return;
386
+ let parsed;
387
+ try {
388
+ parsed = JSON.parse(text.slice(start, end + 1));
389
+ } catch {
390
+ return;
391
+ }
392
+ const decoded = decodePlan(parsed);
393
+ if (!decoded) return;
394
+ const known = new Set(paths);
395
+ const claimed = /* @__PURE__ */ new Set();
396
+ const chapters = [];
397
+ for (const chapter of decoded.chapters) {
398
+ const files = chapter.files.filter((path) => known.has(path) && !claimed.has(path));
399
+ for (const path of files) claimed.add(path);
400
+ if (files.length > 0) chapters.push({
401
+ title: chapter.title,
402
+ files,
403
+ summary: chapter.summary
404
+ });
405
+ }
406
+ if (chapters.length === 0) return;
407
+ const unclaimed = paths.filter((path) => !claimed.has(path));
408
+ if (unclaimed.length > 0) chapters.push({
409
+ title: "The rest of the change",
410
+ files: [...unclaimed]
411
+ });
412
+ return {
413
+ title: decoded.title,
414
+ overview: decoded.overview,
415
+ chapters
416
+ };
417
+ };
418
+ /** Fields of the shape the planner was asked for; anything else is dropped rather than carried. */
419
+ var isString = (value) => typeof value === "string";
420
+ /**
421
+ * Reads the model's JSON into the typed shape, field by field.
422
+ *
423
+ * Every value is checked, `summary` included: a non-string there would reach `buildChapterPrompt`
424
+ * and be interpolated into the next prompt as `[object Object]`.
425
+ */
426
+ var decodePlan = (value) => {
427
+ if (typeof value !== "object" || value === null) return;
428
+ const record = value;
429
+ if (!isString(record.title) || !Array.isArray(record.chapters)) return;
430
+ const chapters = record.chapters.flatMap((entry) => {
431
+ if (typeof entry !== "object" || entry === null) return [];
432
+ const chapter = entry;
433
+ if (!isString(chapter.title) || !Array.isArray(chapter.files)) return [];
434
+ return [{
435
+ title: chapter.title,
436
+ files: chapter.files.filter(isString),
437
+ ...isString(chapter.summary) ? { summary: chapter.summary } : {}
438
+ }];
439
+ });
440
+ return {
441
+ title: record.title,
442
+ overview: isString(record.overview) ? record.overview : "",
443
+ chapters
444
+ };
445
+ };
446
+ /** The diff of one chapter's files, in patch order. */
447
+ var chapterDiff = (files, chapter) => {
448
+ const wanted = new Set(chapter.files);
449
+ return files.filter((file) => wanted.has(file.path)).map((file) => [...file.preamble, ...file.hunks.flatMap((hunk) => [hunk.header, ...hunk.lines])].join("\n")).join("\n");
450
+ };
451
+ var CHAPTER_SYSTEM_PROMPT = [
452
+ "You write ONE chapter of a walkthrough of a pull request: the section a reviewer reads to",
453
+ "understand this part of the change.",
454
+ "",
455
+ "You are given the chapter you are writing, the document it belongs to, and the diff of this",
456
+ "chapter's files only. Other chapters cover the rest; do not describe them.",
457
+ "",
458
+ "Output:",
459
+ "- Open with the H2 heading you are given, exactly as given. No H1, no other H2.",
460
+ "- Under it, a short paragraph saying what this part does and what constraint it satisfies, then",
461
+ " the code it refers to.",
462
+ "- Reference a change with an EMPTY fenced block, exactly like this, and nothing inside it:",
463
+ "",
464
+ " ```diff file=path/to/file.ts lines=66-99",
465
+ " ```",
466
+ "",
467
+ "- `file` is the path exactly as the diff gives it. `lines` is the range in the file AFTER the",
468
+ " change, from the `@@` header. NEVER put diff content inside the fence: it is filled in for you",
469
+ " from the real patch, and anything you write there is discarded.",
470
+ "- A mechanical change repeated across files is one point: fence the instance that shows the",
471
+ " shape and say how many others take it.",
472
+ "- EVERY file listed in your chapter appears in at least one fence. A file whose hunks do not",
473
+ " each earn a paragraph still gets one fence, grouped with the others that change for its reason.",
474
+ "",
475
+ "Write for a reviewer reading once. The sentence rule is the one that matters most:",
476
+ "- ONE IDEA PER SENTENCE, under thirty words. No semicolons joining two clauses, no dashes",
477
+ " carrying a second thought, no sentence that needs a comma-separated list of parentheticals.",
478
+ " Where you would write a long sentence, write two short ones.",
479
+ "- Name the mechanism, not the feeling. Prose explains WHY the change is the way it is: the",
480
+ " constraint, the failure it avoids, the alternative rejected. Do not narrate what the diff shows.",
481
+ "- Active voice with the actor named. Plain words. Sentence case headings. No emoji.",
482
+ "- Output the markdown for this chapter and nothing else. No preamble, no closing summary."
483
+ ].join("\n");
484
+ var buildChapterPrompt = (plan, chapter, diff) => [
485
+ `Document: ${plan.title}`,
486
+ plan.overview ? `Overview: ${plan.overview}` : "",
487
+ "",
488
+ `Your chapter: ## ${chapter.title}`,
489
+ chapter.summary ? `What it must explain: ${chapter.summary}` : "",
490
+ "",
491
+ `Other chapters, for context only: ${plan.chapters.filter((other) => other.title !== chapter.title).map((other) => other.title).join("; ")}`,
492
+ "",
493
+ "Diff:",
494
+ "",
495
+ diff
496
+ ].filter((line) => line !== "").join("\n");
497
+ /** Stitches the planner's opening and the chapter bodies into one document. */
498
+ var assembleWalkthrough = (plan, chapters) => spaceHeadings([
499
+ `# ${plan.title}`,
500
+ "",
501
+ plan.overview,
502
+ "",
503
+ ...chapters.map((chapter) => chapter.trim())
504
+ ].filter((part, index) => part !== "" || index < 3).join("\n").replace(/\n{3,}/g, "\n\n")).trimEnd() + "\n";
505
+ //#endregion
506
+ //#region src/walkthrough/prompt.ts
507
+ /**
508
+ * Measured against Sonnet, whose 16k output budget covers reasoning AND the answer. A whole
509
+ * 75k-character diff is ~33k input tokens, and the model then spends the entire output budget
510
+ * reasoning: the response comes back `finishReason: 'length'` carrying a reasoning block and NO
511
+ * text at all. At ~19k characters the same request answers in full with room to spare.
512
+ *
513
+ * Trimming costs nothing a reader sees, because every hunk the prose does not claim is appended
514
+ * verbatim by {@link fillWalkthrough}.
515
+ */
516
+ var DEFAULT_MAX_DIFF_CHARS = 16e3;
517
+ /**
518
+ * What the model is for: the ORDER and the REASONS, never the diff content.
519
+ *
520
+ * Every chunk is emitted as an empty fence carrying a path and a line range, which a postprocess
521
+ * fills from the patch itself. A model asked to transcribe a diff gets lines subtly wrong, and a
522
+ * review artefact that misquotes the change is worse than no artefact.
523
+ */
524
+ var SYSTEM_PROMPT = [
525
+ "You write walkthroughs of pull requests: one markdown document that takes a reviewer through a",
526
+ "change in the order it is best understood, rather than in the order the files happen to sort.",
527
+ "",
528
+ "Structure:",
529
+ "- Open with an H1 naming the change, then two or three sentences on what it does and why.",
530
+ "- Group the change into sections with H2 headings, ordered so each one builds on the last.",
531
+ " Put the core of the change first and the mechanical consequences after it.",
532
+ "- Under a heading, write a short paragraph saying what this part does and what constraint it",
533
+ " satisfies, then show the code it refers to.",
534
+ "",
535
+ "Showing code — this is the part to get right:",
536
+ "- Reference a change with an EMPTY fenced block, exactly like this, and nothing inside it:",
537
+ "",
538
+ " ```diff file=path/to/file.ts lines=66-99",
539
+ " ```",
540
+ "",
541
+ "- `file` is the path exactly as the diff gives it, after the change. `lines` is the range in the",
542
+ " file AFTER the change, taken from the `@@` header. Omit `lines` to show the whole file.",
543
+ "- NEVER put diff content, code, `@@` headers or `+`/`-` lines inside the fence. It is filled in",
544
+ " for you from the real patch. Anything you write there is discarded.",
545
+ "- One fence per point being made. Several fences under one heading is normal.",
546
+ "",
547
+ "Style:",
548
+ "- Prose explains WHY the change is the way it is: the constraint, the failure it avoids, the",
549
+ " alternative that was rejected. Do not narrate what the diff already shows.",
550
+ "- Do not describe every file. Cover what a reviewer must understand; the rest is appended for",
551
+ " you under a separate heading.",
552
+ "- No preamble, no \"this PR\", no closing summary. Output the markdown document and nothing else.",
553
+ "",
554
+ "Write for a reviewer reading once:",
555
+ "- One idea per sentence. Past thirty words, split it. The reader must never backtrack to parse.",
556
+ "- Name the mechanism, not the feeling: \"the second attempt runs on a warmed socket\", never",
557
+ " \"this makes the call more robust\". A sentence that would fit another project unchanged says",
558
+ " nothing about this one. Cut it.",
559
+ "- Active voice with the actor named: \"the compiler validates queries\", not \"queries are validated\".",
560
+ "- Plain words. Never: additionally, crucial, delve, enhance, leverage, pivotal, robust, seamless,",
561
+ " showcase, testament, underscore, utilize. Say \"is\" rather than \"serves as\" or \"stands as\".",
562
+ "- Sentence case headings. No emoji. No bold label that restates the line it introduces.",
563
+ "- End a sentence or use a comma rather than an em dash."
564
+ ].join("\n");
565
+ /** Trims the patch to the budget, keeping as many files as fit and naming what was left out. */
566
+ var budgetDiff = (diff, maxChars) => {
567
+ const parsed = parsePatch(diff);
568
+ const generated = parsed.filter((file) => isGeneratedFile(file)).map((file) => file.path);
569
+ const files = parsed.filter((file) => !isGeneratedFile(file)).map((file) => ({
570
+ path: file.path,
571
+ text: [...file.preamble, ...file.hunks.flatMap((hunk) => [hunk.header, ...hunk.lines])].join("\n")
572
+ }));
573
+ const withoutGenerated = files.map((file) => file.text).join("\n");
574
+ if (withoutGenerated.length <= maxChars) return {
575
+ diff: generated.length > 0 ? withoutGenerated : diff,
576
+ omitted: generated
577
+ };
578
+ const order = [...files].sort((left, right) => left.text.length - right.text.length);
579
+ const kept = /* @__PURE__ */ new Set();
580
+ let used = 0;
581
+ for (const file of order) {
582
+ if (used + file.text.length > maxChars) continue;
583
+ used += file.text.length + 1;
584
+ kept.add(file.path);
585
+ }
586
+ return {
587
+ diff: files.filter((file) => kept.has(file.path)).map((file) => file.text).join("\n"),
588
+ omitted: [...generated, ...files.filter((file) => !kept.has(file.path)).map((file) => file.path)]
589
+ };
590
+ };
591
+ /** The user-side content: what the change is, followed by the diff the fences will be filled from. */
592
+ var buildPrompt = (input, options = {}) => {
593
+ const { diff, omitted } = budgetDiff(input.diff, options.maxDiffChars ?? DEFAULT_MAX_DIFF_CHARS);
594
+ const lines = [
595
+ `Repository: ${input.owner}/${input.repo}`,
596
+ `Pull request: #${input.number}`,
597
+ `Title: ${input.title}`
598
+ ];
599
+ if (input.headBranch && input.baseBranch) lines.push(`Branch: ${input.headBranch} into ${input.baseBranch}`);
600
+ if (input.description?.trim()) lines.push("", "Description as written by the author:", input.description.trim());
601
+ if (omitted.length > 0) lines.push("", `Omitted from the diff below for length, and not yours to describe: ${omitted.join(", ")}.`);
602
+ lines.push("", "Diff:", "", diff);
603
+ return lines.join("\n");
604
+ };
605
+ /**
606
+ * Decides whether to regenerate, runs the model, fills the chunks, and stores the result.
607
+ *
608
+ * Split from the operation handler so the part with the decisions in it can be tested against a real
609
+ * database without a network or a model: what the handler adds is two HTTP calls.
610
+ */
611
+ var generateWalkthrough = ({ pullRequest, remote, diff, force, model, narrate, report = () => {}, chapterThresholdChars = DEFAULT_CHAPTER_THRESHOLD_CHARS }) => Effect.gen(function* () {
612
+ const existing = yield* findWalkthrough(pullRequest);
613
+ if (existing && !force && remote.commit && !Walkthrough.isStale(existing, remote.commit)) {
614
+ report(Progress.STATUS_COMPLETE, 5);
615
+ return {
616
+ walkthrough: existing,
617
+ generated: false,
618
+ covered: existing.covered ?? 0,
619
+ total: existing.total ?? 0
620
+ };
621
+ }
622
+ report("Writing the walkthrough", 3);
623
+ const facts = {
624
+ owner: pullRequest.owner,
625
+ repo: pullRequest.repo,
626
+ number: pullRequest.number,
627
+ title: remote.title ?? pullRequest.title,
628
+ description: remote.description ?? pullRequest.description,
629
+ baseBranch: remote.baseBranch ?? pullRequest.baseBranch,
630
+ headBranch: remote.headBranch ?? pullRequest.headBranch
631
+ };
632
+ const chaptered = diff.length > chapterThresholdChars ? yield* narrateChapters(facts, diff, narrate, report) : void 0;
633
+ const narration = chaptered ?? (yield* narrate(`${SYSTEM_PROMPT}\n\n---\n\n${buildPrompt({
634
+ ...facts,
635
+ diff
636
+ })}`));
637
+ report("Filling the chunks", 4);
638
+ const filled = fillWalkthrough(narration, diff);
639
+ const walkthrough = yield* upsert(existing, {
640
+ pullRequest: Ref.make(pullRequest),
641
+ title: Walkthrough.makeTitle(pullRequest, remote.title ?? pullRequest.title),
642
+ body: spaceHeadings(filled.body),
643
+ commit: remote.commit ?? "",
644
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
645
+ model,
646
+ covered: filled.covered,
647
+ total: filled.total
648
+ });
649
+ report(Progress.STATUS_COMPLETE, 5);
650
+ return {
651
+ walkthrough,
652
+ strategy: chaptered ? "chaptered" : "one-shot",
653
+ generated: true,
654
+ covered: filled.covered,
655
+ total: filled.total
656
+ };
657
+ });
658
+ /**
659
+ * Plans the chapters, then narrates each one against its own files.
660
+ *
661
+ * Returns undefined when the plan cannot be read, so the caller falls back to one prompt rather
662
+ * than failing: a walkthrough of part of the change beats no walkthrough.
663
+ */
664
+ var narrateChapters = (facts, diff, narrate, report) => Effect.gen(function* () {
665
+ const files = parsePatch(diff).filter((file) => !isGeneratedFile(file));
666
+ const plan = parsePlan(yield* narrate(`${PLANNER_SYSTEM_PROMPT}\n\n---\n\n${buildPlannerPrompt(facts, diff)}`), files.map((file) => file.path));
667
+ if (!plan) return;
668
+ const chapters = [];
669
+ for (const chapter of plan.chapters) {
670
+ report(`Writing "${chapter.title}"`, 3);
671
+ const body = yield* narrate(`${CHAPTER_SYSTEM_PROMPT}\n\n---\n\n${buildChapterPrompt(plan, chapter, chapterDiff(files, chapter))}`);
672
+ chapters.push(body);
673
+ }
674
+ return assembleWalkthrough(plan, chapters);
675
+ });
676
+ /** The walkthrough already written for this pull request, if any. */
677
+ var findWalkthrough = (pullRequest) => Database.query(Filter.type(Walkthrough.Walkthrough, { pullRequest: Ref.make(pullRequest) })).run.pipe(Effect.map(newestWalkthrough), Effect.orDie);
678
+ /**
679
+ * The newest of however many were written, ties broken by id.
680
+ *
681
+ * Two generations racing on one pull request both see none and both add: the check and the write
682
+ * are separate steps, and ECHO has neither a uniqueness constraint nor an atomic upsert to close
683
+ * that. Picking deterministically makes the duplicate inert instead — every reader lands on the
684
+ * same object, and the next regeneration updates that one in place rather than forking again. The
685
+ * loser stays in the space; removing it from a read path would delete another client's object.
686
+ */
687
+ var newestWalkthrough = (walkthroughs) => walkthroughs.reduce((newest, walkthrough) => {
688
+ if (!newest) return walkthrough;
689
+ const left = generatedTime(walkthrough);
690
+ const right = generatedTime(newest);
691
+ if (left !== right) return left > right ? walkthrough : newest;
692
+ return walkthrough.id > newest.id ? walkthrough : newest;
693
+ }, void 0);
694
+ /**
695
+ * Parsed rather than compared as a string: `generatedAt` is an unvalidated date-time, so a value
696
+ * written by anything but this code can carry an offset (`+02:00`) that sorts against a `Z` value
697
+ * the wrong way round. An unparseable or absent one sorts oldest.
698
+ */
699
+ var generatedTime = (walkthrough) => {
700
+ const parsed = Date.parse(walkthrough.generatedAt ?? "");
701
+ return Number.isNaN(parsed) ? Number.NEGATIVE_INFINITY : parsed;
702
+ };
703
+ /** Replaces the body in place where one exists, so links to the walkthrough survive regeneration. */
704
+ var upsert = (existing, props) => Effect.gen(function* () {
705
+ if (!existing) return yield* Database.add(Walkthrough.make(props));
706
+ return Obj.update(existing, (existing) => {
707
+ existing.title = props.title;
708
+ existing.body = props.body;
709
+ existing.commit = props.commit;
710
+ existing.generatedAt = props.generatedAt;
711
+ existing.model = props.model;
712
+ existing.covered = props.covered;
713
+ existing.total = props.total;
714
+ });
715
+ });
716
+ //#endregion
717
+ export { renderHunks as a, parsePatch as i, newestWalkthrough as n, spaceHeadings as r, generateWalkthrough as t };
718
+
719
+ //# sourceMappingURL=chunk-generate.mjs.map