@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.
@@ -7,24 +7,25 @@ import {
7
7
  import {
8
8
  enrichHookPayloadWithFileRefs,
9
9
  preserveHookFileMetadata
10
- } from "../chunk-DA4BMHEB.js";
10
+ } from "../chunk-VYGY3OOX.js";
11
11
  import {
12
12
  postToolInvocationId,
13
- toMove
14
- } from "../chunk-QGVHLP5J.js";
13
+ toMove,
14
+ toolOutcomeFor
15
+ } from "../chunk-7X7SFOPJ.js";
15
16
  import {
16
17
  appendMove,
17
18
  resolveOrg
18
- } from "../chunk-S4LFRVGD.js";
19
+ } from "../chunk-HIMWM526.js";
19
20
  import {
20
21
  scrubFromCwd
21
- } from "../chunk-GF5QII7T.js";
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-KBFFVYBC.js";
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-I3HIPAIR.js";
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
- const envelope = parsed;
141
- if (envelope.hook_event_name !== "PostToolUse") {
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
- const editingTools = editingToolsFor(agent);
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 (resolution.shellMutation === "none") {
174
- emit();
175
- return;
176
- }
177
- if (resolution.shellMutation === void 0 && resolution.fileRefs.length === 0) {
178
- emit();
179
- return;
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 = {
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  checkAffectedDecisions,
4
4
  formatDecisionsWarning
5
- } from "../chunk-YITJ2H3B.js";
6
- import "../chunk-I3HIPAIR.js";
5
+ } from "../chunk-WS3MCNFD.js";
6
+ import "../chunk-CPX3BUOC.js";
7
7
  import "../chunk-UTKQTZHL.js";
8
8
 
9
9
  // src/hooks/pre-commit.ts
@@ -12,10 +12,11 @@ import {
12
12
  failOpenOutput,
13
13
  readHookMode,
14
14
  scrub
15
- } from "../chunk-GF5QII7T.js";
15
+ } from "../chunk-G5D3FF3D.js";
16
16
  import {
17
+ packageVersion,
17
18
  warmBinCache
18
- } from "../chunk-KBFFVYBC.js";
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-I3HIPAIR.js";
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,
@@ -2,19 +2,19 @@
2
2
  import {
3
3
  enrichHookPayloadWithFileRefs,
4
4
  preserveHookFileMetadata
5
- } from "../chunk-DA4BMHEB.js";
5
+ } from "../chunk-VYGY3OOX.js";
6
6
  import {
7
7
  postToolInvocationId,
8
8
  shouldFlushAfter,
9
9
  toMove
10
- } from "../chunk-QGVHLP5J.js";
10
+ } from "../chunk-7X7SFOPJ.js";
11
11
  import {
12
12
  appendMove,
13
13
  resolveOrg
14
- } from "../chunk-S4LFRVGD.js";
14
+ } from "../chunk-HIMWM526.js";
15
15
  import {
16
16
  scrubFromCwd
17
- } from "../chunk-GF5QII7T.js";
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-R4CUX6FY.js";
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-KBFFVYBC.js";
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-I3HIPAIR.js";
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-LOGW54W5.js";
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-R4CUX6FY.js";
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-KBFFVYBC.js";
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-I3HIPAIR.js";
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
- [primEntry, "daemon", "ensure"],
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
- if (!repoSyncId(root)) {
102
- try {
103
- await bindRepository(root, {
104
- signal: AbortSignal.timeout(REPOSITORY_BIND_TIMEOUT_MS),
105
- quietRefresh: true
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 {