@primitive.ai/prim 0.1.0-alpha.97 → 0.1.0-alpha.98

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 (31) hide show
  1. package/README.md +9 -0
  2. package/dist/{chunk-OW4GJBLW.js → chunk-2DA2B4EC.js} +2 -2
  3. package/dist/{chunk-35FMRWJH.js → chunk-2DPLT2CQ.js} +1 -1
  4. package/dist/{chunk-XEDJ5N3M.js → chunk-3X77XQGW.js} +2 -4
  5. package/dist/{chunk-DWRSEC34.js → chunk-6QK75B7G.js} +392 -15
  6. package/dist/{chunk-ZYK3TBEW.js → chunk-7IPGD6CD.js} +4 -6
  7. package/dist/{chunk-RK4ZS3HG.js → chunk-AN6XTFIN.js} +2 -2
  8. package/dist/{chunk-LY6NJ7KL.js → chunk-B6EPQ4YH.js} +1 -1
  9. package/dist/{chunk-QNPTWTBG.js → chunk-BIAWZMCK.js} +2 -2
  10. package/dist/{chunk-2MBV7ZMV.js → chunk-HUZXBJJ5.js} +1 -1
  11. package/dist/{chunk-FBPZ4YUD.js → chunk-IL443QTF.js} +2 -2
  12. package/dist/{chunk-7KABYYWG.js → chunk-JOR67B5T.js} +6 -8
  13. package/dist/{chunk-3I4GEWXQ.js → chunk-MN4X6RR6.js} +8 -10
  14. package/dist/{chunk-UO2U6IKF.js → chunk-NIQAVFP6.js} +1 -1
  15. package/dist/{chunk-AJYZB5PF.js → chunk-PPZBEOWK.js} +3 -3
  16. package/dist/{chunk-4GHANPWQ.js → chunk-QPMLAD2C.js} +2 -2
  17. package/dist/{chunk-Y5W4TZM7.js → chunk-RT7DXMTN.js} +2 -4
  18. package/dist/{chunk-27ADT6FQ.js → chunk-WKLYYT63.js} +44 -6
  19. package/dist/hook-runtime/hooks/pre-commit.js +208 -9
  20. package/dist/hook-runtime/index.js +41 -6
  21. package/dist/hooks/post-commit.js +7 -8
  22. package/dist/hooks/post-rewrite.js +6 -7
  23. package/dist/hooks/post-tool-use.js +13 -14
  24. package/dist/hooks/pre-commit.js +4 -4
  25. package/dist/hooks/pre-tool-use.js +10 -12
  26. package/dist/hooks/prim-hook.js +14 -15
  27. package/dist/hooks/session-end.js +6 -7
  28. package/dist/hooks/session-start.js +13 -14
  29. package/dist/index.js +25 -27
  30. package/package.json +1 -1
  31. package/dist/chunk-DHOQGHKQ.js +0 -379
package/README.md CHANGED
@@ -297,6 +297,15 @@ prim decisions unlink <child> --on <parent> # Remove that dependency
297
297
  `<id>` accepts a full decision ID or its short ID. STDOUT is machine-readable
298
298
  JSON; human-readable status goes to STDERR.
299
299
 
300
+ `decisions check` uses the checkout's current Primitive repository binding and
301
+ Git branch. Paths are relative to the repository root, including from a
302
+ subdirectory; paths for files that do not exist yet are supported. Discovery
303
+ includes exact file, directory, glob, and repository scopes and applies each
304
+ Decision's effective window and audience. It does not run the Conflict Gate.
305
+ Missing bindings, older servers that cannot confirm repository-scoped discovery,
306
+ and bounded partial results report `unavailable` or `truncated`; they are not a
307
+ verified empty result. Reconnect a missing or stale binding with `prim enable`.
308
+
300
309
  When passive capture is inactive in the current repo, an approved one-time create is:
301
310
 
