@pi-chamber/web 1.0.3-rc.1 → 1.0.4-rc.1

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 (290) hide show
  1. package/dist/assets/DiagramView-DfZMQkXY.js +1 -0
  2. package/dist/assets/{DiffView-CXg8TAtI.js → DiffView-BjWUdbL5.js} +6 -6
  3. package/dist/assets/FileSaveConflictDialog-u5L4k_5k.js +3 -0
  4. package/dist/assets/FilesView-qP1ypN9J.js +6 -0
  5. package/dist/assets/GitHubDetailScaffold-zCKCy5OJ.js +11 -0
  6. package/dist/assets/GitHubLinkPicker-CwxKY3lN.js +1 -0
  7. package/dist/assets/GitHubListPrimitives-Ck3zllel.js +1 -0
  8. package/dist/assets/GitView-y2k2i4gR.js +9 -0
  9. package/dist/assets/IssuesSurface-HWgR87N3.js +7 -0
  10. package/dist/assets/JsonTreeView-DSuC4naV.js +1 -0
  11. package/dist/assets/{MarkdownRendererImpl-CeYMkg1A.js → MarkdownRendererImpl-CT5ln9em.js} +5 -5
  12. package/dist/assets/PatchDiff-DArTeWeK.js +1 -0
  13. package/dist/assets/PierreDiffViewer-DQKujzLb.js +134 -0
  14. package/dist/assets/PullRequestsSurface-Cfb1wSvC.js +2 -0
  15. package/dist/assets/SessionSwitcherContent-DEGJyZBl.js +1 -0
  16. package/dist/assets/SessionSwitcherDropdown-cC9wVBH7.js +2 -0
  17. package/dist/assets/SessionUnreadDot-CELKNVIM.js +1 -0
  18. package/dist/assets/SettingsView-CZvRRgJe.js +6 -0
  19. package/dist/assets/SettingsWindow-CZM1dmVb.js +1 -0
  20. package/dist/assets/ToolOutputDialog-DClOSbJc.js +8 -0
  21. package/dist/assets/ToolPartDiffPreview-BaFiGUDE.js +1 -0
  22. package/dist/assets/{VirtualizedFileDiff-CV_Cpmqu.js → VirtualizedFileDiff-D6KbvKc6.js} +3 -3
  23. package/dist/assets/Virtualizer-wpC51ZBQ.js +1 -0
  24. package/dist/assets/collapsible-DhV9d4dT.js +1 -0
  25. package/dist/assets/computeVirtualFileMetrics-CeMpF2xC.js +3 -0
  26. package/dist/assets/{contextFileOpenGuard-BA2pkQY_.js → contextFileOpenGuard-Ck5u_kAP.js} +1 -1
  27. package/dist/assets/gitStatusPredicates-DEBSqUNE.js +1 -0
  28. package/dist/assets/githubLink-DT7i2NlH.js +10 -0
  29. package/dist/assets/index-6IO1AcJI.js +10 -0
  30. package/dist/assets/index-BAmzAlNx.css +1 -0
  31. package/dist/assets/index-eDf4LKLY.js +1 -0
  32. package/dist/assets/main-BczEScAA.js +2 -0
  33. package/dist/assets/main-CHLNMYeJ.js +136 -0
  34. package/dist/assets/markdownCore-C4Gk5Zht.js +2 -0
  35. package/dist/assets/miniChat-Do3hE87Z.js +2 -0
  36. package/dist/assets/mobile-CTnihwfa.js +2 -0
  37. package/dist/assets/permissionStore-B9Hkrqny.js +1 -0
  38. package/dist/assets/pi-session-focus-preference-LDVCJ_YR.js +10 -0
  39. package/dist/assets/renderDiffWithHighlighter-CDsgOnkH.js +1 -0
  40. package/dist/assets/renderElectronMiniChatApp-DSa3gYqR.js +2 -0
  41. package/dist/assets/renderFileWithHighlighter-TpKRyfCY.js +1 -0
  42. package/dist/assets/renderMobileApp-CPE-3uMl.js +11 -0
  43. package/dist/assets/runtimeEndpointReset-CzJfovWI.js +62 -0
  44. package/dist/assets/{runtimeSurface-BdndJV2m.js → runtimeSurface-DW_Ia4q3.js} +1 -1
  45. package/dist/assets/shell-CjFT_Tl9.js +1 -0
  46. package/dist/assets/sprite-HGQGInUp.js +6510 -0
  47. package/dist/assets/useAppFontEffects-CG3_yteE.js +212 -0
  48. package/dist/assets/{useFilesViewSearch-CI5Gy1cp.js → useFilesViewSearch-C_LzYIgD.js} +1 -1
  49. package/dist/assets/useGitHubRemoteSearch-DsxWOzKZ.js +1 -0
  50. package/dist/assets/useSwitcherItems-BmoCnS9W.js +1 -0
  51. package/dist/assets/vendor-base-ui-DIkTOIJS.js +1 -0
  52. package/dist/assets/{vendor-beautiful-mermaid-D3YCkKz7.js → vendor-beautiful-mermaid-DApbjBp2.js} +1 -1
  53. package/dist/assets/vendor-boot-DyL2td56.js +69 -0
  54. package/dist/assets/vendor-codemirror-autocomplete-DsFn4GLp.js +1 -0
  55. package/dist/assets/vendor-codemirror-lang-angular-B_NMmBbS.js +1 -0
  56. package/dist/assets/vendor-codemirror-lang-cpp-GOE7Gjd0.js +1 -0
  57. package/dist/assets/vendor-codemirror-lang-css-Dwf2XpnZ.js +1 -0
  58. package/dist/assets/vendor-codemirror-lang-go-C2KHbcll.js +7 -0
  59. package/dist/assets/vendor-codemirror-lang-html-DcKqyeGk.js +1 -0
  60. package/dist/assets/vendor-codemirror-lang-java-6eGbyB2k.js +1 -0
  61. package/dist/assets/vendor-codemirror-lang-javascript-DpTUrvx8.js +13 -0
  62. package/dist/assets/vendor-codemirror-lang-jinja-xSUJjXhr.js +1 -0
  63. package/dist/assets/vendor-codemirror-lang-json-CLGxdOCz.js +1 -0
  64. package/dist/assets/vendor-codemirror-lang-less-6nXi1rS9.js +1 -0
  65. package/dist/assets/vendor-codemirror-lang-liquid-B9hmb9P8.js +1 -0
  66. package/dist/assets/vendor-codemirror-lang-markdown-DmFP9s6x.js +1 -0
  67. package/dist/assets/vendor-codemirror-lang-php-DC6To8iX.js +1 -0
  68. package/dist/assets/vendor-codemirror-lang-python-yuxIkjit.js +3 -0
  69. package/dist/assets/vendor-codemirror-lang-rust-di1Sjz-0.js +1 -0
  70. package/dist/assets/vendor-codemirror-lang-sass-BWpV9NPV.js +1 -0
  71. package/dist/assets/{vendor-codemirror-lang-sql-HpQWHJjv.js → vendor-codemirror-lang-sql-C_RazIaB.js} +2 -2
  72. package/dist/assets/vendor-codemirror-lang-vue-BYL0r7KR.js +1 -0
  73. package/dist/assets/vendor-codemirror-lang-wast-BiVarhcz.js +1 -0
  74. package/dist/assets/vendor-codemirror-lang-xml-Cn1lY1ts.js +1 -0
  75. package/dist/assets/vendor-codemirror-lang-yaml-BZ6mZw9L.js +1 -0
  76. package/dist/assets/vendor-codemirror-language-data-DglcKYWT.js +2 -0
  77. package/dist/assets/vendor-codemirror-search-DaE6R5gH.js +2 -0
  78. package/dist/assets/{vendor-elkjs-mzfkf0ML.js → vendor-elkjs-D27273Ms.js} +1 -1
  79. package/dist/assets/{vendor-heic2any-BHsbokcA.js → vendor-heic2any-pq-UTQQR.js} +1 -1
  80. package/dist/assets/vendor-lezer-cpp-Dt99h3WT.js +1 -0
  81. package/dist/assets/vendor-lezer-css-DNU_fzPI.js +1 -0
  82. package/dist/assets/vendor-lezer-go-BEFtcNyS.js +1 -0
  83. package/dist/assets/vendor-lezer-html-DDGRhRUz.js +1 -0
  84. package/dist/assets/vendor-lezer-java-DmfZtW09.js +1 -0
  85. package/dist/assets/vendor-lezer-javascript-oje4tdp_.js +1 -0
  86. package/dist/assets/vendor-lezer-json-BRXb_bDX.js +1 -0
  87. package/dist/assets/vendor-lezer-lr-BU2qmu_5.js +1 -0
  88. package/dist/assets/{vendor-lezer-markdown-C6g-d6P3.js → vendor-lezer-markdown-CicYv7V9.js} +4 -4
  89. package/dist/assets/vendor-lezer-php-COORrTpE.js +1 -0
  90. package/dist/assets/vendor-lezer-python-Cuvm9X9Y.js +1 -0
  91. package/dist/assets/vendor-lezer-rust-C_zOfHbX.js +1 -0
  92. package/dist/assets/vendor-lezer-sass-DWP4w7O1.js +1 -0
  93. package/dist/assets/vendor-lezer-xml-Br6nOYeG.js +1 -0
  94. package/dist/assets/vendor-lezer-yaml-CYQmm6Sb.js +1 -0
  95. package/dist/assets/{vendor-lru_map-Cy8fTs3_.js → vendor-lru_map-DOPmc7GU.js} +1 -1
  96. package/dist/assets/{vendor-qrcode-B0KNSajT.js → vendor-qrcode-Dv4uniC1.js} +1 -1
  97. package/dist/assets/vendor-react-DASdDPIk.js +1 -0
  98. package/dist/assets/{vendor-react-drawio-BYDptOsj.js → vendor-react-drawio-Duu5LgQA.js} +1 -1
  99. package/dist/assets/{vendor-replit-codemirror-vim-DaSwPsXt.js → vendor-replit-codemirror-vim-CZy3BUVv.js} +15 -15
  100. package/dist/assets/vendor-zustand-CUi8eEds.js +6 -0
  101. package/dist/assets/{web-components-Cdnmh4Xb.js → web-components-CH3-XV-n.js} +4 -4
  102. package/dist/index.html +7 -9
  103. package/dist/mini-chat.html +6 -8
  104. package/dist/mobile.html +6 -8
  105. package/package.json +1 -1
  106. package/server/index.js +3 -1
  107. package/server/lib/fs/DOCUMENTATION.md +1 -1
  108. package/server/lib/fs/routes.js +1 -50
  109. package/server/lib/git/DOCUMENTATION.md +18 -11
  110. package/server/lib/git/index.js +8 -3
  111. package/server/lib/git/routes.js +0 -129
  112. package/server/lib/git/service.js +40 -152
  113. package/server/lib/git/service.test.js +42 -18
  114. package/server/lib/github/DOCUMENTATION.md +271 -0
  115. package/server/lib/github/cache.js +164 -0
  116. package/server/lib/github/checks.js +230 -0
  117. package/server/lib/github/client.js +305 -0
  118. package/server/lib/github/context.js +177 -0
  119. package/server/lib/github/contracts.test.js +235 -0
  120. package/server/lib/github/correctness.test.js +356 -0
  121. package/server/lib/github/credential.js +46 -0
  122. package/server/lib/github/errors.js +151 -0
  123. package/server/lib/github/gh-cli.js +336 -0
  124. package/server/lib/github/index.js +27 -0
  125. package/server/lib/github/issues.js +495 -0
  126. package/server/lib/github/pulls.js +699 -0
  127. package/server/lib/github/repo-scope.js +688 -0
  128. package/server/lib/github/routes.js +599 -0
  129. package/server/lib/github/security.test.js +275 -0
  130. package/server/lib/github/templates.js +153 -0
  131. package/server/lib/package-manager-detect-child.js +12 -0
  132. package/server/lib/package-manager.js +366 -92
  133. package/server/lib/package-manager.test.js +109 -0
  134. package/server/lib/pi/routes-extension-events.test.js +268 -4
  135. package/server/lib/pi/routes.js +109 -25
  136. package/server/lib/pi/routes.test.js +118 -0
  137. package/server/lib/pi/session-daemon/DOCUMENTATION.md +5 -3
  138. package/server/lib/pi/session-daemon/extension-bridge-draft.test.js +222 -0
  139. package/server/lib/pi/session-daemon/extension-bridge.js +415 -42
  140. package/server/lib/pi/session-daemon/extension-name.js +87 -0
  141. package/server/lib/pi/session-daemon/extension-name.test.js +143 -0
  142. package/server/lib/pi/session-daemon/extension-theme.js +142 -0
  143. package/server/lib/pi/session-daemon/extension-theme.test.js +117 -0
  144. package/server/lib/pi/session-daemon/extension-tool-render.js +365 -0
  145. package/server/lib/pi/session-daemon/extension-tool-render.test.js +607 -0
  146. package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +322 -2
  147. package/server/lib/pi/session-daemon/session-daemon-list-live.test.js +244 -0
  148. package/server/lib/pi/session-daemon/session-daemon.js +204 -33
  149. package/server/lib/pi/session-daemon/session-daemon.test.js +218 -0
  150. package/server/lib/pi/ui-settings-store.js +1 -1
  151. package/server/lib/static-cache-control.js +18 -0
  152. package/server/lib/static-cache-control.test.js +25 -0
  153. package/server/lib/workspace/host.js +2 -0
  154. package/dist/assets/DiagramView-CXjieF51.js +0 -1
  155. package/dist/assets/FileSaveConflictDialog-a-HOCgyP.js +0 -3
  156. package/dist/assets/FilesView-Dcd9ltOX.js +0 -6
  157. package/dist/assets/GitView-DF2nsuSA.js +0 -8
  158. package/dist/assets/JsonTreeView-BRU2mRTd.js +0 -1
  159. package/dist/assets/PatchDiff-kSTpjhu6.js +0 -1
  160. package/dist/assets/SessionSwitcherContent-BsXDFt24.js +0 -1
  161. package/dist/assets/SessionSwitcherDropdown-D8fSObHr.js +0 -2
  162. package/dist/assets/SessionUnreadDot-BpsHyrri.js +0 -1
  163. package/dist/assets/SettingsView-OEl7QmXC.js +0 -6
  164. package/dist/assets/SettingsWindow-BMBCj_L_.js +0 -1
  165. package/dist/assets/ToolOutputDialog-KOVdmTqm.js +0 -8
  166. package/dist/assets/ToolPartDiffPreview-B9xuVvkm.js +0 -1
  167. package/dist/assets/Virtualizer-BSHVMKgK.js +0 -1
  168. package/dist/assets/collapsible-BH1vXEAI.js +0 -1
  169. package/dist/assets/computeVirtualFileMetrics-yHZbtf5H.js +0 -3
  170. package/dist/assets/gitStatusPredicates-CpGQLvMK.js +0 -134
  171. package/dist/assets/index-5fyXnZFi.css +0 -1
  172. package/dist/assets/index-C-sV_9sb.js +0 -8
  173. package/dist/assets/index-D_FGGnQQ.js +0 -1
  174. package/dist/assets/isDiffPlainText-BNyusJZz.js +0 -1
  175. package/dist/assets/isFilePlainText-CMAUe7qD.js +0 -1
  176. package/dist/assets/main-BMLgZ5yn.js +0 -2
  177. package/dist/assets/main-DNq1n9F_.js +0 -135
  178. package/dist/assets/markdownCore-CZWcaNr2.js +0 -3
  179. package/dist/assets/miniChat-B2AgUZqL.js +0 -2
  180. package/dist/assets/mobile-BsGiRUUg.js +0 -2
  181. package/dist/assets/permissionStore-iKN1K2_x.js +0 -1
  182. package/dist/assets/renderElectronMiniChatApp-UV9dnnbf.js +0 -2
  183. package/dist/assets/renderMobileApp-BMifduGA.js +0 -11
  184. package/dist/assets/runtimeEndpointReset-CkvC02dQ.js +0 -53
  185. package/dist/assets/useAppFontEffects-CclUs9KY.js +0 -6722
  186. package/dist/assets/usePushVisibilityBeacon-aDmGZrTW.js +0 -10
  187. package/dist/assets/useSwitcherItems-BZKyNjhp.js +0 -1
  188. package/dist/assets/vendor-aria-hidden-DvXkyWUv.js +0 -1
  189. package/dist/assets/vendor-base-ui-DXSHfszQ.js +0 -1
  190. package/dist/assets/vendor-class-variance-authority-5VPnzWs2.js +0 -1
  191. package/dist/assets/vendor-cmdk-zXx6sGnS.js +0 -1
  192. package/dist/assets/vendor-codemirror-autocomplete-wd6iRebq.js +0 -1
  193. package/dist/assets/vendor-codemirror-commands-CNlncqrr.js +0 -1
  194. package/dist/assets/vendor-codemirror-lang-angular-DU_4KiiW.js +0 -1
  195. package/dist/assets/vendor-codemirror-lang-cpp-CmIT9Z5_.js +0 -1
  196. package/dist/assets/vendor-codemirror-lang-css-djiuoTi8.js +0 -1
  197. package/dist/assets/vendor-codemirror-lang-go-COZSwZYW.js +0 -7
  198. package/dist/assets/vendor-codemirror-lang-html-CKHqhW5R.js +0 -1
  199. package/dist/assets/vendor-codemirror-lang-java-CNMP5hyC.js +0 -1
  200. package/dist/assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js +0 -13
  201. package/dist/assets/vendor-codemirror-lang-jinja-DaKn_b1k.js +0 -1
  202. package/dist/assets/vendor-codemirror-lang-json-CZ07HmNC.js +0 -1
  203. package/dist/assets/vendor-codemirror-lang-less-wJdQiDBf.js +0 -1
  204. package/dist/assets/vendor-codemirror-lang-liquid-0z48Roi8.js +0 -1
  205. package/dist/assets/vendor-codemirror-lang-markdown-DtcZDGqe.js +0 -1
  206. package/dist/assets/vendor-codemirror-lang-php-W8plS-JQ.js +0 -1
  207. package/dist/assets/vendor-codemirror-lang-python-DzzokVau.js +0 -3
  208. package/dist/assets/vendor-codemirror-lang-rust-C4ulBVpf.js +0 -1
  209. package/dist/assets/vendor-codemirror-lang-sass-BkZJYEwS.js +0 -1
  210. package/dist/assets/vendor-codemirror-lang-vue-DiBPljCc.js +0 -1
  211. package/dist/assets/vendor-codemirror-lang-wast-DoABsogh.js +0 -1
  212. package/dist/assets/vendor-codemirror-lang-xml-BhLJhOCH.js +0 -1
  213. package/dist/assets/vendor-codemirror-lang-yaml-D95i1Y5R.js +0 -1
  214. package/dist/assets/vendor-codemirror-language-BByA_dGF.js +0 -3
  215. package/dist/assets/vendor-codemirror-language-data-C6LBD7qA.js +0 -2
  216. package/dist/assets/vendor-codemirror-search-BV44140v.js +0 -2
  217. package/dist/assets/vendor-codemirror-state-CNWM3Q8V.js +0 -5
  218. package/dist/assets/vendor-codemirror-view-Ct4T37Ue.js +0 -4
  219. package/dist/assets/vendor-crelt-C8TCjufn.js +0 -1
  220. package/dist/assets/vendor-detect-node-es-l0sNRNKZ.js +0 -1
  221. package/dist/assets/vendor-dnd-kit-accessibility-DZKKhs9S.js +0 -1
  222. package/dist/assets/vendor-dnd-kit-core-C9qcAm_1.js +0 -5
  223. package/dist/assets/vendor-dnd-kit-sortable-D8ozj8M-.js +0 -1
  224. package/dist/assets/vendor-dnd-kit-utilities-DTY1C6ST.js +0 -1
  225. package/dist/assets/vendor-floating-ui-core-CXmKXOXc.js +0 -1
  226. package/dist/assets/vendor-floating-ui-dom-WyXykhNi.js +0 -1
  227. package/dist/assets/vendor-floating-ui-react-dom-BZOGXAGe.js +0 -1
  228. package/dist/assets/vendor-floating-ui-utils-BzXdqYpP.js +0 -1
  229. package/dist/assets/vendor-framer-motion-CfplGuM0.js +0 -1
  230. package/dist/assets/vendor-get-nonce-C-Z93AgS.js +0 -1
  231. package/dist/assets/vendor-lezer-common-B3-cUCR_.js +0 -1
  232. package/dist/assets/vendor-lezer-cpp-BleAU9o-.js +0 -1
  233. package/dist/assets/vendor-lezer-css-C5xB6jxd.js +0 -1
  234. package/dist/assets/vendor-lezer-go-CXK1UKk8.js +0 -1
  235. package/dist/assets/vendor-lezer-highlight-CDMHUZ74.js +0 -1
  236. package/dist/assets/vendor-lezer-html-C0I1p52t.js +0 -1
  237. package/dist/assets/vendor-lezer-java-D_zzj-NV.js +0 -1
  238. package/dist/assets/vendor-lezer-javascript-D7Tj24ot.js +0 -1
  239. package/dist/assets/vendor-lezer-json-Iaex0UN-.js +0 -1
  240. package/dist/assets/vendor-lezer-lr-bhwg1HMg.js +0 -1
  241. package/dist/assets/vendor-lezer-php-_DHrbsZG.js +0 -1
  242. package/dist/assets/vendor-lezer-python-CvuFxeZl.js +0 -1
  243. package/dist/assets/vendor-lezer-rust-Lqgd5SAo.js +0 -1
  244. package/dist/assets/vendor-lezer-sass-Dnm2lY4t.js +0 -1
  245. package/dist/assets/vendor-lezer-xml-hUDuAyS5.js +0 -1
  246. package/dist/assets/vendor-lezer-yaml-BNIl6S_O.js +0 -1
  247. package/dist/assets/vendor-marijn-find-cluster-break-DXwl3gUT.js +0 -1
  248. package/dist/assets/vendor-motion-dom-DhJ-sYS5.js +0 -1
  249. package/dist/assets/vendor-motion-l0sNRNKZ.js +0 -1
  250. package/dist/assets/vendor-motion-utils-CKEGc_YG.js +0 -1
  251. package/dist/assets/vendor-radix-ui-primitive-Dc_FVRD7.js +0 -1
  252. package/dist/assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js +0 -1
  253. package/dist/assets/vendor-radix-ui-react-context-CFsX-AUC.js +0 -1
  254. package/dist/assets/vendor-radix-ui-react-dialog-D2yhEu2p.js +0 -5
  255. package/dist/assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js +0 -1
  256. package/dist/assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js +0 -1
  257. package/dist/assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js +0 -1
  258. package/dist/assets/vendor-radix-ui-react-id-D2kS9K1j.js +0 -1
  259. package/dist/assets/vendor-radix-ui-react-portal-YgCRIyi7.js +0 -1
  260. package/dist/assets/vendor-radix-ui-react-presence-D432pCMB.js +0 -1
  261. package/dist/assets/vendor-radix-ui-react-primitive-DkH8dMOR.js +0 -1
  262. package/dist/assets/vendor-radix-ui-react-slot-BIDFZX0-.js +0 -1
  263. package/dist/assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js +0 -1
  264. package/dist/assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js +0 -1
  265. package/dist/assets/vendor-radix-ui-react-use-effect-event-D94va83M.js +0 -1
  266. package/dist/assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js +0 -1
  267. package/dist/assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js +0 -1
  268. package/dist/assets/vendor-react-B5Z1Mdn3.js +0 -9
  269. package/dist/assets/vendor-react-remove-scroll-bar-CSAHp1YF.js +0 -38
  270. package/dist/assets/vendor-react-remove-scroll-vR1dy1aP.js +0 -4
  271. package/dist/assets/vendor-react-style-singleton-Ctw6HnYx.js +0 -1
  272. package/dist/assets/vendor-reselect-l0sNRNKZ.js +0 -1
  273. package/dist/assets/vendor-scheduler-7OC5HNn7.js +0 -1
  274. package/dist/assets/vendor-simplewebauthn-browser-VDA66rT_.js +0 -2
  275. package/dist/assets/vendor-sonner-BDtm25td.js +0 -1
  276. package/dist/assets/vendor-style-mod-NZ5MEPvj.js +0 -3
  277. package/dist/assets/vendor-tanstack-react-virtual-2skouoFw.js +0 -1
  278. package/dist/assets/vendor-tanstack-virtual-core-Dubg10g5.js +0 -1
  279. package/dist/assets/vendor-tslib-De9GV7Vy.js +0 -1
  280. package/dist/assets/vendor-use-callback-ref-CVVuCyLj.js +0 -1
  281. package/dist/assets/vendor-use-sidecar-Vv4V8Nd1.js +0 -1
  282. package/dist/assets/vendor-use-sync-external-store-D0AXkdQC.js +0 -1
  283. package/dist/assets/vendor-w3c-keyname-Vcq4gwWv.js +0 -1
  284. package/dist/assets/vendor-zustand-GVb4H8HE.js +0 -6
  285. package/server/lib/git/credentials.js +0 -41
  286. package/server/lib/git/identity-storage.js +0 -122
  287. /package/dist/assets/{vendor-katex-CNckGUMB.js → vendor-katex-DZG0Ov6p.js} +0 -0
  288. /package/dist/assets/{vendor-katex-Cp579UoJ.css → vendor-katex-css-Cp579UoJ.css} +0 -0
  289. /package/dist/assets/{vendor-xterm-xterm-CrXqRur4.js → vendor-xterm-xterm-B-qIQCd3.js} +0 -0
  290. /package/dist/assets/{vendor-xterm-xterm-DDGTF8rc.css → vendor-xterm-xterm-css-DDGTF8rc.css} +0 -0
