stim 1.20.2 → 1.22.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 (231) hide show
  1. package/README.md +141 -8
  2. package/dist/acquire-artifact-Co2k4f7O.mjs +171 -0
  3. package/dist/act-DsuqEkiM.mjs +2801 -0
  4. package/dist/activity-CMLmzp7o.mjs +1397 -0
  5. package/dist/{agent-device-usage-output-Dzgv6lgR.mjs → agent-device-usage-output-DUFaTMdd.mjs} +23 -67
  6. package/dist/{android-DCKZrNvV.mjs → android-ByRMUoiJ.mjs} +157 -93
  7. package/dist/{android-Mz_Inn3w.mjs → android-C7sVmyI9.mjs} +299 -116
  8. package/dist/{android-Dlzxshgp.mjs → android-DGkNqa_c.mjs} +5 -5
  9. package/dist/{android-HqP1_vB_.mjs → android-DR5lZ2Az.mjs} +2 -2
  10. package/dist/android-cas-compiler.mjs +2 -2
  11. package/dist/{android-cas-Bl-cLJBk.mjs → android-cas-ngferVq2.mjs} +7 -6
  12. package/dist/android-project-BCAAmMwz.mjs +12 -0
  13. package/dist/android-project-DVWyCbWU.d.mts +391 -0
  14. package/dist/api.d.mts +810 -64
  15. package/dist/api.mjs +782 -1
  16. package/dist/{artifact-HSwkIWEQ.mjs → artifact-8EY8SAPw.mjs} +240 -213
  17. package/dist/{artifact-D3czlUvT.mjs → artifact-DJPy518Y.mjs} +203 -164
  18. package/dist/artifact-platform-CXcmX_j3.mjs +27 -0
  19. package/dist/{browser-web-CA-F1GQo.mjs → browser-web-Bcv99PBM.mjs} +194 -64
  20. package/dist/budget-Cvwn54qV.mjs +9285 -0
  21. package/dist/{build-DYDbfkk5.mjs → build-CabC3G23.mjs} +153 -98
  22. package/dist/build-cache-Dv7RN200.mjs +602 -0
  23. package/dist/build-plan-DUC8Ka9y.mjs +248 -0
  24. package/dist/{cache-manifest-XH-fvDUj.mjs → cache-manifest-DSeQjt-Q.mjs} +2 -2
  25. package/dist/cache-manifest.mjs +1 -1
  26. package/dist/{ccache-zdKiYQ3E.mjs → ccache-Btwc36-I.mjs} +10 -9
  27. package/dist/{cdp-Dq_ypAlJ.mjs → cdp-3fwICjzi.mjs} +18 -5
  28. package/dist/{chrome-BnzZMqsR.mjs → chrome-Bbw689-6.mjs} +7 -4
  29. package/dist/{cli-CLP3diBm.mjs → cli-CHZa9Lvk.mjs} +20 -20
  30. package/dist/cli.mjs +1 -1
  31. package/dist/client-OyRoEuSr.mjs +1577 -0
  32. package/dist/collector-run.d.mts +4 -40
  33. package/dist/collector-run.mjs +9 -8
  34. package/dist/{command-output-BTy8hZ0F.mjs → command-output-gwpm28fu.mjs} +1 -1
  35. package/dist/config-DlrsduwG.mjs +955 -0
  36. package/dist/{created-devices-Dzd5C2LF.mjs → created-devices-x9rN6bhs.mjs} +14 -4
  37. package/dist/{dependency-state-DG0p31-y.mjs → dependency-state-1I9KZT1Y.mjs} +20 -5
  38. package/dist/{detached-entry-B9C_zeQC.mjs → detached-entry-BwNEtIrP.mjs} +1 -1
  39. package/dist/{dev-client-DAWVIGBu.mjs → dev-client-BSDR5h3F.mjs} +2 -2
  40. package/dist/{device-BECOiufl.mjs → device-B-L3Fbxy.mjs} +91 -34
  41. package/dist/device-DklWZLqb.mjs +1068 -0
  42. package/dist/{device-capacity-CBUAcRyQ.mjs → device-capacity-DK5_EwRS.mjs} +42 -13
  43. package/dist/device-host-worker.mjs +76 -79
  44. package/dist/{device-ios-COSi6oS1.mjs → device-ios-DoB6KFCO.mjs} +77 -51
  45. package/dist/{device-lease-run-Cw2M4z51.mjs → device-lease-run-xJPQ_QQG.mjs} +14 -26
  46. package/dist/{device-pool-Bf-pOhSw.mjs → device-pool-BMkdsefq.mjs} +5 -5
  47. package/dist/{doctor-kfMBnUw6.mjs → doctor-Bo7BXLux.mjs} +271 -320
  48. package/dist/{doctor-CB8oZKCk.mjs → doctor-D5_EzwfA.mjs} +186 -91
  49. package/dist/doctor-fingerprint-DZLoYFVb.mjs +16 -0
  50. package/dist/doctor-fingerprint.mjs +19 -0
  51. package/dist/doctor-thjWAV0z.mjs +2 -0
  52. package/dist/{doctor-watchman-BRyV2adA.mjs → doctor-watchman-N2wDotwQ.mjs} +40 -21
  53. package/dist/{eas-build-JyfqyHfC.mjs → eas-build-CwknaQYj.mjs} +53 -20
  54. package/dist/{build-plan-B7SZsc2N.mjs → eas-fallback-CSgAulr5.mjs} +41 -214
  55. package/dist/{watchman-CPQFZLXY.mjs → eas-session-ledger-DlY_serQ.mjs} +230 -11
  56. package/dist/{error-diagnostics-BR677IDM.mjs → error-diagnostics-DBWO2rxE.mjs} +172 -82
  57. package/dist/exec-DEoAhcze.mjs +858 -0
  58. package/dist/exec-DnYc4HGH.d.mts +78 -0
  59. package/dist/{gc-qWOMdnER.mjs → gc-CXxN-4SE.mjs} +1091 -1029
  60. package/dist/gc-DnNDQyaP.mjs +3 -0
  61. package/dist/{guide-G9cAbVAc.mjs → guide-Br0LEfKy.mjs} +1165 -297
  62. package/dist/{hosted-android-C3MHGld1.mjs → hosted-android-B-9f-jkd.mjs} +10 -8
  63. package/dist/{hosted-client-ZEKpS9vw.mjs → hosted-client-DZAPrcro.mjs} +34 -19
  64. package/dist/{hosted-ios-l-o3iM9J.mjs → hosted-ios-CsCS21hn.mjs} +1 -1
  65. package/dist/{hosted-logs-EzQM7-3Z.mjs → hosted-logs-FIRx9X2f.mjs} +77 -43
  66. package/dist/{hosted-macos-BACVAVqE.mjs → hosted-macos-_awYSpfv.mjs} +35 -22
  67. package/dist/{hosted-native-A4s1QPXe.mjs → hosted-native-BdzE668-.mjs} +49 -27
  68. package/dist/idle-C4cZ757K.d.mts +24 -0
  69. package/dist/{idle-shutdown-DtxhPTKe.mjs → idle-shutdown-DDg3SdvY.mjs} +11 -10
  70. package/dist/ios-CDvlmUs7.d.mts +24 -0
  71. package/dist/{ios-BwVCF7oA.mjs → ios-Ds1clbIt.mjs} +8 -8
  72. package/dist/{ios-device-D7pi2Sca.mjs → ios-device--h_-8ENa.mjs} +51 -26
  73. package/dist/{ios-device-B5veSDDQ.mjs → ios-device-BXZ0c7Kb.mjs} +1 -1
  74. package/dist/{ios-RkW4pnQf.mjs → ios-hcBpnEGk.mjs} +200 -93
  75. package/dist/{ios-Ce7bc7br.mjs → ios-pm4nL6By.mjs} +160 -108
  76. package/dist/{ios-project-K9hY_Jab.mjs → ios-project-CZhKODF3.mjs} +13 -13
  77. package/dist/ios-signing-BtAffm0A.mjs +489 -0
  78. package/dist/{ios-state-CBLe1xYw.mjs → ios-state-Dtw5K2aI.mjs} +1 -1
  79. package/dist/{ios-nOLJGVdy.mjs → ios-xtlRHaeB.mjs} +1 -1
  80. package/dist/{js-swap-Bb3nsS07.mjs → js-swap-Bwhh4S7V.mjs} +30 -25
  81. package/dist/{launch-C3qJ6Agb.mjs → launch-BjxemNpK.mjs} +85 -543
  82. package/dist/{launch-F4sOqAhB.mjs → launch-CCzXlc8r.mjs} +91 -90
  83. package/dist/logs-BfwwadsZ.mjs +479 -0
  84. package/dist/logs-jTS_lHSo.mjs +248 -0
  85. package/dist/{macos-D7uDvO-z.mjs → macos-DVlSSyUg.mjs} +1 -1
  86. package/dist/macos-NfV2D7dO.mjs +694 -0
  87. package/dist/macos-run.mjs +1 -1
  88. package/dist/maintenance-run.mjs +123 -248
  89. package/dist/{metro-DnCEjCxs.mjs → metro-DiXtA3Ty.mjs} +107 -30
  90. package/dist/metro-gateway-CKZqKqx7.mjs +209 -0
  91. package/dist/{named-ports-4WopRPg-.mjs → named-ports-DkEzOfzO.mjs} +42 -90
  92. package/dist/native-android-CqgnOgsT.mjs +645 -0
  93. package/dist/native-gradle-artifact-inputs-DHFnmrVf.mjs +270 -0
  94. package/dist/native-gradle-inputs-Dnh84Zbd.mjs +211 -0
  95. package/dist/native-inputs-TRTTTRxt.mjs +91 -0
  96. package/dist/native-run-NwUuxbkg.mjs +276 -0
  97. package/dist/{native-runtime-k8dTIrbK.mjs → native-runtime-B7KIafpM.mjs} +11 -9
  98. package/dist/native-source-Y0yLhFyQ.mjs +133 -0
  99. package/dist/{native-xcode-inputs-CykopJdM.mjs → native-xcode-inputs-D_VOfFL7.mjs} +26 -18
  100. package/dist/{native-xcode-ios-Bbf30Gm0.mjs → native-xcode-ios-BYDOHWLN.mjs} +104 -60
  101. package/dist/{ndjson-GOnbyvso.mjs → ndjson-CgE_o3Dl.mjs} +3 -3
  102. package/dist/offload-worker.d.mts +59 -41
  103. package/dist/offload-worker.mjs +478 -115
  104. package/dist/operation-exec-BW0em61G.mjs +171 -0
  105. package/dist/{ownership-DCtw_2IA.mjs → ownership-C5fo5Edb.mjs} +3 -3
  106. package/dist/{page-DRHy329N.mjs → page-DBL2PiUU.mjs} +12 -5
  107. package/dist/paths-BsJMoPP2.mjs +12 -0
  108. package/dist/paths-DQtTgsBf.mjs +42 -0
  109. package/dist/{placement-log-MOfPVgaM.mjs → placement-log-BnGgJRRZ.mjs} +5 -5
  110. package/dist/{plan-placement-V0TdzYXp.mjs → plan-placement-DIsMtN-d.mjs} +15 -11
  111. package/dist/{ports-DdSUicVo.mjs → ports-Cy1RkmuQ.mjs} +3 -3
  112. package/dist/prebuild-D4JoEAEs.mjs +484 -0
  113. package/dist/{project-_phNIJfs.mjs → project-wM_XFTvE.mjs} +65 -37
  114. package/dist/{pull-request-CQ8sPbZa.mjs → pull-request-W1IuLXDt.mjs} +102 -20
  115. package/dist/pull-request-eODyIqZF.d.mts +124 -0
  116. package/dist/pull-requests.d.mts +2 -120
  117. package/dist/pull-requests.mjs +2 -2
  118. package/dist/{react-native-android-CM1XRDwv.mjs → react-native-android-6OZ7MSM7.mjs} +121 -72
  119. package/dist/{gradle-DSrXb6lG.mjs → react-native-build-Dvd8hC21.mjs} +292 -15
  120. package/dist/react-native-doctor-DsoSF1Y9.mjs +234 -0
  121. package/dist/{react-native-ios-Dhq_eiYQ.mjs → react-native-ios-4u1Rn-GR.mjs} +71 -39
  122. package/dist/{recordings-D0d5aQt0.mjs → recordings-CQmfzAh7.mjs} +12 -9
  123. package/dist/registration-BcRgF6Ox.mjs +51 -0
  124. package/dist/{reload-C8JhxjSh.mjs → reload-BzkYabB-.mjs} +94 -47
  125. package/dist/reload-D7AVlb8N.mjs +2 -0
  126. package/dist/{remote-BiR6aYjy.mjs → remote-DjGDmlTZ.mjs} +26 -18
  127. package/dist/result-D2Ykz_iD.mjs +435 -0
  128. package/dist/{run-BtPgpKks.mjs → run-DidHghD1.mjs} +5 -5
  129. package/dist/selection-DSMbWEX2.mjs +620 -0
  130. package/dist/{server-bare-R2m_gsH8.mjs → server-bare-CafzuyFB.mjs} +3 -4
  131. package/dist/{server-command-CTtCkmcQ.mjs → server-command-C6QjeupS.mjs} +14 -7
  132. package/dist/{server-expo-DsguMGUF.mjs → server-expo-CrjB29pq.mjs} +54 -11
  133. package/dist/server-expo-D58c9L0M.mjs +2 -0
  134. package/dist/{settings-B717odTD.mjs → settings-C7O8A6ZI.mjs} +309 -119
  135. package/dist/settings-DpR-1Wnn.mjs +114 -0
  136. package/dist/settings-write-CzD60rOD.mjs +360 -0
  137. package/dist/settings.schema.json +176 -16
  138. package/dist/{simslim-CCr3rE-A.mjs → simslim-BNckWpXi.mjs} +14 -12
  139. package/dist/{slot-launch-DPt0m9Nd.mjs → slot-launch-CbfmNgM6.mjs} +15 -20
  140. package/dist/{spawn-entry-Dcb7sDUz.mjs → spawn-entry-jw19m8Nl.mjs} +0 -1
  141. package/dist/stage-Bps5oius.mjs +200 -0
  142. package/dist/{start-TXeMmmO2.mjs → start-Br-oxqMD.mjs} +1 -1
  143. package/dist/start-EojN4WFz.mjs +1364 -0
  144. package/dist/{state-D1Icyjlu.mjs → state--smjFSTL.mjs} +55 -13
  145. package/dist/{state-CG_OFoaA.mjs → state-08I3hw3_.mjs} +3 -2
  146. package/dist/{stats-BoY5sEPU.mjs → stats-D3GerlFW.mjs} +7 -13
  147. package/dist/stats-report-BzaPrRm6.mjs +16 -0
  148. package/dist/{status-BTA7kKiQ.mjs → status-BRROykC8.mjs} +7 -5
  149. package/dist/status-EvrK72L2.mjs +2 -0
  150. package/dist/{status-WgFbkRzj.mjs → status-WBDajew2.mjs} +554 -452
  151. package/dist/{status-watch-C23ILtf9.mjs → status-watch-Bg_u-pwR.mjs} +222 -25
  152. package/dist/status-worker.d.mts +1 -0
  153. package/dist/status-worker.mjs +19 -0
  154. package/dist/stim-desktop-D5OGpYZM.mjs +112 -0
  155. package/dist/{stop-DR6VoDIk.mjs → stop-DTZ9uTw3.mjs} +2 -2
  156. package/dist/{stop-DPEhunlw.mjs → stop-Dky10AEJ.mjs} +33 -23
  157. package/dist/{stop-BNmBMi1F.mjs → stop-Mv6W9FAk.mjs} +137 -98
  158. package/dist/supervisor-run.d.mts +8 -17
  159. package/dist/supervisor-run.mjs +56 -28
  160. package/dist/{support-CwjbFs9H.mjs → support-CNioewsd.mjs} +14 -14
  161. package/dist/{support-DMTqj3Hm.mjs → support-yUiOjnVY.mjs} +20 -13
  162. package/dist/swiftpm-artifact-inputs-DFcGsXDP.mjs +153 -0
  163. package/dist/swiftpm-macos-BIak-Rxv.mjs +532 -0
  164. package/dist/toolchain-BY8X8HXx.mjs +2 -0
  165. package/dist/toolchain-DpJMHq0n.mjs +876 -0
  166. package/dist/{trigger-CigAYjeL.mjs → trigger-Cbyc41d_.mjs} +21 -6
  167. package/dist/trigger-yb_nFzPF.mjs +2 -0
  168. package/dist/{warm-progress-BuY-Fvfn.mjs → warm-progress-CA3TgT3-.mjs} +263 -156
  169. package/dist/web-CZ07gd77.mjs +2 -0
  170. package/dist/{web-BDBMxDpx.mjs → web-DKx6yoFA.mjs} +20 -14
  171. package/dist/web-run.mjs +13 -12
  172. package/dist/windows-report.d.mts +1 -0
  173. package/dist/windows-report.mjs +18 -0
  174. package/dist/windows-report.ps1 +43 -0
  175. package/dist/{workspace-state-DJt_MMvf.mjs → workspace-state-U08dEzhG.mjs} +62 -58
  176. package/dist/{workspaces-C36s2jb9.mjs → workspaces-CpANmBlq.mjs} +1723 -1286
  177. package/dist/{worktree-CgvJYJ-Q.mjs → worktree-CHecZ4Oq.mjs} +1097 -547
  178. package/dist/worktree-ZqZVjD9K.mjs +2 -0
  179. package/dist/xcode-BXn9-xYx.mjs +896 -0
  180. package/package.json +7 -5
  181. package/shim/android-audio/Main.java +24 -0
  182. package/shim/android-audio/README.md +17 -0
  183. package/shim/android-audio.jar +0 -0
  184. package/shim/android-optimizations.gradle +7 -5
  185. package/dist/activity-BSV745Kz.mjs +0 -629
  186. package/dist/api-qvOzWyfO.mjs +0 -154
  187. package/dist/api-run.mjs +0 -294
  188. package/dist/app-install-BIKtMfPq.mjs +0 -896
  189. package/dist/artifact-lifecycle-DzPpBYvK.mjs +0 -30
  190. package/dist/budget-f7516Zk0.mjs +0 -4106
  191. package/dist/build-facts-DcLv2HSd.d.mts +0 -111
  192. package/dist/cancellation-C_22VQTH.mjs +0 -24
  193. package/dist/client-qQAaXSUs.mjs +0 -1771
  194. package/dist/config-BYDxlMY3.mjs +0 -562
  195. package/dist/device-DuiPJQSn.mjs +0 -290
  196. package/dist/device-lease-BX1sJQ2E.mjs +0 -1224
  197. package/dist/device-remote-xRT0Vmo9.mjs +0 -1272
  198. package/dist/eas-session-ledger-Cm0Gwq2F.mjs +0 -207
  199. package/dist/exec-DqKo9GKJ.mjs +0 -268
  200. package/dist/git-DDfFzkMm.mjs +0 -45
  201. package/dist/launch-verify-B6Q8hZP-.mjs +0 -428
  202. package/dist/logs-BGrEUaEs.mjs +0 -383
  203. package/dist/macos-Ch5VJmcS.mjs +0 -584
  204. package/dist/metro-gateway-CX9Xlkq2.mjs +0 -103
  205. package/dist/miss-reason-mKzZ4VvN.mjs +0 -238
  206. package/dist/native-android-D5qc3-_v.mjs +0 -226
  207. package/dist/native-gradle-inputs-BsLRrl7u.mjs +0 -349
  208. package/dist/ndjson-Du3j0AQ9.d.mts +0 -17
  209. package/dist/plan-C4TjdPsR.mjs +0 -260
  210. package/dist/prebuild-DYbucPXy.mjs +0 -212
  211. package/dist/preview-78a9kR_-.mjs +0 -1011
  212. package/dist/react-native-build-CtCccJtb.mjs +0 -239
  213. package/dist/react-native-doctor-CfRnFfjs.mjs +0 -78
  214. package/dist/remote-cache-OyOyVIS3.mjs +0 -526
  215. package/dist/result-CaJg5Iat.mjs +0 -186
  216. package/dist/server-expo-Bigriskl.mjs +0 -2
  217. package/dist/settings-BORNaaCO.mjs +0 -402
  218. package/dist/settings-vk3mJGSm.d.mts +0 -13
  219. package/dist/spawn-claims-DVS5RkMS.mjs +0 -72
  220. package/dist/stage-KNTQopqv.mjs +0 -157
  221. package/dist/start-BWqzODpb.mjs +0 -1116
  222. package/dist/stim-desktop-BzBN2Em2.mjs +0 -63
  223. package/dist/swiftpm-macos-DRNVJWlb.mjs +0 -119
  224. package/dist/tailnet-Dh-qiYzG.mjs +0 -265
  225. package/dist/toolchain-BFkAcstd.mjs +0 -2
  226. package/dist/toolchain-DxSsNssu.mjs +0 -1657
  227. package/dist/trigger-9_USgmxz.mjs +0 -2
  228. package/dist/web-Dq-i3wzJ.mjs +0 -2
  229. package/dist/worktree-DpLdCHga.mjs +0 -2
  230. package/dist/{api-run.d.mts → doctor-fingerprint.d.mts} +0 -0
  231. package/dist/{errors-DzkMYh8Q.mjs → errors-ccaPc4ox.mjs} +2 -2