302
311
  ```bash
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-EZXEWFDG.js";
4
4
  import {
5
5
  scrubEnvironmentPaths
6
- } from "./chunk-QNPTWTBG.js";
6
+ } from "./chunk-BIAWZMCK.js";
7
7
  import {
8
8
  isValidRepoSyncId
9
- } from "./chunk-DHOQGHKQ.js";
9
+ } from "./chunk-6QK75B7G.js";
10
10
 
11
11
  // src/hooks/prim-hook-core.ts
12
12
  import { createHash, randomUUID } from "crypto";
@@ -2,7 +2,7 @@ import {
2
2
  decodeJwtPayload,
3
3
  primConfigDirectory,
4
4
  resolveAuthCredential
5
- } from "./chunk-DWRSEC34.js";
5
+ } from "./chunk-6QK75B7G.js";
6
6
 
7
7
  // src/daemon/client.ts
8
8
  import { createConnection } from "net";
@@ -1,9 +1,7 @@
1
1
  import {
2
+ atomicWriteFile,
2
3
  repoActiveFlag
3
- } from "./chunk-DHOQGHKQ.js";
4
- import {
5
- atomicWriteFile
6
- } from "./chunk-DWRSEC34.js";
4
+ } from "./chunk-6QK75B7G.js";
7
5
 
8
6
  // src/lib/commit-heartbeat.ts
9
7
  import { execFileSync } from "child_process";
@@ -297,7 +297,7 @@ function providerError(value) {
297
297
  return exactString(error, "error", MAX_USER_CODE_LENGTH);
298
298
  }
299
299
  async function defaultSleep(milliseconds, signal) {
300
- await new Promise((resolve, reject) => {
300
+ await new Promise((resolve2, reject) => {
301
301
  if (signal.aborted) {
302
302
  reject(signal.reason);
303
303
  return;
@@ -308,7 +308,7 @@ async function defaultSleep(milliseconds, signal) {
308
308
  };
309
309
  const timer = setTimeout(() => {
310
310
  signal.removeEventListener("abort", abort);
311
- resolve();
311
+ resolve2();
312
312
  }, milliseconds);
313
313
  signal.addEventListener("abort", abort, { once: true });
314
314
  });
@@ -500,6 +500,363 @@ function jwtOrganizationId(token) {
500
500
  return typeof orgId === "string" && orgId.length > 0 ? orgId : void 0;
501
501
  }
502
502
 
503
+ // src/lib/git.ts
504
+ import { execFileSync } from "child_process";
505
+ import { createHash as createHash2 } from "crypto";
506
+ import { lstatSync, realpathSync } from "fs";
507
+ import { basename, dirname, isAbsolute as isAbsolute2, relative, resolve, sep } from "path";
508
+ var GIT_TIMEOUT_MS = 1e3;
509
+ var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
510
+ var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
511
+ function gitToplevel(cwd) {
512
+ try {
513
+ return execFileSync("git", ["rev-parse", "--show-toplevel"], {
514
+ cwd,
515
+ encoding: "utf-8",
516
+ stdio: ["ignore", "pipe", "ignore"],
517
+ timeout: GIT_TIMEOUT_MS
518
+ }).trim();
519
+ } catch {
520
+ return null;
521
+ }
522
+ }
523
+ function mainWorktreeRoot(cwd) {
524
+ try {
525
+ const [gitDir, commonDir] = execFileSync(
526
+ "git",
527
+ ["rev-parse", "--git-dir", "--git-common-dir"],
528
+ {
529
+ cwd,
530
+ encoding: "utf-8",
531
+ stdio: ["ignore", "pipe", "ignore"],
532
+ timeout: GIT_TIMEOUT_MS
533
+ }
534
+ ).trim().split("\n").map((value) => resolve(cwd ?? process.cwd(), value));
535
+ if (gitDir === void 0 || commonDir === void 0 || gitDir === commonDir) return null;
536
+ return basename(commonDir) === ".git" ? dirname(commonDir) : null;
537
+ } catch {
538
+ return null;
539
+ }
540
+ }
541
+ function gitValue(cwd, args) {
542
+ try {
543
+ const value = execFileSync("git", args, {
544
+ cwd,
545
+ encoding: "utf-8",
546
+ stdio: ["ignore", "pipe", "ignore"],
547
+ timeout: GIT_TIMEOUT_MS
548
+ }).trim();
549
+ return value || void 0;
550
+ } catch {
551
+ return void 0;
552
+ }
553
+ }
554
+ function currentBranch(cwd) {
555
+ return gitValue(cwd, ["symbolic-ref", "--quiet", "--short", "HEAD"]);
556
+ }
557
+ function githubRepositoryFullName(cwd) {
558
+ const remote = gitValue(cwd, ["config", "--get", "remote.origin.url"]);
559
+ if (!remote || [...remote].some((char) => char < " " || char === "\x7F")) return null;
560
+ const match = /^(?:git@github\.com:([^?#]+)|(?:https|ssh):\/\/(?:[^/@]+@)?github\.com(?::\d+)?\/([^?#]+))$/i.exec(
561
+ remote
562
+ );
563
+ const path = match?.[1] ?? match?.[2];
564
+ if (!path) return null;
565
+ const parts = path.replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "").split("/");
566
+ if (parts.length !== 2 || !GITHUB_OWNER_PATTERN.test(parts[0] ?? "") || !GITHUB_REPOSITORY_PATTERN.test(parts[1] ?? "")) {
567
+ return null;
568
+ }
569
+ return `${parts[0]}/${parts[1]}`;
570
+ }
571
+ function canonicalGitRoot(cwd) {
572
+ try {
573
+ const top = gitToplevel(cwd);
574
+ return top ? realpathSync.native(top) : null;
575
+ } catch {
576
+ return null;
577
+ }
578
+ }
579
+ function relatedWorktreeTarget(path, cwd, origin) {
580
+ let parent = dirname(resolve(cwd, path));
581
+ while (true) {
582
+ try {
583
+ realpathSync.native(parent);
584
+ break;
585
+ } catch {
586
+ const next = dirname(parent);
587
+ if (next === parent) return null;
588
+ parent = next;
589
+ }
590
+ }
591
+ const target = resolveRepositoryContext(parent);
592
+ if (!target || !target.repoKey || target.repoKey !== origin.repoKey) return null;
593
+ const common = (root) => {
594
+ const value = gitValue(root, ["rev-parse", "--git-common-dir"]);
595
+ try {
596
+ return value ? realpathSync.native(resolve(root, value)) : void 0;
597
+ } catch {
598
+ return void 0;
599
+ }
600
+ };
601
+ const originCommon = common(origin.repoRoot);
602
+ return originCommon && originCommon === common(target.repoRoot) ? target : null;
603
+ }
604
+ function normalizeOriginRemote(remote) {
605
+ const value = remote.trim();
606
+ if (!value) return void 0;
607
+ const scp = !value.includes("://") ? /^(?:[^@/\s]+@)?(?<host>[^:/\s]+):(?<path>.+)$/.exec(value)?.groups : void 0;
608
+ if (scp?.host && scp.path) {
609
+ const path = scp.path.replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "");
610
+ return path ? `${scp.host.toLowerCase()}/${path}` : void 0;
611
+ }
612
+ try {
613
+ const url = new URL(value);
614
+ url.username = "";
615
+ url.password = "";
616
+ url.search = "";
617
+ url.hash = "";
618
+ const path = url.pathname.replace(/^\/+|\/+$/g, "").replace(/\.git$/i, "");
619
+ if (url.host && path) return `${url.host.toLowerCase()}/${path}`;
620
+ return void 0;
621
+ } catch {
622
+ return void 0;
623
+ }
624
+ }
625
+ function opaqueRepoKey(source, value) {
626
+ return `repo_v1_${createHash2("sha256").update(`${source}\0${value}`).digest("hex")}`;
627
+ }
628
+ function resolveRepositoryContext(cwd = process.cwd()) {
629
+ const top = gitToplevel(cwd);
630
+ if (!top) return null;
631
+ let repoRoot;
632
+ try {
633
+ repoRoot = realpathSync.native(top);
634
+ } catch {
635
+ repoRoot = resolve(top);
636
+ }
637
+ const origin = gitValue(repoRoot, ["config", "--get", "remote.origin.url"]);
638
+ const repoFullName = githubRepositoryFullName(repoRoot) ?? void 0;
639
+ const normalizedOrigin = origin ? normalizeOriginRemote(origin) : void 0;
640
+ if (normalizedOrigin) {
641
+ return {
642
+ repoRoot,
643
+ repoKey: opaqueRepoKey("origin", normalizedOrigin),
644
+ identitySource: "origin",
645
+ repoFullName
646
+ };
647
+ }
648
+ const roots = gitValue(repoRoot, ["rev-list", "--max-parents=0", "HEAD"])?.split(/\s+/).filter(Boolean).sort();
649
+ if (roots && roots.length > 0) {
650
+ return {
651
+ repoRoot,
652
+ repoKey: opaqueRepoKey("root_commit", roots.join("\n")),
653
+ identitySource: "root_commit",
654
+ repoFullName
655
+ };
656
+ }
657
+ return { repoRoot, repoFullName };
658
+ }
659
+ function nearestExistingAncestor(path) {
660
+ const suffix = [];
661
+ let cursor = path;
662
+ while (true) {
663
+ try {
664
+ lstatSync(cursor);
665
+ break;
666
+ } catch (error) {
667
+ const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
668
+ if (code !== "ENOENT" && code !== "ENOTDIR") return null;
669
+ const parent = dirname(cursor);
670
+ if (parent === cursor) return null;
671
+ suffix.unshift(cursor.slice(parent.length + (parent.endsWith(sep) ? 0 : 1)));
672
+ cursor = parent;
673
+ }
674
+ }
675
+ try {
676
+ return { real: realpathSync.native(cursor), suffix };
677
+ } catch {
678
+ return null;
679
+ }
680
+ }
681
+ function canonicalRepositoryPathScoped(filePath, context, baseDir) {
682
+ if (!filePath || filePath !== filePath.trim() || filePath.includes("\0")) {
683
+ return { ok: false, reason: "invalid_path" };
684
+ }
685
+ const absolute = resolve(baseDir, filePath);
686
+ const resolved = nearestExistingAncestor(absolute);
687
+ if (!resolved) return { ok: false, reason: "invalid_path" };
688
+ const target = resolve(resolved.real, ...resolved.suffix);
689
+ const rel = relative(context.repoRoot, target);
690
+ if (!rel || rel === ".") return { ok: false, reason: "invalid_path" };
691
+ if (isAbsolute2(rel) || rel === ".." || rel.startsWith(`..${sep}`)) {
692
+ return { ok: false, reason: "outside_repository" };
693
+ }
694
+ return { ok: true, file: sep === "/" ? rel : rel.split(sep).join("/") };
695
+ }
696
+ function canonicalRepositoryPathLegacy(filePath, cwd, repositoryRoot = canonicalGitRoot(cwd)) {
697
+ if (!repositoryRoot || !filePath || [...filePath].some((char) => char < " " || char === "\x7F" || "~*?[]{}$`\\".includes(char)))
698
+ return null;
699
+ const absolute = resolve(cwd, filePath);
700
+ let target;
701
+ try {
702
+ const stat = lstatSync(absolute);
703
+ if (!stat.isFile() || stat.isSymbolicLink()) return null;
704
+ target = realpathSync.native(absolute);
705
+ } catch (error) {
706
+ if (!(error instanceof Error) || error.code !== "ENOENT") {
707
+ return null;
708
+ }
709
+ try {
710
+ const parent = realpathSync.native(dirname(absolute));
711
+ if (!lstatSync(parent).isDirectory()) return null;
712
+ target = resolve(parent, basename(absolute));
713
+ } catch {
714
+ return null;
715
+ }
716
+ }
717
+ const rel = relative(repositoryRoot, target);
718
+ if (!rel || isAbsolute2(rel) || rel === ".." || rel.startsWith(`..${sep}`)) {
719
+ return null;
720
+ }
721
+ return sep === "/" ? rel : rel.split(sep).join("/");
722
+ }
723
+ function canonicalRepositoryPath(filePath, contextOrCwd, baseDirOrRoot) {
724
+ if (typeof contextOrCwd === "string") {
725
+ return canonicalRepositoryPathLegacy(filePath, contextOrCwd, baseDirOrRoot);
726
+ }
727
+ return canonicalRepositoryPathScoped(
728
+ filePath,
729
+ contextOrCwd,
730
+ baseDirOrRoot ?? contextOrCwd.repoRoot
731
+ );
732
+ }
733
+
734
+ // src/lib/activation.ts
735
+ import { execFileSync as execFileSync2 } from "child_process";
736
+ import { existsSync, readFileSync as readFileSync2 } from "fs";
737
+ import { homedir as homedir2 } from "os";
738
+ import { join as join3 } from "path";
739
+ var PRIM_ACTIVE_KEY = "prim.active";
740
+ var PRIM_REPO_SYNC_ID_KEY = "prim.repoSyncId";
741
+ var PRIM_REPO_SYNC_REPOSITORY_KEY = "prim.repoSyncRepository";
742
+ var PRIM_REPO_BINDING_STATE_KEY = "prim.repoBindingState";
743
+ var GIT_TIMEOUT_MS2 = 1e3;
744
+ var REPO_SYNC_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
745
+ var PROJECT_INSTALL_FILES = [".claude/settings.json", ".codex/hooks.json", ".cursor/hooks.json"];
746
+ var PRIM_HOOK_BINS = ["prim-hook", "prim-pre-tool-use", "prim-post-tool-use"];
747
+ function repoActiveFlag(cwd) {
748
+ try {
749
+ const value = execFileSync2("git", ["config", "--get", PRIM_ACTIVE_KEY], {
750
+ cwd,
751
+ encoding: "utf-8",
752
+ stdio: ["ignore", "pipe", "ignore"],
753
+ timeout: GIT_TIMEOUT_MS2
754
+ }).trim();
755
+ if (value === "true") return "true";
756
+ if (value === "false") return "false";
757
+ return void 0;
758
+ } catch {
759
+ return void 0;
760
+ }
761
+ }
762
+ function isRepoActive(cwd) {
763
+ return repoActiveFlag(cwd) === "true";
764
+ }
765
+ function setRepoActive(cwd, active) {
766
+ execFileSync2("git", ["config", "--local", PRIM_ACTIVE_KEY, active ? "true" : "false"], {
767
+ cwd,
768
+ stdio: ["ignore", "ignore", "pipe"],
769
+ timeout: GIT_TIMEOUT_MS2
770
+ });
771
+ }
772
+ function isValidRepoSyncId(value) {
773
+ return typeof value === "string" && REPO_SYNC_ID_RE.test(value);
774
+ }
775
+ function localGitConfigValue(cwd, key) {
776
+ try {
777
+ const value = execFileSync2("git", ["config", "--local", "--get", key], {
778
+ cwd,
779
+ encoding: "utf-8",
780
+ stdio: ["ignore", "pipe", "ignore"],
781
+ timeout: GIT_TIMEOUT_MS2
782
+ }).trim();
783
+ return value || void 0;
784
+ } catch {
785
+ return void 0;
786
+ }
787
+ }
788
+ function setLocalGitConfigValue(cwd, key, value) {
789
+ execFileSync2("git", ["config", "--local", key, value], {
790
+ cwd,
791
+ stdio: ["ignore", "ignore", "pipe"],
792
+ timeout: GIT_TIMEOUT_MS2
793
+ });
794
+ }
795
+ function repoSyncId(cwd) {
796
+ const value = localGitConfigValue(cwd, PRIM_REPO_SYNC_ID_KEY);
797
+ if (!isValidRepoSyncId(value)) return void 0;
798
+ const repositoryFullName = localGitConfigValue(cwd, PRIM_REPO_SYNC_REPOSITORY_KEY);
799
+ return repositoryFullName === githubRepositoryFullName(cwd) ? value : void 0;
800
+ }
801
+ function setRepoSyncId(cwd, value, repositoryFullName) {
802
+ if (!isValidRepoSyncId(value)) {
803
+ throw new Error("invalid repository binding returned by server");
804
+ }
805
+ execFileSync2("git", ["config", "--local", PRIM_REPO_SYNC_ID_KEY, value], {
806
+ cwd,
807
+ stdio: ["ignore", "ignore", "pipe"],
808
+ timeout: GIT_TIMEOUT_MS2
809
+ });
810
+ execFileSync2("git", ["config", "--local", PRIM_REPO_SYNC_REPOSITORY_KEY, repositoryFullName], {
811
+ cwd,
812
+ stdio: ["ignore", "ignore", "pipe"],
813
+ timeout: GIT_TIMEOUT_MS2
814
+ });
815
+ }
816
+ function setRepositoryBindingState(cwd, state) {
817
+ if (state !== "connected" && state !== "unbound" && state !== "invalid") {
818
+ throw new Error("invalid repository binding state");
819
+ }
820
+ execFileSync2("git", ["config", "--local", PRIM_REPO_BINDING_STATE_KEY, state], {
821
+ cwd,
822
+ stdio: ["ignore", "ignore", "pipe"],
823
+ timeout: GIT_TIMEOUT_MS2
824
+ });
825
+ }
826
+ function repositoryBindingState(cwd) {
827
+ const rawId = localGitConfigValue(cwd, PRIM_REPO_SYNC_ID_KEY);
828
+ const marker = localGitConfigValue(cwd, PRIM_REPO_BINDING_STATE_KEY);
829
+ if (rawId !== void 0 && !isValidRepoSyncId(rawId)) return "invalid";
830
+ if (marker === "unbound" || marker === "invalid") return marker;
831
+ if (marker === "connected") return repoSyncId(cwd) ? "connected" : "invalid";
832
+ if (marker !== void 0) return "invalid";
833
+ return rawId === void 0 ? "unbound" : repoSyncId(cwd) ? void 0 : "unbound";
834
+ }
835
+ function hasProjectPrimInstall(cwd) {
836
+ const root = gitToplevel(cwd);
837
+ if (root === null || root === homedir2()) return false;
838
+ for (const rel of PROJECT_INSTALL_FILES) {
839
+ const path = join3(root, rel);
840
+ if (existsSync(path)) {
841
+ try {
842
+ const content = readFileSync2(path, "utf-8");
843
+ if (PRIM_HOOK_BINS.some((bin) => content.includes(bin))) return true;
844
+ } catch {
845
+ }
846
+ }
847
+ }
848
+ return false;
849
+ }
850
+ function isRepoActiveForCapture(cwd) {
851
+ const flag = repoActiveFlag(cwd);
852
+ if (flag === "true") return true;
853
+ if (flag === "false") return false;
854
+ return hasProjectPrimInstall(cwd);
855
+ }
856
+ function decisionIngestionStatus(cwd) {
857
+ return isRepoActiveForCapture(cwd) ? "enabled" : "disabled";
858
+ }
859
+
503
860
  // src/lib/atomic-file.ts
