@primitive.ai/prim 0.1.0-alpha.113 → 0.1.0-alpha.115

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.
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  enrichHookPayloadWithFileRefs,
7
7
  preserveHookFileMetadata
8
- } from "../chunk-IW5HCCOW.js";
8
+ } from "../chunk-IMYELJIV.js";
9
9
  import {
10
10
  postToolInvocationId,
11
11
  toMove,
@@ -20,7 +20,7 @@ import {
20
20
  } from "../chunk-HMD5K6W7.js";
21
21
  import {
22
22
  observeDemoInvocation
23
- } from "../chunk-XV6C5ZV2.js";
23
+ } from "../chunk-RUUSUF43.js";
24
24
  import {
25
25
  appendCodexContext,
26
26
  prepareCodexContext
@@ -13,7 +13,7 @@ import {
13
13
  failOpenOutput,
14
14
  observeDemoInvocation,
15
15
  readHookMode
16
- } from "../chunk-XV6C5ZV2.js";
16
+ } from "../chunk-RUUSUF43.js";
17
17
  import {
18
18
  appendCodexContext,
19
19
  hasVisibleCodexMessage,
@@ -174,6 +174,9 @@ function proposalFor(toolInput) {
174
174
  const redacted = scrub(toolInput, DEFAULT_RULES);
175
175
  return truncateUtf8(JSON.stringify(redacted) ?? "", MAX_PROPOSAL_BYTES);
176
176
  }
177
+ function proposalIsTruncated(toolInput) {
178
+ return Buffer.byteLength(JSON.stringify(scrub(toolInput, DEFAULT_RULES)) ?? "") > MAX_PROPOSAL_BYTES;
179
+ }
177
180
  function parsePreflightResponse(value) {
178
181
  if (!value || typeof value !== "object" || Array.isArray(value)) return null;
179
182
  const response = value;
@@ -222,7 +225,7 @@ function proposedChangeExcerpt(proposal) {
222
225
  }
223
226
  return boundedHealthError(proposal);
224
227
  }
225
- function resultForPreflight(response, preview = "Review the requested change.", invocation) {
228
+ function resultForPreflight(response, preview = "Review the requested change.", invocation, proposalTruncated = false) {
226
229
  const verdict = response.verdict === "block" ? "deny" : response.verdict;
227
230
  const message = boundedHealthError(response.message) ?? "";
228
231
  const unavailable = message || boundedHealthError(response.reasonCode);
@@ -261,12 +264,14 @@ function resultForPreflight(response, preview = "Review the requested change.",
261
264
  preview
262
265
  ) : message;
263
266
  const disclosureContext = decisionDisclosureContext(response);
267
+ const truncationNote = proposalTruncated ? "[primitive] shell proposal was truncated; the complete change was not verified" : "";
264
268
  return {
265
269
  verdict,
266
270
  conflicts: response.conflicts,
267
- reason,
271
+ reason: [reason, truncationNote].filter(Boolean).join("\n"),
268
272
  additionalContext: [
269
273
  disclosureContext,
274
+ truncationNote,
270
275
  ["warn", "ask", "block"].includes(response.verdict) ? guidance : ""
271
276
  ].filter(Boolean).join("\n"),
272
277
  truncated: false,
@@ -287,6 +292,7 @@ function unverifiedResult(message) {
287
292
  // src/hooks/pre-tool-use.ts
288
293
  var STDIN_TIMEOUT_MS = 1e3;
289
294
  var agent = parseAgent(process.argv);
295
+ var uncheckedMutation;
290
296
  async function emit(output) {
291
297
  return await new Promise((resolve) => {
292
298
  try {
@@ -412,8 +418,12 @@ async function main() {
412
418
  await emit(failOpen());
413
419
  return;
414
420
  }
421
+ uncheckedMutation = envelope;
415
422
  if (targets.paths.length === 0 && !targets.definite) {
416
- await emit(failOpen());
423
+ await emitUnverified(
424
+ "shell command write targets could not be determined; change was not verified",
425
+ envelope
426
+ );
417
427
  return;
418
428
  }
419
429
  if (agent === "cursor" && targets.coverage === "unverified") {
@@ -461,7 +471,8 @@ async function main() {
461
471
  result = resultForPreflight(
462
472
  response,
463
473
  editPreview(toolName, envelope.tool_input, targets.paths),
464
- request
474
+ request,
475
+ collectScopeAdmits && (toolName === "Bash" || toolName === "Shell") && proposalIsTruncated(envelope.tool_input)
465
476
  );
466
477
  } catch (error) {
467
478
  await emitUnverified(preflightFailure(error), envelope);
@@ -489,5 +500,10 @@ async function main() {
489
500
  await emit(output);
490
501
  }
491
502
  main().catch(async () => {
492
- await emit(failOpen());
503
+ if (uncheckedMutation)
504
+ await emitUnverified(
505
+ "hook failed while checking a possible write; change was not verified",
506
+ uncheckedMutation
507
+ );
508
+ else await emit(failOpen());
493
509
  });
@@ -18,7 +18,7 @@ import {
18
18
  import {
19
19
  enrichHookPayloadWithFileRefs,
20
20
  preserveHookFileMetadata
21
- } from "../chunk-IW5HCCOW.js";
21
+ } from "../chunk-IMYELJIV.js";
22
22
  import {
23
23
  postToolInvocationId,
24
24
  shouldFlushAfter,
@@ -33,7 +33,7 @@ import {
33
33
  } from "../chunk-HMD5K6W7.js";
34
34
  import {
35
35
  observeDemoInvocation
36
- } from "../chunk-XV6C5ZV2.js";
36
+ } from "../chunk-RUUSUF43.js";
37
37
  import {
38
38
  prepareCodexContext
39
39
  } from "../chunk-PJW6JZMH.js";