@@ -1,5 +1,5 @@
1
- import { t as getExecutor } from "./exec-DqKo9GKJ.mjs";
2
- import { n as gitAsync, r as gitQuiet } from "./git-DDfFzkMm.mjs";
1
+ import { r as WorkspaceProcessCleanupError, t as getExecutor } from "./exec-DEoAhcze.mjs";
2
+ import { c as gitQuiet, l as gitQuietAsync, r as childEnvironment, s as gitAsync, t as runOperationFile } from "./operation-exec-BW0em61G.mjs";
3
3
  //#region src/workspace/pull-request.ts
4
4
  const GH_TIMEOUT_MS = 2e4;
5
5
  const GH_ENV = {
@@ -81,16 +81,8 @@ function headRepoOf(pull) {
81
81
  const name = pull.headRepository?.name;
82
82
  return owner && name ? `${owner.toLowerCase()}/${name.toLowerCase()}` : null;
83
83
  }
84
- /**
85
- * Picks the pull request that describes `head` among those `gh pr list --head <branch>` returned. One whose head is
86
- * `head` wins, then one whose head contains `head`, then one whose head `head` contains. An open one wins a tier,
87
- * then the newest. A pull request unrelated to `head` is from an earlier use of the branch name and is ignored. A
88
- * cross-repository pull request is kept only when its head repository is one of `ownRepos` (this checkout's own git
89
- * remotes, lowercased "owner/name"); otherwise it only shares the branch name with a stranger's fork and is ignored.
90
- * `isAncestor(a, b)` answers whether commit `a` is an ancestor of commit `b`, and false when git cannot tell.
91
- */
92
- function selectPullRequest(pulls, head, isAncestor, ownRepos = /* @__PURE__ */ new Set()) {
93
- const known = pulls.flatMap((pull) => {
84
+ function knownPullRequests(pulls, ownRepos) {
85
+ return pulls.flatMap((pull) => {
94
86
  if (!pull || typeof pull !== "object") return [];
95
87
  const state = stateOf(pull.state);
96
88
  if (!state || !pull.headRefOid) return [];
@@ -103,6 +95,17 @@ function selectPullRequest(pulls, head, isAncestor, ownRepos = /* @__PURE__ */ n
103
95
  state
104
96
  }];
105
97
  });
98
+ }
99
+ /**
100
+ * Picks the pull request that describes `head` among those `gh pr list --head <branch>` returned. One whose head is
101
+ * `head` wins, then one whose head contains `head`, then one whose head `head` contains. An open one wins a tier,
102
+ * then the newest. A pull request unrelated to `head` is from an earlier use of the branch name and is ignored. A
103
+ * cross-repository pull request is kept only when its head repository is one of `ownRepos` (this checkout's own git
104
+ * remotes, lowercased "owner/name"); otherwise it only shares the branch name with a stranger's fork and is ignored.
105
+ * `isAncestor(a, b)` answers whether commit `a` is an ancestor of commit `b`, and false when git cannot tell.
106
+ */
107
+ function selectPullRequest(pulls, head, isAncestor, ownRepos = /* @__PURE__ */ new Set()) {
108
+ const known = knownPullRequests(pulls, ownRepos);
106
109
  const tiers = [
107
110
  known.filter(({ pull }) => pull.headRefOid === head),
108
111
  known.filter(({ pull }) => pull.headRefOid !== head && isAncestor(head, pull.headRefOid)),
@@ -159,7 +162,9 @@ function parseRemoteRepo(url) {
159
162
  return owner && name ? `${owner.toLowerCase()}/${name.toLowerCase()}` : null;
160
163
  }
161
164
  function localRemoteRepos(cwd) {
162
- const out = gitQuiet(cwd, ["remote", "-v"]);
165
+ return remoteRepos(gitQuiet(cwd, ["remote", "-v"]));
166
+ }
167
+ function remoteRepos(out) {
163
168
  const repos = /* @__PURE__ */ new Set();
164
169
  for (const line of out ? out.split("\n") : []) {
165
170
  const url = /^\S+\s+(\S+)\s+\((?:fetch|push)\)$/.exec(line)?.[1];
@@ -168,6 +173,33 @@ function localRemoteRepos(cwd) {
168
173
  }
169
174
  return repos;
170
175
  }
176
+ function gitExecution(operation) {
177
+ return {
178
+ ...operation ? childEnvironment(operation.env) : {},
179
+ signal: operation?.signal,
180
+ declareFor: operation,
181
+ cwd: operation?.cwd,
182
+ killSignal: "SIGKILL"
183
+ };
184
+ }
185
+ async function selectPullRequestAsync(cwd, pulls, head, ownRepos, operation) {
186
+ const options = gitExecution(operation);
187
+ const ancestors = /* @__PURE__ */ new Map();
188
+ for (const { pull } of knownPullRequests(pulls, ownRepos)) {
189
+ if (pull.headRefOid === head) continue;
190
+ for (const [a, b] of [[head, pull.headRefOid], [pull.headRefOid, head]]) {
191
+ const key = `${a}:${b}`;
192
+ if (!ancestors.has(key)) ancestors.set(key, await gitQuietAsync(cwd, [
193
+ "merge-base",
194
+ "--is-ancestor",
195
+ a,
196
+ b
197
+ ], options) !== null);
198
+ }
199
+ }
200
+ operation?.signal.throwIfAborted();
201
+ return selectPullRequest(pulls, head, (a, b) => ancestors.get(`${a}:${b}`) ?? false, ownRepos);
202
+ }
171
203
  /**
172
204
  * Asks GitHub, through `gh`, which pull requests have `branch` as their head, run from `cwd` so `gh` picks the
173
205
  * repository from its remotes. Each call is one fixed `gh pr list` invocation. Once `gh` is missing, signed out or
@@ -211,6 +243,50 @@ function pullRequestLookup() {
211
243
  return { pullRequest: Array.isArray(pulls) ? selectPullRequest(pulls, head, ancestry(cwd), localRemoteRepos(cwd)) : null };
212
244
  };
213
245
  }
246
+ /** The same branch and commit lookup as `pullRequestLookup`, with nonblocking Git and GitHub probes. */
247
+ function pullRequestLookupAsync(operation) {
248
+ let unavailable;
249
+ return async (cwd, branch, head) => {
250
+ const exec = getExecutor();
251
+ operation?.signal.throwIfAborted();
252
+ if (unavailable === void 0) unavailable = exec.findExecutable("gh") ? null : "gh is not installed";
253
+ if (unavailable) return { unavailable };
254
+ let out;
255
+ try {
256
+ out = await runOperationFile(operation, exec, "gh", [
257
+ "pr",
258
+ "list",
259
+ "--head",
260
+ branch,
261
+ "--state",
262
+ "all",
263
+ "--limit",
264
+ "20",
265
+ "--json",
266
+ GH_FIELDS
267
+ ], {
268
+ cwd,
269
+ timeoutMs: GH_TIMEOUT_MS,
270
+ env: GH_ENV
271
+ });
272
+ } catch (error) {
273
+ if (error instanceof WorkspaceProcessCleanupError || error instanceof Error && "reportCleanup" in error) throw error;
274
+ operation?.signal.throwIfAborted();
275
+ const failure = ghFailure(error, "gh pr list");
276
+ if (failure.sticky) unavailable = failure.unavailable;
277
+ return { unavailable: failure.unavailable };
278
+ }
279
+ let pulls;
280
+ try {
281
+ pulls = JSON.parse(out);
282
+ } catch {
283
+ return { unavailable: "gh pr list printed no JSON" };
284
+ }
285
+ if (!Array.isArray(pulls)) return { pullRequest: null };
286
+ const ownRepos = remoteRepos(await gitQuietAsync(cwd, ["remote", "-v"], gitExecution(operation)));
287
+ return { pullRequest: await selectPullRequestAsync(cwd, pulls, head, ownRepos, operation) };
288
+ };
289
+ }
214
290
  function branchesQuery(count, detail) {
215
291
  const variables = Array.from({ length: count }, (_, i) => `, $b${i}: String!`).join("");
216
292
  const nodes = `${GH_SCALAR_FIELDS.replaceAll(",", " ")} ${GH_GRAPHQL_REPO_SELECTION}` + (detail ? ` ${GH_DETAIL_FIELDS}` : "");
@@ -223,9 +299,10 @@ function branchesQuery(count, detail) {
223
299
  * out or times out, every later call through the same function answers `unavailable` without running it again.
224
300
  * With `detail`, it also asks for each pull request's title, review decision and head commit check counts.
225
301
  */
226
- function pullRequestLookups({ detail = false } = {}) {
302
+ function pullRequestLookups({ detail = false, operation } = {}) {
227
303
  let unavailable;
228
304
  return async (repo, queries) => {
305
+ operation?.signal.throwIfAborted();
229
306
  const exec = getExecutor();
230
307
  if (unavailable === void 0) unavailable = exec.findExecutable("gh") ? null : "gh is not installed";
231
308
  const all = (lookup) => queries.map(() => lookup);
@@ -243,12 +320,14 @@ function pullRequestLookups({ detail = false } = {}) {
243
320
  args.push("-f", `query=${branchesQuery(queries.length, detail)}`);
244
321
  let out;
245
322
  try {
246
- out = await exec.runFileAsync("gh", args, {
323
+ out = await runOperationFile(operation, exec, "gh", args, {
247
324
  cwd: repo,
248
325
  timeoutMs: GH_TIMEOUT_MS,
249
326
  env: GH_ENV
250
327
  });
251
328
  } catch (error) {
329
+ if (error instanceof WorkspaceProcessCleanupError || error instanceof Error && "reportCleanup" in error) throw error;
330
+ operation?.signal.throwIfAborted();
252
331
  const failure = ghFailure(error, "gh api graphql");
253
332
  if (failure.sticky) unavailable = failure.unavailable;
254
333
  return all({ unavailable: failure.unavailable });
@@ -260,11 +339,14 @@ function pullRequestLookups({ detail = false } = {}) {
260
339
  return all({ unavailable: "gh api graphql printed no JSON" });
261
340
  }
262
341
  if (!found) return all({ unavailable: "gh api graphql printed no repository" });
263
- const ownRepos = localRemoteRepos(repo);
264
- return queries.map(({ cwd, head }, i) => {
342
+ const ownRepos = remoteRepos(await gitQuietAsync(repo, ["remote", "-v"], gitExecution(operation)));
343
+ const results = [];
344
+ for (const [i, { cwd, head }] of queries.entries()) {
345
+ operation?.signal.throwIfAborted();
265
346
  const pulls = found[`b${i}`]?.nodes;
266
- return { pullRequest: Array.isArray(pulls) ? selectPullRequest(pulls, head, ancestry(cwd), ownRepos) : null };
267
- });
347
+ results.push({ pullRequest: Array.isArray(pulls) ? await selectPullRequestAsync(cwd, pulls, head, ownRepos, operation) : null });
348
+ }
349
+ return results;
268
350
  };
269
351
  }
270
352
  /** The merged or closed pull request whose commits include HEAD, which makes the worktree removable. */
@@ -306,4 +388,4 @@ function worktreePullRequests() {
306
388
  };
307
389
  }
308
390
  //#endregion
309
- export { pullRequestLookup as a, worktreePullRequests as c, parseRemoteRepo as i, describePullRequest as n, pullRequestLookups as o, endedPullRequest as r, selectPullRequest as s, checkCounts as t };
391
+ export { pullRequestLookup as a, selectPullRequest as c, parseRemoteRepo as i, worktreePullRequests as l, describePullRequest as n, pullRequestLookupAsync as o, endedPullRequest as r, pullRequestLookups as s, checkCounts as t };
@@ -0,0 +1,124 @@
1
+ import { StimContext } from "@stim-cli/core";
2
+ //#region src/workspace/pull-request.d.ts
3
+ interface GhPullRequest {
4
+ number: number;
5
+ state: string;
6
+ url: string;
7
+ headRefOid: string;
8
+ mergedAt: string | null;
9
+ closedAt: string | null;
10
+ isCrossRepository?: boolean;
11
+ isDraft?: boolean;
12
+ headRepository?: {
13
+ name?: string | null;
14
+ } | null;
15
+ headRepositoryOwner?: {
16
+ login?: string | null;
17
+ } | null;
18
+ title?: string;
19
+ reviewDecision?: string | null;
20
+ commits?: {
21
+ nodes?: {
22
+ commit?: {
23
+ statusCheckRollup?: GhCheckRollup | null;
24
+ };
25
+ }[];
26
+ };
27
+ }
28
+ interface GhStateCount {
29
+ state: string;
30
+ count: number;
31
+ }
32
+ interface GhCheckRollup {
33
+ contexts?: {
34
+ checkRunCountsByState?: GhStateCount[];
35
+ statusContextCountsByState?: GhStateCount[];
36
+ };
37
+ }
38
+ interface CheckCounts {
39
+ passing: number;
40
+ failing: number;
41
+ pending: number;
42
+ }
43
+ /**
44
+ * The pull request whose head branch is the worktree's branch and whose commits include the worktree's HEAD.
45
+ * `containsHead` is false when the pull request's head is an ancestor of HEAD: HEAD has commits the pull request
46
+ * never had. `endedAt` is when it was merged or closed, in epoch milliseconds, and null while it is open.
47
+ */
48
+ interface PullRequestFact {
49
+ number: number;
50
+ state: "open" | "merged" | "closed";
51
+ draft: boolean;
52
+ url: string;
53
+ head: string;
54
+ containsHead: boolean;
55
+ endedAt: number | null;
56
+ /** Present when the lookup asked for detail. */
57
+ title?: string;
58
+ reviewDecision?: "approved" | "changes-requested" | "review-required" | null;
59
+ checks?: CheckCounts | null;
60
+ }
61
+ /** Sums a head commit's check runs and commit statuses by outcome; null when the commit has no checks. */
62
+ declare function checkCounts(rollup: GhCheckRollup | null | undefined): CheckCounts | null;
63
+ type PullRequestLookup = {
64
+ pullRequest: PullRequestFact | null;
65
+ } | {
66
+ unavailable: string;
67
+ };
68
+ /**
69
+ * Picks the pull request that describes `head` among those `gh pr list --head <branch>` returned. One whose head is
70
+ * `head` wins, then one whose head contains `head`, then one whose head `head` contains. An open one wins a tier,
71
+ * then the newest. A pull request unrelated to `head` is from an earlier use of the branch name and is ignored. A
72
+ * cross-repository pull request is kept only when its head repository is one of `ownRepos` (this checkout's own git
73
+ * remotes, lowercased "owner/name"); otherwise it only shares the branch name with a stranger's fork and is ignored.
74
+ * `isAncestor(a, b)` answers whether commit `a` is an ancestor of commit `b`, and false when git cannot tell.
75
+ */
76
+ declare function selectPullRequest(pulls: readonly GhPullRequest[], head: string, isAncestor: (ancestor: string, descendant: string) => boolean, ownRepos?: ReadonlySet<string>): PullRequestFact | null;
77
+ /**
78
+ * "owner/name", lowercased, parsed out of a git remote URL, or null when it doesn't match: https, `ssh://`, or
79
+ * scp-like (`[user@]host:owner/name`, which also covers an `~/.ssh/config` host alias in place of `user@host`).
80
+ */
81
+ declare function parseRemoteRepo(url: string): string | null;
82
+ /**
83
+ * Asks GitHub, through `gh`, which pull requests have `branch` as their head, run from `cwd` so `gh` picks the
84
+ * repository from its remotes. Each call is one fixed `gh pr list` invocation. Once `gh` is missing, signed out or
85
+ * times out, every later lookup through the same function answers `unavailable` without running it again.
86
+ */
87
+ declare function pullRequestLookup(): (cwd: string, branch: string, head: string) => PullRequestLookup;
88
+ /** The same branch and commit lookup as `pullRequestLookup`, with nonblocking Git and GitHub probes. */
89
+ declare function pullRequestLookupAsync(operation?: StimContext): (cwd: string, branch: string, head: string) => Promise<PullRequestLookup>;
90
+ /** A worktree whose pull request {@link pullRequestLookups} looks up: its path, branch and HEAD commit. */
91
+ interface PullRequestQuery {
92
+ cwd: string;
93
+ branch: string;
94
+ head: string;
95
+ }
96
+ /**
97
+ * {@link pullRequestLookup} for every branch of one repository in one fixed `gh api graphql` call run from `repo`,
98
+ * which asks for the same 20 newest pull requests of each head branch that `gh pr list --head` returns. `gh` fills
99
+ * `{owner}` and `{repo}` from the remotes of `repo`; branch names travel as variables. Once `gh` is missing, signed
100
+ * out or times out, every later call through the same function answers `unavailable` without running it again.
101
+ * With `detail`, it also asks for each pull request's title, review decision and head commit check counts.
102
+ */
103
+ declare function pullRequestLookups({ detail, operation }?: {
104
+ detail?: boolean;
105
+ operation?: StimContext;
106
+ }): (repo: string, queries: readonly PullRequestQuery[]) => Promise<PullRequestLookup[]>;
107
+ /** The merged or closed pull request whose commits include HEAD, which makes the worktree removable. */
108
+ declare function endedPullRequest(lookup: PullRequestLookup | null): PullRequestFact | null;
109
+ /** "PR #123 merged", for reports. */
110
+ declare function describePullRequest(pr: Pick<PullRequestFact, "number" | "state">): string;
111
+ /** A linked worktree whose pull request {@link worktreePullRequests} looks up. */
112
+ interface WorktreeBranch {
113
+ path: string;
114
+ branch: string;
115
+ repository: string;
116
+ }
117
+ /**
118
+ * Looks up the pull request of each worktree's branch and HEAD, with one {@link pullRequestLookups} call per
119
+ * repository. The map holds null for a worktree without one, and leaves out a worktree whose HEAD git cannot read
120
+ * or whose lookup was unavailable.
121
+ */
122
+ declare function worktreePullRequests(): (worktrees: readonly WorktreeBranch[]) => Promise<Map<string, PullRequestFact | null>>;
123
+ //#endregion
124
+ export { PullRequestLookup as a, checkCounts as c, parseRemoteRepo as d, pullRequestLookup as f, worktreePullRequests as g, selectPullRequest as h, PullRequestFact as i, describePullRequest as l, pullRequestLookups as m, GhCheckRollup as n, PullRequestQuery as o, pullRequestLookupAsync as p, GhPullRequest as r, WorktreeBranch as s, CheckCounts as t, endedPullRequest as u };
@@ -1,120 +1,2 @@
1
- //#region src/workspace/pull-request.d.ts
2
- interface GhPullRequest {
3
- number: number;
4
- state: string;
5
- url: string;
6
- headRefOid: string;
7
- mergedAt: string | null;
8
- closedAt: string | null;
9
- isCrossRepository?: boolean;
10
- isDraft?: boolean;
11
- headRepository?: {
12
- name?: string | null;
13
- } | null;
14
- headRepositoryOwner?: {
15
- login?: string | null;
16
- } | null;
17
- title?: string;
18
- reviewDecision?: string | null;
19
- commits?: {
20
- nodes?: {
21
- commit?: {
22
- statusCheckRollup?: GhCheckRollup | null;
23
- };
24
- }[];
25
- };
26
- }
27
- interface GhStateCount {
28
- state: string;
29
- count: number;
30
- }
31
- interface GhCheckRollup {
32
- contexts?: {
33
- checkRunCountsByState?: GhStateCount[];
34
- statusContextCountsByState?: GhStateCount[];
35
- };
36
- }
37
- interface CheckCounts {
38
- passing: number;
39
- failing: number;
40
- pending: number;
41
- }
42
- /**
43
- * The pull request whose head branch is the worktree's branch and whose commits include the worktree's HEAD.
44
- * `containsHead` is false when the pull request's head is an ancestor of HEAD: HEAD has commits the pull request
45
- * never had. `endedAt` is when it was merged or closed, in epoch milliseconds, and null while it is open.
46
- */
47
- interface PullRequestFact {
48
- number: number;
49
- state: "open" | "merged" | "closed";
50
- draft: boolean;
51
- url: string;
52
- head: string;
53
- containsHead: boolean;
54
- endedAt: number | null;
55
- /** Present when the lookup asked for detail. */
56
- title?: string;
57
- reviewDecision?: "approved" | "changes-requested" | "review-required" | null;
58
- checks?: CheckCounts | null;
59
- }
60
- /** Sums a head commit's check runs and commit statuses by outcome; null when the commit has no checks. */
61
- declare function checkCounts(rollup: GhCheckRollup | null | undefined): CheckCounts | null;
62
- type PullRequestLookup = {
63
- pullRequest: PullRequestFact | null;
64
- } | {
65
- unavailable: string;
66
- };
67
- /**
68
- * Picks the pull request that describes `head` among those `gh pr list --head <branch>` returned. One whose head is
69
- * `head` wins, then one whose head contains `head`, then one whose head `head` contains. An open one wins a tier,
70
- * then the newest. A pull request unrelated to `head` is from an earlier use of the branch name and is ignored. A
71
- * cross-repository pull request is kept only when its head repository is one of `ownRepos` (this checkout's own git
72
- * remotes, lowercased "owner/name"); otherwise it only shares the branch name with a stranger's fork and is ignored.
73
- * `isAncestor(a, b)` answers whether commit `a` is an ancestor of commit `b`, and false when git cannot tell.
74
- */
75
- declare function selectPullRequest(pulls: readonly GhPullRequest[], head: string, isAncestor: (ancestor: string, descendant: string) => boolean, ownRepos?: ReadonlySet<string>): PullRequestFact | null;
76
- /**
77
- * "owner/name", lowercased, parsed out of a git remote URL, or null when it doesn't match: https, `ssh://`, or
78
- * scp-like (`[user@]host:owner/name`, which also covers an `~/.ssh/config` host alias in place of `user@host`).
79
- */
80
- declare function parseRemoteRepo(url: string): string | null;
81
- /**
82
- * Asks GitHub, through `gh`, which pull requests have `branch` as their head, run from `cwd` so `gh` picks the
83
- * repository from its remotes. Each call is one fixed `gh pr list` invocation. Once `gh` is missing, signed out or
84
- * times out, every later lookup through the same function answers `unavailable` without running it again.
85
- */
86
- declare function pullRequestLookup(): (cwd: string, branch: string, head: string) => PullRequestLookup;
87
- /** A worktree whose pull request {@link pullRequestLookups} looks up: its path, branch and HEAD commit. */
88
- interface PullRequestQuery {
89
- cwd: string;
90
- branch: string;
91
- head: string;
92
- }
93
- /**
94
- * {@link pullRequestLookup} for every branch of one repository in one fixed `gh api graphql` call run from `repo`,
95
- * which asks for the same 20 newest pull requests of each head branch that `gh pr list --head` returns. `gh` fills
96
- * `{owner}` and `{repo}` from the remotes of `repo`; branch names travel as variables. Once `gh` is missing, signed
97
- * out or times out, every later call through the same function answers `unavailable` without running it again.
98
- * With `detail`, it also asks for each pull request's title, review decision and head commit check counts.
99
- */
100
- declare function pullRequestLookups({ detail }?: {
101
- detail?: boolean;
102
- }): (repo: string, queries: readonly PullRequestQuery[]) => Promise<PullRequestLookup[]>;
103
- /** The merged or closed pull request whose commits include HEAD, which makes the worktree removable. */
104
- declare function endedPullRequest(lookup: PullRequestLookup | null): PullRequestFact | null;
105
- /** "PR #123 merged", for reports. */
106
- declare function describePullRequest(pr: Pick<PullRequestFact, "number" | "state">): string;
107
- /** A linked worktree whose pull request {@link worktreePullRequests} looks up. */
108
- interface WorktreeBranch {
109
- path: string;
110
- branch: string;
111
- repository: string;
112
- }
113
- /**
114
- * Looks up the pull request of each worktree's branch and HEAD, with one {@link pullRequestLookups} call per
115
- * repository. The map holds null for a worktree without one, and leaves out a worktree whose HEAD git cannot read
116
- * or whose lookup was unavailable.
117
- */
118
- declare function worktreePullRequests(): (worktrees: readonly WorktreeBranch[]) => Promise<Map<string, PullRequestFact | null>>;
119
- //#endregion
120
- export { CheckCounts, GhCheckRollup, GhPullRequest, PullRequestFact, PullRequestLookup, PullRequestQuery, WorktreeBranch, checkCounts, describePullRequest, endedPullRequest, parseRemoteRepo, pullRequestLookup, pullRequestLookups, selectPullRequest, worktreePullRequests };
1
+ import { a as PullRequestLookup, c as checkCounts, d as parseRemoteRepo, f as pullRequestLookup, g as worktreePullRequests, h as selectPullRequest, i as PullRequestFact, l as describePullRequest, m as pullRequestLookups, n as GhCheckRollup, o as PullRequestQuery, p as pullRequestLookupAsync, r as GhPullRequest, s as WorktreeBranch, t as CheckCounts, u as endedPullRequest } from "./pull-request-eODyIqZF.mjs";
2
+ export { CheckCounts, GhCheckRollup, GhPullRequest, PullRequestFact, PullRequestLookup, PullRequestQuery, WorktreeBranch, checkCounts, describePullRequest, endedPullRequest, parseRemoteRepo, pullRequestLookup, pullRequestLookupAsync, pullRequestLookups, selectPullRequest, worktreePullRequests };
@@ -1,2 +1,2 @@
1
- import { a as pullRequestLookup, c as worktreePullRequests, i as parseRemoteRepo, n as describePullRequest, o as pullRequestLookups, r as endedPullRequest, s as selectPullRequest, t as checkCounts } from "./pull-request-CQ8sPbZa.mjs";
2
- export { checkCounts, describePullRequest, endedPullRequest, parseRemoteRepo, pullRequestLookup, pullRequestLookups, selectPullRequest, worktreePullRequests };
1
+ import { a as pullRequestLookup, c as selectPullRequest, i as parseRemoteRepo, l as worktreePullRequests, n as describePullRequest, o as pullRequestLookupAsync, r as endedPullRequest, s as pullRequestLookups, t as checkCounts } from "./pull-request-W1IuLXDt.mjs";
2
+ export { checkCounts, describePullRequest, endedPullRequest, parseRemoteRepo, pullRequestLookup, pullRequestLookupAsync, pullRequestLookups, selectPullRequest, worktreePullRequests };