@primitive.ai/prim 0.1.0-alpha.96 → 0.1.0-alpha.98

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 (39) hide show
  1. package/README.md +9 -0
  2. package/dist/{chunk-YYE2NLWX.js → chunk-2DA2B4EC.js} +2 -2
  3. package/dist/{chunk-35FMRWJH.js → chunk-2DPLT2CQ.js} +1 -1
  4. package/dist/{chunk-XEDJ5N3M.js → chunk-3X77XQGW.js} +2 -4
  5. package/dist/{chunk-DWRSEC34.js → chunk-6QK75B7G.js} +392 -15
  6. package/dist/{chunk-Z6NPNLOT.js → chunk-7IPGD6CD.js} +1708 -1578
  7. package/dist/{chunk-RK4ZS3HG.js → chunk-AN6XTFIN.js} +2 -2
  8. package/dist/{chunk-LY6NJ7KL.js → chunk-B6EPQ4YH.js} +1 -1
  9. package/dist/{chunk-URLLSALP.js → chunk-BIAWZMCK.js} +2 -2
  10. package/dist/{chunk-QCBB5HFX.js → chunk-HUZXBJJ5.js} +1 -1
  11. package/dist/{chunk-ROLYLXJS.js → chunk-IL443QTF.js} +2 -2
  12. package/dist/{chunk-7KABYYWG.js → chunk-JOR67B5T.js} +6 -8
  13. package/dist/{chunk-FVDBULGZ.js → chunk-MN4X6RR6.js} +8 -10
  14. package/dist/{chunk-UO2U6IKF.js → chunk-NIQAVFP6.js} +1 -1
  15. package/dist/{chunk-CU7RW7XU.js → chunk-PPZBEOWK.js} +3 -3
  16. package/dist/{chunk-4GHANPWQ.js → chunk-QPMLAD2C.js} +2 -2
  17. package/dist/{chunk-Y5W4TZM7.js → chunk-RT7DXMTN.js} +2 -4
  18. package/dist/{chunk-27ADT6FQ.js → chunk-WKLYYT63.js} +44 -6
  19. package/dist/daemon/server.js +1704 -1572
  20. package/dist/hook-runtime/daemon/server.js +1704 -1572
  21. package/dist/hook-runtime/hooks/post-commit.js +1704 -1572
  22. package/dist/hook-runtime/hooks/post-rewrite.js +1704 -1572
  23. package/dist/hook-runtime/hooks/post-tool-use.js +1704 -1572
  24. package/dist/hook-runtime/hooks/pre-commit.js +208 -9
  25. package/dist/hook-runtime/hooks/pre-tool-use.js +1704 -1572
  26. package/dist/hook-runtime/hooks/prim-hook.js +1704 -1572
  27. package/dist/hook-runtime/hooks/session-start.js +1704 -1572
  28. package/dist/hook-runtime/index.js +1745 -1578
  29. package/dist/hooks/post-commit.js +7 -8
  30. package/dist/hooks/post-rewrite.js +6 -7
  31. package/dist/hooks/post-tool-use.js +13 -14
  32. package/dist/hooks/pre-commit.js +4 -4
  33. package/dist/hooks/pre-tool-use.js +10 -12
  34. package/dist/hooks/prim-hook.js +14 -15
  35. package/dist/hooks/session-end.js +6 -7
  36. package/dist/hooks/session-start.js +13 -14
  37. package/dist/index.js +25 -27
  38. package/package.json +1 -1
  39. package/dist/chunk-DHOQGHKQ.js +0 -379
@@ -2,10 +2,10 @@ import {
2
2
  cursorHooksPath,
3
3
  hasExactCursorHandler,
4
4
  readCursorHooks
5
- } from "./chunk-Y5W4TZM7.js";
5
+ } from "./chunk-RT7DXMTN.js";
6
6
  import {
7
7
  resolveRepositoryContext
8
- } from "./chunk-DHOQGHKQ.js";
8
+ } from "./chunk-6QK75B7G.js";
9
9
 
10
10
  // src/hooks/agent.ts
11
11
  function parseAgent(argv) {
@@ -19,7 +19,7 @@ import {
19
19
  resolveAuthCredential,
20
20
  withFileLock,
21
21
  workosConnectTokenEndpoint
22
- } from "./chunk-DWRSEC34.js";
22
+ } from "./chunk-6QK75B7G.js";
23
23
 
24
24
  // src/client.ts
25
25
  import { createHash } from "crypto";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  boundedHealthError
3
- } from "./chunk-Z6NPNLOT.js";
3
+ } from "./chunk-7IPGD6CD.js";
4
4
  import {
5
5
  terminalSafeLine
6
- } from "./chunk-LY6NJ7KL.js";
6
+ } from "./chunk-B6EPQ4YH.js";
7
7
 
8
8
  // src/hooks/redact.ts
9
9
  import { existsSync, readFileSync, statSync } from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  scheduleCollectScopeRefresh
3
- } from "./chunk-Z6NPNLOT.js";
3
+ } from "./chunk-7IPGD6CD.js";
4
4
 
