@primitive.ai/prim 0.1.0-alpha.92 → 0.1.0-alpha.93

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 +34 -2
  2. package/dist/{chunk-67VNLLBN.js → chunk-2GP5UFV7.js} +1 -0
  3. package/dist/{chunk-ADUTW66W.js → chunk-36TWVNBE.js} +6 -6
  4. package/dist/{chunk-5HRR4AOR.js → chunk-C3VAA5CG.js} +1 -1
  5. package/dist/{chunk-LGGMJYY4.js → chunk-DCJN6LZH.js} +37 -5
  6. package/dist/{chunk-M6RIJVRE.js → chunk-DSWT6BCC.js} +78 -4
  7. package/dist/{chunk-FBAYCS3X.js → chunk-DXJQR4QI.js} +150 -38
  8. package/dist/{chunk-PCVGBE5B.js → chunk-G2VMA2QO.js} +2 -1
  9. package/dist/{chunk-NAHHFSLH.js → chunk-ICM2XCXS.js} +2 -2
  10. package/dist/{chunk-OAAP2MY6.js → chunk-K7D2EYBS.js} +2 -2
  11. package/dist/{chunk-5AFRMOPX.js → chunk-OH3EZXYX.js} +1 -1
  12. package/dist/{chunk-KFXF2V5G.js → chunk-OTHKG76J.js} +1 -1
  13. package/dist/chunk-OYHYCK4K.js +13 -0
  14. package/dist/{chunk-FKXFUUWJ.js → chunk-TYAHC25F.js} +1 -1
  15. package/dist/{chunk-5GYQ4J3D.js → chunk-UKUAAAXE.js} +2 -2
  16. package/dist/{chunk-26P57LAR.js → chunk-X64HTHUF.js} +3 -1
  17. package/dist/{chunk-WX52U7Z2.js → chunk-ZU563PQI.js} +58 -2
  18. package/dist/daemon/server.js +372 -123
  19. package/dist/hook-runtime/daemon/server.js +372 -123
  20. package/dist/hook-runtime/hooks/post-commit.js +57 -39
  21. package/dist/hook-runtime/hooks/post-rewrite.js +58 -40
  22. package/dist/hook-runtime/hooks/post-tool-use.js +95 -62
  23. package/dist/hook-runtime/hooks/pre-tool-use.js +32 -10
  24. package/dist/hook-runtime/hooks/prim-hook.js +142 -102
  25. package/dist/hook-runtime/hooks/session-start.js +37 -3
  26. package/dist/hook-runtime/index.js +1264 -523
  27. package/dist/hook-runtime/statusline-main.js +23 -1
  28. package/dist/hooks/post-commit.js +11 -8
  29. package/dist/hooks/post-rewrite.js +11 -8
  30. package/dist/hooks/post-tool-use.js +13 -15
  31. package/dist/hooks/pre-commit.js +4 -4
  32. package/dist/hooks/pre-tool-use.js +10 -12
  33. package/dist/hooks/prim-hook.js +17 -14
  34. package/dist/hooks/session-end.js +4 -4
  35. package/dist/hooks/session-start.js +12 -36
  36. package/dist/index.js +857 -290
  37. package/dist/statusline-main.js +23 -1
  38. package/package.json +1 -1
  39. package/dist/chunk-BTNNEH2W.js +0 -79
