@primitive.ai/prim 0.1.0-alpha.127 → 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.
Files changed (44) hide show
  1. package/README.md +76 -5
  2. package/dist/{chunk-NVDPKW7Z.js → chunk-3KPTVK4N.js} +3 -51
  3. package/dist/{chunk-URYZDQFH.js → chunk-4DYEBYKM.js} +3 -5
  4. package/dist/{chunk-HZI5PBN4.js → chunk-6QAXVFRJ.js} +1129 -39
  5. package/dist/{chunk-A5VTE43F.js → chunk-ANMNGGTN.js} +2 -2
  6. package/dist/{chunk-TNWI3JWK.js → chunk-B3ICJZXV.js} +4 -2
  7. package/dist/{chunk-RV3JFSMX.js → chunk-C357P37M.js} +4 -4
  8. package/dist/{chunk-KFRGVHGB.js → chunk-E57UVUJL.js} +6 -6
  9. package/dist/{chunk-MGKSZSTV.js → chunk-EQWUCFXK.js} +3 -3
  10. package/dist/{chunk-72NIZMZN.js → chunk-M6KIDB5R.js} +8 -3
  11. package/dist/{chunk-O65UVJZH.js → chunk-N6PZE7HX.js} +2 -2
  12. package/dist/{chunk-WGTUNUIS.js → chunk-NYDM4HSS.js} +5 -5
  13. package/dist/{chunk-R4EYLEIK.js → chunk-P4O7L7JZ.js} +2 -2
  14. package/dist/{chunk-UUQT5GMO.js → chunk-PRJ7P6J5.js} +1 -1
  15. package/dist/{chunk-H74RDXKP.js → chunk-PTZ6BWSU.js} +2 -2
  16. package/dist/{chunk-F3FDVHR7.js → chunk-QQ3G5SXX.js} +1 -1
  17. package/dist/{chunk-VVFVENU4.js → chunk-RDT2IV2Z.js} +6 -6
  18. package/dist/{chunk-L6IL4N6Y.js → chunk-VLT2KGPE.js} +34 -34
  19. package/dist/{chunk-H6X52UVF.js → chunk-WEGZGF3K.js} +1 -1
  20. package/dist/{chunk-C4QNBSWB.js → chunk-XINFTNA2.js} +8 -8
  21. package/dist/{chunk-JCKOW45X.js → chunk-ZCT23NBS.js} +2 -2
  22. package/dist/daemon/server.js +1311 -364
  23. package/dist/hook-runtime/daemon/server.js +1311 -364
  24. package/dist/hook-runtime/hooks/post-commit.js +395 -242
  25. package/dist/hook-runtime/hooks/post-rewrite.js +391 -238
  26. package/dist/hook-runtime/hooks/post-tool-use.js +1442 -498
  27. package/dist/hook-runtime/hooks/pre-commit.js +1293 -349
  28. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +1087 -143
  29. package/dist/hook-runtime/hooks/prim-hook.js +1457 -513
  30. package/dist/hook-runtime/hooks/session-end.js +369 -216
  31. package/dist/hook-runtime/hooks/session-start.js +1209 -219
  32. package/dist/hook-runtime/index.js +2406 -1036
  33. package/dist/hook-runtime/statusline-main.js +360 -207
  34. package/dist/hooks/post-commit.js +7 -7
  35. package/dist/hooks/post-rewrite.js +6 -6
  36. package/dist/hooks/post-tool-use.js +18 -18
  37. package/dist/hooks/pre-commit.js +4 -4
  38. package/dist/hooks/pre-tool-use-worker.js +9 -9
  39. package/dist/hooks/prim-hook.js +16 -16
  40. package/dist/hooks/session-end.js +4 -4
  41. package/dist/hooks/session-start.js +63 -20
  42. package/dist/index.js +387 -43
  43. package/dist/statusline-main.js +360 -207
  44. package/package.json +1 -1
