@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/dist/index.js
CHANGED
|
@@ -19,25 +19,25 @@ import {
|
|
|
19
19
|
resolveRepositoryBinding,
|
|
20
20
|
uninstallGitHookAtPath,
|
|
21
21
|
uninstallProjectGitHook
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-O2WV5SQZ.js";
|
|
23
23
|
import {
|
|
24
24
|
requireDurableIngestAcknowledgement
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-FK7FJPWS.js";
|
|
26
26
|
import {
|
|
27
27
|
checkAffectedDecisions,
|
|
28
28
|
daemonOrDirectGet,
|
|
29
29
|
formatDecisionsWarning
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-2Q3OGSTV.js";
|
|
31
31
|
import {
|
|
32
32
|
fetchFeedbackCapability
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-7VIMU2HR.js";
|
|
34
34
|
import {
|
|
35
35
|
POST_COMMIT_GRACE_MS,
|
|
36
36
|
clearHooksWired,
|
|
37
37
|
inspectPostCommitFiring,
|
|
38
38
|
lastConversationCaptured,
|
|
39
39
|
recordHooksWired
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-KGBMU76T.js";
|
|
41
41
|
import {
|
|
42
42
|
isUnattended,
|
|
43
43
|
unattendedEnv
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
rotationIdentity,
|
|
57
57
|
sweepOrphanedDrainProgress,
|
|
58
58
|
writeDrainCheckpoint
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-JJI7FU24.js";
|
|
60
60
|
import {
|
|
61
61
|
MS_PER_SECOND,
|
|
62
62
|
deliveryBacklogState,
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
formatStatusline,
|
|
66
66
|
formatTeammates,
|
|
67
67
|
repositoryBindingDiagnosticLabel
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-X5BN67D2.js";
|
|
69
69
|
import {
|
|
70
70
|
bold,
|
|
71
71
|
boundedHealthError,
|
|
@@ -84,7 +84,7 @@ import {
|
|
|
84
84
|
isGitHubInstallIntentStatusResponse,
|
|
85
85
|
isMoveIngestRequest,
|
|
86
86
|
stripAnsi
|
|
87
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-25DDRMWS.js";
|
|
88
88
|
import {
|
|
89
89
|
CliManagementResponseError,
|
|
90
90
|
HttpError,
|
|
@@ -101,17 +101,13 @@ import {
|
|
|
101
101
|
setStoredToken,
|
|
102
102
|
stripControlChars,
|
|
103
103
|
terminalSafeLine
|
|
104
|
-
} from "./chunk-
|
|
104
|
+
} from "./chunk-2IRLFOEL.js";
|
|
105
105
|
import {
|
|
106
106
|
MANAGED_GIT_HOOK_NAMES,
|
|
107
107
|
assertOwnedHookRuntime,
|
|
108
108
|
atomicWrite,
|
|
109
|
-
binFile,
|
|
110
|
-
commandMatchesBin,
|
|
111
|
-
compareSemver,
|
|
112
109
|
ensureRegistration,
|
|
113
110
|
entryHasCommand,
|
|
114
|
-
hookCommandResolutions,
|
|
115
111
|
hookRuntimePaths,
|
|
116
112
|
inspectGitHookEntrypoint,
|
|
117
113
|
inspectHookRuntime,
|
|
@@ -119,53 +115,55 @@ import {
|
|
|
119
115
|
inspectHookRuntimeResolutions2,
|
|
120
116
|
makeRegistration,
|
|
121
117
|
managedHookBlock,
|
|
122
|
-
packageRoot,
|
|
123
|
-
packageVersion,
|
|
124
118
|
performStatus,
|
|
125
119
|
performStatus2,
|
|
126
|
-
pinnedNpxArgs,
|
|
127
120
|
projectRoot,
|
|
128
121
|
readSettings,
|
|
129
122
|
registerClaudeCommands,
|
|
130
123
|
registerCursorCommands,
|
|
131
124
|
removeHookRuntime,
|
|
132
|
-
stableHookCommand,
|
|
133
125
|
stableNodePath,
|
|
134
126
|
stageHookRuntime,
|
|
135
127
|
stripCommand
|
|
136
|
-
} from "./chunk-
|
|
137
|
-
import {
|
|
138
|
-
canonicalGitRoot,
|
|
139
|
-
canonicalRepositoryPath,
|
|
140
|
-
decisionIngestionStatus,
|
|
141
|
-
gitToplevel,
|
|
142
|
-
isRepoActiveForCapture,
|
|
143
|
-
isValidRepoSyncId,
|
|
144
|
-
mainWorktreeRoot,
|
|
145
|
-
repoActiveFlag,
|
|
146
|
-
repoSyncId,
|
|
147
|
-
repositoryBindingState,
|
|
148
|
-
setRepoActive
|
|
149
|
-
} from "./chunk-DHOQGHKQ.js";
|
|
128
|
+
} from "./chunk-K4JWJ6OM.js";
|
|
150
129
|
import {
|
|
151
130
|
daemonIsLive,
|
|
152
131
|
daemonRequest
|
|
153
|
-
} from "./chunk-
|
|
132
|
+
} from "./chunk-5LRKJTLA.js";
|
|
154
133
|
import {
|
|
155
134
|
REFRESH_TOKEN_PATH,
|
|
156
135
|
TOKEN_FILE_PATH,
|
|
157
136
|
WorkosConnectProtocolError,
|
|
158
137
|
atomicWriteFile,
|
|
138
|
+
binFile,
|
|
139
|
+
canonicalGitRoot,
|
|
140
|
+
canonicalRepositoryPath,
|
|
141
|
+
commandMatchesBin,
|
|
142
|
+
compareSemver,
|
|
143
|
+
decisionIngestionStatus,
|
|
159
144
|
discoverWorkosConnect,
|
|
145
|
+
gitToplevel,
|
|
146
|
+
hookCommandResolutions,
|
|
147
|
+
isRepoActiveForCapture,
|
|
148
|
+
isValidRepoSyncId,
|
|
149
|
+
mainWorktreeRoot,
|
|
150
|
+
packageRoot,
|
|
151
|
+
packageVersion,
|
|
152
|
+
pinnedNpxArgs,
|
|
160
153
|
pollWorkosDeviceAuthorization,
|
|
161
154
|
primConfigDirectory,
|
|
162
155
|
processIsAlive,
|
|
156
|
+
repoActiveFlag,
|
|
157
|
+
repoSyncId,
|
|
158
|
+
repositoryBindingState,
|
|
163
159
|
requestWorkosDeviceAuthorization,
|
|
164
160
|
resolveAuthCredential,
|
|
161
|
+
setRepoActive,
|
|
162
|
+
stableHookCommand,
|
|
165
163
|
syncDirectory,
|
|
166
164
|
withFileLock,
|
|
167
165
|
withFileLockSync
|
|
168
|
-
} from "./chunk-
|
|
166
|
+
} from "./chunk-XG7S3LIL.js";
|
|
169
167
|
|
|
170
168
|
// src/index.ts
|
|
171
169
|
import { readFileSync as readFileSync10 } from "fs";
|
|
@@ -6188,9 +6186,9 @@ function locationScopeFromOptions(options) {
|
|
|
6188
6186
|
}
|
|
6189
6187
|
function registerDecisionsCommands(program2) {
|
|
6190
6188
|
const decisions = program2.command("decisions").description("Inspect the project Decision Graph");
|
|
6191
|
-
decisions.command("check").description("Look up active decisions
|
|
6189
|
+
decisions.command("check").description("Look up active decisions scoped to file paths in the connected repository").requiredOption(
|
|
6192
6190
|
"--files <files>",
|
|
6193
|
-
"Comma-separated
|
|
6191
|
+
"Comma-separated repository-relative paths to check against the Decision Graph (repeatable)",
|
|
6194
6192
|
collectPaths
|
|
6195
6193
|
).action(async (opts) => {
|
|
6196
6194
|
const result = await checkAffectedDecisions(opts.files);
|
package/dist/statusline-main.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/commands/statusline.ts
|
|
4
|
-
import { readFileSync as
|
|
5
|
-
import { dirname as
|
|
6
|
-
import { fileURLToPath } from "url";
|
|
4
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
5
|
+
import { dirname as dirname6, resolve as resolve3 } from "path";
|
|
6
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
7
7
|
|
|
8
8
|
// src/client.ts
|
|
9
9
|
import { createHash as createHash2 } from "crypto";
|
|
10
|
-
import { chmodSync, existsSync as
|
|
11
|
-
import { dirname as
|
|
10
|
+
import { chmodSync as chmodSync2, existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync5, rmSync as rmSync3 } from "fs";
|
|
11
|
+
import { dirname as dirname4 } from "path";
|
|
12
12
|
|
|
13
13
|
// src/lib/atomic-file.ts
|
|
14
14
|
import { randomUUID } from "crypto";
|
|
@@ -278,6 +278,61 @@ import { existsSync, mkdirSync as mkdirSync2, readFileSync as readFileSync2, rmS
|
|
|
278
278
|
import { dirname as dirname2, join as join3 } from "path";
|
|
279
279
|
var syncSleeper = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
|
280
280
|
|
|
281
|
+
// src/daemon/client-instance-id.ts
|
|
282
|
+
import { randomBytes as randomBytes2 } from "crypto";
|
|
283
|
+
import { chmodSync, lstatSync, readFileSync as readFileSync3 } from "fs";
|
|
284
|
+
import { join as join4 } from "path";
|
|
285
|
+
var INSTANCE_BODY_CHARS = 43;
|
|
286
|
+
var INSTANCE_PREFIX = "pci_";
|
|
287
|
+
var MAX_STORED_BYTES = INSTANCE_PREFIX.length + INSTANCE_BODY_CHARS + 1;
|
|
288
|
+
|
|
289
|
+
// src/lib/bin-path.ts
|
|
290
|
+
import { existsSync as existsSync2, readFileSync as readFileSync4 } from "fs";
|
|
291
|
+
import { dirname as dirname3, isAbsolute as isAbsolute2, join as join5 } from "path";
|
|
292
|
+
import { fileURLToPath } from "url";
|
|
293
|
+
var PKG_NAME = "@primitive.ai/prim";
|
|
294
|
+
var ROOT_WALK_LIMIT = 6;
|
|
295
|
+
var resolvedRoot;
|
|
296
|
+
function locateRoot() {
|
|
297
|
+
if (resolvedRoot !== void 0) {
|
|
298
|
+
return resolvedRoot;
|
|
299
|
+
}
|
|
300
|
+
let dir = dirname3(fileURLToPath(import.meta.url));
|
|
301
|
+
for (let depth = 0; depth < ROOT_WALK_LIMIT; depth++) {
|
|
302
|
+
const manifestPath = join5(dir, "package.json");
|
|
303
|
+
if (existsSync2(manifestPath)) {
|
|
304
|
+
try {
|
|
305
|
+
const manifest = JSON.parse(readFileSync4(manifestPath, "utf-8"));
|
|
306
|
+
if (manifest.name === PKG_NAME && manifest.bin) {
|
|
307
|
+
resolvedRoot = { dir, version: manifest.version, bin: manifest.bin };
|
|
308
|
+
return resolvedRoot;
|
|
309
|
+
}
|
|
310
|
+
} catch {
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const parent = dirname3(dir);
|
|
314
|
+
if (parent === dir) {
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
dir = parent;
|
|
318
|
+
}
|
|
319
|
+
resolvedRoot = null;
|
|
320
|
+
return resolvedRoot;
|
|
321
|
+
}
|
|
322
|
+
function packageVersion() {
|
|
323
|
+
return locateRoot()?.version ?? null;
|
|
324
|
+
}
|
|
325
|
+
var PRIM_CONFIG_SHELL_RESOLVER = [
|
|
326
|
+
'prim_absolute() { case "$1" in [/]* ) ;; *) return 1 ;; esac; case "$1" in [[:space:]]*|*[[:space:]]|*[/][/]*|*[/].[/]*|*[/]..[/]*|*[/].|*[/]..|?*[/]) return 1 ;; esac; }; ',
|
|
327
|
+
'prim_config=${PRIM_CONFIG_DIR:-}; if ! prim_absolute "$prim_config"; then prim_config=${XDG_CONFIG_HOME:-}; if prim_absolute "$prim_config"; then ',
|
|
328
|
+
'case "$prim_config" in /) prim_config=/prim ;; *) prim_config="$prim_config/prim" ;; esac; ',
|
|
329
|
+
'else prim_home=${HOME:-}; prim_absolute "$prim_home" || exit 78; case "$prim_home" in /) prim_config=/.config/prim ;; *) prim_config="$prim_home/.config/prim" ;; esac; ',
|
|
330
|
+
"fi; fi; "
|
|
331
|
+
].join("");
|
|
332
|
+
|
|
333
|
+
// src/lib/ingest-uploader.ts
|
|
334
|
+
var runtimeVersion = process.env.PRIM_RUNTIME_VERSION ?? packageVersion();
|
|
335
|
+
|
|
281
336
|
// src/lib/terminal-safe.ts
|
|
282
337
|
function replaceIsolatedSurrogates(value) {
|
|
283
338
|
let out = "";
|
|
@@ -329,7 +384,7 @@ var CLI_MANAGEMENT_RESPONSE_MAX_BYTES = 2 * 1024 * 1024;
|
|
|
329
384
|
|
|
330
385
|
// src/daemon/client.ts
|
|
331
386
|
import { createConnection } from "net";
|
|
332
|
-
import { join as
|
|
387
|
+
import { join as join7 } from "path";
|
|
333
388
|
|
|
334
389
|
// src/daemon/principal.ts
|
|
335
390
|
import { createHash as createHash3 } from "crypto";
|
|
@@ -376,7 +431,7 @@ function parseDaemonResponseEnvelope(value) {
|
|
|
376
431
|
}
|
|
377
432
|
|
|
378
433
|
// src/daemon/client.ts
|
|
379
|
-
var SOCK_PATH =
|
|
434
|
+
var SOCK_PATH = join7(primConfigDirectory(), "sock");
|
|
380
435
|
var DEFAULT_TIMEOUT_MS = 250;
|
|
381
436
|
var nextRequestId = 1;
|
|
382
437
|
function daemonRequest(method, params = {}, opts = {}) {
|
|
@@ -465,15 +520,15 @@ function daemonRequest(method, params = {}, opts = {}) {
|
|
|
465
520
|
|
|
466
521
|
// src/lib/activation.ts
|
|
467
522
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
468
|
-
import { existsSync as
|
|
523
|
+
import { existsSync as existsSync4, readFileSync as readFileSync6 } from "fs";
|
|
469
524
|
import { homedir as homedir2 } from "os";
|
|
470
|
-
import { join as
|
|
525
|
+
import { join as join8 } from "path";
|
|
471
526
|
|
|
472
527
|
// src/lib/git.ts
|
|
473
528
|
import { execFileSync } from "child_process";
|
|
474
529
|
import { createHash as createHash4 } from "crypto";
|
|
475
|
-
import { lstatSync, realpathSync } from "fs";
|
|
476
|
-
import { basename, dirname as
|
|
530
|
+
import { lstatSync as lstatSync2, realpathSync } from "fs";
|
|
531
|
+
import { basename, dirname as dirname5, isAbsolute as isAbsolute3, relative, resolve as resolve2, sep } from "path";
|
|
477
532
|
var GIT_TIMEOUT_MS = 1e3;
|
|
478
533
|
var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
|
|
479
534
|
var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
|
|
@@ -576,10 +631,10 @@ function hasProjectPrimInstall(cwd) {
|
|
|
576
631
|
const root = gitToplevel(cwd);
|
|
577
632
|
if (root === null || root === homedir2()) return false;
|
|
578
633
|
for (const rel of PROJECT_INSTALL_FILES) {
|
|
579
|
-
const path =
|
|
580
|
-
if (
|
|
634
|
+
const path = join8(root, rel);
|
|
635
|
+
if (existsSync4(path)) {
|
|
581
636
|
try {
|
|
582
|
-
const content =
|
|
637
|
+
const content = readFileSync6(path, "utf-8");
|
|
583
638
|
if (PRIM_HOOK_BINS.some((bin) => content.includes(bin))) return true;
|
|
584
639
|
} catch {
|
|
585
640
|
}
|
|
@@ -726,7 +781,7 @@ function formatStatusline(version, snapshot, resolveIngestionStatus, options = {
|
|
|
726
781
|
var STATUSLINE_TIMEOUT_MS = 200;
|
|
727
782
|
function readPackageVersion() {
|
|
728
783
|
try {
|
|
729
|
-
const here =
|
|
784
|
+
const here = dirname6(fileURLToPath2(import.meta.url));
|
|
730
785
|
const candidates = [
|
|
731
786
|
// Schema-v2 runtimes staged a manifest beside this standalone bundle.
|
|
732
787
|
// Keep resolving it while those legacy launchers transition to schema v3.
|
|
@@ -736,7 +791,7 @@ function readPackageVersion() {
|
|
|
736
791
|
];
|
|
737
792
|
for (const path of candidates) {
|
|
738
793
|
try {
|
|
739
|
-
const pkg = JSON.parse(
|
|
794
|
+
const pkg = JSON.parse(readFileSync7(path, "utf-8"));
|
|
740
795
|
if (pkg.version) {
|
|
741
796
|
return pkg.version;
|
|
742
797
|
}
|
package/package.json
CHANGED