waterplane 0.1.6 → 0.1.14

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 (656) hide show
  1. package/CHANGELOG.md +146 -1
  2. package/README.md +47 -24
  3. package/SECURITY.md +11 -3
  4. package/deploy/node-version +1 -1
  5. package/node_modules/@waterplane/shared/dist/agentfiles.d.ts +17 -0
  6. package/node_modules/@waterplane/shared/dist/agentfiles.js +60 -5
  7. package/node_modules/@waterplane/shared/dist/agentfiles.js.map +1 -1
  8. package/node_modules/@waterplane/shared/dist/alwaysonwords.d.ts +83 -0
  9. package/node_modules/@waterplane/shared/dist/alwaysonwords.js +215 -0
  10. package/node_modules/@waterplane/shared/dist/alwaysonwords.js.map +1 -0
  11. package/node_modules/@waterplane/shared/dist/assess/sasswords.js +4 -0
  12. package/node_modules/@waterplane/shared/dist/assess/sasswords.js.map +1 -1
  13. package/node_modules/@waterplane/shared/dist/autocompact.js +3 -2
  14. package/node_modules/@waterplane/shared/dist/autocompact.js.map +1 -1
  15. package/node_modules/@waterplane/shared/dist/backendsources.d.ts +11 -1
  16. package/node_modules/@waterplane/shared/dist/backendsources.js.map +1 -1
  17. package/node_modules/@waterplane/shared/dist/branchmode.d.ts +33 -0
  18. package/node_modules/@waterplane/shared/dist/branchmode.js +88 -0
  19. package/node_modules/@waterplane/shared/dist/branchmode.js.map +1 -0
  20. package/node_modules/@waterplane/shared/dist/budget.d.ts +7 -1
  21. package/node_modules/@waterplane/shared/dist/budget.js +11 -3
  22. package/node_modules/@waterplane/shared/dist/budget.js.map +1 -1
  23. package/node_modules/@waterplane/shared/dist/buildstamp.d.ts +37 -0
  24. package/node_modules/@waterplane/shared/dist/buildstamp.js +95 -0
  25. package/node_modules/@waterplane/shared/dist/buildstamp.js.map +1 -0
  26. package/node_modules/@waterplane/shared/dist/burn.d.ts +16 -1
  27. package/node_modules/@waterplane/shared/dist/burn.js +30 -0
  28. package/node_modules/@waterplane/shared/dist/burn.js.map +1 -1
  29. package/node_modules/@waterplane/shared/dist/calday.d.ts +4 -0
  30. package/node_modules/@waterplane/shared/dist/calday.js +25 -0
  31. package/node_modules/@waterplane/shared/dist/calday.js.map +1 -0
  32. package/node_modules/@waterplane/shared/dist/changebrief.d.ts +77 -0
  33. package/node_modules/@waterplane/shared/dist/changebrief.js +70 -0
  34. package/node_modules/@waterplane/shared/dist/changebrief.js.map +1 -0
  35. package/node_modules/@waterplane/shared/dist/clihealth/healthrecord.js +1 -0
  36. package/node_modules/@waterplane/shared/dist/clihealth/healthrecord.js.map +1 -1
  37. package/node_modules/@waterplane/shared/dist/costwindow.d.ts +24 -5
  38. package/node_modules/@waterplane/shared/dist/costwindow.js +35 -15
  39. package/node_modules/@waterplane/shared/dist/costwindow.js.map +1 -1
  40. package/node_modules/@waterplane/shared/dist/desktopfiles.d.ts +100 -0
  41. package/node_modules/@waterplane/shared/dist/desktopfiles.js +192 -0
  42. package/node_modules/@waterplane/shared/dist/desktopfiles.js.map +1 -0
  43. package/node_modules/@waterplane/shared/dist/exposure.d.ts +175 -0
  44. package/node_modules/@waterplane/shared/dist/exposure.js +357 -0
  45. package/node_modules/@waterplane/shared/dist/exposure.js.map +1 -0
  46. package/node_modules/@waterplane/shared/dist/exposurepush.d.ts +60 -0
  47. package/node_modules/@waterplane/shared/dist/exposurepush.js +103 -0
  48. package/node_modules/@waterplane/shared/dist/exposurepush.js.map +1 -0
  49. package/node_modules/@waterplane/shared/dist/healthindex/commits.d.ts +26 -0
  50. package/node_modules/@waterplane/shared/dist/healthindex/commits.js +57 -0
  51. package/node_modules/@waterplane/shared/dist/healthindex/commits.js.map +1 -0
  52. package/node_modules/@waterplane/shared/dist/healthindex/move.d.ts +25 -0
  53. package/node_modules/@waterplane/shared/dist/healthindex/move.js +79 -0
  54. package/node_modules/@waterplane/shared/dist/healthindex/move.js.map +1 -0
  55. package/node_modules/@waterplane/shared/dist/healthindex/readings.d.ts +53 -0
  56. package/node_modules/@waterplane/shared/dist/healthindex/readings.js +154 -0
  57. package/node_modules/@waterplane/shared/dist/healthindex/readings.js.map +1 -0
  58. package/node_modules/@waterplane/shared/dist/healthindex/repoindex.d.ts +41 -0
  59. package/node_modules/@waterplane/shared/dist/healthindex/repoindex.js +19 -0
  60. package/node_modules/@waterplane/shared/dist/healthindex/repoindex.js.map +1 -0
  61. package/node_modules/@waterplane/shared/dist/healthindex/score.d.ts +26 -0
  62. package/node_modules/@waterplane/shared/dist/healthindex/score.js +156 -0
  63. package/node_modules/@waterplane/shared/dist/healthindex/score.js.map +1 -0
  64. package/node_modules/@waterplane/shared/dist/healthindex/types.d.ts +206 -0
  65. package/node_modules/@waterplane/shared/dist/healthindex/types.js +58 -0
  66. package/node_modules/@waterplane/shared/dist/healthindex/types.js.map +1 -0
  67. package/node_modules/@waterplane/shared/dist/healthindex/vs.d.ts +26 -0
  68. package/node_modules/@waterplane/shared/dist/healthindex/vs.js +38 -0
  69. package/node_modules/@waterplane/shared/dist/healthindex/vs.js.map +1 -0
  70. package/node_modules/@waterplane/shared/dist/healthindex/words.d.ts +28 -0
  71. package/node_modules/@waterplane/shared/dist/healthindex/words.js +124 -0
  72. package/node_modules/@waterplane/shared/dist/healthindex/words.js.map +1 -0
  73. package/node_modules/@waterplane/shared/dist/healthindex.d.ts +15 -411
  74. package/node_modules/@waterplane/shared/dist/healthindex.js +8 -602
  75. package/node_modules/@waterplane/shared/dist/healthindex.js.map +1 -1
  76. package/node_modules/@waterplane/shared/dist/hints.js +15 -0
  77. package/node_modules/@waterplane/shared/dist/hints.js.map +1 -1
  78. package/node_modules/@waterplane/shared/dist/index.d.ts +37 -0
  79. package/node_modules/@waterplane/shared/dist/index.js +37 -0
  80. package/node_modules/@waterplane/shared/dist/index.js.map +1 -1
  81. package/node_modules/@waterplane/shared/dist/intent/clean.d.ts +87 -0
  82. package/node_modules/@waterplane/shared/dist/intent/clean.js +51 -3
  83. package/node_modules/@waterplane/shared/dist/intent/clean.js.map +1 -1
  84. package/node_modules/@waterplane/shared/dist/intent/kind.d.ts +40 -1
  85. package/node_modules/@waterplane/shared/dist/intent/kind.js +36 -3
  86. package/node_modules/@waterplane/shared/dist/intent/kind.js.map +1 -1
  87. package/node_modules/@waterplane/shared/dist/intent/types.d.ts +13 -0
  88. package/node_modules/@waterplane/shared/dist/intent/types.js.map +1 -1
  89. package/node_modules/@waterplane/shared/dist/intent/verdict.js +9 -16
  90. package/node_modules/@waterplane/shared/dist/intent/verdict.js.map +1 -1
  91. package/node_modules/@waterplane/shared/dist/intent/words.js +5 -0
  92. package/node_modules/@waterplane/shared/dist/intent/words.js.map +1 -1
  93. package/node_modules/@waterplane/shared/dist/intent.d.ts +2 -2
  94. package/node_modules/@waterplane/shared/dist/intent.js +2 -2
  95. package/node_modules/@waterplane/shared/dist/intent.js.map +1 -1
  96. package/node_modules/@waterplane/shared/dist/launchmodes.d.ts +2 -0
  97. package/node_modules/@waterplane/shared/dist/launchmodes.js +12 -0
  98. package/node_modules/@waterplane/shared/dist/launchmodes.js.map +1 -1
  99. package/node_modules/@waterplane/shared/dist/ledgerspan.d.ts +106 -0
  100. package/node_modules/@waterplane/shared/dist/ledgerspan.js +196 -0
  101. package/node_modules/@waterplane/shared/dist/ledgerspan.js.map +1 -0
  102. package/node_modules/@waterplane/shared/dist/naming.d.ts +3 -1
  103. package/node_modules/@waterplane/shared/dist/naming.js +6 -2
  104. package/node_modules/@waterplane/shared/dist/naming.js.map +1 -1
  105. package/node_modules/@waterplane/shared/dist/netfuse.d.ts +5 -0
  106. package/node_modules/@waterplane/shared/dist/netfuse.js +6 -1
  107. package/node_modules/@waterplane/shared/dist/netfuse.js.map +1 -1
  108. package/node_modules/@waterplane/shared/dist/netretry.d.ts +78 -0
  109. package/node_modules/@waterplane/shared/dist/netretry.js +85 -0
  110. package/node_modules/@waterplane/shared/dist/netretry.js.map +1 -0
  111. package/node_modules/@waterplane/shared/dist/netretrycfg.d.ts +12 -0
  112. package/node_modules/@waterplane/shared/dist/netretrycfg.js +27 -0
  113. package/node_modules/@waterplane/shared/dist/netretrycfg.js.map +1 -0
  114. package/node_modules/@waterplane/shared/dist/nodemin.d.ts +6 -4
  115. package/node_modules/@waterplane/shared/dist/nodemin.js +6 -4
  116. package/node_modules/@waterplane/shared/dist/nodemin.js.map +1 -1
  117. package/node_modules/@waterplane/shared/dist/optins.d.ts +35 -1
  118. package/node_modules/@waterplane/shared/dist/optins.js +39 -1
  119. package/node_modules/@waterplane/shared/dist/optins.js.map +1 -1
  120. package/node_modules/@waterplane/shared/dist/pairing.js +4 -0
  121. package/node_modules/@waterplane/shared/dist/pairing.js.map +1 -1
  122. package/node_modules/@waterplane/shared/dist/passive.js +3 -0
  123. package/node_modules/@waterplane/shared/dist/passive.js.map +1 -1
  124. package/node_modules/@waterplane/shared/dist/plugin/api.d.ts +394 -0
  125. package/node_modules/@waterplane/shared/dist/plugin/api.js +2 -0
  126. package/node_modules/@waterplane/shared/dist/plugin/api.js.map +1 -0
  127. package/node_modules/@waterplane/shared/dist/plugin/backend.d.ts +197 -0
  128. package/node_modules/@waterplane/shared/dist/plugin/backend.js +9 -0
  129. package/node_modules/@waterplane/shared/dist/plugin/backend.js.map +1 -0
  130. package/node_modules/@waterplane/shared/dist/plugin/manifest.d.ts +160 -0
  131. package/node_modules/@waterplane/shared/dist/plugin/manifest.js +98 -0
  132. package/node_modules/@waterplane/shared/dist/plugin/manifest.js.map +1 -0
  133. package/node_modules/@waterplane/shared/dist/plugin/module.d.ts +98 -0
  134. package/node_modules/@waterplane/shared/dist/plugin/module.js +13 -0
  135. package/node_modules/@waterplane/shared/dist/plugin/module.js.map +1 -0
  136. package/node_modules/@waterplane/shared/dist/plugin/version.d.ts +66 -0
  137. package/node_modules/@waterplane/shared/dist/plugin/version.js +86 -0
  138. package/node_modules/@waterplane/shared/dist/plugin/version.js.map +1 -0
  139. package/node_modules/@waterplane/shared/dist/plugin.d.ts +5 -867
  140. package/node_modules/@waterplane/shared/dist/plugin.js +27 -186
  141. package/node_modules/@waterplane/shared/dist/plugin.js.map +1 -1
  142. package/node_modules/@waterplane/shared/dist/pluginlaunch.d.ts +7 -0
  143. package/node_modules/@waterplane/shared/dist/prview.d.ts +23 -0
  144. package/node_modules/@waterplane/shared/dist/prview.js +107 -0
  145. package/node_modules/@waterplane/shared/dist/prview.js.map +1 -0
  146. package/node_modules/@waterplane/shared/dist/queue/queueserial.d.ts +11 -2
  147. package/node_modules/@waterplane/shared/dist/queue/queueserial.js +13 -4
  148. package/node_modules/@waterplane/shared/dist/queue/queueserial.js.map +1 -1
  149. package/node_modules/@waterplane/shared/dist/queue/queuewords.js +1 -0
  150. package/node_modules/@waterplane/shared/dist/queue/queuewords.js.map +1 -1
  151. package/node_modules/@waterplane/shared/dist/repohealth.d.ts +4 -0
  152. package/node_modules/@waterplane/shared/dist/repohealth.js.map +1 -1
  153. package/node_modules/@waterplane/shared/dist/repotwins.d.ts +31 -0
  154. package/node_modules/@waterplane/shared/dist/repotwins.js +52 -0
  155. package/node_modules/@waterplane/shared/dist/repotwins.js.map +1 -0
  156. package/node_modules/@waterplane/shared/dist/requirements.js +4 -1
  157. package/node_modules/@waterplane/shared/dist/requirements.js.map +1 -1
  158. package/node_modules/@waterplane/shared/dist/schedule/schedaction.d.ts +29 -0
  159. package/node_modules/@waterplane/shared/dist/schedule/schedaction.js +22 -0
  160. package/node_modules/@waterplane/shared/dist/schedule/schedaction.js.map +1 -1
  161. package/node_modules/@waterplane/shared/dist/schedule/schedclean.js +26 -0
  162. package/node_modules/@waterplane/shared/dist/schedule/schedclean.js.map +1 -1
  163. package/node_modules/@waterplane/shared/dist/schedule/schedhorizon.d.ts +1 -0
  164. package/node_modules/@waterplane/shared/dist/schedule/schedhorizon.js +1 -0
  165. package/node_modules/@waterplane/shared/dist/schedule/schedhorizon.js.map +1 -1
  166. package/node_modules/@waterplane/shared/dist/schedule.d.ts +1 -1
  167. package/node_modules/@waterplane/shared/dist/schedule.js +1 -1
  168. package/node_modules/@waterplane/shared/dist/schedule.js.map +1 -1
  169. package/node_modules/@waterplane/shared/dist/sessionbudget.d.ts +34 -7
  170. package/node_modules/@waterplane/shared/dist/sessionbudget.js +59 -21
  171. package/node_modules/@waterplane/shared/dist/sessionbudget.js.map +1 -1
  172. package/node_modules/@waterplane/shared/dist/sweep.d.ts +2 -1
  173. package/node_modules/@waterplane/shared/dist/sweep.js +2 -1
  174. package/node_modules/@waterplane/shared/dist/sweep.js.map +1 -1
  175. package/node_modules/@waterplane/shared/dist/tokens.d.ts +4 -3
  176. package/node_modules/@waterplane/shared/dist/tokens.js +9 -7
  177. package/node_modules/@waterplane/shared/dist/tokens.js.map +1 -1
  178. package/node_modules/@waterplane/shared/dist/weekburn.d.ts +144 -0
  179. package/node_modules/@waterplane/shared/dist/weekburn.js +250 -0
  180. package/node_modules/@waterplane/shared/dist/weekburn.js.map +1 -0
  181. package/node_modules/@waterplane/shared/dist/wire/alwayson.d.ts +64 -0
  182. package/node_modules/@waterplane/shared/dist/wire/alwayson.js +7 -0
  183. package/node_modules/@waterplane/shared/dist/wire/alwayson.js.map +1 -0
  184. package/node_modules/@waterplane/shared/dist/wire/backend.d.ts +4 -0
  185. package/node_modules/@waterplane/shared/dist/wire/backendtokens.d.ts +6 -0
  186. package/node_modules/@waterplane/shared/dist/wire/backendtokens.js +0 -9
  187. package/node_modules/@waterplane/shared/dist/wire/backendtokens.js.map +1 -1
  188. package/node_modules/@waterplane/shared/dist/wire/costwindow.d.ts +25 -0
  189. package/node_modules/@waterplane/shared/dist/wire/messages/clienthost.d.ts +15 -1
  190. package/node_modules/@waterplane/shared/dist/wire/messages/clientsession.d.ts +24 -0
  191. package/node_modules/@waterplane/shared/dist/wire/messages/hosttools.d.ts +12 -2
  192. package/node_modules/@waterplane/shared/dist/wire/notify.d.ts +194 -1
  193. package/node_modules/@waterplane/shared/dist/wire/notify.js +139 -1
  194. package/node_modules/@waterplane/shared/dist/wire/notify.js.map +1 -1
  195. package/node_modules/@waterplane/shared/dist/wire/pullrequest.d.ts +42 -0
  196. package/node_modules/@waterplane/shared/dist/wire/pullrequest.js +2 -0
  197. package/node_modules/@waterplane/shared/dist/wire/pullrequest.js.map +1 -0
  198. package/node_modules/@waterplane/shared/dist/wire/repo.d.ts +131 -0
  199. package/node_modules/@waterplane/shared/dist/wire/repo.js +8 -3
  200. package/node_modules/@waterplane/shared/dist/wire/repo.js.map +1 -1
  201. package/node_modules/@waterplane/shared/dist/wire/sent.d.ts +3 -1
  202. package/node_modules/@waterplane/shared/dist/wire/session/contextspark.d.ts +7 -0
  203. package/node_modules/@waterplane/shared/dist/wire/session/info.d.ts +4 -1
  204. package/node_modules/@waterplane/shared/dist/wire/session/launch.d.ts +36 -0
  205. package/node_modules/@waterplane/shared/dist/wire/session.d.ts +1 -1
  206. package/node_modules/@waterplane/shared/dist/wire/telemetry.d.ts +30 -0
  207. package/node_modules/@waterplane/shared/dist/wire/work.d.ts +13 -0
  208. package/node_modules/@waterplane/shared/dist/wire/work.js.map +1 -1
  209. package/node_modules/@waterplane/shared/dist/wordof.d.ts +11 -0
  210. package/node_modules/@waterplane/shared/dist/wordof.js +14 -0
  211. package/node_modules/@waterplane/shared/dist/wordof.js.map +1 -0
  212. package/npm-shrinkwrap.json +3 -3
  213. package/package.json +2 -2
  214. package/packages/extensions/scorecard/waterplane-plugin.json +10 -0
  215. package/packages/host/dist/agentexposure.d.ts +13 -0
  216. package/packages/host/dist/agentexposure.js +90 -0
  217. package/packages/host/dist/agentexposure.js.map +1 -0
  218. package/packages/host/dist/agentintents.js +7 -8
  219. package/packages/host/dist/agentintents.js.map +1 -1
  220. package/packages/host/dist/agentwatch.d.ts +3 -7
  221. package/packages/host/dist/agentwatch.js.map +1 -1
  222. package/packages/host/dist/alwayson.d.ts +18 -0
  223. package/packages/host/dist/alwayson.js +159 -0
  224. package/packages/host/dist/alwayson.js.map +1 -0
  225. package/packages/host/dist/answergate.d.ts +3 -7
  226. package/packages/host/dist/answergate.js.map +1 -1
  227. package/packages/host/dist/attentionstore.d.ts +94 -0
  228. package/packages/host/dist/attentionstore.js +232 -0
  229. package/packages/host/dist/attentionstore.js.map +1 -0
  230. package/packages/host/dist/backends/claude-sources.d.ts +2 -0
  231. package/packages/host/dist/backends/claude-sources.js +12 -0
  232. package/packages/host/dist/backends/claude-sources.js.map +1 -1
  233. package/packages/host/dist/backends/claude.js +3 -2
  234. package/packages/host/dist/backends/claude.js.map +1 -1
  235. package/packages/host/dist/backends/derive.js +1 -0
  236. package/packages/host/dist/backends/derive.js.map +1 -1
  237. package/packages/host/dist/backends/overhead.d.ts +7 -5
  238. package/packages/host/dist/backends/overhead.js +15 -13
  239. package/packages/host/dist/backends/overhead.js.map +1 -1
  240. package/packages/host/dist/backends/registry.js +4 -1
  241. package/packages/host/dist/backends/registry.js.map +1 -1
  242. package/packages/host/dist/backends/types.d.ts +2 -0
  243. package/packages/host/dist/besidespend.d.ts +22 -0
  244. package/packages/host/dist/besidespend.js +65 -0
  245. package/packages/host/dist/besidespend.js.map +1 -0
  246. package/packages/host/dist/boxkit.d.ts +19 -0
  247. package/packages/host/dist/boxkit.js +38 -0
  248. package/packages/host/dist/boxkit.js.map +1 -0
  249. package/packages/host/dist/branchrules.d.ts +14 -0
  250. package/packages/host/dist/branchrules.js +47 -0
  251. package/packages/host/dist/branchrules.js.map +1 -0
  252. package/packages/host/dist/budget.d.ts +3 -2
  253. package/packages/host/dist/budget.js +5 -3
  254. package/packages/host/dist/budget.js.map +1 -1
  255. package/packages/host/dist/builds.d.ts +31 -1
  256. package/packages/host/dist/builds.js +55 -3
  257. package/packages/host/dist/builds.js.map +1 -1
  258. package/packages/host/dist/buildversions.d.ts +2 -0
  259. package/packages/host/dist/buildversions.js +36 -0
  260. package/packages/host/dist/buildversions.js.map +1 -0
  261. package/packages/host/dist/burnwatch.d.ts +23 -11
  262. package/packages/host/dist/burnwatch.js +57 -3
  263. package/packages/host/dist/burnwatch.js.map +1 -1
  264. package/packages/host/dist/changebrief.d.ts +37 -0
  265. package/packages/host/dist/changebrief.js +157 -0
  266. package/packages/host/dist/changebrief.js.map +1 -0
  267. package/packages/host/dist/cli/index.js +1 -1
  268. package/packages/host/dist/cli/index.js.map +1 -1
  269. package/packages/host/dist/clihealth.d.ts +2 -0
  270. package/packages/host/dist/clihealth.js +11 -2
  271. package/packages/host/dist/clihealth.js.map +1 -1
  272. package/packages/host/dist/compliance.d.ts +5 -1
  273. package/packages/host/dist/compliance.js +70 -31
  274. package/packages/host/dist/compliance.js.map +1 -1
  275. package/packages/host/dist/composer.d.ts +3 -1
  276. package/packages/host/dist/composer.js +3 -1
  277. package/packages/host/dist/composer.js.map +1 -1
  278. package/packages/host/dist/context.js +29 -4
  279. package/packages/host/dist/context.js.map +1 -1
  280. package/packages/host/dist/convlog.d.ts +1 -1
  281. package/packages/host/dist/convlog.js +1 -1
  282. package/packages/host/dist/costwindow.d.ts +25 -0
  283. package/packages/host/dist/costwindow.js +63 -1
  284. package/packages/host/dist/costwindow.js.map +1 -1
  285. package/packages/host/dist/ctxlog/ctxagents.js +16 -25
  286. package/packages/host/dist/ctxlog/ctxagents.js.map +1 -1
  287. package/packages/host/dist/ctxlog/ctxcursor.d.ts +36 -1
  288. package/packages/host/dist/ctxlog/ctxcursor.js +96 -2
  289. package/packages/host/dist/ctxlog/ctxcursor.js.map +1 -1
  290. package/packages/host/dist/ctxlog/ctxproject.js +2 -1
  291. package/packages/host/dist/ctxlog/ctxproject.js.map +1 -1
  292. package/packages/host/dist/ctxlog/ctxupdate.js +30 -24
  293. package/packages/host/dist/ctxlog/ctxupdate.js.map +1 -1
  294. package/packages/host/dist/ctxlog/usagerecord.d.ts +28 -0
  295. package/packages/host/dist/ctxlog/usagerecord.js +81 -0
  296. package/packages/host/dist/ctxlog/usagerecord.js.map +1 -0
  297. package/packages/host/dist/diskwatch.d.ts +4 -6
  298. package/packages/host/dist/diskwatch.js +3 -1
  299. package/packages/host/dist/diskwatch.js.map +1 -1
  300. package/packages/host/dist/eraseen.d.ts +6 -0
  301. package/packages/host/dist/eraseen.js +100 -0
  302. package/packages/host/dist/eraseen.js.map +1 -0
  303. package/packages/host/dist/explainjob.d.ts +24 -0
  304. package/packages/host/dist/explainjob.js +80 -0
  305. package/packages/host/dist/explainjob.js.map +1 -0
  306. package/packages/host/dist/exposure.d.ts +56 -0
  307. package/packages/host/dist/exposure.js +371 -0
  308. package/packages/host/dist/exposure.js.map +1 -0
  309. package/packages/host/dist/exposurepush.d.ts +28 -0
  310. package/packages/host/dist/exposurepush.js +136 -0
  311. package/packages/host/dist/exposurepush.js.map +1 -0
  312. package/packages/host/dist/exposurerun.d.ts +18 -0
  313. package/packages/host/dist/exposurerun.js +126 -0
  314. package/packages/host/dist/exposurerun.js.map +1 -0
  315. package/packages/host/dist/exposurewatch.d.ts +29 -0
  316. package/packages/host/dist/exposurewatch.js +127 -0
  317. package/packages/host/dist/exposurewatch.js.map +1 -0
  318. package/packages/host/dist/extensions/scorecard/host/engine.d.mts +54 -0
  319. package/packages/host/dist/extensions/scorecard/host/engine.mjs +303 -0
  320. package/packages/host/dist/extensions/scorecard/host/engine.mjs.map +1 -0
  321. package/packages/host/dist/extensions/scorecard/host/gitslug.d.mts +5 -0
  322. package/packages/host/dist/extensions/scorecard/host/gitslug.mjs +45 -0
  323. package/packages/host/dist/extensions/scorecard/host/gitslug.mjs.map +1 -0
  324. package/packages/host/dist/extensions/scorecard/host/index.d.mts +15 -0
  325. package/packages/host/dist/extensions/scorecard/host/index.mjs +47 -0
  326. package/packages/host/dist/extensions/scorecard/host/index.mjs.map +1 -0
  327. package/packages/host/dist/extensions/scorecard/host/store.d.mts +12 -0
  328. package/packages/host/dist/extensions/scorecard/host/store.mjs +91 -0
  329. package/packages/host/dist/extensions/scorecard/host/store.mjs.map +1 -0
  330. package/packages/host/dist/extensions/scorecard/shared/logic.d.mts +42 -0
  331. package/packages/host/dist/extensions/scorecard/shared/logic.mjs +170 -0
  332. package/packages/host/dist/extensions/scorecard/shared/logic.mjs.map +1 -0
  333. package/packages/host/dist/extensions/scorecard/shared/wire.d.mts +140 -0
  334. package/packages/host/dist/extensions/scorecard/shared/wire.mjs +29 -0
  335. package/packages/host/dist/extensions/scorecard/shared/wire.mjs.map +1 -0
  336. package/packages/host/dist/files.d.ts +14 -12
  337. package/packages/host/dist/files.js +64 -94
  338. package/packages/host/dist/files.js.map +1 -1
  339. package/packages/host/dist/forge/github.d.ts +3 -0
  340. package/packages/host/dist/forge/github.js +96 -0
  341. package/packages/host/dist/forge/github.js.map +1 -0
  342. package/packages/host/dist/forge/index.d.ts +14 -0
  343. package/packages/host/dist/forge/index.js +32 -0
  344. package/packages/host/dist/forge/index.js.map +1 -0
  345. package/packages/host/dist/forge/types.d.ts +58 -0
  346. package/packages/host/dist/forge/types.js +2 -0
  347. package/packages/host/dist/forge/types.js.map +1 -0
  348. package/packages/host/dist/git.d.ts +41 -16
  349. package/packages/host/dist/git.js +162 -101
  350. package/packages/host/dist/git.js.map +1 -1
  351. package/packages/host/dist/gitnotify.d.ts +54 -0
  352. package/packages/host/dist/gitnotify.js +167 -0
  353. package/packages/host/dist/gitnotify.js.map +1 -0
  354. package/packages/host/dist/healthwatch.d.ts +2 -1
  355. package/packages/host/dist/healthwatch.js +4 -2
  356. package/packages/host/dist/healthwatch.js.map +1 -1
  357. package/packages/host/dist/hoststore.js +2 -2
  358. package/packages/host/dist/hoststore.js.map +1 -1
  359. package/packages/host/dist/intents/adapters.js +68 -19
  360. package/packages/host/dist/intents/adapters.js.map +1 -1
  361. package/packages/host/dist/intents/clock.d.ts +6 -3
  362. package/packages/host/dist/intents/clock.js +19 -5
  363. package/packages/host/dist/intents/clock.js.map +1 -1
  364. package/packages/host/dist/intents/contract.d.ts +15 -5
  365. package/packages/host/dist/intents/contract.js.map +1 -1
  366. package/packages/host/dist/intents/disk.d.ts +16 -0
  367. package/packages/host/dist/intents/disk.js +26 -1
  368. package/packages/host/dist/intents/disk.js.map +1 -1
  369. package/packages/host/dist/intents/fire.js +7 -1
  370. package/packages/host/dist/intents/fire.js.map +1 -1
  371. package/packages/host/dist/intents/ladder.js +3 -1
  372. package/packages/host/dist/intents/ladder.js.map +1 -1
  373. package/packages/host/dist/intents/manager.d.ts +3 -3
  374. package/packages/host/dist/intents/manager.js +2 -2
  375. package/packages/host/dist/intents/manager.js.map +1 -1
  376. package/packages/host/dist/intents/watch.d.ts +27 -3
  377. package/packages/host/dist/intents/watch.js +70 -9
  378. package/packages/host/dist/intents/watch.js.map +1 -1
  379. package/packages/host/dist/intents/write.d.ts +28 -1
  380. package/packages/host/dist/intents/write.js +87 -2
  381. package/packages/host/dist/intents/write.js.map +1 -1
  382. package/packages/host/dist/localcistatus.d.ts +22 -0
  383. package/packages/host/dist/localcistatus.js +105 -0
  384. package/packages/host/dist/localcistatus.js.map +1 -0
  385. package/packages/host/dist/main.js +45 -12
  386. package/packages/host/dist/main.js.map +1 -1
  387. package/packages/host/dist/net.d.ts +2 -0
  388. package/packages/host/dist/net.js +11 -2
  389. package/packages/host/dist/net.js.map +1 -1
  390. package/packages/host/dist/netlog.d.ts +40 -0
  391. package/packages/host/dist/netlog.js +165 -0
  392. package/packages/host/dist/netlog.js.map +1 -0
  393. package/packages/host/dist/netretrycfg.d.ts +7 -0
  394. package/packages/host/dist/netretrycfg.js +51 -0
  395. package/packages/host/dist/netretrycfg.js.map +1 -0
  396. package/packages/host/dist/notifyprefs.d.ts +6 -2
  397. package/packages/host/dist/notifyprefs.js +20 -5
  398. package/packages/host/dist/notifyprefs.js.map +1 -1
  399. package/packages/host/dist/notifytypes.d.ts +63 -0
  400. package/packages/host/dist/notifytypes.js +2 -0
  401. package/packages/host/dist/notifytypes.js.map +1 -0
  402. package/packages/host/dist/opendeliveries.js +24 -0
  403. package/packages/host/dist/opendeliveries.js.map +1 -1
  404. package/packages/host/dist/optins.d.ts +28 -1
  405. package/packages/host/dist/optins.js +96 -4
  406. package/packages/host/dist/optins.js.map +1 -1
  407. package/packages/host/dist/peers/agentpeer.js +1 -1
  408. package/packages/host/dist/peers/agentpeer.js.map +1 -1
  409. package/packages/host/dist/peers/jobs.d.ts +2 -4
  410. package/packages/host/dist/peers/jobs.js +6 -1
  411. package/packages/host/dist/peers/jobs.js.map +1 -1
  412. package/packages/host/dist/periodspend.d.ts +22 -3
  413. package/packages/host/dist/periodspend.js +44 -4
  414. package/packages/host/dist/periodspend.js.map +1 -1
  415. package/packages/host/dist/plugins/pluginapi.js +40 -10
  416. package/packages/host/dist/plugins/pluginapi.js.map +1 -1
  417. package/packages/host/dist/plugins/pluginregistry.d.ts +3 -8
  418. package/packages/host/dist/plugins/pluginregistry.js +1 -1
  419. package/packages/host/dist/plugins/pluginregistry.js.map +1 -1
  420. package/packages/host/dist/plugins/plugintoolkit/sessionof.d.ts +47 -0
  421. package/packages/host/dist/plugins/plugintoolkit/sessionof.js +136 -0
  422. package/packages/host/dist/plugins/plugintoolkit/sessionof.js.map +1 -0
  423. package/packages/host/dist/prmergestore.d.ts +31 -0
  424. package/packages/host/dist/prmergestore.js +106 -0
  425. package/packages/host/dist/prmergestore.js.map +1 -0
  426. package/packages/host/dist/protectmain.d.ts +35 -0
  427. package/packages/host/dist/protectmain.js +73 -0
  428. package/packages/host/dist/protectmain.js.map +1 -0
  429. package/packages/host/dist/prpush.d.ts +38 -0
  430. package/packages/host/dist/prpush.js +351 -0
  431. package/packages/host/dist/prpush.js.map +1 -0
  432. package/packages/host/dist/prs.d.ts +118 -0
  433. package/packages/host/dist/prs.js +681 -0
  434. package/packages/host/dist/prs.js.map +1 -0
  435. package/packages/host/dist/push.d.ts +85 -1
  436. package/packages/host/dist/push.js +238 -8
  437. package/packages/host/dist/push.js.map +1 -1
  438. package/packages/host/dist/pushlanded.d.ts +29 -0
  439. package/packages/host/dist/pushlanded.js +61 -0
  440. package/packages/host/dist/pushlanded.js.map +1 -0
  441. package/packages/host/dist/pushreach.d.ts +9 -0
  442. package/packages/host/dist/pushreach.js +102 -0
  443. package/packages/host/dist/pushreach.js.map +1 -0
  444. package/packages/host/dist/pushverdict.d.ts +42 -0
  445. package/packages/host/dist/pushverdict.js +110 -0
  446. package/packages/host/dist/pushverdict.js.map +1 -0
  447. package/packages/host/dist/render.d.ts +57 -0
  448. package/packages/host/dist/render.js +57 -39
  449. package/packages/host/dist/render.js.map +1 -1
  450. package/packages/host/dist/repohealth.js +5 -2
  451. package/packages/host/dist/repohealth.js.map +1 -1
  452. package/packages/host/dist/repohealthapproval.d.ts +3 -0
  453. package/packages/host/dist/repohealthapproval.js +92 -2
  454. package/packages/host/dist/repohealthapproval.js.map +1 -1
  455. package/packages/host/dist/repos.d.ts +7 -1
  456. package/packages/host/dist/repos.js +30 -3
  457. package/packages/host/dist/repos.js.map +1 -1
  458. package/packages/host/dist/reposkill.d.ts +8 -5
  459. package/packages/host/dist/reposkill.js +16 -11
  460. package/packages/host/dist/reposkill.js.map +1 -1
  461. package/packages/host/dist/reposkilltext.d.ts +8 -1
  462. package/packages/host/dist/reposkilltext.js +85 -12
  463. package/packages/host/dist/reposkilltext.js.map +1 -1
  464. package/packages/host/dist/routes/apigitspend.d.ts +2 -0
  465. package/packages/host/dist/routes/apigitspend.js +40 -0
  466. package/packages/host/dist/routes/apigitspend.js.map +1 -0
  467. package/packages/host/dist/routes/apihost.js +17 -0
  468. package/packages/host/dist/routes/apihost.js.map +1 -1
  469. package/packages/host/dist/routes/apiprs.d.ts +2 -0
  470. package/packages/host/dist/routes/apiprs.js +47 -0
  471. package/packages/host/dist/routes/apiprs.js.map +1 -0
  472. package/packages/host/dist/routes/apirepofiles.js +13 -1
  473. package/packages/host/dist/routes/apirepofiles.js.map +1 -1
  474. package/packages/host/dist/routes/apirepowork.d.ts +6 -0
  475. package/packages/host/dist/routes/apirepowork.js +42 -33
  476. package/packages/host/dist/routes/apirepowork.js.map +1 -1
  477. package/packages/host/dist/routes/apiroutes.js +2 -1
  478. package/packages/host/dist/routes/apiroutes.js.map +1 -1
  479. package/packages/host/dist/routes/apisession.js +24 -0
  480. package/packages/host/dist/routes/apisession.js.map +1 -1
  481. package/packages/host/dist/routes/apistats.js +12 -7
  482. package/packages/host/dist/routes/apistats.js.map +1 -1
  483. package/packages/host/dist/routes/apisystem.js +23 -1
  484. package/packages/host/dist/routes/apisystem.js.map +1 -1
  485. package/packages/host/dist/routes/apitable.d.ts +10 -0
  486. package/packages/host/dist/routes/apitable.js.map +1 -1
  487. package/packages/host/dist/routes/apiweekburn.d.ts +2 -0
  488. package/packages/host/dist/routes/apiweekburn.js +30 -0
  489. package/packages/host/dist/routes/apiweekburn.js.map +1 -0
  490. package/packages/host/dist/routes/session.js +10 -0
  491. package/packages/host/dist/routes/session.js.map +1 -1
  492. package/packages/host/dist/routes/system.js +34 -6
  493. package/packages/host/dist/routes/system.js.map +1 -1
  494. package/packages/host/dist/routes/types.d.ts +29 -21
  495. package/packages/host/dist/routes/work/workbuild.js +3 -2
  496. package/packages/host/dist/routes/work/workbuild.js.map +1 -1
  497. package/packages/host/dist/routes/work/workintent.js +6 -2
  498. package/packages/host/dist/routes/work/workintent.js.map +1 -1
  499. package/packages/host/dist/routes/work/workschedule.js +33 -3
  500. package/packages/host/dist/routes/work/workschedule.js.map +1 -1
  501. package/packages/host/dist/screenlog.d.ts +20 -0
  502. package/packages/host/dist/screenlog.js +40 -0
  503. package/packages/host/dist/screenlog.js.map +1 -1
  504. package/packages/host/dist/server/billingwire.d.ts +3 -1
  505. package/packages/host/dist/server/billingwire.js +4 -2
  506. package/packages/host/dist/server/billingwire.js.map +1 -1
  507. package/packages/host/dist/server/clients.d.ts +14 -24
  508. package/packages/host/dist/server/clients.js +81 -11
  509. package/packages/host/dist/server/clients.js.map +1 -1
  510. package/packages/host/dist/server/ctx.d.ts +2 -0
  511. package/packages/host/dist/server/ctxseal.d.ts +1 -1
  512. package/packages/host/dist/server/ctxseal.js +6 -6
  513. package/packages/host/dist/server/ctxseal.js.map +1 -1
  514. package/packages/host/dist/server/deliveries.js +4 -2
  515. package/packages/host/dist/server/deliveries.js.map +1 -1
  516. package/packages/host/dist/server/http.js +2 -2
  517. package/packages/host/dist/server/http.js.map +1 -1
  518. package/packages/host/dist/server/intentDeps.js +13 -6
  519. package/packages/host/dist/server/intentDeps.js.map +1 -1
  520. package/packages/host/dist/server/intentEvents.js +9 -4
  521. package/packages/host/dist/server/intentEvents.js.map +1 -1
  522. package/packages/host/dist/server/scan.js +23 -1
  523. package/packages/host/dist/server/scan.js.map +1 -1
  524. package/packages/host/dist/server/sessionEvents.js +40 -15
  525. package/packages/host/dist/server/sessionEvents.js.map +1 -1
  526. package/packages/host/dist/server/shutdown.d.ts +3 -1
  527. package/packages/host/dist/server/shutdown.js +9 -1
  528. package/packages/host/dist/server/shutdown.js.map +1 -1
  529. package/packages/host/dist/sessionbudget.d.ts +2 -0
  530. package/packages/host/dist/sessionbudget.js +17 -6
  531. package/packages/host/dist/sessionbudget.js.map +1 -1
  532. package/packages/host/dist/sessions/agentpoll.d.ts +42 -0
  533. package/packages/host/dist/sessions/agentpoll.js +193 -0
  534. package/packages/host/dist/sessions/agentpoll.js.map +1 -0
  535. package/packages/host/dist/sessions/apiretry.d.ts +106 -0
  536. package/packages/host/dist/sessions/apiretry.js +387 -0
  537. package/packages/host/dist/sessions/apiretry.js.map +1 -0
  538. package/packages/host/dist/sessions/askwatch.d.ts +62 -0
  539. package/packages/host/dist/sessions/askwatch.js +169 -0
  540. package/packages/host/dist/sessions/askwatch.js.map +1 -0
  541. package/packages/host/dist/sessions/boxes.d.ts +2 -23
  542. package/packages/host/dist/sessions/boxes.js +10 -664
  543. package/packages/host/dist/sessions/boxes.js.map +1 -1
  544. package/packages/host/dist/sessions/boxread.d.ts +47 -0
  545. package/packages/host/dist/sessions/boxread.js +628 -0
  546. package/packages/host/dist/sessions/boxread.js.map +1 -0
  547. package/packages/host/dist/sessions/core.d.ts +22 -1
  548. package/packages/host/dist/sessions/ctxseries.js +3 -0
  549. package/packages/host/dist/sessions/ctxseries.js.map +1 -1
  550. package/packages/host/dist/sessions/drive.d.ts +20 -6
  551. package/packages/host/dist/sessions/drive.js +45 -12
  552. package/packages/host/dist/sessions/drive.js.map +1 -1
  553. package/packages/host/dist/sessions/endsession.d.ts +11 -0
  554. package/packages/host/dist/sessions/endsession.js +71 -0
  555. package/packages/host/dist/sessions/endsession.js.map +1 -0
  556. package/packages/host/dist/sessions/haltall.d.ts +14 -0
  557. package/packages/host/dist/sessions/haltall.js +32 -1
  558. package/packages/host/dist/sessions/haltall.js.map +1 -1
  559. package/packages/host/dist/sessions/knobs.d.ts +11 -0
  560. package/packages/host/dist/sessions/knobs.js +12 -0
  561. package/packages/host/dist/sessions/knobs.js.map +1 -1
  562. package/packages/host/dist/sessions/record.js +7 -2
  563. package/packages/host/dist/sessions/record.js.map +1 -1
  564. package/packages/host/dist/sessions/resume.d.ts +17 -0
  565. package/packages/host/dist/sessions/resume.js +65 -11
  566. package/packages/host/dist/sessions/resume.js.map +1 -1
  567. package/packages/host/dist/sessions/roster.js +3 -0
  568. package/packages/host/dist/sessions/roster.js.map +1 -1
  569. package/packages/host/dist/sessions/sidechannel.d.ts +1 -1
  570. package/packages/host/dist/sessions/sidechannel.js +2 -2
  571. package/packages/host/dist/sessions/tmux.js +21 -2
  572. package/packages/host/dist/sessions/tmux.js.map +1 -1
  573. package/packages/host/dist/sessions/turn.d.ts +15 -58
  574. package/packages/host/dist/sessions/turn.js +19 -358
  575. package/packages/host/dist/sessions/turn.js.map +1 -1
  576. package/packages/host/dist/sessions.d.ts +10 -7
  577. package/packages/host/dist/sessions.js +31 -79
  578. package/packages/host/dist/sessions.js.map +1 -1
  579. package/packages/host/dist/settle.d.ts +30 -2
  580. package/packages/host/dist/settle.js +94 -49
  581. package/packages/host/dist/settle.js.map +1 -1
  582. package/packages/host/dist/setupprefs.d.ts +26 -1
  583. package/packages/host/dist/setupprefs.js +49 -1
  584. package/packages/host/dist/setupprefs.js.map +1 -1
  585. package/packages/host/dist/setupwatch.d.ts +10 -8
  586. package/packages/host/dist/setupwatch.js +19 -16
  587. package/packages/host/dist/setupwatch.js.map +1 -1
  588. package/packages/host/dist/sidecar/sidecarname.d.ts +2 -0
  589. package/packages/host/dist/sidecar/sidecarname.js +5 -1
  590. package/packages/host/dist/sidecar/sidecarname.js.map +1 -1
  591. package/packages/host/dist/sidecar/sidecarroute.d.ts +1 -1
  592. package/packages/host/dist/sidecar/sidecarroute.js +5 -0
  593. package/packages/host/dist/sidecar/sidecarroute.js.map +1 -1
  594. package/packages/host/dist/sidecar.d.ts +1 -1
  595. package/packages/host/dist/sidecar.js +1 -1
  596. package/packages/host/dist/sidecar.js.map +1 -1
  597. package/packages/host/dist/tokenscan.d.ts +4 -4
  598. package/packages/host/dist/tokenscan.js +18 -37
  599. package/packages/host/dist/tokenscan.js.map +1 -1
  600. package/packages/host/dist/tokenstats.js +16 -18
  601. package/packages/host/dist/tokenstats.js.map +1 -1
  602. package/packages/host/dist/transcript/transcriptparse.js +17 -26
  603. package/packages/host/dist/transcript/transcriptparse.js.map +1 -1
  604. package/packages/host/dist/transcript/transcriptturns.d.ts +29 -0
  605. package/packages/host/dist/transcript/transcriptturns.js +27 -0
  606. package/packages/host/dist/transcript/transcriptturns.js.map +1 -1
  607. package/packages/host/dist/transcript.d.ts +1 -1
  608. package/packages/host/dist/transcript.js +1 -1
  609. package/packages/host/dist/transcript.js.map +1 -1
  610. package/packages/host/dist/usagesources.d.ts +1 -1
  611. package/packages/host/dist/usagesources.js +7 -2
  612. package/packages/host/dist/usagesources.js.map +1 -1
  613. package/packages/host/dist/visualskill.js +2 -2
  614. package/packages/host/dist/weekburn.d.ts +79 -0
  615. package/packages/host/dist/weekburn.js +276 -0
  616. package/packages/host/dist/weekburn.js.map +1 -0
  617. package/packages/host/dist/worktreeleftover.d.ts +9 -0
  618. package/packages/host/dist/worktreeleftover.js +17 -1
  619. package/packages/host/dist/worktreeleftover.js.map +1 -1
  620. package/packages/web/dist/assets/demo-DsZGy-MC.js +24 -0
  621. package/packages/web/dist/assets/icons-eqlvjswV.js +1 -0
  622. package/packages/web/dist/assets/index-GHwJuQb3.js +169 -0
  623. package/packages/web/dist/assets/index-VzDSZwwH.css +1 -0
  624. package/packages/web/dist/assets/shared-BWk5jXWb.js +49 -0
  625. package/packages/web/dist/assets/sheets-Dj-0m0DB.js +232 -0
  626. package/packages/web/dist/assets/{sheets-Bjv2L-cG.css → sheets-DoUhPGK0.css} +1 -1
  627. package/packages/web/dist/build-id.txt +1 -1
  628. package/packages/web/dist/buildstamp.json +1 -0
  629. package/packages/web/dist/index.html +7 -7
  630. package/packages/web/dist/sw.js +18 -3
  631. package/release.json +7 -4
  632. package/scripts/windows/wsl-setup.sh +10 -1
  633. package/tools/repohealth/constants.mjs +21 -1
  634. package/tools/repohealth/fixture.json +493 -30
  635. package/tools/repohealth/lang/typescript-resolve.mjs +354 -0
  636. package/tools/repohealth/metrics/graph.mjs +258 -0
  637. package/tools/repohealth/metrics/size.mjs +1 -1
  638. package/tools/repohealth/own.mjs +4 -4
  639. package/tools/repohealth/packs/c.mjs +4 -0
  640. package/tools/repohealth/packs/common.mjs +4 -0
  641. package/tools/repohealth/packs/dart.mjs +4 -0
  642. package/tools/repohealth/packs/kotlin.mjs +8 -0
  643. package/tools/repohealth/packs/python.mjs +8 -0
  644. package/tools/repohealth/packs/shell.mjs +4 -0
  645. package/tools/repohealth/packs/typescript.mjs +278 -7
  646. package/tools/repohealth/readings.mjs +39 -0
  647. package/tools/repohealth/series.mjs +1 -0
  648. package/tools/repohealth/snapshot.mjs +14 -0
  649. package/tools/repohealth/types.mjs +12 -0
  650. package/tools/repohealth.mjs +2 -0
  651. package/packages/web/dist/assets/demo-CXlqlYE4.js +0 -23
  652. package/packages/web/dist/assets/icons-BbqDBVjw.js +0 -1
  653. package/packages/web/dist/assets/index-CgPoyb3Y.css +0 -1
  654. package/packages/web/dist/assets/index-D5JKj8DK.js +0 -169
  655. package/packages/web/dist/assets/shared-eyaskl5l.js +0 -47
  656. package/packages/web/dist/assets/sheets-BzzL2re1.js +0 -204
