@primitive.ai/prim 0.1.0-alpha.86 → 0.1.0-alpha.88
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/SKILL.md +1 -1
- package/dist/chunk-BOW3Y3KS.js +18531 -0
- package/dist/{chunk-XGADQPCI.js → chunk-EWM3RYCA.js} +11 -1
- package/dist/{chunk-4CZTNXIS.js → chunk-GBEPUEPZ.js} +1 -1
- package/dist/{chunk-7O6NAUKJ.js → chunk-KL322THW.js} +1 -1
- package/dist/{chunk-OUXH3UEP.js → chunk-MDDHTIXL.js} +1 -1
- package/dist/{chunk-HWSS4BV5.js → chunk-WPD4QRNJ.js} +1 -1
- package/dist/daemon/server.js +8387 -2511
- package/dist/hook-runtime/daemon/server.js +8387 -2511
- package/dist/hook-runtime/hooks/post-commit.js +18292 -179
- package/dist/hook-runtime/hooks/post-rewrite.js +18110 -2
- package/dist/hook-runtime/hooks/post-tool-use.js +18550 -351
- package/dist/hook-runtime/hooks/pre-tool-use.js +18255 -138
- package/dist/hook-runtime/hooks/prim-hook.js +18281 -163
- package/dist/hook-runtime/hooks/session-start.js +18167 -208
- package/dist/hook-runtime/index.js +11429 -5040
- package/dist/hooks/post-commit.js +12 -3
- package/dist/hooks/post-rewrite.js +8 -4
- package/dist/hooks/post-tool-use.js +19 -6
- package/dist/hooks/pre-tool-use.js +16 -4
- package/dist/hooks/prim-hook.js +34 -22
- package/dist/hooks/session-start.js +8 -3
- package/dist/index.js +558 -12175
- package/package.json +1 -1
- package/dist/chunk-TJTVHDJ5.js +0 -321
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
commitAttributionFromEnvironment,
|
|
4
4
|
toCommitMove
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-MDDHTIXL.js";
|
|
6
6
|
import {
|
|
7
7
|
getOrCreateWorkspaceId
|
|
8
8
|
} from "../chunk-EZXEWFDG.js";
|
|
@@ -13,11 +13,12 @@ import {
|
|
|
13
13
|
import "../chunk-FI3LIRCB.js";
|
|
14
14
|
import "../chunk-LEMX3IOG.js";
|
|
15
15
|
import {
|
|
16
|
+
cachedCollectScopeAdmits,
|
|
16
17
|
githubRepositoryFullName,
|
|
17
18
|
isRepoActiveForCapture,
|
|
18
19
|
repoSyncId,
|
|
19
20
|
resolveRepositoryContext
|
|
20
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-BOW3Y3KS.js";
|
|
21
22
|
import "../chunk-Z7YPFWAZ.js";
|
|
22
23
|
import "../chunk-3EEFL6NJ.js";
|
|
23
24
|
|
|
@@ -144,13 +145,21 @@ function runPostCommit() {
|
|
|
144
145
|
}
|
|
145
146
|
const commit = readCommit();
|
|
146
147
|
if (commit) {
|
|
148
|
+
const repositoryFullName = githubRepositoryFullName(cwd) ?? void 0;
|
|
149
|
+
if (!cachedCollectScopeAdmits(cwd, {
|
|
150
|
+
repository: repositoryFullName,
|
|
151
|
+
branch: commit.branch,
|
|
152
|
+
...commit.files.length > 0 || !commit.filesComplete ? { paths: commit.files, pathsComplete: commit.filesComplete } : {}
|
|
153
|
+
})) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
147
156
|
const repository = resolveRepositoryContext(cwd);
|
|
148
157
|
const identity = getOrCreateWorkspaceId(cwd);
|
|
149
158
|
const workspaceId = identity.status === "ready" ? identity.workspaceId : void 0;
|
|
150
159
|
const attribution = commitAttributionFromEnvironment(process.env, workspaceId);
|
|
151
160
|
const move = toCommitMove(commit, resolveCliVersion(), cwd, {
|
|
152
161
|
repository,
|
|
153
|
-
repoFullName:
|
|
162
|
+
repoFullName: repositoryFullName,
|
|
154
163
|
repoSyncId: repoSyncId(cwd),
|
|
155
164
|
workspaceId,
|
|
156
165
|
attribution,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
canonicalRewritePairs,
|
|
4
4
|
toRewriteMove
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-MDDHTIXL.js";
|
|
6
6
|
import {
|
|
7
7
|
getOrCreateWorkspaceId
|
|
8
8
|
} from "../chunk-EZXEWFDG.js";
|
|
@@ -13,11 +13,12 @@ import {
|
|
|
13
13
|
import "../chunk-FI3LIRCB.js";
|
|
14
14
|
import "../chunk-LEMX3IOG.js";
|
|
15
15
|
import {
|
|
16
|
+
cachedCollectScopeAdmits,
|
|
16
17
|
githubRepositoryFullName,
|
|
17
18
|
isRepoActiveForCapture,
|
|
18
19
|
repoSyncId,
|
|
19
20
|
resolveRepositoryContext
|
|
20
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-BOW3Y3KS.js";
|
|
21
22
|
import "../chunk-Z7YPFWAZ.js";
|
|
22
23
|
import "../chunk-3EEFL6NJ.js";
|
|
23
24
|
|
|
@@ -151,6 +152,9 @@ function runPostRewrite() {
|
|
|
151
152
|
if (!validSource(source) || snapshot.pairs.length === 0) return;
|
|
152
153
|
const cwd = gitText(["rev-parse", "--show-toplevel"]) ?? process.cwd();
|
|
153
154
|
if (!isRepoActiveForCapture(cwd)) return;
|
|
155
|
+
const branch = validBranch(process.env.PRIM_REWRITE_BRANCH);
|
|
156
|
+
const repositoryFullName = githubRepositoryFullName(cwd) ?? void 0;
|
|
157
|
+
if (!cachedCollectScopeAdmits(cwd, { repository: repositoryFullName, branch })) return;
|
|
154
158
|
const repository = resolveRepositoryContext(cwd);
|
|
155
159
|
const identity = getOrCreateWorkspaceId(cwd);
|
|
156
160
|
const workspaceId = identity.status === "ready" ? identity.workspaceId : void 0;
|
|
@@ -158,13 +162,13 @@ function runPostRewrite() {
|
|
|
158
162
|
{
|
|
159
163
|
source,
|
|
160
164
|
pairs: snapshot.pairs,
|
|
161
|
-
branch
|
|
165
|
+
branch
|
|
162
166
|
},
|
|
163
167
|
resolveCliVersion(),
|
|
164
168
|
cwd,
|
|
165
169
|
{
|
|
166
170
|
repository,
|
|
167
|
-
repoFullName:
|
|
171
|
+
repoFullName: repositoryFullName,
|
|
168
172
|
repoSyncId: repoSyncId(cwd),
|
|
169
173
|
workspaceId,
|
|
170
174
|
capturedAt: snapshot.capturedAt
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
requireDurableIngestAcknowledgement
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-EWM3RYCA.js";
|
|
5
5
|
import {
|
|
6
6
|
enrichHookPayloadWithFileRefs,
|
|
7
7
|
preserveHookFileMetadata
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-KL322THW.js";
|
|
9
9
|
import {
|
|
10
10
|
postToolInvocationId,
|
|
11
11
|
toMove,
|
|
12
12
|
toolOutcomeFor
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-MDDHTIXL.js";
|
|
14
14
|
import {
|
|
15
15
|
getOrCreateWorkspaceId
|
|
16
16
|
} from "../chunk-EZXEWFDG.js";
|
|
@@ -22,7 +22,7 @@ import "../chunk-PPQYQEIR.js";
|
|
|
22
22
|
import {
|
|
23
23
|
appendCodexContext,
|
|
24
24
|
prepareCodexContext
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-GBEPUEPZ.js";
|
|
26
26
|
import "../chunk-PMRDE2DA.js";
|
|
27
27
|
import {
|
|
28
28
|
scrubFromCwd
|
|
@@ -32,10 +32,12 @@ import {
|
|
|
32
32
|
color
|
|
33
33
|
} from "../chunk-LEMX3IOG.js";
|
|
34
34
|
import {
|
|
35
|
+
cachedCollectScopeAdmits,
|
|
36
|
+
currentBranch,
|
|
35
37
|
isRepoActiveForCapture,
|
|
36
38
|
repoSyncId,
|
|
37
39
|
resolveRepositoryContext
|
|
38
|
-
} from "../chunk-
|
|
40
|
+
} from "../chunk-BOW3Y3KS.js";
|
|
39
41
|
import {
|
|
40
42
|
getClient,
|
|
41
43
|
terminalSafeLine
|
|
@@ -61,7 +63,7 @@ async function deliverPostToolMove(move, orgId) {
|
|
|
61
63
|
{ batch: [move] },
|
|
62
64
|
{ signal: AbortSignal.timeout(INGEST_TIMEOUT_MS) }
|
|
63
65
|
);
|
|
64
|
-
return requireDurableIngestAcknowledgement(response, 1);
|
|
66
|
+
return requireDurableIngestAcknowledgement(response, 1, move.env.gitRoot ?? move.env.cwd);
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
// src/hooks/verdict-footer.ts
|
|
@@ -209,6 +211,17 @@ async function main() {
|
|
|
209
211
|
return;
|
|
210
212
|
}
|
|
211
213
|
}
|
|
214
|
+
const pathsComplete = !resolution.targetsIncomplete && !resolution.targetsTruncated && resolution.rejected.length === 0 && resolution.shellMutation !== "unresolved";
|
|
215
|
+
const hasPathEvidence = resolution.fileRefs.length > 0 || resolution.rejected.length > 0 || resolution.targetsIncomplete || resolution.targetsTruncated || resolution.shellMutation === "unresolved";
|
|
216
|
+
if (!cachedCollectScopeAdmits(cwd, {
|
|
217
|
+
repository: resolvedRepository.repoFullName,
|
|
218
|
+
branch: currentBranch(cwd),
|
|
219
|
+
agent,
|
|
220
|
+
...isHermesDenial || !hasPathEvidence ? {} : { paths: resolution.fileRefs, pathsComplete }
|
|
221
|
+
})) {
|
|
222
|
+
await emit();
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
212
225
|
const enriched = enrichment.parsed;
|
|
213
226
|
const identity = getOrCreateWorkspaceId(cwd);
|
|
214
227
|
const workspaceId = identity.status === "ready" ? identity.workspaceId : void 0;
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
appendCodexContext,
|
|
16
16
|
hasVisibleCodexMessage,
|
|
17
17
|
prepareCodexContext
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-GBEPUEPZ.js";
|
|
19
19
|
import {
|
|
20
20
|
packageVersion
|
|
21
21
|
} from "../chunk-PMRDE2DA.js";
|
|
@@ -27,11 +27,14 @@ import {
|
|
|
27
27
|
boundedHealthError
|
|
28
28
|
} from "../chunk-LEMX3IOG.js";
|
|
29
29
|
import {
|
|
30
|
+
cachedCollectScopeAdmits,
|
|
30
31
|
canonicalGitRoot,
|
|
31
32
|
canonicalRepositoryPath,
|
|
33
|
+
currentBranch,
|
|
34
|
+
githubRepositoryFullName,
|
|
32
35
|
isRepoActive,
|
|
33
36
|
repoSyncId
|
|
34
|
-
} from "../chunk-
|
|
37
|
+
} from "../chunk-BOW3Y3KS.js";
|
|
35
38
|
import {
|
|
36
39
|
getClient
|
|
37
40
|
} from "../chunk-Z7YPFWAZ.js";
|
|
@@ -45,7 +48,7 @@ import "../chunk-3EEFL6NJ.js";
|
|
|
45
48
|
// src/hooks/preflight-v3.ts
|
|
46
49
|
import { Buffer as Buffer2 } from "buffer";
|
|
47
50
|
var PREFLIGHT_PROTOCOL_VERSION = 3;
|
|
48
|
-
var PREFLIGHT_TIMEOUT_MS =
|
|
51
|
+
var PREFLIGHT_TIMEOUT_MS = 7500;
|
|
49
52
|
var MAX_PREFLIGHT_PATHS = 32;
|
|
50
53
|
var MAX_PROPOSAL_BYTES = 6144;
|
|
51
54
|
var MAX_CLIENT_VERSION_CHARS = 32;
|
|
@@ -296,6 +299,7 @@ async function main() {
|
|
|
296
299
|
return;
|
|
297
300
|
}
|
|
298
301
|
const binding = repoSyncId(cwd);
|
|
302
|
+
const branch = currentBranch(cwd);
|
|
299
303
|
const sessionId = envelope.session_id;
|
|
300
304
|
const callId = invocationId(envelope);
|
|
301
305
|
if (!binding || typeof sessionId !== "string" || !sessionId || !callId) {
|
|
@@ -305,6 +309,13 @@ async function main() {
|
|
|
305
309
|
);
|
|
306
310
|
return;
|
|
307
311
|
}
|
|
312
|
+
const collectScopeAdmits = cachedCollectScopeAdmits(cwd, {
|
|
313
|
+
repository: githubRepositoryFullName(cwd) ?? void 0,
|
|
314
|
+
branch,
|
|
315
|
+
agent,
|
|
316
|
+
paths: targets.paths,
|
|
317
|
+
pathsComplete: targets.coverage === "complete"
|
|
318
|
+
});
|
|
308
319
|
const request = {
|
|
309
320
|
protocolVersion: PREFLIGHT_PROTOCOL_VERSION,
|
|
310
321
|
agent,
|
|
@@ -315,7 +326,8 @@ async function main() {
|
|
|
315
326
|
repoSyncId: binding,
|
|
316
327
|
paths: targets.paths,
|
|
317
328
|
coverage: targets.coverage,
|
|
318
|
-
|
|
329
|
+
...branch === void 0 ? {} : { branch },
|
|
330
|
+
proposal: collectScopeAdmits ? proposalFor(envelope.tool_input) : ""
|
|
319
331
|
};
|
|
320
332
|
let result;
|
|
321
333
|
try {
|
package/dist/hooks/prim-hook.js
CHANGED
|
@@ -12,12 +12,12 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
enrichHookPayloadWithFileRefs,
|
|
14
14
|
preserveHookFileMetadata
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-KL322THW.js";
|
|
16
16
|
import {
|
|
17
17
|
postToolInvocationId,
|
|
18
18
|
shouldFlushAfter,
|
|
19
19
|
toMove
|
|
20
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-MDDHTIXL.js";
|
|
21
21
|
import {
|
|
22
22
|
getOrCreateWorkspaceId
|
|
23
23
|
} from "../chunk-EZXEWFDG.js";
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
import "../chunk-PPQYQEIR.js";
|
|
29
29
|
import {
|
|
30
30
|
prepareCodexContext
|
|
31
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-GBEPUEPZ.js";
|
|
32
32
|
import "../chunk-PMRDE2DA.js";
|
|
33
33
|
import {
|
|
34
34
|
scrubFromCwd,
|
|
@@ -36,10 +36,12 @@ import {
|
|
|
36
36
|
} from "../chunk-FI3LIRCB.js";
|
|
37
37
|
import "../chunk-LEMX3IOG.js";
|
|
38
38
|
import {
|
|
39
|
+
cachedCollectScopeAdmits,
|
|
40
|
+
currentBranch,
|
|
39
41
|
isRepoActiveForCapture,
|
|
40
42
|
repoSyncId,
|
|
41
43
|
resolveRepositoryContext
|
|
42
|
-
} from "../chunk-
|
|
44
|
+
} from "../chunk-BOW3Y3KS.js";
|
|
43
45
|
import "../chunk-Z7YPFWAZ.js";
|
|
44
46
|
import {
|
|
45
47
|
normalizeEnvelope,
|
|
@@ -135,25 +137,35 @@ async function main() {
|
|
|
135
137
|
const repository = resolvedRepository ? { ...resolvedRepository, repoSyncId: repoSyncId(cwd) } : null;
|
|
136
138
|
try {
|
|
137
139
|
const enrichment = repository ? enrichHookPayloadWithFileRefs({ parsed, agent, cwd, repository }) : void 0;
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
const resolution = enrichment?.resolution;
|
|
141
|
+
const hasPathEvidence = resolution !== void 0 && (resolution.fileRefs.length > 0 || resolution.rejected.length > 0 || resolution.targetsIncomplete || resolution.targetsTruncated || resolution.shellMutation === "unresolved");
|
|
142
|
+
const pathsComplete = resolution !== void 0 && !resolution.targetsIncomplete && !resolution.targetsTruncated && resolution.rejected.length === 0 && resolution.shellMutation !== "unresolved";
|
|
143
|
+
if (cachedCollectScopeAdmits(cwd, {
|
|
144
|
+
repository: resolvedRepository?.repoFullName,
|
|
145
|
+
branch: currentBranch(cwd),
|
|
143
146
|
agent,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
147
|
+
...hasPathEvidence && resolution !== void 0 ? { paths: resolution.fileRefs, pathsComplete } : {}
|
|
148
|
+
})) {
|
|
149
|
+
const enriched = enrichment?.parsed ?? parsed;
|
|
150
|
+
const invocationId = postToolInvocationId(enriched, agent);
|
|
151
|
+
const base = toMove(
|
|
152
|
+
enriched,
|
|
153
|
+
resolveCliVersion(),
|
|
154
|
+
agent,
|
|
155
|
+
workspaceId,
|
|
156
|
+
repository,
|
|
157
|
+
invocationId
|
|
158
|
+
);
|
|
159
|
+
const scrubbed = await scrubFromCwd(enriched, cwd);
|
|
160
|
+
const move = {
|
|
161
|
+
...base,
|
|
162
|
+
payload: enrichment ? preserveHookFileMetadata(scrubbed, enrichment.resolution) : scrubbed
|
|
163
|
+
};
|
|
164
|
+
const { orgId } = resolveOrg({ sessionId: move.sessionId, cwd });
|
|
165
|
+
appendMove(move, orgId);
|
|
166
|
+
if (shouldFlushAfter(move.eventType)) {
|
|
167
|
+
spawnBackgroundFlush();
|
|
168
|
+
}
|
|
157
169
|
}
|
|
158
170
|
} catch (error) {
|
|
159
171
|
writeHookDebug("capture failed", error);
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
hasUsableCodexGuidance,
|
|
7
7
|
refreshClaudePlugins,
|
|
8
8
|
warmBinCache
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-WPD4QRNJ.js";
|
|
10
10
|
import {
|
|
11
11
|
buildHookOutput,
|
|
12
12
|
handoffHookOutput
|
|
@@ -22,16 +22,17 @@ import {
|
|
|
22
22
|
} from "../chunk-EZXEWFDG.js";
|
|
23
23
|
import {
|
|
24
24
|
prepareCodexContext
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-GBEPUEPZ.js";
|
|
26
26
|
import {
|
|
27
27
|
binFile
|
|
28
28
|
} from "../chunk-PMRDE2DA.js";
|
|
29
29
|
import {
|
|
30
|
+
fetchAndCacheCollectScope,
|
|
30
31
|
gitToplevel,
|
|
31
32
|
isRepoActiveForCapture,
|
|
32
33
|
repoActiveFlag,
|
|
33
34
|
setRepoActive
|
|
34
|
-
} from "../chunk-
|
|
35
|
+
} from "../chunk-BOW3Y3KS.js";
|
|
35
36
|
import {
|
|
36
37
|
getSiteUrl,
|
|
37
38
|
isSessionEnded
|
|
@@ -114,6 +115,10 @@ async function activeProjectRoot(cwd) {
|
|
|
114
115
|
signal: AbortSignal.timeout(REPOSITORY_BIND_TIMEOUT_MS),
|
|
115
116
|
quietRefresh: true
|
|
116
117
|
});
|
|
118
|
+
try {
|
|
119
|
+
await fetchAndCacheCollectScope(root);
|
|
120
|
+
} catch {
|
|
121
|
+
}
|
|
117
122
|
return { root, binding };
|
|
118
123
|
} catch {
|
|
119
124
|
}
|