5
5
  // src/ingest-response.ts
6
6
  var IngestAcknowledgementError = class extends Error {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  boundedHealthError
3
- } from "./chunk-Z6NPNLOT.js";
3
+ } from "./chunk-7IPGD6CD.js";
4
4
  import {
5
5
  stripControlChars
6
- } from "./chunk-LY6NJ7KL.js";
6
+ } from "./chunk-B6EPQ4YH.js";
7
7
 
8
8
  // src/lib/delivery-backlog.ts
9
9
  var MS_PER_SECOND = 1e3;
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  HttpError,
6
6
  getClient
7
- } from "./chunk-LY6NJ7KL.js";
7
+ } from "./chunk-B6EPQ4YH.js";
8
8
  import {
9
9
  GIT_HOOK_CONTRACT_VERSION,
10
10
  binFile,
@@ -17,19 +17,17 @@ import {
17
17
  managedHookBlock,
18
18
  pinnedHookCommand,
19
19
  pinnedNpxCommand
20
- } from "./chunk-Y5W4TZM7.js";
20
+ } from "./chunk-RT7DXMTN.js";
21
21
  import {
22
+ atomicWriteFile,
22
23
  gitToplevel,
23
24
  githubRepositoryFullName,
24
25
  isValidRepoSyncId,
25
- setRepoSyncId,
26
- setRepositoryBindingState
27
- } from "./chunk-DHOQGHKQ.js";
28
- import {
29
- atomicWriteFile,
30
26
  primConfigDirectory,
27
+ setRepoSyncId,
28
+ setRepositoryBindingState,
31
29
  withFileLock
32
- } from "./chunk-DWRSEC34.js";
30
+ } from "./chunk-6QK75B7G.js";
33
31
 
34
32
  // src/commands/skill.ts
35
33
  import { createHash as createHash2 } from "crypto";
@@ -1,28 +1,26 @@
1
1
  import {
2
2
  formatStatusline
3
- } from "./chunk-ROLYLXJS.js";
3
+ } from "./chunk-IL443QTF.js";
4
4
  import {
5
5
  getSiteUrl,
6
6
  isSessionEnded,
7
7
  terminalSafeText
8
- } from "./chunk-LY6NJ7KL.js";
8
+ } from "./chunk-B6EPQ4YH.js";
9
9
  import {
10
10
  packageVersion
11
- } from "./chunk-Y5W4TZM7.js";
12
- import {
13
- decisionIngestionStatus,
14
- gitToplevel,
15
- repositoryBindingState
16
- } from "./chunk-DHOQGHKQ.js";
11
+ } from "./chunk-RT7DXMTN.js";
17
12
  import {
18
13
  daemonPrincipalsMatch,
19
14
  daemonRequest,
20
15
  resolveDaemonPrincipal
21
- } from "./chunk-35FMRWJH.js";
16
+ } from "./chunk-2DPLT2CQ.js";
22
17
  import {
18
+ decisionIngestionStatus,
19
+ gitToplevel,
23
20
  primConfigDirectory,
21
+ repositoryBindingState,
24
22
  withFileLock
25
- } from "./chunk-DWRSEC34.js";
23
+ } from "./chunk-6QK75B7G.js";
26
24
 
27
25
  // src/hooks/codex-context.ts
28
26
  import { createHash, randomBytes as randomBytes2 } from "crypto";
@@ -3,7 +3,7 @@ import {
3
3
  isTerminalSafeText,
4
4
  terminalSafeLine,
5
5
  terminalSafeText
6
- } from "./chunk-LY6NJ7KL.js";
6
+ } from "./chunk-B6EPQ4YH.js";
7
7
 
8
8
  // src/decisions/feedback.ts
9
9
  var FEEDBACK_PROTOCOL_VERSION = 2;
@@ -7,17 +7,17 @@ import {
7
7
  } from "./chunk-MXVCP33E.js";
8
8
  import {
9
9
  scrubEnvironmentPaths
10
- } from "./chunk-URLLSALP.js";
10
+ } from "./chunk-BIAWZMCK.js";
11
11
  import {
12
12
  cachedCollectScopeAdmits
13
- } from "./chunk-Z6NPNLOT.js";
13
+ } from "./chunk-7IPGD6CD.js";
14
14
  import {
15
15
  canonicalRepositoryPath,
16
16
  currentBranch,
17
17
  isRepoActiveForCapture,
18
18
  relatedWorktreeTarget,
19
19
  repoSyncId
20
- } from "./chunk-DHOQGHKQ.js";
20
+ } from "./chunk-6QK75B7G.js";
21
21
 
22
22
  // src/hooks/file-refs.ts
23
23
  var MAX_PREFLIGHT_FILE_TARGETS = 25;
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  getSiteUrl
3
- } from "./chunk-LY6NJ7KL.js";
3
+ } from "./chunk-B6EPQ4YH.js";
4
4
  import {
5
5
  atomicWriteFile,
6
6
  ensureDurableDirectory,
7
7
  jwtOrganizationId,
8
8
  primConfigDirectory,
9
9
  resolveAuthCredential
10
- } from "./chunk-DWRSEC34.js";
10
+ } from "./chunk-6QK75B7G.js";
11
11
 