@@ -53,8 +53,8 @@ var require_ucs2length = __commonJS({
53
53
 
54
54
  // src/hooks/post-commit.ts
55
55
  import { execFileSync as execFileSync4, spawn } from "child_process";
56
- import { lstatSync as lstatSync3, readFileSync as readFileSync9 } from "fs";
57
- import { basename as basename2, dirname as dirname8, isAbsolute as isAbsolute4, join as join10 } from "path";
56
+ import { lstatSync as lstatSync3, readFileSync as readFileSync10 } from "fs";
57
+ import { basename as basename3, dirname as dirname9, isAbsolute as isAbsolute4, join as join11 } from "path";
58
58
  import { fileURLToPath } from "url";
59
59
 
60
60
  // src/binding.ts
@@ -371,16 +371,16 @@ function resolveOrg(args) {
371
371
  import {
372
372
  appendFileSync,
373
373
  closeSync as closeSync2,
374
- existsSync as existsSync4,
374
+ existsSync as existsSync5,
375
375
  fstatSync,
376
376
  mkdirSync as mkdirSync4,
377
377
  openSync as openSync2,
378
378
  opendirSync,
379
- readFileSync as readFileSync5,
379
+ readFileSync as readFileSync6,
380
380
  readSync,
381
- readdirSync
381
+ readdirSync as readdirSync2
382
382
  } from "fs";
383
- import { dirname as dirname5, join as join6 } from "path";
383
+ import { dirname as dirname6, join as join7 } from "path";
384
384
 
385
385
  // src/client.ts
386
386
  import { createHash as createHash2 } from "crypto";
@@ -418,8 +418,19 @@ function getSiteUrlForEnvironment(primApiUrl) {
418
418
  }
419
419
  var CLI_MANAGEMENT_RESPONSE_MAX_BYTES = 2 * 1024 * 1024;
420
420
 
421
+ // src/drain-progress.ts
422
+ import {
423
+ chmodSync as chmodSync2,
424
+ existsSync as existsSync4,
425
+ readFileSync as readFileSync5,
426
+ readdirSync,
427
+ rmSync as rmSync4,
428
+ rmdirSync
429
+ } from "fs";
430
+ import { basename, dirname as dirname5, join as join6 } from "path";
431
+
421
432
  // src/journal.ts
422
- var JOURNAL_DIR = join6(primConfigDirectory(), "moves");
433
+ var JOURNAL_DIR = join7(primConfigDirectory(), "moves");
423
434
  var UNBOUND_BUCKET = "_unbound";
424
435
  var JOURNAL_BASENAME = "journal.ndjson";
425
436
  var JOURNAL_STATS_SAMPLE_BYTES = 64 * 1024;
@@ -431,15 +442,15 @@ function envSlug(apiUrl) {
431
442
  return slug;
432
443
  }
433
444
  function currentEnvDir() {
434
- return join6(JOURNAL_DIR, envSlug(getSiteUrl()));
445
+ return join7(JOURNAL_DIR, envSlug(getSiteUrl()));
435
446
  }
436
447
  var DIR_MODE = 448;
437
448
  var FILE_MODE = 384;
438
449
  var SAFE_BUCKET = /^[A-Za-z0-9_-]+$/;
439
450
  var RESERVED_BUCKETS = /* @__PURE__ */ new Set([UNBOUND_BUCKET, "_legacy"]);
440
451
  function appendMoveToPath(path, move) {
441
- const dir = dirname5(path);
442
- if (!existsSync4(dir)) {
452
+ const dir = dirname6(path);
453
+ if (!existsSync5(dir)) {
443
454
  mkdirSync4(dir, { recursive: true, mode: DIR_MODE });
444
455
  }
445
456
  appendFileSync(path, `${JSON.stringify(move)}
@@ -447,10 +458,10 @@ function appendMoveToPath(path, move) {
447
458
  }
448
459
  function bucketDir(orgId) {
449
460
  const safe = orgId !== void 0 && SAFE_BUCKET.test(orgId) && !RESERVED_BUCKETS.has(orgId);
450
- return join6(currentEnvDir(), safe ? orgId : UNBOUND_BUCKET);
461
+ return join7(currentEnvDir(), safe ? orgId : UNBOUND_BUCKET);
451
462
  }
452
463
  function journalPath(orgId) {
453
- return join6(bucketDir(orgId), JOURNAL_BASENAME);
464
+ return join7(bucketDir(orgId), JOURNAL_BASENAME);
454
465
  }
455
466
  function appendMove(move, orgId) {
456
467
  appendMoveToPath(journalPath(orgId), move);
@@ -459,15 +470,15 @@ var FLUSHING_PREFIX = `${JOURNAL_BASENAME}.flushing.`;
459
470
 
460
471
  // src/lib/activation.ts
461
472
  import { execFileSync as execFileSync2 } from "child_process";
462
- import { existsSync as existsSync5, readFileSync as readFileSync6 } from "fs";
473
+ import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
463
474
  import { homedir as homedir2 } from "os";
464
- import { join as join7 } from "path";
475
+ import { join as join8 } from "path";
465
476
 
466
477
  // src/lib/git.ts
467
478
  import { execFileSync } from "child_process";
468
479
  import { createHash as createHash3 } from "crypto";
469
480
  import { lstatSync, realpathSync } from "fs";
470
- import { basename, dirname as dirname6, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "path";
481
+ import { basename as basename2, dirname as dirname7, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "path";
471
482
  var GIT_TIMEOUT_MS = 1e3;
472
483
  var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
473
484
  var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
@@ -615,10 +626,10 @@ function hasProjectPrimInstall(cwd) {
615
626
  const root = gitToplevel(cwd);
616
627
  if (root === null || root === homedir2()) return false;
617
628
  for (const rel of PROJECT_INSTALL_FILES) {
618
- const path = join7(root, rel);
619
- if (existsSync5(path)) {
629
+ const path = join8(root, rel);
630
+ if (existsSync6(path)) {
620
631
  try {
621
- const content = readFileSync6(path, "utf-8");
632
+ const content = readFileSync7(path, "utf-8");
622
633
  if (PRIM_HOOK_BINS.some((bin) => content.includes(bin))) return true;
623
634
  } catch {
624
635
  }
@@ -18704,12 +18715,18 @@ function cachedCollectScopeAdmits(cwd, facts) {
18704
18715
  );
18705
18716
  }
18706
18717
 
18718
+ // src/lib/unattended.ts
18719
+ var UNATTENDED_ENV = "PRIM_UNATTENDED";
18720
+ function unattendedEnv(env = process.env) {
18721
+ return { ...env, [UNATTENDED_ENV]: "1" };
18722
+ }
18723
+
18707
18724
  // src/lib/workspace-id.ts
18708
18725
  import { execFileSync as execFileSync3 } from "child_process";
18709
18726
  import { randomUUID as randomUUID2 } from "crypto";
18710
18727
  import {
18711
18728
  constants as constants2,
18712
- chmodSync as chmodSync2,
18729
+ chmodSync as chmodSync3,
18713
18730
  closeSync as closeSync3,
18714
18731
  fchmodSync as fchmodSync2,
18715
18732
  fsyncSync as fsyncSync2,
@@ -18717,13 +18734,13 @@ import {
18717
18734
  lstatSync as lstatSync2,
18718
18735
  mkdirSync as mkdirSync5,
18719
18736
  openSync as openSync3,
18720
- readFileSync as readFileSync7,
18737
+ readFileSync as readFileSync8,
18721
18738
  statSync as statSync2,
18722
18739
  unlinkSync,
18723
18740
  writeFileSync as writeFileSync3
18724
18741
  } from "fs";
18725
- import { dirname as dirname7, isAbsolute as isAbsolute3, join as join8, resolve as resolve3 } from "path";
18726
- var WORKSPACE_ID_RELATIVE_PATH = join8("prim", "workspace-id");
18742
+ import { dirname as dirname8, isAbsolute as isAbsolute3, join as join9, resolve as resolve3 } from "path";
18743
+ var WORKSPACE_ID_RELATIVE_PATH = join9("prim", "workspace-id");
18727
18744
  var MAX_ANCESTORS = 64;
18728
18745
  var MAX_GIT_FILE_BYTES = 4096;
18729
18746
  var MAX_ID_FILE_BYTES = 128;
@@ -18782,19 +18799,19 @@ function resolveWorkspaceIdPath(cwd) {
18782
18799
  function resolveFromFilesystem(cwd) {
18783
18800
  let current = resolve3(cwd);
18784
18801
  for (let depth = 0; depth < MAX_ANCESTORS; depth += 1) {
18785
- const dotGit = join8(current, ".git");
18802
+ const dotGit = join9(current, ".git");
18786
18803
  try {
18787
18804
  const stat = lstatSync2(dotGit);
18788
18805
  if (stat.isDirectory() && isGitDirectory(dotGit)) {
18789
- return join8(dotGit, WORKSPACE_ID_RELATIVE_PATH);
18806
+ return join9(dotGit, WORKSPACE_ID_RELATIVE_PATH);
18790
18807
  }
18791
18808
  if (stat.isFile() && stat.size <= MAX_GIT_FILE_BYTES) {
18792
- const contents = readFileSync7(dotGit, "utf8");
18809
+ const contents = readFileSync8(dotGit, "utf8");
18793
18810
  const match = /^gitdir: (.+?)(?:\r?\n)?$/.exec(contents);
18794
18811
  if (match?.[1]) {
18795
18812
  const gitDirectory = isAbsolute3(match[1]) ? resolve3(match[1]) : resolve3(current, match[1]);
18796
18813
  if (isGitDirectory(gitDirectory)) {
18797
- return join8(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
18814
+ return join9(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
18798
18815
  }
18799
18816
  }
18800
18817
  }
@@ -18805,7 +18822,7 @@ function resolveFromFilesystem(cwd) {
18805
18822
  return null;
18806
18823
  }
18807
18824
  }
18808
- const parent = dirname7(current);
18825
+ const parent = dirname8(current);
18809
18826
  if (parent === current) break;
18810
18827
  current = parent;
18811
18828
  }
@@ -18813,7 +18830,7 @@ function resolveFromFilesystem(cwd) {
18813
18830
  }
18814
18831
  function isGitDirectory(path) {
18815
18832
  try {
18816
- return statSync2(join8(path, "HEAD")).isFile();
18833
+ return statSync2(join9(path, "HEAD")).isFile();
18817
18834
  } catch {
18818
18835
  return false;
18819
18836
  }
@@ -18832,7 +18849,7 @@ function inspectPath(path) {
18832
18849
  return { status: "corrupt", path, reason: "invalid_content" };
18833
18850
  }
18834
18851
  try {
18835
- const contents = readFileSync7(path, "utf8");
18852
+ const contents = readFileSync8(path, "utf8");
18836
18853
  const workspaceId = contents.endsWith("\n") ? contents.slice(0, -1) : contents;
18837
18854
  if ((contents === workspaceId || contents === `${workspaceId}
18838
18855
  `) && isCanonicalWorkspaceId(workspaceId)) {
@@ -18849,14 +18866,14 @@ function inspectPath(path) {
18849
18866
  }
18850
18867
  }
18851
18868
  function createWorkspaceId(path) {
18852
- const parent = dirname7(path);
18869
+ const parent = dirname8(path);
18853
18870
  const workspaceId = randomUUID2();
18854
- const temporaryPath = join8(parent, `.workspace-id-${process.pid}-${randomUUID2()}.tmp`);
18871
+ const temporaryPath = join9(parent, `.workspace-id-${process.pid}-${randomUUID2()}.tmp`);
18855
18872
  let temporaryCreated = false;
18856
18873
  let publishing = false;
18857
18874
  try {
18858
18875
  mkdirSync5(parent, { recursive: true, mode: 448 });
18859
- chmodSync2(parent, 448);
18876
+ chmodSync3(parent, 448);
18860
18877
  const fd = openSync3(
18861
18878
  temporaryPath,
18862
18879
  constants2.O_CREAT | constants2.O_EXCL | constants2.O_WRONLY,
@@ -18920,8 +18937,8 @@ var AGENT_ENVELOPE_VERSION = 3;
18920
18937
  var ENVELOPE_VERSION = LEGACY_ENVELOPE_VERSION;
18921
18938
 
18922
18939
  // src/hooks/redact.ts
18923
- import { existsSync as existsSync6, readFileSync as readFileSync8, statSync as statSync3 } from "fs";
18924
- import { join as join9 } from "path";
18940
+ import { existsSync as existsSync7, readFileSync as readFileSync9, statSync as statSync3 } from "fs";
18941
+ import { join as join10 } from "path";
18925
18942
  import { Worker } from "worker_threads";
18926
18943
  var USER_HOME_RULES = [
18927
18944
  {
@@ -19097,7 +19114,7 @@ function toCommitMove(commit, cliVersion, cwd, context = {}) {
19097
19114
  }
19098
19115
 
19099
19116
  // src/hooks/post-commit.ts
19100
- var here = dirname8(fileURLToPath(import.meta.url));
19117
+ var here = dirname9(fileURLToPath(import.meta.url));
19101
19118
  var GIT_TIMEOUT_MS3 = 1e3;
19102
19119
  var FULL_SHA_RE = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u;
19103
19120
  var OBSERVATION_MARKER_RE = /^prim-post-commit-observed\.[A-Za-z0-9]+$/u;
@@ -19105,7 +19122,7 @@ var MAX_OBSERVATION_MARKER_AGE_MS = 10 * 60 * 1e3;
19105
19122
  var MAX_OBSERVATION_MARKER_FUTURE_SKEW_MS = 5e3;
19106
19123
  function capturedAtFromLauncher(env = process.env, now = Date.now()) {
19107
19124
  const path = env.PRIM_COMMIT_OBSERVED_FILE;
19108
- if (!path || !isAbsolute4(path) || !OBSERVATION_MARKER_RE.test(basename2(path))) return;
19125
+ if (!path || !isAbsolute4(path) || !OBSERVATION_MARKER_RE.test(basename3(path))) return;
19109
19126
  try {
19110
19127
  const stat = lstatSync3(path);
19111
19128
  const capturedAt = Math.trunc(stat.mtimeMs);
@@ -19191,17 +19208,18 @@ function readCommit() {
19191
19208
  }
19192
19209
  function resolveCliVersion() {
19193
19210
  try {
19194
- const pkg = JSON.parse(readFileSync9(join10(here, "..", "..", "package.json"), "utf-8"));
19211
+ const pkg = JSON.parse(readFileSync10(join11(here, "..", "..", "package.json"), "utf-8"));
19195
19212
  return pkg.version ?? "unknown";
19196
19213
  } catch {
19197
19214
  return "unknown";
19198
19215
  }
19199
19216
  }
19200
19217
  function spawnBackgroundFlush() {
19201
- const entry = join10(here, "..", "index.js");
19218
+ const entry = join11(here, "..", "index.js");
19202
19219
  spawn(process.execPath, [entry, "moves", "flush"], {
19203
19220
  detached: true,
19204
- stdio: "ignore"
19221
+ stdio: "ignore",
19222
+ env: unattendedEnv()
19205
19223
  }).unref();
19206
19224
  }
19207
19225
  function runPostCommit() {
@@ -59,10 +59,10 @@ import {
59
59
  fstatSync as fstatSync2,
60
60
  lstatSync as lstatSync3,
61
61
  openSync as openSync4,
62
- readFileSync as readFileSync9,
62
+ readFileSync as readFileSync10,
63
63
  unlinkSync as unlinkSync2
64
64
  } from "fs";
65
- import { basename as basename2, dirname as dirname8, isAbsolute as isAbsolute4, join as join10 } from "path";
65
+ import { basename as basename3, dirname as dirname9, isAbsolute as isAbsolute4, join as join11 } from "path";
66
66
  import { fileURLToPath } from "url";
67
67
 
68
68
  // src/binding.ts
@@ -379,16 +379,16 @@ function resolveOrg(args) {
379
379
  import {
380
380
  appendFileSync,
381
381
  closeSync as closeSync2,
382
- existsSync as existsSync4,
382
+ existsSync as existsSync5,
383
383
  fstatSync,
384
384
  mkdirSync as mkdirSync4,
385
385
  openSync as openSync2,
386
386
  opendirSync,
387
- readFileSync as readFileSync5,
387
+ readFileSync as readFileSync6,
388
388
  readSync,
389
- readdirSync
389
+ readdirSync as readdirSync2
390
390
  } from "fs";
391
- import { dirname as dirname5, join as join6 } from "path";
391
+ import { dirname as dirname6, join as join7 } from "path";
392
392
 
393
393
  // src/client.ts
394
394
  import { createHash as createHash2 } from "crypto";
@@ -426,8 +426,19 @@ function getSiteUrlForEnvironment(primApiUrl) {
426
426
  }
427
427
  var CLI_MANAGEMENT_RESPONSE_MAX_BYTES = 2 * 1024 * 1024;
428
428
 
429
+ // src/drain-progress.ts
430
+ import {
431
+ chmodSync as chmodSync2,
432
+ existsSync as existsSync4,
433
+ readFileSync as readFileSync5,
434
+ readdirSync,
435
+ rmSync as rmSync4,
436
+ rmdirSync
437
+ } from "fs";
438
+ import { basename, dirname as dirname5, join as join6 } from "path";
439
+
429
440
  // src/journal.ts
430
- var JOURNAL_DIR = join6(primConfigDirectory(), "moves");
441
+ var JOURNAL_DIR = join7(primConfigDirectory(), "moves");
431
442
  var UNBOUND_BUCKET = "_unbound";
432
443
  var JOURNAL_BASENAME = "journal.ndjson";
433
444
  var JOURNAL_STATS_SAMPLE_BYTES = 64 * 1024;
@@ -439,15 +450,15 @@ function envSlug(apiUrl) {
439
450
  return slug;
440
451
  }
441
452
  function currentEnvDir() {
442
- return join6(JOURNAL_DIR, envSlug(getSiteUrl()));
453
+ return join7(JOURNAL_DIR, envSlug(getSiteUrl()));
443
454
  }
444
455
  var DIR_MODE = 448;
445
456
  var FILE_MODE = 384;
446
457
  var SAFE_BUCKET = /^[A-Za-z0-9_-]+$/;
447
458
  var RESERVED_BUCKETS = /* @__PURE__ */ new Set([UNBOUND_BUCKET, "_legacy"]);
448
459
  function appendMoveToPath(path, move) {
449
- const dir = dirname5(path);
450
- if (!existsSync4(dir)) {
460
+ const dir = dirname6(path);
461
+ if (!existsSync5(dir)) {
451
462
  mkdirSync4(dir, { recursive: true, mode: DIR_MODE });
452
463
  }
453
464
  appendFileSync(path, `${JSON.stringify(move)}
@@ -455,10 +466,10 @@ function appendMoveToPath(path, move) {
455
466
  }
456
467
  function bucketDir(orgId) {
457
468
  const safe = orgId !== void 0 && SAFE_BUCKET.test(orgId) && !RESERVED_BUCKETS.has(orgId);
458
- return join6(currentEnvDir(), safe ? orgId : UNBOUND_BUCKET);
469
+ return join7(currentEnvDir(), safe ? orgId : UNBOUND_BUCKET);
459
470
  }
460
471
  function journalPath(orgId) {
461
- return join6(bucketDir(orgId), JOURNAL_BASENAME);
472
+ return join7(bucketDir(orgId), JOURNAL_BASENAME);
462
473
  }
463
474
  function appendMove(move, orgId) {
464
475
  appendMoveToPath(journalPath(orgId), move);
@@ -467,15 +478,15 @@ var FLUSHING_PREFIX = `${JOURNAL_BASENAME}.flushing.`;
467
478
 
468
479
  // src/lib/activation.ts
469
480
  import { execFileSync as execFileSync2 } from "child_process";
470
- import { existsSync as existsSync5, readFileSync as readFileSync6 } from "fs";
481
+ import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
471
482
  import { homedir as homedir2 } from "os";
472
- import { join as join7 } from "path";
483
+ import { join as join8 } from "path";
473
484
 
474
485
  // src/lib/git.ts
475
486
  import { execFileSync } from "child_process";
476
487
  import { createHash as createHash3 } from "crypto";
477
488
  import { lstatSync, realpathSync } from "fs";
478
- import { basename, dirname as dirname6, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "path";
489
+ import { basename as basename2, dirname as dirname7, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "path";
479
490
  var GIT_TIMEOUT_MS = 1e3;
480
491
  var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
481
492
  var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
@@ -623,10 +634,10 @@ function hasProjectPrimInstall(cwd) {
623
634
  const root = gitToplevel(cwd);
624
635
  if (root === null || root === homedir2()) return false;
625
636
  for (const rel of PROJECT_INSTALL_FILES) {
626
- const path = join7(root, rel);
627
- if (existsSync5(path)) {
637
+ const path = join8(root, rel);
638
+ if (existsSync6(path)) {
628
639
  try {
629
- const content = readFileSync6(path, "utf-8");
640
+ const content = readFileSync7(path, "utf-8");
630
641
  if (PRIM_HOOK_BINS.some((bin) => content.includes(bin))) return true;
631
642
  } catch {
632
643
  }
@@ -18712,12 +18723,18 @@ function cachedCollectScopeAdmits(cwd, facts) {
18712
18723
  );
18713
18724
  }
18714
18725
 
18726
+ // src/lib/unattended.ts
18727
+ var UNATTENDED_ENV = "PRIM_UNATTENDED";
18728
+ function unattendedEnv(env = process.env) {
18729
+ return { ...env, [UNATTENDED_ENV]: "1" };
18730
+ }
18731
+
18715
18732
  // src/lib/workspace-id.ts
18716
18733
  import { execFileSync as execFileSync3 } from "child_process";
18717
18734
  import { randomUUID as randomUUID2 } from "crypto";
18718
18735
  import {
18719
18736
  constants as constants2,
18720
- chmodSync as chmodSync2,
18737
+ chmodSync as chmodSync3,
18721
18738
  closeSync as closeSync3,
18722
18739
  fchmodSync as fchmodSync2,
18723
18740
  fsyncSync as fsyncSync2,
@@ -18725,13 +18742,13 @@ import {
18725
18742
  lstatSync as lstatSync2,
18726
18743
  mkdirSync as mkdirSync5,
18727
18744
  openSync as openSync3,
18728
- readFileSync as readFileSync7,
18745
+ readFileSync as readFileSync8,
18729
18746
  statSync as statSync2,
18730
18747
  unlinkSync,
18731
18748
  writeFileSync as writeFileSync3
18732
18749
  } from "fs";
18733
- import { dirname as dirname7, isAbsolute as isAbsolute3, join as join8, resolve as resolve3 } from "path";
18734
- var WORKSPACE_ID_RELATIVE_PATH = join8("prim", "workspace-id");
18750
+ import { dirname as dirname8, isAbsolute as isAbsolute3, join as join9, resolve as resolve3 } from "path";
18751
+ var WORKSPACE_ID_RELATIVE_PATH = join9("prim", "workspace-id");
18735
18752
  var MAX_ANCESTORS = 64;
18736
18753
  var MAX_GIT_FILE_BYTES = 4096;
18737
18754
  var MAX_ID_FILE_BYTES = 128;
@@ -18790,19 +18807,19 @@ function resolveWorkspaceIdPath(cwd) {
18790
18807
  function resolveFromFilesystem(cwd) {
18791
18808
  let current = resolve3(cwd);
18792
18809
  for (let depth = 0; depth < MAX_ANCESTORS; depth += 1) {
18793
- const dotGit = join8(current, ".git");
18810
+ const dotGit = join9(current, ".git");
18794
18811
  try {
18795
18812
  const stat = lstatSync2(dotGit);
18796
18813
  if (stat.isDirectory() && isGitDirectory(dotGit)) {
18797
- return join8(dotGit, WORKSPACE_ID_RELATIVE_PATH);
18814
+ return join9(dotGit, WORKSPACE_ID_RELATIVE_PATH);
18798
18815
  }
18799
18816
  if (stat.isFile() && stat.size <= MAX_GIT_FILE_BYTES) {
18800
- const contents = readFileSync7(dotGit, "utf8");
18817
+ const contents = readFileSync8(dotGit, "utf8");
18801
18818
  const match = /^gitdir: (.+?)(?:\r?\n)?$/.exec(contents);
18802
18819
  if (match?.[1]) {
18803
18820
  const gitDirectory = isAbsolute3(match[1]) ? resolve3(match[1]) : resolve3(current, match[1]);
18804
18821
  if (isGitDirectory(gitDirectory)) {
18805
- return join8(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
18822
+ return join9(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
18806
18823
  }
18807
18824
  }
18808
18825
  }
@@ -18813,7 +18830,7 @@ function resolveFromFilesystem(cwd) {
18813
18830
  return null;
18814
18831
  }
18815
18832
  }
18816
- const parent = dirname7(current);
18833
+ const parent = dirname8(current);
18817
18834
  if (parent === current) break;
18818
18835
  current = parent;
18819
18836
  }
@@ -18821,7 +18838,7 @@ function resolveFromFilesystem(cwd) {
18821
18838
  }
18822
18839
  function isGitDirectory(path) {
18823
18840
  try {
18824
- return statSync2(join8(path, "HEAD")).isFile();
18841
+ return statSync2(join9(path, "HEAD")).isFile();
18825
18842
  } catch {
18826
18843
  return false;
18827
18844
  }
@@ -18840,7 +18857,7 @@ function inspectPath(path) {
18840
18857
  return { status: "corrupt", path, reason: "invalid_content" };
18841
18858
  }
18842
18859
  try {
18843
- const contents = readFileSync7(path, "utf8");
18860
+ const contents = readFileSync8(path, "utf8");
18844
18861
  const workspaceId = contents.endsWith("\n") ? contents.slice(0, -1) : contents;
18845
18862
  if ((contents === workspaceId || contents === `${workspaceId}
18846
18863
  `) && isCanonicalWorkspaceId(workspaceId)) {
@@ -18857,14 +18874,14 @@ function inspectPath(path) {
18857
18874
  }
18858
18875
  }
18859
18876
  function createWorkspaceId(path) {
18860
- const parent = dirname7(path);
18877
+ const parent = dirname8(path);
18861
18878
  const workspaceId = randomUUID2();
18862
- const temporaryPath = join8(parent, `.workspace-id-${process.pid}-${randomUUID2()}.tmp`);
18879
+ const temporaryPath = join9(parent, `.workspace-id-${process.pid}-${randomUUID2()}.tmp`);
18863
18880
  let temporaryCreated = false;
18864
18881
  let publishing = false;
18865
18882
  try {
18866
18883
  mkdirSync5(parent, { recursive: true, mode: 448 });
18867
- chmodSync2(parent, 448);
18884
+ chmodSync3(parent, 448);
18868
18885
  const fd = openSync3(
18869
18886
  temporaryPath,
18870
18887
  constants2.O_CREAT | constants2.O_EXCL | constants2.O_WRONLY,
@@ -18927,8 +18944,8 @@ var LEGACY_ENVELOPE_VERSION = 1;
18927
18944
  var ENVELOPE_VERSION = LEGACY_ENVELOPE_VERSION;
18928
18945
 
18929
18946
  // src/hooks/redact.ts
18930
- import { existsSync as existsSync6, readFileSync as readFileSync8, statSync as statSync3 } from "fs";
18931
- import { join as join9 } from "path";
18947
+ import { existsSync as existsSync7, readFileSync as readFileSync9, statSync as statSync3 } from "fs";
18948
+ import { join as join10 } from "path";
18932
18949
  import { Worker } from "worker_threads";
18933
18950
  var USER_HOME_RULES = [
18934
18951
  {
@@ -19107,7 +19124,7 @@ function toRewriteMove(rewrite, cliVersion, cwd, context) {
19107
19124
  }
19108
19125
 
19109
19126
  // src/hooks/post-rewrite.ts
19110
- var here = dirname8(fileURLToPath(import.meta.url));
19127
+ var here = dirname9(fileURLToPath(import.meta.url));
19111
19128
  var GIT_TIMEOUT_MS3 = 1e3;
19112
19129
  var MAX_PAIRS_FILE_BYTES = 1048576;
19113
19130
  var MAX_PAIRS_FILE_AGE_MS = 10 * 60 * 1e3;
@@ -19137,7 +19154,7 @@ function privatePairsFileStat(stat, now) {
19137
19154
  }
19138
19155
  function rewritePairsFromLauncher(env = process.env, now = Date.now()) {
19139
19156
  const path = env.PRIM_REWRITE_PAIRS_FILE;
19140
- if (!path || !isAbsolute4(path) || !PAIRS_FILE_RE.test(basename2(path))) return;
19157
+ if (!path || !isAbsolute4(path) || !PAIRS_FILE_RE.test(basename3(path))) return;
19141
19158
  let fd;
19142
19159
  try {
19143
19160
  const pathStat = lstatSync3(path);
@@ -19147,7 +19164,7 @@ function rewritePairsFromLauncher(env = process.env, now = Date.now()) {
19147
19164
  if (!privatePairsFileStat(openStat, now) || openStat.dev !== pathStat.dev || openStat.ino !== pathStat.ino) {
19148
19165
  return;
19149
19166
  }
19150
- const bytes = readFileSync9(fd);
19167
+ const bytes = readFileSync10(fd);
19151
19168
  if (bytes.length !== openStat.size) return;
19152
19169
  let text;
19153
19170
  try {
@@ -19203,17 +19220,18 @@ function validBranch(value) {
19203
19220
  }
19204
19221
  function resolveCliVersion() {
19205
19222
  try {
19206
- const pkg = JSON.parse(readFileSync9(join10(here, "..", "..", "package.json"), "utf-8"));
19223
+ const pkg = JSON.parse(readFileSync10(join11(here, "..", "..", "package.json"), "utf-8"));
19207
19224
  return pkg.version ?? "unknown";
19208
19225
  } catch {
19209
19226
  return "unknown";
19210
19227
  }
19211
19228
  }
19212
19229
  function spawnBackgroundFlush() {
19213
- const entry = join10(here, "..", "index.js");
19230
+ const entry = join11(here, "..", "index.js");
19214
19231
  spawn(process.execPath, [entry, "moves", "flush"], {
19215
19232
  detached: true,
19216
- stdio: "ignore"
19233
+ stdio: "ignore",
19234
+ env: unattendedEnv()
19217
19235
  }).unref();
19218
19236
  }
19219
19237
  function runPostRewrite() {