@primitive.ai/prim 0.1.0-alpha.128 → 0.1.0-alpha.129

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 (43) hide show
  1. package/dist/{chunk-6QAXVFRJ.js → chunk-BVGASV3B.js} +942 -123
  2. package/dist/{chunk-M6KIDB5R.js → chunk-DYXCJ6WZ.js} +10 -10
  3. package/dist/{chunk-B3ICJZXV.js → chunk-FHDTJP2C.js} +2 -2
  4. package/dist/{chunk-XINFTNA2.js → chunk-HDL3UXYJ.js} +5 -5
  5. package/dist/{chunk-C357P37M.js → chunk-IJ3W2YBM.js} +4 -4
  6. package/dist/{chunk-N6PZE7HX.js → chunk-IZAEAALI.js} +2 -2
  7. package/dist/{chunk-PTZ6BWSU.js → chunk-KZNOT2YH.js} +2 -2
  8. package/dist/{chunk-P4O7L7JZ.js → chunk-L7U3G4XR.js} +2 -2
  9. package/dist/{chunk-EQWUCFXK.js → chunk-LBZJD2I4.js} +3 -5
  10. package/dist/{chunk-PRJ7P6J5.js → chunk-MMMY57UA.js} +22 -837
  11. package/dist/{chunk-WEGZGF3K.js → chunk-NWWTFQP2.js} +1 -1
  12. package/dist/{chunk-NYDM4HSS.js → chunk-QSDWWEHF.js} +2 -2
  13. package/dist/{chunk-3KPTVK4N.js → chunk-RAEOSDQ6.js} +1 -1
  14. package/dist/{chunk-E57UVUJL.js → chunk-RS5ADTDF.js} +4 -4
  15. package/dist/{chunk-ANMNGGTN.js → chunk-RWJ7WHTJ.js} +2 -2
  16. package/dist/{chunk-RDT2IV2Z.js → chunk-SJE7OWVS.js} +3 -3
  17. package/dist/{chunk-VLT2KGPE.js → chunk-USJ4JGDC.js} +3 -3
  18. package/dist/{chunk-ZCT23NBS.js → chunk-YPHDV5AS.js} +2 -2
  19. package/dist/{chunk-QQ3G5SXX.js → chunk-YSV43WLK.js} +1 -1
  20. package/dist/{chunk-4DYEBYKM.js → chunk-ZKIBD5MO.js} +2 -2
  21. package/dist/daemon/server.js +624 -289
  22. package/dist/hook-runtime/daemon/server.js +624 -289
  23. package/dist/hook-runtime/hooks/post-commit.js +307 -186
  24. package/dist/hook-runtime/hooks/post-rewrite.js +302 -181
  25. package/dist/hook-runtime/hooks/post-tool-use.js +490 -276
  26. package/dist/hook-runtime/hooks/pre-commit.js +516 -181
  27. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +221 -7
  28. package/dist/hook-runtime/hooks/prim-hook.js +511 -297
  29. package/dist/hook-runtime/hooks/session-end.js +229 -229
  30. package/dist/hook-runtime/hooks/session-start.js +170 -14
  31. package/dist/hook-runtime/index.js +1623 -1607
  32. package/dist/hook-runtime/statusline-main.js +245 -124
  33. package/dist/hooks/post-commit.js +7 -7
  34. package/dist/hooks/post-rewrite.js +6 -6
  35. package/dist/hooks/post-tool-use.js +15 -15
  36. package/dist/hooks/pre-commit.js +4 -4
  37. package/dist/hooks/pre-tool-use-worker.js +9 -9
  38. package/dist/hooks/prim-hook.js +16 -16
  39. package/dist/hooks/session-end.js +4 -4
  40. package/dist/hooks/session-start.js +12 -13
  41. package/dist/index.js +24 -24
  42. package/dist/statusline-main.js +245 -124
  43. package/package.json +1 -1