@@ -11,10 +11,10 @@ import {
11
11
  saveRun,
12
12
  sessionExcluded,
13
13
  sessionKey
14
- } from "./chunk-MGKSZSTV.js";
14
+ } from "./chunk-EQWUCFXK.js";
15
15
  import {
16
16
  packageVersion
17
- } from "./chunk-HZI5PBN4.js";
17
+ } from "./chunk-6QAXVFRJ.js";
18
18
 
19
19
  // src/demo/isolation.ts
20
20
  import { existsSync } from "fs";
@@ -1,9 +1,11 @@
1
1
  import {
2
- getClient,
2
+ getClient
3
+ } from "./chunk-3KPTVK4N.js";
4
+ import {
3
5
  isTerminalSafeText,
4
6
  terminalSafeLine,
5
7
  terminalSafeText
6
- } from "./chunk-NVDPKW7Z.js";
8
+ } from "./chunk-6QAXVFRJ.js";
7
9
 
8
10
  // src/decisions/feedback.ts
9
11
  var FEEDBACK_PROTOCOL_VERSION = 2;
@@ -4,20 +4,20 @@ import {
4
4
  import {
5
5
  analyzeShellTargets,
6
6
  extractFileTargets
7
- } from "./chunk-MGKSZSTV.js";
7
+ } from "./chunk-EQWUCFXK.js";
8
8
  import {
9
9
  scrubEnvironmentPaths
10
- } from "./chunk-R4EYLEIK.js";
10
+ } from "./chunk-P4O7L7JZ.js";
11
11
  import {
12
12
  cachedCollectScopeAdmits
13
- } from "./chunk-WGTUNUIS.js";
13
+ } from "./chunk-NYDM4HSS.js";
14
14
  import {
15
15
  canonicalRepositoryPath,
16
16
  currentBranch,
17
17
  isRepoActiveForCapture,
18
18
  relatedWorktreeTarget,
19
19
  repoSyncId
20
- } from "./chunk-HZI5PBN4.js";
20
+ } from "./chunk-6QAXVFRJ.js";
21
21
 
22
22
  // src/hooks/file-refs.ts
23
23
  var MAX_PREFLIGHT_FILE_TARGETS = 25;
@@ -1,24 +1,24 @@
1
1
  import {
2
2
  formatStatusline
3
- } from "./chunk-URYZDQFH.js";
3
+ } from "./chunk-4DYEBYKM.js";
4
4
  import {
5
5
  daemonPrincipalsMatch,
6
6
  daemonRequest,
7
7
  resolveDaemonPrincipal
8
- } from "./chunk-H6X52UVF.js";
8
+ } from "./chunk-WEGZGF3K.js";
9
9
  import {
10
10
  getSiteUrl,
11
- isSessionEnded,
12
- terminalSafeText
13
- } from "./chunk-NVDPKW7Z.js";
11
+ isSessionEnded
12
+ } from "./chunk-3KPTVK4N.js";
14
13
  import {
15
14
  decisionIngestionStatus,
16
15
  gitToplevel,
17
16
  packageVersion,
18
17
  primConfigDirectory,
19
18
  repositoryBindingState,
19
+ terminalSafeText,
20
20
  withFileLock
21
- } from "./chunk-HZI5PBN4.js";
21
+ } from "./chunk-6QAXVFRJ.js";
22
22
 
23
23
  // src/hooks/codex-context.ts
24
24
  import { createHash, randomBytes as randomBytes2 } from "crypto";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  inspectHookRuntime
3
- } from "./chunk-UUQT5GMO.js";
3
+ } from "./chunk-PRJ7P6J5.js";
4
4
  import {
5
5
  isDemoStatusResponse
6
- } from "./chunk-WGTUNUIS.js";
6
+ } from "./chunk-NYDM4HSS.js";
7
7
  import {
8
8
  atomicWriteFile,
9
9
  primConfigDirectory,
10
10
  withFileLock,
11
11
  withFileLockSync
12
- } from "./chunk-HZI5PBN4.js";
12
+ } from "./chunk-6QAXVFRJ.js";
13
13
 
