@primitive.ai/prim 0.1.0-alpha.120 → 0.1.0-alpha.121

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 (46) hide show
  1. package/README.md +19 -9
  2. package/SKILL.md +7 -2
  3. package/dist/{chunk-HXICZG5J.js → chunk-2DNC2MUN.js} +4 -4
  4. package/dist/{chunk-NQFRQ56V.js → chunk-2PFJJO2M.js} +2 -2
  5. package/dist/{chunk-P2O7NLVN.js → chunk-4GYJHN26.js} +117 -18
  6. package/dist/{chunk-5BQ2NEMP.js → chunk-6DEROXLM.js} +2 -2
  7. package/dist/{chunk-CCGFRNAA.js → chunk-7LXRFXZG.js} +248 -127
  8. package/dist/{chunk-MWNRXAEB.js → chunk-AKGRY7OU.js} +1 -1
  9. package/dist/{chunk-L52OD62C.js → chunk-BHT6X3T5.js} +14 -8
  10. package/dist/{chunk-D235RJNO.js → chunk-DQ4I3FLF.js} +3 -3
  11. package/dist/{chunk-VOC4KOOP.js → chunk-DVHD6LBQ.js} +2 -2
  12. package/dist/{chunk-TC4FTRYO.js → chunk-HG7FJK7R.js} +2 -2
  13. package/dist/{chunk-GYQOZGGF.js → chunk-JXRJLHE4.js} +2 -2
  14. package/dist/{chunk-2AKDX4RU.js → chunk-JZC2LHS6.js} +1 -1
  15. package/dist/{chunk-YTF6OCF3.js → chunk-LQLP26RL.js} +5 -5
  16. package/dist/{chunk-EYBE724K.js → chunk-M4NZJCPQ.js} +4 -4
  17. package/dist/{chunk-R2NUH4B7.js → chunk-MRDY7VQP.js} +2 -2
  18. package/dist/{chunk-SLDZJD6Q.js → chunk-NMZSCSMY.js} +1 -1
  19. package/dist/{chunk-A6M2M5A2.js → chunk-NQZLXYTW.js} +1 -1
  20. package/dist/{chunk-LTTF4MBE.js → chunk-OXW6PSPT.js} +2 -2
  21. package/dist/{chunk-U67RBNIZ.js → chunk-S3ZIMGXV.js} +1 -1
  22. package/dist/{chunk-LBCPRHNG.js → chunk-WN7OURQ3.js} +1 -1
  23. package/dist/daemon/server.js +78 -16
  24. package/dist/hook-runtime/daemon/server.js +78 -16
  25. package/dist/hook-runtime/hooks/post-commit.js +88 -26
  26. package/dist/hook-runtime/hooks/post-rewrite.js +82 -20
  27. package/dist/hook-runtime/hooks/post-tool-use.js +82 -20
  28. package/dist/hook-runtime/hooks/pre-commit.js +9 -5
  29. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +12 -8
  30. package/dist/hook-runtime/hooks/prim-hook.js +85 -23
  31. package/dist/hook-runtime/hooks/session-end.js +75 -13
  32. package/dist/hook-runtime/hooks/session-start.js +247 -176
  33. package/dist/hook-runtime/index.js +1147 -692
  34. package/dist/hook-runtime/statusline-main.js +76 -14
  35. package/dist/hooks/post-commit.js +7 -7
  36. package/dist/hooks/post-rewrite.js +6 -6
  37. package/dist/hooks/post-tool-use.js +15 -15
  38. package/dist/hooks/pre-commit.js +4 -4
  39. package/dist/hooks/pre-tool-use-worker.js +9 -9
  40. package/dist/hooks/prim-hook.js +17 -17
  41. package/dist/hooks/session-end.js +4 -4
  42. package/dist/hooks/session-start.js +11 -11
  43. package/dist/index.js +349 -98
  44. package/dist/statusline-main.js +76 -14
  45. package/package.json +3 -2
  46. package/skills/prim-welcome/SKILL.md +197 -0
@@ -53,7 +53,7 @@ var require_ucs2length = __commonJS({
53
53
  });
54
54
 
55
55
  // src/hooks/post-commit.ts
56
- import { execFileSync as execFileSync5, spawn } from "child_process";
56
+ import { execFileSync as execFileSync6, spawn } from "child_process";
57
57
  import { lstatSync as lstatSync4, readFileSync as readFileSync13 } from "fs";
58
58
  import { basename as basename3, dirname as dirname11, isAbsolute as isAbsolute5, join as join14 } from "path";
