@joshuafolkken/kit 1.872.0 → 1.879.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 (232) hide show
  1. package/.github/workflows/publish.yml +39 -2
  2. package/README.md +3 -3
  3. package/package.json +6 -2
  4. package/scripts/init/distributed-paths.ts +14 -11
  5. package/scripts/init/hook-command-bootstrap.ts +51 -0
  6. package/scripts/init/hook-command-rewrite.ts +9 -1
  7. package/scripts/init/init-logic.ts +2 -8
  8. package/templates/workflows/ci.yml +6 -2
  9. package/dist/hooks/chunk-25JL6FMS.js +0 -4970
  10. package/dist/hooks/chunk-2ANGT3XM.js +0 -375
  11. package/dist/hooks/chunk-2EI5GBSW.js +0 -42
  12. package/dist/hooks/chunk-2OT5XE2N.js +0 -5014
  13. package/dist/hooks/chunk-33ELOKEV.js +0 -910
  14. package/dist/hooks/chunk-33YRTKM7.js +0 -230
  15. package/dist/hooks/chunk-36JQU5NN.js +0 -77
  16. package/dist/hooks/chunk-3EJBTWVS.js +0 -1769
  17. package/dist/hooks/chunk-3FK5SFAC.js +0 -432
  18. package/dist/hooks/chunk-3PWPYDD2.js +0 -240
  19. package/dist/hooks/chunk-3TQU7TDH.js +0 -375
  20. package/dist/hooks/chunk-3TVLSFZ6.js +0 -432
  21. package/dist/hooks/chunk-3VXYCB4E.js +0 -77
  22. package/dist/hooks/chunk-44M6JXGV.js +0 -3398
  23. package/dist/hooks/chunk-46EEEHC3.js +0 -240
  24. package/dist/hooks/chunk-4A7UVP2P.js +0 -364
  25. package/dist/hooks/chunk-4LFQEZS4.js +0 -137
  26. package/dist/hooks/chunk-4OCX3V2T.js +0 -469
  27. package/dist/hooks/chunk-4OHA5DE7.js +0 -49
  28. package/dist/hooks/chunk-4PMDW3YD.js +0 -68
  29. package/dist/hooks/chunk-4QHBNAI4.js +0 -68
  30. package/dist/hooks/chunk-4SSB3FEE.js +0 -3273
  31. package/dist/hooks/chunk-5A2WQ2CQ.js +0 -5390
  32. package/dist/hooks/chunk-5EVA2JQB.js +0 -5390
  33. package/dist/hooks/chunk-5P7VF5VE.js +0 -3230
  34. package/dist/hooks/chunk-5QWJGGZP.js +0 -49
  35. package/dist/hooks/chunk-5U5EZYG6.js +0 -77
  36. package/dist/hooks/chunk-5VUUF3ZV.js +0 -240
  37. package/dist/hooks/chunk-5WA7UBT3.js +0 -374
  38. package/dist/hooks/chunk-6EBGRQ3Q.js +0 -301
  39. package/dist/hooks/chunk-6TVHWMD3.js +0 -432
  40. package/dist/hooks/chunk-6VAGLEMB.js +0 -68
  41. package/dist/hooks/chunk-75BTXKFJ.js +0 -3424
  42. package/dist/hooks/chunk-75RHN67S.js +0 -137
  43. package/dist/hooks/chunk-76KC3BDD.js +0 -3414
  44. package/dist/hooks/chunk-76SLS7CZ.js +0 -898
  45. package/dist/hooks/chunk-7DHZ4DWT.js +0 -5015
  46. package/dist/hooks/chunk-7INSJDGE.js +0 -458
  47. package/dist/hooks/chunk-7VJ4FTDX.js +0 -268
  48. package/dist/hooks/chunk-7XCYNHQK.js +0 -77
  49. package/dist/hooks/chunk-A5YJ3H7E.js +0 -375
  50. package/dist/hooks/chunk-AAEXXUUL.js +0 -268
  51. package/dist/hooks/chunk-ABVEVV2M.js +0 -432
  52. package/dist/hooks/chunk-ACN3YXFL.js +0 -68
  53. package/dist/hooks/chunk-AD3XE3QZ.js +0 -397
  54. package/dist/hooks/chunk-AENFZPZH.js +0 -230
  55. package/dist/hooks/chunk-AFKRFQ6W.js +0 -68
  56. package/dist/hooks/chunk-AHD5IPWI.js +0 -375
  57. package/dist/hooks/chunk-AMK5JGV7.js +0 -77
  58. package/dist/hooks/chunk-ARN7NCQI.js +0 -425
  59. package/dist/hooks/chunk-AUFY653N.js +0 -3425
  60. package/dist/hooks/chunk-AXQBNFEF.js +0 -375
  61. package/dist/hooks/chunk-AYC7R6U4.js +0 -3316
  62. package/dist/hooks/chunk-AYEA2FJ7.js +0 -5015
  63. package/dist/hooks/chunk-B4HPNY2I.js +0 -375
  64. package/dist/hooks/chunk-B57S3VWT.js +0 -922
  65. package/dist/hooks/chunk-BINZ3PLI.js +0 -364
  66. package/dist/hooks/chunk-BODUSXKK.js +0 -410
  67. package/dist/hooks/chunk-BQBAT2YK.js +0 -375
  68. package/dist/hooks/chunk-BUJEBW75.js +0 -391
  69. package/dist/hooks/chunk-BVNWORKA.js +0 -72
  70. package/dist/hooks/chunk-BWI47LQS.js +0 -5205
  71. package/dist/hooks/chunk-C25HRMJX.js +0 -137
  72. package/dist/hooks/chunk-CBFZNC74.js +0 -375
  73. package/dist/hooks/chunk-CECYXS4Y.js +0 -3424
  74. package/dist/hooks/chunk-CELGUP5F.js +0 -49
  75. package/dist/hooks/chunk-CMHANU3F.js +0 -3442
  76. package/dist/hooks/chunk-CMN372LI.js +0 -68
  77. package/dist/hooks/chunk-CPGZLMMK.js +0 -3299
  78. package/dist/hooks/chunk-CTQKXDC7.js +0 -268
  79. package/dist/hooks/chunk-CYAT4RIT.js +0 -68
  80. package/dist/hooks/chunk-CYTWYCH2.js +0 -5014
  81. package/dist/hooks/chunk-CZSOLRBA.js +0 -77
  82. package/dist/hooks/chunk-D2PIDYJR.js +0 -3438
  83. package/dist/hooks/chunk-DE57HI6T.js +0 -137
  84. package/dist/hooks/chunk-DGXDGAPG.js +0 -5306
  85. package/dist/hooks/chunk-DNYRSYQG.js +0 -5014
  86. package/dist/hooks/chunk-DTAXH2A2.js +0 -240
  87. package/dist/hooks/chunk-E2IZUWI5.js +0 -375
  88. package/dist/hooks/chunk-E4L2K2BL.js +0 -397
  89. package/dist/hooks/chunk-ECXVCCVD.js +0 -3079
  90. package/dist/hooks/chunk-EPHO443D.js +0 -68
  91. package/dist/hooks/chunk-EUFK2BI2.js +0 -375
  92. package/dist/hooks/chunk-EYCD5ZAV.js +0 -137
  93. package/dist/hooks/chunk-F2SDYJU4.js +0 -240
  94. package/dist/hooks/chunk-F4B5D5TF.js +0 -68
  95. package/dist/hooks/chunk-FGEO3NDX.js +0 -432
  96. package/dist/hooks/chunk-FJYI52RE.js +0 -137
  97. package/dist/hooks/chunk-FYTZHIY4.js +0 -3085
  98. package/dist/hooks/chunk-G7JL2A5K.js +0 -375
  99. package/dist/hooks/chunk-GA3ITDBW.js +0 -42
  100. package/dist/hooks/chunk-GDR4H4SV.js +0 -469
  101. package/dist/hooks/chunk-GFKDXPSM.js +0 -2855
  102. package/dist/hooks/chunk-GIMRTKFU.js +0 -566
  103. package/dist/hooks/chunk-GOPHRLGO.js +0 -240
  104. package/dist/hooks/chunk-GX4HO7SJ.js +0 -230
  105. package/dist/hooks/chunk-GZ6FUVIK.js +0 -566
  106. package/dist/hooks/chunk-H5HPY5M5.js +0 -2869
  107. package/dist/hooks/chunk-HCF3OGEE.js +0 -1829
  108. package/dist/hooks/chunk-HDEXAOUM.js +0 -469
  109. package/dist/hooks/chunk-HM2TY3TN.js +0 -469
  110. package/dist/hooks/chunk-HOA7NXA2.js +0 -55
  111. package/dist/hooks/chunk-HOFEWH6H.js +0 -240
  112. package/dist/hooks/chunk-HUUI6S5J.js +0 -2669
  113. package/dist/hooks/chunk-I4D3NVUD.js +0 -469
  114. package/dist/hooks/chunk-I4Q6WAJE.js +0 -68
  115. package/dist/hooks/chunk-IB6N4CR2.js +0 -432
  116. package/dist/hooks/chunk-IFLDYJMD.js +0 -469
  117. package/dist/hooks/chunk-IGU466YD.js +0 -77
  118. package/dist/hooks/chunk-IJCQUHKY.js +0 -375
  119. package/dist/hooks/chunk-IKUMBDJB.js +0 -230
  120. package/dist/hooks/chunk-IM3BDIBJ.js +0 -5005
  121. package/dist/hooks/chunk-IMYMAODK.js +0 -3431
  122. package/dist/hooks/chunk-IN2ZVGXA.js +0 -5005
  123. package/dist/hooks/chunk-ITVJ2MKQ.js +0 -18
  124. package/dist/hooks/chunk-J5RIJYTM.js +0 -2669
  125. package/dist/hooks/chunk-JFLMH4K5.js +0 -3460
  126. package/dist/hooks/chunk-JR25IFML.js +0 -77
  127. package/dist/hooks/chunk-JT5AUXFI.js +0 -432
  128. package/dist/hooks/chunk-JY5YVN6N.js +0 -3234
  129. package/dist/hooks/chunk-K5Q4ETVI.js +0 -391
  130. package/dist/hooks/chunk-K67V2F24.js +0 -137
  131. package/dist/hooks/chunk-KATZESEC.js +0 -3273
  132. package/dist/hooks/chunk-KFH4H7W7.js +0 -469
  133. package/dist/hooks/chunk-KMUEI6RX.js +0 -910
  134. package/dist/hooks/chunk-KMV4OY77.js +0 -3438
  135. package/dist/hooks/chunk-KQAZNWEY.js +0 -137
  136. package/dist/hooks/chunk-KZZR6JER.js +0 -5015
  137. package/dist/hooks/chunk-LAR6DREP.js +0 -77
  138. package/dist/hooks/chunk-LNCJWEZD.js +0 -5015
  139. package/dist/hooks/chunk-LRYD2GLM.js +0 -6
  140. package/dist/hooks/chunk-LXBKYHDV.js +0 -77
  141. package/dist/hooks/chunk-LYLKIUNE.js +0 -5024
  142. package/dist/hooks/chunk-LZKCFOVC.js +0 -432
  143. package/dist/hooks/chunk-M4FCIYRI.js +0 -77
  144. package/dist/hooks/chunk-M5M7327Q.js +0 -3425
  145. package/dist/hooks/chunk-MF72MHSX.js +0 -3455
  146. package/dist/hooks/chunk-MK56LKDO.js +0 -397
  147. package/dist/hooks/chunk-N3MJADY7.js +0 -240
  148. package/dist/hooks/chunk-NFQSUDBN.js +0 -458
  149. package/dist/hooks/chunk-NHREKY45.js +0 -137
  150. package/dist/hooks/chunk-NP5TTAAW.js +0 -375
  151. package/dist/hooks/chunk-NQTLTKTJ.js +0 -2993
  152. package/dist/hooks/chunk-NVRCZPBZ.js +0 -391
  153. package/dist/hooks/chunk-O46HMMLJ.js +0 -469
  154. package/dist/hooks/chunk-OFJGH2L4.js +0 -240
  155. package/dist/hooks/chunk-OLFMCZH5.js +0 -240
  156. package/dist/hooks/chunk-OMCZS46I.js +0 -49
  157. package/dist/hooks/chunk-OQZEZW5G.js +0 -469
  158. package/dist/hooks/chunk-P2MDAT2Y.js +0 -1897
  159. package/dist/hooks/chunk-P3M2JJIF.js +0 -68
  160. package/dist/hooks/chunk-PDVHQITQ.js +0 -3453
  161. package/dist/hooks/chunk-PNT2AMDH.js +0 -391
  162. package/dist/hooks/chunk-PR2LVSY6.js +0 -3445
  163. package/dist/hooks/chunk-PRR5R4JK.js +0 -137
  164. package/dist/hooks/chunk-PXT44QVN.js +0 -566
  165. package/dist/hooks/chunk-PZLWJLAP.js +0 -469
  166. package/dist/hooks/chunk-Q2FEAZJ2.js +0 -77
  167. package/dist/hooks/chunk-Q32WETDO.js +0 -3265
  168. package/dist/hooks/chunk-Q45DUBLE.js +0 -3600
  169. package/dist/hooks/chunk-Q7NZSWQ5.js +0 -240
  170. package/dist/hooks/chunk-QH2JNAMK.js +0 -3085
  171. package/dist/hooks/chunk-QPU5H2OS.js +0 -68
  172. package/dist/hooks/chunk-QRAHZ5TO.js +0 -1829
  173. package/dist/hooks/chunk-QUZ5HPIE.js +0 -469
  174. package/dist/hooks/chunk-QVCRG34O.js +0 -2893
  175. package/dist/hooks/chunk-R3MY4E3S.js +0 -1675
  176. package/dist/hooks/chunk-R6TXJJXP.js +0 -77
  177. package/dist/hooks/chunk-REJU6VT7.js +0 -1829
  178. package/dist/hooks/chunk-REQAQLRC.js +0 -2993
  179. package/dist/hooks/chunk-RFCXPAHH.js +0 -391
  180. package/dist/hooks/chunk-RHI6Y22X.js +0 -137
  181. package/dist/hooks/chunk-RKZVOBBS.js +0 -469
  182. package/dist/hooks/chunk-RL57TT2Y.js +0 -566
  183. package/dist/hooks/chunk-RORDOD4S.js +0 -3321
  184. package/dist/hooks/chunk-RZKYW5P2.js +0 -77
  185. package/dist/hooks/chunk-SJPJ6VSI.js +0 -391
  186. package/dist/hooks/chunk-SKSIJQQQ.js +0 -432
  187. package/dist/hooks/chunk-SSQDZKXG.js +0 -268
  188. package/dist/hooks/chunk-SYHFKE4C.js +0 -77
  189. package/dist/hooks/chunk-TCGNI2ZY.js +0 -42
  190. package/dist/hooks/chunk-TG3WXJF5.js +0 -137
  191. package/dist/hooks/chunk-TH7IJAY5.js +0 -77
  192. package/dist/hooks/chunk-TLZ27PCY.js +0 -240
  193. package/dist/hooks/chunk-U652FXTN.js +0 -566
  194. package/dist/hooks/chunk-UEK47YUF.js +0 -268
  195. package/dist/hooks/chunk-UIO45H3O.js +0 -432
  196. package/dist/hooks/chunk-UNLZEEVH.js +0 -5005
  197. package/dist/hooks/chunk-UNRVF3SZ.js +0 -432
  198. package/dist/hooks/chunk-USLFAFOI.js +0 -3453
  199. package/dist/hooks/chunk-VAEELMLL.js +0 -442
  200. package/dist/hooks/chunk-VALSWLDQ.js +0 -3453
  201. package/dist/hooks/chunk-VC5JEPNY.js +0 -3398
  202. package/dist/hooks/chunk-VEZVK6C7.js +0 -230
  203. package/dist/hooks/chunk-VK5JKFAR.js +0 -49
  204. package/dist/hooks/chunk-VNF2KP7Z.js +0 -469
  205. package/dist/hooks/chunk-VWWCUMW6.js +0 -2669
  206. package/dist/hooks/chunk-W4JARUQV.js +0 -137
  207. package/dist/hooks/chunk-WEOBMNJG.js +0 -2993
  208. package/dist/hooks/chunk-WKJU3J5Y.js +0 -5390
  209. package/dist/hooks/chunk-WMN4TSVF.js +0 -3299
  210. package/dist/hooks/chunk-WNON54PT.js +0 -3469
  211. package/dist/hooks/chunk-WOVKBPPX.js +0 -137
  212. package/dist/hooks/chunk-WRVFORYJ.js +0 -432
  213. package/dist/hooks/chunk-WUBVYGQZ.js +0 -240
  214. package/dist/hooks/chunk-WWULTUOM.js +0 -68
  215. package/dist/hooks/chunk-WXHKKB45.js +0 -4962
  216. package/dist/hooks/chunk-XAI3YTHJ.js +0 -469
  217. package/dist/hooks/chunk-XFZH6JZJ.js +0 -77
  218. package/dist/hooks/chunk-XGPWX6IA.js +0 -137
  219. package/dist/hooks/chunk-XIXXIVGY.js +0 -566
  220. package/dist/hooks/chunk-XKDOYJGA.js +0 -922
  221. package/dist/hooks/chunk-YALTVBHM.js +0 -432
  222. package/dist/hooks/chunk-YEBEPBFK.js +0 -5014
  223. package/dist/hooks/chunk-YI2BQ3DK.js +0 -3441
  224. package/dist/hooks/chunk-YVNBCFGG.js +0 -1829
  225. package/dist/hooks/chunk-YXBN3RGG.js +0 -432
  226. package/dist/hooks/chunk-Z2OOJSW3.js +0 -3163
  227. package/dist/hooks/chunk-ZA3HVBOY.js +0 -2644
  228. package/dist/hooks/chunk-ZKID46U3.js +0 -137
  229. package/dist/hooks/chunk-ZPMU2JV6.js +0 -49
  230. package/dist/hooks/chunk-ZRKY4W7O.js +0 -432
  231. package/dist/hooks/chunk-ZTMRB7LJ.js +0 -268
  232. package/dist/hooks/chunk-ZVPPBQ3L.js +0 -3413
