@primitive.ai/prim 0.1.0-alpha.62 → 0.1.0-alpha.64
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/dist/{chunk-QGVHLP5J.js → chunk-7X7SFOPJ.js} +54 -5
- package/dist/{chunk-I3HIPAIR.js → chunk-CPX3BUOC.js} +7 -4
- package/dist/chunk-G5D3FF3D.js +853 -0
- package/dist/{chunk-S4LFRVGD.js → chunk-HIMWM526.js} +1 -1
- package/dist/{chunk-R4CUX6FY.js → chunk-KHZNYEUV.js} +1 -1
- package/dist/{chunk-KBFFVYBC.js → chunk-LNU44OJV.js} +3 -5
- package/dist/{chunk-LOGW54W5.js → chunk-MCPHIB4W.js} +18 -7
- package/dist/{chunk-DA4BMHEB.js → chunk-VYGY3OOX.js} +2 -2
- package/dist/{chunk-YITJ2H3B.js → chunk-WS3MCNFD.js} +1 -1
- package/dist/daemon/server.js +343 -44
- package/dist/hooks/post-commit.js +30 -6
- package/dist/hooks/post-tool-use.js +32 -20
- package/dist/hooks/pre-commit.js +2 -2
- package/dist/hooks/pre-tool-use.js +11 -3
- package/dist/hooks/prim-hook.js +7 -7
- package/dist/hooks/session-start.js +15 -14
- package/dist/index.js +236 -139
- package/dist/statusline-main.js +50 -40
- package/package.json +1 -1
- package/dist/chunk-GF5QII7T.js +0 -411
|
@@ -7,24 +7,25 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
enrichHookPayloadWithFileRefs,
|
|
9
9
|
preserveHookFileMetadata
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-VYGY3OOX.js";
|
|
11
11
|
import {
|
|
12
12
|
postToolInvocationId,
|
|
13
|
-
toMove
|
|
14
|
-
|
|
13
|
+
toMove,
|
|
14
|
+
toolOutcomeFor
|
|
15
|
+
} from "../chunk-7X7SFOPJ.js";
|
|
15
16
|
import {
|
|
16
17
|
appendMove,
|
|
17
18
|
resolveOrg
|
|
18
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-HIMWM526.js";
|
|
19
20
|
import {
|
|
20
21
|
scrubFromCwd
|
|
21
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-G5D3FF3D.js";
|
|
22
23
|
import {
|
|
23
24
|
getOrCreateWorkspaceId
|
|
24
25
|
} from "../chunk-UVIWZWM6.js";
|
|
25
26
|
import {
|
|
26
27
|
warmBinCache
|
|
27
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-LNU44OJV.js";
|
|
28
29
|
import {
|
|
29
30
|
isRepoActiveForCapture,
|
|
30
31
|
repoSyncId,
|
|
@@ -32,7 +33,7 @@ import {
|
|
|
32
33
|
} from "../chunk-XTNMSS4C.js";
|
|
33
34
|
import {
|
|
34
35
|
getClient
|
|
35
|
-
} from "../chunk-
|
|
36
|
+
} from "../chunk-CPX3BUOC.js";
|
|
36
37
|
import {
|
|
37
38
|
normalizeEnvelope,
|
|
38
39
|
parseAgent
|
|
@@ -74,7 +75,7 @@ function isVerdictFooterContext(value) {
|
|
|
74
75
|
// src/hooks/post-tool-use.ts
|
|
75
76
|
var STDIN_TIMEOUT_MS = 1e3;
|
|
76
77
|
var EDITING_TOOLS = /* @__PURE__ */ new Set(["Edit", "Write", "MultiEdit", "NotebookEdit", "Bash"]);
|
|
77
|
-
var CODEX_EDITING_TOOLS = /* @__PURE__ */ new Set(["apply_patch"]);
|
|
78
|
+
var CODEX_EDITING_TOOLS = /* @__PURE__ */ new Set(["apply_patch", "Bash"]);
|
|
78
79
|
var HERMES_EDITING_TOOLS = /* @__PURE__ */ new Set(["write_file", "patch"]);
|
|
79
80
|
function editingToolsFor(agent) {
|
|
80
81
|
if (agent === "codex") {
|
|
@@ -137,17 +138,27 @@ async function main() {
|
|
|
137
138
|
emit();
|
|
138
139
|
return;
|
|
139
140
|
}
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
let envelope = parsed;
|
|
142
|
+
const isToolResult = envelope.hook_event_name === "PostToolUse" || agent === "claude_code" && envelope.hook_event_name === "PostToolUseFailure";
|
|
143
|
+
const isHermesDenial = agent === "hermes" && envelope.hook_event_name === "post_approval_response" && toolOutcomeFor(parsed, agent) === "prevented";
|
|
144
|
+
if (!isToolResult && !isHermesDenial) {
|
|
145
|
+
emit();
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const invocationId = postToolInvocationId(parsed, agent);
|
|
149
|
+
if (isHermesDenial && !invocationId) {
|
|
142
150
|
emit();
|
|
143
151
|
return;
|
|
144
152
|
}
|
|
145
153
|
const toolName = typeof envelope.tool_name === "string" ? envelope.tool_name : "";
|
|
146
|
-
|
|
147
|
-
if (!editingTools.has(toolName)) {
|
|
154
|
+
if (!isHermesDenial && !editingToolsFor(agent).has(toolName)) {
|
|
148
155
|
emit();
|
|
149
156
|
return;
|
|
150
157
|
}
|
|
158
|
+
if (isHermesDenial && (typeof envelope.session_id !== "string" || envelope.session_id.length === 0) && typeof envelope.extra?.session_key === "string" && envelope.extra.session_key.length > 0) {
|
|
159
|
+
parsed = { ...parsed, session_id: envelope.extra.session_key };
|
|
160
|
+
envelope = parsed;
|
|
161
|
+
}
|
|
151
162
|
if (typeof envelope.session_id !== "string" || envelope.session_id.length === 0) {
|
|
152
163
|
emit();
|
|
153
164
|
return;
|
|
@@ -170,18 +181,19 @@ async function main() {
|
|
|
170
181
|
repository
|
|
171
182
|
});
|
|
172
183
|
const { resolution } = enrichment;
|
|
173
|
-
if (
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
184
|
+
if (!isHermesDenial) {
|
|
185
|
+
if (resolution.shellMutation === "none") {
|
|
186
|
+
emit();
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (resolution.shellMutation === void 0 && resolution.fileRefs.length === 0) {
|
|
190
|
+
emit();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
180
193
|
}
|
|
181
194
|
const enriched = enrichment.parsed;
|
|
182
195
|
const identity = getOrCreateWorkspaceId(cwd);
|
|
183
196
|
const workspaceId = identity.status === "ready" ? identity.workspaceId : void 0;
|
|
184
|
-
const invocationId = postToolInvocationId(enriched, agent);
|
|
185
197
|
const base = toMove(enriched, resolveCliVersion(), agent, workspaceId, repository, invocationId);
|
|
186
198
|
const scrubbed = scrubFromCwd(enriched, cwd);
|
|
187
199
|
const move = {
|
package/dist/hooks/pre-commit.js
CHANGED
|
@@ -12,10 +12,11 @@ import {
|
|
|
12
12
|
failOpenOutput,
|
|
13
13
|
readHookMode,
|
|
14
14
|
scrub
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-G5D3FF3D.js";
|
|
16
16
|
import {
|
|
17
|
+
packageVersion,
|
|
17
18
|
warmBinCache
|
|
18
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-LNU44OJV.js";
|
|
19
20
|
import {
|
|
20
21
|
canonicalGitRoot,
|
|
21
22
|
canonicalRepositoryPath,
|
|
@@ -24,7 +25,7 @@ import {
|
|
|
24
25
|
} from "../chunk-XTNMSS4C.js";
|
|
25
26
|
import {
|
|
26
27
|
getClient
|
|
27
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-CPX3BUOC.js";
|
|
28
29
|
import {
|
|
29
30
|
normalizeEnvelope,
|
|
30
31
|
parseAgent
|
|
@@ -36,6 +37,11 @@ var PREFLIGHT_PROTOCOL_VERSION = 3;
|
|
|
36
37
|
var PREFLIGHT_TIMEOUT_MS = 6500;
|
|
37
38
|
var MAX_PREFLIGHT_PATHS = 32;
|
|
38
39
|
var MAX_PROPOSAL_BYTES = 6144;
|
|
40
|
+
var MAX_CLIENT_VERSION_CHARS = 32;
|
|
41
|
+
var CLIENT_VERSION_RE = /^[A-Za-z0-9][A-Za-z0-9._+-]*$/;
|
|
42
|
+
function boundedClientVersion(raw) {
|
|
43
|
+
return typeof raw === "string" && raw.length <= MAX_CLIENT_VERSION_CHARS && CLIENT_VERSION_RE.test(raw) ? raw : "unknown";
|
|
44
|
+
}
|
|
39
45
|
function resolvePreflightTargets(args) {
|
|
40
46
|
let rawPaths;
|
|
41
47
|
let coverage = "complete";
|
|
@@ -224,6 +230,8 @@ async function main() {
|
|
|
224
230
|
const request = {
|
|
225
231
|
protocolVersion: PREFLIGHT_PROTOCOL_VERSION,
|
|
226
232
|
agent,
|
|
233
|
+
clientMode: mode,
|
|
234
|
+
clientVersion: boundedClientVersion(packageVersion()),
|
|
227
235
|
sessionId,
|
|
228
236
|
invocationId: callId,
|
|
229
237
|
repoSyncId: binding,
|
package/dist/hooks/prim-hook.js
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
import {
|
|
3
3
|
enrichHookPayloadWithFileRefs,
|
|
4
4
|
preserveHookFileMetadata
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-VYGY3OOX.js";
|
|
6
6
|
import {
|
|
7
7
|
postToolInvocationId,
|
|
8
8
|
shouldFlushAfter,
|
|
9
9
|
toMove
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-7X7SFOPJ.js";
|
|
11
11
|
import {
|
|
12
12
|
appendMove,
|
|
13
13
|
resolveOrg
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-HIMWM526.js";
|
|
15
15
|
import {
|
|
16
16
|
scrubFromCwd
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-G5D3FF3D.js";
|
|
18
18
|
import {
|
|
19
19
|
buildHookOutput,
|
|
20
20
|
handoffHookOutput
|
|
@@ -24,19 +24,19 @@ import {
|
|
|
24
24
|
acknowledgeDecisionFeedback,
|
|
25
25
|
leaseDecisionFeedback,
|
|
26
26
|
renderFeedback
|
|
27
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-KHZNYEUV.js";
|
|
28
28
|
import {
|
|
29
29
|
getOrCreateWorkspaceId
|
|
30
30
|
} from "../chunk-UVIWZWM6.js";
|
|
31
31
|
import {
|
|
32
32
|
warmBinCache
|
|
33
|
-
} from "../chunk-
|
|
33
|
+
} from "../chunk-LNU44OJV.js";
|
|
34
34
|
import {
|
|
35
35
|
isRepoActiveForCapture,
|
|
36
36
|
repoSyncId,
|
|
37
37
|
resolveRepositoryContext
|
|
38
38
|
} from "../chunk-XTNMSS4C.js";
|
|
39
|
-
import "../chunk-
|
|
39
|
+
import "../chunk-CPX3BUOC.js";
|
|
40
40
|
import {
|
|
41
41
|
normalizeEnvelope,
|
|
42
42
|
parseAgent
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
ensureEffectivePostCommitHook,
|
|
5
5
|
hasUsableCodexGuidance,
|
|
6
6
|
refreshClaudePlugins
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-MCPHIB4W.js";
|
|
8
8
|
import {
|
|
9
9
|
buildHookOutput,
|
|
10
10
|
handoffHookOutput
|
|
@@ -14,25 +14,24 @@ import {
|
|
|
14
14
|
acknowledgeDecisionFeedback,
|
|
15
15
|
leaseDecisionFeedback,
|
|
16
16
|
renderFeedback
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-KHZNYEUV.js";
|
|
18
18
|
import {
|
|
19
19
|
getOrCreateWorkspaceId
|
|
20
20
|
} from "../chunk-UVIWZWM6.js";
|
|
21
21
|
import {
|
|
22
22
|
binFile,
|
|
23
23
|
warmBinCache
|
|
24
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-LNU44OJV.js";
|
|
25
25
|
import {
|
|
26
26
|
gitToplevel,
|
|
27
27
|
isRepoActiveForCapture,
|
|
28
28
|
repoActiveFlag,
|
|
29
|
-
repoSyncId,
|
|
30
29
|
setRepoActive
|
|
31
30
|
} from "../chunk-XTNMSS4C.js";
|
|
32
31
|
import {
|
|
33
32
|
getSiteUrl,
|
|
34
33
|
isSessionEnded
|
|
35
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-CPX3BUOC.js";
|
|
36
35
|
import {
|
|
37
36
|
daemonRequest
|
|
38
37
|
} from "../chunk-UTKQTZHL.js";
|
|
@@ -49,9 +48,13 @@ function kickDaemonEnsure(options = {}) {
|
|
|
49
48
|
return false;
|
|
50
49
|
}
|
|
51
50
|
try {
|
|
51
|
+
const args = [primEntry, "daemon", "ensure"];
|
|
52
|
+
if ((options.platform ?? process.platform) === "darwin") {
|
|
53
|
+
args.push("--latest-bootstrap");
|
|
54
|
+
}
|
|
52
55
|
const child = (options.spawnProcess ?? spawn)(
|
|
53
56
|
options.nodeEntry ?? process.execPath,
|
|
54
|
-
|
|
57
|
+
args,
|
|
55
58
|
{ detached: true, stdio: "ignore" }
|
|
56
59
|
);
|
|
57
60
|
child.unref();
|
|
@@ -98,14 +101,12 @@ async function activeProjectRoot(cwd) {
|
|
|
98
101
|
} catch {
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
} catch {
|
|
108
|
-
}
|
|
104
|
+
try {
|
|
105
|
+
await bindRepository(root, {
|
|
106
|
+
signal: AbortSignal.timeout(REPOSITORY_BIND_TIMEOUT_MS),
|
|
107
|
+
quietRefresh: true
|
|
108
|
+
});
|
|
109
|
+
} catch {
|
|
109
110
|
}
|
|
110
111
|
return root;
|
|
111
112
|
} catch {
|