@primitive.ai/prim 0.1.0-alpha.117 → 0.1.0-alpha.119

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 (50) hide show
  1. package/README.md +21 -21
  2. package/SKILL.md +3 -3
  3. package/dist/{chunk-FTW4ZCBA.js → chunk-2AKDX4RU.js} +1 -1
  4. package/dist/{chunk-D3ZDZZYS.js → chunk-2JA524SC.js} +31 -17
  5. package/dist/{chunk-I3J344DF.js → chunk-4L7TAM5S.js} +122 -287
  6. package/dist/{chunk-3TIKBQHV.js → chunk-5BQ2NEMP.js} +2741 -2540
  7. package/dist/{chunk-LEUZDTNT.js → chunk-A6M2M5A2.js} +1 -1
  8. package/dist/{chunk-JKJ22ONL.js → chunk-CCGFRNAA.js} +6 -6
  9. package/dist/{chunk-CXMLAWC2.js → chunk-CSE44DPA.js} +2 -2
  10. package/dist/{chunk-NEQI2VLM.js → chunk-D235RJNO.js} +5 -5
  11. package/dist/{chunk-4SN5BCIG.js → chunk-GYQOZGGF.js} +2 -2
  12. package/dist/{chunk-LLKJAET2.js → chunk-HXICZG5J.js} +8 -16
  13. package/dist/chunk-JSBRDJBE.js +30 -0
  14. package/dist/chunk-KZB4ABIB.js +13 -0
  15. package/dist/{chunk-KGBMU76T.js → chunk-LBCPRHNG.js} +1 -1
  16. package/dist/{chunk-HMD5K6W7.js → chunk-LTTF4MBE.js} +2 -2
  17. package/dist/{chunk-JKO6PZWQ.js → chunk-MWNRXAEB.js} +26 -48
  18. package/dist/{chunk-6IRAGUYK.js → chunk-NQFRQ56V.js} +2 -2
  19. package/dist/{chunk-XG7S3LIL.js → chunk-P2O7NLVN.js} +887 -918
  20. package/dist/{chunk-J5HBSRAV.js → chunk-SLDZJD6Q.js} +1 -1
  21. package/dist/{chunk-4OEJ2ONG.js → chunk-TC4FTRYO.js} +2 -13
  22. package/dist/{chunk-6JHKKLA2.js → chunk-U67RBNIZ.js} +46 -46
  23. package/dist/{chunk-S55JKCHQ.js → chunk-VOC4KOOP.js} +2 -2
  24. package/dist/chunk-W27EFR7W.js +271 -0
  25. package/dist/{chunk-RLBASQJD.js → chunk-XWAKFL3T.js} +9 -7
  26. package/dist/daemon/server.js +2733 -2531
  27. package/dist/hook-runtime/daemon/server.js +2734 -2531
  28. package/dist/hook-runtime/hooks/post-commit.js +2741 -2538
  29. package/dist/hook-runtime/hooks/post-rewrite.js +2741 -2538
  30. package/dist/hook-runtime/hooks/post-tool-use.js +2883 -2579
  31. package/dist/hook-runtime/hooks/pre-commit.js +1 -0
  32. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +35089 -0
  33. package/dist/hook-runtime/hooks/pre-tool-use.js +109 -35539
  34. package/dist/hook-runtime/hooks/prim-hook.js +2875 -2571
  35. package/dist/hook-runtime/hooks/session-end.js +19 -16
  36. package/dist/hook-runtime/hooks/session-start.js +2834 -2632
  37. package/dist/hook-runtime/index.js +3030 -2830
  38. package/dist/hook-runtime/statusline-main.js +6 -2
  39. package/dist/hooks/post-commit.js +8 -7
  40. package/dist/hooks/post-rewrite.js +7 -6
  41. package/dist/hooks/post-tool-use.js +26 -22
  42. package/dist/hooks/pre-commit.js +5 -4
  43. package/dist/hooks/pre-tool-use-worker.js +264 -0
  44. package/dist/hooks/pre-tool-use.js +93 -250
  45. package/dist/hooks/prim-hook.js +26 -22
  46. package/dist/hooks/session-end.js +10 -7
  47. package/dist/hooks/session-start.js +22 -19
  48. package/dist/index.js +59 -54
  49. package/dist/statusline-main.js +5 -2
  50. package/package.json +3 -3
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire as __primCreateRequire } from "node:module"; const require = __primCreateRequire(import.meta.url);
2
3
 