59
59
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -588,26 +588,87 @@ function appendMove(move, orgId) {
588
588
  var FLUSHING_PREFIX = `${JOURNAL_BASENAME}.flushing.`;
589
589
 
590
590
  // src/lib/activation.ts
591
- import { execFileSync as execFileSync2 } from "child_process";
591
+ import { execFileSync as execFileSync3 } from "child_process";
592
592
  import { existsSync as existsSync7, readFileSync as readFileSync9 } from "fs";
593
593
  import { homedir as homedir2 } from "os";
594
594
  import { join as join10 } from "path";
595
595
 
596
- // src/lib/git.ts
596
+ // src/lib/demo-pause.ts
597
597
  import { execFileSync } from "child_process";
598
+ var DEMO_PAUSE_MS = 30 * 6e4;
599
+ var PAUSE_KEY = "prim.demoPause";
600
+ var GIT_TIMEOUT_MS = 1e3;
601
+ function git(cwd, args) {
602
+ try {
603
+ return execFileSync("git", args, {
604
+ cwd,
605
+ encoding: "utf-8",
606
+ stdio: ["ignore", "pipe", "ignore"],
607
+ timeout: GIT_TIMEOUT_MS
608
+ });
609
+ } catch {
610
+ return void 0;
611
+ }
612
+ }
613
+ function setLocal(cwd, key, value) {
614
+ try {
615
+ execFileSync(
616
+ "git",
617
+ value === null ? ["config", "--local", "--unset", key] : ["config", "--local", key, value],
618
+ { cwd, stdio: ["ignore", "ignore", "pipe"], timeout: GIT_TIMEOUT_MS }
619
+ );
620
+ } catch (error) {
621
+ if (value !== null || error.status !== 5) throw error;
622
+ }
623
+ }
624
+ function parsePause(value) {
625
+ const [runId = "", until, previous, state] = value.trim().split(" ");
626
+ const flag = previous === "true" || previous === "false" ? previous : "unset";
627
+ return { runId, until: Number(until) || 0, previous: flag, ending: state !== "active" };
628
+ }
629
+ function readCaptureConfig(cwd) {
630
+ let active;
631
+ let pause;
632
+ const out = git(cwd, ["config", "--get-regexp", "^prim\\.(active|demopause)$"]) ?? "";
633
+ for (const line of out.split("\n")) {
634
+ const space = line.indexOf(" ");
635
+ const key = line.slice(0, space).toLowerCase();
636
+ const value = line.slice(space + 1);
637
+ if (key === "prim.active") active = value === "true" || value === "false" ? value : void 0;
638
+ if (key === "prim.demopause") pause = parsePause(value);
639
+ }
640
+ return { active, pause };
641
+ }
642
+ function resumeCapture(cwd, pause) {
643
+ setLocal(cwd, "prim.active", pause.previous === "unset" ? null : pause.previous);
644
+ setLocal(cwd, PAUSE_KEY, null);
645
+ }
646
+ function healDemoPause(cwd, pause, options = {}) {
647
+ if (pause.until > (options.now ?? Date.now()) && !(pause.ending && options.userPrompt))
648
+ return false;
649
+ try {
650
+ resumeCapture(cwd, pause);
651
+ return true;
652
+ } catch {
653
+ return false;
654
+ }
655
+ }
656
+
657
+ // src/lib/git.ts
658
+ import { execFileSync as execFileSync2 } from "child_process";
598
659
  import { createHash as createHash3 } from "crypto";
599
660
  import { lstatSync as lstatSync2, realpathSync } from "fs";
600
661
  import { basename as basename2, dirname as dirname8, isAbsolute as isAbsolute3, relative, resolve as resolve2, sep } from "path";
601
- var GIT_TIMEOUT_MS = 1e3;
662
+ var GIT_TIMEOUT_MS2 = 1e3;
602
663
  var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
603
664
  var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
604
665
  function gitToplevel(cwd) {
605
666
  try {
606
- return execFileSync("git", ["rev-parse", "--show-toplevel"], {
667
+ return execFileSync2("git", ["rev-parse", "--show-toplevel"], {
607
668
  cwd,
608
669
  encoding: "utf-8",
609
670
  stdio: ["ignore", "pipe", "ignore"],
610
- timeout: GIT_TIMEOUT_MS
671
+ timeout: GIT_TIMEOUT_MS2
611
672
  }).trim();
612
673
  } catch {
613
674
  return null;
@@ -615,11 +676,11 @@ function gitToplevel(cwd) {
615
676
  }
616
677
  function gitValue(cwd, args) {
617
678
  try {
618
- const value = execFileSync("git", args, {
679
+ const value = execFileSync2("git", args, {
619
680
  cwd,
620
681
  encoding: "utf-8",
621
682
  stdio: ["ignore", "pipe", "ignore"],
622
- timeout: GIT_TIMEOUT_MS
683
+ timeout: GIT_TIMEOUT_MS2
623
684
  }).trim();
624
685
  return value || void 0;
625
686
  } catch {
@@ -700,17 +761,17 @@ function resolveRepositoryContext(cwd = process.cwd()) {
700
761
  var PRIM_ACTIVE_KEY = "prim.active";
701
762
  var PRIM_REPO_SYNC_ID_KEY = "prim.repoSyncId";
702
763
  var PRIM_REPO_SYNC_REPOSITORY_KEY = "prim.repoSyncRepository";
703
- var GIT_TIMEOUT_MS2 = 1e3;
764
+ var GIT_TIMEOUT_MS3 = 1e3;
704
765
  var REPO_SYNC_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
705
766
  var PROJECT_INSTALL_FILES = [".claude/settings.json", ".codex/hooks.json", ".cursor/hooks.json"];
706
767
  var PRIM_HOOK_BINS = ["prim-hook", "prim-pre-tool-use", "prim-post-tool-use"];
707
768
  function repoActiveFlag(cwd, strict = false) {
708
769
  try {
709
- const value = execFileSync2("git", ["config", "--get", PRIM_ACTIVE_KEY], {
770
+ const value = execFileSync3("git", ["config", "--get", PRIM_ACTIVE_KEY], {
710
771
  cwd,
711
772
  encoding: "utf-8",
712
773
  stdio: ["ignore", "pipe", "ignore"],
713
- timeout: GIT_TIMEOUT_MS2
774
+ timeout: GIT_TIMEOUT_MS3
714
775
  }).trim();
715
776
  if (value === "true") return "true";
716
777
  if (value === "false") return "false";
@@ -727,11 +788,11 @@ function isValidRepoSyncId(value) {
727
788
  }
728
789
  function localGitConfigValue(cwd, key) {
729
790
  try {
730
- const value = execFileSync2("git", ["config", "--local", "--get", key], {
791
+ const value = execFileSync3("git", ["config", "--local", "--get", key], {
731
792
  cwd,
732
793
  encoding: "utf-8",
733
794
  stdio: ["ignore", "pipe", "ignore"],
734
- timeout: GIT_TIMEOUT_MS2
795
+ timeout: GIT_TIMEOUT_MS3
735
796
  }).trim();
736
797
  return value || void 0;
737
798
  } catch {
@@ -759,8 +820,9 @@ function hasProjectPrimInstall(cwd) {
759
820
  }
760
821
  return false;
761
822
  }
762
- function isRepoActiveForCapture(cwd) {
763
- const flag = repoActiveFlag(cwd);
823
+ function isRepoActiveForCapture(cwd, options = {}) {
824
+ let { active: flag, pause } = readCaptureConfig(cwd);
825
+ if (pause && healDemoPause(cwd, pause, options)) flag = repoActiveFlag(cwd);
764
826
  if (flag === "true") return true;
765
827
  if (flag === "false") return false;
766
828
  return hasProjectPrimInstall(cwd);
@@ -23223,21 +23285,21 @@ function cachedCollectScopeAdmits(cwd, facts) {
23223
23285
  }
23224
23286
 
23225
23287
  // src/lib/commit-heartbeat.ts
23226
- import { execFileSync as execFileSync3 } from "child_process";
23288
+ import { execFileSync as execFileSync4 } from "child_process";
23227
23289
  import { mkdirSync as mkdirSync5, readFileSync as readFileSync10, readdirSync as readdirSync3, unlinkSync } from "fs";
23228
23290
  import { dirname as dirname9, join as join11, resolve as resolve3 } from "path";
23229
23291
  var FIRED_DIR = "prim/post-commit-fired";
23230
- var GIT_TIMEOUT_MS3 = 1e3;
23292
+ var GIT_TIMEOUT_MS4 = 1e3;
23231
23293
  var MAX_STAMP_BYTES = 1024;
23232
23294
  var MAX_FIRED_STAMPS = 256;
23233
23295
  var PRUNE_SLACK = 64;
23234
23296
  var FULL_SHA_RE = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u;
23235
23297
  function gitPath(cwd, relative2) {
23236
- const value = execFileSync3("git", ["rev-parse", "--git-path", relative2], {
23298
+ const value = execFileSync4("git", ["rev-parse", "--git-path", relative2], {
23237
23299
  cwd,
23238
23300
  encoding: "utf8",
23239
23301
  stdio: ["ignore", "pipe", "ignore"],
23240
- timeout: GIT_TIMEOUT_MS3
23302
+ timeout: GIT_TIMEOUT_MS4
23241
23303
  }).replace(/\r?\n$/u, "");
23242
23304
  if (value === "" || /[\0\r\n]/u.test(value)) throw new Error("Git returned an unsafe path");
23243
23305
  return resolve3(cwd, value);
@@ -23281,7 +23343,7 @@ function unattendedEnv(env = process.env) {
23281
23343
  }
23282
23344
 
23283
23345
  // src/lib/workspace-id.ts
23284
- import { execFileSync as execFileSync4 } from "child_process";
23346
+ import { execFileSync as execFileSync5 } from "child_process";
23285
23347
  import { randomUUID as randomUUID2 } from "crypto";
23286
23348
  import {
23287
23349
  constants as constants2,
@@ -23327,7 +23389,7 @@ function resolveWorkspaceIdPath(cwd) {
23327
23389
  if (fromFilesystem) return { status: "resolved", path: fromFilesystem };
23328
23390
  }
23329
23391
  try {
23330
- const output = execFileSync4(
23392
+ const output = execFileSync5(
23331
23393
  "git",
23332
23394
  ["rev-parse", "--is-inside-work-tree", "--git-path", WORKSPACE_ID_RELATIVE_PATH],
23333
23395
  {
@@ -23674,7 +23736,7 @@ function toCommitMove(commit, cliVersion, cwd, context = {}) {
23674
23736
 
23675
23737
  // src/hooks/post-commit.ts
23676
23738
  var here = dirname11(fileURLToPath2(import.meta.url));
23677
- var GIT_TIMEOUT_MS4 = 1e3;
23739
+ var GIT_TIMEOUT_MS5 = 1e3;
23678
23740
  var FULL_SHA_RE2 = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u;
23679
23741
  var OBSERVATION_MARKER_RE = /^prim-post-commit-observed\.[A-Za-z0-9]+$/u;
23680
23742
  var MAX_OBSERVATION_MARKER_AGE_MS = 10 * 60 * 1e3;
@@ -23696,10 +23758,10 @@ function capturedAtFromLauncher(env = process.env, now = Date.now()) {
23696
23758
  }
23697
23759
  function gitText(args) {
23698
23760
  try {
23699
- return execFileSync5("git", args, {
23761
+ return execFileSync6("git", args, {
23700
23762
  encoding: "utf-8",
23701
23763
  stdio: ["ignore", "pipe", "ignore"],
23702
- timeout: GIT_TIMEOUT_MS4
23764
+ timeout: GIT_TIMEOUT_MS5
23703
23765
  }).trim();
23704
23766
  } catch {
23705
23767
  return;
@@ -23707,10 +23769,10 @@ function gitText(args) {
23707
23769
  }
23708
23770
  function gitBytes(args) {
23709
23771
  try {
23710
- return execFileSync5("git", args, {
23772
+ return execFileSync6("git", args, {
23711
23773
  encoding: "buffer",
23712
23774
  stdio: ["ignore", "pipe", "ignore"],
23713
- timeout: GIT_TIMEOUT_MS4
23775
+ timeout: GIT_TIMEOUT_MS5
23714
23776
  });
23715
23777
  } catch {
23716
23778
  return;
@@ -53,7 +53,7 @@ var require_ucs2length = __commonJS({
53
53
  });
54
54
 
55
55
  // src/hooks/post-rewrite.ts
56
- import { execFileSync as execFileSync4, spawn } from "child_process";
56
+ import { execFileSync as execFileSync5, spawn } from "child_process";
57
57
  import {
58
58
  constants as constants3,
59
59
  closeSync as closeSync4,
@@ -533,26 +533,87 @@ function appendMove(move, orgId) {
533
533
  var FLUSHING_PREFIX = `${JOURNAL_BASENAME}.flushing.`;
534
534
 
535
535
  // src/lib/activation.ts
536
- import { execFileSync as execFileSync2 } from "child_process";
536
+ import { execFileSync as execFileSync3 } from "child_process";
537
537
  import { existsSync as existsSync7, readFileSync as readFileSync9 } from "fs";
538
538
  import { homedir as homedir2 } from "os";
539
539
  import { join as join10 } from "path";
540
540
 
541
- // src/lib/git.ts
541
+ // src/lib/demo-pause.ts
542
542
  import { execFileSync } from "child_process";
543
+ var DEMO_PAUSE_MS = 30 * 6e4;
544
+ var PAUSE_KEY = "prim.demoPause";
545
+ var GIT_TIMEOUT_MS = 1e3;
546
+ function git(cwd, args) {
547
+ try {
548
+ return execFileSync("git", args, {
549
+ cwd,
550
+ encoding: "utf-8",
551
+ stdio: ["ignore", "pipe", "ignore"],
552
+ timeout: GIT_TIMEOUT_MS
553
+ });
554
+ } catch {
555
+ return void 0;
556
+ }
557
+ }
558
+ function setLocal(cwd, key, value) {
559
+ try {
560
+ execFileSync(
561
+ "git",
562
+ value === null ? ["config", "--local", "--unset", key] : ["config", "--local", key, value],
563
+ { cwd, stdio: ["ignore", "ignore", "pipe"], timeout: GIT_TIMEOUT_MS }
564
+ );
565
+ } catch (error) {
566
+ if (value !== null || error.status !== 5) throw error;
567
+ }
568
+ }
569
+ function parsePause(value) {
570
+ const [runId = "", until, previous, state] = value.trim().split(" ");
571
+ const flag = previous === "true" || previous === "false" ? previous : "unset";
572
+ return { runId, until: Number(until) || 0, previous: flag, ending: state !== "active" };
573
+ }
574
+ function readCaptureConfig(cwd) {
575
+ let active;
576
+ let pause;
577
+ const out = git(cwd, ["config", "--get-regexp", "^prim\\.(active|demopause)$"]) ?? "";
578
+ for (const line of out.split("\n")) {
579
+ const space = line.indexOf(" ");
580
+ const key = line.slice(0, space).toLowerCase();
581
+ const value = line.slice(space + 1);
582
+ if (key === "prim.active") active = value === "true" || value === "false" ? value : void 0;
583
+ if (key === "prim.demopause") pause = parsePause(value);
584
+ }
585
+ return { active, pause };
586
+ }
587
+ function resumeCapture(cwd, pause) {
588
+ setLocal(cwd, "prim.active", pause.previous === "unset" ? null : pause.previous);
589
+ setLocal(cwd, PAUSE_KEY, null);
590
+ }
591
+ function healDemoPause(cwd, pause, options = {}) {
592
+ if (pause.until > (options.now ?? Date.now()) && !(pause.ending && options.userPrompt))
593
+ return false;
594
+ try {
595
+ resumeCapture(cwd, pause);
596
+ return true;
597
+ } catch {
598
+ return false;
599
+ }
600
+ }
601
+
602
+ // src/lib/git.ts
603
+ import { execFileSync as execFileSync2 } from "child_process";
543
604
  import { createHash as createHash3 } from "crypto";
544
605
  import { lstatSync as lstatSync2, realpathSync } from "fs";
545
606
  import { basename as basename2, dirname as dirname8, isAbsolute as isAbsolute3, relative, resolve as resolve2, sep } from "path";
546
- var GIT_TIMEOUT_MS = 1e3;
607
+ var GIT_TIMEOUT_MS2 = 1e3;
547
608
  var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
548
609
  var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
549
610
  function gitToplevel(cwd) {
550
611
  try {
551
- return execFileSync("git", ["rev-parse", "--show-toplevel"], {
612
+ return execFileSync2("git", ["rev-parse", "--show-toplevel"], {
552
613
  cwd,
553
614
  encoding: "utf-8",
554
615
  stdio: ["ignore", "pipe", "ignore"],
555
- timeout: GIT_TIMEOUT_MS
616
+ timeout: GIT_TIMEOUT_MS2
556
617
  }).trim();
557
618
  } catch {
558
619
  return null;
@@ -560,11 +621,11 @@ function gitToplevel(cwd) {
560
621
  }
561
622
  function gitValue(cwd, args) {
562
623
  try {
563
- const value = execFileSync("git", args, {
624
+ const value = execFileSync2("git", args, {
564
625
  cwd,
565
626
  encoding: "utf-8",
566
627
  stdio: ["ignore", "pipe", "ignore"],
567
- timeout: GIT_TIMEOUT_MS
628
+ timeout: GIT_TIMEOUT_MS2
568
629
  }).trim();
569
630
  return value || void 0;
570
631
  } catch {
@@ -645,17 +706,17 @@ function resolveRepositoryContext(cwd = process.cwd()) {
645
706
  var PRIM_ACTIVE_KEY = "prim.active";
646
707
  var PRIM_REPO_SYNC_ID_KEY = "prim.repoSyncId";
647
708
  var PRIM_REPO_SYNC_REPOSITORY_KEY = "prim.repoSyncRepository";
648
- var GIT_TIMEOUT_MS2 = 1e3;
709
+ var GIT_TIMEOUT_MS3 = 1e3;
649
710
  var REPO_SYNC_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
650
711
  var PROJECT_INSTALL_FILES = [".claude/settings.json", ".codex/hooks.json", ".cursor/hooks.json"];
651
712
  var PRIM_HOOK_BINS = ["prim-hook", "prim-pre-tool-use", "prim-post-tool-use"];
652
713
  function repoActiveFlag(cwd, strict = false) {
653
714
  try {
654
- const value = execFileSync2("git", ["config", "--get", PRIM_ACTIVE_KEY], {
715
+ const value = execFileSync3("git", ["config", "--get", PRIM_ACTIVE_KEY], {
655
716
  cwd,
656
717
  encoding: "utf-8",
657
718
  stdio: ["ignore", "pipe", "ignore"],
658
- timeout: GIT_TIMEOUT_MS2
719
+ timeout: GIT_TIMEOUT_MS3
659
720
  }).trim();
660
721
  if (value === "true") return "true";
661
722
  if (value === "false") return "false";
@@ -672,11 +733,11 @@ function isValidRepoSyncId(value) {
672
733
  }
673
734
  function localGitConfigValue(cwd, key) {
674
735
  try {
675
- const value = execFileSync2("git", ["config", "--local", "--get", key], {
736
+ const value = execFileSync3("git", ["config", "--local", "--get", key], {
676
737
  cwd,
677
738
  encoding: "utf-8",
678
739
  stdio: ["ignore", "pipe", "ignore"],
679
- timeout: GIT_TIMEOUT_MS2
740
+ timeout: GIT_TIMEOUT_MS3
680
741
  }).trim();
681
742
  return value || void 0;
682
743
  } catch {
@@ -704,8 +765,9 @@ function hasProjectPrimInstall(cwd) {
704
765
  }
705
766
  return false;
706
767
  }
707
- function isRepoActiveForCapture(cwd) {
708
- const flag = repoActiveFlag(cwd);
768
+ function isRepoActiveForCapture(cwd, options = {}) {
769
+ let { active: flag, pause } = readCaptureConfig(cwd);
770
+ if (pause && healDemoPause(cwd, pause, options)) flag = repoActiveFlag(cwd);
709
771
  if (flag === "true") return true;
710
772
  if (flag === "false") return false;
711
773
  return hasProjectPrimInstall(cwd);
@@ -23174,7 +23236,7 @@ function unattendedEnv(env = process.env) {
23174
23236
  }
23175
23237
 
23176
23238
  // src/lib/workspace-id.ts
23177
- import { execFileSync as execFileSync3 } from "child_process";
23239
+ import { execFileSync as execFileSync4 } from "child_process";
23178
23240
  import { randomUUID as randomUUID2 } from "crypto";
23179
23241
  import {
23180
23242
  constants as constants2,
@@ -23220,7 +23282,7 @@ function resolveWorkspaceIdPath(cwd) {
23220
23282
  if (fromFilesystem) return { status: "resolved", path: fromFilesystem };
23221
23283
  }
23222
23284
  try {
23223
- const output = execFileSync3(
23285
+ const output = execFileSync4(
23224
23286
  "git",
23225
23287
  ["rev-parse", "--is-inside-work-tree", "--git-path", WORKSPACE_ID_RELATIVE_PATH],
23226
23288
  {
@@ -23569,7 +23631,7 @@ function toRewriteMove(rewrite, cliVersion, cwd, context) {
23569
23631
 
23570
23632
  // src/hooks/post-rewrite.ts
23571
23633
  var here = dirname10(fileURLToPath2(import.meta.url));
23572
- var GIT_TIMEOUT_MS3 = 1e3;
23634
+ var GIT_TIMEOUT_MS4 = 1e3;
23573
23635
  var MAX_PAIRS_FILE_BYTES = 1048576;
23574
23636
  var MAX_PAIRS_FILE_AGE_MS = 10 * 60 * 1e3;
23575
23637
  var MAX_PAIRS_FILE_FUTURE_SKEW_MS = 5e3;
@@ -23647,10 +23709,10 @@ function unlinkSnapshot(snapshot) {
23647
23709
  }
23648
23710
  function gitText(args) {
23649
23711
  try {
23650
- return execFileSync4("git", args, {
23712
+ return execFileSync5("git", args, {
23651
23713
  encoding: "utf-8",
23652
23714
  stdio: ["ignore", "pipe", "ignore"],
23653
- timeout: GIT_TIMEOUT_MS3
23715
+ timeout: GIT_TIMEOUT_MS4
23654
23716
  }).trim();
23655
23717
  } catch {
23656
23718
  return;
@@ -23077,7 +23077,7 @@ function readRun(id2) {
23077
23077
  "cleanup",
23078
23078
  "completed",
23079
23079
  "skipped"
23080
- ].includes(run.stage) || run.needsStatus !== void 0 && typeof run.needsStatus !== "boolean" || run.server !== void 0 && !isDemoStatusResponse(run.server) || run.receipt !== void 0 && (!Number.isSafeInteger(run.receipt.revision) || run.receipt.revision < 0 || !/^[a-f0-9]{64}$/u.test(run.receipt.appliedDigest)) || typeof run.terminal !== "boolean" || !Array.isArray(run.launcher) || run.launcher.length !== 2 || run.launcher.some((value) => typeof value !== "string" || !value.startsWith("/")) || run.agent !== void 0 && !["claude_code", "codex", "cursor", "hermes"].includes(run.agent)) {
23080
+ ].includes(run.stage) || run.needsStatus !== void 0 && typeof run.needsStatus !== "boolean" || run.server !== void 0 && !isDemoStatusResponse(run.server) || run.receipt !== void 0 && (!Number.isSafeInteger(run.receipt.revision) || run.receipt.revision < 0 || !/^[a-f0-9]{64}$/u.test(run.receipt.appliedDigest)) || typeof run.terminal !== "boolean" || !Array.isArray(run.launcher) || run.launcher.length !== 2 || run.launcher.some((value) => typeof value !== "string" || !value.startsWith("/")) || run.agent !== void 0 && !["claude_code", "codex", "cursor", "hermes"].includes(run.agent) || run.welcomeRepo !== void 0 && (typeof run.welcomeRepo !== "string" || !run.welcomeRepo.startsWith("/"))) {
23081
23081
  throw new Error("invalid demo run state");
23082
23082
  }
23083
23083
  return run;
@@ -23225,26 +23225,87 @@ function observeDemoInvocation(envelope, agent, checkExclusion = true) {
23225
23225
  }
23226
23226
 
23227
23227
  // src/lib/activation.ts
23228
- import { execFileSync as execFileSync2 } from "child_process";
23228
+ import { execFileSync as execFileSync3 } from "child_process";
23229
23229
  import { existsSync as existsSync8, readFileSync as readFileSync7 } from "fs";
23230
23230
  import { homedir as homedir2 } from "os";
23231
23231
  import { join as join9 } from "path";
23232
23232
 
23233
- // src/lib/git.ts
23233
+ // src/lib/demo-pause.ts
23234
23234
  import { execFileSync } from "child_process";
23235
+ var DEMO_PAUSE_MS = 30 * 6e4;
23236
+ var PAUSE_KEY = "prim.demoPause";
23237
+ var GIT_TIMEOUT_MS = 1e3;
23238
+ function git(cwd, args) {
23239
+ try {
23240
+ return execFileSync("git", args, {
23241
+ cwd,
23242
+ encoding: "utf-8",
23243
+ stdio: ["ignore", "pipe", "ignore"],
23244
+ timeout: GIT_TIMEOUT_MS
23245
+ });
23246
+ } catch {
23247
+ return void 0;
23248
+ }
23249
+ }
23250
+ function setLocal(cwd, key, value) {
23251
+ try {
23252
+ execFileSync(
23253
+ "git",
23254
+ value === null ? ["config", "--local", "--unset", key] : ["config", "--local", key, value],
23255
+ { cwd, stdio: ["ignore", "ignore", "pipe"], timeout: GIT_TIMEOUT_MS }
23256
+ );
23257
+ } catch (error) {
23258
+ if (value !== null || error.status !== 5) throw error;
23259
+ }
23260
+ }
23261
+ function parsePause(value) {
23262
+ const [runId = "", until, previous, state] = value.trim().split(" ");
23263
+ const flag = previous === "true" || previous === "false" ? previous : "unset";
23264
+ return { runId, until: Number(until) || 0, previous: flag, ending: state !== "active" };
23265
+ }
23266
+ function readCaptureConfig(cwd) {
23267
+ let active;
23268
+ let pause;
23269
+ const out = git(cwd, ["config", "--get-regexp", "^prim\\.(active|demopause)$"]) ?? "";
23270
+ for (const line of out.split("\n")) {
23271
+ const space3 = line.indexOf(" ");
23272
+ const key = line.slice(0, space3).toLowerCase();
23273
+ const value = line.slice(space3 + 1);
23274
+ if (key === "prim.active") active = value === "true" || value === "false" ? value : void 0;
23275
+ if (key === "prim.demopause") pause = parsePause(value);
23276
+ }
23277
+ return { active, pause };
23278
+ }
23279
+ function resumeCapture(cwd, pause) {
23280
+ setLocal(cwd, "prim.active", pause.previous === "unset" ? null : pause.previous);
23281
+ setLocal(cwd, PAUSE_KEY, null);
23282
+ }
23283
+ function healDemoPause(cwd, pause, options = {}) {
23284
+ if (pause.until > (options.now ?? Date.now()) && !(pause.ending && options.userPrompt))
23285
+ return false;
23286
+ try {
23287
+ resumeCapture(cwd, pause);
23288
+ return true;
23289
+ } catch {
23290
+ return false;
23291
+ }
23292
+ }
23293
+
23294
+ // src/lib/git.ts
23295
+ import { execFileSync as execFileSync2 } from "child_process";
23235
23296
  import { createHash as createHash4 } from "crypto";
23236
23297
  import { lstatSync as lstatSync3, realpathSync as realpathSync2 } from "fs";
23237
23298
  import { basename, dirname as dirname6, isAbsolute as isAbsolute4, relative, resolve as resolve3, sep } from "path";
23238
- var GIT_TIMEOUT_MS = 1e3;
23299
+ var GIT_TIMEOUT_MS2 = 1e3;
23239
23300
  var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
23240
23301
  var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
23241
23302
  function gitToplevel(cwd) {
23242
23303
  try {
23243
- return execFileSync("git", ["rev-parse", "--show-toplevel"], {
23304
+ return execFileSync2("git", ["rev-parse", "--show-toplevel"], {
23244
23305
  cwd,
23245
23306
  encoding: "utf-8",
23246
23307
  stdio: ["ignore", "pipe", "ignore"],
23247
- timeout: GIT_TIMEOUT_MS
23308
+ timeout: GIT_TIMEOUT_MS2
23248
23309
  }).trim();
23249
23310
  } catch {
23250
23311
  return null;
@@ -23252,11 +23313,11 @@ function gitToplevel(cwd) {
23252
23313
  }
23253
23314
  function gitValue(cwd, args) {
23254
23315
  try {
23255
- const value = execFileSync("git", args, {
23316
+ const value = execFileSync2("git", args, {
23256
23317
  cwd,
23257
23318
  encoding: "utf-8",
23258
23319
  stdio: ["ignore", "pipe", "ignore"],
23259
- timeout: GIT_TIMEOUT_MS
23320
+ timeout: GIT_TIMEOUT_MS2
23260
23321
  }).trim();
23261
23322
  return value || void 0;
23262
23323
  } catch {
@@ -23448,17 +23509,17 @@ var PRIM_ACTIVE_KEY = "prim.active";
23448
23509
  var PRIM_REPO_SYNC_ID_KEY = "prim.repoSyncId";
23449
23510
  var PRIM_REPO_SYNC_REPOSITORY_KEY = "prim.repoSyncRepository";
23450
23511
  var PRIM_REPO_BINDING_STATE_KEY = "prim.repoBindingState";
23451
- var GIT_TIMEOUT_MS2 = 1e3;
23512
+ var GIT_TIMEOUT_MS3 = 1e3;
23452
23513
  var REPO_SYNC_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
23453
23514
  var PROJECT_INSTALL_FILES = [".claude/settings.json", ".codex/hooks.json", ".cursor/hooks.json"];
23454
23515
  var PRIM_HOOK_BINS = ["prim-hook", "prim-pre-tool-use", "prim-post-tool-use"];
23455
23516
  function repoActiveFlag(cwd, strict = false) {
23456
23517
  try {
23457
- const value = execFileSync2("git", ["config", "--get", PRIM_ACTIVE_KEY], {
23518
+ const value = execFileSync3("git", ["config", "--get", PRIM_ACTIVE_KEY], {
23458
23519
  cwd,
23459
23520
  encoding: "utf-8",
23460
23521
  stdio: ["ignore", "pipe", "ignore"],
23461
- timeout: GIT_TIMEOUT_MS2
23522
+ timeout: GIT_TIMEOUT_MS3
23462
23523
  }).trim();
23463
23524
  if (value === "true") return "true";
23464
23525
  if (value === "false") return "false";
@@ -23475,11 +23536,11 @@ function isValidRepoSyncId(value) {
23475
23536
  }
23476
23537
  function localGitConfigValue(cwd, key) {
23477
23538
  try {
23478
- const value = execFileSync2("git", ["config", "--local", "--get", key], {
23539
+ const value = execFileSync3("git", ["config", "--local", "--get", key], {
23479
23540
  cwd,
23480
23541
  encoding: "utf-8",
23481
23542
  stdio: ["ignore", "pipe", "ignore"],
23482
- timeout: GIT_TIMEOUT_MS2
23543
+ timeout: GIT_TIMEOUT_MS3
23483
23544
  }).trim();
23484
23545
  return value || void 0;
23485
23546
  } catch {
@@ -23487,10 +23548,10 @@ function localGitConfigValue(cwd, key) {
23487
23548
  }
23488
23549
  }
23489
23550
  function setLocalGitConfigValue(cwd, key, value) {
23490
- execFileSync2("git", ["config", "--local", key, value], {
23551
+ execFileSync3("git", ["config", "--local", key, value], {
23491
23552
  cwd,
23492
23553
  stdio: ["ignore", "ignore", "pipe"],
23493
- timeout: GIT_TIMEOUT_MS2
23554
+ timeout: GIT_TIMEOUT_MS3
23494
23555
  });
23495
23556
  }
23496
23557
  function repoSyncId(cwd) {
@@ -23523,8 +23584,9 @@ function hasProjectPrimInstall(cwd) {
23523
23584
  }
23524
23585
  return false;
23525
23586
  }
23526
- function isRepoActiveForCapture(cwd) {
23527
- const flag = repoActiveFlag(cwd);
23587
+ function isRepoActiveForCapture(cwd, options = {}) {
23588
+ let { active: flag, pause } = readCaptureConfig(cwd);
23589
+ if (pause && healDemoPause(cwd, pause, options)) flag = repoActiveFlag(cwd);
23528
23590
  if (flag === "true") return true;
23529
23591
  if (flag === "false") return false;
23530
23592
  return hasProjectPrimInstall(cwd);
@@ -24561,7 +24623,7 @@ function scheduleCollectScopeRefresh(cwd, collectScopeVersion, dependencies = de
24561
24623
  }
24562
24624
 
24563
24625
  // src/lib/workspace-id.ts
24564
- import { execFileSync as execFileSync3 } from "child_process";
24626
+ import { execFileSync as execFileSync4 } from "child_process";
24565
24627
  import { randomUUID as randomUUID3 } from "crypto";
24566
24628
  import {
24567
24629
  constants as constants3,
@@ -24607,7 +24669,7 @@ function resolveWorkspaceIdPath(cwd) {
24607
24669
  if (fromFilesystem) return { status: "resolved", path: fromFilesystem };
24608
24670
  }
24609
24671
  try {
24610
- const output = execFileSync3(
24672
+ const output = execFileSync4(
24611
24673
  "git",
24612
24674
  ["rev-parse", "--is-inside-work-tree", "--git-path", WORKSPACE_ID_RELATIVE_PATH],
24613
24675
  {
@@ -25565,7 +25627,7 @@ import { homedir as homedir4 } from "os";
25565
25627
  import { isAbsolute as isAbsolute6, join as join16 } from "path";
25566
25628
 
25567
25629
  // src/lib/preflight-host.ts
25568
- import { execFileSync as execFileSync4 } from "child_process";
25630
+ import { execFileSync as execFileSync5 } from "child_process";
25569
25631
 
25570
25632
  // src/commands/claude-install.ts
25571
25633
  import { existsSync as existsSync11, readFileSync as readFileSync12 } from "fs";