diffing 0.10.0 → 0.10.2

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 (152) hide show
  1. package/dist/{cli-agent-CLrK54k2.mjs → cli-agent-CV0k1pXp.mjs} +10 -8
  2. package/dist/cli-gh-C2LAp12S.mjs +313 -0
  3. package/dist/cli.mjs +3 -3
  4. package/dist/client/assets/{angular-html-DdAR2u-k.js → angular-html-CV0Ak818.js} +1 -1
  5. package/dist/client/assets/{angular-ts-Dz_vWKSu.js → angular-ts-2e8zQ7to.js} +1 -1
  6. package/dist/client/assets/{apl-BJ5QXrIk.js → apl-ByVy2dfo.js} +1 -1
  7. package/dist/client/assets/{arc-D9erSW6x.js → arc--R8kldOB.js} +1 -1
  8. package/dist/client/assets/{architectureDiagram-3BPJPVTR-CCQWZLXR.js → architectureDiagram-3BPJPVTR-BWbm1lrV.js} +1 -1
  9. package/dist/client/assets/{astro-BQAej5a5.js → astro-CE7ySGnq.js} +1 -1
  10. package/dist/client/assets/{blade-DkAmuwDx.js → blade-PJJaH6RK.js} +1 -1
  11. package/dist/client/assets/{blockDiagram-GPEHLZMM-vwjxNybI.js → blockDiagram-GPEHLZMM-BdfBhnvZ.js} +1 -1
  12. package/dist/client/assets/{c-DG5p-ChJ.js → c-BhDzEkUq.js} +1 -1
  13. package/dist/client/assets/{c4Diagram-AAUBKEIU-DJ_hVlh4.js → c4Diagram-AAUBKEIU-Bu_tfvPY.js} +1 -1
  14. package/dist/client/assets/channel-DSEnsd3l.js +1 -0
  15. package/dist/client/assets/{chunk-2J33WTMH-CiLowxCo.js → chunk-2J33WTMH-CTGsTtve.js} +1 -1
  16. package/dist/client/assets/{chunk-3OPIFGDE-H3jjMR5Y.js → chunk-3OPIFGDE-BODO_5hx.js} +1 -1
  17. package/dist/client/assets/{chunk-4BX2VUAB-Dk0dk4n5.js → chunk-4BX2VUAB-BTsyFV0Y.js} +1 -1
  18. package/dist/client/assets/{chunk-55IACEB6-nbLiUMJS.js → chunk-55IACEB6-DnrCm6LC.js} +1 -1
  19. package/dist/client/assets/{chunk-5ZQYHXKU-DZ8RgHg8.js → chunk-5ZQYHXKU-DBjF0sdg.js} +1 -1
  20. package/dist/client/assets/{chunk-727SXJPM-DDe5dqJV.js → chunk-727SXJPM-Do27Z5ji.js} +1 -1
  21. package/dist/client/assets/{chunk-AQP2D5EJ-DmpNclOr.js → chunk-AQP2D5EJ-CTnpneGA.js} +1 -1
  22. package/dist/client/assets/{chunk-BSJP7CBP-BKQKvtIj.js → chunk-BSJP7CBP-Kr0_rIcG.js} +1 -1
  23. package/dist/client/assets/{chunk-CSCIHK7Q-D27t4cyv.js → chunk-CSCIHK7Q-vYCYu98G.js} +1 -1
  24. package/dist/client/assets/{chunk-FMBD7UC4-Bu3LA663.js → chunk-FMBD7UC4-D325zkwE.js} +1 -1
  25. package/dist/client/assets/{chunk-KSCS5N6A-Ed5HNXRW.js → chunk-KSCS5N6A-Byf7HmWv.js} +1 -1
  26. package/dist/client/assets/{chunk-L5ZTLDWV-DLjJZgf8.js → chunk-L5ZTLDWV-D6bS5hm3.js} +1 -1
  27. package/dist/client/assets/{chunk-LZXEDZCA-B-cs89SM.js → chunk-LZXEDZCA-BMGYcU-n.js} +2 -2
  28. package/dist/client/assets/{chunk-ND2GUHAM-D_kPSuUA.js → chunk-ND2GUHAM-xfJDzv5I.js} +1 -1
  29. package/dist/client/assets/{chunk-NZK2D7GU-D1u3pjq-.js → chunk-NZK2D7GU-DY1HNoUO.js} +1 -1
  30. package/dist/client/assets/{chunk-O5CBEL6O-Mt0cnPSf.js → chunk-O5CBEL6O-BFgywBQV.js} +1 -1
  31. package/dist/client/assets/chunk-QZHKN3VN-wL51hu-L.js +1 -0
  32. package/dist/client/assets/chunk-WU5MYG2G-DcSuLObv.js +1 -0
  33. package/dist/client/assets/{chunk-XPW4576I-Bt8a8x28.js → chunk-XPW4576I-CCOlY0K5.js} +1 -1
  34. package/dist/client/assets/classDiagram-4FO5ZUOK-Cd9P7jo-.js +1 -0
  35. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-_8XVmWNY.js +1 -0
  36. package/dist/client/assets/{cobol-Daidj_5Y.js → cobol-D5uvQocP.js} +1 -1
  37. package/dist/client/assets/{coffee-DUMdB2Cr.js → coffee-DoE1_DMC.js} +1 -1
  38. package/dist/client/assets/{cose-bilkent-S5V4N54A-DVUDLXie.js → cose-bilkent-S5V4N54A-BffMlb0t.js} +1 -1
  39. package/dist/client/assets/{cpp-C2FeX1Mc.js → cpp-CxMs3g8q.js} +1 -1
  40. package/dist/client/assets/{crystal-D4yb9blJ.js → crystal-Ck_Sab8H.js} +1 -1
  41. package/dist/client/assets/{css-B5cr0U9F.js → css-Bx3zqeyw.js} +1 -1
  42. package/dist/client/assets/{dagre-BM42HDAG-DdZWb-Ee.js → dagre-BM42HDAG-DuK7JkP6.js} +1 -1
  43. package/dist/client/assets/{diagram-2AECGRRQ-C9DOZt92.js → diagram-2AECGRRQ-DW9W2wY6.js} +1 -1
  44. package/dist/client/assets/{diagram-5GNKFQAL-Bbc07UKr.js → diagram-5GNKFQAL-CfmdY-KT.js} +1 -1
  45. package/dist/client/assets/{diagram-KO2AKTUF-C-lUzY3m.js → diagram-KO2AKTUF-C3W0AVns.js} +1 -1
  46. package/dist/client/assets/{diagram-LMA3HP47-D-OjEFhp.js → diagram-LMA3HP47-Jxoj1EBH.js} +1 -1
  47. package/dist/client/assets/{diagram-OG6HWLK6-BjtWGvrf.js → diagram-OG6HWLK6-DKZXYFSu.js} +1 -1
  48. package/dist/client/assets/{dist-BXZygPdX.js → dist-Cxgi_w93.js} +1 -1
  49. package/dist/client/assets/{edge-RCQWcWNp.js → edge-D7XVJcl7.js} +1 -1
  50. package/dist/client/assets/{elixir-DwKyVg2X.js → elixir-DLQjwJ9Q.js} +1 -1
  51. package/dist/client/assets/{elm-DjR33IVs.js → elm-CP5Ox5XO.js} +1 -1
  52. package/dist/client/assets/{erDiagram-TEJ5UH35-C5T4ywLG.js → erDiagram-TEJ5UH35-BGd46oGi.js} +1 -1
  53. package/dist/client/assets/{erb-BnhUH1Hk.js → erb-C97aW-va.js} +1 -1
  54. package/dist/client/assets/{flowDiagram-I6XJVG4X-BJmjm7Kx.js → flowDiagram-I6XJVG4X-D6MFCwKy.js} +1 -1
  55. package/dist/client/assets/{ganttDiagram-6RSMTGT7-DREPnzu5.js → ganttDiagram-6RSMTGT7-i1RH9KFv.js} +1 -1
  56. package/dist/client/assets/{git-rebase-DzXoSDXA.js → git-rebase-B4iN-h71.js} +1 -1
  57. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-DIR4G_-_.js → gitGraphDiagram-PVQCEYII-DiLnrGe6.js} +1 -1
  58. package/dist/client/assets/{glimmer-js-HKnZpCn_.js → glimmer-js-DVkEnHRb.js} +1 -1
  59. package/dist/client/assets/{glimmer-ts-DedV7rWs.js → glimmer-ts-CyUzWW2D.js} +1 -1
  60. package/dist/client/assets/{glsl-Bz-0Alp2.js → glsl-5XFOCOCu.js} +1 -1
  61. package/dist/client/assets/{graphql-DSKkDYCD.js → graphql-IoOZHuWD.js} +1 -1
  62. package/dist/client/assets/{hack-CnaHZm8k.js → hack-BUQ8LqBu.js} +1 -1
  63. package/dist/client/assets/{haml-huGFYKlj.js → haml-BIbv0YDp.js} +1 -1
  64. package/dist/client/assets/{handlebars-CKmgzfWY.js → handlebars-9QihiA8n.js} +1 -1
  65. package/dist/client/assets/{html-B9Ih_dUU.js → html-5bjcBKb2.js} +1 -1
  66. package/dist/client/assets/{html-derivative-YabD-M5d.js → html-derivative-DFAt3hvS.js} +1 -1
  67. package/dist/client/assets/{http-Bdu12JYX.js → http-4_xHs8PR.js} +1 -1
  68. package/dist/client/assets/{hurl-twZzDTNs.js → hurl-B-wi-Gx2.js} +1 -1
  69. package/dist/client/assets/{index-BktdZRWB.js → index-CHvT3DR9.js} +10 -10
  70. package/dist/client/assets/{infoDiagram-5YYISTIA-D2ty2R-i.js → infoDiagram-5YYISTIA-Dy1M2f6k.js} +1 -1
  71. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-Ccnc9xlE.js → ishikawaDiagram-YF4QCWOH-J9qG2PlR.js} +1 -1
  72. package/dist/client/assets/{java-_5trO-p9.js → java-D9isH882.js} +1 -1
  73. package/dist/client/assets/{javascript-BOQn0ikE.js → javascript-Dj8e4yT5.js} +1 -1
  74. package/dist/client/assets/{jinja-BgY-0IBz.js → jinja-Bkare_Hv.js} +1 -1
  75. package/dist/client/assets/{jison-BLNTmT1_.js → jison-DDIUNnOW.js} +1 -1
  76. package/dist/client/assets/{journeyDiagram-JHISSGLW-W7eWXlw0.js → journeyDiagram-JHISSGLW-Do4kGeyR.js} +1 -1
  77. package/dist/client/assets/{json-BLbH8rZf.js → json-Bi84FPdJ.js} +1 -1
  78. package/dist/client/assets/{jsx-CxteptsJ.js → jsx-DI-NKxp6.js} +1 -1
  79. package/dist/client/assets/{julia-B__Ncp_z.js → julia-Yhlqb4JO.js} +1 -1
  80. package/dist/client/assets/{just-DBsHUGW1.js → just-B8KISqsZ.js} +1 -1
  81. package/dist/client/assets/{kanban-definition-UN3LZRKU-Z_AFL-rd.js → kanban-definition-UN3LZRKU-BSeQxfa9.js} +1 -1
  82. package/dist/client/assets/{latex-DFF_0wxo.js → latex-CkYf4HIK.js} +1 -1
  83. package/dist/client/assets/{line-aAv8TyOs.js → line-C2Za_tgK.js} +1 -1
  84. package/dist/client/assets/{linear-BOvEZKH8.js → linear-CRm3pgdR.js} +1 -1
  85. package/dist/client/assets/{liquid-kDWCO6d7.js → liquid-y_Utf1BC.js} +1 -1
  86. package/dist/client/assets/{lua-CYTFayq-.js → lua-C4gbVDKd.js} +1 -1
  87. package/dist/client/assets/{marko-Dpmz3Pdx.js → marko-BlcQZIyX.js} +1 -1
  88. package/dist/client/assets/{mdc-BsxHyM1i.js → mdc-C6KkSPM_.js} +1 -1
  89. package/dist/client/assets/{mermaid-parser.core-D8z_CWL1.js → mermaid-parser.core-B9mHNH7g.js} +1 -1
  90. package/dist/client/assets/{mermaid.core-DNKchnly.js → mermaid.core-pkJSRcFi.js} +3 -3
  91. package/dist/client/assets/{mindmap-definition-RKZ34NQL-xQKMV4Kw.js → mindmap-definition-RKZ34NQL-BAW_jZIg.js} +1 -1
  92. package/dist/client/assets/{nginx-CcdTDme-.js → nginx-BGbv5z-H.js} +1 -1
  93. package/dist/client/assets/{nim-B5wWDskL.js → nim-BtqaozVV.js} +1 -1
  94. package/dist/client/assets/{perl-Ce2_iKLz.js → perl-BaPVFzDG.js} +1 -1
  95. package/dist/client/assets/{php-DuLCFERd.js → php-CUSmmFXP.js} +1 -1
  96. package/dist/client/assets/{pieDiagram-4H26LBE5-CBSCJnUr.js → pieDiagram-4H26LBE5-DHTW5bo3.js} +1 -1
  97. package/dist/client/assets/{pug-BfQJoQj1.js → pug-ComryLhI.js} +1 -1
  98. package/dist/client/assets/{qml-DYeovlVl.js → qml-D4-pUDzN.js} +1 -1
  99. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-uEcgb0Rm.js → quadrantDiagram-W4KKPZXB-oE0LSIIu.js} +1 -1
  100. package/dist/client/assets/{r-DgHSP56L.js → r-IEiS2KmQ.js} +1 -1
  101. package/dist/client/assets/{razor-B00x7W-i.js → razor-A3NOQ-6o.js} +1 -1
  102. package/dist/client/assets/{regexp-CmWVupmd.js → regexp-Dnh3EraB.js} +1 -1
  103. package/dist/client/assets/{requirementDiagram-4Y6WPE33-Q4yY_ALe.js → requirementDiagram-4Y6WPE33-CAnOHDxz.js} +1 -1
  104. package/dist/client/assets/{review-export-pcqDKNqx.js → review-export-D-wScR31.js} +1 -1
  105. package/dist/client/assets/{rst-B3VARbTX.js → rst-DDcT8Cwj.js} +1 -1
  106. package/dist/client/assets/{ruby-CaxKSSbT.js → ruby-BqnC7im3.js} +1 -1
  107. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-B-GLzFGa.js → sankeyDiagram-5OEKKPKP-DARazeui.js} +1 -1
  108. package/dist/client/assets/{sas-Ue0rHUIk.js → sas-BsVPIslL.js} +1 -1
  109. package/dist/client/assets/{scss-BJJ7_L6c.js → scss-Cs-F21hy.js} +1 -1
  110. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-DW0em0D_.js → sequenceDiagram-3UESZ5HK-BYAKokia.js} +1 -1
  111. package/dist/client/assets/{shellscript-C6LkZs1u.js → shellscript-CuqRpwp7.js} +1 -1
  112. package/dist/client/assets/{shellsession-CkZu1e84.js → shellsession-BT4CTJst.js} +1 -1
  113. package/dist/client/assets/{soy-CDaZV57J.js → soy-Njc_erP7.js} +1 -1
  114. package/dist/client/assets/{sql-CLfMGH4x.js → sql-C0M8bIzv.js} +1 -1
  115. package/dist/client/assets/{src-C27zxuNO.js → src-B8u-CQt1.js} +1 -1
  116. package/dist/client/assets/{stata-B0kNMHc9.js → stata-DQWLgfGE.js} +1 -1
  117. package/dist/client/assets/{stateDiagram-AJRCARHV-CrO_D3m4.js → stateDiagram-AJRCARHV-CL6IO6Yx.js} +1 -1
  118. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-CXkQIsOM.js +1 -0
  119. package/dist/client/assets/{surrealql-D9os_yZO.js → surrealql-CxnsjSMN.js} +1 -1
  120. package/dist/client/assets/{svelte-2SxVToeO.js → svelte-YiRJWdT-.js} +1 -1
  121. package/dist/client/assets/{templ-DzmZB67T.js → templ-DVHepm0I.js} +1 -1
  122. package/dist/client/assets/{tex-BMPk3nHk.js → tex-CbaeWbjN.js} +1 -1
  123. package/dist/client/assets/{timeline-definition-PNZ67QCA-C9FBevHv.js → timeline-definition-PNZ67QCA-BAKLMRXW.js} +1 -1
  124. package/dist/client/assets/{ts-tags-CG14Bplc.js → ts-tags-KadJLbnQ.js} +1 -1
  125. package/dist/client/assets/{tsx-D6NK461A.js → tsx-DgmkmSe3.js} +1 -1
  126. package/dist/client/assets/{twig-Agh0j5sD.js → twig-BG7aoIMU.js} +1 -1
  127. package/dist/client/assets/{typescript-_AkeziZ2.js → typescript-C_w_yccd.js} +1 -1
  128. package/dist/client/assets/{vennDiagram-CIIHVFJN-2H9HfhhR.js → vennDiagram-CIIHVFJN-CCRx_JXh.js} +1 -1
  129. package/dist/client/assets/{vue-C1z3QGG9.js → vue-DXnUyZR0.js} +1 -1
  130. package/dist/client/assets/{vue-html-C1RMzLZk.js → vue-html-CetUfade.js} +1 -1
  131. package/dist/client/assets/{vue-vine-oOixA6ge.js → vue-vine-CSW5RjCH.js} +1 -1
  132. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-BJxrQhTf.js → wardleyDiagram-YWT4CUSO-Buoffz1N.js} +1 -1
  133. package/dist/client/assets/{xml-okuDZ7vq.js → xml-CJgpX9jH.js} +1 -1
  134. package/dist/client/assets/{xsl-S_n3XrKb.js → xsl-BZk-xhGC.js} +1 -1
  135. package/dist/client/assets/{xychartDiagram-2RQKCTM6-BGdee7KG.js → xychartDiagram-2RQKCTM6-CEKRZKfv.js} +1 -1
  136. package/dist/client/assets/{yaml-BoX-kqX1.js → yaml-DVxl0VLy.js} +1 -1
  137. package/dist/client/index.html +1 -1
  138. package/dist/{completions-ZSKYvW06.mjs → completions-Csvfqctx.mjs} +16 -1
  139. package/dist/{doctor-CmP0u7-d.mjs → doctor-DhuZFVwO.mjs} +1 -1
  140. package/dist/{github-oCZx5aim.mjs → github-CzxbZnhh.mjs} +152 -28
  141. package/dist/github-DL7-BqhD.mjs +2 -0
  142. package/dist/{mcp-CqxXILYL.mjs → mcp-BBDdXGOZ.mjs} +212 -28
  143. package/dist/{server-CczuXSWo.mjs → server-D-gJ7owz.mjs} +947 -54
  144. package/package.json +1 -1
  145. package/dist/cli-gh-8YC1NzyM.mjs +0 -155
  146. package/dist/client/assets/channel-DmZgR6r0.js +0 -1
  147. package/dist/client/assets/chunk-QZHKN3VN-BrYnBs7h.js +0 -1
  148. package/dist/client/assets/chunk-WU5MYG2G-CdBcsQs_.js +0 -1
  149. package/dist/client/assets/classDiagram-4FO5ZUOK-CCpp3t5M.js +0 -1
  150. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-B1aV1sYb.js +0 -1
  151. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-C9KDGD7R.js +0 -1
  152. package/dist/github-BjZZcSKV.mjs +0 -2
