@primitive.ai/prim 0.1.0-alpha.118 → 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 (45) hide show
  1. package/dist/{chunk-FPDOBG3H.js → chunk-2AKDX4RU.js} +1 -1
  2. package/dist/{chunk-CHRICRVE.js → chunk-2JA524SC.js} +21 -14
  3. package/dist/{chunk-L3NUFCOD.js → chunk-4L7TAM5S.js} +120 -285
  4. package/dist/{chunk-JGOFEG6T.js → chunk-5BQ2NEMP.js} +2732 -2533
  5. package/dist/{chunk-B3FVP7VQ.js → chunk-A6M2M5A2.js} +1 -1
  6. package/dist/{chunk-OHLVHT6R.js → chunk-CCGFRNAA.js} +3 -3
  7. package/dist/{chunk-SCOEPFOV.js → chunk-CSE44DPA.js} +2 -2
  8. package/dist/{chunk-Q4CWXKNV.js → chunk-D235RJNO.js} +3 -3
  9. package/dist/{chunk-QX7QFMLF.js → chunk-GYQOZGGF.js} +2 -2
  10. package/dist/{chunk-PYIIYC3A.js → chunk-HXICZG5J.js} +4 -4
  11. package/dist/{chunk-JXQVXU2K.js → chunk-LBCPRHNG.js} +1 -1
  12. package/dist/{chunk-ECP7EGOD.js → chunk-LTTF4MBE.js} +2 -2
  13. package/dist/{chunk-VEI7KUOU.js → chunk-MWNRXAEB.js} +1 -1
  14. package/dist/{chunk-LEEWUN74.js → chunk-NQFRQ56V.js} +2 -2
  15. package/dist/{chunk-3NJ4FUPK.js → chunk-P2O7NLVN.js} +5 -6
  16. package/dist/{chunk-4HEWA4IO.js → chunk-SLDZJD6Q.js} +1 -1
  17. package/dist/{chunk-C2AEY4AI.js → chunk-TC4FTRYO.js} +2 -2
  18. package/dist/{chunk-UMSJ4DU2.js → chunk-U67RBNIZ.js} +1 -1
  19. package/dist/{chunk-C2AJBMP2.js → chunk-VOC4KOOP.js} +2 -2
  20. package/dist/chunk-W27EFR7W.js +271 -0
  21. package/dist/{chunk-OIXHRN32.js → chunk-XWAKFL3T.js} +9 -7
  22. package/dist/daemon/server.js +2733 -2531
  23. package/dist/hook-runtime/daemon/server.js +2733 -2531
  24. package/dist/hook-runtime/hooks/post-commit.js +2740 -2538
  25. package/dist/hook-runtime/hooks/post-rewrite.js +2740 -2538
  26. package/dist/hook-runtime/hooks/post-tool-use.js +2854 -2550
  27. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +2907 -2564
  28. package/dist/hook-runtime/hooks/pre-tool-use.js +36 -1
  29. package/dist/hook-runtime/hooks/prim-hook.js +2853 -2549
  30. package/dist/hook-runtime/hooks/session-end.js +5 -2
  31. package/dist/hook-runtime/hooks/session-start.js +2740 -2538
  32. package/dist/hook-runtime/index.js +2793 -2581
  33. package/dist/hook-runtime/statusline-main.js +5 -2
  34. package/dist/hooks/post-commit.js +7 -7
  35. package/dist/hooks/post-rewrite.js +6 -6
  36. package/dist/hooks/post-tool-use.js +16 -15
  37. package/dist/hooks/pre-commit.js +4 -4
  38. package/dist/hooks/pre-tool-use-worker.js +77 -35
  39. package/dist/hooks/pre-tool-use.js +26 -1
  40. package/dist/hooks/prim-hook.js +17 -16
  41. package/dist/hooks/session-end.js +4 -4
  42. package/dist/hooks/session-start.js +11 -11
  43. package/dist/index.js +20 -16
  44. package/dist/statusline-main.js +5 -2
  45. package/package.json +1 -1
@@ -15,6 +15,19 @@ function parseAgent(argv) {
15
15
  return "claude_code";
16
16
  }
17
17
 
18
+ // src/hooks/pre-tool-use-scoring.ts
19
+ import { isAbsolute, relative, sep } from "path";
20
+ function readHookMode(env) {
21
+ if (env.PRIM_BYPASS === "1" || env.PRIM_BYPASS === "true") {
22
+ return "off";
23
+ }
24
+ const mode = env.PRIM_HOOK_MODE;
25
+ if (mode === "off" || mode === "warn") {
26
+ return mode;
27
+ }
28
+ return "block";
29
+ }
30
+
18
31
  // src/hooks/pre-tool-use.ts
19
32
  var BUDGET_MS = 2e3;
20
33
  var OUTPUT_RESERVE_MS = 150;
@@ -28,6 +41,28 @@ var child;
28
41
  var finished = false;
29
42
  var stdout = "";
30
43
  var stderr = "";
44
+ var input = "";
45
+ var pauseReason = "[primitive] Operation paused: shell evaluation did not finish within two seconds. Retry the tool call to validate the current invocation.";
46
+ function fallback() {
47
+ if (readHookMode(process.env) === "off" || agent !== "claude_code" && agent !== "codex")
48
+ return silent;
49
+ try {
50
+ const envelope = JSON.parse(input);
51
+ if (envelope?.hook_event_name !== "PreToolUse" || envelope?.tool_name !== "Bash") return silent;
52
+ } catch {
53
+ return silent;
54
+ }
55
+ return {
56
+ hookSpecificOutput: {
57
+ hookEventName: "PreToolUse",
58
+ permissionDecision: "deny",
59
+ permissionDecisionReason: pauseReason
60
+ }
61
+ };
62
+ }
63
+ process.stdin.setEncoding("utf8").on("data", (chunk) => {
64
+ input += chunk;
65
+ });
31
66
  function stopWorker() {
32
67
  if (!child?.pid) return;
33
68
  try {
@@ -36,7 +71,7 @@ function stopWorker() {
36
71
  } catch {
37
72
  }
38
73
  }
39
- function finish(output = silent, diagnostics = "") {
74
+ function finish(output = fallback(), diagnostics = "") {
40
75
  if (finished) return;
41
76
  finished = true;
42
77
  clearTimeout(timer);