@primitive.ai/prim 0.1.0-alpha.126 → 0.1.0-alpha.128
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 +211 -1
- package/SKILL.md +6 -1
- package/dist/{chunk-ZKXNJB6U.js → chunk-3KPTVK4N.js} +70 -78
- package/dist/{chunk-6KXQQ7CQ.js → chunk-4DYEBYKM.js} +3 -5
- package/dist/{chunk-NJBN3WXF.js → chunk-6QAXVFRJ.js} +1900 -179
- package/dist/{chunk-R6NDP7OF.js → chunk-ANMNGGTN.js} +2 -2
- package/dist/{chunk-PPZ56EVJ.js → chunk-B3ICJZXV.js} +4 -2
- package/dist/{chunk-5D2C6RCH.js → chunk-C357P37M.js} +4 -4
- package/dist/{chunk-DT7E3SD5.js → chunk-E57UVUJL.js} +6 -6
- package/dist/{chunk-KKUDAQQZ.js → chunk-EQWUCFXK.js} +3 -3
- package/dist/{chunk-JFWJN2ME.js → chunk-M6KIDB5R.js} +119 -5
- package/dist/{chunk-NBNQI3YJ.js → chunk-N6PZE7HX.js} +6 -3
- package/dist/{chunk-O73J3KQQ.js → chunk-NYDM4HSS.js} +8 -5
- package/dist/{chunk-74DQDWLW.js → chunk-P4O7L7JZ.js} +7 -2
- package/dist/{chunk-L32WYFJT.js → chunk-PRJ7P6J5.js} +135 -12
- package/dist/{chunk-ND6TYHNI.js → chunk-PTZ6BWSU.js} +2 -2
- package/dist/{chunk-BFYJLI7V.js → chunk-QQ3G5SXX.js} +1 -1
- package/dist/{chunk-EZXIKEMA.js → chunk-RDT2IV2Z.js} +9 -7
- package/dist/{chunk-TI37ME2D.js → chunk-VLT2KGPE.js} +47 -38
- package/dist/{chunk-YP4OXKNX.js → chunk-WEGZGF3K.js} +1 -1
- package/dist/{chunk-C5VBPHOS.js → chunk-XINFTNA2.js} +23 -9
- package/dist/{chunk-FYYHBOOM.js → chunk-ZCT23NBS.js} +2 -2
- package/dist/daemon/server.js +1976 -442
- package/dist/hook-runtime/daemon/server.js +1976 -442
- package/dist/hook-runtime/hooks/post-commit.js +592 -212
- package/dist/hook-runtime/hooks/post-rewrite.js +584 -204
- package/dist/hook-runtime/hooks/post-tool-use.js +1997 -575
- package/dist/hook-runtime/hooks/pre-commit.js +1742 -350
- package/dist/hook-runtime/hooks/pre-tool-use-worker.js +1656 -261
- package/dist/hook-runtime/hooks/prim-hook.js +1992 -573
- package/dist/hook-runtime/hooks/session-end.js +549 -180
- package/dist/hook-runtime/hooks/session-start.js +2213 -596
- package/dist/hook-runtime/index.js +5318 -2423
- package/dist/hook-runtime/statusline-main.js +531 -150
- package/dist/hooks/post-commit.js +7 -7
- package/dist/hooks/post-rewrite.js +6 -6
- package/dist/hooks/post-tool-use.js +18 -18
- package/dist/hooks/pre-commit.js +4 -4
- package/dist/hooks/pre-tool-use-worker.js +14 -15
- package/dist/hooks/prim-hook.js +16 -16
- package/dist/hooks/session-end.js +4 -4
- package/dist/hooks/session-start.js +95 -21
- package/dist/index.js +1386 -299
- package/dist/statusline-main.js +531 -150
- package/package.json +1 -1
|
@@ -1,16 +1,47 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isMoveIngestRequest,
|
|
3
3
|
scheduleCollectScopeRefresh
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NYDM4HSS.js";
|
|
5
5
|
import {
|
|
6
6
|
getPinnedClient,
|
|
7
7
|
getSiteUrl
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-3KPTVK4N.js";
|
|
9
9
|
import {
|
|
10
|
+
identityPending,
|
|
10
11
|
machineApiUrl,
|
|
11
12
|
machineJournalBucket,
|
|
13
|
+
machinePendingBucket,
|
|
12
14
|
parseMachineIdentity
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-6QAXVFRJ.js";
|
|
16
|
+
|
|
17
|
+
// src/ingest-response.ts
|
|
18
|
+
var IngestAcknowledgementError = class extends Error {
|
|
19
|
+
constructor(message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "IngestAcknowledgementError";
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
function requireDurableIngestAcknowledgement(value, expected, cwd = process.cwd()) {
|
|
25
|
+
if (typeof value !== "object" || value === null) {
|
|
26
|
+
throw new IngestAcknowledgementError("ingest response was not an object");
|
|
27
|
+
}
|
|
28
|
+
const response = value;
|
|
29
|
+
if (response.disposition !== "persisted") {
|
|
30
|
+
throw new IngestAcknowledgementError("ingest response did not confirm persistence");
|
|
31
|
+
}
|
|
32
|
+
if (response.acknowledged !== expected) {
|
|
33
|
+
throw new IngestAcknowledgementError(
|
|
34
|
+
`ingest acknowledged ${String(response.acknowledged)} of ${String(expected)} moves`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (typeof response.collectScopeVersion === "number" && Number.isSafeInteger(response.collectScopeVersion) && response.collectScopeVersion >= 0) {
|
|
38
|
+
const roots = typeof cwd === "string" ? [cwd] : cwd;
|
|
39
|
+
for (const root of new Set(roots)) {
|
|
40
|
+
scheduleCollectScopeRefresh(root, response.collectScopeVersion);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
14
45
|
|
|
15
46
|
// src/protocol/decision-lifecycle.ts
|
|
16
47
|
var DECISION_LIFECYCLE_PROTOCOL_VERSION = 2;
|
|
@@ -86,11 +117,15 @@ function classifyJournalBuckets(buckets, binding) {
|
|
|
86
117
|
continue;
|
|
87
118
|
}
|
|
88
119
|
if (binding.captureAuthorityKind === "workos_m2m") {
|
|
89
|
-
|
|
90
|
-
|
|
120
|
+
const apiUrl = machineApiUrl(getSiteUrl());
|
|
121
|
+
if (binding.clientId && (bucket === machineJournalBucket({
|
|
122
|
+
apiUrl,
|
|
91
123
|
clientId: binding.clientId,
|
|
92
124
|
authorizedUserId: binding.authorizedUserId
|
|
93
|
-
})
|
|
125
|
+
}) || // What this client captured before its identity was verified. Those
|
|
126
|
+
// belong to whoever the server says the client is, which is now
|
|
127
|
+
// known; no verified identity's bucket is opened this way.
|
|
128
|
+
bucket === machinePendingBucket({ apiUrl, clientId: binding.clientId })))
|
|
94
129
|
deliverableBuckets.add(bucket);
|
|
95
130
|
else
|
|
96
131
|
retainedBuckets.push({
|
|
@@ -120,7 +155,10 @@ function buildOrganizationBoundMoveRequest(batch, binding) {
|
|
|
120
155
|
}
|
|
121
156
|
const { captureActor, ...wireMove } = move;
|
|
122
157
|
if (binding.captureAuthorityKind === "workos_m2m") {
|
|
123
|
-
if (!captureActor || captureActor.clientId !== binding.clientId || captureActor.
|
|
158
|
+
if (!captureActor || captureActor.clientId !== binding.clientId || captureActor.apiUrl !== machineApiUrl(getSiteUrl()) || // An identity-pending actor names only its client and is bound to
|
|
159
|
+
// the identity verified for it. Any other actor is a claim about a
|
|
160
|
+
// verified identity and must match this one exactly.
|
|
161
|
+
!identityPending(captureActor) && (captureActor.authorizedUserId !== binding.authorizedUserId || captureActor.machineId && captureActor.machineId !== binding.machineId || captureActor.organizationId && captureActor.organizationId !== binding.organizationId))
|
|
124
162
|
throw new InvalidJournalEnvelopeError();
|
|
125
163
|
} else if (captureActor) throw new InvalidJournalEnvelopeError();
|
|
126
164
|
return {
|
|
@@ -170,41 +208,12 @@ async function inspectJournalDelivery(buckets, options = {}) {
|
|
|
170
208
|
};
|
|
171
209
|
}
|
|
172
210
|
|
|
173
|
-
// src/ingest-response.ts
|
|
174
|
-
var IngestAcknowledgementError = class extends Error {
|
|
175
|
-
constructor(message) {
|
|
176
|
-
super(message);
|
|
177
|
-
this.name = "IngestAcknowledgementError";
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
function requireDurableIngestAcknowledgement(value, expected, cwd = process.cwd()) {
|
|
181
|
-
if (typeof value !== "object" || value === null) {
|
|
182
|
-
throw new IngestAcknowledgementError("ingest response was not an object");
|
|
183
|
-
}
|
|
184
|
-
const response = value;
|
|
185
|
-
if (response.disposition !== "persisted") {
|
|
186
|
-
throw new IngestAcknowledgementError("ingest response did not confirm persistence");
|
|
187
|
-
}
|
|
188
|
-
if (response.acknowledged !== expected) {
|
|
189
|
-
throw new IngestAcknowledgementError(
|
|
190
|
-
`ingest acknowledged ${String(response.acknowledged)} of ${String(expected)} moves`
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
if (typeof response.collectScopeVersion === "number" && Number.isSafeInteger(response.collectScopeVersion) && response.collectScopeVersion >= 0) {
|
|
194
|
-
const roots = typeof cwd === "string" ? [cwd] : cwd;
|
|
195
|
-
for (const root of new Set(roots)) {
|
|
196
|
-
scheduleCollectScopeRefresh(root, response.collectScopeVersion);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return value;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
211
|
export {
|
|
212
|
+
requireDurableIngestAcknowledgement,
|
|
203
213
|
InvalidJournalEnvelopeError,
|
|
204
214
|
parseOrganizationBinding,
|
|
205
215
|
summarizeRetainedBuckets,
|
|
206
216
|
classifyJournalBuckets,
|
|
207
217
|
buildOrganizationBoundMoveRequest,
|
|
208
|
-
inspectJournalDelivery
|
|
209
|
-
requireDurableIngestAcknowledgement
|
|
218
|
+
inspectJournalDelivery
|
|
210
219
|
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
analyzeShellTargets,
|
|
3
3
|
extractFileTargets
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EQWUCFXK.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_RULES,
|
|
7
7
|
scrub
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-P4O7L7JZ.js";
|
|
9
9
|
import {
|
|
10
10
|
boundedHealthError,
|
|
11
11
|
isPreflightResponseV4
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-NYDM4HSS.js";
|
|
13
13
|
import {
|
|
14
|
-
getClient
|
|
15
|
-
|
|
16
|
-
} from "./chunk-ZKXNJB6U.js";
|
|
14
|
+
getClient
|
|
15
|
+
} from "./chunk-3KPTVK4N.js";
|
|
17
16
|
import {
|
|
18
17
|
canonicalGitRoot,
|
|
19
|
-
canonicalRepositoryPath
|
|
20
|
-
|
|
18
|
+
canonicalRepositoryPath,
|
|
19
|
+
terminalSafeLine
|
|
20
|
+
} from "./chunk-6QAXVFRJ.js";
|
|
21
21
|
|
|
22
22
|
// src/hooks/approval-copy.ts
|
|
23
23
|
var MAX_EXCERPT_CHARS = 80;
|
|
@@ -55,9 +55,14 @@ function decisionLabel(conflict) {
|
|
|
55
55
|
const title = typeof conflict.title === "string" ? displayText(conflict.title, MAX_TITLE_CHARS) : "";
|
|
56
56
|
return title ? `Decision ${id}: \u201C${title}\u201D.` : `Decision ${id}: details unavailable; inspect it before approving.`;
|
|
57
57
|
}
|
|
58
|
+
function isEmptyCheck(check) {
|
|
59
|
+
const coverage = check.evaluationCoverage;
|
|
60
|
+
return coverage?.status === "not_run" && coverage.candidateCount === 0 && (check.verdict === "allow" || check.verdict === "warn") && check.conflicts.length === 0;
|
|
61
|
+
}
|
|
58
62
|
function incomplete(evidence) {
|
|
59
63
|
const coverage = evidence.evaluationCoverage;
|
|
60
|
-
|
|
64
|
+
const settled = coverage?.status === void 0 || coverage.status === "completed" || isEmptyCheck(evidence);
|
|
65
|
+
return Array.isArray(coverage?.selectionOmissions) && coverage.selectionOmissions.length > 0 || Array.isArray(coverage?.evidenceOmissions) && coverage.evidenceOmissions.length > 0 || !settled || ["candidate_set_truncated", "evidence_incomplete", "coverage_unverified"].includes(
|
|
61
66
|
evidence.reasonCode
|
|
62
67
|
);
|
|
63
68
|
}
|
|
@@ -191,6 +196,13 @@ function proposedChangeExcerpt(proposal) {
|
|
|
191
196
|
}
|
|
192
197
|
return boundedHealthError(proposal);
|
|
193
198
|
}
|
|
199
|
+
var COVERAGE_NOTE = "[primitive] Decision coverage is incomplete; some candidates or evidence were not evaluated.";
|
|
200
|
+
function coverageNote(response) {
|
|
201
|
+
const coverage = response.evaluationCoverage;
|
|
202
|
+
if (!coverage) return "";
|
|
203
|
+
const settled = coverage.status === "completed" || isEmptyCheck(response);
|
|
204
|
+
return !settled || coverage.selectionOmissions?.length || coverage.evidenceOmissions?.length ? COVERAGE_NOTE : "";
|
|
205
|
+
}
|
|
194
206
|
function resultForPreflight(response, preview = "Review the requested change.", invocation, proposalTruncated = false) {
|
|
195
207
|
const verdict = response.verdict === "block" ? "deny" : response.verdict;
|
|
196
208
|
const silentCoverageOutcome = response.reasonCode === "coverage_unverified" || response.reasonCode === "candidate_set_truncated";
|
|
@@ -226,6 +238,7 @@ function resultForPreflight(response, preview = "Review the requested change.",
|
|
|
226
238
|
conflicts: response.conflicts,
|
|
227
239
|
message,
|
|
228
240
|
reasonCode: response.reasonCode,
|
|
241
|
+
verdict: response.verdict,
|
|
229
242
|
evaluationCoverage: response.evaluationCoverage
|
|
230
243
|
},
|
|
231
244
|
preview
|
|
@@ -470,6 +483,7 @@ export {
|
|
|
470
483
|
proposalFor,
|
|
471
484
|
proposalIsTruncated,
|
|
472
485
|
requestPreflight,
|
|
486
|
+
coverageNote,
|
|
473
487
|
resultForPreflight,
|
|
474
488
|
unverifiedResult,
|
|
475
489
|
PREFLIGHT_PROTOCOL_VERSION2 as PREFLIGHT_PROTOCOL_VERSION,
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./chunk-EZXEWFDG.js";
|
|
4
4
|
import {
|
|
5
5
|
scrubEnvironmentPaths
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-P4O7L7JZ.js";
|
|
7
7
|
import {
|
|
8
8
|
isValidRepoSyncId
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6QAXVFRJ.js";
|
|
10
10
|
|
|
11
11
|
// src/hooks/prim-hook-core.ts
|
|
12
12
|
import { createHash, randomUUID } from "crypto";
|