@primitive.ai/prim 0.1.0-alpha.116 → 0.1.0-alpha.118
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.
- package/README.md +21 -21
- package/SKILL.md +3 -3
- package/dist/{chunk-XG7S3LIL.js → chunk-3NJ4FUPK.js} +889 -919
- package/dist/{chunk-J5HBSRAV.js → chunk-4HEWA4IO.js} +1 -1
- package/dist/{chunk-LEUZDTNT.js → chunk-B3FVP7VQ.js} +1 -1
- package/dist/{chunk-4OEJ2ONG.js → chunk-C2AEY4AI.js} +2 -13
- package/dist/{chunk-S55JKCHQ.js → chunk-C2AJBMP2.js} +2 -2
- package/dist/{chunk-D3ZDZZYS.js → chunk-CHRICRVE.js} +17 -10
- package/dist/{chunk-HMD5K6W7.js → chunk-ECP7EGOD.js} +2 -2
- package/dist/{chunk-FTW4ZCBA.js → chunk-FPDOBG3H.js} +1 -1
- package/dist/{chunk-3TIKBQHV.js → chunk-JGOFEG6T.js} +6 -4
- package/dist/chunk-JSBRDJBE.js +30 -0
- package/dist/{chunk-KGBMU76T.js → chunk-JXQVXU2K.js} +1 -1
- package/dist/chunk-KZB4ABIB.js +13 -0
- package/dist/{chunk-I3J344DF.js → chunk-L3NUFCOD.js} +5 -5
- package/dist/{chunk-6IRAGUYK.js → chunk-LEEWUN74.js} +2 -2
- package/dist/{chunk-JKJ22ONL.js → chunk-OHLVHT6R.js} +6 -6
- package/dist/{chunk-RLBASQJD.js → chunk-OIXHRN32.js} +4 -4
- package/dist/{chunk-LLKJAET2.js → chunk-PYIIYC3A.js} +8 -16
- package/dist/{chunk-NEQI2VLM.js → chunk-Q4CWXKNV.js} +5 -5
- package/dist/{chunk-4SN5BCIG.js → chunk-QX7QFMLF.js} +2 -2
- package/dist/{chunk-CXMLAWC2.js → chunk-SCOEPFOV.js} +2 -2
- package/dist/{chunk-6JHKKLA2.js → chunk-UMSJ4DU2.js} +46 -46
- package/dist/{chunk-JKO6PZWQ.js → chunk-VEI7KUOU.js} +26 -48
- package/dist/hook-runtime/daemon/server.js +1 -0
- package/dist/hook-runtime/hooks/post-commit.js +1 -0
- package/dist/hook-runtime/hooks/post-rewrite.js +1 -0
- package/dist/hook-runtime/hooks/post-tool-use.js +29 -29
- package/dist/hook-runtime/hooks/pre-commit.js +1 -0
- package/dist/hook-runtime/hooks/pre-tool-use-worker.js +34746 -0
- package/dist/hook-runtime/hooks/pre-tool-use.js +82 -35549
- package/dist/hook-runtime/hooks/prim-hook.js +22 -22
- package/dist/hook-runtime/hooks/session-end.js +14 -14
- package/dist/hook-runtime/hooks/session-start.js +100 -100
- package/dist/hook-runtime/index.js +244 -256
- package/dist/hook-runtime/statusline-main.js +1 -0
- package/dist/hooks/post-commit.js +8 -7
- package/dist/hooks/post-rewrite.js +7 -6
- package/dist/hooks/post-tool-use.js +25 -22
- package/dist/hooks/pre-commit.js +5 -4
- package/dist/hooks/pre-tool-use-worker.js +222 -0
- package/dist/hooks/pre-tool-use.js +73 -257
- package/dist/hooks/prim-hook.js +25 -22
- package/dist/hooks/session-end.js +10 -7
- package/dist/hooks/session-start.js +22 -19
- package/dist/index.js +54 -53
- 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
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -53,8 +54,8 @@ var require_ucs2length = __commonJS({
|
|
|
53
54
|
|
|
54
55
|
// src/hooks/prim-hook.ts
|
|
55
56
|
import { spawn } from "child_process";
|
|
56
|
-
import { readFileSync as
|
|
57
|
-
import { dirname as dirname13, join as
|
|
57
|
+
import { readFileSync as readFileSync18 } from "fs";
|
|
58
|
+
import { dirname as dirname13, join as join21 } from "path";
|
|
58
59
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
59
60
|
|
|
60
61
|
// src/binding.ts
|
|
@@ -1697,6 +1698,7 @@ var HOOK_RUNTIME_ENTRIES = {
|
|
|
1697
1698
|
"prim-pre-commit": "dist/hooks/pre-commit.js",
|
|
1698
1699
|
"prim-post-commit": "dist/hooks/post-commit.js",
|
|
1699
1700
|
"prim-post-rewrite": "dist/hooks/post-rewrite.js",
|
|
1701
|
+
"prim-pre-tool-use-worker": "dist/hooks/pre-tool-use-worker.js",
|
|
1700
1702
|
"prim-pre-tool-use": "dist/hooks/pre-tool-use.js",
|
|
1701
1703
|
"prim-post-tool-use": "dist/hooks/post-tool-use.js",
|
|
1702
1704
|
"prim-session-start": "dist/hooks/session-start.js",
|
|
@@ -25548,19 +25550,17 @@ async function processCodexMessageContext(envelope, deps = defaultDeps) {
|
|
|
25548
25550
|
}
|
|
25549
25551
|
|
|
25550
25552
|
// src/commands/cursor-install.ts
|
|
25551
|
-
import { existsSync as existsSync14, readFileSync as
|
|
25553
|
+
import { existsSync as existsSync14, readFileSync as readFileSync16 } from "fs";
|
|
25552
25554
|
import { homedir as homedir4 } from "os";
|
|
25553
|
-
import { isAbsolute as isAbsolute6, join as
|
|
25555
|
+
import { isAbsolute as isAbsolute6, join as join19 } from "path";
|
|
25554
25556
|
|
|
25555
25557
|
// src/lib/preflight-host.ts
|
|
25556
25558
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
25557
|
-
import { readFileSync as readFileSync15 } from "fs";
|
|
25558
|
-
import { join as join18 } from "path";
|
|
25559
25559
|
|
|
25560
25560
|
// src/commands/claude-install.ts
|
|
25561
|
-
import { existsSync as existsSync13, readFileSync as
|
|
25561
|
+
import { existsSync as existsSync13, readFileSync as readFileSync15 } from "fs";
|
|
25562
25562
|
import { homedir as homedir3 } from "os";
|
|
25563
|
-
import { join as
|
|
25563
|
+
import { join as join18 } from "path";
|
|
25564
25564
|
var CAPTURE_BIN = "prim-hook";
|
|
25565
25565
|
var GATE_BIN = "prim-pre-tool-use";
|
|
25566
25566
|
var POST_TOOL_USE_BIN = "prim-post-tool-use";
|
|
@@ -25569,7 +25569,7 @@ var SESSION_END_BIN = "prim-session-end";
|
|
|
25569
25569
|
var STATUSLINE_BIN = "prim-statusline";
|
|
25570
25570
|
var STATUSLINE_ARGS = "";
|
|
25571
25571
|
var STATUSLINE_COMMAND = stableHookCommand(STATUSLINE_BIN, STATUSLINE_ARGS);
|
|
25572
|
-
var USER_SCOPE_PATH =
|
|
25572
|
+
var USER_SCOPE_PATH = join18(homedir3(), ".claude", "settings.json");
|
|
25573
25573
|
function projectRoot() {
|
|
25574
25574
|
return gitToplevel() ?? process.cwd();
|
|
25575
25575
|
}
|
|
@@ -25589,7 +25589,7 @@ function makeRegistration(event, matcher, bin, args = "") {
|
|
|
25589
25589
|
matcher,
|
|
25590
25590
|
bin,
|
|
25591
25591
|
command: stableHookCommand(bin, args),
|
|
25592
|
-
...bin === GATE_BIN ? { timeout:
|
|
25592
|
+
...bin === GATE_BIN ? { timeout: 2 } : {}
|
|
25593
25593
|
};
|
|
25594
25594
|
}
|
|
25595
25595
|
function makeDetachedRegistration(event, matcher, bin, args = "") {
|
|
@@ -25639,7 +25639,7 @@ var CURSOR_EVENTS = [
|
|
|
25639
25639
|
];
|
|
25640
25640
|
var REGISTRATIONS2 = [
|
|
25641
25641
|
...CURSOR_EVENTS.map((event) => ({ event, bin: CAPTURE_BIN2 })),
|
|
25642
|
-
{ event: "preToolUse", bin: GATE_BIN2, matcher: "Write|Delete|Shell", timeout:
|
|
25642
|
+
{ event: "preToolUse", bin: GATE_BIN2, matcher: "Write|Delete|Shell", timeout: 2 },
|
|
25643
25643
|
{ event: "postToolUse", bin: POST_TOOL_BIN },
|
|
25644
25644
|
{ event: "postToolUseFailure", bin: POST_TOOL_BIN },
|
|
25645
25645
|
{ event: "sessionStart", bin: SESSION_START_BIN2 },
|
|
@@ -25649,11 +25649,11 @@ function cursorConfigDirectory(env = process.env, home = homedir4(), platform2 =
|
|
|
25649
25649
|
const explicit = env.CURSOR_CONFIG_DIR?.trim();
|
|
25650
25650
|
if (explicit && isAbsolute6(explicit)) return explicit;
|
|
25651
25651
|
const xdg = env.XDG_CONFIG_HOME?.trim();
|
|
25652
|
-
if (platform2 !== "darwin" && xdg && isAbsolute6(xdg)) return
|
|
25653
|
-
return
|
|
25652
|
+
if (platform2 !== "darwin" && xdg && isAbsolute6(xdg)) return join19(xdg, "cursor");
|
|
25653
|
+
return join19(home, ".cursor");
|
|
25654
25654
|
}
|
|
25655
25655
|
function cursorHooksPath(scope, root = projectRoot()) {
|
|
25656
|
-
return scope === "user" ?
|
|
25656
|
+
return scope === "user" ? join19(cursorConfigDirectory(), "hooks.json") : join19(root, ".cursor", "hooks.json");
|
|
25657
25657
|
}
|
|
25658
25658
|
function plainObject(value) {
|
|
25659
25659
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -25662,7 +25662,7 @@ function readCursorHooks(path) {
|
|
|
25662
25662
|
if (!existsSync14(path)) return {};
|
|
25663
25663
|
let parsed;
|
|
25664
25664
|
try {
|
|
25665
|
-
parsed = JSON.parse(
|
|
25665
|
+
parsed = JSON.parse(readFileSync16(path, "utf8"));
|
|
25666
25666
|
} catch {
|
|
25667
25667
|
throw new Error(`invalid Cursor hooks JSON at ${path}`);
|
|
25668
25668
|
}
|
|
@@ -25700,7 +25700,7 @@ function hookFor(registration, scope) {
|
|
|
25700
25700
|
command: commandFor(registration, scope),
|
|
25701
25701
|
...registration.matcher ? { matcher: registration.matcher } : {},
|
|
25702
25702
|
...registration.timeout ? { timeout: registration.timeout } : {},
|
|
25703
|
-
...registration.bin === GATE_BIN2 ? { failClosed:
|
|
25703
|
+
...registration.bin === GATE_BIN2 ? { failClosed: false } : {}
|
|
25704
25704
|
};
|
|
25705
25705
|
}
|
|
25706
25706
|
function exactHook(entry, registration, scope) {
|
|
@@ -25934,8 +25934,8 @@ function extractFileTargets(toolName, toolInput, agent = "claude_code") {
|
|
|
25934
25934
|
}
|
|
25935
25935
|
|
|
25936
25936
|
// src/hooks/redact.ts
|
|
25937
|
-
import { existsSync as existsSync15, readFileSync as
|
|
25938
|
-
import { join as
|
|
25937
|
+
import { existsSync as existsSync15, readFileSync as readFileSync17, statSync as statSync5 } from "fs";
|
|
25938
|
+
import { join as join20 } from "path";
|
|
25939
25939
|
import { Worker } from "worker_threads";
|
|
25940
25940
|
var USER_HOME_RULES = [
|
|
25941
25941
|
{
|
|
@@ -26011,7 +26011,7 @@ function normalizedWorkspaceFlags(value) {
|
|
|
26011
26011
|
return [...new Set(`g${requested}`)].sort().join("");
|
|
26012
26012
|
}
|
|
26013
26013
|
function loadWorkspaceRules(cwd) {
|
|
26014
|
-
const path =
|
|
26014
|
+
const path = join20(cwd, WORKSPACE_FILE2);
|
|
26015
26015
|
if (!existsSync15(path)) return [];
|
|
26016
26016
|
let cfg;
|
|
26017
26017
|
try {
|
|
@@ -26019,7 +26019,7 @@ function loadWorkspaceRules(cwd) {
|
|
|
26019
26019
|
debugRedaction(`ignoring oversized ${WORKSPACE_FILE2}`);
|
|
26020
26020
|
return [];
|
|
26021
26021
|
}
|
|
26022
|
-
cfg = JSON.parse(
|
|
26022
|
+
cfg = JSON.parse(readFileSync17(path, "utf-8"));
|
|
26023
26023
|
} catch {
|
|
26024
26024
|
debugRedaction(`ignoring unparseable ${WORKSPACE_FILE2}`);
|
|
26025
26025
|
return [];
|
|
@@ -35775,14 +35775,14 @@ function emitOutput(output, acknowledge) {
|
|
|
35775
35775
|
}
|
|
35776
35776
|
function resolveCliVersion() {
|
|
35777
35777
|
try {
|
|
35778
|
-
const pkg = JSON.parse(
|
|
35778
|
+
const pkg = JSON.parse(readFileSync18(join21(here, "..", "..", "package.json"), "utf-8"));
|
|
35779
35779
|
return pkg.version ?? "unknown";
|
|
35780
35780
|
} catch {
|
|
35781
35781
|
return "unknown";
|
|
35782
35782
|
}
|
|
35783
35783
|
}
|
|
35784
35784
|
function spawnBackgroundFlush() {
|
|
35785
|
-
const entry =
|
|
35785
|
+
const entry = join21(here, "..", "index.js");
|
|
35786
35786
|
spawn(process.execPath, [entry, "moves", "flush"], {
|
|
35787
35787
|
detached: true,
|
|
35788
35788
|
stdio: "ignore",
|
|
@@ -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";
|
|
@@ -549,9 +550,9 @@ function parseAgent(argv) {
|
|
|
549
550
|
}
|
|
550
551
|
|
|
551
552
|
// src/commands/cursor-install.ts
|
|
552
|
-
import { existsSync as existsSync6, readFileSync as
|
|
553
|
+
import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
|
|
553
554
|
import { homedir as homedir4 } from "os";
|
|
554
|
-
import { isAbsolute as isAbsolute5, join as
|
|
555
|
+
import { isAbsolute as isAbsolute5, join as join9 } from "path";
|
|
555
556
|
|
|
556
557
|
// src/lib/atomic-file.ts
|
|
557
558
|
import { randomUUID } from "crypto";
|
|
@@ -691,6 +692,7 @@ var HOOK_RUNTIME_ENTRIES = {
|
|
|
691
692
|
"prim-pre-commit": "dist/hooks/pre-commit.js",
|
|
692
693
|
"prim-post-commit": "dist/hooks/post-commit.js",
|
|
693
694
|
"prim-post-rewrite": "dist/hooks/post-rewrite.js",
|
|
695
|
+
"prim-pre-tool-use-worker": "dist/hooks/pre-tool-use-worker.js",
|
|
694
696
|
"prim-pre-tool-use": "dist/hooks/pre-tool-use.js",
|
|
695
697
|
"prim-post-tool-use": "dist/hooks/post-tool-use.js",
|
|
696
698
|
"prim-session-start": "dist/hooks/session-start.js",
|
|
@@ -726,13 +728,11 @@ exec "$prim_node" "$prim_entry" "$@"
|
|
|
726
728
|
|
|
727
729
|
// src/lib/preflight-host.ts
|
|
728
730
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
729
|
-
import { readFileSync as readFileSync6 } from "fs";
|
|
730
|
-
import { join as join8 } from "path";
|
|
731
731
|
|
|
732
732
|
// src/commands/claude-install.ts
|
|
733
|
-
import { existsSync as existsSync5, readFileSync as
|
|
733
|
+
import { existsSync as existsSync5, readFileSync as readFileSync6 } from "fs";
|
|
734
734
|
import { homedir as homedir3 } from "os";
|
|
735
|
-
import { join as
|
|
735
|
+
import { join as join8 } from "path";
|
|
736
736
|
var CAPTURE_BIN = "prim-hook";
|
|
737
737
|
var GATE_BIN = "prim-pre-tool-use";
|
|
738
738
|
var POST_TOOL_USE_BIN = "prim-post-tool-use";
|
|
@@ -741,7 +741,7 @@ var SESSION_END_BIN = "prim-session-end";
|
|
|
741
741
|
var STATUSLINE_BIN = "prim-statusline";
|
|
742
742
|
var STATUSLINE_ARGS = "";
|
|
743
743
|
var STATUSLINE_COMMAND = stableHookCommand(STATUSLINE_BIN, STATUSLINE_ARGS);
|
|
744
|
-
var USER_SCOPE_PATH =
|
|
744
|
+
var USER_SCOPE_PATH = join8(homedir3(), ".claude", "settings.json");
|
|
745
745
|
function projectRoot() {
|
|
746
746
|
return gitToplevel() ?? process.cwd();
|
|
747
747
|
}
|
|
@@ -761,7 +761,7 @@ function makeRegistration(event, matcher, bin, args = "") {
|
|
|
761
761
|
matcher,
|
|
762
762
|
bin,
|
|
763
763
|
command: stableHookCommand(bin, args),
|
|
764
|
-
...bin === GATE_BIN ? { timeout:
|
|
764
|
+
...bin === GATE_BIN ? { timeout: 2 } : {}
|
|
765
765
|
};
|
|
766
766
|
}
|
|
767
767
|
function makeDetachedRegistration(event, matcher, bin, args = "") {
|
|
@@ -811,7 +811,7 @@ var CURSOR_EVENTS = [
|
|
|
811
811
|
];
|
|
812
812
|
var REGISTRATIONS2 = [
|
|
813
813
|
...CURSOR_EVENTS.map((event) => ({ event, bin: CAPTURE_BIN2 })),
|
|
814
|
-
{ event: "preToolUse", bin: GATE_BIN2, matcher: "Write|Delete|Shell", timeout:
|
|
814
|
+
{ event: "preToolUse", bin: GATE_BIN2, matcher: "Write|Delete|Shell", timeout: 2 },
|
|
815
815
|
{ event: "postToolUse", bin: POST_TOOL_BIN },
|
|
816
816
|
{ event: "postToolUseFailure", bin: POST_TOOL_BIN },
|
|
817
817
|
{ event: "sessionStart", bin: SESSION_START_BIN2 },
|
|
@@ -821,11 +821,11 @@ function cursorConfigDirectory(env = process.env, home = homedir4(), platform =
|
|
|
821
821
|
const explicit = env.CURSOR_CONFIG_DIR?.trim();
|
|
822
822
|
if (explicit && isAbsolute5(explicit)) return explicit;
|
|
823
823
|
const xdg = env.XDG_CONFIG_HOME?.trim();
|
|
824
|
-
if (platform !== "darwin" && xdg && isAbsolute5(xdg)) return
|
|
825
|
-
return
|
|
824
|
+
if (platform !== "darwin" && xdg && isAbsolute5(xdg)) return join9(xdg, "cursor");
|
|
825
|
+
return join9(home, ".cursor");
|
|
826
826
|
}
|
|
827
827
|
function cursorHooksPath(scope, root = projectRoot()) {
|
|
828
|
-
return scope === "user" ?
|
|
828
|
+
return scope === "user" ? join9(cursorConfigDirectory(), "hooks.json") : join9(root, ".cursor", "hooks.json");
|
|
829
829
|
}
|
|
830
830
|
function plainObject(value) {
|
|
831
831
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -834,7 +834,7 @@ function readCursorHooks(path) {
|
|
|
834
834
|
if (!existsSync6(path)) return {};
|
|
835
835
|
let parsed;
|
|
836
836
|
try {
|
|
837
|
-
parsed = JSON.parse(
|
|
837
|
+
parsed = JSON.parse(readFileSync7(path, "utf8"));
|
|
838
838
|
} catch {
|
|
839
839
|
throw new Error(`invalid Cursor hooks JSON at ${path}`);
|
|
840
840
|
}
|
|
@@ -872,7 +872,7 @@ function hookFor(registration, scope) {
|
|
|
872
872
|
command: commandFor(registration, scope),
|
|
873
873
|
...registration.matcher ? { matcher: registration.matcher } : {},
|
|
874
874
|
...registration.timeout ? { timeout: registration.timeout } : {},
|
|
875
|
-
...registration.bin === GATE_BIN2 ? { failClosed:
|
|
875
|
+
...registration.bin === GATE_BIN2 ? { failClosed: false } : {}
|
|
876
876
|
};
|
|
877
877
|
}
|
|
878
878
|
function exactHook(entry, registration, scope) {
|