@primitive.ai/prim 0.1.0-alpha.93 → 0.1.0-alpha.96

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 (41) hide show
  1. package/README.md +57 -12
  2. package/SKILL.md +5 -2
  3. package/dist/{chunk-UKUAAAXE.js → chunk-27ADT6FQ.js} +2 -2
  4. package/dist/{chunk-OTHKG76J.js → chunk-35FMRWJH.js} +1 -1
  5. package/dist/{chunk-DXJQR4QI.js → chunk-4GHANPWQ.js} +2 -2
  6. package/dist/{chunk-DCJN6LZH.js → chunk-7KABYYWG.js} +747 -430
  7. package/dist/{chunk-LFFLHSQO.js → chunk-CU7RW7XU.js} +63 -6
  8. package/dist/{chunk-H4UNYFUC.js → chunk-DHOQGHKQ.js} +184 -1
  9. package/dist/{chunk-2GP5UFV7.js → chunk-DWRSEC34.js} +5 -3
  10. package/dist/{chunk-36TWVNBE.js → chunk-FVDBULGZ.js} +9 -11
  11. package/dist/{chunk-G2VMA2QO.js → chunk-LY6NJ7KL.js} +6 -4
  12. package/dist/{chunk-ZB4F75SZ.js → chunk-MXVCP33E.js} +5 -1
  13. package/dist/{chunk-TYAHC25F.js → chunk-QCBB5HFX.js} +1 -1
  14. package/dist/{chunk-C3VAA5CG.js → chunk-RK4ZS3HG.js} +2 -2
  15. package/dist/{chunk-ZU563PQI.js → chunk-ROLYLXJS.js} +2 -2
  16. package/dist/{chunk-OH3EZXYX.js → chunk-UO2U6IKF.js} +1 -1
  17. package/dist/{chunk-K7D2EYBS.js → chunk-URLLSALP.js} +2 -2
  18. package/dist/chunk-XEDJ5N3M.js +177 -0
  19. package/dist/{chunk-X64HTHUF.js → chunk-Y5W4TZM7.js} +202 -10
  20. package/dist/{chunk-ICM2XCXS.js → chunk-YYE2NLWX.js} +2 -2
  21. package/dist/{chunk-DSWT6BCC.js → chunk-Z6NPNLOT.js} +825 -665
  22. package/dist/daemon/server.js +836 -540
  23. package/dist/hook-runtime/daemon/server.js +836 -540
  24. package/dist/hook-runtime/hooks/post-commit.js +978 -566
  25. package/dist/hook-runtime/hooks/post-rewrite.js +836 -540
  26. package/dist/hook-runtime/hooks/post-tool-use.js +1215 -796
  27. package/dist/hook-runtime/hooks/pre-tool-use.js +2100 -1741
  28. package/dist/hook-runtime/hooks/prim-hook.js +1312 -861
  29. package/dist/hook-runtime/hooks/session-end.js +232 -134
  30. package/dist/hook-runtime/hooks/session-start.js +1799 -935
  31. package/dist/hook-runtime/index.js +3628 -2461
  32. package/dist/hooks/post-commit.js +14 -10
  33. package/dist/hooks/post-rewrite.js +10 -10
  34. package/dist/hooks/post-tool-use.js +20 -20
  35. package/dist/hooks/pre-commit.js +4 -4
  36. package/dist/hooks/pre-tool-use.js +29 -17
  37. package/dist/hooks/prim-hook.js +22 -18
  38. package/dist/hooks/session-end.js +11 -5
  39. package/dist/hooks/session-start.js +46 -28
  40. package/dist/index.js +623 -390
  41. package/package.json +1 -1
@@ -51,10 +51,20 @@ var require_ucs2length = __commonJS({
51
51
  }
52
52
  });
53
53
 
54
- // src/lib/bin-cache.ts
55
- import { chmodSync, mkdirSync as mkdirSync2 } from "fs";
56
- import { homedir } from "os";
57
- import { join as join2 } from "path";
54
+ // src/hooks/agent.ts
55
+ function parseAgent(argv) {
56
+ const i = argv.indexOf("--agent");
57
+ const value = i !== -1 ? argv[i + 1] : void 0;
58
+ if (value === "codex" || value === "cursor" || value === "hermes") {
59
+ return value;
60
+ }
61
+ return "claude_code";
62
+ }
63
+
64
+ // src/commands/cursor-install.ts
65
+ import { existsSync as existsSync5, readFileSync as readFileSync5 } from "fs";
66
+ import { homedir as homedir3 } from "os";
67
+ import { isAbsolute as isAbsolute5, join as join6 } from "path";
58
68
 
59
69
  // src/lib/atomic-file.ts
60
70
  import { randomUUID } from "crypto";
@@ -242,6 +252,13 @@ function pinnedNpxCommand(bin, args = [], options = {}) {
242
252
  }
243
253
  var STABLE_HOOK_ARGUMENTS_RE = /^[-A-Za-z0-9_ ]*$/u;
244
254
  var STABLE_HOOK_BIN_RE = /^[A-Za-z0-9][A-Za-z0-9-]*$/u;