14
14
  // src/hooks/pre-tool-use-scoring.ts
15
15
  import { isAbsolute, relative, sep } from "path";
@@ -9,14 +9,15 @@ import {
9
9
  hookBlockContractVersion,
10
10
  inspectGitHookEntrypoint,
11
11
  managedHookBlock
12
- } from "./chunk-UUQT5GMO.js";
12
+ } from "./chunk-PRJ7P6J5.js";
13
13
  import {
14
14
  HttpError,
15
15
  getClient,
16
16
  getSiteUrl
17
- } from "./chunk-NVDPKW7Z.js";
17
+ } from "./chunk-3KPTVK4N.js";
18
18
  import {
19
19
  CLOUD_CREDENTIALS_REMEDY,
20
+ CLOUD_REJECTED_CREDENTIALS_NOTICE,
20
21
  MachineAuthError,
21
22
  NETWORK_TOKEN_AUTH,
22
23
  atomicWriteFile,
@@ -36,7 +37,7 @@ import {
36
37
  setRepoSyncId,
37
38
  setRepositoryBindingState,
38
39
  withFileLock
39
- } from "./chunk-HZI5PBN4.js";
40
+ } from "./chunk-6QAXVFRJ.js";
40
41
 
41
42
  // src/commands/skill.ts
42
43
  import { createHash as createHash3 } from "crypto";
@@ -854,6 +855,9 @@ function unreachable(what, failure, remedy) {
854
855
  return `${what} did not answer in time. If this persists, check that you ${remedy.replace(/^add /u, "added ")}.`;
855
856
  return `${what} could not be reached (${failure}). Check the environment's network access: ${remedy}.`;
856
857
  }
858
+ function credentialRejected(error) {
859
+ return error instanceof HttpError && error.status === 401;
860
+ }
857
861
  async function diagnoseCloudSession(options = {}) {
858
862
  const env = options.env ?? process.env;
859
863
  if (!isClaudeCloudSession(env)) return void 0;
@@ -868,6 +872,7 @@ async function diagnoseCloudSession(options = {}) {
868
872
  }
869
873
  if (!machine && !resolveStoredCredential(env))
870
874
  return `${prefix}: it has no credentials. To fix it, ${CLOUD_CREDENTIALS_REMEDY}.`;
875
+ if (machine && credentialRejected(options.bindFailure)) return CLOUD_REJECTED_CREDENTIALS_NOTICE;
871
876
  if (options.cwd !== void 0 && !githubRepositoryFullName(options.cwd))
872
877
  return `${prefix}: ${repositoryIdentityRemedy(options.cwd)}.`;
873
878
  const fetchImpl = options.fetch ?? fetch;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getSiteUrl
3
- } from "./chunk-NVDPKW7Z.js";
3
+ } from "./chunk-3KPTVK4N.js";
4
4
  import {
5
5
  atomicWriteFile,
6
6
  ensureDurableDirectory,
@@ -13,7 +13,7 @@ import {
13
13
  machinePendingBucket,
14
14
  primConfigDirectory,
15
15
  resolveAuthCredential
16
- } from "./chunk-HZI5PBN4.js";
16
+ } from "./chunk-6QAXVFRJ.js";
17
17
 
18
18
  // src/journal.ts
