@joshuafolkken/kit 1.872.0 → 1.881.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 (256) hide show
  1. package/.github/workflows/publish.yml +39 -2
  2. package/README.md +3 -3
  3. package/dist/hooks/batch-guard.js +4 -4
  4. package/dist/hooks/{chunk-KABG6AEW.js → chunk-264QY6KS.js} +7 -0
  5. package/dist/hooks/{chunk-I4D3NVUD.js → chunk-36UE53LS.js} +2 -2
  6. package/dist/hooks/{chunk-WCYPBPJC.js → chunk-4OXFU3MK.js} +8 -8
  7. package/dist/hooks/{chunk-ABVEVV2M.js → chunk-6MQCXEEA.js} +1 -1
  8. package/dist/hooks/{chunk-46EEEHC3.js → chunk-FNFOLFFV.js} +1 -1
  9. package/dist/hooks/{chunk-5U5EZYG6.js → chunk-FRJKVSK3.js} +2 -2
  10. package/dist/hooks/{chunk-2RUPMGGV.js → chunk-PRDCNGA6.js} +4 -4
  11. package/dist/hooks/{chunk-WMN4TSVF.js → chunk-VGYSA2NT.js} +2 -2
  12. package/dist/hooks/{chunk-A5YJ3H7E.js → chunk-Y5OYCU2F.js} +3 -3
  13. package/dist/hooks/{chunk-4QHBNAI4.js → chunk-ZBK4XRAS.js} +3 -3
  14. package/dist/hooks/codex-hook-adapter.js +10 -10
  15. package/dist/hooks/duplicate-read-guard.js +5 -5
  16. package/dist/hooks/format-edited.js +2 -2
  17. package/dist/hooks/investigation-guard.js +5 -5
  18. package/dist/hooks/pretool-guard.js +9 -9
  19. package/dist/hooks/stop-guard.js +3 -3
  20. package/dist/josh.js +7 -0
  21. package/package.json +6 -2
  22. package/scripts/init/distributed-paths.ts +14 -11
  23. package/scripts/init/hook-command-bootstrap.ts +51 -0
  24. package/scripts/init/hook-command-rewrite.ts +9 -1
  25. package/scripts/init/init-logic.ts +2 -8
  26. package/scripts/josh/__snapshots__/josh-command-map.test.ts.snap +10 -0
  27. package/scripts/josh/josh-command-map.ts +1 -0
  28. package/scripts/josh/josh-commands-project.ts +6 -0
  29. package/scripts/registry-migration/migrate-logic.ts +229 -0
  30. package/scripts/registry-migration/migrate.ts +280 -0
  31. package/scripts/registry-migration/user-npmrc.ts +15 -0
  32. package/templates/workflows/ci.yml +6 -2
  33. package/dist/hooks/chunk-25JL6FMS.js +0 -4970
  34. package/dist/hooks/chunk-2ANGT3XM.js +0 -375
  35. package/dist/hooks/chunk-2EI5GBSW.js +0 -42
  36. package/dist/hooks/chunk-2OT5XE2N.js +0 -5014
  37. package/dist/hooks/chunk-2XIGZQMQ.js +0 -3299
  38. package/dist/hooks/chunk-33ELOKEV.js +0 -910
  39. package/dist/hooks/chunk-33YRTKM7.js +0 -230
  40. package/dist/hooks/chunk-36JQU5NN.js +0 -77
  41. package/dist/hooks/chunk-3EJBTWVS.js +0 -1769
  42. package/dist/hooks/chunk-3FK5SFAC.js +0 -432
  43. package/dist/hooks/chunk-3PWPYDD2.js +0 -240
  44. package/dist/hooks/chunk-3TQU7TDH.js +0 -375
  45. package/dist/hooks/chunk-3TVLSFZ6.js +0 -432
  46. package/dist/hooks/chunk-3VXYCB4E.js +0 -77
  47. package/dist/hooks/chunk-44M6JXGV.js +0 -3398
  48. package/dist/hooks/chunk-4A7UVP2P.js +0 -364
  49. package/dist/hooks/chunk-4LFQEZS4.js +0 -137
  50. package/dist/hooks/chunk-4OCX3V2T.js +0 -469
  51. package/dist/hooks/chunk-4OHA5DE7.js +0 -49
  52. package/dist/hooks/chunk-4PMDW3YD.js +0 -68
  53. package/dist/hooks/chunk-4SSB3FEE.js +0 -3273
  54. package/dist/hooks/chunk-5A2WQ2CQ.js +0 -5390
  55. package/dist/hooks/chunk-5EVA2JQB.js +0 -5390
  56. package/dist/hooks/chunk-5P7VF5VE.js +0 -3230
  57. package/dist/hooks/chunk-5QWJGGZP.js +0 -49
  58. package/dist/hooks/chunk-5VUUF3ZV.js +0 -240
  59. package/dist/hooks/chunk-5WA7UBT3.js +0 -374
  60. package/dist/hooks/chunk-6EBGRQ3Q.js +0 -301
  61. package/dist/hooks/chunk-6TVHWMD3.js +0 -432
  62. package/dist/hooks/chunk-6VAGLEMB.js +0 -68
  63. package/dist/hooks/chunk-75BTXKFJ.js +0 -3424
  64. package/dist/hooks/chunk-75RHN67S.js +0 -137
  65. package/dist/hooks/chunk-76KC3BDD.js +0 -3414
  66. package/dist/hooks/chunk-76SLS7CZ.js +0 -898
  67. package/dist/hooks/chunk-7DHZ4DWT.js +0 -5015
  68. package/dist/hooks/chunk-7INSJDGE.js +0 -458
  69. package/dist/hooks/chunk-7VJ4FTDX.js +0 -268
  70. package/dist/hooks/chunk-7XCYNHQK.js +0 -77
  71. package/dist/hooks/chunk-AAEXXUUL.js +0 -268
  72. package/dist/hooks/chunk-ACN3YXFL.js +0 -68
  73. package/dist/hooks/chunk-AD3XE3QZ.js +0 -397
  74. package/dist/hooks/chunk-AENFZPZH.js +0 -230
  75. package/dist/hooks/chunk-AFKRFQ6W.js +0 -68
  76. package/dist/hooks/chunk-AHD5IPWI.js +0 -375
  77. package/dist/hooks/chunk-AMK5JGV7.js +0 -77
  78. package/dist/hooks/chunk-ARN7NCQI.js +0 -425
  79. package/dist/hooks/chunk-AUFY653N.js +0 -3425
  80. package/dist/hooks/chunk-AXQBNFEF.js +0 -375
  81. package/dist/hooks/chunk-AYC7R6U4.js +0 -3316
  82. package/dist/hooks/chunk-AYEA2FJ7.js +0 -5015
  83. package/dist/hooks/chunk-B2LIXYFL.js +0 -77
  84. package/dist/hooks/chunk-B4HPNY2I.js +0 -375
  85. package/dist/hooks/chunk-B4YNCUGB.js +0 -469
  86. package/dist/hooks/chunk-B57S3VWT.js +0 -922
  87. package/dist/hooks/chunk-BINZ3PLI.js +0 -364
  88. package/dist/hooks/chunk-BIWLABFK.js +0 -432
  89. package/dist/hooks/chunk-BODUSXKK.js +0 -410
  90. package/dist/hooks/chunk-BQBAT2YK.js +0 -375
  91. package/dist/hooks/chunk-BUJEBW75.js +0 -391
  92. package/dist/hooks/chunk-BVNWORKA.js +0 -72
  93. package/dist/hooks/chunk-BWI47LQS.js +0 -5205
  94. package/dist/hooks/chunk-C25HRMJX.js +0 -137
  95. package/dist/hooks/chunk-CBFZNC74.js +0 -375
  96. package/dist/hooks/chunk-CECYXS4Y.js +0 -3424
  97. package/dist/hooks/chunk-CELGUP5F.js +0 -49
  98. package/dist/hooks/chunk-CMHANU3F.js +0 -3442
  99. package/dist/hooks/chunk-CMN372LI.js +0 -68
  100. package/dist/hooks/chunk-CPGZLMMK.js +0 -3299
  101. package/dist/hooks/chunk-CTQKXDC7.js +0 -268
  102. package/dist/hooks/chunk-CYAT4RIT.js +0 -68
  103. package/dist/hooks/chunk-CYTWYCH2.js +0 -5014
  104. package/dist/hooks/chunk-CZSOLRBA.js +0 -77
  105. package/dist/hooks/chunk-D2PIDYJR.js +0 -3438
  106. package/dist/hooks/chunk-DE57HI6T.js +0 -137
  107. package/dist/hooks/chunk-DGXDGAPG.js +0 -5306
  108. package/dist/hooks/chunk-DNYRSYQG.js +0 -5014
  109. package/dist/hooks/chunk-DTAXH2A2.js +0 -240
  110. package/dist/hooks/chunk-E2IZUWI5.js +0 -375
  111. package/dist/hooks/chunk-E4L2K2BL.js +0 -397
  112. package/dist/hooks/chunk-E55NKX5F.js +0 -68
  113. package/dist/hooks/chunk-ECXVCCVD.js +0 -3079
  114. package/dist/hooks/chunk-EPHO443D.js +0 -68
  115. package/dist/hooks/chunk-EUFK2BI2.js +0 -375
  116. package/dist/hooks/chunk-EYCD5ZAV.js +0 -137
  117. package/dist/hooks/chunk-F2SDYJU4.js +0 -240
  118. package/dist/hooks/chunk-F4B5D5TF.js +0 -68
  119. package/dist/hooks/chunk-FGEO3NDX.js +0 -432
  120. package/dist/hooks/chunk-FJYI52RE.js +0 -137
  121. package/dist/hooks/chunk-FYTZHIY4.js +0 -3085
  122. package/dist/hooks/chunk-G7JL2A5K.js +0 -375
  123. package/dist/hooks/chunk-GA3ITDBW.js +0 -42
  124. package/dist/hooks/chunk-GDR4H4SV.js +0 -469
  125. package/dist/hooks/chunk-GFKDXPSM.js +0 -2855
  126. package/dist/hooks/chunk-GIMRTKFU.js +0 -566
  127. package/dist/hooks/chunk-GOPHRLGO.js +0 -240
  128. package/dist/hooks/chunk-GX4HO7SJ.js +0 -230
  129. package/dist/hooks/chunk-GXKKK23T.js +0 -240
  130. package/dist/hooks/chunk-GZ6FUVIK.js +0 -566
  131. package/dist/hooks/chunk-H5HPY5M5.js +0 -2869
  132. package/dist/hooks/chunk-HCF3OGEE.js +0 -1829
  133. package/dist/hooks/chunk-HDEXAOUM.js +0 -469
  134. package/dist/hooks/chunk-HM2TY3TN.js +0 -469
  135. package/dist/hooks/chunk-HOA7NXA2.js +0 -55
  136. package/dist/hooks/chunk-HOFEWH6H.js +0 -240
  137. package/dist/hooks/chunk-HUUI6S5J.js +0 -2669
  138. package/dist/hooks/chunk-I4Q6WAJE.js +0 -68
  139. package/dist/hooks/chunk-IB6N4CR2.js +0 -432
  140. package/dist/hooks/chunk-IFLDYJMD.js +0 -469
  141. package/dist/hooks/chunk-IGU466YD.js +0 -77
  142. package/dist/hooks/chunk-IJCQUHKY.js +0 -375
  143. package/dist/hooks/chunk-IKUMBDJB.js +0 -230
  144. package/dist/hooks/chunk-IM3BDIBJ.js +0 -5005
  145. package/dist/hooks/chunk-IMYMAODK.js +0 -3431
  146. package/dist/hooks/chunk-IN2ZVGXA.js +0 -5005
  147. package/dist/hooks/chunk-ITVJ2MKQ.js +0 -18
  148. package/dist/hooks/chunk-J5RIJYTM.js +0 -2669
  149. package/dist/hooks/chunk-JFLMH4K5.js +0 -3460
  150. package/dist/hooks/chunk-JR25IFML.js +0 -77
  151. package/dist/hooks/chunk-JT5AUXFI.js +0 -432
  152. package/dist/hooks/chunk-JY5YVN6N.js +0 -3234
  153. package/dist/hooks/chunk-K5Q4ETVI.js +0 -391
  154. package/dist/hooks/chunk-K67V2F24.js +0 -137
  155. package/dist/hooks/chunk-KATZESEC.js +0 -3273
  156. package/dist/hooks/chunk-KFH4H7W7.js +0 -469
  157. package/dist/hooks/chunk-KMUEI6RX.js +0 -910
  158. package/dist/hooks/chunk-KMV4OY77.js +0 -3438
  159. package/dist/hooks/chunk-KQAZNWEY.js +0 -137
  160. package/dist/hooks/chunk-KZZR6JER.js +0 -5015
  161. package/dist/hooks/chunk-LAR6DREP.js +0 -77
  162. package/dist/hooks/chunk-LNCJWEZD.js +0 -5015
  163. package/dist/hooks/chunk-LRYD2GLM.js +0 -6
  164. package/dist/hooks/chunk-LXBKYHDV.js +0 -77
  165. package/dist/hooks/chunk-LYLKIUNE.js +0 -5024
  166. package/dist/hooks/chunk-LZKCFOVC.js +0 -432
  167. package/dist/hooks/chunk-M4FCIYRI.js +0 -77
  168. package/dist/hooks/chunk-M5M7327Q.js +0 -3425
  169. package/dist/hooks/chunk-MF72MHSX.js +0 -3455
  170. package/dist/hooks/chunk-MK56LKDO.js +0 -397
  171. package/dist/hooks/chunk-N3MJADY7.js +0 -240
  172. package/dist/hooks/chunk-NFQSUDBN.js +0 -458
  173. package/dist/hooks/chunk-NHREKY45.js +0 -137
  174. package/dist/hooks/chunk-NP5TTAAW.js +0 -375
  175. package/dist/hooks/chunk-NQTLTKTJ.js +0 -2993
  176. package/dist/hooks/chunk-NVRCZPBZ.js +0 -391
  177. package/dist/hooks/chunk-O46HMMLJ.js +0 -469
  178. package/dist/hooks/chunk-OFJGH2L4.js +0 -240
  179. package/dist/hooks/chunk-OLFMCZH5.js +0 -240
  180. package/dist/hooks/chunk-OMCZS46I.js +0 -49
  181. package/dist/hooks/chunk-OQZEZW5G.js +0 -469
  182. package/dist/hooks/chunk-P2MDAT2Y.js +0 -1897
  183. package/dist/hooks/chunk-P3M2JJIF.js +0 -68
  184. package/dist/hooks/chunk-PDVHQITQ.js +0 -3453
  185. package/dist/hooks/chunk-PNT2AMDH.js +0 -391
  186. package/dist/hooks/chunk-PR2LVSY6.js +0 -3445
  187. package/dist/hooks/chunk-PRR5R4JK.js +0 -137
  188. package/dist/hooks/chunk-PXT44QVN.js +0 -566
  189. package/dist/hooks/chunk-PZLWJLAP.js +0 -469
  190. package/dist/hooks/chunk-Q2FEAZJ2.js +0 -77
  191. package/dist/hooks/chunk-Q32WETDO.js +0 -3265
  192. package/dist/hooks/chunk-Q45DUBLE.js +0 -3600
  193. package/dist/hooks/chunk-Q7NZSWQ5.js +0 -240
  194. package/dist/hooks/chunk-QH2JNAMK.js +0 -3085
  195. package/dist/hooks/chunk-QNNWYQ2R.js +0 -375
  196. package/dist/hooks/chunk-QPU5H2OS.js +0 -68
  197. package/dist/hooks/chunk-QRAHZ5TO.js +0 -1829
  198. package/dist/hooks/chunk-QUZ5HPIE.js +0 -469
  199. package/dist/hooks/chunk-QVCRG34O.js +0 -2893
  200. package/dist/hooks/chunk-R3MY4E3S.js +0 -1675
  201. package/dist/hooks/chunk-R6TXJJXP.js +0 -77
  202. package/dist/hooks/chunk-REJU6VT7.js +0 -1829
  203. package/dist/hooks/chunk-REQAQLRC.js +0 -2993
  204. package/dist/hooks/chunk-RFCXPAHH.js +0 -391
  205. package/dist/hooks/chunk-RHI6Y22X.js +0 -137
  206. package/dist/hooks/chunk-RKZVOBBS.js +0 -469
  207. package/dist/hooks/chunk-RL57TT2Y.js +0 -566
  208. package/dist/hooks/chunk-RORDOD4S.js +0 -3321
  209. package/dist/hooks/chunk-RZKYW5P2.js +0 -77
  210. package/dist/hooks/chunk-SJPJ6VSI.js +0 -391
  211. package/dist/hooks/chunk-SKSIJQQQ.js +0 -432
  212. package/dist/hooks/chunk-SSQDZKXG.js +0 -268
  213. package/dist/hooks/chunk-SYHFKE4C.js +0 -77
  214. package/dist/hooks/chunk-TCGNI2ZY.js +0 -42
  215. package/dist/hooks/chunk-TG3WXJF5.js +0 -137
  216. package/dist/hooks/chunk-TH7IJAY5.js +0 -77
  217. package/dist/hooks/chunk-TLZ27PCY.js +0 -240
  218. package/dist/hooks/chunk-U652FXTN.js +0 -566
  219. package/dist/hooks/chunk-UEK47YUF.js +0 -268
  220. package/dist/hooks/chunk-UIO45H3O.js +0 -432
  221. package/dist/hooks/chunk-UNLZEEVH.js +0 -5005
  222. package/dist/hooks/chunk-UNRVF3SZ.js +0 -432
  223. package/dist/hooks/chunk-USLFAFOI.js +0 -3453
  224. package/dist/hooks/chunk-VAEELMLL.js +0 -442
  225. package/dist/hooks/chunk-VALSWLDQ.js +0 -3453
  226. package/dist/hooks/chunk-VC5JEPNY.js +0 -3398
  227. package/dist/hooks/chunk-VEZVK6C7.js +0 -230
  228. package/dist/hooks/chunk-VK5JKFAR.js +0 -49
  229. package/dist/hooks/chunk-VNF2KP7Z.js +0 -469
  230. package/dist/hooks/chunk-VWWCUMW6.js +0 -2669
  231. package/dist/hooks/chunk-W4JARUQV.js +0 -137
  232. package/dist/hooks/chunk-WEOBMNJG.js +0 -2993
  233. package/dist/hooks/chunk-WKJU3J5Y.js +0 -5390
  234. package/dist/hooks/chunk-WNON54PT.js +0 -3469
  235. package/dist/hooks/chunk-WOVKBPPX.js +0 -137
  236. package/dist/hooks/chunk-WRVFORYJ.js +0 -432
  237. package/dist/hooks/chunk-WUBVYGQZ.js +0 -240
  238. package/dist/hooks/chunk-WWULTUOM.js +0 -68
  239. package/dist/hooks/chunk-WXHKKB45.js +0 -4962
  240. package/dist/hooks/chunk-XAI3YTHJ.js +0 -469
  241. package/dist/hooks/chunk-XFZH6JZJ.js +0 -77
  242. package/dist/hooks/chunk-XGPWX6IA.js +0 -137
  243. package/dist/hooks/chunk-XIXXIVGY.js +0 -566
  244. package/dist/hooks/chunk-XKDOYJGA.js +0 -922
  245. package/dist/hooks/chunk-YALTVBHM.js +0 -432
  246. package/dist/hooks/chunk-YEBEPBFK.js +0 -5014
  247. package/dist/hooks/chunk-YI2BQ3DK.js +0 -3441
  248. package/dist/hooks/chunk-YVNBCFGG.js +0 -1829
  249. package/dist/hooks/chunk-YXBN3RGG.js +0 -432
  250. package/dist/hooks/chunk-Z2OOJSW3.js +0 -3163
  251. package/dist/hooks/chunk-ZA3HVBOY.js +0 -2644
  252. package/dist/hooks/chunk-ZKID46U3.js +0 -137
  253. package/dist/hooks/chunk-ZPMU2JV6.js +0 -49
  254. package/dist/hooks/chunk-ZRKY4W7O.js +0 -432
  255. package/dist/hooks/chunk-ZTMRB7LJ.js +0 -268
  256. package/dist/hooks/chunk-ZVPPBQ3L.js +0 -3413
