@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,432 +0,0 @@
1
- import {
2
- ESLINT_EDIT_CACHE_FLAGS,
3
- time_density_hook
4
- } from "./chunk-VALSWLDQ.js";
5
-
6
- // scripts/hooks/format-edited-file.ts
7
- import { existsSync as existsSync3 } from "node:fs";
8
- import path3 from "node:path";
9
- import { text } from "node:stream/consumers";
10
- import { fileURLToPath } from "node:url";
11
-
12
- // scripts/build/local-bin.ts
13
- import { existsSync, readFileSync } from "node:fs";
14
- import { createRequire } from "node:module";
15
- import path from "node:path";
16
-
17
- // scripts/lib/schemas.ts
18
- import { z } from "zod";
19
- var overrides_snapshot_schema = z.record(z.string(), z.string());
20
- var package_version_schema = z.object({ version: z.string() });
21
- var package_named_version_schema = z.looseObject({ name: z.string(), version: z.string() });
22
- var package_with_version_schema = z.looseObject({ version: z.string() });
23
- var ls_global_dependency_schema = z.looseObject({ version: z.string() });
24
- var ls_global_dependencies_schema = z.record(z.string(), ls_global_dependency_schema).optional();
25
- var pnpm_ls_global_schema = z.array(
26
- z.looseObject({
27
- dependencies: ls_global_dependencies_schema
28
- })
29
- );
30
- var vscode_settings_schema = z.record(z.string(), z.unknown());
31
- var with_scripts_schema = z.looseObject({
32
- scripts: z.record(z.string(), z.string()).optional()
33
- });
34
- var with_development_deps_schema = z.looseObject({
35
- devDependencies: z.record(z.string(), z.string()).optional()
36
- });
37
- var with_package_manager_schema = z.looseObject({
38
- packageManager: z.string().optional()
39
- });
40
- var with_development_engine_schema = z.looseObject({
41
- devEngines: z.record(z.string(), z.unknown()).optional()
42
- });
43
- var bin_entry_schema = z.union([z.string(), z.record(z.string(), z.string())]).optional();
44
- var package_bin_schema = z.looseObject({ bin: bin_entry_schema });
45
- var json_object_schema = z.record(z.string(), z.unknown());
46
- var string_array_schema = z.array(z.string());
47
- var string_record_schema = z.record(z.string(), z.string());
48
-
49
- // scripts/build/local-bin.ts
50
- var NODE_MODULES = "node_modules";
51
- var BIN_DIR = ".bin";
52
- var WINDOWS_PLATFORM = "win32";
53
- var WINDOWS_SHIM_SUFFIX = ".cmd";
54
- var PACKAGE_JSON = "package.json";
55
- function resolve_local_bin(project_root, bin_name) {
56
- const shim = process.platform === WINDOWS_PLATFORM ? `${bin_name}${WINDOWS_SHIM_SUFFIX}` : bin_name;
57
- return path.join(project_root, NODE_MODULES, BIN_DIR, shim);
58
- }
59
- function read_bin_entry(manifest_path, package_name, bin_name) {
60
- const { bin } = package_bin_schema.parse(JSON.parse(readFileSync(manifest_path, "utf8")));
61
- if (typeof bin === "string") return bin_name === path.basename(package_name) ? bin : void 0;
62
- return bin?.[bin_name];
63
- }
64
- function resolve_package_bin(base_directory, package_name, bin_name) {
65
- try {
66
- const resolve_from = createRequire(path.join(base_directory, PACKAGE_JSON));
67
- const manifest_path = resolve_from.resolve(`${package_name}/${PACKAGE_JSON}`);
68
- const bin_entry = read_bin_entry(manifest_path, package_name, bin_name);
69
- if (bin_entry === void 0) return void 0;
70
- const cli_entry = path.join(path.dirname(manifest_path), bin_entry);
71
- return existsSync(cli_entry) ? cli_entry : void 0;
72
- } catch {
73
- return void 0;
74
- }
75
- }
76
-
77
- // scripts/hooks/format-edited-file.ts
78
- import { execa as execa2 } from "execa";
79
- import { z as z2 } from "zod";
80
-
81
- // scripts/hooks/edited-cspell.ts
82
- import { existsSync as existsSync2 } from "node:fs";
83
- import path2 from "node:path";
84
- import { execa } from "execa";
85
- var CSPELL_EXTENSIONS = /* @__PURE__ */ new Set([
86
- ".ts",
87
- ".tsx",
88
- ".js",
89
- ".jsx",
90
- ".mjs",
91
- ".cjs",
92
- ".svelte",
93
- ".md",
94
- ".mdx",
95
- ".txt",
96
- ".json",
97
- ".jsonc",
98
- ".yml",
99
- ".yaml",
100
- ".html",
101
- ".css"
102
- ]);
103
- var CSPELL_ARGS = [
104
- "exec",
105
- "cspell",
106
- "lint",
107
- "--words-only",
108
- "--unique",
109
- "--no-progress",
110
- "--no-summary"
111
- ];
112
- var PNPM = "pnpm";
113
- var PROCESS_TIMEOUT_MS = 15e3;
114
- var HEADER = "The edit hook found words cspell does not know; fix them or add them to `cspell.config.yaml` now rather than at the gate:";
115
- var MAX_DIAGNOSTIC_CHARS = 4e3;
116
- var TRUNCATION_NOTICE = "\n\u2026(unknown words truncated)";
117
- function is_checkable(file_path, project_root) {
118
- if (!existsSync2(file_path) || !CSPELL_EXTENSIONS.has(path2.extname(file_path).toLowerCase())) {
119
- return false;
120
- }
121
- const relative = path2.relative(path2.resolve(project_root), path2.resolve(file_path));
122
- return relative !== "" && !relative.startsWith("..") && !path2.isAbsolute(relative);
123
- }
124
- async function run_cspell(file_path, project_root) {
125
- const result = await execa(PNPM, [...CSPELL_ARGS, file_path], {
126
- reject: false,
127
- cwd: project_root,
128
- stdout: "pipe",
129
- stderr: "ignore",
130
- timeout: PROCESS_TIMEOUT_MS
131
- });
132
- return result.stdout;
133
- }
134
- function format_unknown_words(stdout) {
135
- const words = stdout.split("\n").map((word) => word.trim()).filter((word) => word.length > 0);
136
- if (words.length === 0) return void 0;
137
- const joined = words.join("\n");
138
- const body = joined.length > MAX_DIAGNOSTIC_CHARS ? `${joined.slice(0, MAX_DIAGNOSTIC_CHARS)}${TRUNCATION_NOTICE}` : joined;
139
- return `${HEADER}
140
- ${body}`;
141
- }
142
- async function spelling_diagnostics(file_path, project_root, runner = run_cspell) {
143
- if (file_path === void 0 || !is_checkable(file_path, project_root)) return void 0;
144
- try {
145
- return format_unknown_words(await runner(file_path, project_root));
146
- } catch {
147
- return void 0;
148
- }
149
- }
150
- var edited_cspell = { format_unknown_words, is_checkable, spelling_diagnostics };
151
-
152
- // scripts/hooks/format-rewrite-notice.ts
153
- import { readFileSync as readFileSync2 } from "node:fs";
154
- var MAX_REWRITE_CHARS = 1200;
155
- var REWRITE_TRUNCATION_NOTICE = "\n\u2026(rewrite preview truncated)";
156
- var REWRITE_HEADER = "The format hook rewrote this file after your edit, so your in-memory copy is now stale \u2014 re-read it before the next Edit or the match will miss.";
157
- var REWRITE_RANGE_PREFIX = "Changed around lines ";
158
- var LINE_SEPARATOR = "\n";
159
- var FIRST_LINE = 1;
160
- function common_prefix_length(before, after) {
161
- const limit = Math.min(before.length, after.length);
162
- let index = 0;
163
- while (index < limit && before[index] === after[index]) index += 1;
164
- return index;
165
- }
166
- function common_suffix_length(before, after, prefix) {
167
- const limit = Math.min(before.length, after.length) - prefix;
168
- let index = 0;
169
- while (index < limit && before.at(-1 - index) === after.at(-1 - index)) index += 1;
170
- return index;
171
- }
172
- function changed_range(before, after) {
173
- const before_lines = before.split(LINE_SEPARATOR);
174
- const after_lines = after.split(LINE_SEPARATOR);
175
- const prefix = common_prefix_length(before_lines, after_lines);
176
- const last = after_lines.length - common_suffix_length(before_lines, after_lines, prefix);
177
- return {
178
- start_line: prefix + FIRST_LINE,
179
- end_line: Math.max(prefix + FIRST_LINE, last),
180
- body: after_lines.slice(prefix, last).join(LINE_SEPARATOR)
181
- };
182
- }
183
- function cap_body(body) {
184
- if (body.length <= MAX_REWRITE_CHARS) return body;
185
- return `${body.slice(0, MAX_REWRITE_CHARS)}${REWRITE_TRUNCATION_NOTICE}`;
186
- }
187
- function build(before, after) {
188
- if (before === after) return void 0;
189
- const range = changed_range(before, after);
190
- const location = `${REWRITE_RANGE_PREFIX}${String(range.start_line)}-${String(range.end_line)}:`;
191
- return `${REWRITE_HEADER}
192
- ${location}
193
- ${cap_body(range.body)}`;
194
- }
195
- function read_text(file_path) {
196
- if (file_path === void 0) return "";
197
- try {
198
- return readFileSync2(file_path, "utf8");
199
- } catch {
200
- return "";
201
- }
202
- }
203
- var rewrite_notice = { build, read_text };
204
-
205
- // scripts/hooks/format-edited-file.ts
206
- var hook_payload_schema = z2.object({
207
- tool_input: z2.object({ file_path: z2.string().min(1) }).optional()
208
- });
209
- var PRETTIER_EXTENSIONS = /* @__PURE__ */ new Set([
210
- ".ts",
211
- ".tsx",
212
- ".js",
213
- ".jsx",
214
- ".mjs",
215
- ".cjs",
216
- ".svelte",
217
- ".json",
218
- ".jsonc",
219
- ".md",
220
- ".yml",
221
- ".yaml",
222
- ".css",
223
- ".html"
224
- ]);
225
- var ESLINT_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".svelte"]);
226
- var EXCLUDED_ANYWHERE = /* @__PURE__ */ new Set(["node_modules", ".git"]);
227
- var EXCLUDED_AT_ROOT = /* @__PURE__ */ new Set(["dist", "build"]);
228
- var PARENT_SEGMENT = "..";
229
- var PNPM2 = "pnpm";
230
- var PRETTIER_BIN = "prettier";
231
- var PRETTIER_ARGUMENTS = ["--write", "--ignore-unknown"];
232
- var ESLINT_BIN = "eslint";
233
- var ESLINT_ARGUMENTS = [
234
- "--fix",
235
- "--no-error-on-unmatched-pattern",
236
- ...ESLINT_EDIT_CACHE_FLAGS
237
- ];
238
- var ESLINT_DAEMON = "eslint_d";
239
- var DAEMON_RESTART = "restart";
240
- var ESLINT_CONFIG_DIR = "eslint";
241
- var ESLINT_CONFIG_ENTRY = /^eslint\.config\.[cm]?[jt]s$/u;
242
- var PROCESS_TIMEOUT_MS2 = 15e3;
243
- var DIAGNOSTIC_HEADER = "The edit hook could not auto-fix these lint problems; address them now rather than at the gate:";
244
- var MAX_DIAGNOSTIC_CHARS2 = 4e3;
245
- var DIAGNOSTIC_TRUNCATION_NOTICE = "\n\u2026(diagnostics truncated)";
246
- var SECTION_SEPARATOR = "\n\n";
247
- var MODULE_DIRECTORY = path3.dirname(fileURLToPath(import.meta.url));
248
- function parse_edited_path(raw_payload) {
249
- try {
250
- const result = hook_payload_schema.safeParse(JSON.parse(raw_payload));
251
- return result.success ? result.data.tool_input?.file_path : void 0;
252
- } catch {
253
- return void 0;
254
- }
255
- }
256
- function is_excluded(relative_path) {
257
- const segments = relative_path.split(path3.sep);
258
- return segments.some((segment) => EXCLUDED_ANYWHERE.has(segment)) || EXCLUDED_AT_ROOT.has(segments[0] ?? "");
259
- }
260
- function relative_to_root(project_root, file_path) {
261
- const relative = path3.relative(path3.resolve(project_root), path3.resolve(file_path));
262
- const is_inside_root = relative !== "" && relative.split(path3.sep)[0] !== PARENT_SEGMENT && !path3.isAbsolute(relative);
263
- return is_inside_root ? relative : void 0;
264
- }
265
- function is_formattable(file_path, project_root) {
266
- const relative = relative_to_root(project_root, file_path);
267
- return relative !== void 0 && !is_excluded(relative) && existsSync3(file_path);
268
- }
269
- function plan_commands(file_path, project_root) {
270
- if (!is_formattable(file_path, project_root)) return [];
271
- const extension = path3.extname(file_path).toLowerCase();
272
- const commands = [];
273
- if (ESLINT_EXTENSIONS.has(extension)) {
274
- commands.push({ bin: ESLINT_BIN, command_arguments: [...ESLINT_ARGUMENTS, file_path] });
275
- }
276
- if (PRETTIER_EXTENSIONS.has(extension)) {
277
- commands.push({ bin: PRETTIER_BIN, command_arguments: [...PRETTIER_ARGUMENTS, file_path] });
278
- }
279
- return commands;
280
- }
281
- function select_invocation(command, routes) {
282
- if (routes.daemon_cli !== void 0) {
283
- return {
284
- bin: process.execPath,
285
- command_arguments: [routes.daemon_cli, ...command.command_arguments]
286
- };
287
- }
288
- if (routes.shim !== void 0) {
289
- return { bin: routes.shim, command_arguments: command.command_arguments };
290
- }
291
- return { bin: PNPM2, command_arguments: ["exec", command.bin, ...command.command_arguments] };
292
- }
293
- var DAEMON_BINS = /* @__PURE__ */ new Set([ESLINT_BIN, ESLINT_DAEMON]);
294
- function resolve_daemon_cli(bin, project_root) {
295
- if (!DAEMON_BINS.has(bin)) return void 0;
296
- return resolve_package_bin(MODULE_DIRECTORY, ESLINT_DAEMON, ESLINT_DAEMON) ?? resolve_package_bin(project_root, ESLINT_DAEMON, ESLINT_DAEMON);
297
- }
298
- function is_eslint_config_input(relative_path) {
299
- return relative_path.split(path3.sep)[0] === ESLINT_CONFIG_DIR || ESLINT_CONFIG_ENTRY.test(relative_path);
300
- }
301
- function plan_daemon_restart(file_path, project_root) {
302
- const relative = relative_to_root(project_root, file_path);
303
- if (relative === void 0 || !is_eslint_config_input(relative)) return [];
304
- if (resolve_daemon_cli(ESLINT_DAEMON, project_root) === void 0) return [];
305
- return [{ bin: ESLINT_DAEMON, command_arguments: [DAEMON_RESTART] }];
306
- }
307
- function resolve_invocations(command, project_root) {
308
- const shim = resolve_local_bin(project_root, command.bin);
309
- const routes = {
310
- daemon_cli: resolve_daemon_cli(command.bin, project_root),
311
- shim: existsSync3(shim) ? shim : void 0
312
- };
313
- const without_daemon = select_invocation(command, { ...routes, daemon_cli: void 0 });
314
- if (routes.daemon_cli === void 0) return [without_daemon];
315
- return [select_invocation(command, routes), without_daemon];
316
- }
317
- function is_start_failure(outcome) {
318
- return outcome.exit_code !== 0 && outcome.stdout.length === 0;
319
- }
320
- async function spawn_invocation(invocation, project_root) {
321
- const result = await execa2(invocation.bin, [...invocation.command_arguments], {
322
- reject: false,
323
- cwd: project_root,
324
- env: { ESLINT_D_MISS: "fail" },
325
- stdout: "pipe",
326
- stderr: "ignore",
327
- timeout: PROCESS_TIMEOUT_MS2
328
- });
329
- return { exit_code: result.exitCode ?? 1, stdout: result.stdout };
330
- }
331
- async function run_command(command, project_root) {
332
- let outcome = { exit_code: 0, stdout: "" };
333
- for (const invocation of resolve_invocations(command, project_root)) {
334
- outcome = await spawn_invocation(invocation, project_root);
335
- if (!is_start_failure(outcome)) return outcome;
336
- }
337
- return outcome;
338
- }
339
- function eslint_unfixed(command, outcome) {
340
- if (command.bin !== ESLINT_BIN) return void 0;
341
- if (outcome.exit_code === 0 || outcome.stdout.length === 0) return void 0;
342
- return outcome.stdout;
343
- }
344
- function format_diagnostics(unfixed) {
345
- if (unfixed === void 0) return void 0;
346
- const is_over = unfixed.length > MAX_DIAGNOSTIC_CHARS2;
347
- const body = is_over ? `${unfixed.slice(0, MAX_DIAGNOSTIC_CHARS2)}${DIAGNOSTIC_TRUNCATION_NOTICE}` : unfixed;
348
- return `${DIAGNOSTIC_HEADER}
349
- ${body}`;
350
- }
351
- async function collect_unfixed(plan, runner, project_root) {
352
- let unfixed = "";
353
- for (const command of plan) {
354
- try {
355
- unfixed = eslint_unfixed(command, await runner(command, project_root)) ?? unfixed;
356
- } catch {
357
- continue;
358
- }
359
- }
360
- return unfixed;
361
- }
362
- async function format_edited_file(raw_payload, runner, project_root) {
363
- const file_path = parse_edited_path(raw_payload);
364
- if (file_path === void 0) return void 0;
365
- const plan = [
366
- ...plan_commands(file_path, project_root),
367
- ...plan_daemon_restart(file_path, project_root)
368
- ];
369
- const unfixed = await collect_unfixed(plan, runner, project_root);
370
- return format_diagnostics(unfixed === "" ? void 0 : unfixed);
371
- }
372
- async function format_edited_payload(raw_payload, project_root) {
373
- return await format_edited_file(raw_payload, run_command, project_root);
374
- }
375
- var HOOK_EVENT_NAME = "PostToolUse";
376
- function build_envelope(additional_context) {
377
- return JSON.stringify({
378
- hookSpecificOutput: { hookEventName: HOOK_EVENT_NAME, additionalContext: additional_context }
379
- });
380
- }
381
- function density_envelope(raw_payload) {
382
- const notice = time_density_hook.density_notice(raw_payload);
383
- return notice === void 0 ? void 0 : build_envelope(notice);
384
- }
385
- function compose_context(notice, diagnostics) {
386
- const sections = [notice, diagnostics].filter(
387
- (section) => section !== void 0
388
- );
389
- return sections.length === 0 ? void 0 : sections.join(SECTION_SEPARATOR);
390
- }
391
- function report_no_payload() {
392
- process.stderr.write(
393
- "format:edited reads a Claude Code PostToolUse payload on stdin; it is not run by hand.\n"
394
- );
395
- }
396
- async function run_hook(payload) {
397
- const notice = time_density_hook.density_notice(payload);
398
- const file_path = parse_edited_path(payload);
399
- const before = rewrite_notice.read_text(file_path);
400
- const lint = await format_edited_payload(payload, process.cwd());
401
- const rewrite = rewrite_notice.build(before, rewrite_notice.read_text(file_path));
402
- const spelling = await edited_cspell.spelling_diagnostics(file_path, process.cwd());
403
- const parts = compose_context(rewrite, compose_context(lint, spelling));
404
- const context = compose_context(notice, parts);
405
- if (context !== void 0) process.stdout.write(`${build_envelope(context)}
406
- `);
407
- }
408
- if (process.argv[1] === fileURLToPath(import.meta.url)) {
409
- if (process.stdin.isTTY) {
410
- report_no_payload();
411
- } else {
412
- await run_hook(await text(process.stdin));
413
- }
414
- }
415
-
416
- export {
417
- ESLINT_DAEMON,
418
- PROCESS_TIMEOUT_MS2 as PROCESS_TIMEOUT_MS,
419
- MAX_DIAGNOSTIC_CHARS2 as MAX_DIAGNOSTIC_CHARS,
420
- parse_edited_path,
421
- relative_to_root,
422
- plan_commands,
423
- select_invocation,
424
- plan_daemon_restart,
425
- resolve_invocations,
426
- is_start_failure,
427
- format_edited_file,
428
- format_edited_payload,
429
- build_envelope,
430
- density_envelope,
431
- compose_context
432
- };
@@ -1,68 +0,0 @@
1
- import {
2
- investigation_reads
3
- } from "./chunk-AHD5IPWI.js";
4
- import {
5
- lane_guard_policy
6
- } from "./chunk-QUZ5HPIE.js";
7
- import {
8
- hook_decision
9
- } from "./chunk-DTAXH2A2.js";
10
-
11
- // scripts/delegation/investigation-guard.ts
12
- import { text } from "node:stream/consumers";
13
- import { fileURLToPath } from "node:url";
14
- var SWITCH_ENV_KEY = "JOSH_INVESTIGATION_GUARD";
15
- var STAMP_PREFIX = "josh-investigation-guard-";
16
- var NOTICE_STAMP_PREFIX = "josh-investigation-guard-notice-";
17
- function investigation_mode() {
18
- return lane_guard_policy.mode_here("investigation");
19
- }
20
- function should_block(tail, call, refused_at_ms, run) {
21
- if (investigation_mode() !== "refuse") return false;
22
- return investigation_reads.should_block(tail, call, refused_at_ms, run);
23
- }
24
- function should_notify(tail, call, notified_at_ms, run) {
25
- if (investigation_mode() !== "notice") return false;
26
- return investigation_reads.should_block(tail, call, notified_at_ms, run);
27
- }
28
- var NOTICE = `\u{1F4A1} investigation: files read and not edited since the last delegated unit reached the threshold, so the reading from here should go to a unit of its own. This is a notice, not a refusal \u2014 the read proceeds, because a dispatched lane child ends its turn on a denial. Ask \`pnpm josh delegate investigation\`, then brief a unit with what the main line has already concluded and what is left to find out; it returns the conclusion plus its \`file:line\` citations, never the file text. Keep a read in the main line only where this run will edit that file. This recurs on the next accumulation.`;
29
- function notice_text(_call, tail) {
30
- const pending = investigation_reads.tally_of(tail).pending.map((absolute) => investigation_reads.repository_relative(absolute));
31
- return pending.length === 0 ? NOTICE : `${NOTICE} Read and not edited so far: ${pending.join(" ")}.`;
32
- }
33
- var GUARD = hook_decision.create_transcript_guard({
34
- prefix: STAMP_PREFIX,
35
- switch_key: SWITCH_ENV_KEY,
36
- is_candidate: investigation_reads.is_refusable_call,
37
- should_block,
38
- reason: investigation_reads.REASON,
39
- // The lane-child notice fires where the refusal is withheld (kit#2382), on a record of its own so it
40
- // never spends the refusal's stamp.
41
- notify: {
42
- prefix: NOTICE_STAMP_PREFIX,
43
- should_notify,
44
- text: notice_text
45
- }
46
- });
47
- var investigation_refusal = GUARD.refusal;
48
- var investigation_outcome = GUARD.outcome;
49
- var { is_enabled, refusal_path } = GUARD;
50
- var investigation_notice_path = hook_decision.create_refusal_stamp(NOTICE_STAMP_PREFIX).path;
51
- var { deny_envelope, load_environment_file, DISABLED_VALUES } = hook_decision;
52
- if (process.argv[1] === fileURLToPath(import.meta.url)) {
53
- if (process.stdin.isTTY) hook_decision.report_no_payload("investigation:guard");
54
- else hook_decision.write_outcome(await text(process.stdin), investigation_outcome);
55
- }
56
-
57
- export {
58
- SWITCH_ENV_KEY,
59
- NOTICE,
60
- investigation_refusal,
61
- investigation_outcome,
62
- is_enabled,
63
- refusal_path,
64
- investigation_notice_path,
65
- deny_envelope,
66
- load_environment_file,
67
- DISABLED_VALUES
68
- };