19
19
  import {
@@ -1,11 +1,11 @@
1
1
  import {
2
- getClient,
3
- terminalSafeLine
4
- } from "./chunk-NVDPKW7Z.js";
2
+ getClient
3
+ } from "./chunk-3KPTVK4N.js";
5
4
  import {
6
5
  localGitConfigValue,
7
- setLocalGitConfigValue
8
- } from "./chunk-HZI5PBN4.js";
6
+ setLocalGitConfigValue,
7
+ terminalSafeLine
8
+ } from "./chunk-6QAXVFRJ.js";
9
9
  import {
10
10
  __commonJS,
11
11
  __toESM
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  boundedHealthError
3
- } from "./chunk-WGTUNUIS.js";
3
+ } from "./chunk-NYDM4HSS.js";
4
4
  import {
5
5
  terminalSafeLine
6
- } from "./chunk-NVDPKW7Z.js";
6
+ } from "./chunk-6QAXVFRJ.js";
7
7
 
8
8
  // src/hooks/redact.ts
9
9
  import { existsSync, readFileSync, statSync } from "fs";
@@ -21,7 +21,7 @@ import {
21
21
  syncDirectory,
22
22
  syncFile,
23
23
  withFileLockSync
24
- } from "./chunk-HZI5PBN4.js";
24
+ } from "./chunk-6QAXVFRJ.js";
25
25
 
26
26
  // src/commands/claude-install.ts
27
27
  import { existsSync as existsSync3, lstatSync as lstatSync2, readFileSync as readFileSync2 } from "fs";
@@ -2,10 +2,10 @@ import {
2
2
  cursorHooksPath,
3
3
  hasExactCursorHandler,
4
4
  readCursorHooks
5
- } from "./chunk-UUQT5GMO.js";
5
+ } from "./chunk-PRJ7P6J5.js";
6
6
  import {
7
7
  resolveRepositoryContext
8
- } from "./chunk-HZI5PBN4.js";
8
+ } from "./chunk-6QAXVFRJ.js";
9
9
 
10
10
  // src/hooks/cursor-coexistence.ts
11
11
  var CURSOR_EVENTS = /* @__PURE__ */ new Set([
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  atomicWriteFile,
3
3
  repoActiveFlag
4
- } from "./chunk-HZI5PBN4.js";
4
+ } from "./chunk-6QAXVFRJ.js";
5
5
 
6
6
  // src/lib/commit-heartbeat.ts
7
7
  import { execFileSync } from "child_process";
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  daemonRequest
3
- } from "./chunk-H6X52UVF.js";
3
+ } from "./chunk-WEGZGF3K.js";
4
4
  import {
5
5
  getClient,
6
- getSiteUrl,
7
- terminalSafeLine
8
- } from "./chunk-NVDPKW7Z.js";
6
+ getSiteUrl
7
+ } from "./chunk-3KPTVK4N.js";
9
8
  import {
10
9
  canonicalGitRoot,
11
10
  canonicalRepositoryPath,
12
11
  cloudSetupPointer,
13
12
  currentBranch,
14
13
  isClaudeCloudSession,
15
- repoSyncId
16
- } from "./chunk-HZI5PBN4.js";
14
+ repoSyncId,
15
+ terminalSafeLine
16
+ } from "./chunk-6QAXVFRJ.js";
17
17
 
18
18
  // src/daemon/proxy.ts
19
19
  var DAEMON_HTTP_TIMEOUT_MS = 1e4;
@@ -1,18 +1,47 @@
1
1
  import {
2
2
  isMoveIngestRequest,
3
3
  scheduleCollectScopeRefresh
4
- } from "./chunk-WGTUNUIS.js";
4
+ } from "./chunk-NYDM4HSS.js";
5
5
  import {
6
6
  getPinnedClient,
7
7
  getSiteUrl
8
- } from "./chunk-NVDPKW7Z.js";
8
+ } from "./chunk-3KPTVK4N.js";
9
9
  import {
10
10
  identityPending,
11
11
  machineApiUrl,
12
12
  machineJournalBucket,
13
13
  machinePendingBucket,
14
14
  parseMachineIdentity
15
- } from "./chunk-HZI5PBN4.js";
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
+ }
16
45
 
17
46
  // src/protocol/decision-lifecycle.ts