@@ -0,0 +1,681 @@
1
+ /**
2
+ * The person's open pull requests, and the actions on them (the PR card, P3).
3
+ *
4
+ * EVERY forge call of this module goes through `forge/` (`forgeOrGh`), never `gh`
5
+ * directly. Git calls are `git()`.
6
+ *
7
+ * The list is polled ONLY while a client holds a LEASE on the repo
8
+ * (`localrt.ts`'s model: no socket-close hook here, so a watcher that stops
9
+ * renewing lapses by itself — the phone renews every ~30 s, a lease lasts 60 s,
10
+ * the poll stops with the last watcher). A request never runs `gh pr list`: it is
11
+ * answered from the cache the poll keeps. The actions (merge, auto-merge, close,
12
+ * failing log) are one explicit POST each, from a tap, and run `gh` once.
13
+ *
14
+ * Notifications (checks failed / changes requested / merged or closed off the
15
+ * phone) are raised from the poll, so they exist ONLY while somebody is looking
16
+ * at the card — by design: a background poller per repo is a cost nobody asked for.
17
+ * They go through the same `notify("git", …)` path, so the push prefs gate them.
18
+ *
19
+ * A MERGE'S OUTCOME IS OWNED BY THE READINGS, never by the merge call returning. GitHub may report
20
+ * the merge late (a lagging read), only enqueue it (a merge queue), or merge it after the host's gh
21
+ * gave up waiting. So a merge the person asked for is a RECORD on the watch (`asked`), and whichever
22
+ * read first sees MERGED — the one right after the call, or any later poll — runs `tidyAfterMerge`
23
+ * exactly once (`settleMerged`: the claim is synchronous, the second reader awaits the first's receipt).
24
+ * The "merged off the phone" notice is not sent; instead a tidy no tap is waiting for is said as its
25
+ * own notice carrying the receipt (`tidyNews`), and a tidy that left something needing the person
26
+ * is filed as attention whether or not a tap is waiting.
27
+ * CLOSED-not-merged, or an OPEN record ageing out, drops it and lets the normal notice through.
28
+ * Records are kept on disk (`prmergestore.ts`), so a restart — frequent here — does not turn a
29
+ * queued merge back into somebody else's news.
30
+ */
31
+ import { actionsRunId, prAttentionKey, prChanges, prViewsFrom } from "@waterplane/shared";
32
+ import { branchRules, cachedBranchRules } from "./branchrules.js";
33
+ import { existsSync } from "node:fs";
34
+ import { join } from "node:path";
35
+ import { env, ROOT, STATE_DIR } from "./env.js";
36
+ import { gitDeleteBranch, gitPull, gitRemoteUrl } from "./git.js";
37
+ import { discoverTargets } from "./repos.js";
38
+ import { dueWatchers } from "./localrt.js";
39
+ import { execFileP } from "./proc.js";
40
+ import { forgeOrGh } from "./forge/index.js";
41
+ import { loadAskedMerges, originKey, rehomeTarget, saveAskedMerges } from "./prmergestore.js";
42
+ const NO_PROMPT = { ...process.env, GIT_TERMINAL_PROMPT: "0", GH_PROMPT_DISABLED: "1" };
43
+ const git = (wt, args) => execFileP("git", args, { cwd: wt, timeout: 60_000, env: NO_PROMPT, maxBuffer: 4 * 1024 * 1024 });
44
+ const msg = (e) => String(e.stderr || e?.message || e).trim().split("\n").slice(-3).join(" ");
45
+ // ── timing ───────────────────────────────────────────────────────────────
46
+ export let LEASE_MS = 60_000;
47
+ /**
48
+ * How long a merge the person asked for is awaited. A queue normally lands within hours; a PR the queue
49
+ * ejected stays open, and past a day a later merge is somebody's new decision, so it is news again and
50
+ * its branches are not tidied for the person.
51
+ */
52
+ let askedMs = 24 * 3600_000;
53
+ /**
54
+ * No record outlives this many bounds (a week), whatever a reading would say: an unreadable state is
55
+ * let go, and a MERGED first read after it is no longer assumed the person's — without the merge time
56
+ * the host cannot tell their queued merge from somebody's later one. One bound for a running host
57
+ * (`settleAsked`) and for the file read back after a restart (`loadAsked`), so a restart neither keeps
58
+ * nor loses more than staying up would; it also bounds a record no poll ever reads (nobody opened the card).
59
+ */
60
+ const UNREAD_BOUND = 7;
61
+ const expired = (rec) => Date.now() - rec.at > askedMs * UNREAD_BOUND;
62
+ let pollMs = (() => { const n = Number(env("PRS_POLL_MS")); return Number.isFinite(n) && n > 0 ? Math.max(5_000, n) : 20_000; })();
63
+ /** Test seam: shorten the lease / poll period (no floor). */
64
+ export function setPrTiming(t) {
65
+ if (t.leaseMs !== undefined)
66
+ LEASE_MS = t.leaseMs;
67
+ if (t.askedMs !== undefined)
68
+ askedMs = t.askedMs;
69
+ if (t.pollMs !== undefined)
70
+ pollMs = t.pollMs;
71
+ }
72
+ let rulesLookup = null;
73
+ export function setPrRules(fn) { rulesLookup = fn; }
74
+ const rulesOf = (wt) => (rulesLookup ? rulesLookup(wt) : branchRules(wt));
75
+ /** Test seam: replace (null restores) the tidy's pull — the one git call of the tidy that can throw. */
76
+ let pullFn = null;
77
+ export function setPrGitPull(fn) { pullFn = fn; }
78
+ let deps = null;
79
+ export function setPrNotify(d) { deps = d; }
80
+ const watches = new Map();
81
+ const newWatch = (wt) => {
82
+ let w = watches.get(wt);
83
+ if (!w) {
84
+ w = { holders: new Map(), doc: {}, seq: 0, ours: new Set(), asked: new Map(), tidied: [] };
85
+ watches.set(wt, w);
86
+ }
87
+ return w;
88
+ };
89
+ const watchOf = (wt) => { loadAsked(); return newWatch(wt); };
90
+ // ── asked merges on disk (prmergestore.ts): a restart must not forget a queued merge ──
91
+ /** undefined ⇒ `<state dir>/pr-merges-asked.json`; null ⇒ memory only (tests). */
92
+ let storePath;
93
+ let loaded = false;
94
+ /** Test seam: where the asked merges are kept; also re-arms the load, as a restart would. */
95
+ export function setPrMergeStore(path) { storePath = path; loaded = false; }
96
+ const storeFile = () => (storePath === undefined ? join(STATE_DIR, "pr-merges-asked.json") : storePath);
97
+ /** Once per process (or per `setPrMergeStore`), before any watch is read: the records a previous run kept. */
98
+ function loadAsked() {
99
+ if (loaded)
100
+ return;
101
+ loaded = true;
102
+ const p = storeFile();
103
+ if (!p)
104
+ return;
105
+ let dropped = false;
106
+ const gone = [];
107
+ for (const [wt, m] of loadAskedMerges(p)) {
108
+ for (const [n, a] of m) {
109
+ if (expired(a)) {
110
+ dropped = true;
111
+ continue;
112
+ }
113
+ const w = newWatch(wt);
114
+ if (!w.asked.has(n))
115
+ w.asked.set(n, { ...a });
116
+ }
117
+ if (watches.get(wt)?.asked.size && !existsSync(wt))
118
+ gone.push(wt);
119
+ }
120
+ if (dropped)
121
+ keepAsked();
122
+ if (gone.length)
123
+ rehoming = rehomeAsked(gone).catch((e) => console.warn(`[prs] could not look for moved checkouts: ${msg(e)}`));
124
+ }
125
+ let repoLister = null;
126
+ /** Test seam: which checkouts a record whose folder is gone may move to (null restores: the primary
127
+ * checkouts discovered under ROOT). */
128
+ export function setPrRepoLister(fn) { repoLister = fn; }
129
+ const listRepos = async () => (await discoverTargets(ROOT)).map((t) => ({ path: t.worktreePath, primary: t.isPrimary }));
130
+ let rehoming = Promise.resolve();
131
+ /** Test seam: resolves once the records loaded for a vanished folder have been moved (or left). */
132
+ export function prMergesRehomed() { return rehoming; }
133
+ /**
134
+ * A record whose checkout folder is gone (renamed, moved) goes to the ONE listed primary checkout
135
+ * whose origin is the record's (`rehomeTarget`); several or none ⇒ it stays where it was, said once,
136
+ * and ages out as before. A record without an origin is left exactly as before. A record already
137
+ * under the new path for the same PR is a newer tap's and wins.
138
+ */
139
+ async function rehomeAsked(gone) {
140
+ const listed = (await (repoLister ?? listRepos)()).filter((r) => r.primary && existsSync(r.path));
141
+ const repos = await Promise.all(listed.map(async (r) => ({ path: r.path, origin: originKey(await gitRemoteUrl(r.path)) })));
142
+ let moved = false;
143
+ for (const wt of gone) {
144
+ const from = watches.get(wt);
145
+ if (!from)
146
+ continue;
147
+ for (const [n, rec] of [...from.asked]) {
148
+ if (!rec.origin)
149
+ continue;
150
+ const { to, matches } = rehomeTarget(rec, wt, repos);
151
+ if (!to) {
152
+ console.warn(`[prs] the merge asked for PR #${n} (${rec.origin}) was asked in ${wt}, which is gone, and ${matches ? `${matches} listed checkouts have` : "no listed checkout has"} that origin; it is kept until it ages out`);
153
+ continue;
154
+ }
155
+ from.asked.delete(n);
156
+ const into = newWatch(to);
157
+ if (!into.asked.has(n))
158
+ into.asked.set(n, rec);
159
+ moved = true;
160
+ console.log(`[prs] the merge asked for PR #${n} moved with its checkout: ${wt} → ${to}`);
161
+ }
162
+ if (!from.asked.size && !from.holders.size)
163
+ watches.delete(wt);
164
+ }
165
+ if (moved)
166
+ keepAsked();
167
+ }
168
+ function keepAsked() {
169
+ const p = storeFile();
170
+ if (p)
171
+ saveAskedMerges(p, new Map([...watches].map(([wt, w]) => [wt, w.asked])));
172
+ }
173
+ /** The one way a record goes: only this record (a newer tap's is left), and the file follows. */
174
+ function forgetAsked(w, n, rec) {
175
+ if (w.asked.get(n) !== rec)
176
+ return;
177
+ w.asked.delete(n);
178
+ keepAsked();
179
+ }
180
+ /** Is anything polling this worktree right now? (tests, diagnostics) */
181
+ export function prsPolling(wt) { return !!watches.get(wt)?.timer; }
182
+ /** Merges asked for and not yet settled; and the receipts of tidies the poll ran (tests, diagnostics). */
183
+ export function prMergesAsked(wt) { loadAsked(); return [...(watches.get(wt)?.asked.keys() ?? [])]; }
184
+ export function prTidyReceipts(wt) { return [...(watches.get(wt)?.tidied ?? [])]; }
185
+ /** The cached reading: never runs `gh`. */
186
+ export function cachedPrs(wt) { return watches.get(wt)?.doc ?? {}; }
187
+ /** One `gh pr list`. Failure of any kind is ABSENT (undefined) with a sentence. */
188
+ export async function listPrs(wt, rules) {
189
+ try {
190
+ const raw = await (await forgeOrGh(wt)).listPrs();
191
+ return { prs: prViewsFrom(raw, rules ?? (rulesLookup ? await rulesLookup(wt) : cachedBranchRules(wt))) };
192
+ }
193
+ catch (e) {
194
+ const t = msg(e);
195
+ return { why: /ENOENT/.test(t) ? "gh is not installed on this desktop" : `gh could not list pull requests: ${t.slice(0, 160)}` };
196
+ }
197
+ }
198
+ async function pollOnce(wt, w, seq) {
199
+ // Direct or unread rules: no `gh` call at all — a direct repo's git view costs nothing new.
200
+ const rules = rulesLookup ? await rulesLookup(wt) : cachedBranchRules(wt);
201
+ if (seq !== w.seq)
202
+ return;
203
+ if (!rules || rules.mode === "direct") {
204
+ w.doc = {};
205
+ w.prev = undefined;
206
+ return;
207
+ }
208
+ const r = await listPrs(wt, rules);
209
+ if (seq !== w.seq)
210
+ return; // a newer poll (or a stop) owns the reading now
211
+ if (!r.prs) {
212
+ // Keep the last good list (it says when it is from); say why the refresh failed.
213
+ w.doc = w.doc.prs ? { ...w.doc, why: r.why } : { why: r.why };
214
+ return;
215
+ }
216
+ const changes = prChanges(w.prev, r.prs);
217
+ const titles = new Map((w.prev ?? []).map((p) => [p.number, p.title]));
218
+ w.prev = r.prs;
219
+ w.doc = { prs: r.prs, at: Date.now() };
220
+ const open = new Set(r.prs.map((p) => p.number));
221
+ for (const c of changes) {
222
+ if (c.kind === "gone") {
223
+ if (goneIsOurs(w, c.number))
224
+ continue;
225
+ await goneNews(wt, w, c.number, c.title);
226
+ continue;
227
+ }
228
+ if (!deps || !w.ref)
229
+ continue;
230
+ const key = prAttentionKey(w.ref.id, c.number);
231
+ deps.notify("git", {
232
+ title: `${c.kind === "checks-failed" ? "Check failed" : "Changes requested"} · PR #${c.number}`,
233
+ body: c.kind === "checks-failed" ? `${c.detail ?? "A check"} failed on ${c.title}` : `A reviewer asked for changes on ${c.title}`,
234
+ outcome: "failed", key, tag: `pr-${w.ref.id}-${c.number}`, open: { to: "git", repoId: w.ref.id },
235
+ });
236
+ }
237
+ await settleAsked(wt, w, open, seq, titles);
238
+ // A mark for a PR this reading no longer lists can never meet a "gone" change again: let it go.
239
+ if (seq === w.seq)
240
+ for (const x of w.ours)
241
+ if (!open.has(x))
242
+ w.ours.delete(x);
243
+ }
244
+ /**
245
+ * The ONE answer to "is this PR's disappearance the person's own doing?": a merge still asked for
246
+ * (settled by `settleAsked`), or a mark left by the person's close or by a read that saw their merge
247
+ * MERGED. Consumes the mark, so a disappearance is answered once.
248
+ */
249
+ function goneIsOurs(w, n) {
250
+ return w.ours.delete(n) || w.asked.has(n);
251
+ }
252
+ /**
253
+ * Settle every asked merge this reading can: MERGED tidies (once) and is not news; CLOSED drops the
254
+ * record and IS news; OPEN or unreadable keeps it for a later poll; OPEN past `askedMs` is dropped quietly.
255
+ * Runs inside the one poll in flight, so two polls never settle the same record at once.
256
+ */
257
+ async function settleAsked(wt, w, open, seq, titles) {
258
+ for (const [n, rec] of [...w.asked]) {
259
+ if (seq !== w.seq)
260
+ return;
261
+ if (rec.tidy)
262
+ continue; // a tidy is under way: it owns the record until it settles
263
+ if (expired(rec)) {
264
+ forgetAsked(w, n, rec);
265
+ continue;
266
+ }
267
+ // The age bound is applied to what the reading SAYS, never instead of reading it. Polling runs
268
+ // only while a card holds a lease, so a PR that landed at hour 10 may first be read at hour 30:
269
+ // that MERGED is still the person's merge and is tidied. Only a PR still OPEN past the bound is
270
+ // dropped — a later merge of it is somebody's new decision, so it is news again. An unreadable
271
+ // state (expired gh auth) is kept until it reads, within UNREAD_BOUND bounds of the asking (above).
272
+ const age = Date.now() - rec.at;
273
+ if (open.has(n)) {
274
+ if (age > askedMs)
275
+ forgetAsked(w, n, rec);
276
+ continue;
277
+ }
278
+ const state = await readState(wt, n);
279
+ if (w.asked.get(n) !== rec)
280
+ continue; // the merge call's own read settled it meanwhile
281
+ if (state === "OPEN" && age > askedMs) {
282
+ forgetAsked(w, n, rec);
283
+ continue;
284
+ }
285
+ if (state === "MERGED") {
286
+ // What reaches the person is decided by the tidy itself when it settles (settleMerged).
287
+ const out = await settleMerged(wt, w, n, rec);
288
+ w.tidied = [...w.tidied, out.receipt].slice(-5);
289
+ console.log(`[prs] PR #${n} merged after the tap: ${out.receipt}`);
290
+ }
291
+ else if (state === "CLOSED") {
292
+ forgetAsked(w, n, rec);
293
+ await goneNews(wt, w, n, titles.get(n) ?? `PR #${n}`, state);
294
+ }
295
+ }
296
+ }
297
+ const readState = async (wt, n) => {
298
+ try {
299
+ return (await (await forgeOrGh(wt)).prState(n)).toUpperCase();
300
+ }
301
+ catch {
302
+ return "";
303
+ }
304
+ };
305
+ /** The ONE place an asked merge is tidied: the claim is synchronous, so a second reader gets the first's receipt. */
306
+ function settleMerged(wt, w, n, rec) {
307
+ // The record goes, but its PR may still be in a list a poll is fetching right now: the mark keeps
308
+ // that list's "gone" the person's, not news (review A2c M1).
309
+ w.ours.add(n);
310
+ // The record leaves the disk only once the tidy has settled: a restart mid-tidy finds it and runs
311
+ // the tidy again, which is safe — each step of `tidyAfterMerge` reads "already gone" the second time.
312
+ // Whether a tap is still waiting is read when the tidy SETTLES, not at the claim: a tap that
313
+ // answered "not merged yet" in the gap before its flag dropped is not waiting for this receipt.
314
+ // A tidy that throws (a git read outside any guard) is a not-done tidy like any other: said once,
315
+ // through tidyNews, and never a rejection out of the tap's answer or the poll's other records.
316
+ rec.tidy ??= tidyAfterMerge(wt, n, rec.method, rec.head, rec.base, w.ref)
317
+ .catch((e) => {
318
+ const what = `the tidy stopped: ${msg(e)}`;
319
+ return { receipt: `Merged PR #${n} (${rec.method}). ${NOT_DONE} ${what}.`, notDone: [{ what, routine: false }] };
320
+ })
321
+ .then((tidy) => { tidyNews(w, n, tidy, rec.tap === true); return tidy; })
322
+ .finally(() => forgetAsked(w, n, rec));
323
+ return rec.tidy;
324
+ }
325
+ /**
326
+ * A tidy a later poll ran reaches the person (R-git-025): the tap's receipt promised it, and a
327
+ * partial tidy carries an instruction they need (a squash merge always keeps the local head —
328
+ * "delete it yourself if you are sure"). Read off the tidy's own structured result, never its words:
329
+ * something left that needs the person ⇒ attention, with the receipt as detail; a routine leftover
330
+ * only rides in the receipt of an ok notice.
331
+ *
332
+ * `byTap` (the tap's merge call is waiting and returns this receipt itself) suppresses ONLY the ok
333
+ * notice. Something that needs the person ALWAYS goes through notify: the tap's answer may never
334
+ * reach the phone (its 180 s timeout, a dropped link), and even when it does it is a toast, where
335
+ * the attention item is the durable copy of the instruction — never zero times, never transient only.
336
+ */
337
+ function tidyNews(w, n, tidy, byTap) {
338
+ if (!deps || !w.ref)
339
+ return;
340
+ const key = prAttentionKey(w.ref.id, n);
341
+ const receipt = tidy.receipt;
342
+ // A leftover another owner already filed (the git sink's failed pull) is said in the receipt, never a second item.
343
+ const failed = tidy.notDone.some((x) => !x.routine && !x.filed);
344
+ if (!failed)
345
+ deps.resolveAttention(key, `PR #${n} was merged`);
346
+ if (byTap && !failed)
347
+ return;
348
+ deps.notify("git", {
349
+ title: `PR #${n} merged · ${w.ref.name}`, body: receipt,
350
+ outcome: failed ? "failed" : "ok", key, tag: `pr-${w.ref.id}-${n}`, open: { to: "git", repoId: w.ref.id },
351
+ ...(failed ? { detail: receipt } : {}),
352
+ });
353
+ }
354
+ async function goneNews(wt, w, number, title, known) {
355
+ if (!deps || !w.ref)
356
+ return;
357
+ const state = known ?? await readState(wt, number);
358
+ const word = state === "MERGED" ? "merged" : state === "CLOSED" ? "closed" : "no longer open";
359
+ const key = prAttentionKey(w.ref.id, number);
360
+ deps.resolveAttention(key, `PR #${number} was ${word}`);
361
+ deps.notify("git", {
362
+ title: `PR #${number} ${word} · ${w.ref.name}`, body: title,
363
+ outcome: "ok", tag: `pr-${w.ref.id}-${number}`, open: { to: "git", repoId: w.ref.id },
364
+ });
365
+ }
366
+ /** Start a poll unless one is in flight (then ask for one more right after it). The only place a poll starts. */
367
+ function startPoll(wt, w) {
368
+ if (w.running) {
369
+ w.again = true;
370
+ return;
371
+ }
372
+ const seq = ++w.seq;
373
+ w.running = pollOnce(wt, w, seq).catch(() => undefined).finally(() => {
374
+ w.running = undefined;
375
+ if (w.again) {
376
+ w.again = false;
377
+ if (w.timer) {
378
+ clearTimeout(w.timer);
379
+ w.timer = undefined;
380
+ }
381
+ tick(wt);
382
+ return;
383
+ }
384
+ if (w.holders.size > 0 && !w.timer) {
385
+ w.timer = setTimeout(() => tick(wt), pollMs);
386
+ w.timer.unref?.();
387
+ }
388
+ });
389
+ }
390
+ function tick(wt) {
391
+ const w = watches.get(wt);
392
+ if (!w)
393
+ return;
394
+ w.timer = undefined;
395
+ const { live, lapsed } = dueWatchers([...w.holders].map(([h, until]) => [h, { until, open: true }]), Date.now());
396
+ for (const h of lapsed)
397
+ w.holders.delete(h);
398
+ // Stops with its last watcher; the bump drops a reading still in flight, so a gap never diffs.
399
+ if (live.length === 0) {
400
+ w.prev = undefined;
401
+ w.seq++;
402
+ w.again = false;
403
+ return;
404
+ }
405
+ if (w.running)
406
+ return; // the poll in flight re-arms the timer when it ends
407
+ startPoll(wt, w);
408
+ }
409
+ /**
410
+ * Take (or renew) a lease. The first lease of a worktree polls at once; the
411
+ * answer is whatever is cached NOW (the phone asks again, or the next frame of
412
+ * its renewal carries the fresh list) — a request never waits on `gh`.
413
+ */
414
+ export function leasePrs(wt, holder, ref) {
415
+ const w = watchOf(wt);
416
+ if (ref)
417
+ w.ref = ref;
418
+ w.holders.set(holder, Date.now() + LEASE_MS);
419
+ if (!w.timer && !w.running)
420
+ tick(wt);
421
+ return w.doc;
422
+ }
423
+ /** Drop everything (tests). */
424
+ export function stopAllPrs() {
425
+ for (const w of watches.values()) {
426
+ if (w.timer)
427
+ clearTimeout(w.timer);
428
+ w.holders.clear();
429
+ w.seq++;
430
+ w.again = false;
431
+ }
432
+ watches.clear();
433
+ }
434
+ // ── actions ──────────────────────────────────────────────────────────────
435
+ const isNum = (n) => typeof n === "number" && Number.isInteger(n) && n > 0;
436
+ const METHOD_FLAG = { merge: 1, squash: 1, rebase: 1 };
437
+ const bad = (error) => ({ ok: false, error });
438
+ /** The ONE reading of a requested merge method, for a merge and for auto-merge alike (R-git-023):
439
+ * the person's pick when the repo allows it, refused in words when not, else the first allowed. */
440
+ function methodOf(asked, rules) {
441
+ if (asked === undefined)
442
+ return { method: rules?.allowedMerge[0] };
443
+ if (typeof asked !== "string" || !Object.hasOwn(METHOD_FLAG, asked))
444
+ return { error: "Merge method must be merge, squash or rebase." };
445
+ const method = asked;
446
+ if (rules?.allowedMerge.length && !rules.allowedMerge.includes(method))
447
+ return { error: `This repo does not allow a ${method} merge — it allows ${rules.allowedMerge.join(", ")}.` };
448
+ return { method };
449
+ }
450
+ /** Refresh now so the card is not a poll behind the tap (only while somebody watches; never a second poll). */
451
+ const afterAction = (wt) => {
452
+ const w = watches.get(wt);
453
+ if (w && w.holders.size > 0)
454
+ startPoll(wt, w);
455
+ };
456
+ /**
457
+ * Mark a PR as the person's own BEFORE the forge call: a poll landing while gh is still
458
+ * merging must not report the tap as news (R-git-025). Returns the undo for a failed call.
459
+ */
460
+ const markOurs = (wt, n) => {
461
+ const w = watches.get(wt);
462
+ if (!w || w.holders.size === 0 || w.ours.has(n))
463
+ return () => undefined;
464
+ w.ours.add(n);
465
+ return () => { w.ours.delete(n); };
466
+ };
467
+ export async function mergePr(wt, body) {
468
+ if (!isNum(body.number))
469
+ return bad("Which pull request? (number missing)");
470
+ const n = body.number;
471
+ const rules = await rulesOf(wt);
472
+ const picked = methodOf(body.method, rules);
473
+ if (picked.error)
474
+ return bad(picked.error);
475
+ const method = picked.method;
476
+ let head = "", base = "";
477
+ // What the PR belongs to, whatever this checkout's path later becomes (a folder rename).
478
+ const origin = originKey(await gitRemoteUrl(wt));
479
+ try {
480
+ const v = await (await forgeOrGh(wt)).prInfo(n);
481
+ head = String(v?.headRefName ?? "");
482
+ base = String(v?.baseRefName ?? "");
483
+ if (v?.state && v.state !== "OPEN")
484
+ return bad(`PR #${n} is ${String(v.state).toLowerCase()}, not open.`);
485
+ }
486
+ catch (e) {
487
+ return bad(`Could not read PR #${n}: ${msg(e)}`);
488
+ }
489
+ // Recorded BEFORE the forge call: a poll landing while gh is still merging settles it as the
490
+ // person's own (R-git-025), and any later read that sees MERGED tidies it (R-git-023).
491
+ const w = watchOf(wt);
492
+ const rec = { method: method ?? "merge", head, base, at: Date.now(), tap: true, ...(origin ? { origin } : {}) };
493
+ w.asked.set(n, rec);
494
+ keepAsked();
495
+ try {
496
+ return await mergeAsked(wt, w, n, rec, method, rules);
497
+ }
498
+ finally {
499
+ rec.tap = false;
500
+ }
501
+ }
502
+ async function mergeAsked(wt, w, n, rec, method, rules) {
503
+ const drop = () => forgetAsked(w, n, rec);
504
+ let noAnswer = false;
505
+ try {
506
+ await (await forgeOrGh(wt)).merge(n, method);
507
+ }
508
+ catch (e) {
509
+ // gh ended by a signal (our 60 s timeout) never said what GitHub did: keep the record and read.
510
+ // A worded gh failure is a refusal: drop it, so the PR's later fate is news again — unless a
511
+ // poll already saw it MERGED and tidied it while gh was failing: then that receipt is the answer.
512
+ const x = e;
513
+ if (!x.killed && !x.signal) {
514
+ if (rec.tidy)
515
+ return { ok: true, output: (await rec.tidy).receipt };
516
+ drop();
517
+ return bad(`GitHub did not merge PR #${n}: ${msg(e)}`);
518
+ }
519
+ noAnswer = true;
520
+ }
521
+ afterAction(wt);
522
+ // gh's exit code is NOT the outcome: in a merge-queue repo (or where gh fell back to
523
+ // auto-merge) it exits 0 having only enqueued the PR. Only GitHub's own MERGED lets the
524
+ // host pull the base and delete the head — deleting a queued PR's head closes it.
525
+ const state = await readState(wt, n);
526
+ if (state === "MERGED")
527
+ return { ok: true, output: (await settleMerged(wt, w, n, rec)).receipt };
528
+ if (state === "CLOSED") {
529
+ drop();
530
+ if (w.holders.size > 0)
531
+ w.ours.add(n);
532
+ return { ok: true, output: `PR #${n} was closed, not merged. No branch was touched.` };
533
+ }
534
+ if (rec.tidy)
535
+ return { ok: true, output: (await rec.tidy).receipt }; // a poll saw it merged while this read lagged
536
+ return { ok: true, output: notMergedYet(n, state, rules?.mergeQueue === true, noAnswer) };
537
+ }
538
+ /** No read has seen the PR merged yet: say what is known; the record keeps the promise (settleAsked). */
539
+ function notMergedYet(n, state, queue, noAnswer) {
540
+ const later = "the base is pulled and the head deleted — the PR card checks while it is open, for up to a day.";
541
+ if (noAnswer)
542
+ return `gh did not answer in time on PR #${n}; it may still have merged. No branch was touched yet; if it did merge, ${later}`;
543
+ if (state === "OPEN" && queue)
544
+ return `PR #${n} is queued. No branch was touched; when it lands, ${later}`;
545
+ if (state === "OPEN")
546
+ return `GitHub took the merge of PR #${n} but does not report it merged yet. No branch was touched; when it does, ${later}`;
547
+ return `GitHub accepted the merge of PR #${n}, but its state could not be read back, so no branch was touched yet. Once it reads as merged, ${later}`;
548
+ }
549
+ /** Pull the base branch if checked out, delete the head branch locally and on origin; say what was and was not done. */
550
+ const NOT_DONE = "Not done:";
551
+ async function tidyAfterMerge(wt, n, method, head, base, ref) {
552
+ const did = [`Merged PR #${n} (${method}).`];
553
+ const notDone = [];
554
+ const not = (what, routine = false, filed = false) => { notDone.push({ what, routine, ...(filed ? { filed } : {}) }); };
555
+ let cur = "";
556
+ try {
557
+ cur = (await git(wt, ["rev-parse", "--abbrev-ref", "HEAD"])).stdout.trim();
558
+ }
559
+ catch { /* unknown */ }
560
+ if (!base)
561
+ not("did not pull (the base branch is unknown)");
562
+ // `HEAD` is git's answer on a detached head — a rebase stopped part-way, or a commit checked out:
563
+ // not the routine "another branch" of a linked worktree, so it needs the person.
564
+ else if (cur === "HEAD")
565
+ not(`did not pull ${base} (this checkout is not on a branch — a rebase may have stopped part-way; finish or abort it, then pull)`);
566
+ else if (cur !== base)
567
+ not(`did not pull ${base} (this checkout is on ${cur || "no branch"})`, !!cur);
568
+ else {
569
+ const p = await (pullFn ?? gitPull)(wt, ref); // with the ref, a refused pull is filed like the phone's own (git outcome sink)
570
+ if (p.ok)
571
+ did.push(`Pulled ${base}.`);
572
+ else
573
+ not(`did not pull ${base}: ${(p.error ?? "").split("\n")[0]}`, false, !!ref);
574
+ }
575
+ const safeRef = head && head !== base && /^[A-Za-z0-9._][A-Za-z0-9._/-]*$/.test(head) && !head.includes("..");
576
+ if (!safeRef) {
577
+ not(head ? `kept branch ${head}` : "did not delete the branch (its name is unknown)");
578
+ }
579
+ else {
580
+ if (cur === head)
581
+ not(`kept local branch ${head} (it is checked out)`, true);
582
+ else {
583
+ const d = await gitDeleteBranch(wt, head);
584
+ if (d.ok)
585
+ did.push(`Deleted local branch ${head}.`);
586
+ else if (/not found|did not match/i.test(d.error ?? ""))
587
+ did.push(`Local branch ${head} was already gone.`);
588
+ else
589
+ not(`kept local branch ${head} (git says it is not fully merged here — a squash merge looks like that; delete it yourself if you are sure)`, true);
590
+ }
591
+ try {
592
+ await git(wt, ["push", "origin", "--delete", `refs/heads/${head}`]);
593
+ did.push(`Deleted ${head} on origin.`);
594
+ }
595
+ catch (e) {
596
+ if (/remote ref does not exist|unable to delete|already|not found/i.test(msg(e)))
597
+ did.push(`${head} was already gone on origin.`);
598
+ else
599
+ not(`kept ${head} on origin: ${msg(e).slice(0, 120)}`);
600
+ }
601
+ }
602
+ const receipt = notDone.length ? `${did.join(" ")} ${NOT_DONE} ${notDone.map((x) => x.what).join("; ")}.` : did.join(" ");
603
+ return { receipt, notDone };
604
+ }
605
+ export async function autoMergePr(wt, body) {
606
+ if (!isNum(body.number))
607
+ return bad("Which pull request? (number missing)");
608
+ if (typeof body.on !== "boolean")
609
+ return bad("Say whether auto-merge goes on or off.");
610
+ const n = body.number;
611
+ if (!body.on) {
612
+ try {
613
+ await (await forgeOrGh(wt)).autoMerge(n, false);
614
+ }
615
+ catch (e) {
616
+ return bad(`Could not switch auto-merge off for PR #${n}: ${msg(e)}`);
617
+ }
618
+ afterAction(wt);
619
+ return { ok: true, output: `Auto-merge is off for PR #${n}.` };
620
+ }
621
+ const rules = await rulesOf(wt);
622
+ if (rules && !rules.autoMerge)
623
+ return bad("This repo does not allow auto-merge. Turn on \"Allow auto-merge\" in the repo's GitHub settings, or merge by hand when the checks are green.");
624
+ const picked = methodOf(body.method, rules);
625
+ if (picked.error)
626
+ return bad(picked.error);
627
+ const method = picked.method;
628
+ try {
629
+ await (await forgeOrGh(wt)).autoMerge(n, true, method);
630
+ }
631
+ catch (e) {
632
+ return bad(`Could not switch auto-merge on for PR #${n}: ${msg(e)}`);
633
+ }
634
+ afterAction(wt);
635
+ return { ok: true, output: `Auto-merge is on for PR #${n}: it merges once its checks and reviews allow. Nothing else changes until then.` };
636
+ }
637
+ export async function closePr(wt, body) {
638
+ if (!isNum(body.number))
639
+ return bad("Which pull request? (number missing)");
640
+ const unmark = markOurs(wt, body.number);
641
+ try {
642
+ await (await forgeOrGh(wt)).close(body.number);
643
+ }
644
+ catch (e) {
645
+ unmark();
646
+ return bad(`Could not close PR #${body.number}: ${msg(e)}`);
647
+ }
648
+ afterAction(wt);
649
+ return { ok: true, output: `Closed PR #${body.number}. Its branch was left alone.` };
650
+ }
651
+ const TAIL_LINES = 80;
652
+ const ANSI = /\u001b\[[0-9;?]*[ -/]*[@-~]/g;
653
+ /** The tail of the failing check's Actions log, or the check's own page when it is not an Actions run. */
654
+ export async function failingLog(wt, body) {
655
+ if (!isNum(body.number))
656
+ return bad("Which pull request? (number missing)");
657
+ const n = body.number;
658
+ let pr = (watches.get(wt)?.doc.prs ?? []).find((p) => p.number === n);
659
+ if (!pr)
660
+ pr = (await listPrs(wt)).prs?.find((p) => p.number === n);
661
+ if (!pr)
662
+ return bad(`PR #${n} is not in your open list.`);
663
+ const failed = pr.checks.filter((c) => c.state === "failed");
664
+ const check = (typeof body.check === "string" ? failed.find((c) => c.name === body.check) : undefined) ?? failed[0];
665
+ if (!check)
666
+ return bad(`No check has failed on PR #${n}.`);
667
+ const runId = actionsRunId(check.url);
668
+ if (!runId)
669
+ return { ok: true, url: check.url, output: `${check.name} is not a GitHub Actions run, so there is no log to show here.${check.url ? " Open its page." : ""}` };
670
+ try {
671
+ const stdout = await (await forgeOrGh(wt)).checksLog(runId);
672
+ const lines = stdout.replace(ANSI, "").split("\n").filter((l, i, a) => l.trim() || i < a.length - 1);
673
+ if (!lines.length)
674
+ return { ok: true, url: check.url, output: `${check.name}: the run has no failed-step log yet.` };
675
+ return { ok: true, url: check.url, output: lines.slice(-TAIL_LINES).join("\n") };
676
+ }
677
+ catch (e) {
678
+ return { ok: true, url: check.url, output: `${check.name}: gh could not fetch the log (${msg(e).slice(0, 120)}).${check.url ? " Open its page." : ""}` };
679
+ }
680
+ }
681
+ //# sourceMappingURL=prs.js.map