@primitive.ai/prim 0.1.0-alpha.98 → 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.
Files changed (40) hide show
  1. package/README.md +11 -0
  2. package/dist/{chunk-7IPGD6CD.js → chunk-25DDRMWS.js} +2 -2
  3. package/dist/{chunk-B6EPQ4YH.js → chunk-2IRLFOEL.js} +123 -19
  4. package/dist/{chunk-WKLYYT63.js → chunk-2Q3OGSTV.js} +3 -3
  5. package/dist/{chunk-2DPLT2CQ.js → chunk-5LRKJTLA.js} +1 -1
  6. package/dist/{chunk-AN6XTFIN.js → chunk-6C3CCVDI.js} +2 -2
  7. package/dist/{chunk-NIQAVFP6.js → chunk-7VIMU2HR.js} +1 -1
  8. package/dist/{chunk-2DA2B4EC.js → chunk-EJPKZT5M.js} +2 -2
  9. package/dist/{chunk-HUZXBJJ5.js → chunk-FK7FJPWS.js} +1 -1
  10. package/dist/{chunk-QPMLAD2C.js → chunk-JJI7FU24.js} +2 -2
  11. package/dist/{chunk-PPZBEOWK.js → chunk-JJYS7IPD.js} +3 -3
  12. package/dist/{chunk-RT7DXMTN.js → chunk-K4JWJ6OM.js} +79 -266
  13. package/dist/{chunk-3X77XQGW.js → chunk-KGBMU76T.js} +1 -1
  14. package/dist/{chunk-JOR67B5T.js → chunk-O2WV5SQZ.js} +8 -8
  15. package/dist/{chunk-IL443QTF.js → chunk-X5BN67D2.js} +2 -2
  16. package/dist/{chunk-6QK75B7G.js → chunk-XG7S3LIL.js} +214 -11
  17. package/dist/{chunk-MN4X6RR6.js → chunk-XPS6LG6I.js} +5 -7
  18. package/dist/{chunk-BIAWZMCK.js → chunk-ZNLIGT3J.js} +2 -2
  19. package/dist/daemon/server.js +247 -180
  20. package/dist/hook-runtime/daemon/server.js +247 -180
  21. package/dist/hook-runtime/hooks/post-commit.js +114 -59
  22. package/dist/hook-runtime/hooks/post-rewrite.js +109 -54
  23. package/dist/hook-runtime/hooks/post-tool-use.js +256 -156
  24. package/dist/hook-runtime/hooks/pre-commit.js +177 -33
  25. package/dist/hook-runtime/hooks/pre-tool-use.js +237 -137
  26. package/dist/hook-runtime/hooks/prim-hook.js +281 -181
  27. package/dist/hook-runtime/hooks/session-start.js +209 -109
  28. package/dist/hook-runtime/index.js +615 -515
  29. package/dist/hook-runtime/statusline-main.js +71 -16
  30. package/dist/hooks/post-commit.js +7 -7
  31. package/dist/hooks/post-rewrite.js +6 -6
  32. package/dist/hooks/post-tool-use.js +13 -13
  33. package/dist/hooks/pre-commit.js +4 -4
  34. package/dist/hooks/pre-tool-use.js +10 -11
  35. package/dist/hooks/prim-hook.js +14 -14
  36. package/dist/hooks/session-end.js +4 -4
  37. package/dist/hooks/session-start.js +11 -11
  38. package/dist/index.js +20 -20
  39. package/dist/statusline-main.js +71 -16
  40. package/package.json +1 -1
