@primitive.ai/prim 0.1.0-alpha.122 → 0.1.0-alpha.124
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 +81 -5
- package/dist/{chunk-5ME3WD3P.js → chunk-3OKVMKK2.js} +6 -3
- package/dist/chunk-5BZWFN62.js +206 -0
- package/dist/{chunk-QG3GASJO.js → chunk-5KPDY5GF.js} +4 -4
- package/dist/{chunk-HLMC7VS4.js → chunk-5MH2C5QG.js} +3878 -2644
- package/dist/{chunk-NMZSCSMY.js → chunk-6PSCGY2A.js} +11 -1
- package/dist/{chunk-OXW6PSPT.js → chunk-6VJ7C2B5.js} +15 -3
- package/dist/{chunk-DQ4I3FLF.js → chunk-6W72SEXC.js} +3 -3
- package/dist/{chunk-4M23K2KZ.js → chunk-6WKJWW6D.js} +2 -2
- package/dist/{chunk-JYPVPYW3.js → chunk-A6YTFBQ4.js} +3 -3
- package/dist/{chunk-7LXRFXZG.js → chunk-DGZX3MID.js} +3 -3
- package/dist/{chunk-4NUGCUQC.js → chunk-EER7VG3P.js} +2 -2
- package/dist/{chunk-JZC2LHS6.js → chunk-EWV7VIZ3.js} +1 -1
- package/dist/{chunk-WN7OURQ3.js → chunk-KMWXI7KO.js} +1 -1
- package/dist/{chunk-HG7FJK7R.js → chunk-KTXJJE5K.js} +2 -2
- package/dist/{chunk-4GYJHN26.js → chunk-Q2PVD5W2.js} +1575 -549
- package/dist/{chunk-S3ZIMGXV.js → chunk-QZWLZH6D.js} +76 -2
- package/dist/{chunk-ZQ7UK5US.js → chunk-TS2NX6YT.js} +31 -9
- package/dist/{chunk-AKGRY7OU.js → chunk-WLVEXOHC.js} +145 -63
- package/dist/{chunk-FT673ALA.js → chunk-WQFJ5TEG.js} +2 -2
- package/dist/{chunk-T2T45KF6.js → chunk-ZMH6GJUG.js} +4 -4
- package/dist/daemon/server.js +7795 -5449
- package/dist/hook-runtime/daemon/server.js +7795 -5449
- package/dist/hook-runtime/hooks/post-commit.js +5828 -4329
- package/dist/hook-runtime/hooks/post-rewrite.js +4331 -2833
- package/dist/hook-runtime/hooks/post-tool-use.js +5242 -2892
- package/dist/hook-runtime/hooks/pre-commit.js +1253 -280
- package/dist/hook-runtime/hooks/pre-tool-use-worker.js +4272 -1982
- package/dist/hook-runtime/hooks/pre-tool-use.js +13 -3
- package/dist/hook-runtime/hooks/prim-hook.js +4719 -2479
- package/dist/hook-runtime/hooks/session-end.js +393 -140
- package/dist/hook-runtime/hooks/session-start.js +4207 -1998
- package/dist/hook-runtime/index.js +6157 -3544
- package/dist/hook-runtime/statusline-main.js +368 -122
- package/dist/hooks/post-commit.js +7 -7
- package/dist/hooks/post-rewrite.js +6 -6
- package/dist/hooks/post-tool-use.js +31 -21
- package/dist/hooks/pre-commit.js +4 -4
- package/dist/hooks/pre-tool-use-worker.js +88 -18
- package/dist/hooks/pre-tool-use.js +13 -3
- package/dist/hooks/prim-hook.js +16 -16
- package/dist/hooks/session-end.js +4 -4
- package/dist/hooks/session-start.js +16 -12
- package/dist/index.js +230 -150
- package/dist/statusline-main.js +368 -122
- package/package.json +5 -2
- package/dist/chunk-RRAC76LJ.js +0 -36
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
recordPostCommitFired
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-KMWXI7KO.js";
|
|
5
5
|
import {
|
|
6
6
|
unattendedEnv
|
|
7
7
|
} from "../chunk-OYHYCK4K.js";
|
|
8
8
|
import {
|
|
9
9
|
commitAttributionFromEnvironment,
|
|
10
10
|
toCommitMove
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-6WKJWW6D.js";
|
|
12
12
|
import {
|
|
13
13
|
getOrCreateWorkspaceId
|
|
14
14
|
} from "../chunk-EZXEWFDG.js";
|
|
15
15
|
import {
|
|
16
16
|
appendMove,
|
|
17
17
|
resolveOrg
|
|
18
|
-
} from "../chunk-
|
|
19
|
-
import "../chunk-
|
|
18
|
+
} from "../chunk-6VJ7C2B5.js";
|
|
19
|
+
import "../chunk-EER7VG3P.js";
|
|
20
20
|
import {
|
|
21
21
|
cachedCollectScopeAdmits
|
|
22
|
-
} from "../chunk-
|
|
23
|
-
import "../chunk-
|
|
22
|
+
} from "../chunk-5MH2C5QG.js";
|
|
23
|
+
import "../chunk-QZWLZH6D.js";
|
|
24
24
|
import {
|
|
25
25
|
githubRepositoryFullName,
|
|
26
26
|
isRepoActiveForCapture,
|
|
27
27
|
repoSyncId,
|
|
28
28
|
resolveRepositoryContext
|
|
29
|
-
} from "../chunk-
|
|
29
|
+
} from "../chunk-Q2PVD5W2.js";
|
|
30
30
|
import "../chunk-JSBRDJBE.js";
|
|
31
31
|
|
|
32
32
|
// src/hooks/post-commit.ts
|
|
@@ -5,25 +5,25 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
canonicalRewritePairs,
|
|
7
7
|
toRewriteMove
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-6WKJWW6D.js";
|
|
9
9
|
import {
|
|
10
10
|
getOrCreateWorkspaceId
|
|
11
11
|
} from "../chunk-EZXEWFDG.js";
|
|
12
12
|
import {
|
|
13
13
|
appendMove,
|
|
14
14
|
resolveOrg
|
|
15
|
-
} from "../chunk-
|
|
16
|
-
import "../chunk-
|
|
15
|
+
} from "../chunk-6VJ7C2B5.js";
|
|
16
|
+
import "../chunk-EER7VG3P.js";
|
|
17
17
|
import {
|
|
18
18
|
cachedCollectScopeAdmits
|
|
19
|
-
} from "../chunk-
|
|
20
|
-
import "../chunk-
|
|
19
|
+
} from "../chunk-5MH2C5QG.js";
|
|
20
|
+
import "../chunk-QZWLZH6D.js";
|
|
21
21
|
import {
|
|
22
22
|
githubRepositoryFullName,
|
|
23
23
|
isRepoActiveForCapture,
|
|
24
24
|
repoSyncId,
|
|
25
25
|
resolveRepositoryContext
|
|
26
|
-
} from "../chunk-
|
|
26
|
+
} from "../chunk-Q2PVD5W2.js";
|
|
27
27
|
import "../chunk-JSBRDJBE.js";
|
|
28
28
|
|
|
29
29
|
// src/hooks/post-rewrite.ts
|
|
@@ -1,57 +1,61 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
InvalidJournalEnvelopeError,
|
|
4
|
+
buildOrganizationBoundMoveRequest,
|
|
5
|
+
parseOrganizationBinding,
|
|
3
6
|
requireDurableIngestAcknowledgement
|
|
4
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-5BZWFN62.js";
|
|
5
8
|
import {
|
|
6
9
|
enrichHookPayloadWithFileRefs,
|
|
7
10
|
preserveHookFileMetadata
|
|
8
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-5KPDY5GF.js";
|
|
9
12
|
import {
|
|
10
13
|
appendCodexContext,
|
|
11
14
|
prepareCodexContext
|
|
12
|
-
} from "../chunk-
|
|
13
|
-
import "../chunk-
|
|
15
|
+
} from "../chunk-ZMH6GJUG.js";
|
|
16
|
+
import "../chunk-3OKVMKK2.js";
|
|
14
17
|
import {
|
|
15
18
|
postToolInvocationId,
|
|
16
19
|
toMove,
|
|
17
20
|
toolOutcomeFor
|
|
18
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-6WKJWW6D.js";
|
|
19
22
|
import {
|
|
20
23
|
getOrCreateWorkspaceId
|
|
21
24
|
} from "../chunk-EZXEWFDG.js";
|
|
22
25
|
import {
|
|
23
26
|
appendMove,
|
|
24
27
|
resolveOrg
|
|
25
|
-
} from "../chunk-
|
|
26
|
-
import "../chunk-
|
|
28
|
+
} from "../chunk-6VJ7C2B5.js";
|
|
29
|
+
import "../chunk-6PSCGY2A.js";
|
|
27
30
|
import {
|
|
28
31
|
observeDemoInvocation
|
|
29
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-WQFJ5TEG.js";
|
|
30
33
|
import {
|
|
31
34
|
normalizeEnvelope,
|
|
32
35
|
readHookStdin,
|
|
33
36
|
shouldSuppressImportedCursorHandler
|
|
34
|
-
} from "../chunk-
|
|
35
|
-
import "../chunk-
|
|
36
|
-
import "../chunk-
|
|
37
|
+
} from "../chunk-KTXJJE5K.js";
|
|
38
|
+
import "../chunk-A6YTFBQ4.js";
|
|
39
|
+
import "../chunk-WLVEXOHC.js";
|
|
37
40
|
import {
|
|
38
41
|
scrubFromCwd
|
|
39
|
-
} from "../chunk-
|
|
42
|
+
} from "../chunk-EER7VG3P.js";
|
|
40
43
|
import {
|
|
41
44
|
bold,
|
|
42
45
|
cachedCollectScopeAdmits,
|
|
43
46
|
color
|
|
44
|
-
} from "../chunk-
|
|
47
|
+
} from "../chunk-5MH2C5QG.js";
|
|
45
48
|
import {
|
|
46
49
|
getClient,
|
|
50
|
+
getPinnedClient,
|
|
47
51
|
terminalSafeLine
|
|
48
|
-
} from "../chunk-
|
|
52
|
+
} from "../chunk-QZWLZH6D.js";
|
|
49
53
|
import {
|
|
50
54
|
currentBranch,
|
|
51
55
|
isRepoActiveForCapture,
|
|
52
56
|
repoSyncId,
|
|
53
57
|
resolveRepositoryContext
|
|
54
|
-
} from "../chunk-
|
|
58
|
+
} from "../chunk-Q2PVD5W2.js";
|
|
55
59
|
import {
|
|
56
60
|
parseAgent
|
|
57
61
|
} from "../chunk-KZB4ABIB.js";
|
|
@@ -65,12 +69,18 @@ import { fileURLToPath } from "url";
|
|
|
65
69
|
// src/hooks/post-tool-delivery.ts
|
|
66
70
|
var INGEST_TIMEOUT_MS = 4e3;
|
|
67
71
|
async function deliverPostToolMove(move, orgId) {
|
|
68
|
-
appendMove(move, orgId);
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
const captured = appendMove(move, orgId);
|
|
73
|
+
const signal = AbortSignal.timeout(INGEST_TIMEOUT_MS);
|
|
74
|
+
const client = captured.captureActor ? await getPinnedClient({ signal }) : getClient();
|
|
75
|
+
let request = { batch: [captured] };
|
|
76
|
+
if (captured.captureActor) {
|
|
77
|
+
const binding = parseOrganizationBinding(
|
|
78
|
+
await client.get("/api/cli/auth/status", { signal, quietRefresh: true })
|
|
79
|
+
);
|
|
80
|
+
if (binding.state !== "current") throw new InvalidJournalEnvelopeError();
|
|
81
|
+
request = buildOrganizationBoundMoveRequest([captured], binding.binding);
|
|
82
|
+
}
|
|
83
|
+
const response = await client.post("/api/cli/moves/ingest", request, { signal });
|
|
74
84
|
return requireDurableIngestAcknowledgement(response, 1, move.env.gitRoot ?? move.env.cwd);
|
|
75
85
|
}
|
|
76
86
|
|
package/dist/hooks/pre-commit.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
checkAffectedDecisions,
|
|
4
4
|
formatDecisionsWarning
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-6W72SEXC.js";
|
|
6
|
+
import "../chunk-6PSCGY2A.js";
|
|
7
|
+
import "../chunk-QZWLZH6D.js";
|
|
8
|
+
import "../chunk-Q2PVD5W2.js";
|
|
9
9
|
import "../chunk-JSBRDJBE.js";
|
|
10
10
|
|
|
11
11
|
// src/hooks/pre-commit.ts
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
PREFLIGHT_PROTOCOL_VERSION,
|
|
4
|
+
PREFLIGHT_TIMEOUT_MS,
|
|
4
5
|
boundedClientVersion,
|
|
5
6
|
editPreview,
|
|
6
7
|
hasConfirmedConflict,
|
|
7
8
|
proposalFor,
|
|
8
9
|
proposalIsTruncated,
|
|
10
|
+
requestPreflight,
|
|
9
11
|
resolvePreflightTargets,
|
|
10
12
|
resultForPreflight,
|
|
13
|
+
resultForPreflight2,
|
|
11
14
|
toolInputDigest,
|
|
15
|
+
unverifiedResult,
|
|
12
16
|
waitForPreflight
|
|
13
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-TS2NX6YT.js";
|
|
14
18
|
import {
|
|
15
19
|
observeDemoInvocation
|
|
16
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-WQFJ5TEG.js";
|
|
17
21
|
import {
|
|
18
22
|
normalizeEnvelope,
|
|
19
23
|
readHookStdin,
|
|
20
24
|
shouldSuppressImportedCursorHandler
|
|
21
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-KTXJJE5K.js";
|
|
22
26
|
import {
|
|
23
27
|
buildCodexOutput,
|
|
24
28
|
buildCursorOutput,
|
|
@@ -30,13 +34,13 @@ import {
|
|
|
30
34
|
failOpenHermes,
|
|
31
35
|
failOpenOutput,
|
|
32
36
|
readHookMode
|
|
33
|
-
} from "../chunk-
|
|
34
|
-
import "../chunk-
|
|
35
|
-
import "../chunk-
|
|
37
|
+
} from "../chunk-A6YTFBQ4.js";
|
|
38
|
+
import "../chunk-WLVEXOHC.js";
|
|
39
|
+
import "../chunk-EER7VG3P.js";
|
|
36
40
|
import {
|
|
37
41
|
cachedCollectScopeAdmits
|
|
38
|
-
} from "../chunk-
|
|
39
|
-
import "../chunk-
|
|
42
|
+
} from "../chunk-5MH2C5QG.js";
|
|
43
|
+
import "../chunk-QZWLZH6D.js";
|
|
40
44
|
import {
|
|
41
45
|
canonicalGitRoot,
|
|
42
46
|
currentBranch,
|
|
@@ -44,7 +48,7 @@ import {
|
|
|
44
48
|
packageVersion,
|
|
45
49
|
repoActiveFlag,
|
|
46
50
|
repoSyncId
|
|
47
|
-
} from "../chunk-
|
|
51
|
+
} from "../chunk-Q2PVD5W2.js";
|
|
48
52
|
import {
|
|
49
53
|
parseAgent
|
|
50
54
|
} from "../chunk-KZB4ABIB.js";
|
|
@@ -74,6 +78,16 @@ function failOpen() {
|
|
|
74
78
|
if (agent === "cursor") return failOpenCursor();
|
|
75
79
|
return agent === "codex" ? failOpenCodex() : failOpenOutput();
|
|
76
80
|
}
|
|
81
|
+
async function unverified(message) {
|
|
82
|
+
if (agent === "claude_code") {
|
|
83
|
+
await emit(
|
|
84
|
+
buildHookOutput("allow", [unverifiedResult(`${message}; change was not verified.`)]),
|
|
85
|
+
true
|
|
86
|
+
);
|
|
87
|
+
} else {
|
|
88
|
+
await emit(failOpen());
|
|
89
|
+
}
|
|
90
|
+
}
|
|
77
91
|
function invocationId(envelope) {
|
|
78
92
|
const value = agent === "hermes" ? envelope.extra?.tool_call_id : envelope.tool_use_id;
|
|
79
93
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
@@ -154,6 +168,10 @@ async function main() {
|
|
|
154
168
|
await emit(failOpen(), true);
|
|
155
169
|
return;
|
|
156
170
|
}
|
|
171
|
+
if (agent === "claude_code" && targets.paths.length === 0) {
|
|
172
|
+
await unverified("Mutation targets could not be resolved");
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
157
175
|
if (!protectedShell && targets.paths.length === 0 && !targets.definite) {
|
|
158
176
|
await emit(failOpen());
|
|
159
177
|
return;
|
|
@@ -167,7 +185,9 @@ async function main() {
|
|
|
167
185
|
const sessionId = envelope.session_id;
|
|
168
186
|
const callId = invocationId(envelope);
|
|
169
187
|
if (!binding || typeof sessionId !== "string" || !sessionId || !callId) {
|
|
170
|
-
await
|
|
188
|
+
await unverified(
|
|
189
|
+
!binding ? "GitHub repo connection is required" : "Session or tool identity is missing"
|
|
190
|
+
);
|
|
171
191
|
return;
|
|
172
192
|
}
|
|
173
193
|
const collectScopeAdmits = cachedCollectScopeAdmits(cwd, {
|
|
@@ -184,10 +204,7 @@ async function main() {
|
|
|
184
204
|
knownWritePaths: targets.paths,
|
|
185
205
|
targetCoverage: targets.coverage
|
|
186
206
|
} : envelope.tool_input;
|
|
187
|
-
const
|
|
188
|
-
protocolVersion: PREFLIGHT_PROTOCOL_VERSION,
|
|
189
|
-
operation: "start",
|
|
190
|
-
toolInputDigest: toolInputDigest(toolName, envelope.tool_input),
|
|
207
|
+
const common = {
|
|
191
208
|
agent,
|
|
192
209
|
clientMode: mode,
|
|
193
210
|
clientVersion: boundedClientVersion(packageVersion()),
|
|
@@ -196,13 +213,66 @@ async function main() {
|
|
|
196
213
|
repoSyncId: binding,
|
|
197
214
|
paths: targets.paths,
|
|
198
215
|
coverage: targets.coverage,
|
|
216
|
+
...branch === void 0 ? {} : { branch },
|
|
217
|
+
proposal: collectScopeAdmits ? proposalFor(proposalInput) : ""
|
|
218
|
+
};
|
|
219
|
+
if (agent === "claude_code") {
|
|
220
|
+
const request2 = { ...common, protocolVersion: 3 };
|
|
221
|
+
let result2;
|
|
222
|
+
try {
|
|
223
|
+
const remaining = Math.floor(Math.min(PREFLIGHT_TIMEOUT_MS, deadline - performance.now()));
|
|
224
|
+
if (remaining <= 0) throw new Error("Deadline exceeded");
|
|
225
|
+
const response = await requestPreflight(request2, AbortSignal.timeout(remaining));
|
|
226
|
+
if (!response) {
|
|
227
|
+
await unverified("Decision check returned an invalid response");
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
result2 = resultForPreflight(
|
|
231
|
+
response,
|
|
232
|
+
editPreview(toolName, envelope.tool_input, targets.paths),
|
|
233
|
+
request2,
|
|
234
|
+
collectScopeAdmits && protectedShell && proposalIsTruncated(proposalInput)
|
|
235
|
+
);
|
|
236
|
+
if (result2.verdict === "unavailable") {
|
|
237
|
+
result2.unavailable = `${result2.unavailable || "Decision check is unavailable"}; change was not verified.`;
|
|
238
|
+
}
|
|
239
|
+
const coverage = response.evaluationCoverage;
|
|
240
|
+
const notes = [
|
|
241
|
+
...targets.coverage === "unverified" ? [
|
|
242
|
+
"[primitive] Some mutation targets could not be resolved; the complete change was not verified."
|
|
243
|
+
] : [],
|
|
244
|
+
...coverage && (coverage.status !== "completed" || coverage.selectionOmissions?.length || coverage.evidenceOmissions?.length) ? [
|
|
245
|
+
"[primitive] Decision coverage is incomplete; some candidates or evidence were not evaluated."
|
|
246
|
+
] : []
|
|
247
|
+
];
|
|
248
|
+
if (notes.length > 0) {
|
|
249
|
+
const note = notes.join("\n");
|
|
250
|
+
result2.reason = [result2.reason, note].filter(Boolean).join("\n");
|
|
251
|
+
result2.additionalContext = [result2.additionalContext, note].filter(Boolean).join("\n");
|
|
252
|
+
}
|
|
253
|
+
} catch {
|
|
254
|
+
await unverified("Decision check failed or timed out");
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
await emit(
|
|
258
|
+
buildHookOutput(
|
|
259
|
+
demoteForMode(result2.verdict === "unavailable" ? "allow" : result2.verdict, mode),
|
|
260
|
+
[result2]
|
|
261
|
+
),
|
|
262
|
+
true
|
|
263
|
+
);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const request = {
|
|
267
|
+
...common,
|
|
268
|
+
protocolVersion: PREFLIGHT_PROTOCOL_VERSION,
|
|
269
|
+
operation: "start",
|
|
270
|
+
toolInputDigest: toolInputDigest(toolName, envelope.tool_input),
|
|
199
271
|
...protectedShell ? {
|
|
200
272
|
shellCheck: {
|
|
201
273
|
targetMode: targets.coverage === "complete" ? "files" : "repository"
|
|
202
274
|
}
|
|
203
|
-
} : {}
|
|
204
|
-
...branch === void 0 ? {} : { branch },
|
|
205
|
-
proposal: collectScopeAdmits ? proposalFor(proposalInput) : ""
|
|
275
|
+
} : {}
|
|
206
276
|
};
|
|
207
277
|
let result;
|
|
208
278
|
try {
|
|
@@ -214,7 +284,7 @@ async function main() {
|
|
|
214
284
|
await emit(failOpen(), true);
|
|
215
285
|
return;
|
|
216
286
|
}
|
|
217
|
-
result =
|
|
287
|
+
result = resultForPreflight2(
|
|
218
288
|
response,
|
|
219
289
|
editPreview(toolName, envelope.tool_input, targets.paths),
|
|
220
290
|
request,
|
|
@@ -7,14 +7,24 @@ import "../chunk-JSBRDJBE.js";
|
|
|
7
7
|
// src/hooks/pre-tool-use.ts
|
|
8
8
|
import { spawn } from "child_process";
|
|
9
9
|
import { fileURLToPath } from "url";
|
|
10
|
-
var BUDGET_MS = 2e3;
|
|
11
10
|
var OUTPUT_RESERVE_MS = 150;
|
|
12
11
|
var MAX_OUTPUT_BYTES = 262144;
|
|
13
12
|
var agent = parseAgent(process.argv);
|
|
13
|
+
var budgetMs = agent === "claude_code" ? 15e3 : 2e3;
|
|
14
14
|
var silent = agent === "cursor" ? { permission: "allow" } : agent === "claude_code" ? {
|
|
15
15
|
hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "allow" }
|
|
16
16
|
} : {};
|
|
17
|
-
var
|
|
17
|
+
var unverified = "[primitive] Decision check could not finish; change was not verified.";
|
|
18
|
+
var optedOut = process.env.PRIM_HOOK_MODE === "off" || process.env.PRIM_BYPASS === "1" || process.env.PRIM_BYPASS === "true";
|
|
19
|
+
var fallback = agent === "claude_code" && !optedOut ? {
|
|
20
|
+
systemMessage: unverified,
|
|
21
|
+
hookSpecificOutput: {
|
|
22
|
+
hookEventName: "PreToolUse",
|
|
23
|
+
permissionDecision: "allow",
|
|
24
|
+
additionalContext: unverified
|
|
25
|
+
}
|
|
26
|
+
} : silent;
|
|
27
|
+
var remaining = Math.max(0, budgetMs - process.uptime() * 1e3 - OUTPUT_RESERVE_MS);
|
|
18
28
|
var child;
|
|
19
29
|
var finished = false;
|
|
20
30
|
var stdout = "";
|
|
@@ -27,7 +37,7 @@ function stopWorker() {
|
|
|
27
37
|
} catch {
|
|
28
38
|
}
|
|
29
39
|
}
|
|
30
|
-
function finish(output =
|
|
40
|
+
function finish(output = fallback, diagnostics = "") {
|
|
31
41
|
if (finished) return;
|
|
32
42
|
finished = true;
|
|
33
43
|
clearTimeout(timer);
|
package/dist/hooks/prim-hook.js
CHANGED
|
@@ -8,58 +8,58 @@ import {
|
|
|
8
8
|
acknowledgeDecisionFeedback,
|
|
9
9
|
leaseDecisionFeedback,
|
|
10
10
|
renderFeedback
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-EWV7VIZ3.js";
|
|
12
12
|
import {
|
|
13
13
|
recordConversationCaptured
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-KMWXI7KO.js";
|
|
15
15
|
import {
|
|
16
16
|
unattendedEnv
|
|
17
17
|
} from "../chunk-OYHYCK4K.js";
|
|
18
18
|
import {
|
|
19
19
|
enrichHookPayloadWithFileRefs,
|
|
20
20
|
preserveHookFileMetadata
|
|
21
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-5KPDY5GF.js";
|
|
22
22
|
import {
|
|
23
23
|
prepareCodexContext
|
|
24
|
-
} from "../chunk-
|
|
25
|
-
import "../chunk-
|
|
24
|
+
} from "../chunk-ZMH6GJUG.js";
|
|
25
|
+
import "../chunk-3OKVMKK2.js";
|
|
26
26
|
import {
|
|
27
27
|
postToolInvocationId,
|
|
28
28
|
shouldFlushAfter,
|
|
29
29
|
toMove
|
|
30
|
-
} from "../chunk-
|
|
30
|
+
} from "../chunk-6WKJWW6D.js";
|
|
31
31
|
import {
|
|
32
32
|
getOrCreateWorkspaceId
|
|
33
33
|
} from "../chunk-EZXEWFDG.js";
|
|
34
34
|
import {
|
|
35
35
|
appendMove,
|
|
36
36
|
resolveOrg
|
|
37
|
-
} from "../chunk-
|
|
38
|
-
import "../chunk-
|
|
37
|
+
} from "../chunk-6VJ7C2B5.js";
|
|
38
|
+
import "../chunk-6PSCGY2A.js";
|
|
39
39
|
import {
|
|
40
40
|
observeDemoInvocation
|
|
41
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-WQFJ5TEG.js";
|
|
42
42
|
import {
|
|
43
43
|
normalizeEnvelope,
|
|
44
44
|
readHookStdin,
|
|
45
45
|
shouldSuppressImportedCursorHandler
|
|
46
|
-
} from "../chunk-
|
|
47
|
-
import "../chunk-
|
|
48
|
-
import "../chunk-
|
|
46
|
+
} from "../chunk-KTXJJE5K.js";
|
|
47
|
+
import "../chunk-A6YTFBQ4.js";
|
|
48
|
+
import "../chunk-WLVEXOHC.js";
|
|
49
49
|
import {
|
|
50
50
|
scrubFromCwd,
|
|
51
51
|
writeHookDebug
|
|
52
|
-
} from "../chunk-
|
|
52
|
+
} from "../chunk-EER7VG3P.js";
|
|
53
53
|
import {
|
|
54
54
|
cachedCollectScopeAdmits
|
|
55
|
-
} from "../chunk-
|
|
56
|
-
import "../chunk-
|
|
55
|
+
} from "../chunk-5MH2C5QG.js";
|
|
56
|
+
import "../chunk-QZWLZH6D.js";
|
|
57
57
|
import {
|
|
58
58
|
currentBranch,
|
|
59
59
|
isRepoActiveForCapture,
|
|
60
60
|
repoSyncId,
|
|
61
61
|
resolveRepositoryContext
|
|
62
|
-
} from "../chunk-
|
|
62
|
+
} from "../chunk-Q2PVD5W2.js";
|
|
63
63
|
import {
|
|
64
64
|
parseAgent
|
|
65
65
|
} from "../chunk-KZB4ABIB.js";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
daemonRequest
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-6PSCGY2A.js";
|
|
5
5
|
import {
|
|
6
6
|
normalizeEnvelope,
|
|
7
7
|
readHookStdin,
|
|
8
8
|
shouldSuppressImportedCursorHandler
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-KTXJJE5K.js";
|
|
10
|
+
import "../chunk-WLVEXOHC.js";
|
|
11
11
|
import {
|
|
12
12
|
isRepoActiveForCapture
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-Q2PVD5W2.js";
|
|
14
14
|
import {
|
|
15
15
|
parseAgent
|
|
16
16
|
} from "../chunk-KZB4ABIB.js";
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
kickDaemonEnsure,
|
|
8
8
|
refreshClaudePlugins,
|
|
9
9
|
warmBinCache
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-DGZX3MID.js";
|
|
11
11
|
import {
|
|
12
12
|
buildHookOutput,
|
|
13
13
|
handoffHookOutput
|
|
@@ -17,43 +17,44 @@ import {
|
|
|
17
17
|
acknowledgeDecisionFeedback,
|
|
18
18
|
leaseDecisionFeedback,
|
|
19
19
|
renderFeedback
|
|
20
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-EWV7VIZ3.js";
|
|
21
21
|
import {
|
|
22
22
|
clearHooksWired,
|
|
23
23
|
recordHooksWired
|
|
24
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-KMWXI7KO.js";
|
|
25
25
|
import "../chunk-OYHYCK4K.js";
|
|
26
26
|
import {
|
|
27
27
|
prepareCodexContext
|
|
28
|
-
} from "../chunk-
|
|
29
|
-
import "../chunk-
|
|
28
|
+
} from "../chunk-ZMH6GJUG.js";
|
|
29
|
+
import "../chunk-3OKVMKK2.js";
|
|
30
30
|
import {
|
|
31
31
|
getOrCreateWorkspaceId
|
|
32
32
|
} from "../chunk-EZXEWFDG.js";
|
|
33
33
|
import {
|
|
34
34
|
daemonRequest
|
|
35
|
-
} from "../chunk-
|
|
35
|
+
} from "../chunk-6PSCGY2A.js";
|
|
36
36
|
import {
|
|
37
37
|
normalizeEnvelope,
|
|
38
38
|
readHookStdin,
|
|
39
39
|
shouldSuppressImportedCursorHandler
|
|
40
|
-
} from "../chunk-
|
|
40
|
+
} from "../chunk-KTXJJE5K.js";
|
|
41
41
|
import {
|
|
42
42
|
MANAGED_GIT_HOOK_NAMES
|
|
43
|
-
} from "../chunk-
|
|
43
|
+
} from "../chunk-WLVEXOHC.js";
|
|
44
44
|
import {
|
|
45
45
|
fetchAndCacheCollectScope
|
|
46
|
-
} from "../chunk-
|
|
46
|
+
} from "../chunk-5MH2C5QG.js";
|
|
47
47
|
import {
|
|
48
48
|
getSiteUrl,
|
|
49
49
|
isSessionEnded
|
|
50
|
-
} from "../chunk-
|
|
50
|
+
} from "../chunk-QZWLZH6D.js";
|
|
51
51
|
import {
|
|
52
52
|
gitToplevel,
|
|
53
|
+
hasMachineConfiguration,
|
|
53
54
|
isRepoActiveForCapture,
|
|
54
55
|
repoActiveFlag,
|
|
55
56
|
setRepoActive
|
|
56
|
-
} from "../chunk-
|
|
57
|
+
} from "../chunk-Q2PVD5W2.js";
|
|
57
58
|
import {
|
|
58
59
|
parseAgent
|
|
59
60
|
} from "../chunk-KZB4ABIB.js";
|
|
@@ -62,7 +63,10 @@ import "../chunk-JSBRDJBE.js";
|
|
|
62
63
|
// src/hooks/reauth-notice.ts
|
|
63
64
|
var REAUTH_NOTICE = "[prim] authentication ended \u2014 run `prim auth login` to resume decision capture";
|
|
64
65
|
function reauthNoticeFields(agent) {
|
|
65
|
-
if (agent === "claude_code")
|
|
66
|
+
if (agent === "claude_code")
|
|
67
|
+
return {
|
|
68
|
+
systemMessage: hasMachineConfiguration() ? "[prim] machine delivery paused; local capture remains saved. Run `prim auth status` and ask your administrator to enable or rotate machine credentials." : REAUTH_NOTICE
|
|
69
|
+
};
|
|
66
70
|
return;
|
|
67
71
|
}
|
|
68
72
|
|