@@ -104,13 +104,109 @@ function readGithubToken() {
104
104
  const env = process.env;
105
105
  return env.GH_TOKEN || env.GITHUB_TOKEN || env.GITHUB_API_TOKEN || null;
106
106
  }
107
+ /** True when the host is github.com (or unspecified, which we treat the same). */
108
+ function isGithubDotCom(host) {
109
+ return !host || host === "github.com";
110
+ }
111
+ /**
112
+ * `gh -R` selector: `OWNER/REPO` on github.com, `HOST/OWNER/REPO` on GHES.
113
+ * See `gh help environment` / `--repo [HOST/]OWNER/REPO`.
114
+ */
115
+ function ghRepoSelector(resolved) {
116
+ if (isGithubDotCom(resolved.host)) return `${resolved.owner}/${resolved.repo}`;
117
+ return `${resolved.host}/${resolved.owner}/${resolved.repo}`;
118
+ }
119
+ /** Extra argv for `gh api` / GraphQL when targeting a non-github.com host. */
120
+ function ghHostnameArgs(resolved) {
121
+ if (isGithubDotCom(resolved.host)) return [];
122
+ return ["--hostname", resolved.host];
123
+ }
124
+ /** REST API origin for token-based fetch (GHES uses `/api/v3`). */
125
+ function githubApiBase(host) {
126
+ if (isGithubDotCom(host)) return "https://api.github.com";
127
+ return `${(host.includes("://") ? host : `https://${host}`).replace(/\/$/, "")}/api/v3`;
128
+ }
129
+ /** Build a ResolvedPr from a persisted PR session (host optional for legacy JSON). */
130
+ function resolvedFromSession(session) {
131
+ return {
132
+ owner: session.owner,
133
+ repo: session.repo,
134
+ pullNumber: session.pullNumber,
135
+ ref: session.ref,
136
+ host: session.host
137
+ };
138
+ }
139
+ /**
140
+ * Fetch one repository file exactly as it existed at a PR base/head SHA.
141
+ * The raw media type preserves binary files while `gh` supplies the user's
142
+ * existing GitHub/GHES authentication. A missing path at that revision is a
143
+ * normal result for added/deleted files and is returned as `null`.
144
+ */
145
+ async function fetchPrFileContentViaGh(resolved, path, sha) {
146
+ const normalizedPath = path.replace(/\\/g, "/");
147
+ if (!normalizedPath || normalizedPath.startsWith("/") || normalizedPath.includes("\0") || normalizedPath.split("/").some((segment) => segment === "..")) throw new Error("Invalid repository file path");
148
+ const encodedPath = normalizedPath.split("/").map(encodeURIComponent).join("/");
149
+ const endpoint = `repos/${encodeURIComponent(resolved.owner)}/${encodeURIComponent(resolved.repo)}/contents/${encodedPath}?ref=${encodeURIComponent(sha)}`;
150
+ try {
151
+ const { stdout } = await execFileAsync("gh", [
152
+ "api",
153
+ ...ghHostnameArgs(resolved),
154
+ endpoint,
155
+ "-H",
156
+ "Accept: application/vnd.github.raw+json"
157
+ ], {
158
+ encoding: "buffer",
159
+ maxBuffer: GH_MAX_OUTPUT_BYTES,
160
+ timeout: GH_REQUEST_TIMEOUT_MS
161
+ });
162
+ return Buffer.isBuffer(stdout) ? stdout : Buffer.from(stdout);
163
+ } catch (error) {
164
+ const details = error;
165
+ const output = `${details.message}\n${details.stderr?.toString() ?? ""}\n${details.stdout?.toString() ?? ""}`;
166
+ if (/\bHTTP\s+404\b/i.test(output) || /\bnot found\b/i.test(output)) return null;
167
+ throw error;
168
+ }
169
+ }
170
+ /**
171
+ * Parse a git remote URL into `{ host, owner, repo }`.
172
+ * Supports scp-like SSH, `ssh://`, and `https://` for github.com and GHES.
173
+ */
174
+ function parseGitRemoteUrl(url) {
175
+ const trimmed = url.trim();
176
+ if (!trimmed) return null;
177
+ if (!trimmed.includes("://")) {
178
+ const scp = /^(?:[^@\s]+@)?([^:\s]+):([^/\s]+)\/([^/\s]+?)(?:\.git)?\s*$/.exec(trimmed);
179
+ if (scp) return {
180
+ host: scp[1],
181
+ owner: scp[2],
182
+ repo: scp[3]
183
+ };
184
+ }
185
+ try {
186
+ const normalized = trimmed.replace(/^git\+/, "");
187
+ const u = new URL(normalized);
188
+ const host = u.host;
189
+ const parts = u.pathname.replace(/^\/+/, "").split("/").filter(Boolean);
190
+ if (host && parts.length >= 2) {
191
+ const owner = parts[0];
192
+ const repo = parts[1].replace(/\.git$/i, "");
193
+ if (owner && repo) return {
194
+ host,
195
+ owner,
196
+ repo
197
+ };
198
+ }
199
+ } catch {}
200
+ return null;
201
+ }
107
202
  function parsePrRef(input, cwdRepo) {
108
203
  const trimmed = input.trim();
109
- const urlMatch = /^https?:\/\/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)/i.exec(trimmed);
204
+ const urlMatch = /^https?:\/\/([^/]+)\/([^/]+)\/([^/]+)\/pull\/(\d+)/i.exec(trimmed);
110
205
  if (urlMatch) return {
111
- owner: urlMatch[1],
112
- repo: urlMatch[2],
113
- pullNumber: Number(urlMatch[3]),
206
+ host: urlMatch[1],
207
+ owner: urlMatch[2],
208
+ repo: urlMatch[3],
209
+ pullNumber: Number(urlMatch[4]),
114
210
  ref: trimmed
115
211
  };