255
+ var PRIM_CONFIG_SHELL_RESOLVER = [
256
+ 'prim_absolute() { case "$1" in [/]* ) ;; *) return 1 ;; esac; case "$1" in [[:space:]]*|*[[:space:]]|*[/][/]*|*[/].[/]*|*[/]..[/]*|*[/].|*[/]..|?*[/]) return 1 ;; esac; }; ',
257
+ 'prim_config=${PRIM_CONFIG_DIR:-}; if ! prim_absolute "$prim_config"; then prim_config=${XDG_CONFIG_HOME:-}; if prim_absolute "$prim_config"; then ',
258
+ 'case "$prim_config" in /) prim_config=/prim ;; *) prim_config="$prim_config/prim" ;; esac; ',
259
+ 'else prim_home=${HOME:-}; prim_absolute "$prim_home" || exit 78; case "$prim_home" in /) prim_config=/.config/prim ;; *) prim_config="$prim_home/.config/prim" ;; esac; ',
260
+ "fi; fi; "
261
+ ].join("");
245
262
  function stableHookCommand(bin, args = "") {
246
263
  if (!STABLE_HOOK_BIN_RE.test(bin) || !STABLE_HOOK_ARGUMENTS_RE.test(args)) {
247
264
  throw new Error("invalid stable hook command");
@@ -251,11 +268,7 @@ function stableHookCommand(bin, args = "") {
251
268
  // it as inert data during the rolling window so an older uninstall or
252
269
  // reinstall can remove the stable entry without invoking npm or PATH.
253
270
  `prim_legacy_reader='-p ${PKG_NAME}@stable prim-shim.sh ${bin} '; `,
254
- 'prim_absolute() { case "$1" in [/]* ) ;; *) return 1 ;; esac; case "$1" in [[:space:]]*|*[[:space:]]|*[/][/]*|*[/].[/]*|*[/]..[/]*|*[/].|*[/]..|?*[/]) return 1 ;; esac; }; ',
255
- 'prim_config=${PRIM_CONFIG_DIR:-}; if ! prim_absolute "$prim_config"; then prim_config=${XDG_CONFIG_HOME:-}; if prim_absolute "$prim_config"; then ',
256
- 'case "$prim_config" in /) prim_config=/prim ;; *) prim_config="$prim_config/prim" ;; esac; ',
257
- 'else prim_home=${HOME:-}; prim_absolute "$prim_home" || exit 78; case "$prim_home" in /) prim_config=/.config/prim ;; *) prim_config="$prim_home/.config/prim" ;; esac; ',
258
- "fi; fi; ",
271
+ PRIM_CONFIG_SHELL_RESOLVER,
259
272
  `case "$prim_config" in /) prim_launcher=/${STABLE_HOOK_LAUNCHER_NAME} ;; *) prim_launcher="$prim_config/${STABLE_HOOK_LAUNCHER_NAME}" ;; esac; `,
260
273
  'exec "$prim_launcher" "$@"'
261
274
  ].join("");
@@ -266,61 +279,16 @@ function detachedHookShimCommand(bin, args = "") {
266
279
  return `payload=$(cat); { trap '' HUP; printf '%s' "$payload" | { ${stableHookCommand(bin, args)}; }; } </dev/null >/dev/null 2>&1 &`;
267
280
  }
268
281
 
269
- // src/lib/bin-cache.ts
270
- var GIT_HOOK_CACHE_SHELL_DIR = "${XDG_CACHE_HOME:-$HOME/.cache}/prim/bin";
271
- var GIT_HOOK_CACHE_TTL_MINUTES = 1440;
272
- var GIT_HOOK_CACHED_BINS = ["prim-post-commit", "prim-post-rewrite"];
273
- function binCacheDir() {
274
- const base = process.env.XDG_CACHE_HOME || join2(homedir(), ".cache");
275
- return join2(base, "prim", "bin");
276
- }
277
- function writeAtomic(path, content) {
278
- atomicWriteFile(path, content, { mode: 384 });
279
- }
280
- function warmBinCache() {
281
- try {
282
- if (process.env.PRIM_BIN_CACHE === "0") {
283
- return;
284
- }
285
- const dir = binCacheDir();
286
- mkdirSync2(dir, { recursive: true, mode: 448 });
287
- chmodSync(dir, 448);
288
- writeAtomic(join2(dir, "node"), process.execPath);
289
- for (const bin of GIT_HOOK_CACHED_BINS) {
290
- const file = binFile(bin);
291
- if (file) {
292
- writeAtomic(join2(dir, bin), file);
293
- }
294
- }
295
- } catch {
296
- }
297
- }
298
-
299
- // src/hooks/agent.ts
300
- function parseAgent(argv) {
301
- const i = argv.indexOf("--agent");
302
- const value = i !== -1 ? argv[i + 1] : void 0;
303
- if (value === "codex" || value === "cursor" || value === "hermes") {
304
- return value;
305
- }
306
- return "claude_code";
307
- }
308
-
309
- // src/commands/cursor-install.ts
310
- import { existsSync as existsSync5, readFileSync as readFileSync5 } from "fs";
311
- import { homedir as homedir4 } from "os";
312
- import { isAbsolute as isAbsolute5, join as join7 } from "path";
313
-
314
282
  // src/lib/hook-runtime.ts
315
283
  import { createHash, randomBytes as randomBytes2 } from "crypto";
316
284
  import {
317
285
  constants as constants2,
318
286
  accessSync,
319
- chmodSync as chmodSync2,
287
+ chmodSync,
320
288
  copyFileSync,
321
289
  existsSync as existsSync3,
322
290
  lstatSync,
323
- mkdirSync as mkdirSync4,
291
+ mkdirSync as mkdirSync3,
324
292
  mkdtempSync,
325
293
  readFileSync as readFileSync3,
326
294
  readdirSync,
@@ -331,12 +299,12 @@ import {
331
299
  utimesSync,
332
300
  writeFileSync as writeFileSync3
333
301
  } from "fs";
334
- import { delimiter, dirname as dirname4, isAbsolute as isAbsolute3, join as join5, resolve } from "path";
302
+ import { delimiter, dirname as dirname4, isAbsolute as isAbsolute3, join as join4, resolve } from "path";
335
303
 
336
304
  // src/lib/file-lock.ts
337
305
  import { randomBytes } from "crypto";
338
- import { existsSync as existsSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync2, rmSync as rmSync2, statSync, writeFileSync as writeFileSync2 } from "fs";
339
- import { dirname as dirname3, join as join3 } from "path";
306
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, rmSync as rmSync2, statSync, writeFileSync as writeFileSync2 } from "fs";
307
+ import { dirname as dirname3, join as join2 } from "path";
340
308
 
341
309
  // src/lib/process-liveness.ts
342
310
  function processIsAlive(pid, probe = process.kill) {
@@ -356,7 +324,7 @@ var DEFAULT_INIT_GRACE_MS = 2e3;
356
324
  var DIRECTORY_MODE = 448;
357
325
  var FILE_MODE = 384;
358
326
  function ownerPath(lockDir) {
359
- return join3(lockDir, "owner.json");
327
+ return join2(lockDir, "owner.json");
360
328
  }
361
329
  function readOwner(lockDir) {
362
330
  try {
@@ -374,7 +342,7 @@ function sameOwner(a, b) {
374
342
  }
375
343
  function tryTakeLock(lockDir, now) {
376
344
  try {
377
- mkdirSync3(lockDir, { mode: DIRECTORY_MODE });
345
+ mkdirSync2(lockDir, { mode: DIRECTORY_MODE });
378
346
  } catch (error) {
379
347
  if (error.code === "EEXIST") return null;
380
348
  throw error;
@@ -427,14 +395,14 @@ function throwIfAborted(signal) {
427
395
  }
428
396
  async function defaultSleep(ms, signal) {
429
397
  if (!signal) {
430
- await new Promise((resolve9) => setTimeout(resolve9, ms));
398
+ await new Promise((resolve10) => setTimeout(resolve10, ms));
431
399
  return;
432
400
  }
433
401
  throwIfAborted(signal);
434
- await new Promise((resolve9, reject) => {
402
+ await new Promise((resolve10, reject) => {
435
403
  const timer = setTimeout(() => {
436
404
  signal.removeEventListener("abort", onAbort);
437
- resolve9();
405
+ resolve10();
438
406
  }, ms);
439
407
  const onAbort = () => {
440
408
  clearTimeout(timer);
@@ -445,7 +413,7 @@ async function defaultSleep(ms, signal) {
445
413
  }
446
414
  var syncSleeper = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
447
415
  async function withFileLock(lockDir, operation, options = {}) {
448
- mkdirSync3(dirname3(lockDir), { recursive: true, mode: DIRECTORY_MODE });
416
+ mkdirSync2(dirname3(lockDir), { recursive: true, mode: DIRECTORY_MODE });
449
417
  const nowMs = options.nowMs ?? Date.now;
450
418
  const alive = options.processAlive ?? processIsAlive;
451
419
  const deadline = nowMs() + (options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
@@ -476,9 +444,147 @@ async function withFileLock(lockDir, operation, options = {}) {
476
444
  }
477
445
  }
478
446
 
447
+ // src/lib/git-hook-contract.ts
448
+ var MANAGED_GIT_HOOK_NAMES = ["pre-commit", "post-commit", "post-rewrite"];
449
+ var GIT_HOOK_ENTRYPOINT_NAME = "prim-git-hook-v1";
450
+ var GIT_HOOK_CONTRACT_VERSION = 1;
451
+ var CONTRACT_LINE_PREFIX = "# prim git hook v";
452
+ var CONTRACT_LINE_RE = /^# prim git hook v([0-9]+)\b/mu;
453
+ function blockMarkers(hook) {
454
+ return { start: `# >>> prim ${hook} hook >>>`, end: `# <<< prim ${hook} hook <<<` };
455
+ }
456
+ function entrypointCommand(hook) {
457
+ const script = [
458
+ PRIM_CONFIG_SHELL_RESOLVER,
459
+ `case "$prim_config" in /) prim_entry=/${GIT_HOOK_ENTRYPOINT_NAME} ;; `,
460
+ `*) prim_entry="$prim_config/${GIT_HOOK_ENTRYPOINT_NAME}" ;; esac; `,
461
+ '[ -x "$prim_entry" ] || exit 0; exec "$prim_entry" "$@"'
462
+ ].join("");
463
+ return `/bin/sh -c ${shellQuote(script)} ${GIT_HOOK_ENTRYPOINT_NAME} ${hook} "$@"`;
464
+ }
465
+ function managedHookBlock(hook) {
466
+ const { start, end } = blockMarkers(hook);
467
+ const header = `${CONTRACT_LINE_PREFIX}${GIT_HOOK_CONTRACT_VERSION}: a no-op unless prim is installed and enabled here (see \`prim hooks snippet ${hook}\`).`;
468
+ if (hook !== "post-rewrite") {
469
+ return `${start}
470
+ ${header}
471
+ # shellcheck disable=SC2016
472
+ ${entrypointCommand(hook)} || :
473
+ ${end}`;
474
+ }
475
+ return `${start}
476
+ ${header}
477
+ prim_rewrite_stdin=$(mktemp 2>/dev/null) || prim_rewrite_stdin=
478
+ if test -n "\${prim_rewrite_stdin}" && cat >"\${prim_rewrite_stdin}"; then
479
+ # shellcheck disable=SC2016
480
+ ${entrypointCommand(hook)} <"\${prim_rewrite_stdin}" || :
481
+ exec <"\${prim_rewrite_stdin}"
482
+ fi
483
+ if test -n "\${prim_rewrite_stdin}"; then rm -f "\${prim_rewrite_stdin}"; fi
484
+ unset prim_rewrite_stdin
485
+ ${end}`;
486
+ }
487
+ var OPEN_WORDS = /* @__PURE__ */ new Set(["then", "do", "else", "{", "(", "&&", "||", "|"]);
488
+ function canonicalHookBlock(text) {
489
+ const tokens = [];
490
+ let word = "";
491
+ let quote;
492
+ const separate = () => {
493
+ const last = tokens.at(-1);
494
+ if (last !== void 0 && last !== ";" && !OPEN_WORDS.has(last)) tokens.push(";");
495
+ };
496
+ const flush = () => {
497
+ if (word === "") return;
498
+ const last = tokens.at(-1);
499
+ if (last !== void 0 && /^[0-9]*(?:<|>|>>|<&|>&)$/u.test(last))
500
+ tokens[tokens.length - 1] += word;
501
+ else tokens.push(word);
502
+ word = "";
503
+ };
504
+ for (let index = 0; index < text.length; index += 1) {
505
+ const char = text[index];
506
+ if (quote) {
507
+ word += char;
508
+ if (char === quote) quote = void 0;
509
+ continue;
510
+ }
511
+ if (char === "'" || char === '"') {
512
+ quote = char;
513
+ word += char;
514
+ } else if (char === "#" && word === "") {
515
+ const end = text.indexOf("\n", index);
516
+ const comment = text.slice(index, end === -1 ? text.length : end);
517
+ tokens.push(comment.replace(/\s+/gu, " ").trim());
518
+ index = (end === -1 ? text.length : end) - 1;
519
+ } else if (char === "\n" || char === ";") {
520
+ flush();
521
+ if (char === ";" && text[index + 1] === ";") {
522
+ tokens.push(";;");
523
+ index += 1;
524
+ } else {
525
+ separate();
526
+ }
527
+ } else if (/\s/u.test(char)) {
528
+ flush();
529
+ } else {
530
+ word += char;
531
+ }
532
+ }
533
+ flush();
534
+ while (tokens.at(-1) === ";") tokens.pop();
535
+ return tokens.join("\0");
536
+ }
537
+ function hookBlockContractVersion(block) {
538
+ const match = CONTRACT_LINE_RE.exec(block);
539
+ return match?.[1] ? Number(match[1]) : void 0;
540
+ }
541
+ var GIT_HOOK_ENTRYPOINT_CONTENT = `#!/bin/sh
542
+ # prim git hook entrypoint v1 \u2014 managed by prim; do not edit.
543
+ # Run by the "# >>> prim <hook> hook >>>" block in a Git hook file. Acts only
544
+ # where prim is active (git config prim.active true) and never fails the hook.
545
+ case "$0" in */*) prim_dir=\${0%/*} ;; *) exit 0 ;; esac
546
+ prim_launcher="$prim_dir/${STABLE_HOOK_LAUNCHER_NAME}"
547
+ [ -x "$prim_launcher" ] || exit 0
548
+ [ "$(git config --get prim.active 2>/dev/null)" = "true" ] || exit 0
549
+ prim_hook=\${1-}
550
+ if [ "$#" -gt 0 ]; then shift; fi
551
+ case "$prim_hook" in
552
+ pre-commit)
553
+ "$prim_launcher" prim-pre-commit "$@" || :
554
+ ;;
555
+ post-commit)
556
+ prim_sha=$(git rev-parse --verify HEAD 2>/dev/null) || exit 0
557
+ case "$prim_sha" in *[!0-9a-f]* | "") exit 0 ;; esac
558
+ case "\${#prim_sha}" in 40 | 64) ;; *) exit 0 ;; esac
559
+ prim_branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null) || prim_branch=
560
+ prim_observed=$(mktemp "\${TMPDIR:-/tmp}/prim-post-commit-observed.XXXXXXXX" 2>/dev/null) || prim_observed=
561
+ (
562
+ trap '' HUP
563
+ trap 'if [ -n "$prim_observed" ]; then rm -f "$prim_observed"; fi' 0
564
+ PRIM_COMMIT_SHA=$prim_sha PRIM_COMMIT_BRANCH=$prim_branch PRIM_COMMIT_OBSERVED_FILE=$prim_observed "$prim_launcher" prim-post-commit
565
+ ) </dev/null >/dev/null 2>&1 &
566
+ ;;
567
+ post-rewrite)
568
+ case "\${1-}" in amend | rebase) prim_source=$1 ;; *) exit 0 ;; esac
569
+ prim_pairs=$(mktemp "\${TMPDIR:-/tmp}/prim-post-rewrite-pairs.XXXXXXXX" 2>/dev/null) || exit 0
570
+ if ! chmod 600 "$prim_pairs" 2>/dev/null || ! cat >"$prim_pairs"; then
571
+ rm -f "$prim_pairs"
572
+ exit 0
573
+ fi
574
+ prim_branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null) || prim_branch=
575
+ (
576
+ trap '' HUP
577
+ trap 'rm -f "$prim_pairs"' 0
578
+ PRIM_REWRITE_SOURCE=$prim_source PRIM_REWRITE_BRANCH=$prim_branch PRIM_REWRITE_PAIRS_FILE=$prim_pairs "$prim_launcher" prim-post-rewrite
579
+ ) </dev/null >/dev/null 2>&1 &
580
+ ;;
581
+ esac
582
+ exit 0
583
+ `;
584
+
479
585
  // src/lib/paths.ts
480
- import { homedir as homedir2 } from "os";
481
- import { isAbsolute as isAbsolute2, join as join4, normalize } from "path";
586
+ import { homedir } from "os";
587
+ import { isAbsolute as isAbsolute2, join as join3, normalize } from "path";
482
588
  var UNSAFE_CONFIG_PATH_CHARACTERS = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u;
483
589
  function absolutePath(value, variable) {
484
590
  if (value !== void 0 && UNSAFE_CONFIG_PATH_CHARACTERS.test(value)) {
@@ -493,12 +599,12 @@ function resolvePrimConfigDirectory(options = {}) {
493
599
  const explicit = absolutePath(env.PRIM_CONFIG_DIR, "PRIM_CONFIG_DIR");
494
600
  if (explicit) return { path: explicit, source: "explicit" };
495
601
  const xdgConfigHome = absolutePath(env.XDG_CONFIG_HOME, "XDG_CONFIG_HOME");
496
- if (xdgConfigHome) return { path: join4(xdgConfigHome, "prim"), source: "xdg" };
497
- const home = absolutePath(options.homeDir ?? homedir2(), "HOME");
602
+ if (xdgConfigHome) return { path: join3(xdgConfigHome, "prim"), source: "xdg" };
603
+ const home = absolutePath(options.homeDir ?? homedir(), "HOME");
498
604
  if (!home) {
499
605
  throw new Error("cannot resolve Primitive config directory: HOME is not an absolute path");
500
606
  }
501
- return { path: join4(home, ".config", "prim"), source: "default" };
607
+ return { path: join3(home, ".config", "prim"), source: "default" };
502
608
  }
503
609
  function primConfigDirectory(options = {}) {
504
610
  return resolvePrimConfigDirectory(options).path;
@@ -529,6 +635,24 @@ var SOURCE_ENTRIES = Object.fromEntries(
529
635
  target.replace(/^dist\//u, "")
530
636
  ])
531
637
  );
638
+ function hookRuntimePaths(options = {}) {
639
+ const env = options.env ?? process.env;
640
+ const configDir = primConfigDirectory({
641
+ ...options,
642
+ env,
643
+ homeDir: options.homeDir ?? env.HOME ?? ""
644
+ });
645
+ const runtimeDir = join4(configDir, "hook-runtime");
646
+ return {
647
+ configDir,
648
+ launcher: join4(configDir, STABLE_HOOK_LAUNCHER_NAME),
649
+ gitHookEntrypoint: join4(configDir, GIT_HOOK_ENTRYPOINT_NAME),
650
+ runtimeDir,
651
+ releasesDir: join4(runtimeDir, "releases"),
652
+ current: join4(runtimeDir, "current"),
653
+ selectionLock: join4(runtimeDir, "selection.lock")
654
+ };
655
+ }
532
656
  var STABLE_HOOK_LAUNCHER_CONTENT = `#!/bin/sh
533
657
  set -eu
534
658
  case "$0" in */*) prim_launcher_dir=\${0%/*} ;; *) exit 78 ;; esac
@@ -548,11 +672,45 @@ case "$prim_node" in /*) ;; *) exit 69 ;; esac
548
672
  [ -x "$prim_node" ] && [ -f "$prim_entry" ] || exit 69
549
673
  exec "$prim_node" "$prim_entry" "$@"
550
674
  `;
675
+ function gitHookEntrypointCurrent(paths) {
676
+ try {
677
+ return readFileSync3(paths.gitHookEntrypoint, "utf8") === GIT_HOOK_ENTRYPOINT_CONTENT;
678
+ } catch {
679
+ return false;
680
+ }
681
+ }
682
+ function inspectGitHookEntrypoint(options = {}) {
683
+ let paths;
684
+ try {
685
+ paths = hookRuntimePaths(options);
686
+ } catch {
687
+ return "invalid";
688
+ }
689
+ try {
690
+ const entrypoint = lstatIfPresent(paths.gitHookEntrypoint);
691
+ if (!entrypoint) return "missing";
692
+ if (!entrypoint.isFile() || (Number(entrypoint.mode) & 64) === 0 || !gitHookEntrypointCurrent(paths) || readFileSync3(paths.launcher, "utf8") !== STABLE_HOOK_LAUNCHER_CONTENT || !lstatIfPresent(paths.current)?.isFile()) {
693
+ return "invalid";
694
+ }
695
+ return "ready";
696
+ } catch {
697
+ return "invalid";
698
+ }
699
+ }
700
+ function lstatIfPresent(path) {
701
+ try {
702
+ return lstatSync(path);
703
+ } catch (error) {
704
+ const code = error.code;
705
+ if (code === "ENOENT" || code === "ENOTDIR") return void 0;
706
+ throw error;
707
+ }
708
+ }
551
709
 
552
710
  // src/commands/claude-install.ts
553
711
  import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
554
- import { homedir as homedir3 } from "os";
555
- import { join as join6 } from "path";
712
+ import { homedir as homedir2 } from "os";
713
+ import { join as join5 } from "path";
556
714
 
557
715
  // src/lib/git.ts
558
716
  import { execFileSync } from "child_process";
@@ -666,7 +824,7 @@ var SESSION_END_BIN = "prim-session-end";
666
824
  var STATUSLINE_BIN = "prim-statusline";
667
825
  var STATUSLINE_ARGS = "";
668
826
  var STATUSLINE_COMMAND = stableHookCommand(STATUSLINE_BIN, STATUSLINE_ARGS);
669
- var USER_SCOPE_PATH = join6(homedir3(), ".claude", "settings.json");
827
+ var USER_SCOPE_PATH = join5(homedir2(), ".claude", "settings.json");
670
828
  function projectRoot() {
671
829
  return gitToplevel() ?? process.cwd();
672
830
  }
@@ -741,15 +899,15 @@ var REGISTRATIONS2 = [
741
899
  { event: "sessionStart", bin: SESSION_START_BIN2 },
742
900
  { event: "sessionEnd", bin: SESSION_END_BIN2 }
743
901
  ];
744
- function cursorConfigDirectory(env = process.env, home = homedir4(), platform = process.platform) {
902
+ function cursorConfigDirectory(env = process.env, home = homedir3(), platform = process.platform) {
745
903
  const explicit = env.CURSOR_CONFIG_DIR?.trim();
746
904
  if (explicit && isAbsolute5(explicit)) return explicit;
747
905
  const xdg = env.XDG_CONFIG_HOME?.trim();
748
- if (platform !== "darwin" && xdg && isAbsolute5(xdg)) return join7(xdg, "cursor");
749
- return join7(home, ".cursor");
906
+ if (platform !== "darwin" && xdg && isAbsolute5(xdg)) return join6(xdg, "cursor");
907
+ return join6(home, ".cursor");
750
908
  }
751
909
  function cursorHooksPath(scope, root = projectRoot()) {
752
- return scope === "user" ? join7(cursorConfigDirectory(), "hooks.json") : join7(root, ".cursor", "hooks.json");
910
+ return scope === "user" ? join6(cursorConfigDirectory(), "hooks.json") : join6(root, ".cursor", "hooks.json");
753
911
  }
754
912
  function plainObject(value) {
755
913
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -881,13 +1039,13 @@ function buildHookOutput(options) {
881
1039
  return output;
882
1040
  }
883
1041
  function writeHookOutput(output, stream = process.stdout) {
884
- return new Promise((resolve9) => {
1042
+ return new Promise((resolve10) => {
885
1043
  let settled = false;
886
1044
  const finish = (ok, retainErrorListener = false) => {
887
1045
  if (settled) return;
888
1046
  settled = true;
889
1047
  if (!retainErrorListener) stream.off("error", onError);
890
- resolve9(ok);
1048
+ resolve10(ok);
891
1049
  };
892
1050
  const onError = () => {
893
1051
  if (settled) {
@@ -922,7 +1080,7 @@ async function handoffHookOutput(output, acknowledge, stream = process.stdout) {
922
1080
  // src/hooks/hook-stdin.ts
923
1081
  var DEFAULT_MAX_BYTES = 1024 * 1024;
924
1082
  function readHookStdin(timeoutMs = 1e3, maxBytes = DEFAULT_MAX_BYTES) {
925
- return new Promise((resolve9, reject) => {
1083
+ return new Promise((resolve10, reject) => {
926
1084
  const chunks = [];
927
1085
  let bytes = 0;
928
1086
  let settled = false;
@@ -934,7 +1092,7 @@ function readHookStdin(timeoutMs = 1e3, maxBytes = DEFAULT_MAX_BYTES) {
934
1092
  process.stdin.removeAllListeners("end");
935
1093
  process.stdin.removeAllListeners("error");
936
1094
  if (error) reject(error);
937
- else resolve9(Buffer.concat(chunks, bytes).toString("utf-8"));
1095
+ else resolve10(Buffer.concat(chunks, bytes).toString("utf-8"));
938
1096
  };
939
1097
  const timer = setTimeout(() => finish(new Error("stdin read timeout")), timeoutMs);
940
1098
  process.stdin.on("data", (chunk) => {
@@ -952,13 +1110,13 @@ function readHookStdin(timeoutMs = 1e3, maxBytes = DEFAULT_MAX_BYTES) {
952
1110
 
953
1111
  // src/client.ts
954
1112
  import { createHash as createHash4 } from "crypto";
955
- import { chmodSync as chmodSync3, existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync7, rmSync as rmSync4 } from "fs";
1113
+ import { chmodSync as chmodSync2, existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync7, rmSync as rmSync4 } from "fs";
956
1114
  import { dirname as dirname7 } from "path";
957
1115
 
958
1116
  // src/lib/credentials.ts
959
1117
  import { createHash as createHash3 } from "crypto";
960
1118
  import { readFileSync as readFileSync6 } from "fs";
961
- import { join as join8 } from "path";
1119
+ import { join as join7 } from "path";
962
1120
 
963
1121
  // src/lib/workos-connect.ts
964
1122
  var TOKEN_PATH = "/oauth2/token";
@@ -1106,14 +1264,14 @@ function parseWorkosConnectTokens(value, options = {}) {
1106
1264
 
1107
1265
  // src/lib/credentials.ts
1108
1266
  var CONFIG_DIRECTORY = primConfigDirectory();
1109
- var TOKEN_FILE_PATH = join8(CONFIG_DIRECTORY, "token");
1110
- var REFRESH_TOKEN_PATH = join8(CONFIG_DIRECTORY, "refresh_token");
1111
- var TOKEN_EXPIRES_PATH = join8(CONFIG_DIRECTORY, "token_expires_at");
1112
- var TERMINAL_REFRESH_PATH = join8(CONFIG_DIRECTORY, "refresh_terminal");
1113
- var CREDENTIAL_METADATA_PATH = join8(CONFIG_DIRECTORY, "credential_metadata.json");
1114
- var CREDENTIAL_FAMILY_PATH = join8(CONFIG_DIRECTORY, "credential_family.json");
1115
- var CREDENTIAL_MIGRATION_PATH = join8(CONFIG_DIRECTORY, "credential_migration.json");
1116
- var CREDENTIAL_LOCK_PATH = join8(CONFIG_DIRECTORY, "credentials.lock");
1267
+ var TOKEN_FILE_PATH = join7(CONFIG_DIRECTORY, "token");
1268
+ var REFRESH_TOKEN_PATH = join7(CONFIG_DIRECTORY, "refresh_token");
1269
+ var TOKEN_EXPIRES_PATH = join7(CONFIG_DIRECTORY, "token_expires_at");
1270
+ var TERMINAL_REFRESH_PATH = join7(CONFIG_DIRECTORY, "refresh_terminal");
1271
+ var CREDENTIAL_METADATA_PATH = join7(CONFIG_DIRECTORY, "credential_metadata.json");
1272
+ var CREDENTIAL_FAMILY_PATH = join7(CONFIG_DIRECTORY, "credential_family.json");
1273
+ var CREDENTIAL_MIGRATION_PATH = join7(CONFIG_DIRECTORY, "credential_migration.json");
1274
+ var CREDENTIAL_LOCK_PATH = join7(CONFIG_DIRECTORY, "credentials.lock");
1117
1275
  var MAX_CREDENTIAL_METADATA_BYTES = 4096;
1118
1276
  var CREDENTIAL_MIGRATION_VERSION = 1;
1119
1277
  var CREDENTIAL_MIGRATION_STATE = "family_bound";
@@ -1313,8 +1471,8 @@ function expiresAtFor(token, expiresIn) {
1313
1471
  }
1314
1472
  function ensureConfigDirectory() {
1315
1473
  const directory = dirname7(TOKEN_FILE_PATH);
1316
- mkdirSync5(directory, { recursive: true, mode: CONFIG_DIR_MODE });
1317
- chmodSync3(directory, CONFIG_DIR_MODE);
1474
+ mkdirSync4(directory, { recursive: true, mode: CONFIG_DIR_MODE });
1475
+ chmodSync2(directory, CONFIG_DIR_MODE);
1318
1476
  }
1319
1477
  function atomicWrite(path, content) {
1320
1478
  ensureConfigDirectory();
@@ -1746,7 +1904,7 @@ import {
1746
1904
  existsSync as existsSync8,
1747
1905
  fstatSync as fstatSync2,
1748
1906
  lstatSync as lstatSync4,
1749
- mkdirSync as mkdirSync6,
1907
+ mkdirSync as mkdirSync5,
1750
1908
  openSync as openSync3,
1751
1909
  readFileSync as readFileSync9,
1752
1910
  readSync as readSync2,
@@ -1755,8 +1913,8 @@ import {
1755
1913
  rmSync as rmSync5,
1756
1914
  rmdirSync as rmdirSync2
1757
1915
  } from "fs";
1758
- import { homedir as homedir6 } from "os";
1759
- import { dirname as dirname9, isAbsolute as isAbsolute6, join as join12, relative as relative2, resolve as resolve5, sep as sep2 } from "path";
1916
+ import { homedir as homedir5 } from "os";
1917
+ import { dirname as dirname9, isAbsolute as isAbsolute6, join as join11, relative as relative2, resolve as resolve5, sep as sep2 } from "path";
1760
1918
  import { fileURLToPath as fileURLToPath3 } from "url";
1761
1919
 
1762
1920
  // node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/identity.js
@@ -5191,10 +5349,10 @@ function resolveBlockMap({ composeNode: composeNode2, composeEmptyNode: composeE
5191
5349
  let offset = bm.offset;
5192
5350
  let commentEnd = null;
5193
5351
  for (const collItem of bm.items) {
5194
- const { start, key, sep: sep3, value } = collItem;
5352
+ const { start, key, sep: sep4, value } = collItem;
5195
5353
  const keyProps = resolveProps(start, {
5196
5354
  indicator: "explicit-key-ind",
5197
- next: key ?? sep3?.[0],
5355
+ next: key ?? sep4?.[0],
5198
5356
  offset,
5199
5357
  onError,
5200
5358
  parentIndent: bm.indent,
@@ -5208,7 +5366,7 @@ function resolveBlockMap({ composeNode: composeNode2, composeEmptyNode: composeE
5208
5366
  else if ("indent" in key && key.indent !== bm.indent)
5209
5367
  onError(offset, "BAD_INDENT", startColMsg);
5210
5368
  }
5211
- if (!keyProps.anchor && !keyProps.tag && !sep3) {
5369
+ if (!keyProps.anchor && !keyProps.tag && !sep4) {
5212
5370
  commentEnd = keyProps.end;
5213
5371
  if (keyProps.comment) {
5214
5372
  if (map2.comment)
@@ -5232,7 +5390,7 @@ function resolveBlockMap({ composeNode: composeNode2, composeEmptyNode: composeE
5232
5390
  ctx.atKey = false;
5233
5391
  if (mapIncludes(ctx, map2.items, keyNode))
5234
5392
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
5235
- const valueProps = resolveProps(sep3 ?? [], {
5393
+ const valueProps = resolveProps(sep4 ?? [], {
5236
5394
  indicator: "map-value-ind",
5237
5395
  next: value,
5238
5396
  offset: keyNode.range[2],
@@ -5248,7 +5406,7 @@ function resolveBlockMap({ composeNode: composeNode2, composeEmptyNode: composeE
5248
5406
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
5249
5407
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
5250
5408
  }
5251
- const valueNode = value ? composeNode2(ctx, value, valueProps, onError) : composeEmptyNode2(ctx, offset, sep3, null, valueProps, onError);
5409
+ const valueNode = value ? composeNode2(ctx, value, valueProps, onError) : composeEmptyNode2(ctx, offset, sep4, null, valueProps, onError);
5252
5410
  if (ctx.schema.compat)
5253
5411
  flowIndentCheck(bm.indent, value, onError);
5254
5412
  offset = valueNode.range[2];
@@ -5324,7 +5482,7 @@ function resolveEnd(end, offset, reqSpace, onError) {
5324
5482
  let comment = "";
5325
5483
  if (end) {
5326
5484
  let hasSpace = false;
5327
- let sep3 = "";
5485
+ let sep4 = "";
5328
5486
  for (const token of end) {
5329
5487
  const { source, type } = token;
5330
5488
  switch (type) {
@@ -5338,13 +5496,13 @@ function resolveEnd(end, offset, reqSpace, onError) {
5338
5496
  if (!comment)
5339
5497
  comment = cb;
5340
5498
  else
5341
- comment += sep3 + cb;
5342
- sep3 = "";
5499
+ comment += sep4 + cb;
5500
+ sep4 = "";
5343
5501
  break;
5344
5502
  }
5345
5503
  case "newline":
5346
5504
  if (comment)
5347
- sep3 += source;
5505
+ sep4 += source;
5348
5506
  hasSpace = true;
5349
5507
  break;
5350
5508
  default:
@@ -5373,18 +5531,18 @@ function resolveFlowCollection({ composeNode: composeNode2, composeEmptyNode: co
5373
5531
  let offset = fc.offset + fc.start.source.length;
5374
5532
  for (let i = 0; i < fc.items.length; ++i) {
5375
5533
  const collItem = fc.items[i];
5376
- const { start, key, sep: sep3, value } = collItem;
5534
+ const { start, key, sep: sep4, value } = collItem;
5377
5535
  const props = resolveProps(start, {
5378
5536
  flow: fcName,
5379
5537
  indicator: "explicit-key-ind",
5380
- next: key ?? sep3?.[0],
5538
+ next: key ?? sep4?.[0],
5381
5539
  offset,
5382
5540
  onError,
5383
5541
  parentIndent: fc.indent,
5384
5542
  startOnNewline: false
5385
5543
  });
5386
5544
  if (!props.found) {
5387
- if (!props.anchor && !props.tag && !sep3 && !value) {
5545
+ if (!props.anchor && !props.tag && !sep4 && !value) {
5388
5546
  if (i === 0 && props.comma)
5389
5547
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
5390
5548
  else if (i < fc.items.length - 1)
@@ -5438,8 +5596,8 @@ function resolveFlowCollection({ composeNode: composeNode2, composeEmptyNode: co
5438
5596
  }
5439
5597
  }
5440
5598
  }
5441
- if (!isMap2 && !sep3 && !props.found) {
5442
- const valueNode = value ? composeNode2(ctx, value, props, onError) : composeEmptyNode2(ctx, props.end, sep3, null, props, onError);
5599
+ if (!isMap2 && !sep4 && !props.found) {
5600
+ const valueNode = value ? composeNode2(ctx, value, props, onError) : composeEmptyNode2(ctx, props.end, sep4, null, props, onError);
5443
5601
  coll.items.push(valueNode);
5444
5602
  offset = valueNode.range[2];
5445
5603
  if (isBlock(value))
@@ -5451,7 +5609,7 @@ function resolveFlowCollection({ composeNode: composeNode2, composeEmptyNode: co
5451
5609
  if (isBlock(key))
5452
5610
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
5453
5611
  ctx.atKey = false;
5454
- const valueProps = resolveProps(sep3 ?? [], {
5612
+ const valueProps = resolveProps(sep4 ?? [], {
5455
5613
  flow: fcName,
5456
5614
  indicator: "map-value-ind",
5457
5615
  next: value,
@@ -5462,8 +5620,8 @@ function resolveFlowCollection({ composeNode: composeNode2, composeEmptyNode: co
5462
5620
  });
5463
5621
  if (valueProps.found) {
5464
5622
  if (!isMap2 && !props.found && ctx.options.strict) {
5465
- if (sep3)
5466
- for (const st of sep3) {
5623
+ if (sep4)
5624
+ for (const st of sep4) {
5467
5625
  if (st === valueProps.found)
5468
5626
  break;
5469
5627
  if (st.type === "newline") {
@@ -5480,7 +5638,7 @@ function resolveFlowCollection({ composeNode: composeNode2, composeEmptyNode: co
5480
5638
  else
5481
5639
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
5482
5640
  }
5483
- const valueNode = value ? composeNode2(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode2(ctx, valueProps.end, sep3, null, valueProps, onError) : null;
5641
+ const valueNode = value ? composeNode2(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode2(ctx, valueProps.end, sep4, null, valueProps, onError) : null;
5484
5642
  if (valueNode) {
5485
5643
  if (isBlock(value))
5486
5644
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -5640,7 +5798,7 @@ function resolveBlockScalar(ctx, scalar, onError) {
5640
5798
  chompStart = i + 1;
5641
5799
  }
5642
5800
  let value = "";
5643
- let sep3 = "";
5801
+ let sep4 = "";
5644
5802
  let prevMoreIndented = false;
5645
5803
  for (let i = 0; i < contentStart; ++i)
5646
5804
  value += lines[i][0].slice(trimIndent) + "\n";
@@ -5657,24 +5815,24 @@ function resolveBlockScalar(ctx, scalar, onError) {
5657
5815
  indent = "";
5658
5816
  }
5659
5817
  if (type === Scalar.BLOCK_LITERAL) {
5660
- value += sep3 + indent.slice(trimIndent) + content;
5661
- sep3 = "\n";
5818
+ value += sep4 + indent.slice(trimIndent) + content;
5819
+ sep4 = "\n";
5662
5820
  } else if (indent.length > trimIndent || content[0] === " ") {
5663
- if (sep3 === " ")
5664
- sep3 = "\n";
5665
- else if (!prevMoreIndented && sep3 === "\n")
5666
- sep3 = "\n\n";
5667
- value += sep3 + indent.slice(trimIndent) + content;
5668
- sep3 = "\n";
5821
+ if (sep4 === " ")
5822
+ sep4 = "\n";
5823
+ else if (!prevMoreIndented && sep4 === "\n")
5824
+ sep4 = "\n\n";
5825
+ value += sep4 + indent.slice(trimIndent) + content;
5826
+ sep4 = "\n";
5669
5827
  prevMoreIndented = true;
5670
5828
  } else if (content === "") {
5671
- if (sep3 === "\n")
5829
+ if (sep4 === "\n")
5672
5830
  value += "\n";
5673
5831
  else
5674
- sep3 = "\n";
5832
+ sep4 = "\n";
5675
5833
  } else {
5676
- value += sep3 + content;
5677
- sep3 = " ";
5834
+ value += sep4 + content;
5835
+ sep4 = " ";
5678
5836
  prevMoreIndented = false;
5679
5837
  }
5680
5838
  }
@@ -5848,25 +6006,25 @@ function foldLines(source) {
5848
6006
  if (!match)
5849
6007
  return source;
5850
6008
  let res = match[1];
5851
- let sep3 = " ";
6009
+ let sep4 = " ";
5852
6010
  let pos = first.lastIndex;
5853
6011
  line.lastIndex = pos;
5854
6012
  while (match = line.exec(source)) {
5855
6013
  if (match[1] === "") {
5856
- if (sep3 === "\n")
5857
- res += sep3;
6014
+ if (sep4 === "\n")
6015
+ res += sep4;
5858
6016
  else
5859
- sep3 = "\n";
6017
+ sep4 = "\n";
5860
6018
  } else {
5861
- res += sep3 + match[1];
5862
- sep3 = " ";
6019
+ res += sep4 + match[1];
6020
+ sep4 = " ";
5863
6021
  }
5864
6022
  pos = line.lastIndex;
5865
6023
  }
5866
6024
  const last = /[ \t]*(.*)/sy;
5867
6025
  last.lastIndex = pos;
5868
6026
  match = last.exec(source);
5869
- return res + sep3 + (match?.[1] ?? "");
6027
+ return res + sep4 + (match?.[1] ?? "");
5870
6028
  }
5871
6029
  function doubleQuotedValue(source, onError) {
5872
6030
  let res = "";
@@ -7483,18 +7641,18 @@ var Parser = class {
7483
7641
  if (this.type === "map-value-ind") {
7484
7642
  const prev = getPrevProps(this.peek(2));
7485
7643
  const start = getFirstKeyStartProps(prev);
7486
- let sep3;
7644
+ let sep4;
7487
7645
  if (scalar.end) {
7488
- sep3 = scalar.end;
7489
- sep3.push(this.sourceToken);
7646
+ sep4 = scalar.end;
7647
+ sep4.push(this.sourceToken);
7490
7648
  delete scalar.end;
7491
7649
  } else
7492
- sep3 = [this.sourceToken];
7650
+ sep4 = [this.sourceToken];
7493
7651
  const map2 = {
7494
7652
  type: "block-map",
7495
7653
  offset: scalar.offset,
7496
7654
  indent: scalar.indent,
7497
- items: [{ start, key: scalar, sep: sep3 }]
7655
+ items: [{ start, key: scalar, sep: sep4 }]
7498
7656
  };
7499
7657
  this.onKeyLine = true;
7500
7658
  this.stack[this.stack.length - 1] = map2;
@@ -7647,15 +7805,15 @@ var Parser = class {
7647
7805
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
7648
7806
  const start2 = getFirstKeyStartProps(it.start);
7649
7807
  const key = it.key;
7650
- const sep3 = it.sep;
7651
- sep3.push(this.sourceToken);
7808
+ const sep4 = it.sep;
7809
+ sep4.push(this.sourceToken);
7652
7810
  delete it.key;
7653
7811
  delete it.sep;
7654
7812
  this.stack.push({
7655
7813
  type: "block-map",
7656
7814
  offset: this.offset,
7657
7815
  indent: this.indent,
7658
- items: [{ start: start2, key, sep: sep3 }]
7816
+ items: [{ start: start2, key, sep: sep4 }]
7659
7817
  });
7660
7818
  } else if (start.length > 0) {
7661
7819
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -7849,13 +8007,13 @@ var Parser = class {
7849
8007
  const prev = getPrevProps(parent);
7850
8008
  const start = getFirstKeyStartProps(prev);
7851
8009
  fixFlowSeqItems(fc);
7852
- const sep3 = fc.end.splice(1, fc.end.length);
7853
- sep3.push(this.sourceToken);
8010
+ const sep4 = fc.end.splice(1, fc.end.length);
8011
+ sep4.push(this.sourceToken);
7854
8012
  const map2 = {
7855
8013
  type: "block-map",
7856
8014
  offset: fc.offset,
7857
8015
  indent: fc.indent,
7858
- items: [{ start, key: fc, sep: sep3 }]
8016
+ items: [{ start, key: fc, sep: sep4 }]
7859
8017
  };
7860
8018
  this.onKeyLine = true;
7861
8019
  this.stack[this.stack.length - 1] = map2;
@@ -8041,8 +8199,8 @@ import {
8041
8199
  rmdirSync,
8042
8200
  unlinkSync
8043
8201
  } from "fs";
8044
- import { homedir as homedir5 } from "os";
8045
- import { dirname as dirname8, join as join11, resolve as resolve4 } from "path";
8202
+ import { homedir as homedir4 } from "os";
8203
+ import { dirname as dirname8, join as join10, resolve as resolve4 } from "path";
8046
8204
  import { fileURLToPath as fileURLToPath2 } from "url";
8047
8205
 
8048
8206
  // node_modules/.pnpm/diff@5.2.2/node_modules/diff/lib/index.mjs
@@ -8212,7 +8370,7 @@ Diff.prototype = {
8212
8370
  tokenize: function tokenize(value) {
8213
8371
  return value.split("");
8214
8372
  },
8215
- join: function join10(chars) {
8373
+ join: function join9(chars) {
8216
8374
  return chars.join("");
8217
8375
  }
8218
8376
  };
@@ -8429,10 +8587,10 @@ function readCodexGuidance(path) {
8429
8587
  }
8430
8588
  }
8431
8589
  function effectiveCodexGuidance(scope) {
8432
- const override = readCodexGuidance(join11(scope, "AGENTS.override.md"));
8590
+ const override = readCodexGuidance(join10(scope, "AGENTS.override.md"));
8433
8591
  if (override === null) return null;
8434
8592
  if (override !== void 0 && override.toString("utf8").trim().length > 0) return override;
8435
- const base = readCodexGuidance(join11(scope, "AGENTS.md"));
8593
+ const base = readCodexGuidance(join10(scope, "AGENTS.md"));
8436
8594
  return base ?? null;
8437
8595
  }
8438
8596
  function hasUsablePrimBlock(content, visibleBytes) {
@@ -8455,7 +8613,7 @@ function hasUsablePrimBlock(content, visibleBytes) {
8455
8613
  }
8456
8614
  function hasUsableCodexGuidance(projectRoot2) {
8457
8615
  try {
8458
- const codexHome = process.env.CODEX_HOME?.trim() ? resolve4(process.env.CODEX_HOME) : join11(homedir5(), ".codex");
8616
+ const codexHome = process.env.CODEX_HOME?.trim() ? resolve4(process.env.CODEX_HOME) : join10(homedir4(), ".codex");
8459
8617
  const scopes = [
8460
8618
  { path: codexHome, visibleBytes: CODEX_GUIDANCE_LIMIT_BYTES },
8461
8619
  { path: projectRoot2, visibleBytes: CODEX_DEFAULT_PROJECT_GUIDANCE_BYTES }
@@ -8475,14 +8633,14 @@ function sha256(content) {
8475
8633
  }
8476
8634
  function cursorSkillDirectory(cwd, scope) {
8477
8635
  const base = scope === "user" ? cursorConfigDirectory() : gitToplevel(cwd) ?? cwd;
8478
- return join11(base, scope === "user" ? "skills" : ".cursor/skills", "prim");
8636
+ return join10(base, scope === "user" ? "skills" : ".cursor/skills", "prim");
8479
8637
  }
8480
8638
  function cursorSkillPaths(cwd, scope) {
8481
8639
  const directory = cursorSkillDirectory(cwd, scope);
8482
8640
  return {
8483
8641
  directory,
8484
- skill: join11(directory, "SKILL.md"),
8485
- manifest: join11(directory, CURSOR_SKILL_MANIFEST)
8642
+ skill: join10(directory, "SKILL.md"),
8643
+ manifest: join10(directory, CURSOR_SKILL_MANIFEST)
8486
8644
  };
8487
8645
  }
8488
8646
  function readCursorSkillManifest(path) {
@@ -8535,8 +8693,8 @@ var MAX_SKILL_BYTES = 1024 * 1024;
8535
8693
  var REFRESH_LOCK_TIMEOUT_MS = 150;
8536
8694
  var REFRESH_LOCK_POLL_MS = 10;
8537
8695
  function pluginDirFor(cwd, scope) {
8538
- const base = scope === "user" ? join12(homedir6(), ".claude") : join12(gitToplevel(cwd) ?? cwd, ".claude");
8539
- return join12(base, "skills", "prim");
8696
+ const base = scope === "user" ? join11(homedir5(), ".claude") : join11(gitToplevel(cwd) ?? cwd, ".claude");
8697
+ return join11(base, "skills", "prim");
8540
8698
  }
8541
8699
  function packageVersion2() {
8542
8700
  let dir = __dirname2;
@@ -8558,8 +8716,8 @@ function renderClaudePlugin() {
8558
8716
  }
8559
8717
  function pluginPaths(dir) {
8560
8718
  return {
8561
- manifestPath: join12(dir, ".claude-plugin", "plugin.json"),
8562
- skillPath: join12(dir, "SKILL.md")
8719
+ manifestPath: join11(dir, ".claude-plugin", "plugin.json"),
8720
+ skillPath: join11(dir, "SKILL.md")
8563
8721
  };
8564
8722
  }
8565
8723
  function pathIsInside(root, path) {
@@ -8624,9 +8782,9 @@ function inspectRecognizedInstallation(paths, projectRoot2) {
8624
8782
  };
8625
8783
  }
8626
8784
  function refreshLockDir(physicalPluginDir) {
8627
- const cacheRoot = process.env.XDG_CACHE_HOME || join12(homedir6(), ".cache");
8785
+ const cacheRoot = process.env.XDG_CACHE_HOME || join11(homedir5(), ".cache");
8628
8786
  const identity = createHash6("sha256").update(physicalPluginDir).digest("hex");
8629
- return join12(cacheRoot, "prim", "skill-refresh-locks", `${identity}.lock`);
8787
+ return join11(cacheRoot, "prim", "skill-refresh-locks", `${identity}.lock`);
8630
8788
  }
8631
8789
  async function refreshClaudePlugins(cwd, options = {}) {
8632
8790
  const result = { installed: 0, refreshed: 0 };
@@ -8634,7 +8792,7 @@ async function refreshClaudePlugins(cwd, options = {}) {
8634
8792
  if (options.includeProject !== false) {
8635
8793
  const projectRoot2 = options.projectRoot ?? gitToplevel(cwd);
8636
8794
  if (projectRoot2 !== null && isAbsolute6(projectRoot2)) {
8637
- candidates.push({ dir: join12(projectRoot2, ".claude", "skills", "prim"), projectRoot: projectRoot2 });
8795
+ candidates.push({ dir: join11(projectRoot2, ".claude", "skills", "prim"), projectRoot: projectRoot2 });
8638
8796
  }
8639
8797
  }
8640
8798
  candidates.push({ dir: pluginDirFor(cwd, "user") });
@@ -8698,7 +8856,7 @@ async function refreshClaudePlugins(cwd, options = {}) {
8698
8856
 
8699
8857
  // src/daemon/client.ts
8700
8858
  import { createConnection } from "net";
8701
- import { join as join13 } from "path";
8859
+ import { join as join12 } from "path";
8702
8860
 
8703
8861
  // src/daemon/principal.ts
8704
8862
  import { createHash as createHash7 } from "crypto";
@@ -8748,7 +8906,7 @@ function parseDaemonResponseEnvelope(value) {
8748
8906
  }
8749
8907
 
8750
8908
  // src/daemon/client.ts
8751
- var SOCK_PATH = join13(primConfigDirectory(), "sock");
8909
+ var SOCK_PATH = join12(primConfigDirectory(), "sock");
8752
8910
  var DEFAULT_TIMEOUT_MS2 = 250;
8753
8911
  var nextRequestId = 1;
8754
8912
  function daemonRequest(method, params = {}, opts = {}) {
@@ -8761,7 +8919,7 @@ function daemonRequest(method, params = {}, opts = {}) {
8761
8919
  ...caller ? { caller } : {}
8762
8920
  };
8763
8921
  const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS2;
8764
- return new Promise((resolve9) => {
8922
+ return new Promise((resolve10) => {
8765
8923
  let settled = false;
8766
8924
  let socket;
8767
8925
  let buffer = Buffer.alloc(0);
@@ -8776,7 +8934,7 @@ function daemonRequest(method, params = {}, opts = {}) {
8776
8934
  } catch {
8777
8935
  }
8778
8936
  }
8779
- resolve9(value);
8937
+ resolve10(value);
8780
8938
  };
8781
8939
  const timer = setTimeout(() => settle(null), timeoutMs);
8782
8940
  timer.unref();
@@ -9055,8 +9213,8 @@ async function acknowledgeDecisionFeedback(input, dependencies = {}) {
9055
9213
  // src/lib/activation.ts
9056
9214
  import { execFileSync as execFileSync2 } from "child_process";
9057
9215
  import { existsSync as existsSync9, readFileSync as readFileSync10 } from "fs";
9058
- import { homedir as homedir7 } from "os";
9059
- import { join as join14 } from "path";
9216
+ import { homedir as homedir6 } from "os";
9217
+ import { join as join13 } from "path";
9060
9218
  var PRIM_ACTIVE_KEY = "prim.active";
9061
9219
  var PRIM_REPO_SYNC_ID_KEY = "prim.repoSyncId";
9062
9220
  var PRIM_REPO_SYNC_REPOSITORY_KEY = "prim.repoSyncRepository";
@@ -9152,9 +9310,9 @@ function repositoryBindingState(cwd) {
9152
9310
  }
9153
9311
  function hasProjectPrimInstall(cwd) {
9154
9312
  const root = gitToplevel(cwd);
9155
- if (root === null || root === homedir7()) return false;
9313
+ if (root === null || root === homedir6()) return false;
9156
9314
  for (const rel of PROJECT_INSTALL_FILES) {
9157
- const path = join14(root, rel);
9315
+ const path = join13(root, rel);
9158
9316
  if (existsSync9(path)) {
9159
9317
  try {
9160
9318
  const content = readFileSync10(path, "utf-8");
@@ -9175,6 +9333,39 @@ function decisionIngestionStatus(cwd) {
9175
9333
  return isRepoActiveForCapture(cwd) ? "enabled" : "disabled";
9176
9334
  }
9177
9335
 
9336
+ // src/lib/bin-cache.ts
9337
+ import { chmodSync as chmodSync3, mkdirSync as mkdirSync6 } from "fs";
9338
+ import { homedir as homedir7 } from "os";
9339
+ import { join as join14 } from "path";
9340
+ var GIT_HOOK_CACHE_SHELL_DIR = "${XDG_CACHE_HOME:-$HOME/.cache}/prim/bin";
9341
+ var GIT_HOOK_CACHE_TTL_MINUTES = 1440;
9342
+ var GIT_HOOK_CACHED_BINS = ["prim-post-commit", "prim-post-rewrite"];
9343
+ function binCacheDir() {
9344
+ const base = process.env.XDG_CACHE_HOME || join14(homedir7(), ".cache");
9345
+ return join14(base, "prim", "bin");
9346
+ }
9347
+ function writeAtomic(path, content) {
9348
+ atomicWriteFile(path, content, { mode: 384 });
9349
+ }
9350
+ function warmBinCache() {
9351
+ try {
9352
+ if (process.env.PRIM_BIN_CACHE === "0") {
9353
+ return;
9354
+ }
9355
+ const dir = binCacheDir();
9356
+ mkdirSync6(dir, { recursive: true, mode: 448 });
9357
+ chmodSync3(dir, 448);
9358
+ writeAtomic(join14(dir, "node"), process.execPath);
9359
+ for (const bin of GIT_HOOK_CACHED_BINS) {
9360
+ const file = binFile(bin);
9361
+ if (file) {
9362
+ writeAtomic(join14(dir, bin), file);
9363
+ }
9364
+ }
9365
+ } catch {
9366
+ }
9367
+ }
9368
+
9178
9369
  // src/generated/cli-http-v1.validators.js
9179
9370
  var import_ucs2length = __toESM(require_ucs2length(), 1);
9180
9371
  var schema33 = { "type": "object", "properties": { "authenticated": { "type": "boolean", "const": true }, "organizationBindingVersion": { "type": "number", "const": 1 }, "captureAuthorityKind": { "type": "string", "enum": ["workos", "service_token"] }, "organizationId": { "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }] }, "workosOrganizationId": { "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }] } }, "required": ["authenticated", "organizationBindingVersion", "captureAuthorityKind", "organizationId", "workosOrganizationId"], "additionalProperties": false };
@@ -20255,7 +20446,6 @@ function validate45(data, { instancePath = "", parentData, parentDataProperty, r
20255
20446
  return errors === 0;
20256
20447
  }
20257
20448
  validate45.evaluated = { "dynamicProps": true, "dynamicItems": false };
20258
- var schema83 = { "anyOf": [{ "type": "object", "properties": { "error": { "type": "string", "const": "Unauthorized" } }, "required": ["error"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "const": "interactive_workos_authority_required" } }, "required": ["error"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "const": "feature_disabled" }, "feature": { "type": "string", "const": "github-connect" } }, "required": ["error", "feature"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "enum": ["github_connect_unavailable", "feature_check_unavailable"] }, "feature": { "type": "string", "const": "github-connect" } }, "required": ["error", "feature"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "const": "WorkOS identity authority is temporarily unavailable" } }, "required": ["error"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "const": "github_install_intent_conflict" } }, "required": ["error"], "additionalProperties": false }, { "type": "object", "properties": { "error": { "type": "string", "const": "github_install_intent_rate_limited" }, "retryAt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } }, "required": ["error", "retryAt"], "additionalProperties": false }] };
20259
20449
  function validate46(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
20260
20450
  ;
20261
20451
  let vErrors = null;
@@ -20405,7 +20595,7 @@ function validate46(data, { instancePath = "", parentData, parentDataProperty, r
20405
20595
  if (errors === _errs12) {
20406
20596
  if (data && typeof data == "object" && !Array.isArray(data)) {
20407
20597
  let missing2;
20408
- if (data.error === void 0 && (missing2 = "error") || data.feature === void 0 && (missing2 = "feature")) {
20598
+ if (data.error === void 0 && (missing2 = "error")) {
20409
20599
  const err10 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/2/required", keyword: "required", params: { missingProperty: missing2 }, message: "must have required property '" + missing2 + "'" };
20410
20600
  if (vErrors === null) {
20411
20601
  vErrors = [err10];
@@ -20416,7 +20606,7 @@ function validate46(data, { instancePath = "", parentData, parentDataProperty, r
20416
20606
  } else {
20417
20607
  const _errs14 = errors;
20418
20608
  for (const key2 in data) {
20419
- if (!(key2 === "error" || key2 === "feature")) {
20609
+ if (!(key2 === "error")) {
20420
20610
  const err11 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/2/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key2 }, message: "must NOT have additional properties" };
20421
20611
  if (vErrors === null) {
20422
20612
  vErrors = [err11];
@@ -20430,7 +20620,6 @@ function validate46(data, { instancePath = "", parentData, parentDataProperty, r
20430
20620
  if (_errs14 === errors) {
20431
20621
  if (data.error !== void 0) {
20432
20622
  let data2 = data.error;
20433
- const _errs15 = errors;
20434
20623
  if (typeof data2 !== "string") {
20435
20624
  const err12 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/2/properties/error/type", keyword: "type", params: { type: "string" }, message: "must be string" };
20436
20625
  if (vErrors === null) {
@@ -20440,8 +20629,8 @@ function validate46(data, { instancePath = "", parentData, parentDataProperty, r
20440
20629
  }
20441
20630
  errors++;
20442
20631
  }
20443
- if ("feature_disabled" !== data2) {
20444
- const err13 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/2/properties/error/const", keyword: "const", params: { allowedValue: "feature_disabled" }, message: "must be equal to constant" };
20632
+ if ("github_connect_unavailable" !== data2) {
20633
+ const err13 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/2/properties/error/const", keyword: "const", params: { allowedValue: "github_connect_unavailable" }, message: "must be equal to constant" };
20445
20634
  if (vErrors === null) {
20446
20635
  vErrors = [err13];
20447
20636
  } else {
@@ -20449,45 +20638,15 @@ function validate46(data, { instancePath = "", parentData, parentDataProperty, r
20449
20638
  }
20450
20639
  errors++;
20451
20640
  }
20452
- var valid4 = _errs15 === errors;
20453
- } else {
20454
- var valid4 = true;
20455
- }
20456
- if (valid4) {
20457
- if (data.feature !== void 0) {
20458
- let data3 = data.feature;
20459
- const _errs17 = errors;
20460
- if (typeof data3 !== "string") {
20461
- const err14 = { instancePath: instancePath + "/feature", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/2/properties/feature/type", keyword: "type", params: { type: "string" }, message: "must be string" };
20462
- if (vErrors === null) {
20463
- vErrors = [err14];
20464
- } else {
20465
- vErrors.push(err14);
20466
- }
20467
- errors++;
20468
- }
20469
- if ("github-connect" !== data3) {
20470
- const err15 = { instancePath: instancePath + "/feature", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/2/properties/feature/const", keyword: "const", params: { allowedValue: "github-connect" }, message: "must be equal to constant" };
20471
- if (vErrors === null) {
20472
- vErrors = [err15];
20473
- } else {
20474
- vErrors.push(err15);
20475
- }
20476
- errors++;
20477
- }
20478
- var valid4 = _errs17 === errors;
20479
- } else {
20480
- var valid4 = true;
20481
- }
20482
20641
  }
20483
20642
  }
20484
20643
  }
20485
20644
  } else {
20486
- const err16 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/2/type", keyword: "type", params: { type: "object" }, message: "must be object" };
20645
+ const err14 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/2/type", keyword: "type", params: { type: "object" }, message: "must be object" };
20487
20646
  if (vErrors === null) {
20488
- vErrors = [err16];
20647
+ vErrors = [err14];
20489
20648
  } else {
20490
- vErrors.push(err16);
20649
+ vErrors.push(err14);
20491
20650
  }
20492
20651
  errors++;
20493
20652
  }
@@ -20499,148 +20658,117 @@ function validate46(data, { instancePath = "", parentData, parentDataProperty, r
20499
20658
  props0 = true;
20500
20659
  }
20501
20660
  }
20502
- const _errs19 = errors;
20503
- if (errors === _errs19) {
20661
+ const _errs17 = errors;
20662
+ if (errors === _errs17) {
20504
20663
  if (data && typeof data == "object" && !Array.isArray(data)) {
20505
20664
  let missing3;
20506
- if (data.error === void 0 && (missing3 = "error") || data.feature === void 0 && (missing3 = "feature")) {
20507
- const err17 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/3/required", keyword: "required", params: { missingProperty: missing3 }, message: "must have required property '" + missing3 + "'" };
20665
+ if (data.error === void 0 && (missing3 = "error")) {
20666
+ const err15 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/3/required", keyword: "required", params: { missingProperty: missing3 }, message: "must have required property '" + missing3 + "'" };
20508
20667
  if (vErrors === null) {
20509
- vErrors = [err17];
20668
+ vErrors = [err15];
20510
20669
  } else {
20511
- vErrors.push(err17);
20670
+ vErrors.push(err15);
20512
20671
  }
20513
20672
  errors++;
20514
20673
  } else {
20515
- const _errs21 = errors;
20674
+ const _errs19 = errors;
20516
20675
  for (const key3 in data) {
20517
- if (!(key3 === "error" || key3 === "feature")) {
20518
- const err18 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/3/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key3 }, message: "must NOT have additional properties" };
20676
+ if (!(key3 === "error")) {
20677
+ const err16 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/3/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key3 }, message: "must NOT have additional properties" };
20519
20678
  if (vErrors === null) {
20520
- vErrors = [err18];
20679
+ vErrors = [err16];
20521
20680
  } else {
20522
- vErrors.push(err18);
20681
+ vErrors.push(err16);
20523
20682
  }
20524
20683
  errors++;
20525
20684
  break;
20526
20685
  }
20527
20686
  }
20528
- if (_errs21 === errors) {
20687
+ if (_errs19 === errors) {
20529
20688
  if (data.error !== void 0) {
20530
- let data4 = data.error;
20531
- const _errs22 = errors;
20532
- if (typeof data4 !== "string") {
20533
- const err19 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/3/properties/error/type", keyword: "type", params: { type: "string" }, message: "must be string" };
20689
+ let data3 = data.error;
20690
+ if (typeof data3 !== "string") {
20691
+ const err17 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/3/properties/error/type", keyword: "type", params: { type: "string" }, message: "must be string" };
20534
20692
  if (vErrors === null) {
20535
- vErrors = [err19];
20693
+ vErrors = [err17];
20536
20694
  } else {
20537
- vErrors.push(err19);
20695
+ vErrors.push(err17);
20538
20696
  }
20539
20697
  errors++;
20540
20698
  }
20541
- if (!(data4 === "github_connect_unavailable" || data4 === "feature_check_unavailable")) {
20542
- const err20 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/3/properties/error/enum", keyword: "enum", params: { allowedValues: schema83.anyOf[3].properties.error.enum }, message: "must be equal to one of the allowed values" };
20699
+ if ("WorkOS identity authority is temporarily unavailable" !== data3) {
20700
+ const err18 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/3/properties/error/const", keyword: "const", params: { allowedValue: "WorkOS identity authority is temporarily unavailable" }, message: "must be equal to constant" };
20543
20701
  if (vErrors === null) {
20544
- vErrors = [err20];
20702
+ vErrors = [err18];
20545
20703
  } else {
20546
- vErrors.push(err20);
20704
+ vErrors.push(err18);
20547
20705
  }
20548
20706
  errors++;
20549
20707
  }
20550
- var valid5 = _errs22 === errors;
20551
- } else {
20552
- var valid5 = true;
20553
- }
20554
- if (valid5) {
20555
- if (data.feature !== void 0) {
20556
- let data5 = data.feature;
20557
- const _errs24 = errors;
20558
- if (typeof data5 !== "string") {
20559
- const err21 = { instancePath: instancePath + "/feature", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/3/properties/feature/type", keyword: "type", params: { type: "string" }, message: "must be string" };
20560
- if (vErrors === null) {
20561
- vErrors = [err21];
20562
- } else {
20563
- vErrors.push(err21);
20564
- }
20565
- errors++;
20566
- }
20567
- if ("github-connect" !== data5) {
20568
- const err22 = { instancePath: instancePath + "/feature", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/3/properties/feature/const", keyword: "const", params: { allowedValue: "github-connect" }, message: "must be equal to constant" };
20569
- if (vErrors === null) {
20570
- vErrors = [err22];
20571
- } else {
20572
- vErrors.push(err22);
20573
- }
20574
- errors++;
20575
- }
20576
- var valid5 = _errs24 === errors;
20577
- } else {
20578
- var valid5 = true;
20579
- }
20580
20708
  }
20581
20709
  }
20582
20710
  }
20583
20711
  } else {
20584
- const err23 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/3/type", keyword: "type", params: { type: "object" }, message: "must be object" };
20712
+ const err19 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/3/type", keyword: "type", params: { type: "object" }, message: "must be object" };
20585
20713
  if (vErrors === null) {
20586
- vErrors = [err23];
20714
+ vErrors = [err19];
20587
20715
  } else {
20588
- vErrors.push(err23);
20716
+ vErrors.push(err19);
20589
20717
  }
20590
20718
  errors++;
20591
20719
  }
20592
20720
  }
20593
- var _valid0 = _errs19 === errors;
20721
+ var _valid0 = _errs17 === errors;
20594
20722
  valid1 = valid1 || _valid0;
20595
20723
  if (_valid0) {
20596
20724
  if (props0 !== true) {
20597
20725
  props0 = true;
20598
20726
  }
20599
20727
  }
20600
- const _errs26 = errors;
20601
- if (errors === _errs26) {
20728
+ const _errs22 = errors;
20729
+ if (errors === _errs22) {
20602
20730
  if (data && typeof data == "object" && !Array.isArray(data)) {
20603
20731
  let missing4;
20604
20732
  if (data.error === void 0 && (missing4 = "error")) {
20605
- const err24 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/4/required", keyword: "required", params: { missingProperty: missing4 }, message: "must have required property '" + missing4 + "'" };
20733
+ const err20 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/4/required", keyword: "required", params: { missingProperty: missing4 }, message: "must have required property '" + missing4 + "'" };
20606
20734
  if (vErrors === null) {
20607
- vErrors = [err24];
20735
+ vErrors = [err20];
20608
20736
  } else {
20609
- vErrors.push(err24);
20737
+ vErrors.push(err20);
20610
20738
  }
20611
20739
  errors++;
20612
20740
  } else {
20613
- const _errs28 = errors;
20741
+ const _errs24 = errors;
20614
20742
  for (const key4 in data) {
20615
20743
  if (!(key4 === "error")) {
20616
- const err25 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/4/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key4 }, message: "must NOT have additional properties" };
20744
+ const err21 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/4/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key4 }, message: "must NOT have additional properties" };
20617
20745
  if (vErrors === null) {
20618
- vErrors = [err25];
20746
+ vErrors = [err21];
20619
20747
  } else {
20620
- vErrors.push(err25);
20748
+ vErrors.push(err21);
20621
20749
  }
20622
20750
  errors++;
20623
20751
  break;
20624
20752
  }
20625
20753
  }
20626
- if (_errs28 === errors) {
20754
+ if (_errs24 === errors) {
20627
20755
  if (data.error !== void 0) {
20628
- let data6 = data.error;
20629
- if (typeof data6 !== "string") {
20630
- const err26 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/4/properties/error/type", keyword: "type", params: { type: "string" }, message: "must be string" };
20756
+ let data4 = data.error;
20757
+ if (typeof data4 !== "string") {
20758
+ const err22 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/4/properties/error/type", keyword: "type", params: { type: "string" }, message: "must be string" };
20631
20759
  if (vErrors === null) {
20632
- vErrors = [err26];
20760
+ vErrors = [err22];
20633
20761
  } else {
20634
- vErrors.push(err26);
20762
+ vErrors.push(err22);
20635
20763
  }
20636
20764
  errors++;
20637
20765
  }
20638
- if ("WorkOS identity authority is temporarily unavailable" !== data6) {
20639
- const err27 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/4/properties/error/const", keyword: "const", params: { allowedValue: "WorkOS identity authority is temporarily unavailable" }, message: "must be equal to constant" };
20766
+ if ("github_install_intent_conflict" !== data4) {
20767
+ const err23 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/4/properties/error/const", keyword: "const", params: { allowedValue: "github_install_intent_conflict" }, message: "must be equal to constant" };
20640
20768
  if (vErrors === null) {
20641
- vErrors = [err27];
20769
+ vErrors = [err23];
20642
20770
  } else {
20643
- vErrors.push(err27);
20771
+ vErrors.push(err23);
20644
20772
  }
20645
20773
  errors++;
20646
20774
  }
@@ -20648,195 +20776,128 @@ function validate46(data, { instancePath = "", parentData, parentDataProperty, r
20648
20776
  }
20649
20777
  }
20650
20778
  } else {
20651
- const err28 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/4/type", keyword: "type", params: { type: "object" }, message: "must be object" };
20779
+ const err24 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/4/type", keyword: "type", params: { type: "object" }, message: "must be object" };
20652
20780
  if (vErrors === null) {
20653
- vErrors = [err28];
20781
+ vErrors = [err24];
20654
20782
  } else {
20655
- vErrors.push(err28);
20783
+ vErrors.push(err24);
20656
20784
  }
20657
20785
  errors++;
20658
20786
  }
20659
20787
  }
20660
- var _valid0 = _errs26 === errors;
20788
+ var _valid0 = _errs22 === errors;
20661
20789
  valid1 = valid1 || _valid0;
20662
20790
  if (_valid0) {
20663
20791
  if (props0 !== true) {
20664
20792
  props0 = true;
20665
20793
  }
20666
20794
  }
20667
- const _errs31 = errors;
20668
- if (errors === _errs31) {
20795
+ const _errs27 = errors;
20796
+ if (errors === _errs27) {
20669
20797
  if (data && typeof data == "object" && !Array.isArray(data)) {
20670
20798
  let missing5;
20671
- if (data.error === void 0 && (missing5 = "error")) {
20672
- const err29 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/required", keyword: "required", params: { missingProperty: missing5 }, message: "must have required property '" + missing5 + "'" };
20799
+ if (data.error === void 0 && (missing5 = "error") || data.retryAt === void 0 && (missing5 = "retryAt")) {
20800
+ const err25 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/required", keyword: "required", params: { missingProperty: missing5 }, message: "must have required property '" + missing5 + "'" };
20673
20801
  if (vErrors === null) {
20674
- vErrors = [err29];
20802
+ vErrors = [err25];
20675
20803
  } else {
20676
- vErrors.push(err29);
20804
+ vErrors.push(err25);
20677
20805
  }
20678
20806
  errors++;
20679
20807
  } else {
20680
- const _errs33 = errors;
20808
+ const _errs29 = errors;
20681
20809
  for (const key5 in data) {
20682
- if (!(key5 === "error")) {
20683
- const err30 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key5 }, message: "must NOT have additional properties" };
20810
+ if (!(key5 === "error" || key5 === "retryAt")) {
20811
+ const err26 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key5 }, message: "must NOT have additional properties" };
20684
20812
  if (vErrors === null) {
20685
- vErrors = [err30];
20813
+ vErrors = [err26];
20686
20814
  } else {
20687
- vErrors.push(err30);
20815
+ vErrors.push(err26);
20688
20816
  }
20689
20817
  errors++;
20690
20818
  break;
20691
20819
  }
20692
20820
  }
20693
- if (_errs33 === errors) {
20821
+ if (_errs29 === errors) {
20694
20822
  if (data.error !== void 0) {
20695
- let data7 = data.error;
20696
- if (typeof data7 !== "string") {
20697
- const err31 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/properties/error/type", keyword: "type", params: { type: "string" }, message: "must be string" };
20823
+ let data5 = data.error;
20824
+ const _errs30 = errors;
20825
+ if (typeof data5 !== "string") {
20826
+ const err27 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/properties/error/type", keyword: "type", params: { type: "string" }, message: "must be string" };
20698
20827
  if (vErrors === null) {
20699
- vErrors = [err31];
20828
+ vErrors = [err27];
20700
20829
  } else {
20701
- vErrors.push(err31);
20830
+ vErrors.push(err27);
20702
20831
  }
20703
20832
  errors++;
20704
20833
  }
20705
- if ("github_install_intent_conflict" !== data7) {
20706
- const err32 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/properties/error/const", keyword: "const", params: { allowedValue: "github_install_intent_conflict" }, message: "must be equal to constant" };
20834
+ if ("github_install_intent_rate_limited" !== data5) {
20835
+ const err28 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/properties/error/const", keyword: "const", params: { allowedValue: "github_install_intent_rate_limited" }, message: "must be equal to constant" };
20707
20836
  if (vErrors === null) {
20708
- vErrors = [err32];
20837
+ vErrors = [err28];
20709
20838
  } else {
20710
- vErrors.push(err32);
20839
+ vErrors.push(err28);
20711
20840
  }
20712
20841
  errors++;
20713
20842
  }
20843
+ var valid7 = _errs30 === errors;
20844
+ } else {
20845
+ var valid7 = true;
20846
+ }
20847
+ if (valid7) {
20848
+ if (data.retryAt !== void 0) {
20849
+ let data6 = data.retryAt;
20850
+ const _errs32 = errors;
20851
+ if (!(typeof data6 == "number" && (!(data6 % 1) && !isNaN(data6)) && isFinite(data6))) {
20852
+ const err29 = { instancePath: instancePath + "/retryAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/properties/retryAt/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
20853
+ if (vErrors === null) {
20854
+ vErrors = [err29];
20855
+ } else {
20856
+ vErrors.push(err29);
20857
+ }
20858
+ errors++;
20859
+ }
20860
+ if (errors === _errs32) {
20861
+ if (typeof data6 == "number" && isFinite(data6)) {
20862
+ if (data6 > 9007199254740991 || isNaN(data6)) {
20863
+ const err30 = { instancePath: instancePath + "/retryAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/properties/retryAt/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" };
20864
+ if (vErrors === null) {
20865
+ vErrors = [err30];
20866
+ } else {
20867
+ vErrors.push(err30);
20868
+ }
20869
+ errors++;
20870
+ } else {
20871
+ if (data6 < 0 || isNaN(data6)) {
20872
+ const err31 = { instancePath: instancePath + "/retryAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/properties/retryAt/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
20873
+ if (vErrors === null) {
20874
+ vErrors = [err31];
20875
+ } else {
20876
+ vErrors.push(err31);
20877
+ }
20878
+ errors++;
20879
+ }
20880
+ }
20881
+ }
20882
+ }
20883
+ var valid7 = _errs32 === errors;
20884
+ } else {
20885
+ var valid7 = true;
20886
+ }
20714
20887
  }
20715
20888
  }
20716
20889
  }
20717
20890
  } else {
20718
- const err33 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/type", keyword: "type", params: { type: "object" }, message: "must be object" };
20891
+ const err32 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/5/type", keyword: "type", params: { type: "object" }, message: "must be object" };
20719
20892
  if (vErrors === null) {
20720
- vErrors = [err33];
20893
+ vErrors = [err32];
20721
20894
  } else {
20722
- vErrors.push(err33);
20895
+ vErrors.push(err32);
20723
20896
  }
20724
20897
  errors++;
20725
20898
  }
20726
20899
  }
20727
- var _valid0 = _errs31 === errors;
20728
- valid1 = valid1 || _valid0;
20729
- if (_valid0) {
20730
- if (props0 !== true) {
20731
- props0 = true;
20732
- }
20733
- }
20734
- const _errs36 = errors;
20735
- if (errors === _errs36) {
20736
- if (data && typeof data == "object" && !Array.isArray(data)) {
20737
- let missing6;
20738
- if (data.error === void 0 && (missing6 = "error") || data.retryAt === void 0 && (missing6 = "retryAt")) {
20739
- const err34 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/required", keyword: "required", params: { missingProperty: missing6 }, message: "must have required property '" + missing6 + "'" };
20740
- if (vErrors === null) {
20741
- vErrors = [err34];
20742
- } else {
20743
- vErrors.push(err34);
20744
- }
20745
- errors++;
20746
- } else {
20747
- const _errs38 = errors;
20748
- for (const key6 in data) {
20749
- if (!(key6 === "error" || key6 === "retryAt")) {
20750
- const err35 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key6 }, message: "must NOT have additional properties" };
20751
- if (vErrors === null) {
20752
- vErrors = [err35];
20753
- } else {
20754
- vErrors.push(err35);
20755
- }
20756
- errors++;
20757
- break;
20758
- }
20759
- }
20760
- if (_errs38 === errors) {
20761
- if (data.error !== void 0) {
20762
- let data8 = data.error;
20763
- const _errs39 = errors;
20764
- if (typeof data8 !== "string") {
20765
- const err36 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/properties/error/type", keyword: "type", params: { type: "string" }, message: "must be string" };
20766
- if (vErrors === null) {
20767
- vErrors = [err36];
20768
- } else {
20769
- vErrors.push(err36);
20770
- }
20771
- errors++;
20772
- }
20773
- if ("github_install_intent_rate_limited" !== data8) {
20774
- const err37 = { instancePath: instancePath + "/error", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/properties/error/const", keyword: "const", params: { allowedValue: "github_install_intent_rate_limited" }, message: "must be equal to constant" };
20775
- if (vErrors === null) {
20776
- vErrors = [err37];
20777
- } else {
20778
- vErrors.push(err37);
20779
- }
20780
- errors++;
20781
- }
20782
- var valid8 = _errs39 === errors;
20783
- } else {
20784
- var valid8 = true;
20785
- }
20786
- if (valid8) {
20787
- if (data.retryAt !== void 0) {
20788
- let data9 = data.retryAt;
20789
- const _errs41 = errors;
20790
- if (!(typeof data9 == "number" && (!(data9 % 1) && !isNaN(data9)) && isFinite(data9))) {
20791
- const err38 = { instancePath: instancePath + "/retryAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/properties/retryAt/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
20792
- if (vErrors === null) {
20793
- vErrors = [err38];
20794
- } else {
20795
- vErrors.push(err38);
20796
- }
20797
- errors++;
20798
- }
20799
- if (errors === _errs41) {
20800
- if (typeof data9 == "number" && isFinite(data9)) {
20801
- if (data9 > 9007199254740991 || isNaN(data9)) {
20802
- const err39 = { instancePath: instancePath + "/retryAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/properties/retryAt/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" };
20803
- if (vErrors === null) {
20804
- vErrors = [err39];
20805
- } else {
20806
- vErrors.push(err39);
20807
- }
20808
- errors++;
20809
- } else {
20810
- if (data9 < 0 || isNaN(data9)) {
20811
- const err40 = { instancePath: instancePath + "/retryAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/properties/retryAt/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
20812
- if (vErrors === null) {
20813
- vErrors = [err40];
20814
- } else {
20815
- vErrors.push(err40);
20816
- }
20817
- errors++;
20818
- }
20819
- }
20820
- }
20821
- }
20822
- var valid8 = _errs41 === errors;
20823
- } else {
20824
- var valid8 = true;
20825
- }
20826
- }
20827
- }
20828
- }
20829
- } else {
20830
- const err41 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf/6/type", keyword: "type", params: { type: "object" }, message: "must be object" };
20831
- if (vErrors === null) {
20832
- vErrors = [err41];
20833
- } else {
20834
- vErrors.push(err41);
20835
- }
20836
- errors++;
20837
- }
20838
- }
20839
- var _valid0 = _errs36 === errors;
20900
+ var _valid0 = _errs27 === errors;
20840
20901
  valid1 = valid1 || _valid0;
20841
20902
  if (_valid0) {
20842
20903
  if (props0 !== true) {
@@ -20844,11 +20905,11 @@ function validate46(data, { instancePath = "", parentData, parentDataProperty, r
20844
20905
  }
20845
20906
  }
20846
20907
  if (!valid1) {
20847
- const err42 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
20908
+ const err33 = { instancePath, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/GitHubInstallIntentStartErrorResponse/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
20848
20909
  if (vErrors === null) {
20849
- vErrors = [err42];
20910
+ vErrors = [err33];
20850
20911
  } else {
20851
- vErrors.push(err42);
20912
+ vErrors.push(err33);
20852
20913
  }
20853
20914
  errors++;
20854
20915
  validate46.errors = vErrors;
@@ -22950,7 +23011,7 @@ function validate50(data, { instancePath = "", parentData, parentDataProperty, r
22950
23011
  return errors === 0;
22951
23012
  }
22952
23013
  validate50.evaluated = { "dynamicProps": true, "dynamicItems": false };
22953
- var schema93 = { "type": "object", "properties": { "batch": { "type": "array", "items": { "anyOf": [{ "type": "object", "properties": { "moveId": { "type": "string" }, "capturedAt": { "type": "number" }, "sessionId": { "type": "string" }, "invocationId": { "type": "string" }, "eventType": { "type": "string" }, "payload": {}, "env": {}, "capturedOrganizationId": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9_-]+$" }, "captureAuthorityKind": { "type": "string", "enum": ["workos", "service_token"] }, "decisionLifecycleProtocolVersion": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 }, "producer": { "type": "string", "enum": ["claude_code", "codex", "cursor", "hermes"] }, "toolOutcome": { "type": "string", "enum": ["succeeded", "returned", "failed", "interrupted", "prevented", "unknown"] }, "envelopeVersion": { "type": "number", "const": 4 } }, "required": ["moveId", "capturedAt", "sessionId", "eventType", "capturedOrganizationId", "captureAuthorityKind", "decisionLifecycleProtocolVersion", "envelopeVersion"], "additionalProperties": {} }, { "type": "object", "properties": { "moveId": { "type": "string" }, "capturedAt": { "type": "number" }, "sessionId": { "type": "string" }, "invocationId": { "type": "string" }, "eventType": { "type": "string" }, "payload": {}, "env": {}, "capturedOrganizationId": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9_-]+$" }, "captureAuthorityKind": { "type": "string", "enum": ["workos", "service_token"] }, "decisionLifecycleProtocolVersion": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 }, "producer": { "type": "string", "enum": ["claude_code", "codex", "cursor", "hermes"] }, "toolOutcome": { "type": "string", "enum": ["succeeded", "returned", "failed", "interrupted", "prevented", "unknown"] }, "envelopeVersion": { "type": "number", "exclusiveMaximum": 4 } }, "required": ["moveId", "capturedAt", "sessionId", "eventType"], "additionalProperties": {} }] } } }, "required": ["batch"], "additionalProperties": {} };
23014
+ var schema93 = { "type": "object", "properties": { "batch": { "type": "array", "items": { "anyOf": [{ "type": "object", "properties": { "moveId": { "type": "string" }, "capturedAt": { "type": "number" }, "sessionId": { "type": "string" }, "invocationId": { "type": "string" }, "eventType": { "type": "string" }, "payload": {}, "env": {}, "repositoryContext": { "oneOf": [{ "type": "object", "properties": { "kind": { "type": "string", "const": "repository_bound" }, "repoSyncId": { "type": "string", "minLength": 1, "maxLength": 128 } }, "required": ["kind", "repoSyncId"], "additionalProperties": false }, { "type": "object", "properties": { "kind": { "type": "string", "const": "non_repository" } }, "required": ["kind"], "additionalProperties": false }] }, "capturedOrganizationId": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9_-]+$" }, "captureAuthorityKind": { "type": "string", "enum": ["workos", "service_token"] }, "decisionLifecycleProtocolVersion": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 }, "producer": { "type": "string", "enum": ["claude_code", "codex", "cursor", "hermes"] }, "toolOutcome": { "type": "string", "enum": ["succeeded", "returned", "failed", "interrupted", "prevented", "unknown"] }, "envelopeVersion": { "type": "number", "const": 4 } }, "required": ["moveId", "capturedAt", "sessionId", "eventType", "capturedOrganizationId", "captureAuthorityKind", "decisionLifecycleProtocolVersion", "envelopeVersion"], "additionalProperties": {} }, { "type": "object", "properties": { "moveId": { "type": "string" }, "capturedAt": { "type": "number" }, "sessionId": { "type": "string" }, "invocationId": { "type": "string" }, "eventType": { "type": "string" }, "payload": {}, "env": {}, "repositoryContext": { "oneOf": [{ "type": "object", "properties": { "kind": { "type": "string", "const": "repository_bound" }, "repoSyncId": { "type": "string", "minLength": 1, "maxLength": 128 } }, "required": ["kind", "repoSyncId"], "additionalProperties": false }, { "type": "object", "properties": { "kind": { "type": "string", "const": "non_repository" } }, "required": ["kind"], "additionalProperties": false }] }, "capturedOrganizationId": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9_-]+$" }, "captureAuthorityKind": { "type": "string", "enum": ["workos", "service_token"] }, "decisionLifecycleProtocolVersion": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 }, "producer": { "type": "string", "enum": ["claude_code", "codex", "cursor", "hermes"] }, "toolOutcome": { "type": "string", "enum": ["succeeded", "returned", "failed", "interrupted", "prevented", "unknown"] }, "envelopeVersion": { "type": "number", "exclusiveMaximum": 4 } }, "required": ["moveId", "capturedAt", "sessionId", "eventType"], "additionalProperties": {} }] } } }, "required": ["batch"], "additionalProperties": {} };
22954
23015
  var pattern8 = new RegExp("^[A-Za-z0-9_-]+$", "u");
22955
23016
  function validate51(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
22956
23017
  ;
@@ -23077,13 +23138,18 @@ function validate51(data, { instancePath = "", parentData, parentDataProperty, r
23077
23138
  var valid4 = true;
23078
23139
  }
23079
23140
  if (valid4) {
23080
- if (data1.capturedOrganizationId !== void 0) {
23081
- let data7 = data1.capturedOrganizationId;
23141
+ if (data1.repositoryContext !== void 0) {
23142
+ let data7 = data1.repositoryContext;
23082
23143
  const _errs20 = errors;
23083
- if (errors === _errs20) {
23084
- if (typeof data7 === "string") {
23085
- if (func1(data7) > 128) {
23086
- const err6 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/capturedOrganizationId/maxLength", keyword: "maxLength", params: { limit: 128 }, message: "must NOT have more than 128 characters" };
23144
+ const _errs21 = errors;
23145
+ let valid5 = false;
23146
+ let passing0 = null;
23147
+ const _errs22 = errors;
23148
+ if (errors === _errs22) {
23149
+ if (data7 && typeof data7 == "object" && !Array.isArray(data7)) {
23150
+ let missing2;
23151
+ if (data7.kind === void 0 && (missing2 = "kind") || data7.repoSyncId === void 0 && (missing2 = "repoSyncId")) {
23152
+ const err6 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/repositoryContext/oneOf/0/required", keyword: "required", params: { missingProperty: missing2 }, message: "must have required property '" + missing2 + "'" };
23087
23153
  if (vErrors === null) {
23088
23154
  vErrors = [err6];
23089
23155
  } else {
@@ -23091,201 +23157,409 @@ function validate51(data, { instancePath = "", parentData, parentDataProperty, r
23091
23157
  }
23092
23158
  errors++;
23093
23159
  } else {
23094
- if (func1(data7) < 1) {
23095
- const err7 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/capturedOrganizationId/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
23096
- if (vErrors === null) {
23097
- vErrors = [err7];
23098
- } else {
23099
- vErrors.push(err7);
23100
- }
23101
- errors++;
23102
- } else {
23103
- if (!pattern8.test(data7)) {
23104
- const err8 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/capturedOrganizationId/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9_-]+$" }, message: 'must match pattern "^[A-Za-z0-9_-]+$"' };
23160
+ const _errs24 = errors;
23161
+ for (const key0 in data7) {
23162
+ if (!(key0 === "kind" || key0 === "repoSyncId")) {
23163
+ const err7 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/repositoryContext/oneOf/0/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key0 }, message: "must NOT have additional properties" };
23105
23164
  if (vErrors === null) {
23106
- vErrors = [err8];
23165
+ vErrors = [err7];
23107
23166
  } else {
23108
- vErrors.push(err8);
23167
+ vErrors.push(err7);
23109
23168
  }
23110
23169
  errors++;
23170
+ break;
23171
+ }
23172
+ }
23173
+ if (_errs24 === errors) {
23174
+ if (data7.kind !== void 0) {
23175
+ let data8 = data7.kind;
23176
+ const _errs25 = errors;
23177
+ if (typeof data8 !== "string") {
23178
+ const err8 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext/kind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/repositoryContext/oneOf/0/properties/kind/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23179
+ if (vErrors === null) {
23180
+ vErrors = [err8];
23181
+ } else {
23182
+ vErrors.push(err8);
23183
+ }
23184
+ errors++;
23185
+ }
23186
+ if ("repository_bound" !== data8) {
23187
+ const err9 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext/kind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/repositoryContext/oneOf/0/properties/kind/const", keyword: "const", params: { allowedValue: "repository_bound" }, message: "must be equal to constant" };
23188
+ if (vErrors === null) {
23189
+ vErrors = [err9];
23190
+ } else {
23191
+ vErrors.push(err9);
23192
+ }
23193
+ errors++;
23194
+ }
23195
+ var valid6 = _errs25 === errors;
23196
+ } else {
23197
+ var valid6 = true;
23198
+ }
23199
+ if (valid6) {
23200
+ if (data7.repoSyncId !== void 0) {
23201
+ let data9 = data7.repoSyncId;
23202
+ const _errs27 = errors;
23203
+ if (errors === _errs27) {
23204
+ if (typeof data9 === "string") {
23205
+ if (func1(data9) > 128) {
23206
+ const err10 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext/repoSyncId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/repositoryContext/oneOf/0/properties/repoSyncId/maxLength", keyword: "maxLength", params: { limit: 128 }, message: "must NOT have more than 128 characters" };
23207
+ if (vErrors === null) {
23208
+ vErrors = [err10];
23209
+ } else {
23210
+ vErrors.push(err10);
23211
+ }
23212
+ errors++;
23213
+ } else {
23214
+ if (func1(data9) < 1) {
23215
+ const err11 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext/repoSyncId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/repositoryContext/oneOf/0/properties/repoSyncId/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
23216
+ if (vErrors === null) {
23217
+ vErrors = [err11];
23218
+ } else {
23219
+ vErrors.push(err11);
23220
+ }
23221
+ errors++;
23222
+ }
23223
+ }
23224
+ } else {
23225
+ const err12 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext/repoSyncId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/repositoryContext/oneOf/0/properties/repoSyncId/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23226
+ if (vErrors === null) {
23227
+ vErrors = [err12];
23228
+ } else {
23229
+ vErrors.push(err12);
23230
+ }
23231
+ errors++;
23232
+ }
23233
+ }
23234
+ var valid6 = _errs27 === errors;
23235
+ } else {
23236
+ var valid6 = true;
23237
+ }
23111
23238
  }
23112
23239
  }
23113
23240
  }
23114
23241
  } else {
23115
- const err9 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/capturedOrganizationId/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23242
+ const err13 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/repositoryContext/oneOf/0/type", keyword: "type", params: { type: "object" }, message: "must be object" };
23116
23243
  if (vErrors === null) {
23117
- vErrors = [err9];
23244
+ vErrors = [err13];
23118
23245
  } else {
23119
- vErrors.push(err9);
23246
+ vErrors.push(err13);
23120
23247
  }
23121
23248
  errors++;
23122
23249
  }
23123
23250
  }
23124
- var valid4 = _errs20 === errors;
23125
- } else {
23126
- var valid4 = true;
23127
- }
23128
- if (valid4) {
23129
- if (data1.captureAuthorityKind !== void 0) {
23130
- let data8 = data1.captureAuthorityKind;
23131
- const _errs22 = errors;
23132
- if (typeof data8 !== "string") {
23133
- const err10 = { instancePath: instancePath + "/batch/" + i0 + "/captureAuthorityKind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/captureAuthorityKind/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23134
- if (vErrors === null) {
23135
- vErrors = [err10];
23251
+ var _valid1 = _errs22 === errors;
23252
+ if (_valid1) {
23253
+ valid5 = true;
23254
+ passing0 = 0;
23255
+ var props0 = true;
23256
+ }
23257
+ const _errs29 = errors;
23258
+ if (errors === _errs29) {
23259
+ if (data7 && typeof data7 == "object" && !Array.isArray(data7)) {
23260
+ let missing3;
23261
+ if (data7.kind === void 0 && (missing3 = "kind")) {
23262
+ const err14 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/repositoryContext/oneOf/1/required", keyword: "required", params: { missingProperty: missing3 }, message: "must have required property '" + missing3 + "'" };
23263
+ if (vErrors === null) {
23264
+ vErrors = [err14];
23265
+ } else {
23266
+ vErrors.push(err14);
23267
+ }
23268
+ errors++;
23136
23269
  } else {
23137
- vErrors.push(err10);
23270
+ const _errs31 = errors;
23271
+ for (const key1 in data7) {
23272
+ if (!(key1 === "kind")) {
23273
+ const err15 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/repositoryContext/oneOf/1/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key1 }, message: "must NOT have additional properties" };
23274
+ if (vErrors === null) {
23275
+ vErrors = [err15];
23276
+ } else {
23277
+ vErrors.push(err15);
23278
+ }
23279
+ errors++;
23280
+ break;
23281
+ }
23282
+ }
23283
+ if (_errs31 === errors) {
23284
+ if (data7.kind !== void 0) {
23285
+ let data10 = data7.kind;
23286
+ if (typeof data10 !== "string") {
23287
+ const err16 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext/kind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/repositoryContext/oneOf/1/properties/kind/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23288
+ if (vErrors === null) {
23289
+ vErrors = [err16];
23290
+ } else {
23291
+ vErrors.push(err16);
23292
+ }
23293
+ errors++;
23294
+ }
23295
+ if ("non_repository" !== data10) {
23296
+ const err17 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext/kind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/repositoryContext/oneOf/1/properties/kind/const", keyword: "const", params: { allowedValue: "non_repository" }, message: "must be equal to constant" };
23297
+ if (vErrors === null) {
23298
+ vErrors = [err17];
23299
+ } else {
23300
+ vErrors.push(err17);
23301
+ }
23302
+ errors++;
23303
+ }
23304
+ }
23305
+ }
23138
23306
  }
23139
- errors++;
23140
- }
23141
- if (!(data8 === "workos" || data8 === "service_token")) {
23142
- const err11 = { instancePath: instancePath + "/batch/" + i0 + "/captureAuthorityKind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/captureAuthorityKind/enum", keyword: "enum", params: { allowedValues: schema93.properties.batch.items.anyOf[0].properties.captureAuthorityKind.enum }, message: "must be equal to one of the allowed values" };
23307
+ } else {
23308
+ const err18 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/repositoryContext/oneOf/1/type", keyword: "type", params: { type: "object" }, message: "must be object" };
23143
23309
  if (vErrors === null) {
23144
- vErrors = [err11];
23310
+ vErrors = [err18];
23145
23311
  } else {
23146
- vErrors.push(err11);
23312
+ vErrors.push(err18);
23147
23313
  }
23148
23314
  errors++;
23149
23315
  }
23150
- var valid4 = _errs22 === errors;
23316
+ }
23317
+ var _valid1 = _errs29 === errors;
23318
+ if (_valid1 && valid5) {
23319
+ valid5 = false;
23320
+ passing0 = [passing0, 1];
23151
23321
  } else {
23152
- var valid4 = true;
23322
+ if (_valid1) {
23323
+ valid5 = true;
23324
+ passing0 = 1;
23325
+ if (props0 !== true) {
23326
+ props0 = true;
23327
+ }
23328
+ }
23153
23329
  }
23154
- if (valid4) {
23155
- if (data1.decisionLifecycleProtocolVersion !== void 0) {
23156
- let data9 = data1.decisionLifecycleProtocolVersion;
23157
- const _errs24 = errors;
23158
- if (!(typeof data9 == "number" && (!(data9 % 1) && !isNaN(data9)) && isFinite(data9))) {
23159
- const err12 = { instancePath: instancePath + "/batch/" + i0 + "/decisionLifecycleProtocolVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/decisionLifecycleProtocolVersion/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
23160
- if (vErrors === null) {
23161
- vErrors = [err12];
23162
- } else {
23163
- vErrors.push(err12);
23164
- }
23165
- errors++;
23330
+ if (!valid5) {
23331
+ const err19 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/repositoryContext/oneOf", keyword: "oneOf", params: { passingSchemas: passing0 }, message: "must match exactly one schema in oneOf" };
23332
+ if (vErrors === null) {
23333
+ vErrors = [err19];
23334
+ } else {
23335
+ vErrors.push(err19);
23336
+ }
23337
+ errors++;
23338
+ } else {
23339
+ errors = _errs21;
23340
+ if (vErrors !== null) {
23341
+ if (_errs21) {
23342
+ vErrors.length = _errs21;
23343
+ } else {
23344
+ vErrors = null;
23166
23345
  }
23167
- if (errors === _errs24) {
23168
- if (typeof data9 == "number" && isFinite(data9)) {
23169
- if (data9 > 9007199254740991 || isNaN(data9)) {
23170
- const err13 = { instancePath: instancePath + "/batch/" + i0 + "/decisionLifecycleProtocolVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/decisionLifecycleProtocolVersion/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" };
23346
+ }
23347
+ }
23348
+ var valid4 = _errs20 === errors;
23349
+ } else {
23350
+ var valid4 = true;
23351
+ }
23352
+ if (valid4) {
23353
+ if (data1.capturedOrganizationId !== void 0) {
23354
+ let data11 = data1.capturedOrganizationId;
23355
+ const _errs34 = errors;
23356
+ if (errors === _errs34) {
23357
+ if (typeof data11 === "string") {
23358
+ if (func1(data11) > 128) {
23359
+ const err20 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/capturedOrganizationId/maxLength", keyword: "maxLength", params: { limit: 128 }, message: "must NOT have more than 128 characters" };
23360
+ if (vErrors === null) {
23361
+ vErrors = [err20];
23362
+ } else {
23363
+ vErrors.push(err20);
23364
+ }
23365
+ errors++;
23366
+ } else {
23367
+ if (func1(data11) < 1) {
23368
+ const err21 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/capturedOrganizationId/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
23171
23369
  if (vErrors === null) {
23172
- vErrors = [err13];
23370
+ vErrors = [err21];
23173
23371
  } else {
23174
- vErrors.push(err13);
23372
+ vErrors.push(err21);
23175
23373
  }
23176
23374
  errors++;
23177
23375
  } else {
23178
- if (data9 < 1 || isNaN(data9)) {
23179
- const err14 = { instancePath: instancePath + "/batch/" + i0 + "/decisionLifecycleProtocolVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/decisionLifecycleProtocolVersion/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
23376
+ if (!pattern8.test(data11)) {
23377
+ const err22 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/capturedOrganizationId/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9_-]+$" }, message: 'must match pattern "^[A-Za-z0-9_-]+$"' };
23180
23378
  if (vErrors === null) {
23181
- vErrors = [err14];
23379
+ vErrors = [err22];
23182
23380
  } else {
23183
- vErrors.push(err14);
23381
+ vErrors.push(err22);
23184
23382
  }
23185
23383
  errors++;
23186
23384
  }
23187
23385
  }
23188
23386
  }
23387
+ } else {
23388
+ const err23 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/capturedOrganizationId/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23389
+ if (vErrors === null) {
23390
+ vErrors = [err23];
23391
+ } else {
23392
+ vErrors.push(err23);
23393
+ }
23394
+ errors++;
23395
+ }
23396
+ }
23397
+ var valid4 = _errs34 === errors;
23398
+ } else {
23399
+ var valid4 = true;
23400
+ }
23401
+ if (valid4) {
23402
+ if (data1.captureAuthorityKind !== void 0) {
23403
+ let data12 = data1.captureAuthorityKind;
23404
+ const _errs36 = errors;
23405
+ if (typeof data12 !== "string") {
23406
+ const err24 = { instancePath: instancePath + "/batch/" + i0 + "/captureAuthorityKind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/captureAuthorityKind/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23407
+ if (vErrors === null) {
23408
+ vErrors = [err24];
23409
+ } else {
23410
+ vErrors.push(err24);
23411
+ }
23412
+ errors++;
23413
+ }
23414
+ if (!(data12 === "workos" || data12 === "service_token")) {
23415
+ const err25 = { instancePath: instancePath + "/batch/" + i0 + "/captureAuthorityKind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/captureAuthorityKind/enum", keyword: "enum", params: { allowedValues: schema93.properties.batch.items.anyOf[0].properties.captureAuthorityKind.enum }, message: "must be equal to one of the allowed values" };
23416
+ if (vErrors === null) {
23417
+ vErrors = [err25];
23418
+ } else {
23419
+ vErrors.push(err25);
23420
+ }
23421
+ errors++;
23189
23422
  }
23190
- var valid4 = _errs24 === errors;
23423
+ var valid4 = _errs36 === errors;
23191
23424
  } else {
23192
23425
  var valid4 = true;
23193
23426
  }
23194
23427
  if (valid4) {
23195
- if (data1.producer !== void 0) {
23196
- let data10 = data1.producer;
23197
- const _errs26 = errors;
23198
- if (typeof data10 !== "string") {
23199
- const err15 = { instancePath: instancePath + "/batch/" + i0 + "/producer", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/producer/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23428
+ if (data1.decisionLifecycleProtocolVersion !== void 0) {
23429
+ let data13 = data1.decisionLifecycleProtocolVersion;
23430
+ const _errs38 = errors;
23431
+ if (!(typeof data13 == "number" && (!(data13 % 1) && !isNaN(data13)) && isFinite(data13))) {
23432
+ const err26 = { instancePath: instancePath + "/batch/" + i0 + "/decisionLifecycleProtocolVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/decisionLifecycleProtocolVersion/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
23200
23433
  if (vErrors === null) {
23201
- vErrors = [err15];
23434
+ vErrors = [err26];
23202
23435
  } else {
23203
- vErrors.push(err15);
23436
+ vErrors.push(err26);
23204
23437
  }
23205
23438
  errors++;
23206
23439
  }
23207
- if (!(data10 === "claude_code" || data10 === "codex" || data10 === "cursor" || data10 === "hermes")) {
23208
- const err16 = { instancePath: instancePath + "/batch/" + i0 + "/producer", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/producer/enum", keyword: "enum", params: { allowedValues: schema93.properties.batch.items.anyOf[0].properties.producer.enum }, message: "must be equal to one of the allowed values" };
23209
- if (vErrors === null) {
23210
- vErrors = [err16];
23211
- } else {
23212
- vErrors.push(err16);
23440
+ if (errors === _errs38) {
23441
+ if (typeof data13 == "number" && isFinite(data13)) {
23442
+ if (data13 > 9007199254740991 || isNaN(data13)) {
23443
+ const err27 = { instancePath: instancePath + "/batch/" + i0 + "/decisionLifecycleProtocolVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/decisionLifecycleProtocolVersion/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" };
23444
+ if (vErrors === null) {
23445
+ vErrors = [err27];
23446
+ } else {
23447
+ vErrors.push(err27);
23448
+ }
23449
+ errors++;
23450
+ } else {
23451
+ if (data13 < 1 || isNaN(data13)) {
23452
+ const err28 = { instancePath: instancePath + "/batch/" + i0 + "/decisionLifecycleProtocolVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/decisionLifecycleProtocolVersion/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
23453
+ if (vErrors === null) {
23454
+ vErrors = [err28];
23455
+ } else {
23456
+ vErrors.push(err28);
23457
+ }
23458
+ errors++;
23459
+ }
23460
+ }
23213
23461
  }
23214
- errors++;
23215
23462
  }
23216
- var valid4 = _errs26 === errors;
23463
+ var valid4 = _errs38 === errors;
23217
23464
  } else {
23218
23465
  var valid4 = true;
23219
23466
  }
23220
23467
  if (valid4) {
23221
- if (data1.toolOutcome !== void 0) {
23222
- let data11 = data1.toolOutcome;
23223
- const _errs28 = errors;
23224
- if (typeof data11 !== "string") {
23225
- const err17 = { instancePath: instancePath + "/batch/" + i0 + "/toolOutcome", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/toolOutcome/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23468
+ if (data1.producer !== void 0) {
23469
+ let data14 = data1.producer;
23470
+ const _errs40 = errors;
23471
+ if (typeof data14 !== "string") {
23472
+ const err29 = { instancePath: instancePath + "/batch/" + i0 + "/producer", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/producer/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23226
23473
  if (vErrors === null) {
23227
- vErrors = [err17];
23474
+ vErrors = [err29];
23228
23475
  } else {
23229
- vErrors.push(err17);
23476
+ vErrors.push(err29);
23230
23477
  }
23231
23478
  errors++;
23232
23479
  }
23233
- if (!(data11 === "succeeded" || data11 === "returned" || data11 === "failed" || data11 === "interrupted" || data11 === "prevented" || data11 === "unknown")) {
23234
- const err18 = { instancePath: instancePath + "/batch/" + i0 + "/toolOutcome", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/toolOutcome/enum", keyword: "enum", params: { allowedValues: schema93.properties.batch.items.anyOf[0].properties.toolOutcome.enum }, message: "must be equal to one of the allowed values" };
23480
+ if (!(data14 === "claude_code" || data14 === "codex" || data14 === "cursor" || data14 === "hermes")) {
23481
+ const err30 = { instancePath: instancePath + "/batch/" + i0 + "/producer", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/producer/enum", keyword: "enum", params: { allowedValues: schema93.properties.batch.items.anyOf[0].properties.producer.enum }, message: "must be equal to one of the allowed values" };
23235
23482
  if (vErrors === null) {
23236
- vErrors = [err18];
23483
+ vErrors = [err30];
23237
23484
  } else {
23238
- vErrors.push(err18);
23485
+ vErrors.push(err30);
23239
23486
  }
23240
23487
  errors++;
23241
23488
  }
23242
- var valid4 = _errs28 === errors;
23489
+ var valid4 = _errs40 === errors;
23243
23490
  } else {
23244
23491
  var valid4 = true;
23245
23492
  }
23246
23493
  if (valid4) {
23247
- if (data1.envelopeVersion !== void 0) {
23248
- let data12 = data1.envelopeVersion;
23249
- const _errs30 = errors;
23250
- if (!(typeof data12 == "number" && isFinite(data12))) {
23251
- const err19 = { instancePath: instancePath + "/batch/" + i0 + "/envelopeVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/envelopeVersion/type", keyword: "type", params: { type: "number" }, message: "must be number" };
23494
+ if (data1.toolOutcome !== void 0) {
23495
+ let data15 = data1.toolOutcome;
23496
+ const _errs42 = errors;
23497
+ if (typeof data15 !== "string") {
23498
+ const err31 = { instancePath: instancePath + "/batch/" + i0 + "/toolOutcome", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/toolOutcome/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23252
23499
  if (vErrors === null) {
23253
- vErrors = [err19];
23500
+ vErrors = [err31];
23254
23501
  } else {
23255
- vErrors.push(err19);
23502
+ vErrors.push(err31);
23256
23503
  }
23257
23504
  errors++;
23258
23505
  }
23259
- if (4 !== data12) {
23260
- const err20 = { instancePath: instancePath + "/batch/" + i0 + "/envelopeVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/envelopeVersion/const", keyword: "const", params: { allowedValue: 4 }, message: "must be equal to constant" };
23506
+ if (!(data15 === "succeeded" || data15 === "returned" || data15 === "failed" || data15 === "interrupted" || data15 === "prevented" || data15 === "unknown")) {
23507
+ const err32 = { instancePath: instancePath + "/batch/" + i0 + "/toolOutcome", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/toolOutcome/enum", keyword: "enum", params: { allowedValues: schema93.properties.batch.items.anyOf[0].properties.toolOutcome.enum }, message: "must be equal to one of the allowed values" };
23261
23508
  if (vErrors === null) {
23262
- vErrors = [err20];
23509
+ vErrors = [err32];
23263
23510
  } else {
23264
- vErrors.push(err20);
23511
+ vErrors.push(err32);
23265
23512
  }
23266
23513
  errors++;
23267
23514
  }
23268
- var valid4 = _errs30 === errors;
23515
+ var valid4 = _errs42 === errors;
23269
23516
  } else {
23270
23517
  var valid4 = true;
23271
23518
  }
23272
- }
23273
- }
23274
- }
23275
- }
23276
- }
23277
- }
23278
- }
23519
+ if (valid4) {
23520
+ if (data1.envelopeVersion !== void 0) {
23521
+ let data16 = data1.envelopeVersion;
23522
+ const _errs44 = errors;
23523
+ if (!(typeof data16 == "number" && isFinite(data16))) {
23524
+ const err33 = { instancePath: instancePath + "/batch/" + i0 + "/envelopeVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/envelopeVersion/type", keyword: "type", params: { type: "number" }, message: "must be number" };
23525
+ if (vErrors === null) {
23526
+ vErrors = [err33];
23527
+ } else {
23528
+ vErrors.push(err33);
23529
+ }
23530
+ errors++;
23531
+ }
23532
+ if (4 !== data16) {
23533
+ const err34 = { instancePath: instancePath + "/batch/" + i0 + "/envelopeVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/properties/envelopeVersion/const", keyword: "const", params: { allowedValue: 4 }, message: "must be equal to constant" };
23534
+ if (vErrors === null) {
23535
+ vErrors = [err34];
23536
+ } else {
23537
+ vErrors.push(err34);
23538
+ }
23539
+ errors++;
23540
+ }
23541
+ var valid4 = _errs44 === errors;
23542
+ } else {
23543
+ var valid4 = true;
23544
+ }
23545
+ }
23546
+ }
23547
+ }
23548
+ }
23549
+ }
23550
+ }
23551
+ }
23552
+ }
23279
23553
  }
23280
23554
  }
23281
23555
  }
23282
23556
  }
23283
23557
  } else {
23284
- const err21 = { instancePath: instancePath + "/batch/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/type", keyword: "type", params: { type: "object" }, message: "must be object" };
23558
+ const err35 = { instancePath: instancePath + "/batch/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/0/type", keyword: "type", params: { type: "object" }, message: "must be object" };
23285
23559
  if (vErrors === null) {
23286
- vErrors = [err21];
23560
+ vErrors = [err35];
23287
23561
  } else {
23288
- vErrors.push(err21);
23562
+ vErrors.push(err35);
23289
23563
  }
23290
23564
  errors++;
23291
23565
  }
@@ -23293,296 +23567,509 @@ function validate51(data, { instancePath = "", parentData, parentDataProperty, r
23293
23567
  var _valid0 = _errs7 === errors;
23294
23568
  valid3 = valid3 || _valid0;
23295
23569
  if (_valid0) {
23296
- var props0 = true;
23570
+ var props1 = true;
23297
23571
  }
23298
- const _errs32 = errors;
23299
- if (errors === _errs32) {
23572
+ const _errs46 = errors;
23573
+ if (errors === _errs46) {
23300
23574
  if (data1 && typeof data1 == "object" && !Array.isArray(data1)) {
23301
- let missing2;
23302
- if (data1.moveId === void 0 && (missing2 = "moveId") || data1.capturedAt === void 0 && (missing2 = "capturedAt") || data1.sessionId === void 0 && (missing2 = "sessionId") || data1.eventType === void 0 && (missing2 = "eventType")) {
23303
- const err22 = { instancePath: instancePath + "/batch/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/required", keyword: "required", params: { missingProperty: missing2 }, message: "must have required property '" + missing2 + "'" };
23575
+ let missing4;
23576
+ if (data1.moveId === void 0 && (missing4 = "moveId") || data1.capturedAt === void 0 && (missing4 = "capturedAt") || data1.sessionId === void 0 && (missing4 = "sessionId") || data1.eventType === void 0 && (missing4 = "eventType")) {
23577
+ const err36 = { instancePath: instancePath + "/batch/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/required", keyword: "required", params: { missingProperty: missing4 }, message: "must have required property '" + missing4 + "'" };
23304
23578
  if (vErrors === null) {
23305
- vErrors = [err22];
23579
+ vErrors = [err36];
23306
23580
  } else {
23307
- vErrors.push(err22);
23581
+ vErrors.push(err36);
23308
23582
  }
23309
23583
  errors++;
23310
23584
  } else {
23311
23585
  if (data1.moveId !== void 0) {
23312
- const _errs35 = errors;
23586
+ const _errs49 = errors;
23313
23587
  if (typeof data1.moveId !== "string") {
23314
- const err23 = { instancePath: instancePath + "/batch/" + i0 + "/moveId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/moveId/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23588
+ const err37 = { instancePath: instancePath + "/batch/" + i0 + "/moveId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/moveId/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23315
23589
  if (vErrors === null) {
23316
- vErrors = [err23];
23590
+ vErrors = [err37];
23317
23591
  } else {
23318
- vErrors.push(err23);
23592
+ vErrors.push(err37);
23319
23593
  }
23320
23594
  errors++;
23321
23595
  }
23322
- var valid5 = _errs35 === errors;
23596
+ var valid8 = _errs49 === errors;
23323
23597
  } else {
23324
- var valid5 = true;
23598
+ var valid8 = true;
23325
23599
  }
23326
- if (valid5) {
23600
+ if (valid8) {
23327
23601
  if (data1.capturedAt !== void 0) {
23328
- let data14 = data1.capturedAt;
23329
- const _errs37 = errors;
23330
- if (!(typeof data14 == "number" && isFinite(data14))) {
23331
- const err24 = { instancePath: instancePath + "/batch/" + i0 + "/capturedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/capturedAt/type", keyword: "type", params: { type: "number" }, message: "must be number" };
23602
+ let data18 = data1.capturedAt;
23603
+ const _errs51 = errors;
23604
+ if (!(typeof data18 == "number" && isFinite(data18))) {
23605
+ const err38 = { instancePath: instancePath + "/batch/" + i0 + "/capturedAt", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/capturedAt/type", keyword: "type", params: { type: "number" }, message: "must be number" };
23332
23606
  if (vErrors === null) {
23333
- vErrors = [err24];
23607
+ vErrors = [err38];
23334
23608
  } else {
23335
- vErrors.push(err24);
23609
+ vErrors.push(err38);
23336
23610
  }
23337
23611
  errors++;
23338
23612
  }
23339
- var valid5 = _errs37 === errors;
23613
+ var valid8 = _errs51 === errors;
23340
23614
  } else {
23341
- var valid5 = true;
23615
+ var valid8 = true;
23342
23616
  }
23343
- if (valid5) {
23617
+ if (valid8) {
23344
23618
  if (data1.sessionId !== void 0) {
23345
- const _errs39 = errors;
23619
+ const _errs53 = errors;
23346
23620
  if (typeof data1.sessionId !== "string") {
23347
- const err25 = { instancePath: instancePath + "/batch/" + i0 + "/sessionId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/sessionId/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23621
+ const err39 = { instancePath: instancePath + "/batch/" + i0 + "/sessionId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/sessionId/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23348
23622
  if (vErrors === null) {
23349
- vErrors = [err25];
23623
+ vErrors = [err39];
23350
23624
  } else {
23351
- vErrors.push(err25);
23625
+ vErrors.push(err39);
23352
23626
  }
23353
23627
  errors++;
23354
23628
  }
23355
- var valid5 = _errs39 === errors;
23629
+ var valid8 = _errs53 === errors;
23356
23630
  } else {
23357
- var valid5 = true;
23631
+ var valid8 = true;
23358
23632
  }
23359
- if (valid5) {
23633
+ if (valid8) {
23360
23634
  if (data1.invocationId !== void 0) {
23361
- const _errs41 = errors;
23635
+ const _errs55 = errors;
23362
23636
  if (typeof data1.invocationId !== "string") {
23363
- const err26 = { instancePath: instancePath + "/batch/" + i0 + "/invocationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/invocationId/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23637
+ const err40 = { instancePath: instancePath + "/batch/" + i0 + "/invocationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/invocationId/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23364
23638
  if (vErrors === null) {
23365
- vErrors = [err26];
23639
+ vErrors = [err40];
23366
23640
  } else {
23367
- vErrors.push(err26);
23641
+ vErrors.push(err40);
23368
23642
  }
23369
23643
  errors++;
23370
23644
  }
23371
- var valid5 = _errs41 === errors;
23645
+ var valid8 = _errs55 === errors;
23372
23646
  } else {
23373
- var valid5 = true;
23647
+ var valid8 = true;
23374
23648
  }
23375
- if (valid5) {
23649
+ if (valid8) {
23376
23650
  if (data1.eventType !== void 0) {
23377
- const _errs43 = errors;
23651
+ const _errs57 = errors;
23378
23652
  if (typeof data1.eventType !== "string") {
23379
- const err27 = { instancePath: instancePath + "/batch/" + i0 + "/eventType", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/eventType/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23653
+ const err41 = { instancePath: instancePath + "/batch/" + i0 + "/eventType", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/eventType/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23380
23654
  if (vErrors === null) {
23381
- vErrors = [err27];
23655
+ vErrors = [err41];
23382
23656
  } else {
23383
- vErrors.push(err27);
23657
+ vErrors.push(err41);
23384
23658
  }
23385
23659
  errors++;
23386
23660
  }
23387
- var valid5 = _errs43 === errors;
23661
+ var valid8 = _errs57 === errors;
23388
23662
  } else {
23389
- var valid5 = true;
23663
+ var valid8 = true;
23390
23664
  }
23391
- if (valid5) {
23392
- if (data1.capturedOrganizationId !== void 0) {
23393
- let data18 = data1.capturedOrganizationId;
23394
- const _errs45 = errors;
23395
- if (errors === _errs45) {
23396
- if (typeof data18 === "string") {
23397
- if (func1(data18) > 128) {
23398
- const err28 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/capturedOrganizationId/maxLength", keyword: "maxLength", params: { limit: 128 }, message: "must NOT have more than 128 characters" };
23665
+ if (valid8) {
23666
+ if (data1.repositoryContext !== void 0) {
23667
+ let data22 = data1.repositoryContext;
23668
+ const _errs59 = errors;
23669
+ const _errs60 = errors;
23670
+ let valid9 = false;
23671
+ let passing1 = null;
23672
+ const _errs61 = errors;
23673
+ if (errors === _errs61) {
23674
+ if (data22 && typeof data22 == "object" && !Array.isArray(data22)) {
23675
+ let missing5;
23676
+ if (data22.kind === void 0 && (missing5 = "kind") || data22.repoSyncId === void 0 && (missing5 = "repoSyncId")) {
23677
+ const err42 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/repositoryContext/oneOf/0/required", keyword: "required", params: { missingProperty: missing5 }, message: "must have required property '" + missing5 + "'" };
23399
23678
  if (vErrors === null) {
23400
- vErrors = [err28];
23679
+ vErrors = [err42];
23401
23680
  } else {
23402
- vErrors.push(err28);
23681
+ vErrors.push(err42);
23403
23682
  }
23404
23683
  errors++;
23405
23684
  } else {
23406
- if (func1(data18) < 1) {
23407
- const err29 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/capturedOrganizationId/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
23408
- if (vErrors === null) {
23409
- vErrors = [err29];
23410
- } else {
23411
- vErrors.push(err29);
23412
- }
23413
- errors++;
23414
- } else {
23415
- if (!pattern8.test(data18)) {
23416
- const err30 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/capturedOrganizationId/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9_-]+$" }, message: 'must match pattern "^[A-Za-z0-9_-]+$"' };
23685
+ const _errs63 = errors;
23686
+ for (const key2 in data22) {
23687
+ if (!(key2 === "kind" || key2 === "repoSyncId")) {
23688
+ const err43 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/repositoryContext/oneOf/0/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key2 }, message: "must NOT have additional properties" };
23417
23689
  if (vErrors === null) {
23418
- vErrors = [err30];
23690
+ vErrors = [err43];
23419
23691
  } else {
23420
- vErrors.push(err30);
23692
+ vErrors.push(err43);
23421
23693
  }
23422
23694
  errors++;
23695
+ break;
23696
+ }
23697
+ }
23698
+ if (_errs63 === errors) {
23699
+ if (data22.kind !== void 0) {
23700
+ let data23 = data22.kind;
23701
+ const _errs64 = errors;
23702
+ if (typeof data23 !== "string") {
23703
+ const err44 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext/kind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/repositoryContext/oneOf/0/properties/kind/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23704
+ if (vErrors === null) {
23705
+ vErrors = [err44];
23706
+ } else {
23707
+ vErrors.push(err44);
23708
+ }
23709
+ errors++;
23710
+ }
23711
+ if ("repository_bound" !== data23) {
23712
+ const err45 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext/kind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/repositoryContext/oneOf/0/properties/kind/const", keyword: "const", params: { allowedValue: "repository_bound" }, message: "must be equal to constant" };
23713
+ if (vErrors === null) {
23714
+ vErrors = [err45];
23715
+ } else {
23716
+ vErrors.push(err45);
23717
+ }
23718
+ errors++;
23719
+ }
23720
+ var valid10 = _errs64 === errors;
23721
+ } else {
23722
+ var valid10 = true;
23723
+ }
23724
+ if (valid10) {
23725
+ if (data22.repoSyncId !== void 0) {
23726
+ let data24 = data22.repoSyncId;
23727
+ const _errs66 = errors;
23728
+ if (errors === _errs66) {
23729
+ if (typeof data24 === "string") {
23730
+ if (func1(data24) > 128) {
23731
+ const err46 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext/repoSyncId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/repositoryContext/oneOf/0/properties/repoSyncId/maxLength", keyword: "maxLength", params: { limit: 128 }, message: "must NOT have more than 128 characters" };
23732
+ if (vErrors === null) {
23733
+ vErrors = [err46];
23734
+ } else {
23735
+ vErrors.push(err46);
23736
+ }
23737
+ errors++;
23738
+ } else {
23739
+ if (func1(data24) < 1) {
23740
+ const err47 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext/repoSyncId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/repositoryContext/oneOf/0/properties/repoSyncId/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
23741
+ if (vErrors === null) {
23742
+ vErrors = [err47];
23743
+ } else {
23744
+ vErrors.push(err47);
23745
+ }
23746
+ errors++;
23747
+ }
23748
+ }
23749
+ } else {
23750
+ const err48 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext/repoSyncId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/repositoryContext/oneOf/0/properties/repoSyncId/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23751
+ if (vErrors === null) {
23752
+ vErrors = [err48];
23753
+ } else {
23754
+ vErrors.push(err48);
23755
+ }
23756
+ errors++;
23757
+ }
23758
+ }
23759
+ var valid10 = _errs66 === errors;
23760
+ } else {
23761
+ var valid10 = true;
23762
+ }
23423
23763
  }
23424
23764
  }
23425
23765
  }
23426
23766
  } else {
23427
- const err31 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/capturedOrganizationId/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23767
+ const err49 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/repositoryContext/oneOf/0/type", keyword: "type", params: { type: "object" }, message: "must be object" };
23428
23768
  if (vErrors === null) {
23429
- vErrors = [err31];
23769
+ vErrors = [err49];
23430
23770
  } else {
23431
- vErrors.push(err31);
23771
+ vErrors.push(err49);
23432
23772
  }
23433
23773
  errors++;
23434
23774
  }
23435
23775
  }
23436
- var valid5 = _errs45 === errors;
23437
- } else {
23438
- var valid5 = true;
23439
- }
23440
- if (valid5) {
23441
- if (data1.captureAuthorityKind !== void 0) {
23442
- let data19 = data1.captureAuthorityKind;
23443
- const _errs47 = errors;
23444
- if (typeof data19 !== "string") {
23445
- const err32 = { instancePath: instancePath + "/batch/" + i0 + "/captureAuthorityKind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/captureAuthorityKind/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23446
- if (vErrors === null) {
23447
- vErrors = [err32];
23776
+ var _valid2 = _errs61 === errors;
23777
+ if (_valid2) {
23778
+ valid9 = true;
23779
+ passing1 = 0;
23780
+ var props2 = true;
23781
+ }
23782
+ const _errs68 = errors;
23783
+ if (errors === _errs68) {
23784
+ if (data22 && typeof data22 == "object" && !Array.isArray(data22)) {
23785
+ let missing6;
23786
+ if (data22.kind === void 0 && (missing6 = "kind")) {
23787
+ const err50 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/repositoryContext/oneOf/1/required", keyword: "required", params: { missingProperty: missing6 }, message: "must have required property '" + missing6 + "'" };
23788
+ if (vErrors === null) {
23789
+ vErrors = [err50];
23790
+ } else {
23791
+ vErrors.push(err50);
23792
+ }
23793
+ errors++;
23448
23794
  } else {
23449
- vErrors.push(err32);
23795
+ const _errs70 = errors;
23796
+ for (const key3 in data22) {
23797
+ if (!(key3 === "kind")) {
23798
+ const err51 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/repositoryContext/oneOf/1/additionalProperties", keyword: "additionalProperties", params: { additionalProperty: key3 }, message: "must NOT have additional properties" };
23799
+ if (vErrors === null) {
23800
+ vErrors = [err51];
23801
+ } else {
23802
+ vErrors.push(err51);
23803
+ }
23804
+ errors++;
23805
+ break;
23806
+ }
23807
+ }
23808
+ if (_errs70 === errors) {
23809
+ if (data22.kind !== void 0) {
23810
+ let data25 = data22.kind;
23811
+ if (typeof data25 !== "string") {
23812
+ const err52 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext/kind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/repositoryContext/oneOf/1/properties/kind/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23813
+ if (vErrors === null) {
23814
+ vErrors = [err52];
23815
+ } else {
23816
+ vErrors.push(err52);
23817
+ }
23818
+ errors++;
23819
+ }
23820
+ if ("non_repository" !== data25) {
23821
+ const err53 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext/kind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/repositoryContext/oneOf/1/properties/kind/const", keyword: "const", params: { allowedValue: "non_repository" }, message: "must be equal to constant" };
23822
+ if (vErrors === null) {
23823
+ vErrors = [err53];
23824
+ } else {
23825
+ vErrors.push(err53);
23826
+ }
23827
+ errors++;
23828
+ }
23829
+ }
23830
+ }
23450
23831
  }
23451
- errors++;
23452
- }
23453
- if (!(data19 === "workos" || data19 === "service_token")) {
23454
- const err33 = { instancePath: instancePath + "/batch/" + i0 + "/captureAuthorityKind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/captureAuthorityKind/enum", keyword: "enum", params: { allowedValues: schema93.properties.batch.items.anyOf[1].properties.captureAuthorityKind.enum }, message: "must be equal to one of the allowed values" };
23832
+ } else {
23833
+ const err54 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/repositoryContext/oneOf/1/type", keyword: "type", params: { type: "object" }, message: "must be object" };
23455
23834
  if (vErrors === null) {
23456
- vErrors = [err33];
23835
+ vErrors = [err54];
23457
23836
  } else {
23458
- vErrors.push(err33);
23837
+ vErrors.push(err54);
23459
23838
  }
23460
23839
  errors++;
23461
23840
  }
23462
- var valid5 = _errs47 === errors;
23841
+ }
23842
+ var _valid2 = _errs68 === errors;
23843
+ if (_valid2 && valid9) {
23844
+ valid9 = false;
23845
+ passing1 = [passing1, 1];
23463
23846
  } else {
23464
- var valid5 = true;
23847
+ if (_valid2) {
23848
+ valid9 = true;
23849
+ passing1 = 1;
23850
+ if (props2 !== true) {
23851
+ props2 = true;
23852
+ }
23853
+ }
23465
23854
  }
23466
- if (valid5) {
23467
- if (data1.decisionLifecycleProtocolVersion !== void 0) {
23468
- let data20 = data1.decisionLifecycleProtocolVersion;
23469
- const _errs49 = errors;
23470
- if (!(typeof data20 == "number" && (!(data20 % 1) && !isNaN(data20)) && isFinite(data20))) {
23471
- const err34 = { instancePath: instancePath + "/batch/" + i0 + "/decisionLifecycleProtocolVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/decisionLifecycleProtocolVersion/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
23472
- if (vErrors === null) {
23473
- vErrors = [err34];
23474
- } else {
23475
- vErrors.push(err34);
23476
- }
23477
- errors++;
23855
+ if (!valid9) {
23856
+ const err55 = { instancePath: instancePath + "/batch/" + i0 + "/repositoryContext", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/repositoryContext/oneOf", keyword: "oneOf", params: { passingSchemas: passing1 }, message: "must match exactly one schema in oneOf" };
23857
+ if (vErrors === null) {
23858
+ vErrors = [err55];
23859
+ } else {
23860
+ vErrors.push(err55);
23861
+ }
23862
+ errors++;
23863
+ } else {
23864
+ errors = _errs60;
23865
+ if (vErrors !== null) {
23866
+ if (_errs60) {
23867
+ vErrors.length = _errs60;
23868
+ } else {
23869
+ vErrors = null;
23478
23870
  }
23479
- if (errors === _errs49) {
23480
- if (typeof data20 == "number" && isFinite(data20)) {
23481
- if (data20 > 9007199254740991 || isNaN(data20)) {
23482
- const err35 = { instancePath: instancePath + "/batch/" + i0 + "/decisionLifecycleProtocolVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/decisionLifecycleProtocolVersion/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" };
23871
+ }
23872
+ }
23873
+ var valid8 = _errs59 === errors;
23874
+ } else {
23875
+ var valid8 = true;
23876
+ }
23877
+ if (valid8) {
23878
+ if (data1.capturedOrganizationId !== void 0) {
23879
+ let data26 = data1.capturedOrganizationId;
23880
+ const _errs73 = errors;
23881
+ if (errors === _errs73) {
23882
+ if (typeof data26 === "string") {
23883
+ if (func1(data26) > 128) {
23884
+ const err56 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/capturedOrganizationId/maxLength", keyword: "maxLength", params: { limit: 128 }, message: "must NOT have more than 128 characters" };
23885
+ if (vErrors === null) {
23886
+ vErrors = [err56];
23887
+ } else {
23888
+ vErrors.push(err56);
23889
+ }
23890
+ errors++;
23891
+ } else {
23892
+ if (func1(data26) < 1) {
23893
+ const err57 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/capturedOrganizationId/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
23483
23894
  if (vErrors === null) {
23484
- vErrors = [err35];
23895
+ vErrors = [err57];
23485
23896
  } else {
23486
- vErrors.push(err35);
23897
+ vErrors.push(err57);
23487
23898
  }
23488
23899
  errors++;
23489
23900
  } else {
23490
- if (data20 < 1 || isNaN(data20)) {
23491
- const err36 = { instancePath: instancePath + "/batch/" + i0 + "/decisionLifecycleProtocolVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/decisionLifecycleProtocolVersion/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
23901
+ if (!pattern8.test(data26)) {
23902
+ const err58 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/capturedOrganizationId/pattern", keyword: "pattern", params: { pattern: "^[A-Za-z0-9_-]+$" }, message: 'must match pattern "^[A-Za-z0-9_-]+$"' };
23492
23903
  if (vErrors === null) {
23493
- vErrors = [err36];
23904
+ vErrors = [err58];
23494
23905
  } else {
23495
- vErrors.push(err36);
23906
+ vErrors.push(err58);
23496
23907
  }
23497
23908
  errors++;
23498
23909
  }
23499
23910
  }
23500
23911
  }
23912
+ } else {
23913
+ const err59 = { instancePath: instancePath + "/batch/" + i0 + "/capturedOrganizationId", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/capturedOrganizationId/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23914
+ if (vErrors === null) {
23915
+ vErrors = [err59];
23916
+ } else {
23917
+ vErrors.push(err59);
23918
+ }
23919
+ errors++;
23501
23920
  }
23502
- var valid5 = _errs49 === errors;
23921
+ }
23922
+ var valid8 = _errs73 === errors;
23923
+ } else {
23924
+ var valid8 = true;
23925
+ }
23926
+ if (valid8) {
23927
+ if (data1.captureAuthorityKind !== void 0) {
23928
+ let data27 = data1.captureAuthorityKind;
23929
+ const _errs75 = errors;
23930
+ if (typeof data27 !== "string") {
23931
+ const err60 = { instancePath: instancePath + "/batch/" + i0 + "/captureAuthorityKind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/captureAuthorityKind/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23932
+ if (vErrors === null) {
23933
+ vErrors = [err60];
23934
+ } else {
23935
+ vErrors.push(err60);
23936
+ }
23937
+ errors++;
23938
+ }
23939
+ if (!(data27 === "workos" || data27 === "service_token")) {
23940
+ const err61 = { instancePath: instancePath + "/batch/" + i0 + "/captureAuthorityKind", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/captureAuthorityKind/enum", keyword: "enum", params: { allowedValues: schema93.properties.batch.items.anyOf[1].properties.captureAuthorityKind.enum }, message: "must be equal to one of the allowed values" };
23941
+ if (vErrors === null) {
23942
+ vErrors = [err61];
23943
+ } else {
23944
+ vErrors.push(err61);
23945
+ }
23946
+ errors++;
23947
+ }
23948
+ var valid8 = _errs75 === errors;
23503
23949
  } else {
23504
- var valid5 = true;
23950
+ var valid8 = true;
23505
23951
  }
23506
- if (valid5) {
23507
- if (data1.producer !== void 0) {
23508
- let data21 = data1.producer;
23509
- const _errs51 = errors;
23510
- if (typeof data21 !== "string") {
23511
- const err37 = { instancePath: instancePath + "/batch/" + i0 + "/producer", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/producer/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23952
+ if (valid8) {
23953
+ if (data1.decisionLifecycleProtocolVersion !== void 0) {
23954
+ let data28 = data1.decisionLifecycleProtocolVersion;
23955
+ const _errs77 = errors;
23956
+ if (!(typeof data28 == "number" && (!(data28 % 1) && !isNaN(data28)) && isFinite(data28))) {
23957
+ const err62 = { instancePath: instancePath + "/batch/" + i0 + "/decisionLifecycleProtocolVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/decisionLifecycleProtocolVersion/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
23512
23958
  if (vErrors === null) {
23513
- vErrors = [err37];
23959
+ vErrors = [err62];
23514
23960
  } else {
23515
- vErrors.push(err37);
23961
+ vErrors.push(err62);
23516
23962
  }
23517
23963
  errors++;
23518
23964
  }
23519
- if (!(data21 === "claude_code" || data21 === "codex" || data21 === "cursor" || data21 === "hermes")) {
23520
- const err38 = { instancePath: instancePath + "/batch/" + i0 + "/producer", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/producer/enum", keyword: "enum", params: { allowedValues: schema93.properties.batch.items.anyOf[1].properties.producer.enum }, message: "must be equal to one of the allowed values" };
23521
- if (vErrors === null) {
23522
- vErrors = [err38];
23523
- } else {
23524
- vErrors.push(err38);
23965
+ if (errors === _errs77) {
23966
+ if (typeof data28 == "number" && isFinite(data28)) {
23967
+ if (data28 > 9007199254740991 || isNaN(data28)) {
23968
+ const err63 = { instancePath: instancePath + "/batch/" + i0 + "/decisionLifecycleProtocolVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/decisionLifecycleProtocolVersion/maximum", keyword: "maximum", params: { comparison: "<=", limit: 9007199254740991 }, message: "must be <= 9007199254740991" };
23969
+ if (vErrors === null) {
23970
+ vErrors = [err63];
23971
+ } else {
23972
+ vErrors.push(err63);
23973
+ }
23974
+ errors++;
23975
+ } else {
23976
+ if (data28 < 1 || isNaN(data28)) {
23977
+ const err64 = { instancePath: instancePath + "/batch/" + i0 + "/decisionLifecycleProtocolVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/decisionLifecycleProtocolVersion/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
23978
+ if (vErrors === null) {
23979
+ vErrors = [err64];
23980
+ } else {
23981
+ vErrors.push(err64);
23982
+ }
23983
+ errors++;
23984
+ }
23985
+ }
23525
23986
  }
23526
- errors++;
23527
23987
  }
23528
- var valid5 = _errs51 === errors;
23988
+ var valid8 = _errs77 === errors;
23529
23989
  } else {
23530
- var valid5 = true;
23990
+ var valid8 = true;
23531
23991
  }
23532
- if (valid5) {
23533
- if (data1.toolOutcome !== void 0) {
23534
- let data22 = data1.toolOutcome;
23535
- const _errs53 = errors;
23536
- if (typeof data22 !== "string") {
23537
- const err39 = { instancePath: instancePath + "/batch/" + i0 + "/toolOutcome", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/toolOutcome/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23992
+ if (valid8) {
23993
+ if (data1.producer !== void 0) {
23994
+ let data29 = data1.producer;
23995
+ const _errs79 = errors;
23996
+ if (typeof data29 !== "string") {
23997
+ const err65 = { instancePath: instancePath + "/batch/" + i0 + "/producer", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/producer/type", keyword: "type", params: { type: "string" }, message: "must be string" };
23538
23998
  if (vErrors === null) {
23539
- vErrors = [err39];
23999
+ vErrors = [err65];
23540
24000
  } else {
23541
- vErrors.push(err39);
24001
+ vErrors.push(err65);
23542
24002
  }
23543
24003
  errors++;
23544
24004
  }
23545
- if (!(data22 === "succeeded" || data22 === "returned" || data22 === "failed" || data22 === "interrupted" || data22 === "prevented" || data22 === "unknown")) {
23546
- const err40 = { instancePath: instancePath + "/batch/" + i0 + "/toolOutcome", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/toolOutcome/enum", keyword: "enum", params: { allowedValues: schema93.properties.batch.items.anyOf[1].properties.toolOutcome.enum }, message: "must be equal to one of the allowed values" };
24005
+ if (!(data29 === "claude_code" || data29 === "codex" || data29 === "cursor" || data29 === "hermes")) {
24006
+ const err66 = { instancePath: instancePath + "/batch/" + i0 + "/producer", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/producer/enum", keyword: "enum", params: { allowedValues: schema93.properties.batch.items.anyOf[1].properties.producer.enum }, message: "must be equal to one of the allowed values" };
23547
24007
  if (vErrors === null) {
23548
- vErrors = [err40];
24008
+ vErrors = [err66];
23549
24009
  } else {
23550
- vErrors.push(err40);
24010
+ vErrors.push(err66);
23551
24011
  }
23552
24012
  errors++;
23553
24013
  }
23554
- var valid5 = _errs53 === errors;
24014
+ var valid8 = _errs79 === errors;
23555
24015
  } else {
23556
- var valid5 = true;
24016
+ var valid8 = true;
23557
24017
  }
23558
- if (valid5) {
23559
- if (data1.envelopeVersion !== void 0) {
23560
- let data23 = data1.envelopeVersion;
23561
- const _errs55 = errors;
23562
- if (errors === _errs55) {
23563
- if (typeof data23 == "number" && isFinite(data23)) {
23564
- if (data23 >= 4 || isNaN(data23)) {
23565
- const err41 = { instancePath: instancePath + "/batch/" + i0 + "/envelopeVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/envelopeVersion/exclusiveMaximum", keyword: "exclusiveMaximum", params: { comparison: "<", limit: 4 }, message: "must be < 4" };
24018
+ if (valid8) {
24019
+ if (data1.toolOutcome !== void 0) {
24020
+ let data30 = data1.toolOutcome;
24021
+ const _errs81 = errors;
24022
+ if (typeof data30 !== "string") {
24023
+ const err67 = { instancePath: instancePath + "/batch/" + i0 + "/toolOutcome", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/toolOutcome/type", keyword: "type", params: { type: "string" }, message: "must be string" };
24024
+ if (vErrors === null) {
24025
+ vErrors = [err67];
24026
+ } else {
24027
+ vErrors.push(err67);
24028
+ }
24029
+ errors++;
24030
+ }
24031
+ if (!(data30 === "succeeded" || data30 === "returned" || data30 === "failed" || data30 === "interrupted" || data30 === "prevented" || data30 === "unknown")) {
24032
+ const err68 = { instancePath: instancePath + "/batch/" + i0 + "/toolOutcome", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/toolOutcome/enum", keyword: "enum", params: { allowedValues: schema93.properties.batch.items.anyOf[1].properties.toolOutcome.enum }, message: "must be equal to one of the allowed values" };
24033
+ if (vErrors === null) {
24034
+ vErrors = [err68];
24035
+ } else {
24036
+ vErrors.push(err68);
24037
+ }
24038
+ errors++;
24039
+ }
24040
+ var valid8 = _errs81 === errors;
24041
+ } else {
24042
+ var valid8 = true;
24043
+ }
24044
+ if (valid8) {
24045
+ if (data1.envelopeVersion !== void 0) {
24046
+ let data31 = data1.envelopeVersion;
24047
+ const _errs83 = errors;
24048
+ if (errors === _errs83) {
24049
+ if (typeof data31 == "number" && isFinite(data31)) {
24050
+ if (data31 >= 4 || isNaN(data31)) {
24051
+ const err69 = { instancePath: instancePath + "/batch/" + i0 + "/envelopeVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/envelopeVersion/exclusiveMaximum", keyword: "exclusiveMaximum", params: { comparison: "<", limit: 4 }, message: "must be < 4" };
24052
+ if (vErrors === null) {
24053
+ vErrors = [err69];
24054
+ } else {
24055
+ vErrors.push(err69);
24056
+ }
24057
+ errors++;
24058
+ }
24059
+ } else {
24060
+ const err70 = { instancePath: instancePath + "/batch/" + i0 + "/envelopeVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/envelopeVersion/type", keyword: "type", params: { type: "number" }, message: "must be number" };
23566
24061
  if (vErrors === null) {
23567
- vErrors = [err41];
24062
+ vErrors = [err70];
23568
24063
  } else {
23569
- vErrors.push(err41);
24064
+ vErrors.push(err70);
23570
24065
  }
23571
24066
  errors++;
23572
24067
  }
23573
- } else {
23574
- const err42 = { instancePath: instancePath + "/batch/" + i0 + "/envelopeVersion", schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/properties/envelopeVersion/type", keyword: "type", params: { type: "number" }, message: "must be number" };
23575
- if (vErrors === null) {
23576
- vErrors = [err42];
23577
- } else {
23578
- vErrors.push(err42);
23579
- }
23580
- errors++;
23581
24068
  }
24069
+ var valid8 = _errs83 === errors;
24070
+ } else {
24071
+ var valid8 = true;
23582
24072
  }
23583
- var valid5 = _errs55 === errors;
23584
- } else {
23585
- var valid5 = true;
23586
24073
  }
23587
24074
  }
23588
24075
  }
@@ -23596,28 +24083,28 @@ function validate51(data, { instancePath = "", parentData, parentDataProperty, r
23596
24083
  }
23597
24084
  }
23598
24085
  } else {
23599
- const err43 = { instancePath: instancePath + "/batch/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/type", keyword: "type", params: { type: "object" }, message: "must be object" };
24086
+ const err71 = { instancePath: instancePath + "/batch/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf/1/type", keyword: "type", params: { type: "object" }, message: "must be object" };
23600
24087
  if (vErrors === null) {
23601
- vErrors = [err43];
24088
+ vErrors = [err71];
23602
24089
  } else {
23603
- vErrors.push(err43);
24090
+ vErrors.push(err71);
23604
24091
  }
23605
24092
  errors++;
23606
24093
  }
23607
24094
  }
23608
- var _valid0 = _errs32 === errors;
24095
+ var _valid0 = _errs46 === errors;
23609
24096
  valid3 = valid3 || _valid0;
23610
24097
  if (_valid0) {
23611
- if (props0 !== true) {
23612
- props0 = true;
24098
+ if (props1 !== true) {
24099
+ props1 = true;
23613
24100
  }
23614
24101
  }
23615
24102
  if (!valid3) {
23616
- const err44 = { instancePath: instancePath + "/batch/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
24103
+ const err72 = { instancePath: instancePath + "/batch/" + i0, schemaPath: "https://api.getprimitive.ai/contracts/cli-http-v1.schema.json#/$defs/MoveIngestRequest/properties/batch/items/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
23617
24104
  if (vErrors === null) {
23618
- vErrors = [err44];
24105
+ vErrors = [err72];
23619
24106
  } else {
23620
- vErrors.push(err44);
24107
+ vErrors.push(err72);
23621
24108
  }
23622
24109
  errors++;
23623
24110
  validate51.errors = vErrors;
@@ -27089,8 +27576,59 @@ async function fetchAndCacheCollectScope(cwd, dependencies = defaultDependencies
27089
27576
  return dependencies.writeCached(cwd, response);
27090
27577
  }
27091
27578
 
27092
- // src/lib/post-commit-hook.ts
27579
+ // src/lib/commit-heartbeat.ts
27093
27580
  import { execFileSync as execFileSync3 } from "child_process";
27581
+ import { mkdirSync as mkdirSync7, readFileSync as readFileSync11, readdirSync as readdirSync4, unlinkSync as unlinkSync2 } from "fs";
27582
+ import { dirname as dirname10, join as join15, resolve as resolve6 } from "path";
27583
+ var WIRED_PATH = "prim/git-hooks-wired";
27584
+ var GIT_TIMEOUT_MS3 = 1e3;
27585
+ var MAX_STAMP_BYTES = 1024;
27586
+ function commonPath(cwd, relative4) {
27587
+ const value = execFileSync3("git", ["rev-parse", "--git-common-dir"], {
27588
+ cwd,
27589
+ encoding: "utf8",
27590
+ stdio: ["ignore", "pipe", "ignore"],
27591
+ timeout: GIT_TIMEOUT_MS3
27592
+ }).replace(/\r?\n$/u, "");
27593
+ if (value === "" || /[\0\r\n]/u.test(value)) throw new Error("Git returned an unsafe path");
27594
+ return join15(resolve6(cwd, value), relative4);
27595
+ }
27596
+ function ensurePrivateParent(path) {
27597
+ mkdirSync7(dirname10(dirname10(path)), { recursive: true, mode: 448 });
27598
+ mkdirSync7(dirname10(path), { recursive: true, mode: 448 });
27599
+ }
27600
+ function writeStamp(path, at) {
27601
+ ensurePrivateParent(path);
27602
+ atomicWriteFile(path, `${JSON.stringify({ at })}
27603
+ `, { mode: 384 });
27604
+ }
27605
+ function readStampAt(path) {
27606
+ try {
27607
+ const raw = readFileSync11(path, "utf8");
27608
+ if (raw.length > MAX_STAMP_BYTES) return void 0;
27609
+ const parsed = JSON.parse(raw);
27610
+ return typeof parsed.at === "number" && Number.isSafeInteger(parsed.at) && parsed.at > 0 ? parsed.at : void 0;
27611
+ } catch {
27612
+ return void 0;
27613
+ }
27614
+ }
27615
+ function recordHooksWired(cwd, options = {}) {
27616
+ try {
27617
+ const path = commonPath(cwd, WIRED_PATH);
27618
+ if (options.onlyIfAbsent && readStampAt(path) !== void 0) return;
27619
+ writeStamp(path, options.now ?? Date.now());
27620
+ } catch {
27621
+ }
27622
+ }
27623
+ function clearHooksWired(cwd) {
27624
+ try {
27625
+ unlinkSync2(commonPath(cwd, WIRED_PATH));
27626
+ } catch {
27627
+ }
27628
+ }
27629
+
27630
+ // src/lib/git-hooks.ts
27631
+ import { execFileSync as execFileSync4 } from "child_process";
27094
27632
  import { createHash as createHash8, randomUUID as randomUUID2 } from "crypto";
27095
27633
  import {
27096
27634
  constants as constants5,
@@ -27099,50 +27637,28 @@ import {
27099
27637
  fchmodSync as fchmodSync2,
27100
27638
  fsyncSync as fsyncSync2,
27101
27639
  lstatSync as lstatSync5,
27102
- mkdirSync as mkdirSync7,
27640
+ mkdirSync as mkdirSync8,
27103
27641
  openSync as openSync4,
27104
- readFileSync as readFileSync11,
27642
+ readFileSync as readFileSync12,
27643
+ realpathSync as realpathSync4,
27105
27644
  renameSync as renameSync3,
27106
- unlinkSync as unlinkSync2,
27645
+ unlinkSync as unlinkSync3,
27107
27646
  writeFileSync as writeFileSync4
27108
27647
  } from "fs";
27109
- import { basename as basename2, dirname as dirname10, isAbsolute as isAbsolute7, resolve as resolve6 } from "path";
27110
- var PRIM_POST_COMMIT_BLOCK_START = "# >>> prim post-commit hook >>>";
27111
- var PRIM_POST_COMMIT_BLOCK_END = "# <<< prim post-commit hook <<<";
27112
- var PRIM_CREATED_MARK = "prim-created-post-commit-hook";
27113
- var PRIM_POST_REWRITE_BLOCK_START = "# >>> prim post-rewrite hook >>>";
27114
- var PRIM_POST_REWRITE_BLOCK_END = "# <<< prim post-rewrite hook <<<";
27115
- var PRIM_POST_REWRITE_CREATED_MARK = "prim-created-post-rewrite-hook";
27116
- var LEGACY_PRIM_CREATED_MARK = "prim-created-hook";
27117
- var LEGACY_PRIM_OWNED_HEADER = "# prim post-commit hook \u2014 installed by: prim hooks install (prim-managed-hook)";
27118
- var LEGACY_GLOBAL_OWNED_HEADER = "# prim global post-commit hook (core.hooksPath) \u2014 managed by prim; do not edit.";
27119
- var MAX_HOOK_BYTES = 1048576;
27120
- var GIT_TIMEOUT_MS3 = 1e3;
27121
- var SUPPORTED_SHEBANGS = /* @__PURE__ */ new Set([
27122
- "#!/bin/sh",
27123
- "#!/usr/bin/env sh",
27124
- "#!/bin/bash",
27125
- "#!/usr/bin/env bash",
27126
- "#!/bin/zsh",
27127
- "#!/usr/bin/env zsh"
27128
- ]);
27129
- var HUSKY_V9_DISPATCHERS = /* @__PURE__ */ new Set([
27130
- '#!/usr/bin/env sh\n. "${0%/*}/h"',
27131
- '#!/usr/bin/env sh\n. "$(dirname "$0")/h"'
27132
- ]);
27133
- var HUSKY_DIRECT_DISPATCHER = '#!/bin/sh\nexec sh "$(dirname "$0")/../post-commit"\n';
27134
- var HUSKY_V9_RUNTIME_HASHES = /* @__PURE__ */ new Set([
27135
- "d6aaa6f3f7c11008c525e649161df4a93152f1e55d0887fa1d7b8d622735d380",
27136
- "b02cb91cab7125a9e906be723a1b85297fc435a8307d429ae845546b4ee0ecde",
27137
- "9db5d129c4eb822a773157d98cd8fb8f1b156b85e3193117fefe527ca6d45e91",
27138
- "3b2cb21335e544b4ebce658ca47af4a69d2c77026cc4d3f8b2227c34d062b207",
27139
- "548990e1c11285694096184993d907b258d41235461a7ca2551e3b53ff9d3a38",
27140
- "c029a943acea5d6e2ddbaa271a1fb22c2da55d56b5c6fb59ca804ac9a4018708",
27141
- "ae3413a8fe2b39372de48bdc9691f42055f089c0c7529834b2fb07a131585b6a",
27142
- "70200b200ca709b0622784f93839a5b2872333a917a09afddefd7dc2d8cdc680"
27143
- ]);
27144
- function currentPostCommitBlock() {
27145
- return `${PRIM_POST_COMMIT_BLOCK_START}
27648
+ import { basename as basename2, dirname as dirname11, isAbsolute as isAbsolute8, join as join16, relative as relative3, resolve as resolve7, sep as sep3 } from "path";
27649
+
27650
+ // src/lib/git-hook-legacy.ts
27651
+ import { isAbsolute as isAbsolute7 } from "path";
27652
+ var PRIM_MANAGED_MARK = "prim-managed-hook";
27653
+ var PRE_COMMIT = { hookName: "pre-commit", binName: "prim-pre-commit" };
27654
+ function blockMarkers2(spec) {
27655
+ return {
27656
+ start: `# >>> prim ${spec.hookName} hook >>>`,
27657
+ end: `# <<< prim ${spec.hookName} hook <<<`
27658
+ };
27659
+ }
27660
+ function legacyPostCommitBlock() {
27661
+ return `# >>> prim post-commit hook >>>
27146
27662
  if [ "$(git config --get prim.active 2>/dev/null)" = "true" ]; then
27147
27663
  prim_commit_sha=$(git rev-parse --verify HEAD 2>/dev/null) || prim_commit_sha=
27148
27664
  case "$prim_commit_sha" in *[!0-9a-f]*|"") prim_commit_sha= ;; esac
@@ -27171,13 +27687,10 @@ if [ "$(git config --get prim.active 2>/dev/null)" = "true" ]; then
27171
27687
  fi
27172
27688
  unset prim_commit_sha
27173
27689
  fi
27174
- ${PRIM_POST_COMMIT_BLOCK_END}`;
27690
+ # <<< prim post-commit hook <<<`;
27175
27691
  }
27176
- function postCommitHookBlock() {
27177
- return currentPostCommitBlock();
27178
- }
27179
- function postRewriteHookBlock() {
27180
- return `${PRIM_POST_REWRITE_BLOCK_START}
27692
+ function legacyPostRewriteBlock() {
27693
+ return `# >>> prim post-rewrite hook >>>
27181
27694
  if [ "$(git config --get prim.active 2>/dev/null)" = "true" ]; then
27182
27695
  case "$1" in amend|rebase) prim_rewrite_source="$1" ;; *) prim_rewrite_source= ;; esac
27183
27696
  if [ -n "$prim_rewrite_source" ]; then
@@ -27216,22 +27729,159 @@ if [ "$(git config --get prim.active 2>/dev/null)" = "true" ]; then
27216
27729
  fi
27217
27730
  unset prim_rewrite_source
27218
27731
  fi
27219
- ${PRIM_POST_REWRITE_BLOCK_END}`;
27220
- }
27221
- var POST_COMMIT_MANAGED_HOOK = {
27222
- hookName: "post-commit",
27223
- blockStart: PRIM_POST_COMMIT_BLOCK_START,
27224
- blockEnd: PRIM_POST_COMMIT_BLOCK_END,
27225
- createdMark: PRIM_CREATED_MARK,
27226
- block: postCommitHookBlock
27227
- };
27228
- var POST_REWRITE_MANAGED_HOOK = {
27229
- hookName: "post-rewrite",
27230
- blockStart: PRIM_POST_REWRITE_BLOCK_START,
27231
- blockEnd: PRIM_POST_REWRITE_BLOCK_END,
27232
- createdMark: PRIM_POST_REWRITE_CREATED_MARK,
27233
- block: postRewriteHookBlock
27732
+ # <<< prim post-rewrite hook <<<`;
27733
+ }
27734
+ var PRE_COMMIT_GATE = 'if [ "$(git config --get prim.active 2>/dev/null)" = "true" ]; then';
27735
+ function preCommitLadder(fallback, failSoft) {
27736
+ const soft = failSoft ? " || true" : "";
27737
+ return `if command -v prim-pre-commit >/dev/null 2>&1; then
27738
+ prim-pre-commit${soft}
27739
+ elif [ -f "./node_modules/.bin/prim-pre-commit" ]; then
27740
+ ./node_modules/.bin/prim-pre-commit${soft}
27741
+ else
27742
+ ${fallback} 2>/dev/null || true
27743
+ fi`;
27744
+ }
27745
+ var LADDER_ALPHA_2 = preCommitLadder("npx --yes @primitive.ai/prim pre-commit-hook", false);
27746
+ var LADDER_ALPHA_9 = preCommitLadder("npx --yes -p @primitive.ai/prim prim-pre-commit", false);
27747
+ var LADDER_ALPHA_35 = preCommitLadder("npx --yes -p @primitive.ai/prim prim-pre-commit", true);
27748
+ var PINNED_NPX_PRE_COMMIT = String.raw`npx --yes(?: --ignore-scripts)? -p @primitive\.ai/prim@[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)? prim-pre-commit`;
27749
+ var PINNED_PRE_COMMIT_RE = new RegExp(
27750
+ String.raw`^\{ (?:${PINNED_NPX_PRE_COMMIT}|if \[ -x (?<node>'.*') \] && \[ -f (?<entry>'.*') \]; then \k<node> \k<entry>; else ${PINNED_NPX_PRE_COMMIT}; fi); \} \|\| true$`,
27751
+ "u"
27752
+ );
27753
+ var SHELL_QUOTED_RE = /^'(?:[^']|'"'"')*'$/u;
27754
+ function decodePinnedPath(token) {
27755
+ if (!token || !SHELL_QUOTED_RE.test(token)) return void 0;
27756
+ const value = token.slice(1, -1).replaceAll(`'"'"'`, "'");
27757
+ if (!isAbsolute7(value) || value.includes("\0") || value.includes("\n") || value.includes("\r")) {
27758
+ return void 0;
27759
+ }
27760
+ return value;
27761
+ }
27762
+ function isPinnedPreCommitInvocation(line) {
27763
+ const match = PINNED_PRE_COMMIT_RE.exec(line);
27764
+ if (!match) return false;
27765
+ if (match.groups?.node === void 0) return true;
27766
+ return Boolean(
27767
+ decodePinnedPath(match.groups.node) && decodePinnedPath(match.groups.entry)?.endsWith("/dist/hooks/pre-commit.js")
27768
+ );
27769
+ }
27770
+ function isLegacyPreCommitBody(body) {
27771
+ if (body === LADDER_ALPHA_2 || body === LADDER_ALPHA_9 || body === LADDER_ALPHA_35) return true;
27772
+ if (isPinnedPreCommitInvocation(body)) return true;
27773
+ const prefix = `${PRE_COMMIT_GATE}
27774
+ `;
27775
+ if (!body.startsWith(prefix) || !body.endsWith("\nfi")) return false;
27776
+ const inner = body.slice(prefix.length, -"\nfi".length);
27777
+ return inner === LADDER_ALPHA_35 || isPinnedPreCommitInvocation(inner);
27778
+ }
27779
+ function isLegacyOwnedPreCommitScript(content) {
27780
+ const original = (ladder) => `#!/bin/sh
27781
+ # prim pre-commit hook \u2014 auto-syncs affected specs on commit
27782
+ # Installed by: prim hooks install
27783
+
27784
+ # Find the nearest node_modules/.bin with prim, or use npx
27785
+ ${ladder}
27786
+ `;
27787
+ if (content === original(LADDER_ALPHA_2) || content === original(LADDER_ALPHA_9)) return true;
27788
+ if (content === `#!/bin/sh
27789
+ # prim pre-commit hook \u2014 installed by: prim hooks install
27790
+
27791
+ ${LADDER_ALPHA_9}
27792
+ `) {
27793
+ return true;
27794
+ }
27795
+ const prefix = `#!/bin/sh
27796
+ # prim pre-commit hook \u2014 installed by: prim hooks install (${PRIM_MANAGED_MARK})
27797
+
27798
+ `;
27799
+ if (!content.startsWith(prefix) || !content.endsWith("\n")) return false;
27800
+ const body = content.slice(prefix.length, -1);
27801
+ return body === LADDER_ALPHA_35 || isPinnedPreCommitInvocation(body);
27802
+ }
27803
+ var PINNED_PACKAGE_VERSION_RE = /@primitive\.ai\/prim@[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?/gu;
27804
+ function legacyInlineHookBlock(hookName) {
27805
+ return hookName === "post-commit" ? legacyPostCommitBlock() : legacyPostRewriteBlock();
27806
+ }
27807
+ function isRecognizedLegacyBlock(hookName, block) {
27808
+ if (hookName === "pre-commit") {
27809
+ const { start, end } = blockMarkers2(PRE_COMMIT);
27810
+ const prefix = `${start}
27811
+ `;
27812
+ const suffix = `
27813
+ ${end}`;
27814
+ if (!block.startsWith(prefix) || !block.endsWith(suffix)) return false;
27815
+ return isLegacyPreCommitBody(block.slice(prefix.length, -suffix.length));
27816
+ }
27817
+ const expected = legacyInlineHookBlock(hookName);
27818
+ const normalize2 = (text) => text.replace(PINNED_PACKAGE_VERSION_RE, "@primitive.ai/prim@<version>");
27819
+ return normalize2(block) === normalize2(expected);
27820
+ }
27821
+
27822
+ // src/lib/git-hooks.ts
27823
+ var LEGACY_PRIM_CREATED_MARK = "prim-created-hook";
27824
+ var LEGACY_PRIM_OWNED_HEADER = "# prim post-commit hook \u2014 installed by: prim hooks install (prim-managed-hook)";
27825
+ var LEGACY_GLOBAL_OWNED_HEADER = "# prim global post-commit hook (core.hooksPath) \u2014 managed by prim; do not edit.";
27826
+ var MAX_HOOK_BYTES = 1048576;
27827
+ var GIT_TIMEOUT_MS4 = 1e3;
27828
+ var SUPPORTED_SHEBANGS = /* @__PURE__ */ new Set([
27829
+ "#!/bin/sh",
27830
+ "#!/usr/bin/env sh",
27831
+ "#!/bin/bash",
27832
+ "#!/usr/bin/env bash",
27833
+ "#!/bin/zsh",
27834
+ "#!/usr/bin/env zsh"
27835
+ ]);
27836
+ var HUSKY_V9_DISPATCHERS = /* @__PURE__ */ new Set([
27837
+ '#!/usr/bin/env sh\n. "${0%/*}/h"',
27838
+ '#!/usr/bin/env sh\n. "$(dirname "$0")/h"'
27839
+ ]);
27840
+ var HUSKY_DIRECT_DISPATCHER = '#!/bin/sh\nexec sh "$(dirname "$0")/../post-commit"\n';
27841
+ var HUSKY_V9_RUNTIME_HASHES = /* @__PURE__ */ new Set([
27842
+ "d6aaa6f3f7c11008c525e649161df4a93152f1e55d0887fa1d7b8d622735d380",
27843
+ "b02cb91cab7125a9e906be723a1b85297fc435a8307d429ae845546b4ee0ecde",
27844
+ "9db5d129c4eb822a773157d98cd8fb8f1b156b85e3193117fefe527ca6d45e91",
27845
+ "3b2cb21335e544b4ebce658ca47af4a69d2c77026cc4d3f8b2227c34d062b207",
27846
+ "548990e1c11285694096184993d907b258d41235461a7ca2551e3b53ff9d3a38",
27847
+ "c029a943acea5d6e2ddbaa271a1fb22c2da55d56b5c6fb59ca804ac9a4018708",
27848
+ "ae3413a8fe2b39372de48bdc9691f42055f089c0c7529834b2fb07a131585b6a",
27849
+ "70200b200ca709b0622784f93839a5b2872333a917a09afddefd7dc2d8cdc680"
27850
+ ]);
27851
+ function managedHookSpecFor(hookName) {
27852
+ const { start, end } = blockMarkers(hookName);
27853
+ return {
27854
+ hookName,
27855
+ blockStart: start,
27856
+ blockEnd: end,
27857
+ createdMark: `prim-created-${hookName}-hook`
27858
+ };
27859
+ }
27860
+ var MANAGED_HOOK_SPECS = {
27861
+ "pre-commit": managedHookSpecFor("pre-commit"),
27862
+ "post-commit": managedHookSpecFor("post-commit"),
27863
+ "post-rewrite": managedHookSpecFor("post-rewrite")
27234
27864
  };
27865
+ function managedHookSpec(hookName) {
27866
+ return MANAGED_HOOK_SPECS[hookName];
27867
+ }
27868
+ function gitHooksMode(options = {}) {
27869
+ try {
27870
+ const value = execFileSync4(
27871
+ "git",
27872
+ ["config", ...options.global ? ["--global"] : [], "--get", "prim.gitHooks"],
27873
+ {
27874
+ cwd: options.cwd,
27875
+ encoding: "utf8",
27876
+ stdio: ["ignore", "pipe", "ignore"],
27877
+ timeout: GIT_TIMEOUT_MS4
27878
+ }
27879
+ ).trim();
27880
+ return value === "manual" ? "manual" : "auto";
27881
+ } catch {
27882
+ return "auto";
27883
+ }
27884
+ }
27235
27885
  function legacyFloatingInvocation() {
27236
27886
  return `if command -v prim-post-commit >/dev/null 2>&1; then
27237
27887
  prim-post-commit || true
@@ -27248,15 +27898,6 @@ fi
27248
27898
  `);
27249
27899
  }
27250
27900
  var PINNED_INVOCATION_RE = /^\{ if \[ -x (?<node>'.*') \] && \[ -f (?<entry>'.*') \]; then \k<node> \k<entry>; else npx --yes -p @primitive\.ai\/prim@(?<version>[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?) prim-post-commit; fi; \} \|\| true$/u;
27251
- var SHELL_QUOTED_RE = /^'(?:[^']|'"'"')*'$/u;
27252
- function decodePinnedPath(token) {
27253
- if (!token || !SHELL_QUOTED_RE.test(token)) return void 0;
27254
- const value = token.slice(1, -1).replaceAll(`'"'"'`, "'");
27255
- if (!isAbsolute7(value) || value.includes("\0") || value.includes("\n") || value.includes("\r")) {
27256
- return void 0;
27257
- }
27258
- return value;
27259
- }
27260
27901
  function isPinnedInvocation(value) {
27261
27902
  const match = PINNED_INVOCATION_RE.exec(value);
27262
27903
  const node = decodePinnedPath(match?.groups?.node);
@@ -27289,48 +27930,122 @@ function isKnownLegacyGlobalGate(value) {
27289
27930
  }
27290
27931
  function createdScaffold(spec) {
27291
27932
  return Buffer.from(`#!/bin/sh
27292
- ${spec.block()}
27933
+ ${managedHookBlock(spec.hookName)}
27293
27934
  # ${spec.createdMark}
27294
27935
  `);
27295
27936
  }
27937
+ function oldCreatedPrefixes(spec) {
27938
+ return [
27939
+ Buffer.from(`#!/bin/sh
27940
+ # ${spec.createdMark}
27941
+
27942
+ `),
27943
+ Buffer.from(`#!/bin/sh
27944
+ # ${LEGACY_PRIM_CREATED_MARK}
27945
+
27946
+ `)
27947
+ ];
27948
+ }
27949
+ function isOwnedStandalonePreCommit(content) {
27950
+ return content === "#!/bin/sh\nprim-pre-commit\n" || isLegacyOwnedPreCommitScript(content);
27951
+ }
27952
+ function realpathLoose(path) {
27953
+ const missing = [];
27954
+ let current = resolve7(path);
27955
+ for (; ; ) {
27956
+ try {
27957
+ return join16(realpathSync4.native(current), ...missing);
27958
+ } catch {
27959
+ const parent = dirname11(current);
27960
+ if (parent === current) return resolve7(path);
27961
+ missing.unshift(basename2(current));
27962
+ current = parent;
27963
+ }
27964
+ }
27965
+ }
27966
+ function isWithin(path, directory) {
27967
+ const rel = relative3(directory, path);
27968
+ return rel === "" || !isAbsolute8(rel) && rel !== ".." && !rel.startsWith(`..${sep3}`);
27969
+ }
27970
+ function primGitHooksDirectory() {
27971
+ try {
27972
+ return join16(primConfigDirectory(), "git-hooks");
27973
+ } catch {
27974
+ return void 0;
27975
+ }
27976
+ }
27977
+ function otherWorktreeRoots(gitRoot) {
27978
+ try {
27979
+ const self = realpathLoose(gitRoot);
27980
+ return execFileSync4("git", ["worktree", "list", "--porcelain"], {
27981
+ cwd: gitRoot,
27982
+ encoding: "utf8",
27983
+ stdio: ["ignore", "pipe", "ignore"],
27984
+ timeout: GIT_TIMEOUT_MS4
27985
+ }).split("\n").flatMap((line) => line.startsWith("worktree ") ? [realpathLoose(line.slice(9))] : []).filter((root) => root !== self);
27986
+ } catch {
27987
+ return [];
27988
+ }
27989
+ }
27990
+ function hookLocation(hookPath, dirs) {
27991
+ const path = realpathLoose(hookPath);
27992
+ if (isWithin(path, realpathLoose(dirs.gitDir)) || isWithin(path, realpathLoose(dirs.commonDir))) {
27993
+ return "repository";
27994
+ }
27995
+ const primDir = primGitHooksDirectory();
27996
+ if (primDir !== void 0 && isWithin(path, realpathLoose(primDir))) return "prim";
27997
+ const root = realpathLoose(dirs.gitRoot);
27998
+ if (!isWithin(path, root)) return "external";
27999
+ const nested = otherWorktreeRoots(dirs.gitRoot).filter((other) => isWithin(other, root));
28000
+ return nested.some((other) => isWithin(path, other)) ? "external" : "worktree";
28001
+ }
27296
28002
  function safeGitPath(root, value) {
27297
28003
  if (value.length === 0 || value !== value.trim() || value.includes("\0") || value.includes("\n") || value.includes("\r")) {
27298
28004
  throw new Error("Git returned an unsafe hooks path");
27299
28005
  }
27300
- return isAbsolute7(value) ? resolve6(value) : resolve6(root, value);
28006
+ return isAbsolute8(value) ? resolve7(value) : resolve7(root, value);
27301
28007
  }
27302
- function resolveEffectiveManagedHook(spec, cwd = process.cwd()) {
28008
+ function resolveEffectiveGitHook(hookName, cwd = process.cwd()) {
27303
28009
  const gitRoot = gitToplevel(cwd);
27304
28010
  if (!gitRoot) throw new Error("not a git repository");
27305
- const value = execFileSync3("git", ["rev-parse", "--git-path", "hooks"], {
27306
- cwd: gitRoot,
27307
- encoding: "utf8",
27308
- stdio: ["ignore", "pipe", "ignore"],
27309
- timeout: GIT_TIMEOUT_MS3
27310
- }).replace(/\r?\n$/u, "");
27311
- const hooksDir = safeGitPath(gitRoot, value);
27312
- if (basename2(hooksDir) === "_" && basename2(dirname10(hooksDir)) === ".husky") {
28011
+ const lines = execFileSync4(
28012
+ "git",
28013
+ ["rev-parse", "--git-path", "hooks", "--absolute-git-dir", "--git-common-dir"],
28014
+ {
28015
+ cwd: gitRoot,
28016
+ encoding: "utf8",
28017
+ stdio: ["ignore", "pipe", "ignore"],
28018
+ timeout: GIT_TIMEOUT_MS4
28019
+ }
28020
+ ).replace(/\r?\n$/u, "").split(/\r?\n/u);
28021
+ if (lines.length !== 3) throw new Error("Git returned unexpected repository paths");
28022
+ const [hooksValue, gitDirValue, commonDirValue] = lines;
28023
+ const hooksDir = safeGitPath(gitRoot, hooksValue);
28024
+ const dirs = {
28025
+ gitRoot,
28026
+ gitDir: safeGitPath(gitRoot, gitDirValue),
28027
+ commonDir: safeGitPath(gitRoot, commonDirValue)
28028
+ };
28029
+ if (basename2(hooksDir) === "_" && basename2(dirname11(hooksDir)) === ".husky") {
28030
+ const hookPath2 = resolve7(dirname11(hooksDir), hookName);
27313
28031
  return {
27314
28032
  gitRoot,
27315
28033
  hooksDir,
27316
- hookPath: resolve6(dirname10(hooksDir), spec.hookName),
28034
+ hookPath: hookPath2,
27317
28035
  kind: "husky_v9",
27318
- dispatcherPath: resolve6(hooksDir, spec.hookName)
28036
+ dispatcherPath: resolve7(hooksDir, hookName),
28037
+ location: hookLocation(hookPath2, dirs)
27319
28038
  };
27320
28039
  }
28040
+ const hookPath = resolve7(hooksDir, hookName);
27321
28041
  return {
27322
28042
  gitRoot,
27323
28043
  hooksDir,
27324
- hookPath: resolve6(hooksDir, spec.hookName),
27325
- kind: "direct"
28044
+ hookPath,
28045
+ kind: "direct",
28046
+ location: hookLocation(hookPath, dirs)
27326
28047
  };
27327
28048
  }
27328
- function resolveEffectivePostCommitHook(cwd = process.cwd()) {
27329
- return resolveEffectiveManagedHook(POST_COMMIT_MANAGED_HOOK, cwd);
27330
- }
27331
- function resolveEffectivePostRewriteHook(cwd = process.cwd()) {
27332
- return resolveEffectiveManagedHook(POST_REWRITE_MANAGED_HOOK, cwd);
27333
- }
27334
28049
  function assertSafeFile(path, spec) {
27335
28050
  if (!existsSync10(path)) return void 0;
27336
28051
  const stat = lstatSync5(path);
@@ -27354,7 +28069,7 @@ function assertUsableHuskyDispatcher(target, spec) {
27354
28069
  if (!HUSKY_V9_DISPATCHERS.has(normalizedDispatcher)) {
27355
28070
  throw new Error(`unrecognized Husky ${spec.hookName} dispatcher: ${target.dispatcherPath}`);
27356
28071
  }
27357
- const huskyRuntime = resolve6(dirname10(target.dispatcherPath), "h");
28072
+ const huskyRuntime = resolve7(dirname11(target.dispatcherPath), "h");
27358
28073
  const runtimeStat = assertSafeFile(huskyRuntime, spec);
27359
28074
  const runtime = runtimeStat ? readHookFile(huskyRuntime) : void 0;
27360
28075
  const runtimeHash = runtime ? createHash8("sha256").update(runtime).digest("hex") : void 0;
@@ -27363,7 +28078,7 @@ function assertUsableHuskyDispatcher(target, spec) {
27363
28078
  }
27364
28079
  }
27365
28080
  function readHookFile(path) {
27366
- const value = readFileSync11(path);
28081
+ const value = readFileSync12(path);
27367
28082
  return Buffer.isBuffer(value) ? value : Buffer.from(value);
27368
28083
  }
27369
28084
  function decodeHookText(content, spec) {
@@ -27412,16 +28127,107 @@ function blockRange(content, spec) {
27412
28127
  }
27413
28128
  const start = starts[0];
27414
28129
  const end = ends[0] + endMarker.length;
27415
- const current = Buffer.from(spec.block());
27416
- return content.subarray(start, end).equals(current) ? { kind: "current", start, end } : { kind: "stale", start, end };
28130
+ const text = content.subarray(start, end).toString("utf8");
28131
+ if (canonicalHookBlock(text) === canonicalHookBlock(managedHookBlock(spec.hookName))) {
28132
+ return { kind: "current", start, end };
28133
+ }
28134
+ const version = hookBlockContractVersion(text);
28135
+ if (version !== void 0 && version > GIT_HOOK_CONTRACT_VERSION) {
28136
+ return { kind: "newer", start, end };
28137
+ }
28138
+ return { kind: "stale", start, end };
28139
+ }
28140
+ var HUSKY_V8_SOURCE_RE = /^\.[ \t]+"\$\(dirname(?:[ \t]+--)?[ \t]+"\$0"\)\/_\/husky\.sh"[ \t]*$/mu;
28141
+ function blockInsertionPoint(content, allowShebangless, spec, huskyV8) {
28142
+ const shebangEnd = shellInsertionPoint(content, allowShebangless, spec);
28143
+ if (!huskyV8) return shebangEnd;
28144
+ const rest = content.subarray(shebangEnd).toString("utf8");
28145
+ const match = HUSKY_V8_SOURCE_RE.exec(rest);
28146
+ if (!match) return shebangEnd;
28147
+ const lineEnd = match.index + match[0].length;
28148
+ const afterLine = rest[lineEnd] === "\n" ? lineEnd + 1 : lineEnd;
28149
+ return shebangEnd + Buffer.byteLength(rest.slice(0, afterLine), "utf8");
28150
+ }
28151
+ var HUSKY_SPEC_MAJOR_RE = /^\s*[~^]?=?\s*v?([0-9]+)(?:\.(?:[0-9]+|[xX*])){0,2}(?:-[0-9A-Za-z.-]+)?\s*$/u;
28152
+ function declaredHuskyMajor(dir) {
28153
+ for (let current = resolve7(dir); ; ) {
28154
+ const manifest = join16(current, "package.json");
28155
+ if (existsSync10(manifest)) {
28156
+ try {
28157
+ if (lstatSync5(manifest).size > MAX_HOOK_BYTES) return void 0;
28158
+ const parsed = JSON.parse(readFileSync12(manifest, "utf8"));
28159
+ const range = parsed.devDependencies?.husky ?? parsed.dependencies?.husky;
28160
+ const major = typeof range === "string" ? HUSKY_SPEC_MAJOR_RE.exec(range)?.[1] : void 0;
28161
+ return major === void 0 ? void 0 : Number(major);
28162
+ } catch {
28163
+ return void 0;
28164
+ }
28165
+ }
28166
+ const parent = dirname11(current);
28167
+ if (parent === current || existsSync10(join16(current, ".git"))) return void 0;
28168
+ current = parent;
28169
+ }
27417
28170
  }
27418
- function mergedContent(existing, allowShebangless, spec) {
27419
- const block = Buffer.from(spec.block());
27420
- if (!existing) {
28171
+ function isHuskyV8Hook(hookPath) {
28172
+ const runtime = join16(dirname11(hookPath), "_", "husky.sh");
28173
+ try {
28174
+ const stat = lstatSync5(runtime);
28175
+ return stat.isFile() && stat.size <= MAX_HOOK_BYTES && readFileSync12(runtime, "utf8").includes("husky_skip_init");
28176
+ } catch (error) {
28177
+ if (errorCode(error) !== "ENOENT") return false;
28178
+ }
28179
+ const major = declaredHuskyMajor(dirname11(dirname11(hookPath)));
28180
+ return major !== void 0 && major <= 8;
28181
+ }
28182
+ var TERMINAL_LINE_RE = /^(?:exit|return)(?:\s|;|$)/u;
28183
+ var REDIRECT_OPERATOR_RE = /^[0-9]*(?:<<?|>>?|<&|>&|<>|>\|)$/u;
28184
+ var REDIRECT_WORD_RE = /^[0-9]*(?:<|>)/u;
28185
+ function isReplacingExec(line) {
28186
+ if (!/^exec(?:\s|$)/u.test(line)) return false;
28187
+ const words = line.slice(4).trim().split(/\s+/u).filter(Boolean);
28188
+ for (let index = 0; index < words.length; index += 1) {
28189
+ const word = words[index];
28190
+ if (word.startsWith("#")) break;
28191
+ if (REDIRECT_OPERATOR_RE.test(word)) {
28192
+ index += 1;
28193
+ continue;
28194
+ }
28195
+ if (!REDIRECT_WORD_RE.test(word)) return true;
28196
+ }
28197
+ return false;
28198
+ }
28199
+ function terminatesBefore(content, from, offset) {
28200
+ const lines = content.subarray(from, offset).toString("utf8").split("\n");
28201
+ return lines.some((line) => TERMINAL_LINE_RE.test(line) || isReplacingExec(line));
28202
+ }
28203
+ function mayTerminateBefore(content, from, offset) {
28204
+ return content.subarray(from, offset).toString("utf8").split(/\n|;|&&|\|\||\||[{()]|\b(?:then|do|else)\b/u).some((part) => {
28205
+ const command = part.trim();
28206
+ return TERMINAL_LINE_RE.test(command) || isReplacingExec(command);
28207
+ });
28208
+ }
28209
+ function withoutRange(content, start, end) {
28210
+ const suffix = content.subarray(end);
28211
+ return Buffer.concat([
28212
+ content.subarray(0, start),
28213
+ suffix.at(0) === 10 ? suffix.subarray(1) : suffix
28214
+ ]);
28215
+ }
28216
+ function insertBlock(content, at, spec) {
28217
+ return Buffer.concat([
28218
+ content.subarray(0, at),
28219
+ Buffer.from(managedHookBlock(spec.hookName)),
28220
+ Buffer.from("\n"),
28221
+ content.subarray(at)
28222
+ ]);
28223
+ }
28224
+ function migratedLegacyContent(existing, allowShebangless, spec, huskyV8) {
28225
+ const text = existing.toString("utf8");
28226
+ if (spec.hookName === "pre-commit" && isOwnedStandalonePreCommit(text)) {
27421
28227
  return createdScaffold(spec);
27422
28228
  }
27423
- const range = blockRange(existing, spec);
27424
- if (spec.hookName === POST_COMMIT_MANAGED_HOOK.hookName && range.kind === "absent" && existing.toString("utf8").startsWith(`#!/bin/sh
28229
+ if (spec.hookName !== "post-commit") return void 0;
28230
+ if (text.startsWith(`#!/bin/sh
27425
28231
  ${LEGACY_GLOBAL_OWNED_HEADER}
27426
28232
  `)) {
27427
28233
  const gateAt = existing.indexOf(Buffer.from('if [ "$(git config --get prim.active'));
@@ -27436,15 +28242,13 @@ ${LEGACY_GLOBAL_OWNED_HEADER}
27436
28242
  existing.subarray(0, gateAt),
27437
28243
  existing.subarray(chainAt)
27438
28244
  ]);
27439
- const shebangEnd2 = shellInsertionPoint(withoutLegacyGate, allowShebangless, spec);
27440
- return Buffer.concat([
27441
- withoutLegacyGate.subarray(0, shebangEnd2),
27442
- block,
27443
- Buffer.from("\n"),
27444
- withoutLegacyGate.subarray(shebangEnd2)
27445
- ]);
28245
+ return insertBlock(
28246
+ withoutLegacyGate,
28247
+ blockInsertionPoint(withoutLegacyGate, allowShebangless, spec, huskyV8),
28248
+ spec
28249
+ );
27446
28250
  }
27447
- if (spec.hookName === POST_COMMIT_MANAGED_HOOK.hookName && range.kind === "absent" && existing.toString("utf8").startsWith(`#!/bin/sh
28251
+ if (text.startsWith(`#!/bin/sh
27448
28252
  ${LEGACY_PRIM_OWNED_HEADER}
27449
28253
  `)) {
27450
28254
  const prefixLength = legacyProjectPrefixLength(existing);
@@ -27453,42 +28257,59 @@ ${LEGACY_PRIM_OWNED_HEADER}
27453
28257
  }
27454
28258
  return Buffer.concat([createdScaffold(spec), existing.subarray(prefixLength)]);
27455
28259
  }
27456
- if (range.kind !== "absent") {
27457
- const oldCreatedPrefixes = [
27458
- Buffer.from(`#!/bin/sh
27459
- # ${spec.createdMark}
27460
-
27461
- `),
27462
- ...spec.hookName === POST_COMMIT_MANAGED_HOOK.hookName ? [Buffer.from(`#!/bin/sh
27463
- # ${LEGACY_PRIM_CREATED_MARK}
27464
-
27465
- `)] : []
27466
- ];
27467
- const oldCreated = oldCreatedPrefixes.some(
28260
+ return void 0;
28261
+ }
28262
+ function mergedContent(existing, allowShebangless, spec, relocate, huskyV8) {
28263
+ if (!existing) return { content: createdScaffold(spec), migrates: false };
28264
+ const range = blockRange(existing, spec);
28265
+ if (range.kind === "absent") {
28266
+ const migrated = migratedLegacyContent(existing, allowShebangless, spec, huskyV8);
28267
+ if (migrated) return { content: migrated, migrates: true };
28268
+ } else if (range.kind !== "newer") {
28269
+ const oldCreated = oldCreatedPrefixes(spec).some(
27468
28270
  (prefix) => range.start === prefix.length && existing.subarray(0, prefix.length).equals(prefix)
27469
28271
  );
27470
28272
  if (oldCreated) {
27471
28273
  const suffix = existing.subarray(range.end);
27472
28274
  const tail = suffix.at(0) === 10 ? suffix.subarray(1) : suffix;
27473
- return Buffer.concat([createdScaffold(spec), tail]);
28275
+ return {
28276
+ content: Buffer.concat([createdScaffold(spec), tail]),
28277
+ migrates: range.kind === "stale"
28278
+ };
27474
28279
  }
27475
28280
  }
27476
28281
  const shebangEnd = shellInsertionPoint(existing, allowShebangless, spec);
27477
- if (range.kind === "current" && range.start === shebangEnd) return existing;
27478
- let withoutBlock = existing;
27479
- if (range.kind !== "absent") {
27480
- const suffix = existing.subarray(range.end);
27481
- withoutBlock = Buffer.concat([
27482
- existing.subarray(0, range.start),
27483
- range.start === shebangEnd && suffix.at(0) === 10 ? suffix.subarray(1) : suffix
27484
- ]);
28282
+ const insertion = blockInsertionPoint(existing, allowShebangless, spec, huskyV8);
28283
+ switch (range.kind) {
28284
+ case "newer":
28285
+ return { content: existing, migrates: false };
28286
+ case "absent":
28287
+ return { content: insertBlock(existing, insertion, spec), migrates: false };
28288
+ case "current":
28289
+ case "stale": {
28290
+ const misplaced = terminatesBefore(existing, shebangEnd, range.start) || range.start < insertion;
28291
+ if (relocate && misplaced) {
28292
+ const without = withoutRange(existing, range.start, range.end);
28293
+ return {
28294
+ content: insertBlock(
28295
+ without,
28296
+ blockInsertionPoint(without, allowShebangless, spec, huskyV8),
28297
+ spec
28298
+ ),
28299
+ migrates: range.kind === "stale"
28300
+ };
28301
+ }
28302
+ if (range.kind === "current") return { content: existing, migrates: false };
28303
+ return {
28304
+ content: Buffer.concat([
28305
+ existing.subarray(0, range.start),
28306
+ Buffer.from(managedHookBlock(spec.hookName)),
28307
+ existing.subarray(range.end)
28308
+ ]),
28309
+ migrates: true
28310
+ };
28311
+ }
27485
28312
  }
27486
- return Buffer.concat([
27487
- withoutBlock.subarray(0, shebangEnd),
27488
- block,
27489
- Buffer.from("\n"),
27490
- withoutBlock.subarray(shebangEnd)
27491
- ]);
27492
28313
  }
27493
28314
  function errorCode(error) {
27494
28315
  return typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
@@ -27509,9 +28330,9 @@ function assertTargetUnchanged(path, expected, spec, stat) {
27509
28330
  }
27510
28331
  }
27511
28332
  function rewriteHookAtomically(path, next, expected, spec, stat) {
27512
- const parent = dirname10(path);
27513
- mkdirSync7(parent, { recursive: true });
27514
- const temporary = resolve6(
28333
+ const parent = dirname11(path);
28334
+ mkdirSync8(parent, { recursive: true });
28335
+ const temporary = resolve7(
27515
28336
  parent,
27516
28337
  `.${basename2(path)}.prim-${String(process.pid)}-${randomUUID2()}.tmp`
27517
28338
  );
@@ -27537,41 +28358,71 @@ function rewriteHookAtomically(path, next, expected, spec, stat) {
27537
28358
  }
27538
28359
  }
27539
28360
  try {
27540
- unlinkSync2(temporary);
28361
+ unlinkSync3(temporary);
27541
28362
  } catch (error) {
27542
28363
  if (errorCode(error) !== "ENOENT") {
27543
28364
  }
27544
28365
  }
27545
28366
  }
27546
28367
  }
27547
- function ensureEffectivePostCommitHook(cwd = process.cwd()) {
27548
- const target = resolveEffectivePostCommitHook(cwd);
27549
- return ensureTarget(target, POST_COMMIT_MANAGED_HOOK);
27550
- }
27551
- function ensureEffectivePostRewriteHook(cwd = process.cwd()) {
27552
- const target = resolveEffectivePostRewriteHook(cwd);
27553
- return ensureTarget(target, POST_REWRITE_MANAGED_HOOK);
28368
+ function workingLegacyBlock(content, target, spec) {
28369
+ try {
28370
+ const range = blockRange(content, spec);
28371
+ if (range.kind !== "stale") return false;
28372
+ const block = content.subarray(range.start, range.end).toString("utf8");
28373
+ const from = shellInsertionPoint(content, target.kind === "husky_v9", spec);
28374
+ return isRecognizedLegacyBlock(spec.hookName, block) && !mayTerminateBefore(content, from, range.start);
28375
+ } catch {
28376
+ return false;
28377
+ }
27554
28378
  }
27555
- function ensureTarget(target, spec, initialContent) {
28379
+ var AMBIENT_LOCATIONS = ["repository", "prim"];
28380
+ var EXPLICIT_LOCATIONS = ["repository", "prim", "worktree"];
28381
+ function ensureTarget(target, spec, policy) {
28382
+ const result = { hookName: spec.hookName, path: target.hookPath, kind: target.kind };
28383
+ const skip = (outcome) => ({
28384
+ ...result,
28385
+ changed: false,
28386
+ outcome
28387
+ });
27556
28388
  assertUsableHuskyDispatcher(target, spec);
27557
28389
  const stat = assertSafeFile(target.hookPath, spec);
27558
28390
  if (stat && target.kind === "direct" && (stat.mode & 64) === 0) {
27559
28391
  throw new Error(`existing ${spec.hookName} hook is not executable: ${target.hookPath}`);
27560
28392
  }
27561
28393
  const existing = stat ? readHookFile(target.hookPath) : void 0;
27562
- const next = !existing && initialContent !== void 0 ? Buffer.from(initialContent) : mergedContent(existing, target.kind === "husky_v9", spec);
27563
- if (!existing && initialContent !== void 0) {
27564
- const shebangEnd = shellInsertionPoint(next, target.kind === "husky_v9", spec);
27565
- const range = blockRange(next, spec);
27566
- if (range.kind !== "current" || range.start !== shebangEnd) {
27567
- throw new Error(`invalid initial Prim ${spec.hookName} scaffold`);
27568
- }
27569
- }
27570
- const contentChanged = !existing || !next.equals(existing);
27571
- if (contentChanged) {
27572
- rewriteHookAtomically(target.hookPath, next, existing, spec, stat);
28394
+ if (policy.repairOnly && (!existing || blockRange(existing, spec).kind === "absent")) {
28395
+ return skip("skipped");
28396
+ }
28397
+ const huskyV8 = isHuskyV8Hook(target.hookPath);
28398
+ const next = mergedContent(existing, target.kind === "husky_v9", spec, policy.relocate, huskyV8);
28399
+ if (existing && next.content.equals(existing)) return skip("unchanged");
28400
+ if (!policy.writable(target.location)) {
28401
+ if (target.location === "worktree") return skip("deferred");
28402
+ return skip(existing && workingLegacyBlock(existing, target, spec) ? "kept" : "external");
28403
+ }
28404
+ if (next.migrates && inspectGitHookEntrypoint() !== "ready") return skip("runtime_missing");
28405
+ rewriteHookAtomically(target.hookPath, next.content, existing, spec, stat);
28406
+ return { ...result, changed: true, outcome: existing ? "updated" : "created" };
28407
+ }
28408
+ function ensureEffectiveGitHook(hookName, cwd = process.cwd(), options = {}) {
28409
+ const target = resolveEffectiveGitHook(hookName, cwd);
28410
+ if (gitHooksMode({ cwd: target.gitRoot }) === "manual") {
28411
+ return {
28412
+ hookName,
28413
+ path: target.hookPath,
28414
+ kind: target.kind,
28415
+ changed: false,
28416
+ outcome: "manual"
28417
+ };
27573
28418
  }
27574
- return { path: target.hookPath, changed: contentChanged || !stat, kind: target.kind };
28419
+ const explicit = (options.context ?? "explicit") === "explicit";
28420
+ const allowed = explicit ? EXPLICIT_LOCATIONS : AMBIENT_LOCATIONS;
28421
+ return ensureTarget(target, managedHookSpec(hookName), {
28422
+ writable: (location) => allowed.includes(location),
28423
+ relocate: explicit,
28424
+ repairOnly: options.repairOnly === true
28425
+ });
27575
28426
  }
27576
28427
 
27577
28428
  // src/lib/repository-binding.ts
@@ -27631,7 +28482,7 @@ async function bindRepository(root, options) {
27631
28482
  }
27632
28483
 
27633
28484
  // src/lib/workspace-id.ts
27634
- import { execFileSync as execFileSync4 } from "child_process";
28485
+ import { execFileSync as execFileSync5 } from "child_process";
27635
28486
  import { randomUUID as randomUUID3 } from "crypto";
27636
28487
  import {
27637
28488
  constants as constants6,
@@ -27641,15 +28492,15 @@ import {
27641
28492
  fsyncSync as fsyncSync3,
27642
28493
  linkSync,
27643
28494
  lstatSync as lstatSync6,
27644
- mkdirSync as mkdirSync8,
28495
+ mkdirSync as mkdirSync9,
27645
28496
  openSync as openSync5,
27646
- readFileSync as readFileSync12,
28497
+ readFileSync as readFileSync13,
27647
28498
  statSync as statSync3,
27648
- unlinkSync as unlinkSync3,
28499
+ unlinkSync as unlinkSync4,
27649
28500
  writeFileSync as writeFileSync5
27650
28501
  } from "fs";
27651
- import { dirname as dirname11, isAbsolute as isAbsolute8, join as join15, resolve as resolve7 } from "path";
27652
- var WORKSPACE_ID_RELATIVE_PATH = join15("prim", "workspace-id");
28502
+ import { dirname as dirname12, isAbsolute as isAbsolute9, join as join17, resolve as resolve8 } from "path";
28503
+ var WORKSPACE_ID_RELATIVE_PATH = join17("prim", "workspace-id");
27653
28504
  var MAX_ANCESTORS = 64;
27654
28505
  var MAX_GIT_FILE_BYTES = 4096;
27655
28506
  var MAX_ID_FILE_BYTES = 128;
@@ -27677,7 +28528,7 @@ function resolveWorkspaceIdPath(cwd) {
27677
28528
  if (fromFilesystem) return { status: "resolved", path: fromFilesystem };
27678
28529
  }
27679
28530
  try {
27680
- const output = execFileSync4(
28531
+ const output = execFileSync5(
27681
28532
  "git",
27682
28533
  ["rev-parse", "--is-inside-work-tree", "--git-path", WORKSPACE_ID_RELATIVE_PATH],
27683
28534
  {
@@ -27695,7 +28546,7 @@ function resolveWorkspaceIdPath(cwd) {
27695
28546
  }
27696
28547
  return {
27697
28548
  status: "resolved",
27698
- path: isAbsolute8(gitPath) ? resolve7(gitPath) : resolve7(cwd, gitPath)
28549
+ path: isAbsolute9(gitPath) ? resolve8(gitPath) : resolve8(cwd, gitPath)
27699
28550
  };
27700
28551
  } catch (error) {
27701
28552
  const code = errorCode2(error);
@@ -27706,21 +28557,21 @@ function resolveWorkspaceIdPath(cwd) {
27706
28557
  }
27707
28558
  }
27708
28559
  function resolveFromFilesystem(cwd) {
27709
- let current = resolve7(cwd);
28560
+ let current = resolve8(cwd);
27710
28561
  for (let depth = 0; depth < MAX_ANCESTORS; depth += 1) {
27711
- const dotGit = join15(current, ".git");
28562
+ const dotGit = join17(current, ".git");
27712
28563
  try {
27713
28564
  const stat = lstatSync6(dotGit);
27714
28565
  if (stat.isDirectory() && isGitDirectory(dotGit)) {
27715
- return join15(dotGit, WORKSPACE_ID_RELATIVE_PATH);
28566
+ return join17(dotGit, WORKSPACE_ID_RELATIVE_PATH);
27716
28567
  }
27717
28568
  if (stat.isFile() && stat.size <= MAX_GIT_FILE_BYTES) {
27718
- const contents = readFileSync12(dotGit, "utf8");
28569
+ const contents = readFileSync13(dotGit, "utf8");
27719
28570
  const match = /^gitdir: (.+?)(?:\r?\n)?$/.exec(contents);
27720
28571
  if (match?.[1]) {
27721
- const gitDirectory = isAbsolute8(match[1]) ? resolve7(match[1]) : resolve7(current, match[1]);
28572
+ const gitDirectory = isAbsolute9(match[1]) ? resolve8(match[1]) : resolve8(current, match[1]);
27722
28573
  if (isGitDirectory(gitDirectory)) {
27723
- return join15(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
28574
+ return join17(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
27724
28575
  }
27725
28576
  }
27726
28577
  }
@@ -27731,7 +28582,7 @@ function resolveFromFilesystem(cwd) {
27731
28582
  return null;
27732
28583
  }
27733
28584
  }
27734
- const parent = dirname11(current);
28585
+ const parent = dirname12(current);
27735
28586
  if (parent === current) break;
27736
28587
  current = parent;
27737
28588
  }
@@ -27739,7 +28590,7 @@ function resolveFromFilesystem(cwd) {
27739
28590
  }
27740
28591
  function isGitDirectory(path) {
27741
28592
  try {
27742
- return statSync3(join15(path, "HEAD")).isFile();
28593
+ return statSync3(join17(path, "HEAD")).isFile();
27743
28594
  } catch {
27744
28595
  return false;
27745
28596
  }
@@ -27758,7 +28609,7 @@ function inspectPath(path) {
27758
28609
  return { status: "corrupt", path, reason: "invalid_content" };
27759
28610
  }
27760
28611
  try {
27761
- const contents = readFileSync12(path, "utf8");
28612
+ const contents = readFileSync13(path, "utf8");
27762
28613
  const workspaceId = contents.endsWith("\n") ? contents.slice(0, -1) : contents;
27763
28614
  if ((contents === workspaceId || contents === `${workspaceId}
27764
28615
  `) && isCanonicalWorkspaceId(workspaceId)) {
@@ -27775,13 +28626,13 @@ function inspectPath(path) {
27775
28626
  }
27776
28627
  }
27777
28628
  function createWorkspaceId(path) {
27778
- const parent = dirname11(path);
28629
+ const parent = dirname12(path);
27779
28630
  const workspaceId = randomUUID3();
27780
- const temporaryPath = join15(parent, `.workspace-id-${process.pid}-${randomUUID3()}.tmp`);
28631
+ const temporaryPath = join17(parent, `.workspace-id-${process.pid}-${randomUUID3()}.tmp`);
27781
28632
  let temporaryCreated = false;
27782
28633
  let publishing = false;
27783
28634
  try {
27784
- mkdirSync8(parent, { recursive: true, mode: 448 });
28635
+ mkdirSync9(parent, { recursive: true, mode: 448 });
27785
28636
  chmodSync4(parent, 448);
27786
28637
  const fd = openSync5(
27787
28638
  temporaryPath,
@@ -27811,7 +28662,7 @@ function createWorkspaceId(path) {
27811
28662
  } finally {
27812
28663
  if (temporaryCreated) {
27813
28664
  try {
27814
- unlinkSync3(temporaryPath);
28665
+ unlinkSync4(temporaryPath);
27815
28666
  } catch {
27816
28667
  }
27817
28668
  }
@@ -27841,16 +28692,16 @@ import { createHash as createHash9, randomBytes as randomBytes4 } from "crypto";
27841
28692
  import {
27842
28693
  chmodSync as chmodSync5,
27843
28694
  existsSync as existsSync11,
27844
- mkdirSync as mkdirSync9,
27845
- readFileSync as readFileSync13,
27846
- readdirSync as readdirSync4,
28695
+ mkdirSync as mkdirSync10,
28696
+ readFileSync as readFileSync14,
28697
+ readdirSync as readdirSync5,
27847
28698
  renameSync as renameSync4,
27848
28699
  rmSync as rmSync6,
27849
28700
  statSync as statSync4,
27850
- unlinkSync as unlinkSync4,
28701
+ unlinkSync as unlinkSync5,
27851
28702
  writeFileSync as writeFileSync6
27852
28703
  } from "fs";
27853
- import { join as join16 } from "path";
28704
+ import { join as join18 } from "path";
27854
28705
 
27855
28706
  // src/daemon/decision-digest-cache.ts
27856
28707
  import { randomBytes as randomBytes3 } from "crypto";
@@ -28003,10 +28854,10 @@ var STATE_VERSION = 1;
28003
28854
  var DRAFT_STATE_VERSION = 2;
28004
28855
  var NO_CURSOR = -1;
28005
28856
  function stateRoot(namespace) {
28006
- return join16(primConfigDirectory(), namespace, "decision-digests");
28857
+ return join18(primConfigDirectory(), namespace, "decision-digests");
28007
28858
  }
28008
28859
  function draftStateRoot(namespace) {
28009
- return join16(primConfigDirectory(), namespace, "decision-draft-deliveries");
28860
+ return join18(primConfigDirectory(), namespace, "decision-draft-deliveries");
28010
28861
  }
28011
28862
  function workspaceFor(cwd) {
28012
28863
  try {
@@ -28018,12 +28869,12 @@ function workspaceFor(cwd) {
28018
28869
  function statePath(args) {
28019
28870
  const identity = `${args.siteUrl}\0${workspaceFor(args.cwd)}\0${args.sessionId}`;
28020
28871
  const key = createHash9("sha256").update(identity).digest("hex");
28021
- return join16(stateRoot(args.namespace), `${key}.json`);
28872
+ return join18(stateRoot(args.namespace), `${key}.json`);
28022
28873
  }
28023
28874
  function draftStatePath(args) {
28024
28875
  const identity = `${args.siteUrl}\0${workspaceFor(args.cwd)}\0${args.sessionId}\0${args.principalId}\0${args.organizationId}\0${args.credentialFingerprint}`;
28025
28876
  const key = createHash9("sha256").update(identity).digest("hex");
28026
- return join16(draftStateRoot(args.namespace), `${key}.json`);
28877
+ return join18(draftStateRoot(args.namespace), `${key}.json`);
28027
28878
  }
28028
28879
  function parseState(value) {
28029
28880
  if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
@@ -28064,7 +28915,7 @@ function parseDraftState(value) {
28064
28915
  function readState(path) {
28065
28916
  if (!existsSync11(path)) return void 0;
28066
28917
  try {
28067
- return parseState(JSON.parse(readFileSync13(path, "utf8")));
28918
+ return parseState(JSON.parse(readFileSync14(path, "utf8")));
28068
28919
  } catch {
28069
28920
  return void 0;
28070
28921
  }
@@ -28072,15 +28923,15 @@ function readState(path) {
28072
28923
  function readDraftState(path) {
28073
28924
  if (!existsSync11(path)) return void 0;
28074
28925
  try {
28075
- return parseDraftState(JSON.parse(readFileSync13(path, "utf8")));
28926
+ return parseDraftState(JSON.parse(readFileSync14(path, "utf8")));
28076
28927
  } catch {
28077
28928
  return void 0;
28078
28929
  }
28079
28930
  }
28080
28931
  function writeStateFile(path, directory, state) {
28081
- mkdirSync9(directory, { recursive: true, mode: 448 });
28932
+ mkdirSync10(directory, { recursive: true, mode: 448 });
28082
28933
  chmodSync5(directory, 448);
28083
- const temporary = join16(
28934
+ const temporary = join18(
28084
28935
  directory,
28085
28936
  `.${path.slice(directory.length + 1)}.tmp-${process.pid}-${randomBytes4(8).toString("hex")}`
28086
28937
  );
@@ -28095,7 +28946,7 @@ function writeStateFile(path, directory, state) {
28095
28946
  renameSync4(temporary, path);
28096
28947
  } finally {
28097
28948
  try {
28098
- unlinkSync4(temporary);
28949
+ unlinkSync5(temporary);
28099
28950
  } catch {
28100
28951
  }
28101
28952
  }
@@ -28104,14 +28955,14 @@ function cleanupStateFiles(directory, now) {
28104
28955
  if (!existsSync11(directory)) return;
28105
28956
  let names;
28106
28957
  try {
28107
- names = readdirSync4(directory);
28958
+ names = readdirSync5(directory);
28108
28959
  } catch {
28109
28960
  return;
28110
28961
  }
28111
28962
  const files = [];
28112
28963
  const residue = [];
28113
28964
  for (const name of names) {
28114
- const path = join16(directory, name);
28965
+ const path = join18(directory, name);
28115
28966
  try {
28116
28967
  const mtimeMs = statSync4(path).mtimeMs;
28117
28968
  if (name.endsWith(".json")) {
@@ -28126,7 +28977,7 @@ function cleanupStateFiles(directory, now) {
28126
28977
  const excess = files.filter((file) => !stale.some((candidate) => candidate.path === file.path)).sort((a, b) => a.mtimeMs - b.mtimeMs).slice(0, Math.max(0, files.length - CODEX_DIGEST_STATE_MAX_FILES));
28127
28978
  for (const file of [...stale, ...excess]) {
28128
28979
  try {
28129
- unlinkSync4(file.path);
28980
+ unlinkSync5(file.path);
28130
28981
  } catch {
28131
28982
  }
28132
28983
  }
@@ -28417,8 +29268,8 @@ async function prepareCodexContext(options) {
28417
29268
 
28418
29269
  // src/hooks/normalize.ts
28419
29270
  import { createHash as createHash10 } from "crypto";
28420
- import { realpathSync as realpathSync4 } from "fs";
28421
- import { isAbsolute as isAbsolute9, resolve as resolve8 } from "path";
29271
+ import { realpathSync as realpathSync5 } from "fs";
29272
+ import { isAbsolute as isAbsolute10, resolve as resolve9 } from "path";
28422
29273
  var HERMES_EVENT_MAP = {
28423
29274
  on_session_start: "SessionStart",
28424
29275
  on_session_end: "SessionEnd",
@@ -28466,16 +29317,16 @@ function cursorToolUseId(value) {
28466
29317
  function workspaceCandidates(value) {
28467
29318
  if (!Array.isArray(value)) return [];
28468
29319
  const roots = value.filter((item) => typeof item === "string" && item.length > 0);
28469
- if (roots.some((root) => !isAbsolute9(root))) {
29320
+ if (roots.some((root) => !isAbsolute10(root))) {
28470
29321
  throw new TypeError("Cursor workspace roots must be absolute");
28471
29322
  }
28472
29323
  return roots;
28473
29324
  }
28474
29325
  function pathIdentity(path) {
28475
29326
  try {
28476
- return realpathSync4.native(path);
29327
+ return realpathSync5.native(path);
28477
29328
  } catch {
28478
- return resolve8(path);
29329
+ return resolve9(path);
28479
29330
  }
28480
29331
  }
28481
29332
  function resolveCursorCwd(parsed) {
@@ -28490,17 +29341,17 @@ function resolveCursorCwd(parsed) {
28490
29341
  }
28491
29342
  const expectedRepo = [...repositoryRoots][0];
28492
29343
  const rawCwd = typeof parsed.cwd === "string" && parsed.cwd.length > 0 ? parsed.cwd : void 0;
28493
- if (rawCwd && !isAbsolute9(rawCwd)) {
29344
+ if (rawCwd && !isAbsolute10(rawCwd)) {
28494
29345
  throw new TypeError("Cursor hook cwd must be absolute");
28495
29346
  }
28496
29347
  const envelopeCwd = rawCwd ? pathIdentity(rawCwd) : void 0;
28497
29348
  const input = typeof parsed.tool_input === "object" && parsed.tool_input !== null && !Array.isArray(parsed.tool_input) ? parsed.tool_input : void 0;
28498
29349
  const rawToolCwd = parsed.tool_name === "Shell" && typeof input?.working_directory === "string" ? input.working_directory : void 0;
28499
29350
  const base = envelopeCwd ?? (roots.length === 1 ? roots[0] : expectedRepo);
28500
- if (rawToolCwd && !isAbsolute9(rawToolCwd) && !base) {
29351
+ if (rawToolCwd && !isAbsolute10(rawToolCwd) && !base) {
28501
29352
  throw new TypeError("relative Cursor tool cwd has no workspace base");
28502
29353
  }
28503
- const toolCwd = rawToolCwd ? pathIdentity(isAbsolute9(rawToolCwd) ? rawToolCwd : resolve8(base, rawToolCwd)) : void 0;
29354
+ const toolCwd = rawToolCwd ? pathIdentity(isAbsolute10(rawToolCwd) ? rawToolCwd : resolve9(base, rawToolCwd)) : void 0;
28504
29355
  const selected = toolCwd ?? envelopeCwd ?? (roots.length === 1 ? roots[0] : expectedRepo);
28505
29356
  if (!selected) {
28506
29357
  throw new TypeError("Cursor hook envelope has no unambiguous workspace");
@@ -28594,7 +29445,11 @@ var CODEX_PRIM_REMINDER = primReminder(CODEX_PRIM_ACTION, CODEX_PRIM_ACTION);
28594
29445
  async function activeProjectRoot(cwd) {
28595
29446
  try {
28596
29447
  const root = gitToplevel(cwd);
28597
- if (!root || !isRepoActiveForCapture(cwd)) return null;
29448
+ if (!root) return null;
29449
+ if (!isRepoActiveForCapture(cwd)) {
29450
+ if (repoActiveFlag(root) === "false") clearHooksWired(root);
29451
+ return null;
29452
+ }
28598
29453
  let shellGateActive = repoActiveFlag(root) === "true";
28599
29454
  if (!shellGateActive) {
28600
29455
  try {
@@ -28604,13 +29459,18 @@ async function activeProjectRoot(cwd) {
28604
29459
  }
28605
29460
  }
28606
29461
  if (shellGateActive) {
28607
- try {
28608
- ensureEffectivePostCommitHook(root);
28609
- } catch {
28610
- }
28611
- try {
28612
- ensureEffectivePostRewriteHook(root);
28613
- } catch {
29462
+ for (const hookName of MANAGED_GIT_HOOK_NAMES) {
29463
+ try {
29464
+ const result = ensureEffectiveGitHook(hookName, root, {
29465
+ context: "ambient",
29466
+ repairOnly: hookName === "pre-commit"
29467
+ });
29468
+ if (hookName === "post-commit" && // Manual mode: the user's own wiring is expected to reach prim too.
29469
+ ["created", "updated", "unchanged", "manual"].includes(result.outcome)) {
29470
+ recordHooksWired(root, { onlyIfAbsent: true });
29471
+ }
29472
+ } catch {
29473
+ }
28614
29474
  }
28615
29475
  }
28616
29476
  try {
@@ -28653,13 +29513,18 @@ async function processSessionStart(raw, agent, feedbackSignal) {
28653
29513
  if (typeof envelope.session_id !== "string" || envelope.session_id.length === 0) {
28654
29514
  return { output: buildHookOutput({}) };
28655
29515
  }
29516
+ const cwd = envelope.cwd ?? process.cwd();
29517
+ if (!gitToplevel(cwd) || !isRepoActiveForCapture(cwd)) {
29518
+ if (repoActiveFlag(cwd) === "false") clearHooksWired(cwd);
29519
+ return { output: agent === "cursor" ? {} : buildHookOutput({}) };
29520
+ }
29521
+ warmBinCache();
28656
29522
  kickDaemonEnsure();
28657
29523
  await daemonRequest(
28658
29524
  "session_start",
28659
29525
  { sessionId: envelope.session_id, callerEnv: getSiteUrl() },
28660
29526
  { timeoutMs: DAEMON_TIMEOUT_MS }
28661
29527
  );
28662
- const cwd = envelope.cwd ?? process.cwd();
28663
29528
  let projectRoot2 = null;
28664
29529
  let active = false;
28665
29530
  let skillState = { installed: 0, refreshed: 0 };
@@ -28786,7 +29651,6 @@ function emitOutput(output, acknowledge) {
28786
29651
  return handoffHookOutput(output, acknowledge);
28787
29652
  }
28788
29653
  async function main() {
28789
- warmBinCache();
28790
29654
  const agent = parseAgent(process.argv);
28791
29655
  let raw;
28792
29656
  try {