12
12
  // src/journal.ts
13
13
  import {
@@ -1,13 +1,11 @@
1
- import {
2
- gitToplevel
3
- } from "./chunk-DHOQGHKQ.js";
4
1
  import {
5
2
  atomicWriteFile,
3
+ gitToplevel,
6
4
  primConfigDirectory,
7
5
  syncDirectory,
8
6
  syncFile,
9
7
  withFileLockSync
10
- } from "./chunk-DWRSEC34.js";
8
+ } from "./chunk-6QK75B7G.js";
11
9
 
12
10
  // src/lib/bin-path.ts
13
11
  import { existsSync, readFileSync } from "fs";
@@ -2,10 +2,16 @@ import {
2
2
  getClient,
3
3
  getSiteUrl,
4
4
  terminalSafeLine
5
- } from "./chunk-LY6NJ7KL.js";
5
+ } from "./chunk-B6EPQ4YH.js";
6
6
  import {
7
7
  daemonRequest
8
- } from "./chunk-35FMRWJH.js";
8
+ } from "./chunk-2DPLT2CQ.js";
9
+ import {
10
+ canonicalGitRoot,
11
+ canonicalRepositoryPath,
12
+ currentBranch,
13
+ repoSyncId
14
+ } from "./chunk-6QK75B7G.js";
9
15
 
10
16
  // src/daemon/proxy.ts
11
17
  var DAEMON_HTTP_TIMEOUT_MS = 1e4;
@@ -42,18 +48,28 @@ function chunk(items, size) {
42
48
  }
43
49
  return out;
44
50
  }
45
- async function fetchAffecting(client, batch) {
51
+ async function fetchAffecting(client, batch, repository) {
46
52
  const params = new URLSearchParams();
53
+ params.set("repoSyncId", repository.repoSyncId);
54
+ if (repository.branch) params.set("branch", repository.branch);
47
55
  for (const file of batch) {
48
56
  params.append("files", file);
49
57
  }
50
58
  try {
51
- return await daemonOrDirectGet(
59
+ const response = await daemonOrDirectGet(
52
60
  "decisions_affecting",
53
61
  `/api/cli/decisions/affecting?${params.toString()}`,
54
62
  client,
55
63
  DECISIONS_CHECK_TIMEOUT_MS
56
64
  );
65
+ if (response.repoSyncId !== repository.repoSyncId) {
66
+ return {
67
+ decisions: [],
68
+ truncated: response.truncated === true,
69
+ unavailable: response.unavailable ?? "service did not verify repository-scoped discovery"
70
+ };
71
+ }
72
+ return response;
57
73
  } catch (err) {
58
74
  const detail = err instanceof Error ? err.message : String(err);
59
75
  return { decisions: [], truncated: false, unavailable: `decision check failed: ${detail}` };
@@ -63,9 +79,31 @@ async function checkAffectedDecisions(filePaths, deps = defaultDeps) {
63
79
  if (filePaths.length === 0) {
64
80
  return { decisions: [], truncated: false };
65
81
  }
82
+ const cwd = process.cwd();
83
+ const root = canonicalGitRoot(cwd);
84
+ const binding = repoSyncId(cwd);
85
+ if (!root || !binding) {
86
+ return {
87
+ decisions: [],
88
+ truncated: false,
89
+ unavailable: "this checkout has no current Primitive repository binding; run prim enable"
90
+ };
91
+ }
92
+ const canonical = filePaths.map(
93
+ (file) => canonicalRepositoryPath(file, { repoRoot: root }, root)
94
+ );
95
+ if (canonical.some((path) => !path.ok)) {
96
+ return {
97
+ decisions: [],
98
+ truncated: false,
99
+ unavailable: "files must resolve inside this repository; use repository-relative paths"
100
+ };
101
+ }
102
+ const paths = [...new Set(canonical.flatMap((path) => path.ok ? [path.file] : []))];
103
+ const repository = { repoSyncId: binding, branch: currentBranch(cwd) };
66
104
  const client = deps.getClient();
67
105
  const responses = await Promise.all(
68
- chunk(filePaths, MAX_FILES_PER_REQUEST).map((batch) => fetchAffecting(client, batch))
106
+ chunk(paths, MAX_FILES_PER_REQUEST).map((batch) => fetchAffecting(client, batch, repository))
69
107
  );
70
108
  const byId = /* @__PURE__ */ new Map();
71
109
  let truncated = false;
@@ -113,7 +151,7 @@ function formatDecisionsWarning(result) {
113
151
  }
114
152
  if (result.truncated) {
115
153
  lines.push(
116
- "[prim] result truncated \u2014 more files than the server checks per request; not all decisions shown"
154
+ "[prim] result truncated \u2014 a discovery scan or result limit was reached; not all decisions shown"
117
155
  );
118
156
  }
119
157
  return lines.join("\n");