116
212
  const shorthand = /^([^/\s]+)\/([^#\s]+)#(\d+)$/.exec(trimmed);
@@ -118,21 +214,24 @@ function parsePrRef(input, cwdRepo) {
118
214
  owner: shorthand[1],
119
215
  repo: shorthand[2],
120
216
  pullNumber: Number(shorthand[3]),
121
- ref: trimmed
217
+ ref: trimmed,
218
+ host: cwdRepo?.host
122
219
  };
123
220
  const bare = /^#?(\d+)$/.exec(trimmed);
124
221
  if (bare && cwdRepo) return {
125
222
  owner: cwdRepo.owner,
126
223
  repo: cwdRepo.repo,
127
224
  pullNumber: Number(bare[1]),
128
- ref: trimmed
225
+ ref: trimmed,
226
+ host: cwdRepo.host
129
227
  };
130
228
  if (bare) throw new Error(`Cannot resolve bare PR number "${trimmed}" — run from inside the target repo, or pass a full URL or \`owner/repo#1234\`.`);
131
229
  throw new Error(`Unrecognised PR ref: ${trimmed}`);
132
230
  }
133
231
  /**
134
- * Best-effort: derive `{ owner, repo }` for the current working directory
135
- * from `git remote get-url origin`. Falls back to throwing.
232
+ * Best-effort: derive `{ host, owner, repo }` for the current working directory
233
+ * from `git remote get-url origin`, then fall back to `gh repo view` (which
234
+ * understands GHES remotes when `gh` is logged in to that host).
136
235
  */
137
236
  async function detectCwdRepo() {
138
237
  try {
@@ -141,12 +240,29 @@ async function detectCwdRepo() {
141
240
  "get-url",
142
241
  "origin"
143
242
  ], { encoding: "utf-8" });
144
- const url = stdout.trim();
145
- const m = /github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\s*$/.exec(url);
146
- if (m) return {
147
- owner: m[1],
148
- repo: m[2]
149
- };
243
+ const parsed = parseGitRemoteUrl(stdout.trim());
244
+ if (parsed) return parsed;
245
+ } catch {}
246
+ try {
247
+ const { stdout } = await execFileAsync("gh", [
248
+ "repo",
249
+ "view",
250
+ "--json",
251
+ "nameWithOwner,url"
252
+ ], { encoding: "utf-8" });
253
+ const data = JSON.parse(stdout);
254
+ if (data.url) {
255
+ const fromUrl = parseGitRemoteUrl(data.url);
256
+ if (fromUrl) return fromUrl;
257
+ }
258
+ if (data.nameWithOwner) {
259
+ const [owner, repo] = data.nameWithOwner.split("/");
260
+ if (owner && repo) return {
261
+ owner,
262
+ repo,
263
+ host: "github.com"
264
+ };
265
+ }
150
266
  } catch {}
151
267
  return null;
152
268
  }
