@primitive.ai/prim 0.1.0-alpha.97 → 0.1.0-alpha.99
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 +20 -0
- package/dist/{chunk-ZYK3TBEW.js → chunk-25DDRMWS.js} +4 -6
- package/dist/{chunk-LY6NJ7KL.js → chunk-2IRLFOEL.js} +123 -19
- package/dist/{chunk-27ADT6FQ.js → chunk-2Q3OGSTV.js} +44 -6
- package/dist/{chunk-35FMRWJH.js → chunk-5LRKJTLA.js} +1 -1
- package/dist/{chunk-RK4ZS3HG.js → chunk-6C3CCVDI.js} +2 -2
- package/dist/{chunk-UO2U6IKF.js → chunk-7VIMU2HR.js} +1 -1
- package/dist/{chunk-OW4GJBLW.js → chunk-EJPKZT5M.js} +2 -2
- package/dist/{chunk-2MBV7ZMV.js → chunk-FK7FJPWS.js} +1 -1
- package/dist/{chunk-4GHANPWQ.js → chunk-JJI7FU24.js} +2 -2
- package/dist/{chunk-AJYZB5PF.js → chunk-JJYS7IPD.js} +3 -3
- package/dist/{chunk-Y5W4TZM7.js → chunk-K4JWJ6OM.js} +80 -269
- package/dist/{chunk-XEDJ5N3M.js → chunk-KGBMU76T.js} +2 -4
- package/dist/{chunk-7KABYYWG.js → chunk-O2WV5SQZ.js} +11 -13
- package/dist/{chunk-FBPZ4YUD.js → chunk-X5BN67D2.js} +2 -2
- package/dist/{chunk-DWRSEC34.js → chunk-XG7S3LIL.js} +596 -16
- package/dist/{chunk-3I4GEWXQ.js → chunk-XPS6LG6I.js} +8 -12
- package/dist/{chunk-QNPTWTBG.js → chunk-ZNLIGT3J.js} +2 -2
- package/dist/daemon/server.js +247 -180
- package/dist/hook-runtime/daemon/server.js +247 -180
- package/dist/hook-runtime/hooks/post-commit.js +114 -59
- package/dist/hook-runtime/hooks/post-rewrite.js +109 -54
- package/dist/hook-runtime/hooks/post-tool-use.js +256 -156
- package/dist/hook-runtime/hooks/pre-commit.js +374 -31
- package/dist/hook-runtime/hooks/pre-tool-use.js +237 -137
- package/dist/hook-runtime/hooks/prim-hook.js +281 -181
- package/dist/hook-runtime/hooks/session-start.js +209 -109
- package/dist/hook-runtime/index.js +656 -521
- package/dist/hook-runtime/statusline-main.js +71 -16
- package/dist/hooks/post-commit.js +7 -8
- package/dist/hooks/post-rewrite.js +6 -7
- package/dist/hooks/post-tool-use.js +13 -14
- package/dist/hooks/pre-commit.js +4 -4
- package/dist/hooks/pre-tool-use.js +11 -14
- package/dist/hooks/prim-hook.js +14 -15
- package/dist/hooks/session-end.js +6 -7
- package/dist/hooks/session-start.js +13 -14
- package/dist/index.js +33 -35
- package/dist/statusline-main.js +71 -16
- package/package.json +1 -1
- package/dist/chunk-DHOQGHKQ.js +0 -379
package/README.md
CHANGED
|
@@ -297,6 +297,15 @@ prim decisions unlink <child> --on <parent> # Remove that dependency
|
|
|
297
297
|
`<id>` accepts a full decision ID or its short ID. STDOUT is machine-readable
|
|
298
298
|
JSON; human-readable status goes to STDERR.
|
|
299
299
|
|
|
300
|
+
`decisions check` uses the checkout's current Primitive repository binding and
|
|
301
|
+
Git branch. Paths are relative to the repository root, including from a
|
|
302
|
+
subdirectory; paths for files that do not exist yet are supported. Discovery
|
|
303
|
+
includes exact file, directory, glob, and repository scopes and applies each
|
|
304
|
+
Decision's effective window and audience. It does not run the Conflict Gate.
|
|
305
|
+
Missing bindings, older servers that cannot confirm repository-scoped discovery,
|
|
306
|
+
and bounded partial results report `unavailable` or `truncated`; they are not a
|
|
307
|
+
verified empty result. Reconnect a missing or stale binding with `prim enable`.
|
|
308
|
+
|
|
300
309
|
When passive capture is inactive in the current repo, an approved one-time create is:
|
|
301
310
|
|
|
302
311
|
```bash
|
|
@@ -415,6 +424,17 @@ long) hands them to a detached background `prim moves flush` and never waits for
|
|
|
415
424
|
it. It starts none while a live daemon on the same version and deployment, with
|
|
416
425
|
a healthy heartbeat and no recorded ingestion failure, already owns the drain.
|
|
417
426
|
|
|
427
|
+
Move uploads include `X-Prim-Uploader-Version` (the uploader process's version)
|
|
428
|
+
and `X-Prim-Client-Instance-Id` (the opaque installation ID also used by presence
|
|
429
|
+
heartbeats). These let server traces distinguish the uploader from the version
|
|
430
|
+
that originally captured a replayed move. The ID is stored in
|
|
431
|
+
`client_instance_id` under the Prim config directory (`~/.config/prim` by default,
|
|
432
|
+
or `PRIM_CONFIG_DIR` / `XDG_CONFIG_HOME/prim`). Compare that file with the trace's
|
|
433
|
+
`uploaderClientInstanceId` to correlate an installation; it contains no hostname.
|
|
434
|
+
If the identity cannot be read or created immediately, uploads omit that header
|
|
435
|
+
and continue. Invalid stored identities are never silently replaced. Older
|
|
436
|
+
clients remain unattributed until updated and their uploader process restarted.
|
|
437
|
+
|
|
418
438
|
### Skill
|
|
419
439
|
|
|
420
440
|
```bash
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getClient,
|
|
3
3
|
terminalSafeLine
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-2IRLFOEL.js";
|
|
5
5
|
import {
|
|
6
|
+
__commonJS,
|
|
7
|
+
__toESM,
|
|
6
8
|
localGitConfigValue,
|
|
7
9
|
setLocalGitConfigValue
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import {
|
|
10
|
-
__commonJS,
|
|
11
|
-
__toESM
|
|
12
|
-
} from "./chunk-DWRSEC34.js";
|
|
10
|
+
} from "./chunk-XG7S3LIL.js";
|
|
13
11
|
|
|
14
12
|
// node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js
|
|
15
13
|
var require_ucs2length = __commonJS({
|
|
@@ -11,21 +11,124 @@ import {
|
|
|
11
11
|
TOKEN_FILE_PATH,
|
|
12
12
|
WORKOS_CONNECT_RESPONSE_MAX_BYTES,
|
|
13
13
|
atomicWriteFile,
|
|
14
|
+
ensureDurableDirectory,
|
|
14
15
|
jwtExpiresAt,
|
|
16
|
+
packageVersion,
|
|
15
17
|
parseWorkosConnectTokens,
|
|
18
|
+
primConfigDirectory,
|
|
16
19
|
readBoundedJson,
|
|
17
20
|
readCredentialMigrationState,
|
|
18
21
|
readStoredCredentialMetadata,
|
|
19
22
|
resolveAuthCredential,
|
|
23
|
+
syncDirectory,
|
|
20
24
|
withFileLock,
|
|
21
25
|
workosConnectTokenEndpoint
|
|
22
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-XG7S3LIL.js";
|
|
23
27
|
|
|
24
28
|
// src/client.ts
|
|
25
29
|
import { createHash } from "crypto";
|
|
26
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync } from "fs";
|
|
30
|
+
import { chmodSync as chmodSync2, existsSync, mkdirSync, readFileSync as readFileSync2, rmSync } from "fs";
|
|
27
31
|
import { dirname } from "path";
|
|
28
32
|
|
|
33
|
+
// src/daemon/client-instance-id.ts
|
|
34
|
+
import { randomBytes } from "crypto";
|
|
35
|
+
import { chmodSync, lstatSync, readFileSync } from "fs";
|
|
36
|
+
import { join } from "path";
|
|
37
|
+
var CONFIG_DIRECTORY_MODE = 448;
|
|
38
|
+
var INSTANCE_FILE_MODE = 384;
|
|
39
|
+
var INSTANCE_ENTROPY_BYTES = 32;
|
|
40
|
+
var INSTANCE_BODY_CHARS = 43;
|
|
41
|
+
var INSTANCE_PREFIX = "pci_";
|
|
42
|
+
var CLIENT_INSTANCE_ID_RE = /^pci_[A-Za-z0-9_-]{43}$/u;
|
|
43
|
+
var MAX_STORED_BYTES = INSTANCE_PREFIX.length + INSTANCE_BODY_CHARS + 1;
|
|
44
|
+
function isClientInstanceId(value) {
|
|
45
|
+
return typeof value === "string" && CLIENT_INSTANCE_ID_RE.test(value);
|
|
46
|
+
}
|
|
47
|
+
function ensurePrivateConfigDirectory(configDir) {
|
|
48
|
+
ensureDurableDirectory(configDir, CONFIG_DIRECTORY_MODE);
|
|
49
|
+
const metadata = lstatSync(configDir);
|
|
50
|
+
if (!metadata.isDirectory() || metadata.isSymbolicLink()) {
|
|
51
|
+
throw new Error("prim config path must be a private directory");
|
|
52
|
+
}
|
|
53
|
+
chmodSync(configDir, CONFIG_DIRECTORY_MODE);
|
|
54
|
+
syncDirectory(configDir);
|
|
55
|
+
}
|
|
56
|
+
function readExisting(path) {
|
|
57
|
+
let metadata;
|
|
58
|
+
try {
|
|
59
|
+
metadata = lstatSync(path);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (error.code === "ENOENT") {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
if (!metadata.isFile() || metadata.isSymbolicLink()) {
|
|
67
|
+
throw new Error("stored client instance identity is invalid");
|
|
68
|
+
}
|
|
69
|
+
chmodSync(path, INSTANCE_FILE_MODE);
|
|
70
|
+
if (metadata.size > MAX_STORED_BYTES) {
|
|
71
|
+
throw new Error("stored client instance identity is invalid");
|
|
72
|
+
}
|
|
73
|
+
const raw = readFileSync(path, "utf8");
|
|
74
|
+
const value = raw.endsWith("\n") ? raw.slice(0, -1) : raw;
|
|
75
|
+
if (raw !== value && raw !== `${value}
|
|
76
|
+
` || !isClientInstanceId(value)) {
|
|
77
|
+
throw new Error("stored client instance identity is invalid");
|
|
78
|
+
}
|
|
79
|
+
return value;
|
|
80
|
+
}
|
|
81
|
+
function atomicWrite(path, value) {
|
|
82
|
+
atomicWriteFile(path, `${value}
|
|
83
|
+
`, { mode: INSTANCE_FILE_MODE });
|
|
84
|
+
}
|
|
85
|
+
async function getOrCreateClientInstanceId(options) {
|
|
86
|
+
const configDir = options.configDir;
|
|
87
|
+
const path = join(configDir, "client_instance_id");
|
|
88
|
+
const lockPath = join(configDir, "client-instance.lock");
|
|
89
|
+
ensurePrivateConfigDirectory(configDir);
|
|
90
|
+
return withFileLock(
|
|
91
|
+
lockPath,
|
|
92
|
+
() => {
|
|
93
|
+
const existing = readExisting(path);
|
|
94
|
+
if (existing !== void 0) {
|
|
95
|
+
return existing;
|
|
96
|
+
}
|
|
97
|
+
const generated = `${INSTANCE_PREFIX}${randomBytes(INSTANCE_ENTROPY_BYTES).toString(
|
|
98
|
+
"base64url"
|
|
99
|
+
)}`;
|
|
100
|
+
if (!isClientInstanceId(generated)) {
|
|
101
|
+
throw new Error("generated client instance identity is invalid");
|
|
102
|
+
}
|
|
103
|
+
atomicWrite(path, generated);
|
|
104
|
+
return generated;
|
|
105
|
+
},
|
|
106
|
+
options.lockOptions
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/lib/ingest-uploader.ts
|
|
111
|
+
var runtimeVersion = process.env.PRIM_RUNTIME_VERSION ?? packageVersion();
|
|
112
|
+
var VERSION_RE = /^\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?(?:\+[A-Za-z0-9.-]+)?$/u;
|
|
113
|
+
var instanceId;
|
|
114
|
+
async function ingestUploaderHeaders() {
|
|
115
|
+
const headers = {};
|
|
116
|
+
if (runtimeVersion && runtimeVersion.length <= 64 && VERSION_RE.test(runtimeVersion)) {
|
|
117
|
+
headers["X-Prim-Uploader-Version"] = runtimeVersion;
|
|
118
|
+
}
|
|
119
|
+
instanceId ??= getOrCreateClientInstanceId({
|
|
120
|
+
configDir: primConfigDirectory(),
|
|
121
|
+
// Attribution must not consume the upload deadline waiting for another process.
|
|
122
|
+
lockOptions: { timeoutMs: 0 }
|
|
123
|
+
}).catch(() => {
|
|
124
|
+
instanceId = void 0;
|
|
125
|
+
return void 0;
|
|
126
|
+
});
|
|
127
|
+
const id = await instanceId;
|
|
128
|
+
if (id) headers["X-Prim-Client-Instance-Id"] = id;
|
|
129
|
+
return headers;
|
|
130
|
+
}
|
|
131
|
+
|
|
29
132
|
// src/lib/terminal-safe.ts
|
|
30
133
|
function replaceIsolatedSurrogates(value) {
|
|
31
134
|
let out = "";
|
|
@@ -79,7 +182,7 @@ var DEFAULT_API_URL = "https://api.getprimitive.ai";
|
|
|
79
182
|
var AUTH_EXPIRED_MESSAGE = "Authentication expired. Run `prim auth login` to re-authenticate.";
|
|
80
183
|
function readTrimmed(path) {
|
|
81
184
|
try {
|
|
82
|
-
const value =
|
|
185
|
+
const value = readFileSync2(path, "utf8").trim();
|
|
83
186
|
return value || void 0;
|
|
84
187
|
} catch {
|
|
85
188
|
return void 0;
|
|
@@ -97,9 +200,9 @@ function expiresAtFor(token, expiresIn) {
|
|
|
97
200
|
function ensureConfigDirectory() {
|
|
98
201
|
const directory = dirname(TOKEN_FILE_PATH);
|
|
99
202
|
mkdirSync(directory, { recursive: true, mode: CONFIG_DIR_MODE });
|
|
100
|
-
|
|
203
|
+
chmodSync2(directory, CONFIG_DIR_MODE);
|
|
101
204
|
}
|
|
102
|
-
function
|
|
205
|
+
function atomicWrite2(path, content) {
|
|
103
206
|
ensureConfigDirectory();
|
|
104
207
|
atomicWriteFile(path, content, { mode: CREDENTIAL_FILE_MODE });
|
|
105
208
|
}
|
|
@@ -138,7 +241,7 @@ function credentialFamilyMetadata(accessToken, refreshToken2, metadata) {
|
|
|
138
241
|
return metadata === void 0 ? legacyBrokerCredentialMetadata(accessToken, refreshToken2) : { ...metadata, ...hashes };
|
|
139
242
|
}
|
|
140
243
|
function writeCredentialMigrationSentinel() {
|
|
141
|
-
|
|
244
|
+
atomicWrite2(
|
|
142
245
|
CREDENTIAL_MIGRATION_PATH,
|
|
143
246
|
`${JSON.stringify({
|
|
144
247
|
version: CREDENTIAL_MIGRATION_VERSION,
|
|
@@ -156,7 +259,7 @@ function bindLegacyBrokerGeneration(accessToken, refreshToken2, metadata) {
|
|
|
156
259
|
return { state: "invalid" };
|
|
157
260
|
}
|
|
158
261
|
if (metadata.metadata === void 0) {
|
|
159
|
-
|
|
262
|
+
atomicWrite2(CREDENTIAL_FAMILY_PATH, `${JSON.stringify(familyMetadata)}
|
|
160
263
|
`);
|
|
161
264
|
}
|
|
162
265
|
const migrationState = readCredentialMigrationState();
|
|
@@ -171,14 +274,14 @@ function preserveMarkerlessLegacyGeneration() {
|
|
|
171
274
|
const refreshToken2 = readTrimmed(REFRESH_TOKEN_PATH);
|
|
172
275
|
if (!(accessToken && refreshToken2)) return;
|
|
173
276
|
const familyMetadata = legacyBrokerCredentialMetadata(accessToken, refreshToken2);
|
|
174
|
-
|
|
277
|
+
atomicWrite2(CREDENTIAL_FAMILY_PATH, `${JSON.stringify(familyMetadata)}
|
|
175
278
|
`);
|
|
176
279
|
}
|
|
177
280
|
function terminalFingerprint() {
|
|
178
281
|
return readTrimmed(TERMINAL_REFRESH_PATH);
|
|
179
282
|
}
|
|
180
283
|
function writeTerminalFingerprint(refreshToken2) {
|
|
181
|
-
|
|
284
|
+
atomicWrite2(TERMINAL_REFRESH_PATH, `${refreshFingerprint(refreshToken2)}
|
|
182
285
|
`);
|
|
183
286
|
}
|
|
184
287
|
function clearTerminalFingerprint() {
|
|
@@ -203,24 +306,24 @@ function commitCredentialsUnlocked(credentials) {
|
|
|
203
306
|
if (credentials.metadata !== void 0) {
|
|
204
307
|
preserveMarkerlessLegacyGeneration();
|
|
205
308
|
writeCredentialMigrationSentinel();
|
|
206
|
-
|
|
309
|
+
atomicWrite2(CREDENTIAL_FAMILY_PATH, `${JSON.stringify(familyMetadata)}
|
|
207
310
|
`);
|
|
208
|
-
|
|
311
|
+
atomicWrite2(CREDENTIAL_METADATA_PATH, `${JSON.stringify(familyMetadata)}
|
|
209
312
|
`);
|
|
210
|
-
|
|
313
|
+
atomicWrite2(REFRESH_TOKEN_PATH, `${refreshToken2}
|
|
211
314
|
`);
|
|
212
315
|
} else {
|
|
213
|
-
|
|
316
|
+
atomicWrite2(REFRESH_TOKEN_PATH, `${refreshToken2}
|
|
214
317
|
`);
|
|
215
|
-
|
|
318
|
+
atomicWrite2(CREDENTIAL_FAMILY_PATH, `${JSON.stringify(familyMetadata)}
|
|
216
319
|
`);
|
|
217
320
|
removeCredentialFile(CREDENTIAL_METADATA_PATH);
|
|
218
321
|
}
|
|
219
322
|
const expiresAt = expiresAtFor(accessToken, credentials.expiresIn);
|
|
220
323
|
if (expiresAt === void 0) removeCredentialFile(TOKEN_EXPIRES_PATH);
|
|
221
|
-
else
|
|
324
|
+
else atomicWrite2(TOKEN_EXPIRES_PATH, `${expiresAt}
|
|
222
325
|
`);
|
|
223
|
-
|
|
326
|
+
atomicWrite2(TOKEN_FILE_PATH, `${accessToken}
|
|
224
327
|
`);
|
|
225
328
|
clearTerminalFingerprint();
|
|
226
329
|
_cachedCredential = { token: accessToken, source: "token_file" };
|
|
@@ -238,7 +341,7 @@ async function setStoredToken(token, options = {}) {
|
|
|
238
341
|
removeCredentialFile(CREDENTIAL_METADATA_PATH);
|
|
239
342
|
clearTerminalFingerprint();
|
|
240
343
|
removeCredentialFile(CREDENTIAL_MIGRATION_PATH);
|
|
241
|
-
|
|
344
|
+
atomicWrite2(TOKEN_FILE_PATH, `${value}
|
|
242
345
|
`);
|
|
243
346
|
_cachedCredential = { token: value, source: "token_file" };
|
|
244
347
|
}, options);
|
|
@@ -531,12 +634,13 @@ function selectedCredential() {
|
|
|
531
634
|
}
|
|
532
635
|
return _cachedCredential;
|
|
533
636
|
}
|
|
534
|
-
function fetchWithToken(method, path, body, options, token, siteUrl) {
|
|
637
|
+
async function fetchWithToken(method, path, body, options, token, siteUrl) {
|
|
535
638
|
return fetch(`${siteUrl}${path}`, {
|
|
536
639
|
method,
|
|
537
640
|
headers: {
|
|
538
641
|
Authorization: `Bearer ${token}`,
|
|
539
|
-
"Content-Type": "application/json"
|
|
642
|
+
"Content-Type": "application/json",
|
|
643
|
+
...method === "POST" && path === "/api/cli/moves/ingest" ? await ingestUploaderHeaders() : {}
|
|
540
644
|
},
|
|
541
645
|
body: body === void 0 ? void 0 : JSON.stringify(body),
|
|
542
646
|
signal: options?.signal
|
|
@@ -2,10 +2,16 @@ import {
|
|
|
2
2
|
getClient,
|
|
3
3
|
getSiteUrl,
|
|
4
4
|
terminalSafeLine
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-2IRLFOEL.js";
|
|
6
6
|
import {
|
|
7
7
|
daemonRequest
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-5LRKJTLA.js";
|
|
9
|
+
import {
|
|
10
|
+
canonicalGitRoot,
|
|
11
|
+
canonicalRepositoryPath,
|
|
12
|
+
currentBranch,
|
|
13
|
+
repoSyncId
|
|
14
|
+
} from "./chunk-XG7S3LIL.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
|
-
|
|
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(
|
|
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
|
|
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");
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
cursorHooksPath,
|
|
3
3
|
hasExactCursorHandler,
|
|
4
4
|
readCursorHooks
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-K4JWJ6OM.js";
|
|
6
6
|
import {
|
|
7
7
|
resolveRepositoryContext
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-XG7S3LIL.js";
|
|
9
9
|
|
|
10
10
|
// src/hooks/agent.ts
|
|
11
11
|
function parseAgent(argv) {
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./chunk-EZXEWFDG.js";
|
|
4
4
|
import {
|
|
5
5
|
scrubEnvironmentPaths
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZNLIGT3J.js";
|
|
7
7
|
import {
|
|
8
8
|
isValidRepoSyncId
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XG7S3LIL.js";
|
|
10
10
|
|
|
11
11
|
// src/hooks/prim-hook-core.ts
|
|
12
12
|
import { createHash, randomUUID } from "crypto";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSiteUrl
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2IRLFOEL.js";
|
|
4
4
|
import {
|
|
5
5
|
atomicWriteFile,
|
|
6
6
|
ensureDurableDirectory,
|
|
7
7
|
jwtOrganizationId,
|
|
8
8
|
primConfigDirectory,
|
|
9
9
|
resolveAuthCredential
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-XG7S3LIL.js";
|
|
11
11
|
|
|
12
12
|
// src/journal.ts
|
|
13
13
|
import {
|
|
@@ -7,17 +7,17 @@ import {
|
|
|
7
7
|
} from "./chunk-MXVCP33E.js";
|
|
8
8
|
import {
|
|
9
9
|
scrubEnvironmentPaths
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ZNLIGT3J.js";
|
|
11
11
|
import {
|
|
12
12
|
cachedCollectScopeAdmits
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-25DDRMWS.js";
|
|
14
14
|
import {
|
|
15
15
|
canonicalRepositoryPath,
|
|
16
16
|
currentBranch,
|
|
17
17
|
isRepoActiveForCapture,
|
|
18
18
|
relatedWorktreeTarget,
|
|
19
19
|
repoSyncId
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-XG7S3LIL.js";
|
|
21
21
|
|
|
22
22
|
// src/hooks/file-refs.ts
|
|
23
23
|
var MAX_PREFLIGHT_FILE_TARGETS = 25;
|