@@ -1,922 +0,0 @@
1
- import {
2
- lane_child_marker,
3
- run_issue_number
4
- } from "./chunk-IKUMBDJB.js";
5
- import {
6
- stamp_file,
7
- time_shell
8
- } from "./chunk-RORDOD4S.js";
9
-
10
- // scripts/git/constants.ts
11
- import { platform } from "node:os";
12
- var GIT_COMMAND_UNIX = "/usr/bin/git";
13
- var PORCELAIN_FLAG = "--porcelain";
14
- function get_git_command() {
15
- if (platform() === "win32") {
16
- return String.raw`"C:\Program Files\Git\cmd\git.exe"`;
17
- }
18
- return GIT_COMMAND_UNIX;
19
- }
20
- function get_git_command_for_spawn() {
21
- if (platform() === "win32") {
22
- return String.raw`C:\Program Files\Git\cmd\git.exe`;
23
- }
24
- return GIT_COMMAND_UNIX;
25
- }
26
- var git_utilities = {
27
- get_git_command,
28
- get_git_command_for_spawn
29
- };
30
-
31
- // scripts/git/git-push-transport.ts
32
- import { execa } from "execa";
33
-
34
- // scripts/git/git-execa-error.ts
35
- function get_exit_code(error) {
36
- if (typeof error !== "object" || error === null) return void 0;
37
- if (!("exitCode" in error)) return void 0;
38
- const { exitCode: exit_code } = error;
39
- return typeof exit_code === "number" ? exit_code : void 0;
40
- }
41
- function has_timed_out(error) {
42
- if (typeof error !== "object" || error === null || !("timedOut" in error)) return false;
43
- return error.timedOut === true;
44
- }
45
- function create_spawn_error(command, exit_code) {
46
- const exit_code_string = exit_code === void 0 ? "unknown" : String(exit_code);
47
- const error_message = `git ${command} exited with code ${exit_code_string}`;
48
- return new Error(error_message, { cause: { exit_code: exit_code_string } });
49
- }
50
-
51
- // scripts/git/git-push-transport.ts
52
- var MS_PER_SECOND = 1e3;
53
- var PUSH_TIMEOUT_SECONDS = 120;
54
- var PUSH_TIMEOUT_MS = PUSH_TIMEOUT_SECONDS * MS_PER_SECOND;
55
- var PUSH_TIMEOUT_LABEL = `${String(PUSH_TIMEOUT_SECONDS)}s`;
56
- var PUSH_TIMEOUT_MESSAGE = "git push timed out";
57
- var PUSH_TIMEOUT_EXIT_CODE = "timeout";
58
- var SSH_KEEPALIVE_OPTIONS = "-o ServerAliveInterval=15 -o ServerAliveCountMax=3";
59
- var SSH_COMMAND_VARIABLE = "GIT_SSH_COMMAND";
60
- var SSH_LEGACY_VARIABLE = "GIT_SSH";
61
- var KEEPALIVE_SSH_COMMAND = `ssh ${SSH_KEEPALIVE_OPTIONS}`;
62
- var SSH_COMMAND_CONFIG_KEY = "core.sshCommand";
63
- var PUSH_SUBCOMMAND = "push";
64
- function to_environment_value(name) {
65
- return process.env[name]?.trim() ?? "";
66
- }
67
- function to_configured_ssh_command() {
68
- const from_command = to_environment_value(SSH_COMMAND_VARIABLE);
69
- return from_command === "" ? to_environment_value(SSH_LEGACY_VARIABLE) : from_command;
70
- }
71
- async function has_configured_ssh_command() {
72
- if (to_configured_ssh_command() !== "") return true;
73
- try {
74
- const git_command_bin = git_utilities.get_git_command_for_spawn();
75
- const { stdout } = await execa(git_command_bin, ["config", "--get", SSH_COMMAND_CONFIG_KEY]);
76
- return stdout.trim() !== "";
77
- } catch {
78
- return false;
79
- }
80
- }
81
- async function to_push_options() {
82
- const should_keep_alive = !await has_configured_ssh_command();
83
- return {
84
- stdio: "inherit",
85
- timeout: PUSH_TIMEOUT_MS,
86
- env: should_keep_alive ? { [SSH_COMMAND_VARIABLE]: KEEPALIVE_SSH_COMMAND } : {}
87
- };
88
- }
89
- async function did_push_time_out(arguments_list) {
90
- const git_command_bin = git_utilities.get_git_command_for_spawn();
91
- const options = await to_push_options();
92
- try {
93
- await execa(git_command_bin, [PUSH_SUBCOMMAND, ...arguments_list], options);
94
- return false;
95
- } catch (error) {
96
- if (has_timed_out(error)) return true;
97
- throw create_spawn_error(PUSH_SUBCOMMAND, get_exit_code(error));
98
- }
99
- }
100
- function to_manual_command(arguments_list) {
101
- return ["git", PUSH_SUBCOMMAND, ...arguments_list].join(" ");
102
- }
103
- function to_retry_notice(arguments_list) {
104
- return `${PUSH_TIMEOUT_MESSAGE} after ${PUSH_TIMEOUT_LABEL} \u2014 retrying once: ${to_manual_command(arguments_list)}`;
105
- }
106
- function create_timeout_error(arguments_list) {
107
- const message = `${PUSH_TIMEOUT_MESSAGE} twice (${PUSH_TIMEOUT_LABEL} each). Re-run it by hand: ${to_manual_command(arguments_list)}`;
108
- return new Error(message, { cause: { exit_code: PUSH_TIMEOUT_EXIT_CODE } });
109
- }
110
- async function push(arguments_list) {
111
- if (!await did_push_time_out(arguments_list)) return;
112
- console.warn(to_retry_notice(arguments_list));
113
- if (!await did_push_time_out(arguments_list)) return;
114
- throw create_timeout_error(arguments_list);
115
- }
116
- var git_push_transport = {
117
- push
118
- };
119
-
120
- // scripts/git/git-spawn.ts
121
- import { execa as execa2 } from "execa";
122
- async function read(arguments_) {
123
- const git_cmd = git_utilities.get_git_command_for_spawn();
124
- const { stdout } = await execa2(git_cmd, arguments_);
125
- return stdout.trimEnd();
126
- }
127
- async function with_output(command, arguments_list) {
128
- const git_command_bin = git_utilities.get_git_command_for_spawn();
129
- try {
130
- await execa2(git_command_bin, [command, ...arguments_list], { stdio: "inherit" });
131
- } catch (error) {
132
- throw create_spawn_error(command, get_exit_code(error));
133
- }
134
- }
135
- var git_spawn = {
136
- read,
137
- with_output
138
- };
139
-
140
- // scripts/git/git-command.ts
141
- async function branch() {
142
- return await git_spawn.read(["rev-parse", "--abbrev-ref", "HEAD"]);
143
- }
144
- async function status() {
145
- return await git_spawn.read(["status", PORCELAIN_FLAG, "--untracked-files=normal"]);
146
- }
147
- async function repository_root() {
148
- return await git_spawn.read(["rev-parse", "--show-toplevel"]);
149
- }
150
- async function head_commit() {
151
- return await git_spawn.read(["rev-parse", "HEAD"]);
152
- }
153
- var GIT_DIRECTORY_ARGUMENTS = [
154
- "rev-parse",
155
- "--absolute-git-dir",
156
- "--path-format=absolute",
157
- "--git-common-dir"
158
- ];
159
- async function git_directories() {
160
- const output = await git_spawn.read([...GIT_DIRECTORY_ARGUMENTS]);
161
- return output.split("\n").filter((line) => line !== "");
162
- }
163
- async function diff_cached(file_path) {
164
- return await git_spawn.read(["diff", "--cached", file_path]);
165
- }
166
- var REFS_REMOTES_ORIGIN_PREFIX = "refs/remotes/origin/";
167
- var NAME_ONLY_FLAG = "--name-only";
168
- var DEFAULT_BRANCH_FALLBACK = "main";
169
- async function get_default_branch() {
170
- try {
171
- const output = await git_spawn.read(["symbolic-ref", "refs/remotes/origin/HEAD"]);
172
- const trimmed = output.trim();
173
- if (trimmed.startsWith(REFS_REMOTES_ORIGIN_PREFIX)) {
174
- return trimmed.slice(REFS_REMOTES_ORIGIN_PREFIX.length);
175
- }
176
- } catch {
177
- }
178
- return DEFAULT_BRANCH_FALLBACK;
179
- }
180
- var MERGE_BASE_COMMAND = "merge-base";
181
- async function reference_exists(reference) {
182
- try {
183
- await git_spawn.read(["rev-parse", "--verify", "--quiet", reference]);
184
- return true;
185
- } catch {
186
- return false;
187
- }
188
- }
189
- async function default_branch_reference() {
190
- const default_branch = await get_default_branch();
191
- const remote_reference = `${REFS_REMOTES_ORIGIN_PREFIX}${default_branch}`;
192
- return await reference_exists(remote_reference) ? remote_reference : default_branch;
193
- }
194
- async function change_base() {
195
- const default_branch = await default_branch_reference();
196
- try {
197
- return await git_spawn.read([MERGE_BASE_COMMAND, default_branch, "HEAD"]);
198
- } catch {
199
- return default_branch;
200
- }
201
- }
202
- async function diff_main(file_path) {
203
- return await git_spawn.read(["diff", await change_base(), "--", file_path]);
204
- }
205
- var NO_PATH_QUOTING = ["-c", "core.quotePath=false"];
206
- var NO_RELATIVE_PATHS = "--no-relative";
207
- var NO_RENAME_DETECTION = "--no-renames";
208
- async function change_base_commit() {
209
- return await git_spawn.read(["rev-parse", await change_base()]);
210
- }
211
- async function diff_main_names() {
212
- return await git_spawn.read([
213
- ...NO_PATH_QUOTING,
214
- "diff",
215
- NAME_ONLY_FLAG,
216
- NO_RELATIVE_PATHS,
217
- NO_RENAME_DETECTION,
218
- await change_base(),
219
- "--"
220
- ]);
221
- }
222
- async function diff_cached_names() {
223
- return await git_spawn.read([
224
- ...NO_PATH_QUOTING,
225
- "diff",
226
- "--cached",
227
- NAME_ONLY_FLAG,
228
- NO_RELATIVE_PATHS,
229
- NO_RENAME_DETECTION
230
- ]);
231
- }
232
- async function diff_main_numstat() {
233
- return await git_spawn.read([
234
- ...NO_PATH_QUOTING,
235
- "diff",
236
- "--numstat",
237
- NO_RELATIVE_PATHS,
238
- NO_RENAME_DETECTION,
239
- await change_base(),
240
- "--"
241
- ]);
242
- }
243
- var WHOLE_TREE_PATHSPEC = ":/";
244
- async function untracked_names() {
245
- return await git_spawn.read([
246
- ...NO_PATH_QUOTING,
247
- "ls-files",
248
- "--others",
249
- "--exclude-standard",
250
- "--full-name",
251
- WHOLE_TREE_PATHSPEC
252
- ]);
253
- }
254
- async function fetch_branch(branch_name) {
255
- const refspec = `+refs/heads/${branch_name}:refs/remotes/origin/${branch_name}`;
256
- return await git_spawn.read(["fetch", "origin", refspec]);
257
- }
258
- async function merge_fast_forward(branch_name) {
259
- return await git_spawn.read(["merge", "--ff-only", `origin/${branch_name}`]);
260
- }
261
- async function merge_branch(branch_name) {
262
- await git_spawn.with_output("merge", [`origin/${branch_name}`]);
263
- }
264
- async function checkout_b(branch_name) {
265
- return await git_spawn.read(["checkout", "-b", branch_name]);
266
- }
267
- async function checkout(branch_name) {
268
- return await git_spawn.read(["checkout", branch_name]);
269
- }
270
- async function commit(message) {
271
- await git_spawn.with_output("commit", ["-m", message]);
272
- }
273
- async function delete_branch(branch_name) {
274
- await git_spawn.read(["branch", "-d", branch_name]);
275
- }
276
- async function commit_count_beyond(base, tip) {
277
- const range = `${base}..${tip}`;
278
- const output = await git_spawn.read(["rev-list", "--count", range]);
279
- const parsed = Number(output);
280
- if (output.length > 0 && Number.isFinite(parsed)) return parsed;
281
- throw new Error(`\`git rev-list --count ${range}\` printed \`${output}\` rather than a count`);
282
- }
283
- function is_exit_code_128(cause) {
284
- return typeof cause === "object" && cause !== null && "exit_code" in cause && cause.exit_code === "128";
285
- }
286
- function is_upstream_not_set_error(error) {
287
- if (!(error instanceof Error)) return false;
288
- const { cause } = error;
289
- return cause !== void 0 && is_exit_code_128(cause);
290
- }
291
- async function push_with_upstream(branch_name) {
292
- await git_push_transport.push(["--set-upstream", "origin", branch_name]);
293
- }
294
- async function push2() {
295
- try {
296
- await git_push_transport.push([]);
297
- } catch (error) {
298
- if (is_upstream_not_set_error(error)) {
299
- const current_branch = await branch();
300
- await push_with_upstream(current_branch);
301
- return;
302
- }
303
- throw error;
304
- }
305
- }
306
- async function pull_fast_forward() {
307
- await git_spawn.with_output("pull", ["--ff-only"]);
308
- }
309
- var SHORT_NAME_FORMAT = "--format=%(refname:short)";
310
- var REMOTES_FLAG = "--remotes";
311
- async function list_branches(flags, pattern) {
312
- try {
313
- const output = await git_spawn.read([
314
- "branch",
315
- "--list",
316
- SHORT_NAME_FORMAT,
317
- ...flags,
318
- pattern
319
- ]);
320
- return output.split("\n").filter((line) => line.trim() !== "");
321
- } catch {
322
- return [];
323
- }
324
- }
325
- async function branch_names(pattern) {
326
- return await list_branches([], pattern);
327
- }
328
- async function branch_names_remote(pattern) {
329
- return await list_branches([REMOTES_FLAG], pattern);
330
- }
331
- async function branch_exists(branch_name) {
332
- const names = await branch_names(branch_name);
333
- return names.length > 0;
334
- }
335
- var ALL_PATHS_PATHSPEC = ":/";
336
- function exclude_pathspec(file_path) {
337
- return `:(exclude,top)${file_path}`;
338
- }
339
- async function add_tracked(excluded_paths) {
340
- const exclusions = excluded_paths.map((file_path) => exclude_pathspec(file_path));
341
- await git_spawn.read(["add", "-u", "--", ALL_PATHS_PATHSPEC, ...exclusions]);
342
- }
343
- async function add_path(file_path) {
344
- await git_spawn.with_output("add", ["--", file_path]);
345
- }
346
- var FIRST_PARENT_FLAG = "--first-parent";
347
- async function log_first_parent(limit, file_path, tip = "HEAD") {
348
- const output = await git_spawn.read([
349
- "log",
350
- FIRST_PARENT_FLAG,
351
- "--format=%H",
352
- `-n`,
353
- String(limit),
354
- tip,
355
- "--",
356
- file_path
357
- ]);
358
- return output.split("\n").filter((line) => line.length > 0);
359
- }
360
- async function show_file(spec) {
361
- return await git_spawn.read(["show", spec]);
362
- }
363
- var MERGE_COUNT_ARGUMENTS = [
364
- "rev-list",
365
- "--count",
366
- "--merges",
367
- FIRST_PARENT_FLAG
368
- ];
369
- function merge_count_arguments(range) {
370
- return [...MERGE_COUNT_ARGUMENTS, range];
371
- }
372
- async function count_merges(range) {
373
- const output = await git_spawn.read(merge_count_arguments(range));
374
- const parsed = Number(output.trim());
375
- return Number.isFinite(parsed) ? parsed : 0;
376
- }
377
- var git_command = {
378
- GIT_DIRECTORY_ARGUMENTS,
379
- branch,
380
- status,
381
- repository_root,
382
- head_commit,
383
- git_directories,
384
- diff_cached,
385
- diff_cached_names,
386
- diff_main,
387
- change_base,
388
- change_base_commit,
389
- diff_main_names,
390
- diff_main_numstat,
391
- untracked_names,
392
- get_default_branch,
393
- default_branch_reference,
394
- fetch_branch,
395
- merge_fast_forward,
396
- merge_branch,
397
- checkout_b,
398
- checkout,
399
- commit,
400
- commit_count_beyond,
401
- delete_branch,
402
- push: push2,
403
- pull_fast_forward,
404
- branch_exists,
405
- branch_names,
406
- branch_names_remote,
407
- add_tracked,
408
- add_path,
409
- log_first_parent,
410
- show_file,
411
- count_merges,
412
- merge_count_arguments,
413
- is_upstream_not_set_error
414
- };
415
-
416
- // scripts/run/run-hold.ts
417
- import { z } from "zod";
418
- var HOLD_PREFIX = "josh-run-hold-";
419
- var UNNUMBERED_ISSUE = "new";
420
- var HOLD_MAX_AGE_HOURS = 8;
421
- var MILLISECONDS_PER_HOUR = 36e5;
422
- var HOLD_MAX_AGE_MS = HOLD_MAX_AGE_HOURS * MILLISECONDS_PER_HOUR;
423
- var RELEASE_COMMAND = "pnpm josh run:release";
424
- var FORCE_RELEASE_COMMAND = `${RELEASE_COMMAND} --force`;
425
- var NOT_IDLE = 'that is not "nothing is running here"';
426
- var FREE_READ = { kind: "free" };
427
- var UNREADABLE_READ = { kind: "unreadable" };
428
- function hold_path(git_directory) {
429
- return stamp_file.stamp_path(HOLD_PREFIX, git_directory);
430
- }
431
- async function worktree_directory() {
432
- const directories = await git_command.git_directories();
433
- return directories[0];
434
- }
435
- async function is_linked_worktree() {
436
- const directories = await git_command.git_directories();
437
- return directories[0] !== void 0 && directories[0] !== directories[1];
438
- }
439
- var run_hold_schema = z.object({
440
- issue: z.string(),
441
- taken_at: z.string(),
442
- pid: z.number()
443
- });
444
- function parse_hold(raw) {
445
- try {
446
- const parsed = run_hold_schema.safeParse(JSON.parse(raw));
447
- return parsed.success ? parsed.data : void 0;
448
- } catch {
449
- return void 0;
450
- }
451
- }
452
- function is_stale(hold, now) {
453
- const taken = Date.parse(hold.taken_at);
454
- if (Number.isNaN(taken)) return true;
455
- return now.getTime() - taken > HOLD_MAX_AGE_MS;
456
- }
457
- function classify(raw, now) {
458
- if (raw === void 0) return FREE_READ;
459
- const hold = parse_hold(raw);
460
- if (hold === void 0) return UNREADABLE_READ;
461
- return { kind: is_stale(hold, now) ? "stale" : "held", hold };
462
- }
463
- function read_hold(target, now = /* @__PURE__ */ new Date()) {
464
- return classify(stamp_file.read_stamp_text(target), now);
465
- }
466
- function build_hold(issue, now) {
467
- return { issue, taken_at: now.toISOString(), pid: process.pid };
468
- }
469
- function write_hold(target, issue, now = /* @__PURE__ */ new Date()) {
470
- const hold = build_hold(issue, now);
471
- stamp_file.write_stamp(target, hold);
472
- return hold;
473
- }
474
- function create_hold(target, issue, now = /* @__PURE__ */ new Date()) {
475
- return stamp_file.create_stamp(target, build_hold(issue, now));
476
- }
477
- async function is_tree_dirty() {
478
- try {
479
- const status2 = await git_command.status();
480
- return status2.trim() !== "";
481
- } catch {
482
- return true;
483
- }
484
- }
485
- function release_hold(target) {
486
- stamp_file.remove_stamp(target);
487
- }
488
- function describe_holder(hold) {
489
- const holder = hold.issue === UNNUMBERED_ISSUE ? "an unnumbered run" : `#${hold.issue}`;
490
- return `${holder}, recorded ${hold.taken_at} (pid ${String(hold.pid)})`;
491
- }
492
- function own_release_command(issue) {
493
- return issue === UNNUMBERED_ISSUE ? RELEASE_COMMAND : `${RELEASE_COMMAND} ${issue}`;
494
- }
495
- function is_own_hold(hold, claimant) {
496
- return hold.issue === claimant;
497
- }
498
- function held_message(hold) {
499
- return `This working tree is already held by ${describe_holder(hold)}. One run at a time per working tree: a second run here commits its files onto the other run's branch. If that record is stale, run \`${FORCE_RELEASE_COMMAND}\` in this working tree \u2014 it removes a record this run did not write, so be sure the run that did has ended \u2014 and ask again.`;
500
- }
501
- function foreign_release_message(hold) {
502
- return `This working tree is held by ${describe_holder(hold)}, and this release did not claim it \u2014 nothing was removed. Release it as that run with \`${own_release_command(hold.issue)}\`, or, once you are sure it has ended, remove the record with \`${FORCE_RELEASE_COMMAND}\`.`;
503
- }
504
- function forced_release_message(hold) {
505
- return `Forced: removed the run record held by ${describe_holder(hold)}.`;
506
- }
507
- function unreadable_message() {
508
- return `This working tree's run record could not be read \u2014 ${NOT_IDLE}. Run \`${FORCE_RELEASE_COMMAND}\` in this working tree to clear it, then ask again.`;
509
- }
510
- function stale_message(hold) {
511
- return `Replaced a stale run record held by ${describe_holder(hold)}: older than ${String(HOLD_MAX_AGE_HOURS)} hours, so the run that wrote it has ended without releasing it.`;
512
- }
513
- function uncommitted_message(hold) {
514
- return `This working tree still has uncommitted changes, and its run record \u2014 held by ${describe_holder(hold)} \u2014 has expired. That is a run which stopped for a person rather than one that finished, so the tree is not free: commit or stash the work, or run \`${own_release_command(hold.issue)}\` once you are done with it, then ask again.`;
515
- }
516
- function race_message(read2, target) {
517
- if (read2.kind === "held") return held_message(read2.hold);
518
- return `A record already exists at ${target} and this run did not write it \u2014 ${NOT_IDLE}. Either another run claimed the tree at the same moment, or the record belongs to another account. Run \`${FORCE_RELEASE_COMMAND}\`, and remove that file by hand if it is still there.`;
519
- }
520
- function unknown_message() {
521
- return `Could not read this working tree's git directory \u2014 ${NOT_IDLE}. Run this from inside the checkout the run will edit.`;
522
- }
523
- var run_hold = {
524
- FORCE_RELEASE_COMMAND,
525
- HOLD_MAX_AGE_HOURS,
526
- HOLD_MAX_AGE_MS,
527
- RELEASE_COMMAND,
528
- UNNUMBERED_ISSUE,
529
- classify,
530
- create_hold,
531
- describe_holder,
532
- foreign_release_message,
533
- forced_release_message,
534
- held_message,
535
- hold_path,
536
- is_linked_worktree,
537
- is_own_hold,
538
- is_tree_dirty,
539
- own_release_command,
540
- parse_hold,
541
- race_message,
542
- read_hold,
543
- release_hold,
544
- stale_message,
545
- uncommitted_message,
546
- unknown_message,
547
- unreadable_message,
548
- worktree_directory,
549
- write_hold
550
- };
551
-
552
- // scripts/run/run-cut.ts
553
- import { execFileSync } from "node:child_process";
554
-
555
- // scripts/backlog/backlog-budget.ts
556
- var MS_PER_MINUTE = 6e4;
557
- var MINUTES_PER_HOUR = 60;
558
- var WHOLE_RUN_BUDGET_HOURS = 8;
559
- var WHOLE_RUN_BUDGET_MINUTES = WHOLE_RUN_BUDGET_HOURS * MINUTES_PER_HOUR;
560
- var WHOLE_RUN_BUDGET_MS = WHOLE_RUN_BUDGET_MINUTES * MS_PER_MINUTE;
561
- var DEFAULT_IDLE_MINUTES = 30;
562
- var DEFAULT_IDLE_MS = DEFAULT_IDLE_MINUTES * MS_PER_MINUTE;
563
- var IDLE_POLL_MINUTES = 5;
564
- var RUN_VERDICT = "run";
565
- var WATCH_VERDICT = "watch";
566
- var STOP_VERDICT = "stop";
567
- var ANSWERS = ["blocked", "candidates", "exhausted", "parked", "unreadable"];
568
- var WHOLE_RUN_REASON = `The whole-run bound of ${String(WHOLE_RUN_BUDGET_HOURS)} hours has passed. An unattended run that has not finished overnight needs a person, not more waiting.`;
569
- var PARKED_REASON = "Nothing opted in can proceed without a person. Report the parked issues and finish.";
570
- var UNREADABLE_REASON = "The backlog listing could not be read, so nothing was offered. Report what the command printed and finish \u2014 it is not an empty backlog.";
571
- var BLOCKED_REASON = "Everything opted in is blocked or already running, so waiting can still change the answer. Poll again at the polling interval.";
572
- var NO_IDLE_WATCH_REASON = "The backlog is empty and the idle watch was turned off with `--idle 0`, so the run finishes here.";
573
- function to_minutes(duration_ms) {
574
- return String(Math.ceil(duration_ms / MS_PER_MINUTE));
575
- }
576
- function max_reached_reason(merged, max_issues) {
577
- return `This run's maximum of ${String(max_issues)} is reached, with ${String(merged)} merged. Report what was done, including how many were picked up during an idle watch, and finish.`;
578
- }
579
- function draining_reason(running, reason) {
580
- return `Start nothing more and poll until the running children merge (running: ${String(running)}). Then report and finish \u2014 ${reason}`;
581
- }
582
- function idle_expired_reason(idle_budget_ms) {
583
- return `The backlog stayed empty for the whole ${to_minutes(idle_budget_ms)}-minute idle watch. Report what was done, including how many were picked up during the watch, and finish.`;
584
- }
585
- function next_ask_minutes(left_ms) {
586
- const left_minutes = Number(to_minutes(left_ms));
587
- return String(Math.min(IDLE_POLL_MINUTES, left_minutes));
588
- }
589
- function idle_watch_reason(left_ms) {
590
- return `The backlog is empty and the idle watch has about ${to_minutes(left_ms)} minutes left. Release the working tree, ask again in ${next_ask_minutes(left_ms)} minutes, and restart the watch the moment a candidate appears.`;
591
- }
592
- function running_watch_reason(running, left_ms) {
593
- return `The backlog is empty and the idle watch has about ${to_minutes(left_ms)} minutes left, with ${String(running)} still running. Keep the working tree until they merge and poll at the polling interval, not the idle poll \u2014 the watch is running down meanwhile.`;
594
- }
595
- function watching_reason(input, left_ms) {
596
- if (input.running === 0) return idle_watch_reason(left_ms);
597
- return running_watch_reason(input.running, left_ms);
598
- }
599
- function taken_by(input) {
600
- return input.merged + input.running;
601
- }
602
- function run_reason(input) {
603
- const { max_issues } = input;
604
- if (max_issues === void 0) return "No maximum was given, so start every issue offered.";
605
- return `Start at most ${String(max_issues - taken_by(input))} more: this run's maximum is ${String(max_issues)}, with ${String(input.merged)} merged and ${String(input.running)} running.`;
606
- }
607
- var ANSWER_STOP_REASONS = {
608
- parked: PARKED_REASON,
609
- unreadable: UNREADABLE_REASON
610
- };
611
- function whole_run_reason(input) {
612
- if (input.now_ms - input.started_at_ms < WHOLE_RUN_BUDGET_MS) return void 0;
613
- return WHOLE_RUN_REASON;
614
- }
615
- function stop_reason(input) {
616
- return ANSWER_STOP_REASONS[input.answer] ?? whole_run_reason(input);
617
- }
618
- function stopping(input, reason) {
619
- if (input.running === 0) return { verdict: STOP_VERDICT, reason };
620
- return { verdict: WATCH_VERDICT, reason: draining_reason(input.running, reason) };
621
- }
622
- function max_decision(input) {
623
- const { max_issues } = input;
624
- if (max_issues === void 0 || taken_by(input) < max_issues) return void 0;
625
- return stopping(input, max_reached_reason(input.merged, max_issues));
626
- }
627
- function idle_decision(input) {
628
- const { idle_budget_ms } = input;
629
- if (idle_budget_ms === void 0) return stopping(input, NO_IDLE_WATCH_REASON);
630
- const left_ms = idle_budget_ms - (input.now_ms - input.active_at_ms);
631
- if (left_ms <= 0) return stopping(input, idle_expired_reason(idle_budget_ms));
632
- return { verdict: WATCH_VERDICT, reason: watching_reason(input, left_ms) };
633
- }
634
- function decide(input) {
635
- const reason = stop_reason(input);
636
- if (reason !== void 0) return stopping(input, reason);
637
- const capped = max_decision(input);
638
- if (capped !== void 0) return capped;
639
- if (input.answer === "candidates") return { verdict: RUN_VERDICT, reason: run_reason(input) };
640
- if (input.answer === "blocked") return { verdict: WATCH_VERDICT, reason: BLOCKED_REASON };
641
- return idle_decision(input);
642
- }
643
- var backlog_budget = {
644
- ANSWERS,
645
- ANSWER_STOP_REASONS,
646
- BLOCKED_REASON,
647
- DEFAULT_IDLE_MINUTES,
648
- DEFAULT_IDLE_MS,
649
- IDLE_POLL_MINUTES,
650
- MS_PER_MINUTE,
651
- NO_IDLE_WATCH_REASON,
652
- PARKED_REASON,
653
- RUN_VERDICT,
654
- STOP_VERDICT,
655
- UNREADABLE_REASON,
656
- WATCH_VERDICT,
657
- WHOLE_RUN_BUDGET_HOURS,
658
- WHOLE_RUN_BUDGET_MINUTES,
659
- WHOLE_RUN_BUDGET_MS,
660
- WHOLE_RUN_REASON,
661
- decide,
662
- draining_reason,
663
- idle_expired_reason,
664
- idle_watch_reason,
665
- max_reached_reason,
666
- run_reason,
667
- running_watch_reason,
668
- taken_by
669
- };
670
-
671
- // scripts/cost-runtime/context-cut-threshold.ts
672
- var CONTEXT_CUT_THRESHOLD = 2e5;
673
- var RECENT_REQUEST_WINDOW = 10;
674
-
675
- // scripts/lane/lane-child-invocation.ts
676
- var CHILD_INVOCATION = "fullrun";
677
- var RESUME_GUIDE = ".claude/skills/workflow-commands/pre-gate-cut.md";
678
- function child_invocation(issue) {
679
- run_issue_number.require_issue_number(issue);
680
- return `${CHILD_INVOCATION} #${issue}`;
681
- }
682
- function resume_invocation(issue) {
683
- const preamble = `Resuming the lane child for issue #${issue} \u2014 do not re-read the workflow-commands entry documents (SKILL.md, fullrun.md). Run \`pnpm josh run:cut --resume ${issue}\` before anything else and follow the matching verdict in ${RESUME_GUIDE}: \`resume\` goes to the gate, \`resume-impl\` continues implementation. Only on \`fresh\` proceed as an ordinary`;
684
- return `${preamble} ${child_invocation(issue)}`;
685
- }
686
- function outage_resume_invocation(issue) {
687
- const preamble = `Resuming the lane child for issue #${issue} after an API disconnection \u2014 your session was restored with its full context, so do not re-read the workflow-commands entry documents (SKILL.md, fullrun.md). Continue the run from where it stopped: run \`pnpm josh run:step ${issue}\` to find the next action, redoing only the last step if it did not complete.`;
688
- return `${preamble} ${child_invocation(issue)}`;
689
- }
690
- var lane_child_invocation = {
691
- CHILD_INVOCATION,
692
- child_invocation,
693
- outage_resume_invocation,
694
- resume_invocation
695
- };
696
-
697
- // scripts/run/run-cut.ts
698
- import { z as z2 } from "zod";
699
- var CUT_PREFIX = "josh-run-cut-";
700
- var PRE_GATE_PHASE = "pre-gate";
701
- var IMPLEMENTATION_PHASE = "implementation";
702
- var IMPLEMENTATION_CONTEXT_THRESHOLD = CONTEXT_CUT_THRESHOLD;
703
- var CUT_MAX_AGE_MS = backlog_budget.WHOLE_RUN_BUDGET_MS;
704
- var CUT_MAX_AGE_HOURS = backlog_budget.WHOLE_RUN_BUDGET_HOURS;
705
- var GIT_READ_TIMEOUT_MS = 5e3;
706
- var END_COMMAND = "pnpm josh run:cut --end";
707
- var READ_COMMAND = "pnpm josh run:cut --json";
708
- var NONE_READ = { kind: "none" };
709
- var UNREADABLE_READ2 = { kind: "unreadable" };
710
- var run_cut_schema = z2.object({
711
- invocation: z2.string(),
712
- issue: z2.string(),
713
- branch: z2.string(),
714
- phase: z2.string(),
715
- cut_at: z2.string(),
716
- is_handed_off: z2.boolean().optional()
717
- });
718
- function cut_path(git_directory) {
719
- return stamp_file.stamp_path(CUT_PREFIX, git_directory);
720
- }
721
- var { worktree_directory: worktree_directory2 } = run_hold;
722
- function invocation_for(issue) {
723
- return lane_child_invocation.child_invocation(issue);
724
- }
725
- function parse_cut(raw) {
726
- try {
727
- const parsed = run_cut_schema.safeParse(JSON.parse(raw));
728
- return parsed.success ? parsed.data : void 0;
729
- } catch {
730
- return void 0;
731
- }
732
- }
733
- function is_expired(cut, now) {
734
- const started = Date.parse(cut.cut_at);
735
- if (Number.isNaN(started)) return true;
736
- return now.getTime() - started > CUT_MAX_AGE_MS;
737
- }
738
- function classify2(raw, now) {
739
- if (raw === void 0) return NONE_READ;
740
- const cut = parse_cut(raw);
741
- if (cut === void 0) return UNREADABLE_READ2;
742
- return { kind: is_expired(cut, now) ? "expired" : "carried", cut };
743
- }
744
- function read_cut(target, now = /* @__PURE__ */ new Date()) {
745
- return classify2(stamp_file.read_stamp_text(target), now);
746
- }
747
- function worktree_git_directory_sync() {
748
- try {
749
- const output = execFileSync(
750
- git_utilities.get_git_command_for_spawn(),
751
- [...git_command.GIT_DIRECTORY_ARGUMENTS],
752
- // git's own diagnostics are discarded: a checkout it cannot describe is already the
753
- // `undefined` below, and a hook that let `fatal: not a git repository` through would print it
754
- // in front of a tool call that is about to be allowed.
755
- // A `PreToolUse` hook holds the tool call while it runs, so the read is bounded rather than
756
- // left to whatever git does.
757
- { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: GIT_READ_TIMEOUT_MS }
758
- );
759
- return output.split("\n").find((line) => line !== "");
760
- } catch {
761
- return void 0;
762
- }
763
- }
764
- function carried_cut_sync(now = /* @__PURE__ */ new Date(), directory = worktree_git_directory_sync()) {
765
- if (directory === void 0) return void 0;
766
- const read2 = read_cut(cut_path(directory), now);
767
- return read2.kind === "carried" ? read2.cut : void 0;
768
- }
769
- function fresh_cut(spec, now) {
770
- return {
771
- invocation: invocation_for(spec.issue),
772
- issue: spec.issue,
773
- branch: spec.branch,
774
- phase: spec.phase,
775
- cut_at: now.toISOString(),
776
- is_handed_off: true
777
- };
778
- }
779
- function begin_cut(target, spec, now = /* @__PURE__ */ new Date()) {
780
- const cut = fresh_cut(spec, now);
781
- return stamp_file.create_stamp(target, cut) ? cut : void 0;
782
- }
783
- function is_declared_cut(cut, issue) {
784
- return cut.is_handed_off === true && cut.invocation === invocation_for(issue);
785
- }
786
- function matches_state(cut, request) {
787
- return cut.branch === request.current_branch && cut.issue === request.issue && request.is_dirty && request.is_held;
788
- }
789
- function is_adopted_cut(cut, issue) {
790
- return cut.is_handed_off === false && cut.invocation === invocation_for(issue);
791
- }
792
- function classify_resume(cut, request) {
793
- if (is_adopted_cut(cut, request.issue)) return "handed-off";
794
- if (!is_declared_cut(cut, request.issue)) return "stale";
795
- return matches_state(cut, request) ? "resume" : "stale";
796
- }
797
- function adopt_cut(target, cut) {
798
- const next = { ...cut, is_handed_off: false };
799
- stamp_file.remove_stamp(target);
800
- return stamp_file.create_stamp(target, next) ? next : void 0;
801
- }
802
- function end_cut(target) {
803
- stamp_file.remove_stamp(target);
804
- }
805
- function tree_is_held(directory) {
806
- if (directory === void 0) return false;
807
- const read2 = run_hold.read_hold(run_hold.hold_path(directory));
808
- return read2.kind === "held" || read2.kind === "stale";
809
- }
810
- async function current_state() {
811
- const branch2 = await git_command.branch();
812
- const is_dirty = await run_hold.is_tree_dirty();
813
- const directory = await worktree_directory2();
814
- return { branch: branch2, is_dirty, is_held: tree_is_held(directory) };
815
- }
816
- function describe_cut(cut) {
817
- return `${cut.invocation} cut at ${cut.cut_at} on ${cut.branch} (${cut.phase})`;
818
- }
819
- function busy_message(cut) {
820
- return `Another process already resumed this cut \u2014 ${describe_cut(cut)}. Nothing was resumed here; a double launch was detected.`;
821
- }
822
- function handed_off_message(cut) {
823
- return `This cut was already handed off to a successor \u2014 ${describe_cut(cut)}. Nothing was resumed here; the run is being carried on by the process that adopted it, so this one has nothing to do.`;
824
- }
825
- function stale_message2(cut) {
826
- return `This cut does not match the current tree \u2014 ${describe_cut(cut)}. Resume failed; verify the branch and the uncommitted work, then clear it with \`${END_COMMAND}\` if the run is over.`;
827
- }
828
- function unreadable_message2() {
829
- return `A cut record is here but could not be read; clear it with \`${END_COMMAND}\` once you know no run is using it. Read it with \`${READ_COMMAND}\`.`;
830
- }
831
- function unknown_message2() {
832
- return "This working tree\u2019s git directory could not be read, so no cut record was acted on.";
833
- }
834
- var run_cut = {
835
- CUT_MAX_AGE_HOURS,
836
- CUT_MAX_AGE_MS,
837
- END_COMMAND,
838
- IMPLEMENTATION_CONTEXT_THRESHOLD,
839
- IMPLEMENTATION_PHASE,
840
- PRE_GATE_PHASE,
841
- adopt_cut,
842
- begin_cut,
843
- busy_message,
844
- carried_cut_sync,
845
- classify: classify2,
846
- classify_resume,
847
- current_state,
848
- cut_path,
849
- describe_cut,
850
- end_cut,
851
- fresh_cut,
852
- handed_off_message,
853
- invocation_for,
854
- is_expired,
855
- read_cut,
856
- stale_message: stale_message2,
857
- unknown_message: unknown_message2,
858
- unreadable_message: unreadable_message2,
859
- worktree_directory: worktree_directory2,
860
- worktree_git_directory_sync
861
- };
862
-
863
- // scripts/git/issue-labels.ts
864
- var NEEDS_DECISION_LABEL = "needs-decision";
865
-
866
- // scripts/rules/shell-segments.ts
867
- var SEGMENT_SEPARATOR = /&&|\|\||;|\n/u;
868
- function segments_of(command) {
869
- return command.split(SEGMENT_SEPARATOR).map((segment) => segment.trim());
870
- }
871
- function is_josh_command(segment, names) {
872
- const named = time_shell.josh_command_of(segment);
873
- if (!named.startsWith(time_shell.JOSH_PREFIX)) return false;
874
- return names.has(named.slice(time_shell.JOSH_PREFIX.length));
875
- }
876
- var shell_segments = {
877
- SEGMENT_SEPARATOR,
878
- is_josh_command,
879
- segments_of
880
- };
881
-
882
- // scripts/rules/lane-park.ts
883
- var NOTIFY_COMMANDS = /* @__PURE__ */ new Set(["notify"]);
884
- var CONFIRMATION_TASK_TYPE = /(?:^|\s)--task-type[=\s]+["']?confirmation\b/u;
885
- function is_confirmation_notify(command) {
886
- return shell_segments.segments_of(command).some(
887
- (segment) => shell_segments.is_josh_command(segment, NOTIFY_COMMANDS) && CONFIRMATION_TASK_TYPE.test(segment)
888
- );
889
- }
890
- var NOTIFY_INVOCATION = /josh\s+(?:notify|nf)\b/u;
891
- function mentions_confirmation_notify(text) {
892
- return NOTIFY_INVOCATION.test(text) && CONFIRMATION_TASK_TYPE.test(text);
893
- }
894
- function is_unparked_stop(command, is_lane_child = lane_child_marker.is_child_of(process.cwd())) {
895
- if (!is_confirmation_notify(command)) return false;
896
- return is_lane_child;
897
- }
898
- var APPLIES_NEEDS_DECISION = new RegExp(
899
- String.raw`(?:labels\[\]=|--add-label[= ]'?)${NEEDS_DECISION_LABEL}\b`,
900
- "u"
901
- );
902
- function records_the_park(command) {
903
- return APPLIES_NEEDS_DECISION.test(command);
904
- }
905
- var LANE_PARK_REASON = '\u26D4 lane child park: this session is a dispatched lane child, and a stop that waits on a person must leave the question on the Issue before it sends this Telegram \u2014 otherwise the parent finds an OPEN Issue with `in-progress` and no question, and a person cannot tell what to answer (joshuafolkken/kit#2034 measured this twice in one run). The child is the only process that knows the question, the options and whether it stashed, so it records the park itself rather than leaving the parent to guess from a log. Before you notify and stop: apply `needs-decision` and post a comment carrying the question, the options, and whether work was stashed \u2014 `gh api repos/{owner}/{repo}/issues/<N>/labels -f \'labels[]=needs-decision\'` then `pnpm josh issue:comment <N> --body-file <path>`. If this stop is a `needs-human-review` or `already-done` one, that label is already on the Issue and there is nothing to add. Then reissue this notify \u2014 it fires once per run and cannot repeat on the call in hand. The procedure is `.claude/skills/workflow-commands/pre-gate-cut.md` \u2192 "A lane child records its park before it stops", and the park itself is `backlogrun-park.md` \u2192 "park and continue".';
906
- var lane_park = {
907
- LANE_PARK_REASON,
908
- is_confirmation_notify,
909
- is_unparked_stop,
910
- mentions_confirmation_notify,
911
- records_the_park
912
- };
913
-
914
- export {
915
- git_utilities,
916
- shell_segments,
917
- CONTEXT_CUT_THRESHOLD,
918
- RECENT_REQUEST_WINDOW,
919
- run_hold,
920
- run_cut,
921
- lane_park
922
- };