@@ -155,7 +271,7 @@ async function detectCwdRepo() {
155
271
  * Throws with a user-readable message on failure.
156
272
  */
157
273
  async function fetchPrMetadataViaGh(resolved) {
158
- const args = ["-R", `${resolved.owner}/${resolved.repo}`];
274
+ const args = ["-R", ghRepoSelector(resolved)];
159
275
  let metaJson;
160
276
  try {
161
277
  const { stdout } = await execFileAsync("gh", [
@@ -218,6 +334,7 @@ async function fetchExistingReviewsViaGh(resolved) {
218
334
  try {
219
335
  const { stdout } = await execFileAsync("gh", [
220
336
  "api",
337
+ ...ghHostnameArgs(resolved),
221
338
  reviewsEndpoint,
222
339
  "--paginate"
223
340
  ], {
@@ -253,7 +370,6 @@ async function fetchExistingReviewsViaGh(resolved) {
253
370
  }
254
371
  }
255
372
  async function fetchExistingCommentsViaGh(resolved, existingReviews) {
256
- `${resolved.owner}${resolved.repo}`;
257
373
  const endpoint = `repos/${resolved.owner}/${resolved.repo}/pulls/${resolved.pullNumber}/comments`;
258
374
  const recentReviews = existingReviews ?? await fetchExistingReviewsViaGh(resolved);
259
375
  const reviewStateById = /* @__PURE__ */ new Map();
@@ -262,6 +378,7 @@ async function fetchExistingCommentsViaGh(resolved, existingReviews) {
262
378
  try {
263
379
  const { stdout } = await execFileAsync("gh", [
264
380
  "api",
381
+ ...ghHostnameArgs(resolved),
265
382
  `${endpoint}?per_page=100`,
266
383
  "--paginate"
267
384
  ], {
@@ -354,6 +471,7 @@ async function fetchReviewThreadStateViaGh(resolved) {
354
471
  const { stdout } = await execWithInput("gh", [
355
472
  "api",
356
473
  "graphql",
474
+ ...ghHostnameArgs(resolved),
357
475
  "--input",
358
476
  "-"
359
477
  ], JSON.stringify({
@@ -471,12 +589,13 @@ function stripBPrefix(path) {
471
589
  }
472
590
  async function submitViaGh(input) {
473
591
  const payload = buildReviewPayload(input);
474
- `${input.resolved.owner}${input.resolved.repo}`;
592
+ const endpoint = `repos/${input.resolved.owner}/${input.resolved.repo}/pulls/${input.resolved.pullNumber}/reviews`;
475
593
  const args = [
476
594
  "api",
595
+ ...ghHostnameArgs(input.resolved),
477
596
  "--method",
478
597
  "POST",
479
- `repos/${input.resolved.owner}/${input.resolved.repo}/pulls/${input.resolved.pullNumber}/reviews`,
598
+ endpoint,
480
599
  "-H",
481
600
  "Accept: application/vnd.github+json",
482
601
  "--input",
@@ -507,7 +626,7 @@ async function submitViaGh(input) {
507
626
  }
508
627
  async function submitViaToken(input, token) {
509
628
  const payload = buildReviewPayload(input);
510
- const url = `https://api.github.com/repos/${input.resolved.owner}/${input.resolved.repo}/pulls/${input.resolved.pullNumber}/reviews`;
629
+ const url = `${githubApiBase(input.resolved.host)}/repos/${input.resolved.owner}/${input.resolved.repo}/pulls/${input.resolved.pullNumber}/reviews`;
511
630
  try {
512
631
  const res = await fetch(url, {
513
632
  method: "POST",
@@ -551,9 +670,11 @@ async function submitViaToken(input, token) {
551
670
  async function fetchPrChecks(resolved, headSha) {
552
671
  const checks = [];
553
672
  try {
673
+ const endpoint = `repos/${resolved.owner}/${resolved.repo}/commits/${headSha}/check-runs?per_page=50`;
554
674
  const { stdout } = await execFileAsync("gh", [
555
675
  "api",
556
- `repos/${resolved.owner}/${resolved.repo}/commits/${headSha}/check-runs?per_page=50`,
676
+ ...ghHostnameArgs(resolved),
677
+ endpoint,
557
678
  "-H",
558
679
  "Accept: application/vnd.github+json"
559
680
  ], {
@@ -597,6 +718,7 @@ async function replyToPrComment(input) {
597
718
  try {
598
719
  const { stdout } = await execWithInput("gh", [
599
720
  "api",
721
+ ...ghHostnameArgs(input.resolved),
600
722
  "--method",
601
723
  "POST",
602
724
  endpoint,
@@ -638,6 +760,7 @@ async function updatePrReviewComment(input) {
638
760
  try {
639
761
  await execWithInput("gh", [
640
762
  "api",
763
+ ...ghHostnameArgs(input.resolved),
641
764
  "--method",
642
765
  "PATCH",
643
766
  endpoint,
@@ -659,6 +782,7 @@ async function deletePrReviewComment(input) {
659
782
  try {
660
783
  await execFileAsync("gh", [
661
784
  "api",
785
+ ...ghHostnameArgs(input.resolved),
662
786
  "--method",
663
787
  "DELETE",
664
788
  endpoint,
@@ -689,6 +813,7 @@ async function setPrReviewThreadResolved(input) {
689
813
  const { stdout } = await execWithInput("gh", [
690
814
  "api",
691
815
  "graphql",
816
+ ...ghHostnameArgs({ host: input.host }),
692
817
  "--input",
693
818
  "-"
694
819
  ], JSON.stringify({
@@ -719,12 +844,16 @@ function githubCommandError(error, fallback) {
719
844
  return String(error?.stderr || error?.message || fallback).trim().slice(0, 500) || fallback;
720
845
  }
721
846
  async function buildPrSession(ref) {
722
- const meta = await fetchPrMetadataViaGh(parsePrRef(ref, await detectCwdRepo() ?? void 0));
847
+ const cwdRepo = await detectCwdRepo();
848
+ const resolved = parsePrRef(ref, cwdRepo ?? void 0);
849
+ const meta = await fetchPrMetadataViaGh(resolved);
850
+ const host = resolved.host ?? parseGitRemoteUrl(meta.url)?.host ?? cwdRepo?.host;
723
851
  return {
724
852
  ref,
725
853
  owner: meta.owner,
726
854
  repo: meta.repo,
727
855
  pullNumber: meta.number,
856
+ host: isGithubDotCom(host) ? void 0 : host,
728
857
  baseSha: meta.baseSha,
729
858
  headSha: meta.headSha,
730
859
  title: meta.title,
@@ -741,12 +870,7 @@ async function buildPrSession(ref) {
741
870
  }
742
871
  /** Refresh `diff` + `existingComments` + head SHA in an existing session. */
743
872
  async function refreshPrSession(session) {
744
- const meta = await fetchPrMetadataViaGh({
745
- owner: session.owner,
746
- repo: session.repo,
747
- pullNumber: session.pullNumber,
748
- ref: session.ref
749
- });
873
+ const meta = await fetchPrMetadataViaGh(resolvedFromSession(session));
750
874
  return {
751
875
  ...session,
752
876
  baseSha: meta.baseSha,
@@ -763,4 +887,4 @@ async function refreshPrSession(session) {
763
887
  };
764
888
  }
765
889
  //#endregion
766
- export { replyToPrComment as _, detectCwdRepo as a, updatePrReviewComment as b, expandMultiLineComments as c, fetchPrChecks as d, fetchPrMetadataViaGh as f, refreshPrSession as g, readGithubToken as h, deletePrReviewComment as i, fetchExistingCommentsViaGh as l, parsePrRef as m, buildReviewPayload as n, detectGhCli as o, parseGhAuthStatusUser as p, decisionToEvent as r, execWithInput as s, buildPrSession as t, fetchExistingReviewsViaGh as u, setPrReviewThreadResolved as v, submitReview as y };
890
+ export { replyToPrComment as C, updatePrReviewComment as D, submitReview as E, refreshPrSession as S, setPrReviewThreadResolved as T, isGithubDotCom as _, detectCwdRepo as a, parsePrRef as b, expandMultiLineComments as c, fetchPrChecks as d, fetchPrFileContentViaGh as f, githubApiBase as g, ghRepoSelector as h, deletePrReviewComment as i, fetchExistingCommentsViaGh as l, ghHostnameArgs as m, buildReviewPayload as n, detectGhCli as o, fetchPrMetadataViaGh as p, decisionToEvent as r, execWithInput as s, buildPrSession as t, fetchExistingReviewsViaGh as u, parseGhAuthStatusUser as v, resolvedFromSession as w, readGithubToken as x, parseGitRemoteUrl as y };
@@ -0,0 +1,2 @@
1
+ import { C as replyToPrComment, d as fetchPrChecks, n as buildReviewPayload } from "./github-CzxbZnhh.mjs";
2
+ export { buildReviewPayload, fetchPrChecks, replyToPrComment };