@@ -55,42 +55,42 @@ var require_ucs2length = __commonJS({
55
55
  // src/hooks/post-rewrite.ts
56
56
  import { execFileSync as execFileSync6, spawn as spawn2 } from "child_process";
57
57
  import {
58
- constants as constants3,
58
+ constants as constants4,
59
59
  closeSync as closeSync4,
60
60
  fstatSync as fstatSync2,
61
- lstatSync as lstatSync7,
61
+ lstatSync as lstatSync8,
62
62
  openSync as openSync4,
63
- readFileSync as readFileSync17,
63
+ readFileSync as readFileSync18,
64
64
  unlinkSync as unlinkSync2
65
65
  } from "fs";
66
- import { basename as basename4, dirname as dirname11, isAbsolute as isAbsolute5, join as join19 } from "path";
67
- import { fileURLToPath as fileURLToPath4 } from "url";
66
+ import { basename as basename4, dirname as dirname13, isAbsolute as isAbsolute6, join as join21 } from "path";
67
+ import { fileURLToPath as fileURLToPath5 } from "url";
68
68
 
69
69
  // src/binding.ts
70
- import { existsSync as existsSync4, readFileSync as readFileSync8 } from "fs";
71
- import { dirname as dirname6, join as join10 } from "path";
70
+ import { existsSync as existsSync6, readFileSync as readFileSync9 } from "fs";
71
+ import { dirname as dirname8, join as join12 } from "path";
72
72
 
73
73
  // src/lib/credentials.ts
74
- import { createHash as createHash6 } from "crypto";
75
- import { readFileSync as readFileSync7 } from "fs";
76
- import { join as join9 } from "path";
74
+ import { createHash as createHash7 } from "crypto";
75
+ import { readFileSync as readFileSync8 } from "fs";
76
+ import { join as join11 } from "path";
77
77
 
78
78
  // src/lib/machine-credentials.ts
79
79
  import { execFileSync as execFileSync2 } from "child_process";
80
- import { createHash as createHash5, randomBytes as randomBytes3, randomUUID as randomUUID2 } from "crypto";
80
+ import { createHash as createHash6, randomBytes as randomBytes4, randomUUID as randomUUID2 } from "crypto";
81
81
  import {
82
- chmodSync,
83
- existsSync as existsSync3,
82
+ chmodSync as chmodSync2,
83
+ existsSync as existsSync5,
84
84
  linkSync,
85
- lstatSync as lstatSync4,
86
- mkdirSync as mkdirSync3,
87
- readFileSync as readFileSync6,
88
- rmSync as rmSync6,
89
- writeFileSync as writeFileSync3
85
+ lstatSync as lstatSync5,
86
+ mkdirSync as mkdirSync4,
87
+ readFileSync as readFileSync7,
88
+ rmSync as rmSync7,
89
+ writeFileSync as writeFileSync4
90
90
  } from "fs";
91
- import { createRequire } from "module";
92
- import { dirname as dirname5, join as join8 } from "path";
93
- import { fileURLToPath as fileURLToPath3 } from "url";
91
+ import { createRequire as createRequire2 } from "module";
92
+ import { dirname as dirname7, join as join10 } from "path";
93
+ import { fileURLToPath as fileURLToPath4 } from "url";
94
94
 
95
95
  // src/lib/atomic-file.ts
96
96
  import { randomUUID } from "crypto";
@@ -113,13 +113,27 @@ import { existsSync, mkdirSync as mkdirSync2, readFileSync, rmSync as rmSync2, s
113
113
  import { dirname as dirname2, join } from "path";
114
114
  var syncSleeper = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
115
115
 
116
- // src/lib/machine-broker.ts
117
- import { spawn } from "child_process";
118
- import { createHash, createHmac, randomBytes as randomBytes2, timingSafeEqual } from "crypto";
119
- import { lstatSync, readFileSync as readFileSync3, rmSync as rmSync3 } from "fs";
120
- import { createServer } from "http";
121
- import { basename, join as join4 } from "path";
122
- import { fileURLToPath as fileURLToPath2 } from "url";
116
+ // src/lib/hook-runtime.ts
117
+ import { createHash, randomBytes as randomBytes2 } from "crypto";
118
+ import {
119
+ constants as constants2,
120
+ accessSync,
121
+ chmodSync,
122
+ copyFileSync,
123
+ existsSync as existsSync4,
124
+ lstatSync,
125
+ mkdirSync as mkdirSync3,
126
+ mkdtempSync,
127
+ readFileSync as readFileSync3,
128
+ readdirSync,
129
+ realpathSync,
130
+ renameSync as renameSync2,
131
+ rmSync as rmSync3,
132
+ statSync as statSync2,
133
+ utimesSync,
134
+ writeFileSync as writeFileSync3
135
+ } from "fs";
136
+ import { delimiter, dirname as dirname5, isAbsolute as isAbsolute3, join as join5, resolve } from "path";
123
137
 
124
138
  // src/lib/bin-path.ts
125
139
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
@@ -127,6 +141,7 @@ import { dirname as dirname3, isAbsolute, join as join2 } from "path";
127
141
  import { fileURLToPath } from "url";
128
142
  var PKG_NAME = "@primitive.ai/prim";
129
143
  var ROOT_WALK_LIMIT = 6;
144
+ var STABLE_HOOK_LAUNCHER_NAME = "prim-hook-launcher-v1";
130
145
  var resolvedRoot;
131
146
  function locateRoot() {
132
147
  if (resolvedRoot !== void 0) {
@@ -165,6 +180,140 @@ var PRIM_CONFIG_SHELL_RESOLVER = [
165
180
  "fi; fi; "
166
181
  ].join("");
167
182
 
183
+ // src/lib/git-hook-contract.ts
184
+ var GIT_HOOK_ENTRYPOINT_CONTENT = `#!/bin/sh
185
+ # prim git hook entrypoint v1 \u2014 managed by prim; do not edit.
186
+ # Run by the "# >>> prim <hook> hook >>>" block in a Git hook file. Acts only
187
+ # where prim is active (git config prim.active true) and never fails the hook.
188
+ case "$0" in */*) prim_dir=\${0%/*} ;; *) exit 0 ;; esac
189
+ prim_launcher="$prim_dir/${STABLE_HOOK_LAUNCHER_NAME}"
190
+ [ -x "$prim_launcher" ] || exit 0
191
+ [ "$(git config --get prim.active 2>/dev/null)" = "true" ] || exit 0
192
+ prim_hook=\${1-}
193
+ if [ "$#" -gt 0 ]; then shift; fi
194
+ case "$prim_hook" in
195
+ pre-commit)
196
+ "$prim_launcher" prim-pre-commit "$@" || :
197
+ ;;
198
+ post-commit)
199
+ prim_sha=$(git rev-parse --verify HEAD 2>/dev/null) || exit 0
200
+ case "$prim_sha" in *[!0-9a-f]* | "") exit 0 ;; esac
201
+ case "\${#prim_sha}" in 40 | 64) ;; *) exit 0 ;; esac
202
+ prim_branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null) || prim_branch=
203
+ prim_observed=$(mktemp "\${TMPDIR:-/tmp}/prim-post-commit-observed.XXXXXXXX" 2>/dev/null) || prim_observed=
204
+ (
205
+ trap '' HUP
206
+ trap 'if [ -n "$prim_observed" ]; then rm -f "$prim_observed"; fi' 0
207
+ PRIM_COMMIT_SHA=$prim_sha PRIM_COMMIT_BRANCH=$prim_branch PRIM_COMMIT_OBSERVED_FILE=$prim_observed "$prim_launcher" prim-post-commit
208
+ ) </dev/null >/dev/null 2>&1 &
209
+ ;;
210
+ post-rewrite)
211
+ case "\${1-}" in amend | rebase) prim_source=$1 ;; *) exit 0 ;; esac
212
+ prim_pairs=$(mktemp "\${TMPDIR:-/tmp}/prim-post-rewrite-pairs.XXXXXXXX" 2>/dev/null) || exit 0
213
+ if ! chmod 600 "$prim_pairs" 2>/dev/null || ! cat >"$prim_pairs"; then
214
+ rm -f "$prim_pairs"
215
+ exit 0
216
+ fi
217
+ prim_branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null) || prim_branch=
218
+ (
219
+ trap '' HUP
220
+ trap 'rm -f "$prim_pairs"' 0
221
+ PRIM_REWRITE_SOURCE=$prim_source PRIM_REWRITE_BRANCH=$prim_branch PRIM_REWRITE_PAIRS_FILE=$prim_pairs "$prim_launcher" prim-post-rewrite
222
+ ) </dev/null >/dev/null 2>&1 &
223
+ ;;
224
+ esac
225
+ exit 0
226
+ `;
227
+
228
+ // src/lib/native-keyring.ts
229
+ import { existsSync as existsSync3 } from "fs";
230
+ import { createRequire } from "module";
231
+ import { dirname as dirname4, join as join3 } from "path";
232
+ import { fileURLToPath as fileURLToPath2 } from "url";
233
+ var require2 = createRequire(import.meta.url);
234
+
235
+ // src/lib/paths.ts
236
+ import { homedir } from "os";
237
+ import { isAbsolute as isAbsolute2, join as join4, normalize } from "path";
238
+ var UNSAFE_CONFIG_PATH_CHARACTERS = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u;
239
+ function absolutePath(value, variable) {
240
+ if (value !== void 0 && UNSAFE_CONFIG_PATH_CHARACTERS.test(value)) {
241
+ throw new Error(`${variable} contains unsafe characters`);
242
+ }
243
+ if (!value || value.trim() !== value || !isAbsolute2(value)) return;
244
+ const normalized = normalize(value);
245
+ return normalized === value ? value : void 0;
246
+ }
247
+ function resolvePrimConfigDirectory(options = {}) {
248
+ const env = options.env ?? process.env;
249
+ const explicit = absolutePath(env.PRIM_CONFIG_DIR, "PRIM_CONFIG_DIR");
250
+ if (explicit) return { path: explicit, source: "explicit" };
251
+ const xdgConfigHome = absolutePath(env.XDG_CONFIG_HOME, "XDG_CONFIG_HOME");
252
+ if (xdgConfigHome) return { path: join4(xdgConfigHome, "prim"), source: "xdg" };
253
+ const home = absolutePath(options.homeDir ?? homedir(), "HOME");
254
+ if (!home) {
255
+ throw new Error("cannot resolve Primitive config directory: HOME is not an absolute path");
256
+ }
257
+ return { path: join4(home, ".config", "prim"), source: "default" };
258
+ }
259
+ function primConfigDirectory(options = {}) {
260
+ return resolvePrimConfigDirectory(options).path;
261
+ }
262
+
263
+ // src/lib/hook-runtime.ts
264
+ var RELEASE_PREFIX = "release-";
265
+ var MAX_MANIFEST_BYTES = 64 * 1024;
266
+ var RELEASE_GRACE_MS = 10 * 60 * 1e3;
267
+ var HOOK_RUNTIME_ENTRIES = {
268
+ // SessionStart self-healing resolves this exact CLI entry to run
269
+ // `daemon ensure`; it must travel with the immutable hook release.
270
+ prim: "dist/index.js",
271
+ "prim-hook": "dist/hooks/prim-hook.js",
272
+ "prim-pre-commit": "dist/hooks/pre-commit.js",
273
+ "prim-post-commit": "dist/hooks/post-commit.js",
274
+ "prim-post-rewrite": "dist/hooks/post-rewrite.js",
275
+ "prim-pre-tool-use-worker": "dist/hooks/pre-tool-use-worker.js",
276
+ "prim-pre-tool-use": "dist/hooks/pre-tool-use.js",
277
+ "prim-post-tool-use": "dist/hooks/post-tool-use.js",
278
+ "prim-session-start": "dist/hooks/session-start.js",
279
+ "prim-session-end": "dist/hooks/session-end.js",
280
+ "prim-daemon-server": "dist/daemon/server.js",
281
+ "prim-statusline": "dist/statusline-main.js"
282
+ };
283
+ var SOURCE_ENTRIES = Object.fromEntries(
284
+ Object.entries(HOOK_RUNTIME_ENTRIES).map(([bin, target]) => [
285
+ bin,
286
+ target.replace(/^dist\//u, "")
287
+ ])
288
+ );
289
+ var STABLE_HOOK_LAUNCHER_CONTENT = `#!/bin/sh
290
+ set -eu
291
+ case "$0" in */*) prim_launcher_dir=\${0%/*} ;; *) exit 78 ;; esac
292
+ IFS= read -r prim_release_name < "$prim_launcher_dir/hook-runtime/current" || exit 69
293
+ case "$prim_release_name" in ${RELEASE_PREFIX}*) ;; *) exit 69 ;; esac
294
+ prim_release_id=\${prim_release_name#${RELEASE_PREFIX}}
295
+ case "$prim_release_id" in *[!0-9a-f]*|"") exit 69 ;; esac
296
+ [ "\${#prim_release_id}" -eq 64 ] || exit 69
297
+ prim_release="$prim_launcher_dir/hook-runtime/releases/$prim_release_name"
298
+ case "\${1-}" in
299
+ ${Object.entries(HOOK_RUNTIME_ENTRIES).map(([bin, entry]) => ` ${bin}) prim_entry="$prim_release/${entry}" ;;`).join("\n")}
300
+ *) exit 64 ;;
301
+ esac
302
+ shift
303
+ IFS= read -r prim_node < "$prim_release/node" || exit 69
304
+ case "$prim_node" in /*) ;; *) exit 69 ;; esac
305
+ [ -x "$prim_node" ] && [ -f "$prim_entry" ] || exit 69
306
+ exec "$prim_node" "$prim_entry" "$@"
307
+ `;
308
+
309
+ // src/lib/machine-broker.ts
310
+ import { spawn } from "child_process";
311
+ import { createHash as createHash2, createHmac, randomBytes as randomBytes3, timingSafeEqual } from "crypto";
312
+ import { lstatSync as lstatSync2, readFileSync as readFileSync4, rmSync as rmSync4 } from "fs";
313
+ import { createServer } from "http";
314
+ import { basename, join as join6 } from "path";
315
+ import { fileURLToPath as fileURLToPath3 } from "url";
316
+
168
317
  // src/lib/loopback-fetch.ts
169
318
  import { request } from "http";
170
319
  import { Readable } from "stream";
@@ -321,34 +470,6 @@ function parseMachineIdentity(value, clientId) {
321
470
  };
322
471
  }
323
472
 
324
- // src/lib/paths.ts
325
- import { homedir } from "os";
326
- import { isAbsolute as isAbsolute2, join as join3, normalize } from "path";
327
- var UNSAFE_CONFIG_PATH_CHARACTERS = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u;
328
- function absolutePath(value, variable) {
329
- if (value !== void 0 && UNSAFE_CONFIG_PATH_CHARACTERS.test(value)) {
330
- throw new Error(`${variable} contains unsafe characters`);
331
- }
332
- if (!value || value.trim() !== value || !isAbsolute2(value)) return;
333
- const normalized = normalize(value);
334
- return normalized === value ? value : void 0;
335
- }
336
- function resolvePrimConfigDirectory(options = {}) {
337
- const env = options.env ?? process.env;
338
- const explicit = absolutePath(env.PRIM_CONFIG_DIR, "PRIM_CONFIG_DIR");
339
- if (explicit) return { path: explicit, source: "explicit" };
340
- const xdgConfigHome = absolutePath(env.XDG_CONFIG_HOME, "XDG_CONFIG_HOME");
341
- if (xdgConfigHome) return { path: join3(xdgConfigHome, "prim"), source: "xdg" };
342
- const home = absolutePath(options.homeDir ?? homedir(), "HOME");
343
- if (!home) {
344
- throw new Error("cannot resolve Primitive config directory: HOME is not an absolute path");
345
- }
346
- return { path: join3(home, ".config", "prim"), source: "default" };
347
- }
348
- function primConfigDirectory(options = {}) {
349
- return resolvePrimConfigDirectory(options).path;
350
- }
351
-
352
473
  // src/lib/machine-broker.ts
353
474
  var MAX_RESPONSE_BYTES = 96 * 1024;
354
475
  var MAX_FORWARD_REQUEST_BYTES = 12 * 1024 * 1024;
@@ -357,23 +478,23 @@ var MAX_FORWARD_RESPONSE_BYTES = 36 * 1024 * 1024;
357
478
  var IDLE_MS = 5 * 6e4;
358
479
 
359
480
  // src/lib/machine-retry.ts
360
- import { createHash as createHash2 } from "crypto";
361
- import { lstatSync as lstatSync2, readFileSync as readFileSync4, readdirSync, rmSync as rmSync4 } from "fs";
362
- import { join as join5 } from "path";
481
+ import { createHash as createHash3 } from "crypto";
482
+ import { lstatSync as lstatSync3, readFileSync as readFileSync5, readdirSync as readdirSync2, rmSync as rmSync5 } from "fs";
483
+ import { join as join7 } from "path";
363
484
  var MAX_SERVER_WAIT_MS = 15 * 6e4;
364
485
 
365
486
  // src/lib/session-identity.ts
366
487
  import { execFile } from "child_process";
367
- import { createHash as createHash4 } from "crypto";
368
- import { rmSync as rmSync5 } from "fs";
369
- import { join as join7 } from "path";
488
+ import { createHash as createHash5 } from "crypto";
489
+ import { rmSync as rmSync6 } from "fs";
490
+ import { join as join9 } from "path";
370
491
  import { promisify } from "util";
371
492
 
372
493
  // src/lib/git.ts
373
494
  import { execFileSync } from "child_process";
374
- import { createHash as createHash3 } from "crypto";
375
- import { lstatSync as lstatSync3, readFileSync as readFileSync5, realpathSync } from "fs";
376
- import { basename as basename2, dirname as dirname4, isAbsolute as isAbsolute3, join as join6, relative, resolve, sep } from "path";
495
+ import { createHash as createHash4 } from "crypto";
496
+ import { lstatSync as lstatSync4, readFileSync as readFileSync6, realpathSync as realpathSync2 } from "fs";
497
+ import { basename as basename2, dirname as dirname6, isAbsolute as isAbsolute4, join as join8, relative, resolve as resolve2, sep } from "path";
377
498
  var GIT_TIMEOUT_MS = 1e3;
378
499
  var MAX_SETTINGS_BYTES = 1024 * 1024;
379
500
  var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
@@ -427,12 +548,12 @@ function githubRepositoryFromRemote(remote) {
427
548
  return path ? parseGithubRepositoryName(path) : null;
428
549
  }
429
550
  function checkoutSettingsText(repoRoot) {
430
- const path = join6(repoRoot, ".claude", "settings.json");
551
+ const path = join8(repoRoot, ".claude", "settings.json");
431
552
  try {
432
- if (!lstatSync3(join6(repoRoot, ".claude")).isDirectory()) return null;
433
- const stat = lstatSync3(path);
553
+ if (!lstatSync4(join8(repoRoot, ".claude")).isDirectory()) return null;
554
+ const stat = lstatSync4(path);
434
555
  if (!stat.isFile() || stat.size > MAX_SETTINGS_BYTES) return null;
435
- return readFileSync5(path, "utf8");
556
+ return readFileSync6(path, "utf8");
436
557
  } catch {
437
558
  return null;
438
559
  }
@@ -485,16 +606,16 @@ function normalizeOriginRemote(remote) {
485
606
  }
486
607
  }
487
608
  function opaqueRepoKey(source, value) {
488
- return `repo_v1_${createHash3("sha256").update(`${source}\0${value}`).digest("hex")}`;
609
+ return `repo_v1_${createHash4("sha256").update(`${source}\0${value}`).digest("hex")}`;
489
610
  }
490
611
  function resolveRepositoryContext(cwd = process.cwd()) {
491
612
  const top = gitToplevel(cwd);
492
613
  if (!top) return null;
493
614
  let repoRoot;
494
615
  try {
495
- repoRoot = realpathSync.native(top);
616
+ repoRoot = realpathSync2.native(top);
496
617
  } catch {
497
- repoRoot = resolve(top);
618
+ repoRoot = resolve2(top);
498
619
  }
499
620
  const origin = gitValue(repoRoot, ["config", "--get", "remote.origin.url"]);
500
621
  const repoFullName = githubRepositoryFullName(repoRoot) ?? void 0;
@@ -564,7 +685,7 @@ var CHALLENGE_GONE = failure(
564
685
  NEW_SESSION_REMEDY
565
686
  );
566
687
  function hash(value) {
567
- return createHash4("sha256").update(value).digest("hex");
688
+ return createHash5("sha256").update(value).digest("hex");
568
689
  }
569
690
  function sessionContext(deps) {
570
691
  const env = deps.env ?? process.env;
@@ -591,9 +712,9 @@ function sessionContext(deps) {
591
712
  clientId: environment.clientId,
592
713
  generation: environment.generation,
593
714
  sessionId,
594
- tokenPath: join7(directory, `session_identity_${key}.json`),
595
- statePath: join7(directory, `session_identity_${key}.state.json`),
596
- lockPath: join7(directory, "session-identity.lock")
715
+ tokenPath: join9(directory, `session_identity_${key}.json`),
716
+ statePath: join9(directory, `session_identity_${key}.state.json`),
717
+ lockPath: join9(directory, "session-identity.lock")
597
718
  };
598
719
  }
599
720
  function readRecord(path) {
@@ -659,7 +780,7 @@ var SERVER_CONTRACT_FAILURE = failure(
659
780
  function sessionScoped(deps) {
660
781
  return !deps.localEnvironment && !deps.environmentOnly && sessionIdentityMode(deps);
661
782
  }
662
- var require2 = createRequire(import.meta.url);
783
+ var require3 = createRequire2(import.meta.url);
663
784
  var DEFAULT_API_URL2 = "https://api.getprimitive.ai";
664
785
  var PROFILE_FILE = "machine_profile.json";
665
786
  var cached;
@@ -670,10 +791,10 @@ function apiUrlFor(deps) {
670
791
  return machineApiUrl((deps.env ?? process.env).PRIM_API_URL?.trim() || DEFAULT_API_URL2);
671
792
  }
672
793
  function hash2(value) {
673
- return createHash5("sha256").update(value).digest("hex");
794
+ return createHash6("sha256").update(value).digest("hex");
674
795
  }
675
796
  function environmentContextPath(deps, clientId) {
676
- return join8(
797
+ return join10(
677
798
  configurationDirectory(deps),
678
799
  `machine_context_${hash2(`${apiUrlFor(deps)}\0${clientId}`)}.json`
679
800
  );
@@ -701,7 +822,7 @@ function readEnvironmentContext(environment, deps) {
701
822
  }
702
823
  function protectPath(path, directory) {
703
824
  if (process.platform !== "win32") {
704
- chmodSync(path, directory ? 448 : 384);
825
+ chmodSync2(path, directory ? 448 : 384);
705
826
  return;
706
827
  }
707
828
  const encodedPath = Buffer.from(path).toString("base64");
@@ -718,8 +839,8 @@ function protectPath(path, directory) {
718
839
  );
719
840
  }
720
841
  function ensureDirectory(directory) {
721
- mkdirSync3(directory, { recursive: true, mode: 448 });
722
- if (lstatSync4(directory).isSymbolicLink())
842
+ mkdirSync4(directory, { recursive: true, mode: 448 });
843
+ if (lstatSync5(directory).isSymbolicLink())
723
844
  throw new MachineAuthError(
724
845
  "unsafe_storage",
725
846
  "Credential directory must not be a symbolic link."
@@ -732,14 +853,14 @@ function readMachineMetadata(path) {
732
853
  function readPrivate(path) {
733
854
  let raw;
734
855
  try {
735
- const stat = lstatSync4(path);
856
+ const stat = lstatSync5(path);
736
857
  if (!stat.isFile() || stat.size > 96 * 1024 || process.platform !== "win32" && ((stat.mode & 63) !== 0 || stat.uid !== process.getuid?.())) {
737
858
  throw new MachineAuthError(
738
859
  "unsafe_storage",
739
860
  "Machine credential files must be owner-only regular files."
740
861
  );
741
862
  }
742
- raw = readFileSync6(path, "utf8");
863
+ raw = readFileSync7(path, "utf8");
743
864
  } catch (error) {
744
865
  if (error.code === "ENOENT") return void 0;
745
866
  throw error;
@@ -784,7 +905,7 @@ function parseProfile(value) {
784
905
  };
785
906
  }
786
907
  function readMachineProfile(deps = {}) {
787
- const value = readPrivate(join8(configurationDirectory(deps), PROFILE_FILE));
908
+ const value = readPrivate(join10(configurationDirectory(deps), PROFILE_FILE));
788
909
  return value === void 0 ? void 0 : parseProfile(value);
789
910
  }
790
911
  var NETWORK_SECRET_AUTH = "network-secret";
@@ -793,20 +914,20 @@ var INJECTED_IDENTITY_TTL_MS = 60 * 6e4;
793
914
  var brokerKeys = /* @__PURE__ */ new Map();
794
915
  function networkSecretBrokerKey(deps, clientId) {
795
916
  const directory = configurationDirectory(deps);
796
- const path = join8(directory, `machine_network_${hash2(`${apiUrlFor(deps)}\0${clientId}`)}.key`);
917
+ const path = join10(directory, `machine_network_${hash2(`${apiUrlFor(deps)}\0${clientId}`)}.key`);
797
918
  const known = brokerKeys.get(path);
798
919
  if (known) return known;
799
920
  ensureDirectory(directory);
800
921
  const read = () => {
801
922
  try {
802
- const stat = lstatSync4(path);
923
+ const stat = lstatSync5(path);
803
924
  if (!stat.isFile() || process.platform !== "win32" && ((stat.mode & 63) !== 0 || typeof process.getuid === "function" && stat.uid !== process.getuid()))
804
925
  throw new MachineAuthError(
805
926
  "unsafe_storage",
806
927
  `The machine broker key at ${path} is not an owner-only file. Delete it and retry.`,
807
928
  true
808
929
  );
809
- const value = readFileSync6(path, "utf8").trim();
930
+ const value = readFileSync7(path, "utf8").trim();
810
931
  return { key: /^[a-f0-9]{64}$/u.test(value) ? value : void 0 };
811
932
  } catch (error) {
812
933
  if (error.code === "ENOENT") return void 0;
@@ -825,16 +946,16 @@ function networkSecretBrokerKey(deps, clientId) {
825
946
  `The machine broker key at ${path} is damaged. Delete it and retry.`,
826
947
  true
827
948
  );
828
- const staged = `${path}.${process.pid}.${randomBytes3(6).toString("hex")}`;
949
+ const staged = `${path}.${process.pid}.${randomBytes4(6).toString("hex")}`;
829
950
  try {
830
- writeFileSync3(staged, `${randomBytes3(32).toString("hex")}
951
+ writeFileSync4(staged, `${randomBytes4(32).toString("hex")}
831
952
  `, { mode: 384, flag: "wx" });
832
953
  protectPath(staged, false);
833
954
  linkSync(staged, path);
834
955
  } catch (error) {
835
956
  if (error.code !== "EEXIST") throw error;
836
957
  } finally {
837
- rmSync6(staged, { force: true });
958
+ rmSync7(staged, { force: true });
838
959
  }
839
960
  }
840
961
  const key = read()?.key;
@@ -893,7 +1014,7 @@ function environmentCredentials(deps) {
893
1014
  }
894
1015
  function hasMachineConfiguration(deps = {}) {
895
1016
  const env = deps.env ?? process.env;
896
- const configured = env.PRIM_M2M_CLIENT_ID !== void 0 || env.PRIM_M2M_CLIENT_SECRET !== void 0 || env.PRIM_M2M_CLIENT_AUTH !== void 0 || existsSync3(join8(configurationDirectory(deps), PROFILE_FILE));
1017
+ const configured = env.PRIM_M2M_CLIENT_ID !== void 0 || env.PRIM_M2M_CLIENT_SECRET !== void 0 || env.PRIM_M2M_CLIENT_AUTH !== void 0 || existsSync5(join10(configurationDirectory(deps), PROFILE_FILE));
897
1018
  if (configured && env.PRIM_TOKEN?.trim()) {
898
1019
  throw new MachineAuthError(
899
1020
  "conflicting_credentials",
@@ -953,20 +1074,20 @@ function machinePendingBucket(identity) {
953
1074
 
954
1075
  // src/lib/credentials.ts
955
1076
  var CONFIG_DIRECTORY = primConfigDirectory();
956
- var TOKEN_FILE_PATH = join9(CONFIG_DIRECTORY, "token");
957
- var REFRESH_TOKEN_PATH = join9(CONFIG_DIRECTORY, "refresh_token");
958
- var TOKEN_EXPIRES_PATH = join9(CONFIG_DIRECTORY, "token_expires_at");
959
- var TERMINAL_REFRESH_PATH = join9(CONFIG_DIRECTORY, "refresh_terminal");
960
- var CREDENTIAL_METADATA_PATH = join9(CONFIG_DIRECTORY, "credential_metadata.json");
961
- var CREDENTIAL_FAMILY_PATH = join9(CONFIG_DIRECTORY, "credential_family.json");
962
- var CREDENTIAL_MIGRATION_PATH = join9(CONFIG_DIRECTORY, "credential_migration.json");
963
- var CREDENTIAL_LOCK_PATH = join9(CONFIG_DIRECTORY, "credentials.lock");
1077
+ var TOKEN_FILE_PATH = join11(CONFIG_DIRECTORY, "token");
1078
+ var REFRESH_TOKEN_PATH = join11(CONFIG_DIRECTORY, "refresh_token");
1079
+ var TOKEN_EXPIRES_PATH = join11(CONFIG_DIRECTORY, "token_expires_at");
1080
+ var TERMINAL_REFRESH_PATH = join11(CONFIG_DIRECTORY, "refresh_terminal");
1081
+ var CREDENTIAL_METADATA_PATH = join11(CONFIG_DIRECTORY, "credential_metadata.json");
1082
+ var CREDENTIAL_FAMILY_PATH = join11(CONFIG_DIRECTORY, "credential_family.json");
1083
+ var CREDENTIAL_MIGRATION_PATH = join11(CONFIG_DIRECTORY, "credential_migration.json");
1084
+ var CREDENTIAL_LOCK_PATH = join11(CONFIG_DIRECTORY, "credentials.lock");
964
1085
  var MAX_CREDENTIAL_METADATA_BYTES = 4096;
965
1086
  var CREDENTIAL_MIGRATION_VERSION = 1;
966
1087
  var CREDENTIAL_MIGRATION_STATE = "family_bound";
967
1088
  function readTrimmed(path) {
968
1089
  try {
969
- const value = readFileSync7(path, "utf8").trim();
1090
+ const value = readFileSync8(path, "utf8").trim();
970
1091
  return value || void 0;
971
1092
  } catch {
972
1093
  return void 0;
@@ -1003,7 +1124,7 @@ function resolveAuthCredential(options = {}) {
1003
1124
  return { token: stored, source: "token_file" };
1004
1125
  }
1005
1126
  function credentialFingerprint(value) {
1006
- return createHash6("sha256").update(value).digest("hex");
1127
+ return createHash7("sha256").update(value).digest("hex");
1007
1128
  }
1008
1129
  function parseLegacyBrokerCredentialMetadata(value) {
1009
1130
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
@@ -1023,7 +1144,7 @@ function parseLegacyBrokerCredentialMetadata(value) {
1023
1144
  function readBoundedCredentialJson(path) {
1024
1145
  let raw;
1025
1146
  try {
1026
- raw = readFileSync7(path, "utf8");
1147
+ raw = readFileSync8(path, "utf8");
1027
1148
  } catch (error) {
1028
1149
  return error.code === "ENOENT" ? void 0 : null;
1029
1150
  }
@@ -1096,14 +1217,14 @@ function jwtOrganizationId(token) {
1096
1217
 
1097
1218
  // src/binding.ts
1098
1219
  var PRIM_CONFIG_DIR = primConfigDirectory();
1099
- var SESSIONS_DIR = join10(PRIM_CONFIG_DIR, "sessions");
1220
+ var SESSIONS_DIR = join12(PRIM_CONFIG_DIR, "sessions");
1100
1221
  var WORKSPACE_FILE = ".prim/workspace.json";
1101
1222
  function readJsonSafe(path) {
1102
- if (!existsSync4(path)) {
1223
+ if (!existsSync6(path)) {
1103
1224
  return;
1104
1225
  }
1105
1226
  try {
1106
- return JSON.parse(readFileSync8(path, "utf-8"));
1227
+ return JSON.parse(readFileSync9(path, "utf-8"));
1107
1228
  } catch {
1108
1229
  return;
1109
1230
  }
@@ -1112,17 +1233,17 @@ function fromSessionMarker(sessionId) {
1112
1233
  if (!sessionId) {
1113
1234
  return;
1114
1235
  }
1115
- const marker = readJsonSafe(join10(SESSIONS_DIR, `${sessionId}.json`));
1236
+ const marker = readJsonSafe(join12(SESSIONS_DIR, `${sessionId}.json`));
1116
1237
  return marker?.orgId;
1117
1238
  }
1118
1239
  function fromWorkspaceFile(startDir) {
1119
1240
  let dir = startDir;
1120
1241
  while (true) {
1121
- const config = readJsonSafe(join10(dir, WORKSPACE_FILE));
1242
+ const config = readJsonSafe(join12(dir, WORKSPACE_FILE));
1122
1243
  if (config?.orgId) {
1123
1244
  return config.orgId;
1124
1245
  }
1125
- const parent = dirname6(dir);
1246
+ const parent = dirname8(dir);
1126
1247
  if (parent === dir) {
1127
1248
  return;
1128
1249
  }
@@ -1158,26 +1279,26 @@ function resolveOrg(args) {
1158
1279
  import {
1159
1280
  appendFileSync,
1160
1281
  closeSync as closeSync2,
1161
- existsSync as existsSync7,
1282
+ existsSync as existsSync9,
1162
1283
  fstatSync,
1163
- mkdirSync as mkdirSync5,
1284
+ mkdirSync as mkdirSync6,
1164
1285
  openSync as openSync2,
1165
1286
  opendirSync,
1166
- readFileSync as readFileSync12,
1287
+ readFileSync as readFileSync13,
1167
1288
  readSync,
1168
- readdirSync as readdirSync3
1289
+ readdirSync as readdirSync4
1169
1290
  } from "fs";
1170
- import { dirname as dirname9, join as join14 } from "path";
1291
+ import { dirname as dirname11, join as join16 } from "path";
1171
1292
 
1172
1293
  // src/client.ts
1173
- import { createHash as createHash7 } from "crypto";
1174
- import { chmodSync as chmodSync3, existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync10, rmSync as rmSync7 } from "fs";
1175
- import { dirname as dirname7 } from "path";
1294
+ import { createHash as createHash8 } from "crypto";
1295
+ import { chmodSync as chmodSync4, existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync11, rmSync as rmSync8 } from "fs";
1296
+ import { dirname as dirname9 } from "path";
1176
1297
 
1177
1298
  // src/daemon/client-instance-id.ts
1178
- import { randomBytes as randomBytes4 } from "crypto";
1179
- import { chmodSync as chmodSync2, lstatSync as lstatSync5, readFileSync as readFileSync9 } from "fs";
1180
- import { join as join11 } from "path";
1299
+ import { randomBytes as randomBytes5 } from "crypto";
1300
+ import { chmodSync as chmodSync3, lstatSync as lstatSync6, readFileSync as readFileSync10 } from "fs";
1301
+ import { join as join13 } from "path";
1181
1302
  var INSTANCE_BODY_CHARS = 43;
1182
1303
  var INSTANCE_PREFIX = "pci_";
1183
1304
  var MAX_STORED_BYTES = INSTANCE_PREFIX.length + INSTANCE_BODY_CHARS + 1;
@@ -1197,17 +1318,17 @@ var CLI_MANAGEMENT_RESPONSE_MAX_BYTES = 2 * 1024 * 1024;
1197
1318
 
1198
1319
  // src/drain-progress.ts
1199
1320
  import {
1200
- chmodSync as chmodSync4,
1201
- existsSync as existsSync6,
1202
- readFileSync as readFileSync11,
1203
- readdirSync as readdirSync2,
1204
- rmSync as rmSync8,
1321
+ chmodSync as chmodSync5,
1322
+ existsSync as existsSync8,
1323
+ readFileSync as readFileSync12,
1324
+ readdirSync as readdirSync3,
1325
+ rmSync as rmSync9,
1205
1326
  rmdirSync
1206
1327
  } from "fs";
1207
- import { basename as basename3, dirname as dirname8, join as join13 } from "path";
1328
+ import { basename as basename3, dirname as dirname10, join as join15 } from "path";
1208
1329
 
1209
1330
  // src/journal.ts
1210
- var JOURNAL_DIR = join14(primConfigDirectory(), "moves");
1331
+ var JOURNAL_DIR = join16(primConfigDirectory(), "moves");
1211
1332
  var UNBOUND_BUCKET = "_unbound";
1212
1333
  var JOURNAL_BASENAME = "journal.ndjson";
1213
1334
  var JOURNAL_STATS_SAMPLE_BYTES = 64 * 1024;
@@ -1219,26 +1340,26 @@ function envSlug(apiUrl) {
1219
1340
  return slug;
1220
1341
  }
1221
1342
  function currentEnvDir() {
1222
- return join14(JOURNAL_DIR, envSlug(getSiteUrl()));
1343
+ return join16(JOURNAL_DIR, envSlug(getSiteUrl()));
1223
1344
  }
1224
1345
  var DIR_MODE = 448;
1225
1346
  var FILE_MODE = 384;
1226
1347
  var SAFE_BUCKET = /^[A-Za-z0-9_-]+$/;
1227
1348
  var RESERVED_BUCKETS = /* @__PURE__ */ new Set([UNBOUND_BUCKET, "_legacy"]);
1228
1349
  function appendMoveToPath(path, move) {
1229
- const dir = dirname9(path);
1230
- if (!existsSync7(dir)) {
1231
- mkdirSync5(dir, { recursive: true, mode: DIR_MODE });
1350
+ const dir = dirname11(path);
1351
+ if (!existsSync9(dir)) {
1352
+ mkdirSync6(dir, { recursive: true, mode: DIR_MODE });
1232
1353
  }
1233
1354
  appendFileSync(path, `${JSON.stringify(move)}
1234
1355
  `, { mode: FILE_MODE });
1235
1356
  }
1236
1357
  function bucketDir(orgId) {
1237
1358
  const safe = orgId !== void 0 && SAFE_BUCKET.test(orgId) && !RESERVED_BUCKETS.has(orgId);
1238
- return join14(currentEnvDir(), safe ? orgId : UNBOUND_BUCKET);
1359
+ return join16(currentEnvDir(), safe ? orgId : UNBOUND_BUCKET);
1239
1360
  }
1240
1361
  function journalPath(orgId) {
1241
- return join14(bucketDir(orgId), JOURNAL_BASENAME);
1362
+ return join16(bucketDir(orgId), JOURNAL_BASENAME);
1242
1363
  }
1243
1364
  function appendMove(move, orgId) {
1244
1365
  const actor = machineCaptureActor();
@@ -1251,21 +1372,21 @@ var FLUSHING_PREFIX = `${JOURNAL_BASENAME}.flushing.`;
1251
1372
 
1252
1373
  // src/lib/activation.ts
1253
1374
  import { execFileSync as execFileSync4 } from "child_process";
1254
- import { existsSync as existsSync9, readFileSync as readFileSync14 } from "fs";
1375
+ import { existsSync as existsSync11, readFileSync as readFileSync15 } from "fs";
1255
1376
  import { homedir as homedir2 } from "os";
1256
- import { join as join16 } from "path";
1377
+ import { join as join18 } from "path";
1257
1378
 
1258
1379
  // src/lib/cloud-prepared.ts
1259
- import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync13, rmSync as rmSync9, writeFileSync as writeFileSync4 } from "fs";
1260
- import { join as join15 } from "path";
1380
+ import { existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync14, rmSync as rmSync10, writeFileSync as writeFileSync5 } from "fs";
1381
+ import { join as join17 } from "path";
1261
1382
  var CLOUD_PREPARED_MARKER = "cloud-prepared";
1262
1383
  function cloudPreparedPath(env = process.env) {
1263
- return join15(primConfigDirectory({ env }), CLOUD_PREPARED_MARKER);
1384
+ return join17(primConfigDirectory({ env }), CLOUD_PREPARED_MARKER);
1264
1385
  }
1265
1386
  function isPreparedCloudSession(env = process.env) {
1266
1387
  if (!isClaudeCloudSession(env)) return false;
1267
1388
  try {
1268
- return existsSync8(cloudPreparedPath(env));
1389
+ return existsSync10(cloudPreparedPath(env));
1269
1390
  } catch {
1270
1391
  return false;
1271
1392
  }
@@ -1384,10 +1505,10 @@ function repoSyncId(cwd) {
1384
1505
  function projectPrimInstallAt(root) {
1385
1506
  if (root === null || root === homedir2()) return false;
1386
1507
  for (const rel of PROJECT_INSTALL_FILES) {
1387
- const path = join16(root, rel);
1388
- if (existsSync9(path)) {
1508
+ const path = join18(root, rel);
1509
+ if (existsSync11(path)) {
1389
1510
  try {
1390
- const content = readFileSync14(path, "utf-8");
1511
+ const content = readFileSync15(path, "utf-8");
1391
1512
  if (PRIM_HOOK_BINS.some((bin) => content.includes(bin))) return true;
1392
1513
  } catch {
1393
1514
  }
@@ -28396,22 +28517,22 @@ function unattendedEnv(env = process.env) {
28396
28517
  import { execFileSync as execFileSync5 } from "child_process";
28397
28518
  import { randomUUID as randomUUID3 } from "crypto";
28398
28519
  import {
28399
- constants as constants2,
28400
- chmodSync as chmodSync5,
28520
+ constants as constants3,
28521
+ chmodSync as chmodSync6,
28401
28522
  closeSync as closeSync3,
28402
28523
  fchmodSync as fchmodSync2,
28403
28524
  fsyncSync as fsyncSync2,
28404
28525
  linkSync as linkSync2,
28405
- lstatSync as lstatSync6,
28406
- mkdirSync as mkdirSync7,
28526
+ lstatSync as lstatSync7,
28527
+ mkdirSync as mkdirSync8,
28407
28528
  openSync as openSync3,
28408
- readFileSync as readFileSync15,
28409
- statSync as statSync2,
28529
+ readFileSync as readFileSync16,
28530
+ statSync as statSync3,
28410
28531
  unlinkSync,
28411
- writeFileSync as writeFileSync5
28532
+ writeFileSync as writeFileSync6
28412
28533
  } from "fs";
28413
- import { dirname as dirname10, isAbsolute as isAbsolute4, join as join17, resolve as resolve3 } from "path";
28414
- var WORKSPACE_ID_RELATIVE_PATH = join17("prim", "workspace-id");
28534
+ import { dirname as dirname12, isAbsolute as isAbsolute5, join as join19, resolve as resolve4 } from "path";
28535
+ var WORKSPACE_ID_RELATIVE_PATH = join19("prim", "workspace-id");
28415
28536
  var MAX_ANCESTORS = 64;
28416
28537
  var MAX_GIT_FILE_BYTES = 4096;
28417
28538
  var MAX_ID_FILE_BYTES = 128;
@@ -28457,7 +28578,7 @@ function resolveWorkspaceIdPath(cwd) {
28457
28578
  }
28458
28579
  return {
28459
28580
  status: "resolved",
28460
- path: isAbsolute4(gitPath) ? resolve3(gitPath) : resolve3(cwd, gitPath)
28581
+ path: isAbsolute5(gitPath) ? resolve4(gitPath) : resolve4(cwd, gitPath)
28461
28582
  };
28462
28583
  } catch (error) {
28463
28584
  const code = errorCode(error);
@@ -28468,21 +28589,21 @@ function resolveWorkspaceIdPath(cwd) {
28468
28589
  }
28469
28590
  }
28470
28591
  function resolveFromFilesystem(cwd) {
28471
- let current = resolve3(cwd);
28592
+ let current = resolve4(cwd);
28472
28593
  for (let depth = 0; depth < MAX_ANCESTORS; depth += 1) {
28473
- const dotGit = join17(current, ".git");
28594
+ const dotGit = join19(current, ".git");
28474
28595
  try {
28475
- const stat = lstatSync6(dotGit);
28596
+ const stat = lstatSync7(dotGit);
28476
28597
  if (stat.isDirectory() && isGitDirectory(dotGit)) {
28477
- return join17(dotGit, WORKSPACE_ID_RELATIVE_PATH);
28598
+ return join19(dotGit, WORKSPACE_ID_RELATIVE_PATH);
28478
28599
  }
28479
28600
  if (stat.isFile() && stat.size <= MAX_GIT_FILE_BYTES) {
28480
- const contents = readFileSync15(dotGit, "utf8");
28601
+ const contents = readFileSync16(dotGit, "utf8");
28481
28602
  const match = /^gitdir: (.+?)(?:\r?\n)?$/.exec(contents);
28482
28603
  if (match?.[1]) {
28483
- const gitDirectory = isAbsolute4(match[1]) ? resolve3(match[1]) : resolve3(current, match[1]);
28604
+ const gitDirectory = isAbsolute5(match[1]) ? resolve4(match[1]) : resolve4(current, match[1]);
28484
28605
  if (isGitDirectory(gitDirectory)) {
28485
- return join17(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
28606
+ return join19(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
28486
28607
  }
28487
28608
  }
28488
28609
  }
@@ -28493,7 +28614,7 @@ function resolveFromFilesystem(cwd) {
28493
28614
  return null;
28494
28615
  }
28495
28616
  }
28496
- const parent = dirname10(current);
28617
+ const parent = dirname12(current);
28497
28618
  if (parent === current) break;
28498
28619
  current = parent;
28499
28620
  }
@@ -28501,7 +28622,7 @@ function resolveFromFilesystem(cwd) {
28501
28622
  }
28502
28623
  function isGitDirectory(path) {
28503
28624
  try {
28504
- return statSync2(join17(path, "HEAD")).isFile();
28625
+ return statSync3(join19(path, "HEAD")).isFile();
28505
28626
  } catch {
28506
28627
  return false;
28507
28628
  }
@@ -28509,7 +28630,7 @@ function isGitDirectory(path) {
28509
28630
  function inspectPath(path) {
28510
28631
  let stat;
28511
28632
  try {
28512
- stat = lstatSync6(path);
28633
+ stat = lstatSync7(path);
28513
28634
  } catch (error) {
28514
28635
  const code = errorCode(error);
28515
28636
  if (code === "ENOENT" || code === "ENOTDIR") return { status: "missing", path };
@@ -28520,7 +28641,7 @@ function inspectPath(path) {
28520
28641
  return { status: "corrupt", path, reason: "invalid_content" };
28521
28642
  }
28522
28643
  try {
28523
- const contents = readFileSync15(path, "utf8");
28644
+ const contents = readFileSync16(path, "utf8");
28524
28645
  const workspaceId = contents.endsWith("\n") ? contents.slice(0, -1) : contents;
28525
28646
  if ((contents === workspaceId || contents === `${workspaceId}
28526
28647
  `) && isCanonicalWorkspaceId(workspaceId)) {
@@ -28537,22 +28658,22 @@ function inspectPath(path) {
28537
28658
  }
28538
28659
  }
28539
28660
  function createWorkspaceId(path) {
28540
- const parent = dirname10(path);
28661
+ const parent = dirname12(path);
28541
28662
  const workspaceId = randomUUID3();
28542
- const temporaryPath = join17(parent, `.workspace-id-${process.pid}-${randomUUID3()}.tmp`);
28663
+ const temporaryPath = join19(parent, `.workspace-id-${process.pid}-${randomUUID3()}.tmp`);
28543
28664
  let temporaryCreated = false;
28544
28665
  let publishing = false;
28545
28666
  try {
28546
- mkdirSync7(parent, { recursive: true, mode: 448 });
28547
- chmodSync5(parent, 448);
28667
+ mkdirSync8(parent, { recursive: true, mode: 448 });
28668
+ chmodSync6(parent, 448);
28548
28669
  const fd = openSync3(
28549
28670
  temporaryPath,
28550
- constants2.O_CREAT | constants2.O_EXCL | constants2.O_WRONLY,
28671
+ constants3.O_CREAT | constants3.O_EXCL | constants3.O_WRONLY,
28551
28672
  384
28552
28673
  );
28553
28674
  temporaryCreated = true;
28554
28675
  try {
28555
- writeFileSync5(fd, `${workspaceId}
28676
+ writeFileSync6(fd, `${workspaceId}
28556
28677
  `, "utf8");
28557
28678
  fchmodSync2(fd, 384);
28558
28679
  fsyncSync2(fd);
@@ -28599,7 +28720,7 @@ function errorCode(error) {
28599
28720
  }
28600
28721
 
28601
28722
  // src/hooks/prim-hook-core.ts
28602
- import { createHash as createHash8, randomUUID as randomUUID4 } from "crypto";
28723
+ import { createHash as createHash9, randomUUID as randomUUID4 } from "crypto";
28603
28724
  import { platform } from "os";
28604
28725
 
28605
28726
  // src/protocol/move.ts
@@ -28607,8 +28728,8 @@ var LEGACY_ENVELOPE_VERSION = 1;
28607
28728
  var ENVELOPE_VERSION = LEGACY_ENVELOPE_VERSION;
28608
28729
 
28609
28730
  // src/hooks/redact.ts
28610
- import { existsSync as existsSync10, readFileSync as readFileSync16, statSync as statSync3 } from "fs";
28611
- import { join as join18 } from "path";
28731
+ import { existsSync as existsSync12, readFileSync as readFileSync17, statSync as statSync4 } from "fs";
28732
+ import { join as join20 } from "path";
28612
28733
  import { Worker } from "worker_threads";
28613
28734
  var USER_HOME_RULES = [
28614
28735
  {
@@ -28760,7 +28881,7 @@ function toRewriteMove(rewrite, cliVersion, cwd, context) {
28760
28881
  const moves = [];
28761
28882
  for (let offset = 0; offset < pairs.length; offset += MAX_REWRITE_PAIRS_PER_MOVE) {
28762
28883
  const sortedPairs = pairs.slice(offset, offset + MAX_REWRITE_PAIRS_PER_MOVE);
28763
- const moveId = `rewrite:v1:${createHash8("sha256").update(JSON.stringify(["rewrite:v1", repoSyncId2, workspaceId, rewrite.source, sortedPairs])).digest("hex")}`;
28884
+ const moveId = `rewrite:v1:${createHash9("sha256").update(JSON.stringify(["rewrite:v1", repoSyncId2, workspaceId, rewrite.source, sortedPairs])).digest("hex")}`;
28764
28885
  moves.push({
28765
28886
  moveId,
28766
28887
  capturedAt: observedAt,
@@ -28792,7 +28913,7 @@ function toRewriteMove(rewrite, cliVersion, cwd, context) {
28792
28913
  }
28793
28914
 
28794
28915
  // src/hooks/post-rewrite.ts
28795
- var here = dirname11(fileURLToPath4(import.meta.url));
28916
+ var here = dirname13(fileURLToPath5(import.meta.url));
28796
28917
  var GIT_TIMEOUT_MS4 = 1e3;
28797
28918
  var MAX_PAIRS_FILE_BYTES = 1048576;
28798
28919
  var MAX_PAIRS_FILE_AGE_MS = 10 * 60 * 1e3;
@@ -28822,17 +28943,17 @@ function privatePairsFileStat(stat, now) {
28822
28943
  }
28823
28944
  function rewritePairsFromLauncher(env = process.env, now = Date.now()) {
28824
28945
  const path = env.PRIM_REWRITE_PAIRS_FILE;
28825
- if (!path || !isAbsolute5(path) || !PAIRS_FILE_RE.test(basename4(path))) return;
28946
+ if (!path || !isAbsolute6(path) || !PAIRS_FILE_RE.test(basename4(path))) return;
28826
28947
  let fd;
28827
28948
  try {
28828
- const pathStat = lstatSync7(path);
28949
+ const pathStat = lstatSync8(path);
28829
28950
  if (!privatePairsFileStat(pathStat, now)) return;
28830
- fd = openSync4(path, constants3.O_RDONLY | constants3.O_NOFOLLOW);
28951
+ fd = openSync4(path, constants4.O_RDONLY | constants4.O_NOFOLLOW);
28831
28952
  const openStat = fstatSync2(fd);
28832
28953
  if (!privatePairsFileStat(openStat, now) || openStat.dev !== pathStat.dev || openStat.ino !== pathStat.ino) {
28833
28954
  return;
28834
28955
  }
28835
- const bytes = readFileSync17(fd);
28956
+ const bytes = readFileSync18(fd);
28836
28957
  if (bytes.length !== openStat.size) return;
28837
28958
  let text;
28838
28959
  try {
@@ -28862,7 +28983,7 @@ function rewritePairsFromLauncher(env = process.env, now = Date.now()) {
28862
28983
  }
28863
28984
  function unlinkSnapshot(snapshot) {
28864
28985
  try {
28865
- const current = lstatSync7(snapshot.path);
28986
+ const current = lstatSync8(snapshot.path);
28866
28987
  if (current.isFile() && !current.isSymbolicLink() && current.dev === snapshot.dev && current.ino === snapshot.ino) {
28867
28988
  unlinkSync2(snapshot.path);
28868
28989
  }
@@ -28888,14 +29009,14 @@ function validBranch(value) {
28888
29009
  }
28889
29010
  function resolveCliVersion() {
28890
29011
  try {
28891
- const pkg = JSON.parse(readFileSync17(join19(here, "..", "..", "package.json"), "utf-8"));
29012
+ const pkg = JSON.parse(readFileSync18(join21(here, "..", "..", "package.json"), "utf-8"));
28892
29013
  return pkg.version ?? "unknown";
28893
29014
  } catch {
28894
29015
  return "unknown";
28895
29016
  }
28896
29017
  }
28897
29018
  function spawnBackgroundFlush() {
28898
- const entry = join19(here, "..", "index.js");
29019
+ const entry = join21(here, "..", "index.js");
28899
29020
  spawn2(process.execPath, [entry, "moves", "flush"], {
28900
29021
  detached: true,
28901
29022
  stdio: "ignore",