504
861
  import { randomUUID } from "crypto";
505
862
  import {
@@ -513,7 +870,7 @@ import {
513
870
  rmSync,
514
871
  writeFileSync
515
872
  } from "fs";
516
- import { dirname } from "path";
873
+ import { dirname as dirname2 } from "path";
517
874
  var DEFAULT_FILE_MODE = 438;
518
875
  function syncDirectory(path) {
519
876
  const fd = openSync(path, constants.O_RDONLY);
@@ -536,14 +893,14 @@ function syncCreatedParentChain(firstCreatedParent, parent) {
536
893
  let current = parent;
537
894
  while (current !== firstCreatedParent) {
538
895
  createdDirectories.push(current);
539
- const next = dirname(current);
896
+ const next = dirname2(current);
540
897
  if (next === current) {
541
898
  throw new Error("recursive mkdir returned a path outside the target parent chain");
542
899
  }
543
900
  current = next;
544
901
  }
545
902
  createdDirectories.push(firstCreatedParent);
546
- syncDirectory(dirname(firstCreatedParent));
903
+ syncDirectory(dirname2(firstCreatedParent));
547
904
  for (const directory of createdDirectories.reverse().slice(0, -1)) {
548
905
  syncDirectory(directory);
549
906
  }
@@ -555,7 +912,7 @@ function ensureDurableDirectory(path, mode) {
555
912
  }
556
913
  }
557
914
  function atomicWriteFile(target, content, options = {}) {
558
- const parent = dirname(target);
915
+ const parent = dirname2(target);
559
916
  if (options.ensureParent) {
560
917
  ensureDurableDirectory(parent);
561
918
  }
@@ -599,19 +956,19 @@ function processIsAlive(pid, probe = process.kill) {
599
956
 
600
957
  // src/lib/file-lock.ts
601
958
  import { randomBytes } from "crypto";
602
- import { existsSync, mkdirSync as mkdirSync2, readFileSync as readFileSync2, rmSync as rmSync2, statSync, writeFileSync as writeFileSync2 } from "fs";
603
- import { dirname as dirname2, join as join3 } from "path";
959
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync2, statSync, writeFileSync as writeFileSync2 } from "fs";
960
+ import { dirname as dirname3, join as join4 } from "path";
604
961
  var DEFAULT_TIMEOUT_MS = 3e4;
605
962
  var DEFAULT_POLL_MS = 50;
606
963
  var DEFAULT_INIT_GRACE_MS = 2e3;
607
964
  var DIRECTORY_MODE = 448;
608
965
  var FILE_MODE = 384;
609
966
  function ownerPath(lockDir) {
610
- return join3(lockDir, "owner.json");
967
+ return join4(lockDir, "owner.json");
611
968
  }
612
969
  function readOwner(lockDir) {
613
970
  try {
614
- const owner = JSON.parse(readFileSync2(ownerPath(lockDir), "utf8"));
971
+ const owner = JSON.parse(readFileSync3(ownerPath(lockDir), "utf8"));
615
972
  if (!Number.isInteger(owner.pid) || owner.pid <= 0 || typeof owner.nonce !== "string" || typeof owner.createdAt !== "number") {
616
973
  return null;
617
974
  }
@@ -678,14 +1035,14 @@ function throwIfAborted(signal) {
678
1035
  }
679
1036
  async function defaultSleep2(ms, signal) {
680
1037
  if (!signal) {
681
- await new Promise((resolve) => setTimeout(resolve, ms));
1038
+ await new Promise((resolve2) => setTimeout(resolve2, ms));
682
1039
  return;
683
1040
  }
684
1041
  throwIfAborted(signal);
685
- await new Promise((resolve, reject) => {
1042
+ await new Promise((resolve2, reject) => {
686
1043
  const timer = setTimeout(() => {
687
1044
  signal.removeEventListener("abort", onAbort);
688
- resolve();
1045
+ resolve2();
689
1046
  }, ms);
690
1047
  const onAbort = () => {
691
1048
  clearTimeout(timer);
@@ -699,7 +1056,7 @@ function defaultSleepSync(ms) {
699
1056
  Atomics.wait(syncSleeper, 0, 0, ms);
700
1057
  }
701
1058
  function withFileLockSync(lockDir, operation, options = {}) {
702
- mkdirSync2(dirname2(lockDir), { recursive: true, mode: DIRECTORY_MODE });
1059
+ mkdirSync2(dirname3(lockDir), { recursive: true, mode: DIRECTORY_MODE });
703
1060
  const nowMs = options.nowMs ?? Date.now;
704
1061
  const alive = options.processAlive ?? processIsAlive;
705
1062
  const deadline = nowMs() + (options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
@@ -723,7 +1080,7 @@ function withFileLockSync(lockDir, operation, options = {}) {
723
1080
  }
724
1081
  }
725
1082
  async function withFileLock(lockDir, operation, options = {}) {
726
- mkdirSync2(dirname2(lockDir), { recursive: true, mode: DIRECTORY_MODE });
1083
+ mkdirSync2(dirname3(lockDir), { recursive: true, mode: DIRECTORY_MODE });
727
1084
  const nowMs = options.nowMs ?? Date.now;
728
1085
  const alive = options.processAlive ?? processIsAlive;
729
1086
  const deadline = nowMs() + (options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
@@ -782,6 +1139,26 @@ export {
782
1139
  decodeJwtPayload,
783
1140
  jwtExpiresAt,
784
1141
  jwtOrganizationId,
1142
+ gitToplevel,
1143
+ mainWorktreeRoot,
1144
+ currentBranch,
1145
+ githubRepositoryFullName,
1146
+ canonicalGitRoot,
1147
+ relatedWorktreeTarget,
1148
+ resolveRepositoryContext,
1149
+ canonicalRepositoryPath,
1150
+ repoActiveFlag,
1151
+ isRepoActive,
1152
+ setRepoActive,
1153
+ isValidRepoSyncId,
1154
+ localGitConfigValue,
1155
+ setLocalGitConfigValue,
1156
+ repoSyncId,
1157
+ setRepoSyncId,
1158
+ setRepositoryBindingState,
1159
+ repositoryBindingState,
1160
+ isRepoActiveForCapture,
1161
+ decisionIngestionStatus,
785
1162
  syncDirectory,
786
1163
  syncFile,
787
1164
  ensureDurableDirectory,
@@ -1,15 +1,13 @@
1
1
  import {
2
2
  getClient,
3
3
  terminalSafeLine
4
- } from "./chunk-LY6NJ7KL.js";
4
+ } from "./chunk-B6EPQ4YH.js";
5
5
  import {
6
+ __commonJS,
7
+ __toESM,
6
8
  localGitConfigValue,
7
9
  setLocalGitConfigValue
8
- } from "./chunk-DHOQGHKQ.js";
9
- import {
10
- __commonJS,
11
- __toESM
12
- } from "./chunk-DWRSEC34.js";
10
+ } from "./chunk-6QK75B7G.js";
13
11
 
14
12
  // node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js
15
13
  var require_ucs2length = __commonJS({
@@ -2,10 +2,10 @@ import {
2
2
  cursorHooksPath,
3
3
  hasExactCursorHandler,
4
4
  readCursorHooks
5
- } from "./chunk-Y5W4TZM7.js";
5
+ } from "./chunk-RT7DXMTN.js";
6
6
  import {
7
7
  resolveRepositoryContext
8
- } from "./chunk-DHOQGHKQ.js";
8
+ } from "./chunk-6QK75B7G.js";
9
9
 
10
10
  // src/hooks/agent.ts
11
11
  function parseAgent(argv) {
@@ -19,7 +19,7 @@ import {
19
19
  resolveAuthCredential,
20
20
  withFileLock,
21
21
  workosConnectTokenEndpoint
22
- } from "./chunk-DWRSEC34.js";
22
+ } from "./chunk-6QK75B7G.js";
23
23
 
24
24
  // src/client.ts
25
25
  import { createHash } from "crypto";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  boundedHealthError
3
- } from "./chunk-ZYK3TBEW.js";
3
+ } from "./chunk-7IPGD6CD.js";
4
4
  import {
5
5
  terminalSafeLine
6
- } from "./chunk-LY6NJ7KL.js";
6
+ } from "./chunk-B6EPQ4YH.js";
7
7
 
8
8
  // src/hooks/redact.ts
9
9
  import { existsSync, readFileSync, statSync } from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  scheduleCollectScopeRefresh
3
- } from "./chunk-ZYK3TBEW.js";
3
+ } from "./chunk-7IPGD6CD.js";
4
4
 
5
5
  // src/ingest-response.ts
6
6
  var IngestAcknowledgementError = class extends Error {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  boundedHealthError
3
- } from "./chunk-ZYK3TBEW.js";
3
+ } from "./chunk-7IPGD6CD.js";
4
4
  import {
5
5
  stripControlChars
6
- } from "./chunk-LY6NJ7KL.js";
6
+ } from "./chunk-B6EPQ4YH.js";
7
7
 
8
8
  // src/lib/delivery-backlog.ts
9
9
  var MS_PER_SECOND = 1e3;
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  HttpError,
6
6
  getClient
7
- } from "./chunk-LY6NJ7KL.js";
7
+ } from "./chunk-B6EPQ4YH.js";
8
8
  import {
9
9
  GIT_HOOK_CONTRACT_VERSION,
10
10
  binFile,
@@ -17,19 +17,17 @@ import {
17
17
  managedHookBlock,
18
18
  pinnedHookCommand,
19
19
  pinnedNpxCommand
20
- } from "./chunk-Y5W4TZM7.js";
20
+ } from "./chunk-RT7DXMTN.js";
21
21
  import {
22
+ atomicWriteFile,
22
23
  gitToplevel,
23
24
  githubRepositoryFullName,
24
25
  isValidRepoSyncId,
25
- setRepoSyncId,
26
- setRepositoryBindingState
27
- } from "./chunk-DHOQGHKQ.js";
28
- import {
29
- atomicWriteFile,
30
26
  primConfigDirectory,
27
+ setRepoSyncId,
28
+ setRepositoryBindingState,
31
29
  withFileLock
32
- } from "./chunk-DWRSEC34.js";
30
+ } from "./chunk-6QK75B7G.js";
33
31
 
34
32
  // src/commands/skill.ts
35
33
  import { createHash as createHash2 } from "crypto";