@@ -0,0 +1,699 @@
1
+ /** Pull request reads and actions. See DOCUMENTATION.md (§5.2 caching, routes). */
2
+
3
+ import { createTtlCache, nextCursor, readWithStaleFallback, repoCachePrefix, repoInvalidatePredicate } from './cache.js';
4
+ import { failed, inputError, toSectionError } from './errors.js';
5
+ import {
6
+ FALLBACK_CAPABILITIES,
7
+ buildViewerContextLoader,
8
+ isValidIssueNumber,
9
+ parseEnumParam,
10
+ parsePerPage,
11
+ } from './repo-scope.js';
12
+
13
+ /** Full media type: responses include `body_html` (server-sanitized,
14
+ * signed image URLs) alongside `body`. Detail/comment reads use this;
15
+ * list summaries stay body-free. Signed image URLs expire (~5 min), far
16
+ * above the 15 s detail TTL and uncached comment reads (see DOCUMENTATION.md). */
17
+ export const FULL_ACCEPT = 'application/vnd.github.full+json';
18
+
19
+ export const LIST_TTL_MS = 30_000;
20
+ export const DETAIL_TTL_MS = 15_000;
21
+ export const SHORT_TTL_MS = 15_000;
22
+ const PER_PAGE = 30;
23
+
24
+ export const mapUser = (user) => (user && typeof user === 'object' ? {
25
+ login: user.login || null,
26
+ id: typeof user.id === 'number' ? user.id : undefined,
27
+ avatarUrl: user.avatar_url || null,
28
+ } : null);
29
+
30
+ export const mapLabel = (label) => (typeof label === 'string' ? { name: label } : { name: label.name, color: label.color });
31
+
32
+ const mapPullState = (item) => {
33
+ if (item?.merged_at) return 'merged';
34
+ return item?.state === 'closed' ? 'closed' : 'open';
35
+ };
36
+
37
+ export const mapPullSummary = (item) => ({
38
+ number: item.number,
39
+ title: item.title || '',
40
+ url: item.html_url || '',
41
+ state: mapPullState(item),
42
+ draft: item.draft === true,
43
+ base: item.base?.ref || '',
44
+ head: item.head?.ref || '',
45
+ headSha: item.head?.sha || null,
46
+ author: mapUser(item.user),
47
+ labels: (item.labels || []).map(mapLabel),
48
+ assignees: (item.assignees || []).map(mapUser),
49
+ requestedReviewers: (item.requested_reviewers || []).map(mapUser),
50
+ createdAt: item.created_at || null,
51
+ updatedAt: item.updated_at || null,
52
+ mergedAt: item.merged_at || null,
53
+ additions: typeof item.additions === 'number' ? item.additions : undefined,
54
+ deletions: typeof item.deletions === 'number' ? item.deletions : undefined,
55
+ changedFiles: typeof item.changed_files === 'number' ? item.changed_files : undefined,
56
+ comments: typeof item.comments === 'number' ? item.comments : undefined,
57
+ });
58
+
59
+ const mapReview = (item) => ({
60
+ id: item.id,
61
+ state: item.state || null,
62
+ body: typeof item.body === 'string' ? item.body : '',
63
+ bodyHtml: typeof item.body_html === 'string' ? item.body_html : null,
64
+ author: mapUser(item.user),
65
+ submittedAt: item.submitted_at || null,
66
+ commitId: item.commit_id || null,
67
+ });
68
+
69
+ export const summarizeReviews = (reviews) => {
70
+ let approvals = 0;
71
+ let changesRequested = 0;
72
+ let commented = 0;
73
+ const byUser = new Map();
74
+ for (const review of reviews) {
75
+ if (!review?.author?.login || review.state === 'PENDING') continue;
76
+ byUser.set(review.author.login, review.state);
77
+ }
78
+ for (const state of byUser.values()) {
79
+ if (state === 'APPROVED') approvals += 1;
80
+ else if (state === 'CHANGES_REQUESTED') changesRequested += 1;
81
+ else if (state === 'COMMENTED') commented += 1;
82
+ }
83
+ return {
84
+ approvals,
85
+ changesRequested,
86
+ commented,
87
+ decision: changesRequested > 0 ? 'changes-requested' : (approvals > 0 ? 'approved' : 'pending'),
88
+ };
89
+ };
90
+
91
+ const REVIEW_THREADS_QUERY = `
92
+ query PullRequestThreads($owner: String!, $repo: String!, $number: Int!) {
93
+ repository(owner: $owner, name: $repo) {
94
+ pullRequest(number: $number) {
95
+ id
96
+ reviewThreads(first: 50) {
97
+ nodes {
98
+ id
99
+ isResolved
100
+ path
101
+ line
102
+ originalLine
103
+ diffSide
104
+ comments(first: 20) {
105
+ nodes {
106
+ id
107
+ databaseId
108
+ body
109
+ bodyHTML
110
+ createdAt
111
+ updatedAt
112
+ url
113
+ path
114
+ line
115
+ originalLine
116
+ author { login avatarUrl }
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+ }`;
124
+
125
+ export const mapThread = (node) => ({
126
+ id: node.id,
127
+ resolved: node.isResolved === true,
128
+ path: node.path || null,
129
+ line: node.line ?? null,
130
+ originalLine: node.originalLine ?? null,
131
+ diffSide: node.diffSide || null,
132
+ comments: (node.comments?.nodes || []).map((comment) => ({
133
+ id: comment.databaseId ?? null,
134
+ nodeId: comment.id,
135
+ body: comment.body || '',
136
+ bodyHtml: typeof comment.bodyHTML === 'string' ? comment.bodyHTML : null,
137
+ author: comment.author ? { login: comment.author.login || null, avatarUrl: comment.author.avatarUrl || null } : null,
138
+ createdAt: comment.createdAt || null,
139
+ updatedAt: comment.updatedAt || null,
140
+ url: comment.url || '',
141
+ path: comment.path || null,
142
+ line: comment.line ?? null,
143
+ })),
144
+ });
145
+
146
+ export const createPullsService = ({
147
+ client,
148
+ now = Date.now,
149
+ resolveViewer = null,
150
+ resolvePermission = null,
151
+ } = {}) => {
152
+ if (!client || typeof client.request !== 'function') {
153
+ throw new Error('createPullsService requires client');
154
+ }
155
+ const listCache = createTtlCache({ ttlMs: LIST_TTL_MS, maxEntries: 300, now });
156
+ const detailCache = createTtlCache({ ttlMs: DETAIL_TTL_MS, maxEntries: 300, now });
157
+ const filesCache = createTtlCache({ ttlMs: SHORT_TTL_MS, maxEntries: 300, now });
158
+ const commentsCache = createTtlCache({ ttlMs: SHORT_TTL_MS, maxEntries: 300, now });
159
+
160
+ const repoKey = (credential, repo) => repoCachePrefix(credential, repo);
161
+
162
+ const loadViewerContext = buildViewerContextLoader({
163
+ getPermissions: (cred, ref) => client.request({
164
+ credential: cred, host: ref.host, method: 'GET',
165
+ path: `/repos/${ref.owner}/${ref.repo}`,
166
+ operation: 'repository lookup',
167
+ }).then((response) => ({ permissions: response.body?.permissions ?? null })),
168
+ resolveViewer,
169
+ resolvePermission,
170
+ });
171
+
172
+ const buildSearchQuery = ({ repo, state, filter, q, viewerLogin }) => {
173
+ const terms = [`repo:${repo.owner}/${repo.repo}`, 'type:pr'];
174
+ if (state === 'open' || state === 'closed' || state === 'merged') {
175
+ terms.push(state === 'merged' ? 'is:merged' : `state:${state}`);
176
+ }
177
+ if (filter === 'mine' && viewerLogin) terms.push(`author:${viewerLogin}`);
178
+ else if (filter === 'review' && viewerLogin) terms.push(`review-requested:${viewerLogin}`);
179
+ else if (filter === 'assigned' && viewerLogin) terms.push(`assignee:${viewerLogin}`);
180
+ if (q) terms.push(q);
181
+ return terms.join(' ');
182
+ };
183
+
184
+ const listPulls = async (credential, repo, { state = 'open', filter = 'all', q = '', cursor = null, sort = 'updated', perPage = PER_PAGE } = {}) => {
185
+ const page = cursor ? Number.parseInt(String(cursor), 10) : 1;
186
+ if (!Number.isInteger(page) || page < 1 || page > 100) {
187
+ throw inputError('Invalid pagination cursor.');
188
+ }
189
+ const validState = parseEnumParam(state, ['open', 'closed', 'merged', 'all'], 'open', { name: 'state' });
190
+ const validFilter = parseEnumParam(filter, ['all', 'mine', 'review', 'assigned'], 'all', { name: 'filter' });
191
+ const validSort = parseEnumParam(sort, ['updated', 'created'], 'updated', { name: 'sort' });
192
+ const effectivePerPage = parsePerPage(perPage);
193
+ if (typeof q === 'string' && q.length > 500) {
194
+ throw inputError('Search query is too long.');
195
+ }
196
+ const useSearch = Boolean((typeof q === 'string' && q.trim()) || (validFilter && validFilter !== 'all'));
197
+ const viewerLogin = useSearch && resolveViewer ? await resolveViewer(credential) : null;
198
+ const key = `${repoKey(credential, repo)}:pulls:${validState}:${validFilter}:${q}:${page}:${validSort}:${effectivePerPage}:${useSearch ? 'search' : 'list'}`;
199
+ const load = async () => {
200
+ if (!useSearch) {
201
+ const restState = validState === 'merged' ? 'closed' : validState;
202
+ const response = await client.request({
203
+ credential,
204
+ host: repo.host,
205
+ method: 'GET',
206
+ path: `/repos/${repo.owner}/${repo.repo}/pulls`,
207
+ query: {
208
+ state: restState,
209
+ sort: validSort,
210
+ direction: 'desc',
211
+ per_page: effectivePerPage,
212
+ page,
213
+ },
214
+ operation: 'pull request list',
215
+ });
216
+ const raw = Array.isArray(response.body) ? response.body : [];
217
+ let items = raw.map(mapPullSummary);
218
+ if (validState === 'merged') items = items.filter((item) => item.state === 'merged');
219
+ // Cursor follows the raw page: a filtered-out page still advances.
220
+ return { items, nextCursor: nextCursor(raw, page, effectivePerPage) };
221
+ }
222
+ const response = await client.request({
223
+ credential,
224
+ host: repo.host,
225
+ method: 'GET',
226
+ path: '/search/issues',
227
+ query: {
228
+ q: buildSearchQuery({ repo, state: validState, filter: validFilter, q: (q || '').trim(), viewerLogin }),
229
+ sort: validSort,
230
+ order: 'desc',
231
+ per_page: effectivePerPage,
232
+ page,
233
+ },
234
+ operation: 'pull request search',
235
+ });
236
+ const items = ((response.body?.items || []).map((item) => ({
237
+ number: item.number,
238
+ title: item.title || '',
239
+ url: item.html_url || '',
240
+ state: item.pull_request?.merged_at ? 'merged' : (item.state === 'closed' ? 'closed' : 'open'),
241
+ draft: item.draft === true,
242
+ base: '',
243
+ head: '',
244
+ headSha: null,
245
+ author: mapUser(item.user),
246
+ labels: (item.labels || []).map(mapLabel),
247
+ assignees: (item.assignees || []).map(mapUser),
248
+ requestedReviewers: [],
249
+ createdAt: item.created_at || null,
250
+ updatedAt: item.updated_at || null,
251
+ mergedAt: item.pull_request?.merged_at || item.merged_at || null,
252
+ })));
253
+ return { items, nextCursor: nextCursor(items, page, effectivePerPage) };
254
+ };
255
+ const { value, fetchedAt, stale } = await readWithStaleFallback(listCache, key, load);
256
+ return { repo: { ...repo }, ...value, fetchedAt, ...(stale ? { stale: true } : {}) };
257
+ };
258
+
259
+ const getPull = async (credential, repo, number) => {
260
+ if (!isValidIssueNumber(number)) throw inputError('Invalid pull request number.');
261
+ const key = `${repoKey(credential, repo)}:pull:${number}`;
262
+ const load = async () => {
263
+ // Nothing below depends on the detail body, so every read runs in
264
+ // parallel; only a detail failure fails the whole load.
265
+ const [detailResponse, reviewsSettled, threadsSettled, viewerContext] = await Promise.all([
266
+ client.request({
267
+ credential, host: repo.host, method: 'GET',
268
+ path: `/repos/${repo.owner}/${repo.repo}/pulls/${number}`,
269
+ accept: FULL_ACCEPT,
270
+ operation: 'pull request detail',
271
+ }),
272
+ client.request({
273
+ credential, host: repo.host, method: 'GET',
274
+ path: `/repos/${repo.owner}/${repo.repo}/pulls/${number}/reviews`,
275
+ query: { per_page: 100 },
276
+ accept: FULL_ACCEPT,
277
+ operation: 'pull request reviews',
278
+ }).then((response) => ({ ok: true, response }), (error) => ({ ok: false, error })),
279
+ client.graphql({
280
+ credential, host: repo.host, query: REVIEW_THREADS_QUERY,
281
+ variables: { owner: repo.owner, repo: repo.repo, number: Number(number) },
282
+ operation: 'review threads',
283
+ }).then((response) => ({ ok: true, response }), (error) => ({ ok: false, error })),
284
+ loadViewerContext(credential, repo).catch(() => ({
285
+ viewerPermission: { level: null, fallback: true },
286
+ capabilities: { ...FALLBACK_CAPABILITIES },
287
+ viewerLogin: null,
288
+ })),
289
+ ]);
290
+ const item = detailResponse.body || {};
291
+ const sectionErrors = {};
292
+ let reviews = [];
293
+ if (reviewsSettled.ok) {
294
+ reviews = (Array.isArray(reviewsSettled.response.body) ? reviewsSettled.response.body : []).map(mapReview);
295
+ } else {
296
+ sectionErrors.reviews = toSectionError(reviewsSettled.error);
297
+ }
298
+ let threads = [];
299
+ let nodeId = null;
300
+ if (threadsSettled.ok) {
301
+ threads = threadsSettled.response.body?.repository?.pullRequest?.reviewThreads?.nodes || [];
302
+ nodeId = threadsSettled.response.body?.repository?.pullRequest?.id || null;
303
+ } else {
304
+ sectionErrors.threads = toSectionError(threadsSettled.error);
305
+ }
306
+ return {
307
+ pr: {
308
+ ...mapPullSummary(item),
309
+ body: typeof item.body === 'string' ? item.body : '',
310
+ bodyHtml: typeof item.body_html === 'string' ? item.body_html : null,
311
+ mergeable: item.mergeable ?? null,
312
+ mergeableState: item.mergeable_state || null,
313
+ labels: (item.labels || []).map(mapLabel),
314
+ assignees: (item.assignees || []).map(mapUser),
315
+ requestedReviewers: (item.requested_reviewers || []).map(mapUser),
316
+ milestone: item.milestone ? { title: item.milestone.title, number: item.milestone.number } : null,
317
+ reviewSummary: summarizeReviews(reviews),
318
+ },
319
+ reviews,
320
+ threads: threads.map(mapThread),
321
+ nodeId,
322
+ viewerPermission: viewerContext.viewerPermission,
323
+ capabilities: viewerContext.capabilities,
324
+ viewerLogin: viewerContext.viewerLogin,
325
+ ...(Object.keys(sectionErrors).length > 0 ? { sectionErrors } : {}),
326
+ };
327
+ };
328
+ const { value, fetchedAt, stale } = await readWithStaleFallback(detailCache, key, load);
329
+ return { repo: { ...repo }, ...value, fetchedAt, ...(stale ? { stale: true } : {}) };
330
+ };
331
+
332
+ const listFiles = async (credential, repo, number, { cursor = null } = {}) => {
333
+ if (!isValidIssueNumber(number)) throw inputError('Invalid pull request number.');
334
+ const page = cursor ? Number.parseInt(String(cursor), 10) : 1;
335
+ if (!Number.isInteger(page) || page < 1 || page > 100) {
336
+ throw inputError('Invalid pagination cursor.');
337
+ }
338
+ const key = `${repoKey(credential, repo)}:files:${number}:${page}`;
339
+ const load = async () => {
340
+ const response = await client.request({
341
+ credential,
342
+ host: repo.host,
343
+ method: 'GET',
344
+ path: `/repos/${repo.owner}/${repo.repo}/pulls/${number}/files`,
345
+ query: { per_page: 100, page },
346
+ operation: 'pull request files',
347
+ });
348
+ const files = (Array.isArray(response.body) ? response.body : []).map((file) => ({
349
+ filename: file.filename,
350
+ status: file.status || null,
351
+ additions: file.additions ?? 0,
352
+ deletions: file.deletions ?? 0,
353
+ changes: file.changes ?? 0,
354
+ patch: typeof file.patch === 'string' ? file.patch : null,
355
+ }));
356
+ return { files, nextCursor: nextCursor(files, page, 100) };
357
+ };
358
+ const { value, fetchedAt, stale } = await readWithStaleFallback(filesCache, key, load);
359
+ return { repo: { ...repo }, number: Number(number), ...value, fetchedAt, ...(stale ? { stale: true } : {}) };
360
+ };
361
+
362
+ /**
363
+ * Cheapest correct head SHA for checks: one single-resource REST read.
364
+ * The checks route used to re-run the full detail fan-out (detail +
365
+ * reviews + threads + viewer) just for this SHA.
366
+ */
367
+ const getPullHeadSha = async (credential, repo, number) => {
368
+ if (!isValidIssueNumber(number)) throw inputError('Invalid pull request number.');
369
+ const response = await client.request({
370
+ credential,
371
+ host: repo.host,
372
+ method: 'GET',
373
+ path: `/repos/${repo.owner}/${repo.repo}/pulls/${number}`,
374
+ operation: 'pull request head',
375
+ });
376
+ const sha = response.body?.head?.sha;
377
+ if (typeof sha !== 'string' || !sha) {
378
+ throw failed('Pull request has no head commit to check.');
379
+ }
380
+ return sha;
381
+ };
382
+
383
+ const invalidate = (credential = null, repo = null, number = null) => {
384
+ const fingerprint = credential?.fingerprint || '';
385
+ listCache.invalidate(repoInvalidatePredicate({ fingerprint, repo }));
386
+ detailCache.invalidate(repoInvalidatePredicate({ fingerprint, repo, number, matchNumberInside: true }));
387
+ filesCache.invalidate(repoInvalidatePredicate({ fingerprint, repo, number, matchNumberInside: true }));
388
+ commentsCache.invalidate(repoInvalidatePredicate({ fingerprint, repo, number, matchNumberInside: true }));
389
+ };
390
+
391
+ const createPull = async (credential, repo, { title, head, base, body = '', draft = false }) => {
392
+ if (typeof title !== 'string' || !title.trim() || title.trim().length > 300) {
393
+ throw inputError('A pull request title is required (max 300 characters).');
394
+ }
395
+ if (typeof head !== 'string' || !head.trim() || head.length > 300) {
396
+ throw inputError('A head branch is required.');
397
+ }
398
+ if (typeof base !== 'string' || !base.trim() || base.length > 300) {
399
+ throw inputError('A base branch is required.');
400
+ }
401
+ const response = await client.request({
402
+ credential,
403
+ host: repo.host,
404
+ method: 'POST',
405
+ path: `/repos/${repo.owner}/${repo.repo}/pulls`,
406
+ body: { title: title.trim(), head: head.trim(), base: base.trim(), body: String(body || ''), draft: draft === true },
407
+ operation: 'create pull request',
408
+ });
409
+ invalidate(credential, repo);
410
+ return { repo: { ...repo }, pr: mapPullSummary(response.body || {}), fetchedAt: now() };
411
+ };
412
+
413
+ const MERGE_METHODS = { merge: 'merge', squash: 'squash', rebase: 'rebase' };
414
+
415
+ // Mutation results stay lightweight (`pr: null`): the UI ignores the
416
+ // returned detail and re-reads collections + detail after invalidating,
417
+ // so re-running the detail fan-out here only costs a duplicate fetch.
418
+ // Caches are still invalidated so the re-read observes the mutation.
419
+ const runAction = async (credential, repo, number, action, options = {}) => {
420
+ if (!isValidIssueNumber(number)) throw inputError('Invalid pull request number.');
421
+ const num = Number(number);
422
+ if (action === 'merge' || action === 'squash' || action === 'rebase') {
423
+ const response = await client.request({
424
+ credential, host: repo.host, method: 'POST',
425
+ path: `/repos/${repo.owner}/${repo.repo}/pulls/${num}/merge`,
426
+ body: { merge_method: MERGE_METHODS[action] },
427
+ operation: `${action} pull request`,
428
+ });
429
+ invalidate(credential, repo, num);
430
+ return { ok: response.body?.merged === true, action, message: response.body?.message || null, pr: null, fetchedAt: now() };
431
+ }
432
+ if (action === 'ready') {
433
+ await client.request({
434
+ credential, host: repo.host, method: 'POST',
435
+ path: `/repos/${repo.owner}/${repo.repo}/pulls/${num}/ready_for_review`,
436
+ operation: 'mark pull request ready',
437
+ });
438
+ invalidate(credential, repo, num);
439
+ return { ok: true, action, pr: null, fetchedAt: now() };
440
+ }
441
+ if (action === 'draft') {
442
+ const detail = await getPull(credential, repo, num);
443
+ if (!detail.nodeId) throw inputError('Could not resolve the pull request for draft conversion.');
444
+ await client.graphql({
445
+ credential, host: repo.host,
446
+ query: 'mutation ConvertToDraft($id: ID!) { convertPullRequestToDraft(input: { pullRequestId: $id }) { pullRequest { id isDraft } } }',
447
+ variables: { id: detail.nodeId },
448
+ operation: 'convert pull request to draft',
449
+ });
450
+ invalidate(credential, repo, num);
451
+ return { ok: true, action, pr: null, fetchedAt: now() };
452
+ }
453
+ if (action === 'close' || action === 'reopen') {
454
+ await client.request({
455
+ credential, host: repo.host, method: 'PATCH',
456
+ path: `/repos/${repo.owner}/${repo.repo}/pulls/${num}`,
457
+ body: { state: action === 'close' ? 'closed' : 'open' },
458
+ operation: `${action} pull request`,
459
+ });
460
+ invalidate(credential, repo, num);
461
+ return { ok: true, action, pr: null, fetchedAt: now() };
462
+ }
463
+ if (action === 'update-branch') {
464
+ const response = await client.request({
465
+ credential, host: repo.host, method: 'PUT',
466
+ path: `/repos/${repo.owner}/${repo.repo}/pulls/${num}/update-branch`,
467
+ body: options.expectedHeadSha ? { expected_head_sha: options.expectedHeadSha } : {},
468
+ operation: 'update pull request branch',
469
+ });
470
+ invalidate(credential, repo, num);
471
+ return { ok: true, action, message: response.body?.message || null, pr: null, fetchedAt: now() };
472
+ }
473
+ throw inputError(`Unknown pull request action: ${action}.`);
474
+ };
475
+
476
+ const updatePull = async (credential, repo, number, { title, body }) => {
477
+ if (!isValidIssueNumber(number)) throw inputError('Invalid pull request number.');
478
+ const patch = {};
479
+ if (title !== undefined) {
480
+ if (typeof title !== 'string' || !title.trim() || title.trim().length > 300) {
481
+ throw inputError('A pull request title is required (max 300 characters).');
482
+ }
483
+ patch.title = title.trim();
484
+ }
485
+ if (body !== undefined) {
486
+ if (typeof body !== 'string' || body.length > 200_000) throw inputError('Pull request body is too long.');
487
+ patch.body = body;
488
+ }
489
+ if (Object.keys(patch).length === 0) throw inputError('Nothing to update.');
490
+ await client.request({
491
+ credential, host: repo.host, method: 'PATCH',
492
+ path: `/repos/${repo.owner}/${repo.repo}/pulls/${number}`,
493
+ body: patch,
494
+ operation: 'update pull request',
495
+ });
496
+ invalidate(credential, repo, Number(number));
497
+ return { ok: true, pr: null, fetchedAt: now() };
498
+ };
499
+
500
+ const postComment = async (credential, repo, number, { body }) => {
501
+ if (!isValidIssueNumber(number)) throw inputError('Invalid pull request number.');
502
+ if (typeof body !== 'string' || !body.trim() || body.length > 200_000) {
503
+ throw inputError('A comment body is required (max 200,000 characters).');
504
+ }
505
+ const response = await client.request({
506
+ credential, host: repo.host, method: 'POST',
507
+ path: `/repos/${repo.owner}/${repo.repo}/issues/${number}/comments`,
508
+ body: { body },
509
+ accept: FULL_ACCEPT,
510
+ operation: 'comment on pull request',
511
+ });
512
+ invalidate(credential, repo, Number(number));
513
+ return { ok: true, comment: mapIssueComment(response.body || {}), fetchedAt: now() };
514
+ };
515
+
516
+ /**
517
+ * Top-level (conversation) comments on a PR through the issues comments
518
+ * API for the PR number — paginated, oldest-first pages of 100. Cached
519
+ * ~15 s so concurrent mounts coalesce; posting invalidates this number's
520
+ * entries, so a new comment is visible on the immediate re-read.
521
+ */
522
+ const listPullComments = async (credential, repo, number, { cursor = null } = {}) => {
523
+ if (!isValidIssueNumber(number)) throw inputError('Invalid pull request number.');
524
+ const page = cursor ? Number.parseInt(String(cursor), 10) : 1;
525
+ if (!Number.isInteger(page) || page < 1 || page > 100) {
526
+ throw inputError('Invalid pagination cursor.');
527
+ }
528
+ const key = `${repoKey(credential, repo)}:pull-comments:${number}:${page}`;
529
+ const load = async () => {
530
+ const response = await client.request({
531
+ credential, host: repo.host, method: 'GET',
532
+ path: `/repos/${repo.owner}/${repo.repo}/issues/${number}/comments`,
533
+ query: { per_page: 100, page },
534
+ accept: FULL_ACCEPT,
535
+ operation: 'pull request comments',
536
+ });
537
+ const comments = (Array.isArray(response.body) ? response.body : []).map(mapIssueComment);
538
+ return { comments, nextCursor: nextCursor(comments, page, 100) };
539
+ };
540
+ const { value, fetchedAt, stale } = await readWithStaleFallback(commentsCache, key, load);
541
+ return { repo: { ...repo }, number: Number(number), ...value, fetchedAt, ...(stale ? { stale: true } : {}) };
542
+ };
543
+
544
+ const submitReview = async (credential, repo, number, { event, body = '', comments = [], commitId = null }) => {
545
+ if (!isValidIssueNumber(number)) throw inputError('Invalid pull request number.');
546
+ const normalizedEvent = String(event || 'comment').toUpperCase();
547
+ if (!['APPROVE', 'REQUEST_CHANGES', 'COMMENT'].includes(normalizedEvent)) {
548
+ throw inputError('Review event must be approve, request-changes, or comment.');
549
+ }
550
+ if (!Array.isArray(comments)) throw inputError('Review comments must be an array.');
551
+ if (comments.length > 50) throw inputError('Too many inline comments in one review (max 50).');
552
+ const mapped = comments.map((comment) => {
553
+ if (typeof comment?.body !== 'string' || !comment.body.trim()) throw inputError('Each inline comment needs a body.');
554
+ if (typeof comment?.path !== 'string' || !comment.path) throw inputError('Each inline comment needs a path.');
555
+ const entry = { path: comment.path, body: comment.body };
556
+ if (comment.line != null) {
557
+ const line = Number(comment.line);
558
+ if (!Number.isInteger(line) || line < 1) throw inputError('Inline comment line must be a positive integer.');
559
+ entry.line = line;
560
+ } else if (comment.position != null) {
561
+ const position = Number(comment.position);
562
+ if (!Number.isInteger(position) || position < 1) throw inputError('Inline comment position must be a positive integer.');
563
+ entry.position = position;
564
+ } else {
565
+ throw inputError('Each inline comment needs a line or position.');
566
+ }
567
+ if (comment.side) {
568
+ if (!['LEFT', 'RIGHT'].includes(String(comment.side).toUpperCase())) throw inputError('Inline comment side must be LEFT or RIGHT.');
569
+ entry.side = String(comment.side).toUpperCase();
570
+ }
571
+ if (comment.startLine != null) {
572
+ const startLine = Number(comment.startLine);
573
+ if (!Number.isInteger(startLine) || startLine < 1) throw inputError('Inline comment start line must be a positive integer.');
574
+ entry.start_line = startLine;
575
+ entry.start_side = comment.startSide ? String(comment.startSide).toUpperCase() : entry.side;
576
+ }
577
+ return entry;
578
+ });
579
+ const payload = { body: String(body || ''), event: normalizedEvent };
580
+ if (commitId) payload.commit_id = commitId;
581
+ if (mapped.length > 0) payload.comments = mapped;
582
+ const response = await client.request({
583
+ credential, host: repo.host, method: 'POST',
584
+ path: `/repos/${repo.owner}/${repo.repo}/pulls/${number}/reviews`,
585
+ body: payload,
586
+ operation: 'submit pull request review',
587
+ });
588
+ invalidate(credential, repo, Number(number));
589
+ return { ok: true, review: mapReview(response.body || {}), fetchedAt: now() };
590
+ };
591
+
592
+ const replyToThread = async (credential, repo, number, commentId, { body }) => {
593
+ if (!isValidIssueNumber(number)) throw inputError('Invalid pull request number.');
594
+ if (!isValidIssueNumber(commentId)) throw inputError('Invalid comment id.');
595
+ if (typeof body !== 'string' || !body.trim() || body.length > 200_000) {
596
+ throw inputError('A reply body is required (max 200,000 characters).');
597
+ }
598
+ const response = await client.request({
599
+ credential, host: repo.host, method: 'POST',
600
+ path: `/repos/${repo.owner}/${repo.repo}/pulls/${number}/comments/${commentId}/replies`,
601
+ body: { body },
602
+ operation: 'reply to review thread',
603
+ });
604
+ invalidate(credential, repo, Number(number));
605
+ return { ok: true, comment: mapReviewComment(response.body || {}), fetchedAt: now() };
606
+ };
607
+
608
+ const setThreadResolved = async (credential, repo, number, threadId, resolved) => {
609
+ if (!isValidIssueNumber(number)) throw inputError('Invalid pull request number.');
610
+ if (typeof threadId !== 'string' || !threadId.trim() || threadId.length > 200) {
611
+ throw inputError('A thread id is required (max 200 characters).');
612
+ }
613
+ const mutation = resolved ? 'resolveReviewThread' : 'unresolveReviewThread';
614
+ await client.graphql({
615
+ credential, host: repo.host,
616
+ query: `mutation SetThreadResolved($id: ID!) { ${mutation}(input: { threadId: $id }) { thread { id isResolved } } }`,
617
+ variables: { id: threadId },
618
+ operation: resolved ? 'resolve review thread' : 'unresolve review thread',
619
+ });
620
+ invalidate(credential, repo, Number(number));
621
+ return { ok: true, threadId, resolved, fetchedAt: now() };
622
+ };
623
+
624
+ const findPullForBranch = async (credential, repo, { branch, headOwner = null, defaultBranch = null }) => {
625
+ if (typeof branch !== 'string' || !branch.trim()) throw inputError('A branch name is required.');
626
+ const cleanBranch = branch.trim();
627
+ if (cleanBranch.length > 300) throw inputError('Branch name is too long.');
628
+ if (defaultBranch && cleanBranch === defaultBranch) {
629
+ return { repo: { ...repo }, branch: cleanBranch, pr: null, skippedDefaultBranch: true, fetchedAt: now() };
630
+ }
631
+ const owner = headOwner || repo.owner;
632
+ const openResponse = await client.request({
633
+ credential, host: repo.host, method: 'GET',
634
+ path: `/repos/${repo.owner}/${repo.repo}/pulls`,
635
+ query: { head: `${owner}:${cleanBranch}`, state: 'open', per_page: 5 },
636
+ operation: 'find pull request for branch',
637
+ });
638
+ const openItems = Array.isArray(openResponse.body) ? openResponse.body : [];
639
+ if (openItems.length > 0) {
640
+ const summary = mapPullSummary(openItems[0]);
641
+ return { repo: { ...repo }, branch: cleanBranch, pr: summary, fetchedAt: now() };
642
+ }
643
+ const closedResponse = await client.request({
644
+ credential, host: repo.host, method: 'GET',
645
+ path: `/repos/${repo.owner}/${repo.repo}/pulls`,
646
+ query: { head: `${owner}:${cleanBranch}`, state: 'closed', per_page: 5, sort: 'updated', direction: 'desc' },
647
+ operation: 'find pull request for branch',
648
+ });
649
+ const closedItems = Array.isArray(closedResponse.body) ? closedResponse.body : [];
650
+ return {
651
+ repo: { ...repo },
652
+ branch: cleanBranch,
653
+ pr: closedItems.length > 0 ? mapPullSummary(closedItems[0]) : null,
654
+ fetchedAt: now(),
655
+ };
656
+ };
657
+
658
+ return {
659
+ listPulls,
660
+ getPull,
661
+ listPullComments,
662
+ listFiles,
663
+ getPullHeadSha,
664
+ createPull,
665
+ runAction,
666
+ updatePull,
667
+ postComment,
668
+ submitReview,
669
+ replyToThread,
670
+ setThreadResolved,
671
+ findPullForBranch,
672
+ invalidate,
673
+ mapPullSummary,
674
+ summarizeReviews,
675
+ };
676
+ };
677
+
678
+ export const mapIssueComment = (item) => ({
679
+ id: item.id,
680
+ body: typeof item.body === 'string' ? item.body : '',
681
+ bodyHtml: typeof item.body_html === 'string' ? item.body_html : null,
682
+ author: mapUser(item.user),
683
+ createdAt: item.created_at || null,
684
+ updatedAt: item.updated_at || null,
685
+ url: item.html_url || '',
686
+ });
687
+
688
+ export const mapReviewComment = (item) => ({
689
+ id: item.id,
690
+ body: typeof item.body === 'string' ? item.body : '',
691
+ bodyHtml: typeof item.body_html === 'string' ? item.body_html : null,
692
+ author: mapUser(item.user),
693
+ path: item.path || null,
694
+ line: item.line ?? null,
695
+ originalLine: item.original_line ?? null,
696
+ createdAt: item.created_at || null,
697
+ updatedAt: item.updated_at || null,
698
+ url: item.html_url || '',
699
+ });