18
47
  var DECISION_LIFECYCLE_PROTOCOL_VERSION = 2;
@@ -179,41 +208,12 @@ async function inspectJournalDelivery(buckets, options = {}) {
179
208
  };
180
209
  }
181
210
 
182
- // src/ingest-response.ts
183
- var IngestAcknowledgementError = class extends Error {
184
- constructor(message) {
185
- super(message);
186
- this.name = "IngestAcknowledgementError";
187
- }
188
- };
189
- function requireDurableIngestAcknowledgement(value, expected, cwd = process.cwd()) {
190
- if (typeof value !== "object" || value === null) {
191
- throw new IngestAcknowledgementError("ingest response was not an object");
192
- }
193
- const response = value;
194
- if (response.disposition !== "persisted") {
195
- throw new IngestAcknowledgementError("ingest response did not confirm persistence");
196
- }
197
- if (response.acknowledged !== expected) {
198
- throw new IngestAcknowledgementError(
199
- `ingest acknowledged ${String(response.acknowledged)} of ${String(expected)} moves`
200
- );
201
- }
202
- if (typeof response.collectScopeVersion === "number" && Number.isSafeInteger(response.collectScopeVersion) && response.collectScopeVersion >= 0) {
203
- const roots = typeof cwd === "string" ? [cwd] : cwd;
204
- for (const root of new Set(roots)) {
205
- scheduleCollectScopeRefresh(root, response.collectScopeVersion);
206
- }
207
- }
208
- return value;
209
- }
210
-
211
211
  export {
212
+ requireDurableIngestAcknowledgement,
212
213
  InvalidJournalEnvelopeError,
213
214
  parseOrganizationBinding,
214
215
  summarizeRetainedBuckets,
215
216
  classifyJournalBuckets,
216
217
  buildOrganizationBoundMoveRequest,
217
- inspectJournalDelivery,
218
- requireDurableIngestAcknowledgement
218
+ inspectJournalDelivery
219
219
  };
@@ -4,7 +4,7 @@ import {
4
4
  machineContext,
5
5
  primConfigDirectory,
6
6
  resolveAuthCredential
7
- } from "./chunk-HZI5PBN4.js";
7
+ } from "./chunk-6QAXVFRJ.js";
8
8
 
9
9
  // src/daemon/principal.ts
10
10
  import { createHash } from "crypto";
@@ -1,23 +1,23 @@
1
1
  import {
2
2
  analyzeShellTargets,
3
3
  extractFileTargets
4
- } from "./chunk-MGKSZSTV.js";
4
+ } from "./chunk-EQWUCFXK.js";
5
5
  import {
6
6
  DEFAULT_RULES,
7
7
  scrub
8
- } from "./chunk-R4EYLEIK.js";
8
+ } from "./chunk-P4O7L7JZ.js";
9
9
  import {
10
10
  boundedHealthError,
11
11
  isPreflightResponseV4
12
- } from "./chunk-WGTUNUIS.js";
12
+ } from "./chunk-NYDM4HSS.js";
13
13
  import {
14
- getClient,
15
- terminalSafeLine
16
- } from "./chunk-NVDPKW7Z.js";
14
+ getClient
15
+ } from "./chunk-3KPTVK4N.js";
17
16
  import {
18
17
  canonicalGitRoot,
19
- canonicalRepositoryPath
20
- } from "./chunk-HZI5PBN4.js";
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;
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-EZXEWFDG.js";
4
4
  import {
5
5
  scrubEnvironmentPaths
6
- } from "./chunk-R4EYLEIK.js";
6
+ } from "./chunk-P4O7L7JZ.js";
7
7
  import {
8
8
  isValidRepoSyncId
9
- } from "./chunk-HZI5PBN4.js";
9
+ } from "./chunk-6QAXVFRJ.js";
10
10
 
11
11
  // src/hooks/prim-hook-core.ts
12
12
  import { createHash, randomUUID } from "crypto";