3
4
  // src/daemon/principal.ts
4
5
  import { createHash as createHash2 } from "crypto";
@@ -501,7 +502,7 @@ var PRIM_ACTIVE_KEY = "prim.active";
501
502
  var GIT_TIMEOUT_MS2 = 1e3;
502
503
  var PROJECT_INSTALL_FILES = [".claude/settings.json", ".codex/hooks.json", ".cursor/hooks.json"];
503
504
  var PRIM_HOOK_BINS = ["prim-hook", "prim-pre-tool-use", "prim-post-tool-use"];
504
- function repoActiveFlag(cwd) {
505
+ function repoActiveFlag(cwd, strict = false) {
505
506
  try {
506
507
  const value = execFileSync2("git", ["config", "--get", PRIM_ACTIVE_KEY], {
507
508
  cwd,
@@ -511,8 +512,11 @@ function repoActiveFlag(cwd) {
511
512
  }).trim();
512
513
  if (value === "true") return "true";
513
514
  if (value === "false") return "false";
515
+ if (strict) throw new Error("Repository activation is invalid");
514
516
  return void 0;
515
- } catch {
517
+ } catch (error) {
518
+ if (strict && !(typeof error === "object" && error !== null && "status" in error && error.status === 1))
519
+ throw error;
516
520
  return void 0;
517
521
  }
518
522
  }
@@ -549,9 +553,9 @@ function parseAgent(argv) {
549
553
  }
550
554
 
551
555
  // src/commands/cursor-install.ts
552
- import { existsSync as existsSync6, readFileSync as readFileSync8 } from "fs";
556
+ import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
553
557
  import { homedir as homedir4 } from "os";
554
- import { isAbsolute as isAbsolute5, join as join10 } from "path";
558
+ import { isAbsolute as isAbsolute5, join as join9 } from "path";
555
559
 
556
560
  // src/lib/atomic-file.ts
557
561
  import { randomUUID } from "crypto";
@@ -691,6 +695,7 @@ var HOOK_RUNTIME_ENTRIES = {
691
695
  "prim-pre-commit": "dist/hooks/pre-commit.js",
692
696
  "prim-post-commit": "dist/hooks/post-commit.js",
693
697
  "prim-post-rewrite": "dist/hooks/post-rewrite.js",
698
+ "prim-pre-tool-use-worker": "dist/hooks/pre-tool-use-worker.js",
694
699
  "prim-pre-tool-use": "dist/hooks/pre-tool-use.js",
695
700
  "prim-post-tool-use": "dist/hooks/post-tool-use.js",
696
701
  "prim-session-start": "dist/hooks/session-start.js",
@@ -726,13 +731,11 @@ exec "$prim_node" "$prim_entry" "$@"
726
731
 
727
732
  // src/lib/preflight-host.ts
728
733
  import { execFileSync as execFileSync3 } from "child_process";
729
- import { readFileSync as readFileSync6 } from "fs";
730
- import { join as join8 } from "path";
731
734
 
732
735
  // src/commands/claude-install.ts
733
- import { existsSync as existsSync5, readFileSync as readFileSync7 } from "fs";
736
+ import { existsSync as existsSync5, readFileSync as readFileSync6 } from "fs";
734
737
  import { homedir as homedir3 } from "os";
735
- import { join as join9 } from "path";
738
+ import { join as join8 } from "path";
736
739
  var CAPTURE_BIN = "prim-hook";
737
740
  var GATE_BIN = "prim-pre-tool-use";
738
741
  var POST_TOOL_USE_BIN = "prim-post-tool-use";
@@ -741,7 +744,7 @@ var SESSION_END_BIN = "prim-session-end";
741
744
  var STATUSLINE_BIN = "prim-statusline";
742
745
  var STATUSLINE_ARGS = "";
743
746
  var STATUSLINE_COMMAND = stableHookCommand(STATUSLINE_BIN, STATUSLINE_ARGS);
744
- var USER_SCOPE_PATH = join9(homedir3(), ".claude", "settings.json");
747
+ var USER_SCOPE_PATH = join8(homedir3(), ".claude", "settings.json");
745
748
  function projectRoot() {
746
749
  return gitToplevel() ?? process.cwd();
747
750
  }
@@ -761,7 +764,7 @@ function makeRegistration(event, matcher, bin, args = "") {
761
764
  matcher,
762
765
  bin,
763
766
  command: stableHookCommand(bin, args),
764
- ...bin === GATE_BIN ? { timeout: 300, ...args.includes("--agent codex") ? {} : { onFailure: "block" } } : {}
767
+ ...bin === GATE_BIN ? { timeout: 2 } : {}
765
768
  };
766
769
  }
767
770
  function makeDetachedRegistration(event, matcher, bin, args = "") {
@@ -811,7 +814,7 @@ var CURSOR_EVENTS = [
811
814
  ];
812
815
  var REGISTRATIONS2 = [
813
816
  ...CURSOR_EVENTS.map((event) => ({ event, bin: CAPTURE_BIN2 })),
814
- { event: "preToolUse", bin: GATE_BIN2, matcher: "Write|Delete|Shell", timeout: 300 },
817
+ { event: "preToolUse", bin: GATE_BIN2, matcher: "Write|Delete|Shell", timeout: 2 },
815
818
  { event: "postToolUse", bin: POST_TOOL_BIN },
816
819
  { event: "postToolUseFailure", bin: POST_TOOL_BIN },
817
820
  { event: "sessionStart", bin: SESSION_START_BIN2 },
@@ -821,11 +824,11 @@ function cursorConfigDirectory(env = process.env, home = homedir4(), platform =
821
824
  const explicit = env.CURSOR_CONFIG_DIR?.trim();
822
825
  if (explicit && isAbsolute5(explicit)) return explicit;
823
826
  const xdg = env.XDG_CONFIG_HOME?.trim();
824
- if (platform !== "darwin" && xdg && isAbsolute5(xdg)) return join10(xdg, "cursor");
825
- return join10(home, ".cursor");
827
+ if (platform !== "darwin" && xdg && isAbsolute5(xdg)) return join9(xdg, "cursor");
828
+ return join9(home, ".cursor");
826
829
  }
827
830
  function cursorHooksPath(scope, root = projectRoot()) {
828
- return scope === "user" ? join10(cursorConfigDirectory(), "hooks.json") : join10(root, ".cursor", "hooks.json");
831
+ return scope === "user" ? join9(cursorConfigDirectory(), "hooks.json") : join9(root, ".cursor", "hooks.json");
829
832
  }
830
833
  function plainObject(value) {
831
834
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -834,7 +837,7 @@ function readCursorHooks(path) {
834
837
  if (!existsSync6(path)) return {};
835
838
  let parsed;
836
839
  try {
837
- parsed = JSON.parse(readFileSync8(path, "utf8"));
840
+ parsed = JSON.parse(readFileSync7(path, "utf8"));
838
841
  } catch {
839
842
  throw new Error(`invalid Cursor hooks JSON at ${path}`);
840
843
  }
@@ -872,7 +875,7 @@ function hookFor(registration, scope) {
872
875
  command: commandFor(registration, scope),
873
876
  ...registration.matcher ? { matcher: registration.matcher } : {},
874
877
  ...registration.timeout ? { timeout: registration.timeout } : {},
875
- ...registration.bin === GATE_BIN2 ? { failClosed: true } : {}
878
+ ...registration.bin === GATE_BIN2 ? { failClosed: false } : {}
876
879
  };
877
880
  }
878
881
  function exactHook(entry, registration, scope) {