@@ -1,469 +0,0 @@
1
- import {
2
- lane_child_marker
3
- } from "./chunk-46EEEHC3.js";
4
- import {
5
- time_bundle_call,
6
- time_format,
7
- time_round_trips,
8
- time_spans,
9
- time_transcript_line
10
- } from "./chunk-44M6JXGV.js";
11
-
12
- // scripts/lane/lane-guard-policy.ts
13
- var DEFAULT_MODE = "refuse";
14
- var OFF_MODE = "off";
15
- var LANE_GUARD_POLICY = [
16
- {
17
- id: "investigation",
18
- mode_in_lane_child: "notice",
19
- because: 'a refusal ends a child turn so it cannot fire as one (kit#2138), which is why it was `off` from #2138 to #2382. The exemption reason \u2014 "the child is itself the delegated unit, so it cannot dispatch a sub-unit to read its own edit targets" \u2014 did not hold in measurement: kit#2382 re-measured the six lane children after #2347 (#2366 #2370 #2371 #2372 #2374 #2375) and every one dispatched sub-agents (10 launches, 2 of them investigation fan-outs) and read 4\u201317 files it never edited, all six over the threshold of 3. So the reading the guard exists to send out was there to send. It takes `notice`, not `off`: the child is nudged to delegate rather than killed, on the `additionalContext` path batching and duplicate-read already use, and the notice names the concrete unedited files this run read (the #2276 precedent) rather than the generic "delegate" #2164 \u2192 #2178 measured not to move the number. The density is a genuine experiment \u2014 re-measured on the next backlogrun, and a notice that still does not move it is redesigned rather than kept'
20
- },
21
- {
22
- id: "batching",
23
- mode_in_lane_child: "notice",
24
- because: 'a refusal ends a child turn so it cannot fire as one (kit#2138); kit#2164 replaced it with a notice, kit#2178 took that notice off after it did not move the density (1.00 calls per turn on both sides of it, transcript f39efeb5), and kit#2276 restores it as a notice \u2014 but a different one. #2178 turned the notice fully off, so across the 2026-09-21 backlogrun 13 runs it fired zero times and the measured 1.147 is the rate with no guidance at all, not guidance that failed. #2276 re-enables it with the two things #2164 lacked: it names the concrete recent calls the run issued one-per-turn (not just "batch more"), and it recurs every single-call turn rather than every three, so the pressure arrives as often as the mistake. The density is to be re-measured on the next backlogrun; if it still does not reach 1.40 the notice is redesigned rather than kept, per the issue'
25
- },
26
- {
27
- id: "duplicate-read",
28
- mode_in_lane_child: "notice",
29
- because: "a refusal ends a child turn so it cannot fire as one (kit#2138), and the unchanged re-reads the guard catches are measured in lane children above all (kit#2298 baseline: 8.0 per lane run) \u2014 so silencing it there (`off`) would neuter it exactly where the count lives. It takes `notice` instead: the child is nudged to scroll up to the earlier read rather than killed. The mode is a genuine experiment, as the batching notice is \u2014 a notice that does not reduce the duplicate reads on the next backlogrun is redesigned rather than kept"
30
- },
31
- {
32
- id: "rule",
33
- mode_in_lane_child: "refuse",
34
- because: "it carries the lane-only rules a child depends on (`pre-gate-cut`, `implementation-cut`, `lane-park`) and the safety rules a child must still obey (`shell-body`, `piped-verification`); a blanket suppression would disarm exactly the guards written for the child. `implementation-cut` (joshuafolkken/kit#2310) needs `refuse` for the same reason the pre-gate cut does \u2014 kit#1864 and kit#2310 both measured a cut carried as prose firing 0 times, so a notice, being prose in front of the run, would drop enforcement without a procedural replacement. The pre-gate-cut refusal does collateral a sibling call batched in the same turn \u2014 a `PreToolUse` deny cancels the turn's other parallel calls, which is the harness behavior kit#2177 measured on #2160 (gate refused, its batched `review:brief` cancelled) \u2014 and that collateral is not avoidable at the guard level. `notice` was considered for the pre-gate-cut point and rejected: kit#1864 measured the cut taken 0 times while it was carried as prose, and a notice is prose in front of the run (kit#2178 measured a lane-child notice not moving the number), so a notice would drop enforcement without a procedural replacement. kit#2177 supplies that replacement in the procedure instead \u2014 the chain orders the cut before the gate, so the cut is issued on its own (its `cut` verdict ends the turn, batching with nothing) and the gate runs in the fresh process where the carried cut keeps this guard silent; the refusal therefore stays `refuse` as insurance and the collateral is gone from the default path rather than from the guard"
35
- }
36
- ];
37
- var KNOWN_GUARD_IDS = LANE_GUARD_POLICY.map((entry) => entry.id);
38
- function entry_for(id) {
39
- return LANE_GUARD_POLICY.find((entry) => entry.id === id.trim());
40
- }
41
- function mode_in_lane_child(id) {
42
- return entry_for(id)?.mode_in_lane_child ?? DEFAULT_MODE;
43
- }
44
- function mode_here(id, directory = process.cwd(), source = process.env) {
45
- const lane_mode = mode_in_lane_child(id);
46
- if (lane_mode === DEFAULT_MODE) return DEFAULT_MODE;
47
- return lane_child_marker.is_child_of(directory, source) ? lane_mode : DEFAULT_MODE;
48
- }
49
- function is_suppressed_here(id, directory = process.cwd(), source = process.env) {
50
- return mode_here(id, directory, source) === OFF_MODE;
51
- }
52
- var lane_guard_policy = {
53
- LANE_GUARD_POLICY,
54
- KNOWN_GUARD_IDS,
55
- entry_for,
56
- mode_in_lane_child,
57
- mode_here,
58
- is_suppressed_here
59
- };
60
-
61
- // scripts/time-runtime/time-agent-bundles.ts
62
- var NONE = 0;
63
- var ONE = 1;
64
- var MIN_GROUP = 2;
65
- function is_launch(span) {
66
- return span.category === time_spans.TOOL_CATEGORY && !span.is_continuation && time_bundle_call.is_launch_tool(span.label);
67
- }
68
- function new_walk() {
69
- return { closed: [], open: NONE, wrote_since: false, turn_id: time_spans.NO_MESSAGE_ID };
70
- }
71
- function close_group(walk) {
72
- if (walk.open >= MIN_GROUP) walk.closed.push(walk.open);
73
- walk.open = NONE;
74
- }
75
- function is_same_turn(walk, span) {
76
- return span.message_id !== time_spans.NO_MESSAGE_ID && span.message_id === walk.turn_id;
77
- }
78
- function open_turn(walk, span) {
79
- if (walk.wrote_since || span.has_prior_reference) close_group(walk);
80
- walk.open += ONE;
81
- walk.turn_id = span.message_id;
82
- walk.wrote_since = false;
83
- }
84
- function step(walk, span) {
85
- if (span.is_writing) {
86
- walk.wrote_since = true;
87
- return;
88
- }
89
- if (!is_launch(span) || is_same_turn(walk, span)) return;
90
- open_turn(walk, span);
91
- }
92
- function agent_bundles(spans) {
93
- const walk = new_walk();
94
- for (const span of time_round_trips.in_time_order(spans)) step(walk, span);
95
- close_group(walk);
96
- return walk.closed;
97
- }
98
- var time_agent_bundles = { agent_bundles };
99
-
100
- // scripts/time-runtime/time-bundles.ts
101
- var { unmeasured_row } = time_format;
102
- var HEADING = "Bundling:";
103
- var SEQUENCE_LABEL = "bundleable sequences";
104
- var RECOVERABLE_LABEL = "recoverable round trips";
105
- var SAVING_LABEL = "recoverable wait";
106
- var BY_TOOL_LABEL = "recoverable by tool";
107
- var AGENT_ROW_LABEL = "Agent";
108
- var ROW_INDENT = " ";
109
- var MIN_SEQUENCE = 2;
110
- var ONE_CALL = 1;
111
- var NONE2 = 0;
112
- var PATH_SEPARATOR = "/";
113
- var FIRST_CALL = 1;
114
- var NO_LABEL = "";
115
- var NO_BUNDLES = {
116
- sequence_count: 0,
117
- longest_sequence: 0,
118
- recoverable_round_trips: 0,
119
- by_tool: [],
120
- unattributed_round_trips: 0,
121
- is_measured: false
122
- };
123
- function contains_segments(whole, part) {
124
- if (whole.startsWith(`${part}${PATH_SEPARATOR}`)) return true;
125
- return whole.endsWith(`${PATH_SEPARATOR}${part}`) || whole.includes(`${PATH_SEPARATOR}${part}${PATH_SEPARATOR}`);
126
- }
127
- function is_related(left, right) {
128
- if (left === right) return true;
129
- return contains_segments(left, right) || contains_segments(right, left);
130
- }
131
- function shares_target(left, right) {
132
- return left.some((one) => right.some((other) => is_related(one, other)));
133
- }
134
- function is_dependent(earlier, later) {
135
- if (earlier.is_writing && later.is_writing) return false;
136
- return shares_target(earlier.targets, later.targets);
137
- }
138
- function conflicts(span, sequence) {
139
- return sequence.some((earlier) => is_dependent(earlier, span));
140
- }
141
- function is_call(span) {
142
- return span.category === time_spans.TOOL_CATEGORY && !span.is_continuation;
143
- }
144
- function is_turn_boundary(span) {
145
- return span.category === time_spans.MODEL_CATEGORY;
146
- }
147
- function new_walk2() {
148
- return { pending: [], sequence: [], closed: [] };
149
- }
150
- function flush(walk) {
151
- if (walk.sequence.length >= MIN_SEQUENCE) walk.closed.push(walk.sequence);
152
- walk.sequence = [];
153
- }
154
- function extend(walk, span) {
155
- if (conflicts(span, walk.sequence)) flush(walk);
156
- walk.sequence.push(span);
157
- }
158
- function close_trip(walk) {
159
- const [only] = walk.pending;
160
- if (walk.pending.length === ONE_CALL && only?.is_bundleable === true) extend(walk, only);
161
- else if (walk.pending.length > NONE2) flush(walk);
162
- walk.pending = [];
163
- }
164
- function is_same_turn2(span, pending) {
165
- const [first] = pending;
166
- if (first === void 0 || span.is_continuation || span.message_id === time_spans.NO_MESSAGE_ID) {
167
- return false;
168
- }
169
- return span.message_id === first.message_id;
170
- }
171
- function step2(walk, span) {
172
- if (is_call(span)) {
173
- walk.pending.push(span);
174
- return;
175
- }
176
- if (is_same_turn2(span, walk.pending)) return;
177
- close_trip(walk);
178
- if (!is_turn_boundary(span)) flush(walk);
179
- }
180
- function longest_of(sizes) {
181
- return sizes.length === NONE2 ? NONE2 : Math.max(...sizes);
182
- }
183
- function recoverable_of(sizes) {
184
- return sizes.reduce((sum, size) => sum + size - ONE_CALL, NONE2);
185
- }
186
- function sizes_of(closed) {
187
- return closed.map((sequence) => sequence.length);
188
- }
189
- function tally_for(tallies, label) {
190
- const found = tallies.get(label);
191
- if (found !== void 0) return found;
192
- const created = { sequence_count: NONE2, recoverable_round_trips: NONE2 };
193
- tallies.set(label, created);
194
- return created;
195
- }
196
- function count_trip(tallies, counted, label) {
197
- const tally = tally_for(tallies, label);
198
- tally.recoverable_round_trips += ONE_CALL;
199
- if (!counted.has(label)) tally.sequence_count += ONE_CALL;
200
- counted.add(label);
201
- }
202
- function tally_sequence(tallies, sequence) {
203
- const counted = /* @__PURE__ */ new Set();
204
- for (const span of sequence.slice(FIRST_CALL)) {
205
- if (span.label !== NO_LABEL) count_trip(tallies, counted, span.label);
206
- }
207
- }
208
- function by_weight(left, right) {
209
- if (left.recoverable_round_trips !== right.recoverable_round_trips) {
210
- return right.recoverable_round_trips - left.recoverable_round_trips;
211
- }
212
- return left.label.localeCompare(right.label);
213
- }
214
- function tool_rows(closed) {
215
- const tallies = /* @__PURE__ */ new Map();
216
- for (const sequence of closed) tally_sequence(tallies, sequence);
217
- return [...tallies].map(([label, tally]) => ({ label, ...tally })).toSorted(by_weight);
218
- }
219
- function attributed_of(rows) {
220
- return rows.reduce((sum, row) => sum + row.recoverable_round_trips, NONE2);
221
- }
222
- function with_agent_row(rows, agent_sizes) {
223
- const recoverable_round_trips = recoverable_of(agent_sizes);
224
- if (recoverable_round_trips === NONE2) return [...rows];
225
- const row = {
226
- label: AGENT_ROW_LABEL,
227
- sequence_count: agent_sizes.length,
228
- recoverable_round_trips
229
- };
230
- return [...rows, row].toSorted(by_weight);
231
- }
232
- function build_bundles(spans) {
233
- const walk = new_walk2();
234
- for (const span of time_round_trips.in_time_order(spans)) step2(walk, span);
235
- close_trip(walk);
236
- flush(walk);
237
- const sizes = sizes_of(walk.closed);
238
- const agent_sizes = time_agent_bundles.agent_bundles(spans);
239
- const by_tool = with_agent_row(tool_rows(walk.closed), agent_sizes);
240
- const recoverable_round_trips = recoverable_of(sizes) + recoverable_of(agent_sizes);
241
- return {
242
- sequence_count: sizes.length + agent_sizes.length,
243
- longest_sequence: Math.max(longest_of(sizes), longest_of(agent_sizes)),
244
- recoverable_round_trips,
245
- by_tool,
246
- unattributed_round_trips: recoverable_round_trips - attributed_of(by_tool),
247
- is_measured: time_spans.has_transcript_data(spans.length)
248
- };
249
- }
250
- function open_sequence(spans) {
251
- const walk = new_walk2();
252
- for (const span of time_round_trips.in_time_order(spans)) step2(walk, span);
253
- return walk.sequence;
254
- }
255
- function sequence_suffix(totals) {
256
- return `longest ${String(totals.longest_sequence)} turn(s)`;
257
- }
258
- function recoverable_suffix(totals, round_trip_count) {
259
- const share = time_format.format_share(totals.recoverable_round_trips, round_trip_count);
260
- return `${share} of ${String(round_trip_count)} round trip(s)`;
261
- }
262
- function saving_line(totals, model_ms_per_round_trip) {
263
- const saved_ms = totals.recoverable_round_trips * model_ms_per_round_trip;
264
- const rate = `at ${time_format.format_seconds(model_ms_per_round_trip)} model time per round trip`;
265
- return time_format.format_row(SAVING_LABEL, saved_ms, rate);
266
- }
267
- function by_tool_suffix(totals) {
268
- const attributed = totals.recoverable_round_trips - totals.unattributed_round_trips;
269
- return `${String(attributed)} of ${String(totals.recoverable_round_trips)} attributed`;
270
- }
271
- function tool_row(row) {
272
- return time_format.format_columns(
273
- `${ROW_INDENT}${row.label}`,
274
- String(row.recoverable_round_trips),
275
- `in ${String(row.sequence_count)} sequence(s)`
276
- );
277
- }
278
- function by_tool_lines(totals) {
279
- const heading = time_format.format_columns(
280
- BY_TOOL_LABEL,
281
- String(totals.by_tool.length),
282
- by_tool_suffix(totals)
283
- );
284
- const rows = totals.by_tool.slice(NONE2, time_format.MAX_ROWS).map((row) => tool_row(row));
285
- return [heading, ...rows, ...time_format.overflow_line(totals.by_tool.length)];
286
- }
287
- function measured_lines(totals, price) {
288
- return [
289
- time_format.format_columns(
290
- SEQUENCE_LABEL,
291
- String(totals.sequence_count),
292
- sequence_suffix(totals)
293
- ),
294
- time_format.format_columns(
295
- RECOVERABLE_LABEL,
296
- String(totals.recoverable_round_trips),
297
- recoverable_suffix(totals, price.round_trip_count)
298
- ),
299
- saving_line(totals, price.model_ms_per_round_trip),
300
- ...by_tool_lines(totals)
301
- ];
302
- }
303
- var LABELS = [SEQUENCE_LABEL, RECOVERABLE_LABEL, SAVING_LABEL, BY_TOOL_LABEL];
304
- function no_divisor_lines() {
305
- return LABELS.map((label) => time_format.format_columns(label, "", time_format.NO_CALLS));
306
- }
307
- function bundle_lines(totals, price) {
308
- const heading = ["", HEADING];
309
- if (!totals.is_measured) return [...heading, ...LABELS.map((label) => unmeasured_row(label))];
310
- if (price.round_trip_count === NONE2) return [...heading, ...no_divisor_lines()];
311
- return [...heading, ...measured_lines(totals, price)];
312
- }
313
- var time_bundles = {
314
- HEADING,
315
- SEQUENCE_LABEL,
316
- RECOVERABLE_LABEL,
317
- SAVING_LABEL,
318
- BY_TOOL_LABEL,
319
- MIN_SEQUENCE,
320
- NO_BUNDLES,
321
- build_bundles,
322
- bundle_lines,
323
- is_dependent,
324
- open_sequence,
325
- shares_target
326
- };
327
-
328
- // scripts/time-runtime/time-command-key.ts
329
- var UNNAMED_KEY = "";
330
- function command_key(span) {
331
- if (span.label === time_spans.UNKNOWN_TOOL) return UNNAMED_KEY;
332
- return span.josh_command === "" ? span.label : span.josh_command;
333
- }
334
- var time_command_key = { UNNAMED_KEY, command_key };
335
-
336
- // scripts/time-runtime/time-call-identity.ts
337
- var IDENTITY_SEPARATOR = "\0";
338
- function identity_of(call) {
339
- return [
340
- time_command_key.command_key(call),
341
- call.check_key,
342
- [...call.targets].toSorted((left, right) => left.localeCompare(right)).join(",")
343
- ].join(IDENTITY_SEPARATOR);
344
- }
345
- var time_call_identity = { identity_of };
346
-
347
- // scripts/time-runtime/time-batch-guard.ts
348
- var CONSECUTIVE_LIMIT = 3;
349
- var REFIRE_EVERY = CONSECUTIVE_LIMIT;
350
- var ONE_TURN = 1;
351
- var NONE3 = 0;
352
- var NOTICE_REFIRE_EVERY = ONE_TURN;
353
- var NAMED_CANDIDATE_COUNT = 3;
354
- var SEQUENCE_BEFORE_LIMIT = CONSECUTIVE_LIMIT - ONE_TURN;
355
- var REASON = `\u26D4 batching: the last ${String(SEQUENCE_BEFORE_LIMIT)} turns each issued a single tool call, so this one would make ${String(CONSECUTIVE_LIMIT)} in a row. Reissue it in one turn together with the calls meant to follow it that do not need its result. **The criterion is whether this call's input needs another call's result, not what kind of call it is** \u2014 edits are covered exactly as reads are, and it never authorizes weakening a verification gate or a review: fewer turns, never less work. The measured cost and the rejected mechanisms are in \`prompts/collaboration-workflow/turn-batching.md\`. If this turn was already batching, or the call genuinely has nothing to go beside it, reissue it as it was: this fires once per run of single-call turns and cannot repeat on the call in hand.`;
356
- var NOTICE = `\u{1F4A1} batching: the last ${String(SEQUENCE_BEFORE_LIMIT)} turns each issued a single tool call, so this Write makes ${String(CONSECUTIVE_LIMIT)} in a row. This is a notice, not a refusal \u2014 the write proceeds. Where the writes meant to follow it do not need its result, issue them in one turn together. **The criterion is whether a call's input needs another call's result, not what kind of call it is** \u2014 it never authorizes weakening a verification gate or a review: fewer turns, never less work. The measured cost and the rejected mechanisms are in \`prompts/collaboration-workflow/turn-batching.md\`. If this run was already batching, or the write genuinely has nothing to go beside it, carry on: this recurs every ${String(NOTICE_REFIRE_EVERY)} further single-call turn(s).`;
357
- var LANE_NOTICE = `\u{1F4A1} batching: the last ${String(SEQUENCE_BEFORE_LIMIT)} turns each issued a single tool call, so this one makes ${String(CONSECUTIVE_LIMIT)} in a row. This is a notice, not a refusal \u2014 the call proceeds, because a dispatched lane child ends its turn on a denial. Where the calls meant to follow it do not need its result, issue them in one turn together. **The criterion is whether a call's input needs another call's result, not what kind of call it is** \u2014 it never authorizes weakening a verification gate or a review: fewer turns, never less work. The measured cost and the rejected mechanisms are in \`prompts/collaboration-workflow/turn-batching.md\`. If this run was already batching, or the call genuinely has nothing to go beside it, carry on: this recurs every ${String(NOTICE_REFIRE_EVERY)} further single-call turn(s).`;
358
- var WHOLE_FILE_WRITE_TOOL = "Write";
359
- var EDIT_TOOL = "Edit";
360
- function is_guarded_call(call) {
361
- if (call.name === WHOLE_FILE_WRITE_TOOL) return false;
362
- return time_bundle_call.call_facts(call.name, call.input).is_bundleable;
363
- }
364
- function is_notice_call(call) {
365
- return call.name === WHOLE_FILE_WRITE_TOOL;
366
- }
367
- function is_read_only_call(call) {
368
- const facts = time_bundle_call.call_facts(call.name, call.input);
369
- return facts.is_bundleable && !facts.may_write;
370
- }
371
- function depends_on_sequence(sequence, facts) {
372
- return sequence.some((span) => time_bundles.shares_target(span.targets, facts.targets));
373
- }
374
- function sequence_started_ms(sequence) {
375
- return sequence[0]?.ended_ms ?? NONE3;
376
- }
377
- function turns_since(sequence, last_fired_ms) {
378
- return sequence.filter((span) => span.ended_ms > last_fired_ms).length;
379
- }
380
- function is_sequence_at_limit(sequence, facts, last_fired_ms, refire_every) {
381
- if (sequence.length < SEQUENCE_BEFORE_LIMIT || depends_on_sequence(sequence, facts)) return false;
382
- if (last_fired_ms < sequence_started_ms(sequence)) return true;
383
- return turns_since(sequence, last_fired_ms) >= refire_every;
384
- }
385
- function is_at_limit(spans, call, last_fired_ms, refire_every) {
386
- return is_sequence_at_limit(
387
- time_bundles.open_sequence(spans),
388
- time_bundle_call.call_facts(call.name, call.input),
389
- last_fired_ms,
390
- refire_every
391
- );
392
- }
393
- var GUARD_LABEL = time_transcript_line.guard_from_refusal(REASON);
394
- function is_reissued_refusal(spans, call) {
395
- const identity = time_call_identity.identity_of(
396
- time_spans.to_tool_call(call.name, call.input, time_spans.NO_MESSAGE_ID)
397
- );
398
- return spans.some(
399
- (span) => span.refusal_guard === GUARD_LABEL && time_call_identity.identity_of(span) === identity
400
- );
401
- }
402
- function should_block(text, call, refused_at_ms, refire_every = REFIRE_EVERY) {
403
- if (!is_guarded_call(call)) return false;
404
- const { spans } = time_spans.parse_timeline(text);
405
- if (is_reissued_refusal(spans, call)) return false;
406
- return is_at_limit(spans, call, refused_at_ms, refire_every);
407
- }
408
- function should_notify(text, call, notified_at_ms) {
409
- if (!is_notice_call(call)) return false;
410
- const { spans } = time_spans.parse_timeline(text);
411
- return is_at_limit(spans, call, notified_at_ms, NOTICE_REFIRE_EVERY);
412
- }
413
- function describe_span(span) {
414
- const target = span.targets[0] ?? "";
415
- if (target === "" || span.label.includes(target)) return span.label;
416
- return `${span.label} ${target}`;
417
- }
418
- var FOLD_MINIMUM = 2;
419
- function read_targets(sequence) {
420
- const paths = sequence.filter((span) => span.is_bundleable && !span.is_writing).map((span) => span.targets[0] ?? "").filter((path) => path !== "" && time_bundle_call.has_extension(path));
421
- return [...new Set(paths)];
422
- }
423
- function read_fold_directive(sequence) {
424
- const paths = read_targets(sequence);
425
- if (paths.length < FOLD_MINIMUM) return "";
426
- return ` Fold them into one call: \`pnpm josh read:files ${paths.join(" ")}\`.`;
427
- }
428
- function write_targets(sequence) {
429
- const paths = sequence.filter((span) => span.label === EDIT_TOOL).map((span) => span.targets[0] ?? "").filter((path) => path !== "" && time_bundle_call.has_extension(path));
430
- return [...new Set(paths)];
431
- }
432
- function write_fold_directive(sequence) {
433
- const paths = write_targets(sequence);
434
- if (paths.length < FOLD_MINIMUM) return "";
435
- return ` Fold them into one \`pnpm josh edit:files\` call with a plan over: ${paths.join(" ")}.`;
436
- }
437
- function recent_candidates(tail) {
438
- const recent = time_bundles.open_sequence(time_spans.parse_timeline(tail).spans).slice(-NAMED_CANDIDATE_COUNT);
439
- if (recent.length === NONE3) return "";
440
- const named = recent.map((span) => describe_span(span)).join(", ");
441
- const folds = `${read_fold_directive(recent)}${write_fold_directive(recent)}`;
442
- return ` Just issued one per turn, so at least these could have shared a turn: ${named}.${folds}`;
443
- }
444
- var STAMP_PREFIX = "josh-batch-guard-";
445
- var NOTICE_STAMP_PREFIX = "josh-batch-guard-notice-";
446
- var time_batch_guard = {
447
- CONSECUTIVE_LIMIT,
448
- GUARD_LABEL,
449
- LANE_NOTICE,
450
- NAMED_CANDIDATE_COUNT,
451
- NOTICE,
452
- NOTICE_REFIRE_EVERY,
453
- NOTICE_STAMP_PREFIX,
454
- REASON,
455
- REFIRE_EVERY,
456
- SEQUENCE_BEFORE_LIMIT,
457
- STAMP_PREFIX,
458
- is_guarded_call,
459
- is_notice_call,
460
- is_read_only_call,
461
- recent_candidates,
462
- should_block,
463
- should_notify
464
- };
465
-
466
- export {
467
- lane_guard_policy,
468
- time_batch_guard
469
- };
@@ -1,55 +0,0 @@
1
- import {
2
- lane_guard_policy,
3
- time_batch_guard
4
- } from "./chunk-BODUSXKK.js";
5
- import {
6
- hook_decision
7
- } from "./chunk-GX4HO7SJ.js";
8
-
9
- // scripts/hooks/batch-guard.ts
10
- import { text } from "node:stream/consumers";
11
- import { fileURLToPath } from "node:url";
12
- var SWITCH_ENV_KEY = "JOSH_BATCH_GUARD";
13
- function is_batch_candidate(call) {
14
- return time_batch_guard.is_guarded_call(call) || time_batch_guard.is_notice_call(call);
15
- }
16
- function is_candidate(call) {
17
- return is_batch_candidate(call) && !lane_guard_policy.is_suppressed_here("batching");
18
- }
19
- var GUARD = hook_decision.create_transcript_guard({
20
- prefix: time_batch_guard.STAMP_PREFIX,
21
- switch_key: SWITCH_ENV_KEY,
22
- is_candidate,
23
- should_block: time_batch_guard.should_block,
24
- reason: time_batch_guard.REASON,
25
- // The whole-file write is notified rather than refused, on a record of its own so it never spends
26
- // the refusal's stamp (joshuafolkken/kit#1848).
27
- notify: {
28
- prefix: time_batch_guard.NOTICE_STAMP_PREFIX,
29
- should_notify: time_batch_guard.should_notify,
30
- text: time_batch_guard.NOTICE
31
- }
32
- });
33
- var batch_refusal = GUARD.refusal;
34
- var batch_outcome = GUARD.outcome;
35
- var { is_enabled, refusal_path } = GUARD;
36
- var notice_refusal_path = hook_decision.create_refusal_stamp(
37
- time_batch_guard.NOTICE_STAMP_PREFIX
38
- ).path;
39
- var { deny_envelope, load_environment_file, DISABLED_VALUES } = hook_decision;
40
- if (process.argv[1] === fileURLToPath(import.meta.url)) {
41
- if (process.stdin.isTTY) hook_decision.report_no_payload("batch:guard");
42
- else hook_decision.write_outcome(await text(process.stdin), batch_outcome);
43
- }
44
-
45
- export {
46
- SWITCH_ENV_KEY,
47
- batch_refusal,
48
- batch_outcome,
49
- is_enabled,
50
- refusal_path,
51
- notice_refusal_path,
52
- deny_envelope,
53
- load_environment_file,
54
- DISABLED_VALUES
55
- };