@@ -53,9 +53,9 @@ var require_ucs2length = __commonJS({
53
53
 
54
54
  // src/hooks/post-commit.ts
55
55
  import { execFileSync as execFileSync5, spawn } from "child_process";
56
- import { lstatSync as lstatSync3, readFileSync as readFileSync11 } from "fs";
57
- import { basename as basename3, dirname as dirname10, isAbsolute as isAbsolute4, join as join12 } from "path";
58
- import { fileURLToPath } from "url";
56
+ import { lstatSync as lstatSync4, readFileSync as readFileSync13 } from "fs";
57
+ import { basename as basename3, dirname as dirname11, isAbsolute as isAbsolute5, join as join14 } from "path";
58
+ import { fileURLToPath as fileURLToPath2 } from "url";
59
59
 
60
60
  // src/binding.ts
61
61
  import { existsSync, readFileSync as readFileSync2 } from "fs";
@@ -371,21 +371,21 @@ function resolveOrg(args) {
371
371
  import {
372
372
  appendFileSync,
373
373
  closeSync as closeSync2,
374
- existsSync as existsSync5,
374
+ existsSync as existsSync6,
375
375
  fstatSync,
376
376
  mkdirSync as mkdirSync4,
377
377
  openSync as openSync2,
378
378
  opendirSync,
379
- readFileSync as readFileSync6,
379
+ readFileSync as readFileSync8,
380
380
  readSync,
381
381
  readdirSync as readdirSync2
382
382
  } from "fs";
383
- import { dirname as dirname6, join as join7 } from "path";
383
+ import { dirname as dirname7, join as join9 } from "path";
384
384
 
385
385
  // src/client.ts
386
386
  import { createHash as createHash2 } from "crypto";
387
- import { chmodSync, existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync4, rmSync as rmSync3 } from "fs";
388
- import { dirname as dirname4 } from "path";
387
+ import { chmodSync as chmodSync2, existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync6, rmSync as rmSync3 } from "fs";
388
+ import { dirname as dirname5 } from "path";
389
389
 
390
390
  // src/lib/atomic-file.ts
391
391
  import { randomUUID } from "crypto";
@@ -471,6 +471,61 @@ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as rea
471
471
  import { dirname as dirname3, join as join4 } from "path";
472
472
  var syncSleeper = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
473
473
 
474
+ // src/daemon/client-instance-id.ts
475
+ import { randomBytes as randomBytes2 } from "crypto";
476
+ import { chmodSync, lstatSync, readFileSync as readFileSync4 } from "fs";
477
+ import { join as join5 } from "path";
478
+ var INSTANCE_BODY_CHARS = 43;
479
+ var INSTANCE_PREFIX = "pci_";
480
+ var MAX_STORED_BYTES = INSTANCE_PREFIX.length + INSTANCE_BODY_CHARS + 1;
481
+
482
+ // src/lib/bin-path.ts
483
+ import { existsSync as existsSync3, readFileSync as readFileSync5 } from "fs";
484
+ import { dirname as dirname4, isAbsolute as isAbsolute2, join as join6 } from "path";
485
+ import { fileURLToPath } from "url";
486
+ var PKG_NAME = "@primitive.ai/prim";
487
+ var ROOT_WALK_LIMIT = 6;
488
+ var resolvedRoot;
489
+ function locateRoot() {
490
+ if (resolvedRoot !== void 0) {
491
+ return resolvedRoot;
492
+ }
493
+ let dir = dirname4(fileURLToPath(import.meta.url));
494
+ for (let depth = 0; depth < ROOT_WALK_LIMIT; depth++) {
495
+ const manifestPath = join6(dir, "package.json");
496
+ if (existsSync3(manifestPath)) {
497
+ try {
498
+ const manifest = JSON.parse(readFileSync5(manifestPath, "utf-8"));
499
+ if (manifest.name === PKG_NAME && manifest.bin) {
500
+ resolvedRoot = { dir, version: manifest.version, bin: manifest.bin };
501
+ return resolvedRoot;
502
+ }
503
+ } catch {
504
+ }
505
+ }
506
+ const parent = dirname4(dir);
507
+ if (parent === dir) {
508
+ break;
509
+ }
510
+ dir = parent;
511
+ }
512
+ resolvedRoot = null;
513
+ return resolvedRoot;
514
+ }
515
+ function packageVersion() {
516
+ return locateRoot()?.version ?? null;
517
+ }
518
+ var PRIM_CONFIG_SHELL_RESOLVER = [
519
+ 'prim_absolute() { case "$1" in [/]* ) ;; *) return 1 ;; esac; case "$1" in [[:space:]]*|*[[:space:]]|*[/][/]*|*[/].[/]*|*[/]..[/]*|*[/].|*[/]..|?*[/]) return 1 ;; esac; }; ',
520
+ 'prim_config=${PRIM_CONFIG_DIR:-}; if ! prim_absolute "$prim_config"; then prim_config=${XDG_CONFIG_HOME:-}; if prim_absolute "$prim_config"; then ',
521
+ 'case "$prim_config" in /) prim_config=/prim ;; *) prim_config="$prim_config/prim" ;; esac; ',
522
+ '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; ',
523
+ "fi; fi; "
524
+ ].join("");
525
+
526
+ // src/lib/ingest-uploader.ts
527
+ var runtimeVersion = process.env.PRIM_RUNTIME_VERSION ?? packageVersion();
528
+
474
529
  // src/client.ts
475
530
  var DEFAULT_API_URL = "https://api.getprimitive.ai";
476
531
  function getSiteUrl() {
@@ -483,17 +538,17 @@ var CLI_MANAGEMENT_RESPONSE_MAX_BYTES = 2 * 1024 * 1024;
483
538
 
484
539
  // src/drain-progress.ts
485
540
  import {
486
- chmodSync as chmodSync2,
487
- existsSync as existsSync4,
488
- readFileSync as readFileSync5,
541
+ chmodSync as chmodSync3,
542
+ existsSync as existsSync5,
543
+ readFileSync as readFileSync7,
489
544
  readdirSync,
490
545
  rmSync as rmSync4,
491
546
  rmdirSync
492
547
  } from "fs";
493
- import { basename, dirname as dirname5, join as join6 } from "path";
548
+ import { basename, dirname as dirname6, join as join8 } from "path";
494
549
 
495
550
  // src/journal.ts
496
- var JOURNAL_DIR = join7(primConfigDirectory(), "moves");
551
+ var JOURNAL_DIR = join9(primConfigDirectory(), "moves");
497
552
  var UNBOUND_BUCKET = "_unbound";
498
553
  var JOURNAL_BASENAME = "journal.ndjson";
499
554
  var JOURNAL_STATS_SAMPLE_BYTES = 64 * 1024;
@@ -505,15 +560,15 @@ function envSlug(apiUrl) {
505
560
  return slug;
506
561
  }
507
562
  function currentEnvDir() {
508
- return join7(JOURNAL_DIR, envSlug(getSiteUrl()));
563
+ return join9(JOURNAL_DIR, envSlug(getSiteUrl()));
509
564
  }
510
565
  var DIR_MODE = 448;
511
566
  var FILE_MODE = 384;
512
567
  var SAFE_BUCKET = /^[A-Za-z0-9_-]+$/;
513
568
  var RESERVED_BUCKETS = /* @__PURE__ */ new Set([UNBOUND_BUCKET, "_legacy"]);
514
569
  function appendMoveToPath(path, move) {
515
- const dir = dirname6(path);
516
- if (!existsSync5(dir)) {
570
+ const dir = dirname7(path);
571
+ if (!existsSync6(dir)) {
517
572
  mkdirSync4(dir, { recursive: true, mode: DIR_MODE });
518
573
  }
519
574
  appendFileSync(path, `${JSON.stringify(move)}
@@ -521,10 +576,10 @@ function appendMoveToPath(path, move) {
521
576
  }
522
577
  function bucketDir(orgId) {
523
578
  const safe = orgId !== void 0 && SAFE_BUCKET.test(orgId) && !RESERVED_BUCKETS.has(orgId);
524
- return join7(currentEnvDir(), safe ? orgId : UNBOUND_BUCKET);
579
+ return join9(currentEnvDir(), safe ? orgId : UNBOUND_BUCKET);
525
580
  }
526
581
  function journalPath(orgId) {
527
- return join7(bucketDir(orgId), JOURNAL_BASENAME);
582
+ return join9(bucketDir(orgId), JOURNAL_BASENAME);
528
583
  }
529
584
  function appendMove(move, orgId) {
530
585
  appendMoveToPath(journalPath(orgId), move);
@@ -533,15 +588,15 @@ var FLUSHING_PREFIX = `${JOURNAL_BASENAME}.flushing.`;
533
588
 
534
589
  // src/lib/activation.ts
535
590
  import { execFileSync as execFileSync2 } from "child_process";
536
- import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
591
+ import { existsSync as existsSync7, readFileSync as readFileSync9 } from "fs";
537
592
  import { homedir as homedir2 } from "os";
538
- import { join as join8 } from "path";
593
+ import { join as join10 } from "path";
539
594
 
540
595
  // src/lib/git.ts
541
596
  import { execFileSync } from "child_process";
542
597
  import { createHash as createHash3 } from "crypto";
543
- import { lstatSync, realpathSync } from "fs";
544
- import { basename as basename2, dirname as dirname7, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "path";
598
+ import { lstatSync as lstatSync2, realpathSync } from "fs";
599
+ import { basename as basename2, dirname as dirname8, isAbsolute as isAbsolute3, relative, resolve as resolve2, sep } from "path";
545
600
  var GIT_TIMEOUT_MS = 1e3;
546
601
  var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
547
602
  var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
@@ -689,10 +744,10 @@ function hasProjectPrimInstall(cwd) {
689
744
  const root = gitToplevel(cwd);
690
745
  if (root === null || root === homedir2()) return false;
691
746
  for (const rel of PROJECT_INSTALL_FILES) {
692
- const path = join8(root, rel);
693
- if (existsSync6(path)) {
747
+ const path = join10(root, rel);
748
+ if (existsSync7(path)) {
694
749
  try {
695
- const content = readFileSync7(path, "utf-8");
750
+ const content = readFileSync9(path, "utf-8");
696
751
  if (PRIM_HOOK_BINS.some((bin) => content.includes(bin))) return true;
697
752
  } catch {
698
753
  }
@@ -19208,8 +19263,8 @@ function cachedCollectScopeAdmits(cwd, facts) {
19208
19263
 
19209
19264
  // src/lib/commit-heartbeat.ts
19210
19265
  import { execFileSync as execFileSync3 } from "child_process";
19211
- import { mkdirSync as mkdirSync5, readFileSync as readFileSync8, readdirSync as readdirSync3, unlinkSync } from "fs";
19212
- import { dirname as dirname8, join as join9, resolve as resolve3 } from "path";
19266
+ import { mkdirSync as mkdirSync5, readFileSync as readFileSync10, readdirSync as readdirSync3, unlinkSync } from "fs";
19267
+ import { dirname as dirname9, join as join11, resolve as resolve3 } from "path";
19213
19268
  var FIRED_DIR = "prim/post-commit-fired";
19214
19269
  var GIT_TIMEOUT_MS3 = 1e3;
19215
19270
  var MAX_STAMP_BYTES = 1024;
@@ -19227,8 +19282,8 @@ function gitPath(cwd, relative2) {
19227
19282
  return resolve3(cwd, value);
19228
19283
  }
19229
19284
  function ensurePrivateParent(path) {
19230
- mkdirSync5(dirname8(dirname8(path)), { recursive: true, mode: 448 });
19231
- mkdirSync5(dirname8(path), { recursive: true, mode: 448 });
19285
+ mkdirSync5(dirname9(dirname9(path)), { recursive: true, mode: 448 });
19286
+ mkdirSync5(dirname9(path), { recursive: true, mode: 448 });
19232
19287
  }
19233
19288
  function writeStamp(path, at) {
19234
19289
  ensurePrivateParent(path);
@@ -19237,7 +19292,7 @@ function writeStamp(path, at) {
19237
19292
  }
19238
19293
  function readStampAt(path) {
19239
19294
  try {
19240
- const raw = readFileSync8(path, "utf8");
19295
+ const raw = readFileSync10(path, "utf8");
19241
19296
  if (raw.length > MAX_STAMP_BYTES) return void 0;
19242
19297
  const parsed = JSON.parse(raw);
19243
19298
  return typeof parsed.at === "number" && Number.isSafeInteger(parsed.at) && parsed.at > 0 ? parsed.at : void 0;
@@ -19249,11 +19304,11 @@ function recordPostCommitFired(cwd, sha, now = Date.now()) {
19249
19304
  if (!sha || !FULL_SHA_RE.test(sha)) return;
19250
19305
  try {
19251
19306
  const dir = gitPath(cwd, FIRED_DIR);
19252
- writeStamp(join9(dir, sha), now);
19307
+ writeStamp(join11(dir, sha), now);
19253
19308
  const names = readdirSync3(dir).filter((name) => FULL_SHA_RE.test(name));
19254
19309
  if (names.length <= MAX_FIRED_STAMPS + PRUNE_SLACK) return;
19255
- const stale = names.map((name) => ({ name, at: readStampAt(join9(dir, name)) ?? 0 })).sort((left, right) => right.at - left.at || left.name.localeCompare(right.name)).slice(MAX_FIRED_STAMPS);
19256
- for (const { name } of stale) unlinkSync(join9(dir, name));
19310
+ const stale = names.map((name) => ({ name, at: readStampAt(join11(dir, name)) ?? 0 })).sort((left, right) => right.at - left.at || left.name.localeCompare(right.name)).slice(MAX_FIRED_STAMPS);
19311
+ for (const { name } of stale) unlinkSync(join11(dir, name));
19257
19312
  } catch {
19258
19313
  }
19259
19314
  }
@@ -19269,21 +19324,21 @@ import { execFileSync as execFileSync4 } from "child_process";
19269
19324
  import { randomUUID as randomUUID2 } from "crypto";
19270
19325
  import {
19271
19326
  constants as constants2,
19272
- chmodSync as chmodSync3,
19327
+ chmodSync as chmodSync4,
19273
19328
  closeSync as closeSync3,
19274
19329
  fchmodSync as fchmodSync2,
19275
19330
  fsyncSync as fsyncSync2,
19276
19331
  linkSync,
19277
- lstatSync as lstatSync2,
19332
+ lstatSync as lstatSync3,
19278
19333
  mkdirSync as mkdirSync6,
19279
19334
  openSync as openSync3,
19280
- readFileSync as readFileSync9,
19335
+ readFileSync as readFileSync11,
19281
19336
  statSync as statSync2,
19282
19337
  unlinkSync as unlinkSync2,
19283
19338
  writeFileSync as writeFileSync3
19284
19339
  } from "fs";
19285
- import { dirname as dirname9, isAbsolute as isAbsolute3, join as join10, resolve as resolve4 } from "path";
19286
- var WORKSPACE_ID_RELATIVE_PATH = join10("prim", "workspace-id");
19340
+ import { dirname as dirname10, isAbsolute as isAbsolute4, join as join12, resolve as resolve4 } from "path";
19341
+ var WORKSPACE_ID_RELATIVE_PATH = join12("prim", "workspace-id");
19287
19342
  var MAX_ANCESTORS = 64;
19288
19343
  var MAX_GIT_FILE_BYTES = 4096;
19289
19344
  var MAX_ID_FILE_BYTES = 128;
@@ -19329,7 +19384,7 @@ function resolveWorkspaceIdPath(cwd) {
19329
19384
  }
19330
19385
  return {
19331
19386
  status: "resolved",
19332
- path: isAbsolute3(gitPath2) ? resolve4(gitPath2) : resolve4(cwd, gitPath2)
19387
+ path: isAbsolute4(gitPath2) ? resolve4(gitPath2) : resolve4(cwd, gitPath2)
19333
19388
  };
19334
19389
  } catch (error) {
19335
19390
  const code = errorCode(error);
@@ -19342,19 +19397,19 @@ function resolveWorkspaceIdPath(cwd) {
19342
19397
  function resolveFromFilesystem(cwd) {
19343
19398
  let current = resolve4(cwd);
19344
19399
  for (let depth = 0; depth < MAX_ANCESTORS; depth += 1) {
19345
- const dotGit = join10(current, ".git");
19400
+ const dotGit = join12(current, ".git");
19346
19401
  try {
19347
- const stat = lstatSync2(dotGit);
19402
+ const stat = lstatSync3(dotGit);
19348
19403
  if (stat.isDirectory() && isGitDirectory(dotGit)) {
19349
- return join10(dotGit, WORKSPACE_ID_RELATIVE_PATH);
19404
+ return join12(dotGit, WORKSPACE_ID_RELATIVE_PATH);
19350
19405
  }
19351
19406
  if (stat.isFile() && stat.size <= MAX_GIT_FILE_BYTES) {
19352
- const contents = readFileSync9(dotGit, "utf8");
19407
+ const contents = readFileSync11(dotGit, "utf8");
19353
19408
  const match = /^gitdir: (.+?)(?:\r?\n)?$/.exec(contents);
19354
19409
  if (match?.[1]) {
19355
- const gitDirectory = isAbsolute3(match[1]) ? resolve4(match[1]) : resolve4(current, match[1]);
19410
+ const gitDirectory = isAbsolute4(match[1]) ? resolve4(match[1]) : resolve4(current, match[1]);
19356
19411
  if (isGitDirectory(gitDirectory)) {
19357
- return join10(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
19412
+ return join12(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
19358
19413
  }
19359
19414
  }
19360
19415
  }
@@ -19365,7 +19420,7 @@ function resolveFromFilesystem(cwd) {
19365
19420
  return null;
19366
19421
  }
19367
19422
  }
19368
- const parent = dirname9(current);
19423
+ const parent = dirname10(current);
19369
19424
  if (parent === current) break;
19370
19425
  current = parent;
19371
19426
  }
@@ -19373,7 +19428,7 @@ function resolveFromFilesystem(cwd) {
19373
19428
  }
19374
19429
  function isGitDirectory(path) {
19375
19430
  try {
19376
- return statSync2(join10(path, "HEAD")).isFile();
19431
+ return statSync2(join12(path, "HEAD")).isFile();
19377
19432
  } catch {
19378
19433
  return false;
19379
19434
  }
@@ -19381,7 +19436,7 @@ function isGitDirectory(path) {
19381
19436
  function inspectPath(path) {
19382
19437
  let stat;
19383
19438
  try {
19384
- stat = lstatSync2(path);
19439
+ stat = lstatSync3(path);
19385
19440
  } catch (error) {
19386
19441
  const code = errorCode(error);
19387
19442
  if (code === "ENOENT" || code === "ENOTDIR") return { status: "missing", path };
@@ -19392,7 +19447,7 @@ function inspectPath(path) {
19392
19447
  return { status: "corrupt", path, reason: "invalid_content" };
19393
19448
  }
19394
19449
  try {
19395
- const contents = readFileSync9(path, "utf8");
19450
+ const contents = readFileSync11(path, "utf8");
19396
19451
  const workspaceId = contents.endsWith("\n") ? contents.slice(0, -1) : contents;
19397
19452
  if ((contents === workspaceId || contents === `${workspaceId}
19398
19453
  `) && isCanonicalWorkspaceId(workspaceId)) {
@@ -19409,14 +19464,14 @@ function inspectPath(path) {
19409
19464
  }
19410
19465
  }
19411
19466
  function createWorkspaceId(path) {
19412
- const parent = dirname9(path);
19467
+ const parent = dirname10(path);
19413
19468
  const workspaceId = randomUUID2();
19414
- const temporaryPath = join10(parent, `.workspace-id-${process.pid}-${randomUUID2()}.tmp`);
19469
+ const temporaryPath = join12(parent, `.workspace-id-${process.pid}-${randomUUID2()}.tmp`);
19415
19470
  let temporaryCreated = false;
19416
19471
  let publishing = false;
19417
19472
  try {
19418
19473
  mkdirSync6(parent, { recursive: true, mode: 448 });
19419
- chmodSync3(parent, 448);
19474
+ chmodSync4(parent, 448);
19420
19475
  const fd = openSync3(
19421
19476
  temporaryPath,
19422
19477
  constants2.O_CREAT | constants2.O_EXCL | constants2.O_WRONLY,
@@ -19480,8 +19535,8 @@ var AGENT_ENVELOPE_VERSION = 3;
19480
19535
  var ENVELOPE_VERSION = LEGACY_ENVELOPE_VERSION;
19481
19536
 
19482
19537
  // src/hooks/redact.ts
19483
- import { existsSync as existsSync7, readFileSync as readFileSync10, statSync as statSync3 } from "fs";
19484
- import { join as join11 } from "path";
19538
+ import { existsSync as existsSync8, readFileSync as readFileSync12, statSync as statSync3 } from "fs";
19539
+ import { join as join13 } from "path";
19485
19540
  import { Worker } from "worker_threads";
19486
19541
  var USER_HOME_RULES = [
19487
19542
  {
@@ -19657,7 +19712,7 @@ function toCommitMove(commit, cliVersion, cwd, context = {}) {
19657
19712
  }
19658
19713
 
19659
19714
  // src/hooks/post-commit.ts
19660
- var here = dirname10(fileURLToPath(import.meta.url));
19715
+ var here = dirname11(fileURLToPath2(import.meta.url));
19661
19716
  var GIT_TIMEOUT_MS4 = 1e3;
19662
19717
  var FULL_SHA_RE2 = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u;
19663
19718
  var OBSERVATION_MARKER_RE = /^prim-post-commit-observed\.[A-Za-z0-9]+$/u;
@@ -19665,9 +19720,9 @@ var MAX_OBSERVATION_MARKER_AGE_MS = 10 * 60 * 1e3;
19665
19720
  var MAX_OBSERVATION_MARKER_FUTURE_SKEW_MS = 5e3;
19666
19721
  function capturedAtFromLauncher(env = process.env, now = Date.now()) {
19667
19722
  const path = env.PRIM_COMMIT_OBSERVED_FILE;
19668
- if (!path || !isAbsolute4(path) || !OBSERVATION_MARKER_RE.test(basename3(path))) return;
19723
+ if (!path || !isAbsolute5(path) || !OBSERVATION_MARKER_RE.test(basename3(path))) return;
19669
19724
  try {
19670
- const stat = lstatSync3(path);
19725
+ const stat = lstatSync4(path);
19671
19726
  const capturedAt = Math.trunc(stat.mtimeMs);
19672
19727
  const uid = process.getuid?.();
19673
19728
  if (!stat.isFile() || stat.isSymbolicLink() || stat.size !== 0 || stat.nlink !== 1 || (stat.mode & 63) !== 0 || uid !== void 0 && stat.uid !== uid || !Number.isSafeInteger(capturedAt) || capturedAt <= 0 || capturedAt < now - MAX_OBSERVATION_MARKER_AGE_MS || capturedAt > now + MAX_OBSERVATION_MARKER_FUTURE_SKEW_MS) {
@@ -19751,14 +19806,14 @@ function readCommit() {
19751
19806
  }
19752
19807
  function resolveCliVersion() {
19753
19808
  try {
19754
- const pkg = JSON.parse(readFileSync11(join12(here, "..", "..", "package.json"), "utf-8"));
19809
+ const pkg = JSON.parse(readFileSync13(join14(here, "..", "..", "package.json"), "utf-8"));
19755
19810
  return pkg.version ?? "unknown";
19756
19811
  } catch {
19757
19812
  return "unknown";
19758
19813
  }
19759
19814
  }
19760
19815
  function spawnBackgroundFlush() {
19761
- const entry = join12(here, "..", "index.js");
19816
+ const entry = join14(here, "..", "index.js");
19762
19817
  spawn(process.execPath, [entry, "moves", "flush"], {
19763
19818
  detached: true,
19764
19819
  stdio: "ignore",