@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
@@ -16,7 +16,7 @@ import {
16
16
  syncDirectory,
17
17
  syncFile,
18
18
  withFileLockSync
19
- } from "./chunk-P2O7NLVN.js";
19
+ } from "./chunk-4GYJHN26.js";
20
20
 
21
21
  // src/commands/claude-install.ts
22
22
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  inspectHookRuntime
3
- } from "./chunk-MWNRXAEB.js";
3
+ } from "./chunk-AKGRY7OU.js";
4
4
  import {
5
5
  isDemoStatusResponse
6
- } from "./chunk-5BQ2NEMP.js";
6
+ } from "./chunk-6DEROXLM.js";
7
7
  import {
8
8
  atomicWriteFile,
9
9
  primConfigDirectory,
10
10
  withFileLock,
11
11
  withFileLockSync
12
- } from "./chunk-P2O7NLVN.js";
12
+ } from "./chunk-4GYJHN26.js";
13
13
 
14
14
  // src/hooks/pre-tool-use-scoring.ts
15
15
  import { isAbsolute, relative, sep } from "path";
@@ -1241,14 +1241,14 @@ function readRun(id) {
1241
1241
  "cleanup",
1242
1242
  "completed",
1243
1243
  "skipped"
1244
- ].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)) {
1244
+ ].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("/"))) {
1245
1245
  throw new Error("invalid demo run state");
1246
1246
  }
1247
1247
  return run;
1248
1248
  }
1249
1249
  var saveRun = (run) => saveDemoJson(runPath(run.id), run);
1250
1250
  var lockRun = (id, action) => withFileLockSync(`${runPath(id)}.lock`, () => action(readRun(id)), { timeoutMs: 500 });
1251
- function prepareRun(agent, terminal = false) {
1251
+ function prepareRun(agent, terminal = false, welcomeRepo) {
1252
1252
  const run = {
1253
1253
  version: 2,
1254
1254
  id: randomUUID(),
@@ -1256,7 +1256,8 @@ function prepareRun(agent, terminal = false) {
1256
1256
  terminal,
1257
1257
  agent,
1258
1258
  preparationKey: preparationKey(agent),
1259
- launcher: [process.execPath, resolve2(process.argv[1])]
1259
+ launcher: [process.execPath, resolve2(process.argv[1])],
1260
+ ...welcomeRepo ? { welcomeRepo } : {}
1260
1261
  };
1261
1262
  saveRun(run);
1262
1263
  return run;
@@ -1303,10 +1304,13 @@ function onboardingFinished() {
1303
1304
  function finishOnboarding(outcome) {
1304
1305
  saveDemoJson(join(demoDirectory(), "onboarding.json"), { outcome });
1305
1306
  }
1306
- function pendingRuns() {
1307
+ function runIds() {
1307
1308
  const path = join(demoDirectory(), "runs");
1308
1309
  if (!existsSync(path)) return [];
1309
- return readdirSync(path).filter((name) => name.endsWith(".json") && RUN_ID.test(name.slice(0, -5))).map((name) => name.slice(0, -5)).filter((id) => !["completed", "skipped"].includes(readRun(id).stage));
1310
+ return readdirSync(path).filter((name) => name.endsWith(".json") && RUN_ID.test(name.slice(0, -5))).map((name) => name.slice(0, -5));
1311
+ }
1312
+ function pendingRuns() {
1313
+ return runIds().filter((id) => !["completed", "skipped"].includes(readRun(id).stage));
1310
1314
  }
1311
1315
  function sessionKey(agent, session) {
1312
1316
  return createHash("sha256").update(`${agent}\0${session}`).digest("hex");
@@ -1419,6 +1423,7 @@ export {
1419
1423
  demoteForMode,
1420
1424
  analyzeShellTargets,
1421
1425
  RUN_ID,
1426
+ demoDirectory,
1422
1427
  runPath,
1423
1428
  readDemoJson,
1424
1429
  saveDemoJson,
@@ -1433,6 +1438,7 @@ export {
1433
1438
  demoResumeCommand,
1434
1439
  onboardingFinished,
1435
1440
  finishOnboarding,
1441
+ runIds,
1436
1442
  pendingRuns,
1437
1443
  sessionKey,
1438
1444
  exclusionPath,
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  daemonRequest
3
- } from "./chunk-SLDZJD6Q.js";
3
+ } from "./chunk-NMZSCSMY.js";
4
4
  import {
5
5
  getClient,
6
6
  getSiteUrl,
7
7
  terminalSafeLine
8
- } from "./chunk-U67RBNIZ.js";
8
+ } from "./chunk-S3ZIMGXV.js";
9
9
  import {
10
10
  canonicalGitRoot,
11
11
  canonicalRepositoryPath,
12
12
  currentBranch,
13
13
  repoSyncId
14
- } from "./chunk-P2O7NLVN.js";
14
+ } from "./chunk-4GYJHN26.js";
15
15
 
16
16
  // src/daemon/proxy.ts
17
17
  var DAEMON_HTTP_TIMEOUT_MS = 1e4;
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-EZXEWFDG.js";
4
4
  import {
5
5
  scrubEnvironmentPaths
6
- } from "./chunk-NQFRQ56V.js";
6
+ } from "./chunk-2PFJJO2M.js";
7
7
  import {
8
8
  isValidRepoSyncId
9
- } from "./chunk-P2O7NLVN.js";
9
+ } from "./chunk-4GYJHN26.js";
10
10
 
11
11
  // src/hooks/prim-hook-core.ts
12
12
  import { createHash, randomUUID } from "crypto";
@@ -2,10 +2,10 @@ import {
2
2
  cursorHooksPath,
3
3
  hasExactCursorHandler,
4
4
  readCursorHooks
5
- } from "./chunk-MWNRXAEB.js";
5
+ } from "./chunk-AKGRY7OU.js";
6
6
  import {
7
7
  resolveRepositoryContext
8
- } from "./chunk-P2O7NLVN.js";
8
+ } from "./chunk-4GYJHN26.js";
9
9
 
10
10
  // src/hooks/cursor-coexistence.ts
11
11
  var CURSOR_EVENTS = /* @__PURE__ */ new Set([
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  boundedHealthError
3
- } from "./chunk-5BQ2NEMP.js";
3
+ } from "./chunk-6DEROXLM.js";
4
4
  import {
5
5
  stripControlChars
6
- } from "./chunk-U67RBNIZ.js";
6
+ } from "./chunk-S3ZIMGXV.js";
7
7
 
8
8
  // src/lib/delivery-backlog.ts
9
9
  var MS_PER_SECOND = 1e3;
@@ -3,7 +3,7 @@ import {
3
3
  isTerminalSafeText,
4
4
  terminalSafeLine,
5
5
  terminalSafeText
6
- } from "./chunk-U67RBNIZ.js";
6
+ } from "./chunk-S3ZIMGXV.js";
7
7
 
8
8
  // src/decisions/feedback.ts
9
9
  var FEEDBACK_PROTOCOL_VERSION = 2;
@@ -1,23 +1,23 @@
1
1
  import {
2
2
  analyzeShellTargets,
3
3
  extractFileTargets
4
- } from "./chunk-L52OD62C.js";
4
+ } from "./chunk-BHT6X3T5.js";
5
5
  import {
6
6
  DEFAULT_RULES,
7
7
  scrub
8
- } from "./chunk-NQFRQ56V.js";
8
+ } from "./chunk-2PFJJO2M.js";
9
9
  import {
10
10
  boundedHealthError,
11
11
  isPreflightResponseV4
12
- } from "./chunk-5BQ2NEMP.js";
12
+ } from "./chunk-6DEROXLM.js";
13
13
  import {
14
14
  getClient,
15
15
  terminalSafeLine
16
- } from "./chunk-U67RBNIZ.js";
16
+ } from "./chunk-S3ZIMGXV.js";
17
17
  import {
18
18
  canonicalGitRoot,
19
19
  canonicalRepositoryPath
20
- } from "./chunk-P2O7NLVN.js";
20
+ } from "./chunk-4GYJHN26.js";
21
21
 
22
22
  // src/hooks/approval-copy.ts
23
23
  var MAX_EXCERPT_CHARS = 80;
@@ -4,20 +4,20 @@ import {
4
4
  import {
5
5
  analyzeShellTargets,
6
6
  extractFileTargets
7
- } from "./chunk-L52OD62C.js";
7
+ } from "./chunk-BHT6X3T5.js";
8
8
  import {
9
9
  scrubEnvironmentPaths
10
- } from "./chunk-NQFRQ56V.js";
10
+ } from "./chunk-2PFJJO2M.js";
11
11
  import {
12
12
  cachedCollectScopeAdmits
13
- } from "./chunk-5BQ2NEMP.js";
13
+ } from "./chunk-6DEROXLM.js";
14
14
  import {
15
15
  canonicalRepositoryPath,
16
16
  currentBranch,
17
17
  isRepoActiveForCapture,
18
18
  relatedWorktreeTarget,
19
19
  repoSyncId
20
- } from "./chunk-P2O7NLVN.js";
20
+ } from "./chunk-4GYJHN26.js";
21
21
 
22
22
  // src/hooks/file-refs.ts
23
23
  var MAX_PREFLIGHT_FILE_TARGETS = 25;
@@ -11,10 +11,10 @@ import {
11
11
  saveRun,
12
12
  sessionExcluded,
13
13
  sessionKey
14
- } from "./chunk-L52OD62C.js";
14
+ } from "./chunk-BHT6X3T5.js";
15
15
  import {
16
16
  packageVersion
17
- } from "./chunk-P2O7NLVN.js";
17
+ } from "./chunk-4GYJHN26.js";
18
18
 
19
19
  // src/demo/isolation.ts
20
20
  import { existsSync } from "fs";
@@ -2,7 +2,7 @@ import {
2
2
  decodeJwtPayload,
3
3
  primConfigDirectory,
4
4
  resolveAuthCredential
5
- } from "./chunk-P2O7NLVN.js";
5
+ } from "./chunk-4GYJHN26.js";
6
6
 
7
7
  // src/daemon/principal.ts
8
8
  import { createHash } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  scheduleCollectScopeRefresh
3
- } from "./chunk-5BQ2NEMP.js";
3
+ } from "./chunk-6DEROXLM.js";
4
4
 
5
5
  // src/ingest-response.ts
6
6
  var IngestAcknowledgementError = class extends Error {
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  getSiteUrl
3
- } from "./chunk-U67RBNIZ.js";
3
+ } from "./chunk-S3ZIMGXV.js";
4
4
  import {
5
5
  atomicWriteFile,
6
6
  ensureDurableDirectory,
7
7
  jwtOrganizationId,
8
8
  primConfigDirectory,
9
9
  resolveAuthCredential
10
- } from "./chunk-P2O7NLVN.js";
10
+ } from "./chunk-4GYJHN26.js";
11
11
 
12
12
  // src/journal.ts
13
13
  import {
@@ -23,7 +23,7 @@ import {
23
23
  syncDirectory,
24
24
  withFileLock,
25
25
  workosConnectTokenEndpoint
26
- } from "./chunk-P2O7NLVN.js";
26
+ } from "./chunk-4GYJHN26.js";
27
27
 
28
28
  // src/decisions/identity.ts
29
29
  var PUBLIC_ID = /^dec_[0-9a-f]{8}$/u;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  atomicWriteFile,
3
3
  repoActiveFlag
4
- } from "./chunk-P2O7NLVN.js";
4
+ } from "./chunk-4GYJHN26.js";
5
5
 
6
6
  // src/lib/commit-heartbeat.ts
7
7
  import { execFileSync } from "child_process";
@@ -23775,26 +23775,87 @@ function validate79(data, { instancePath = "", parentData, parentDataProperty, r
23775
23775
  validate79.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
23776
23776
 
23777
23777
  // src/lib/activation.ts
23778
- import { execFileSync as execFileSync2 } from "child_process";
23778
+ import { execFileSync as execFileSync3 } from "child_process";
23779
23779
  import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
23780
23780
  import { homedir as homedir2 } from "os";
23781
23781
  import { join as join9 } from "path";
23782
23782
 
23783
- // src/lib/git.ts
23783
+ // src/lib/demo-pause.ts
23784
23784
  import { execFileSync } from "child_process";
23785
+ var DEMO_PAUSE_MS = 30 * 6e4;
23786
+ var PAUSE_KEY = "prim.demoPause";
23787
+ var GIT_TIMEOUT_MS = 1e3;
23788
+ function git(cwd, args) {
23789
+ try {
23790
+ return execFileSync("git", args, {
23791
+ cwd,
23792
+ encoding: "utf-8",
23793
+ stdio: ["ignore", "pipe", "ignore"],
23794
+ timeout: GIT_TIMEOUT_MS
23795
+ });
23796
+ } catch {
23797
+ return void 0;
23798
+ }
23799
+ }
23800
+ function setLocal(cwd, key, value) {
23801
+ try {
23802
+ execFileSync(
23803
+ "git",
23804
+ value === null ? ["config", "--local", "--unset", key] : ["config", "--local", key, value],
23805
+ { cwd, stdio: ["ignore", "ignore", "pipe"], timeout: GIT_TIMEOUT_MS }
23806
+ );
23807
+ } catch (error) {
23808
+ if (value !== null || error.status !== 5) throw error;
23809
+ }
23810
+ }
23811
+ function parsePause(value) {
23812
+ const [runId = "", until, previous, state] = value.trim().split(" ");
23813
+ const flag = previous === "true" || previous === "false" ? previous : "unset";
23814
+ return { runId, until: Number(until) || 0, previous: flag, ending: state !== "active" };
23815
+ }
23816
+ function readCaptureConfig(cwd) {
23817
+ let active;
23818
+ let pause;
23819
+ const out = git(cwd, ["config", "--get-regexp", "^prim\\.(active|demopause)$"]) ?? "";
23820
+ for (const line of out.split("\n")) {
23821
+ const space = line.indexOf(" ");
23822
+ const key = line.slice(0, space).toLowerCase();
23823
+ const value = line.slice(space + 1);
23824
+ if (key === "prim.active") active = value === "true" || value === "false" ? value : void 0;
23825
+ if (key === "prim.demopause") pause = parsePause(value);
23826
+ }
23827
+ return { active, pause };
23828
+ }
23829
+ function resumeCapture(cwd, pause) {
23830
+ setLocal(cwd, "prim.active", pause.previous === "unset" ? null : pause.previous);
23831
+ setLocal(cwd, PAUSE_KEY, null);
23832
+ }
23833
+ function healDemoPause(cwd, pause, options = {}) {
23834
+ if (pause.until > (options.now ?? Date.now()) && !(pause.ending && options.userPrompt))
23835
+ return false;
23836
+ try {
23837
+ resumeCapture(cwd, pause);
23838
+ return true;
23839
+ } catch {
23840
+ return false;
23841
+ }
23842
+ }
23843
+
23844
+ // src/lib/git.ts
23845
+ import { execFileSync as execFileSync2 } from "child_process";
23785
23846
  import { createHash as createHash5 } from "crypto";
23786
23847
  import { lstatSync as lstatSync2, realpathSync } from "fs";
23787
23848
  import { basename as basename2, dirname as dirname7, isAbsolute as isAbsolute3, relative, resolve as resolve2, sep } from "path";
23788
- var GIT_TIMEOUT_MS = 1e3;
23849
+ var GIT_TIMEOUT_MS2 = 1e3;
23789
23850
  var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
23790
23851
  var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
23791
23852
  function gitToplevel(cwd) {
23792
23853
  try {
23793
- return execFileSync("git", ["rev-parse", "--show-toplevel"], {
23854
+ return execFileSync2("git", ["rev-parse", "--show-toplevel"], {
23794
23855
  cwd,
23795
23856
  encoding: "utf-8",
23796
23857
  stdio: ["ignore", "pipe", "ignore"],
23797
- timeout: GIT_TIMEOUT_MS
23858
+ timeout: GIT_TIMEOUT_MS2
23798
23859
  }).trim();
23799
23860
  } catch {
23800
23861
  return null;
@@ -23802,11 +23863,11 @@ function gitToplevel(cwd) {
23802
23863
  }
23803
23864
  function gitValue(cwd, args) {
23804
23865
  try {
23805
- const value = execFileSync("git", args, {
23866
+ const value = execFileSync2("git", args, {
23806
23867
  cwd,
23807
23868
  encoding: "utf-8",
23808
23869
  stdio: ["ignore", "pipe", "ignore"],
23809
- timeout: GIT_TIMEOUT_MS
23870
+ timeout: GIT_TIMEOUT_MS2
23810
23871
  }).trim();
23811
23872
  return value || void 0;
23812
23873
  } catch {
@@ -23833,17 +23894,17 @@ var PRIM_ACTIVE_KEY = "prim.active";
23833
23894
  var PRIM_REPO_SYNC_ID_KEY = "prim.repoSyncId";
23834
23895
  var PRIM_REPO_SYNC_REPOSITORY_KEY = "prim.repoSyncRepository";
23835
23896
  var PRIM_REPO_BINDING_STATE_KEY = "prim.repoBindingState";
23836
- var GIT_TIMEOUT_MS2 = 1e3;
23897
+ var GIT_TIMEOUT_MS3 = 1e3;
23837
23898
  var REPO_SYNC_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
23838
23899
  var PROJECT_INSTALL_FILES = [".claude/settings.json", ".codex/hooks.json", ".cursor/hooks.json"];
23839
23900
  var PRIM_HOOK_BINS = ["prim-hook", "prim-pre-tool-use", "prim-post-tool-use"];
23840
23901
  function repoActiveFlag(cwd, strict = false) {
23841
23902
  try {
23842
- const value = execFileSync2("git", ["config", "--get", PRIM_ACTIVE_KEY], {
23903
+ const value = execFileSync3("git", ["config", "--get", PRIM_ACTIVE_KEY], {
23843
23904
  cwd,
23844
23905
  encoding: "utf-8",
23845
23906
  stdio: ["ignore", "pipe", "ignore"],
23846
- timeout: GIT_TIMEOUT_MS2
23907
+ timeout: GIT_TIMEOUT_MS3
23847
23908
  }).trim();
23848
23909
  if (value === "true") return "true";
23849
23910
  if (value === "false") return "false";
@@ -23860,11 +23921,11 @@ function isValidRepoSyncId(value) {
23860
23921
  }
23861
23922
  function localGitConfigValue(cwd, key) {
23862
23923
  try {
23863
- const value = execFileSync2("git", ["config", "--local", "--get", key], {
23924
+ const value = execFileSync3("git", ["config", "--local", "--get", key], {
23864
23925
  cwd,
23865
23926
  encoding: "utf-8",
23866
23927
  stdio: ["ignore", "pipe", "ignore"],
23867
- timeout: GIT_TIMEOUT_MS2
23928
+ timeout: GIT_TIMEOUT_MS3
23868
23929
  }).trim();
23869
23930
  return value || void 0;
23870
23931
  } catch {
@@ -23872,10 +23933,10 @@ function localGitConfigValue(cwd, key) {
23872
23933
  }
23873
23934
  }
23874
23935
  function setLocalGitConfigValue(cwd, key, value) {
23875
- execFileSync2("git", ["config", "--local", key, value], {
23936
+ execFileSync3("git", ["config", "--local", key, value], {
23876
23937
  cwd,
23877
23938
  stdio: ["ignore", "ignore", "pipe"],
23878
- timeout: GIT_TIMEOUT_MS2
23939
+ timeout: GIT_TIMEOUT_MS3
23879
23940
  });
23880
23941
  }
23881
23942
  function repoSyncId(cwd) {
@@ -23908,8 +23969,9 @@ function hasProjectPrimInstall(cwd) {
23908
23969
  }
23909
23970
  return false;
23910
23971
  }
23911
- function isRepoActiveForCapture(cwd) {
23912
- const flag = repoActiveFlag(cwd);
23972
+ function isRepoActiveForCapture(cwd, options = {}) {
23973
+ let { active: flag, pause } = readCaptureConfig(cwd);
23974
+ if (pause && healDemoPause(cwd, pause, options)) flag = repoActiveFlag(cwd);
23913
23975
  if (flag === "true") return true;
23914
23976
  if (flag === "false") return false;
23915
23977
  return hasProjectPrimInstall(cwd);
@@ -23776,26 +23776,87 @@ function validate79(data, { instancePath = "", parentData, parentDataProperty, r
23776
23776
  validate79.evaluated = { "props": true, "dynamicProps": false, "dynamicItems": false };
23777
23777
 
23778
23778
  // src/lib/activation.ts
23779
- import { execFileSync as execFileSync2 } from "child_process";
23779
+ import { execFileSync as execFileSync3 } from "child_process";
23780
23780
  import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
23781
23781
  import { homedir as homedir2 } from "os";
23782
23782
  import { join as join9 } from "path";
23783
23783
 
23784
- // src/lib/git.ts
23784
+ // src/lib/demo-pause.ts
23785
23785
  import { execFileSync } from "child_process";
23786
+ var DEMO_PAUSE_MS = 30 * 6e4;
23787
+ var PAUSE_KEY = "prim.demoPause";
23788
+ var GIT_TIMEOUT_MS = 1e3;
23789
+ function git(cwd, args) {
23790
+ try {
23791
+ return execFileSync("git", args, {
23792
+ cwd,
23793
+ encoding: "utf-8",
23794
+ stdio: ["ignore", "pipe", "ignore"],
23795
+ timeout: GIT_TIMEOUT_MS
23796
+ });
23797
+ } catch {
23798
+ return void 0;
23799
+ }
23800
+ }
23801
+ function setLocal(cwd, key, value) {
23802
+ try {
23803
+ execFileSync(
23804
+ "git",
23805
+ value === null ? ["config", "--local", "--unset", key] : ["config", "--local", key, value],
23806
+ { cwd, stdio: ["ignore", "ignore", "pipe"], timeout: GIT_TIMEOUT_MS }
23807
+ );
23808
+ } catch (error) {
23809
+ if (value !== null || error.status !== 5) throw error;
23810
+ }
23811
+ }
23812
+ function parsePause(value) {
23813
+ const [runId = "", until, previous, state] = value.trim().split(" ");
23814
+ const flag = previous === "true" || previous === "false" ? previous : "unset";
23815
+ return { runId, until: Number(until) || 0, previous: flag, ending: state !== "active" };
23816
+ }
23817
+ function readCaptureConfig(cwd) {
23818
+ let active;
23819
+ let pause;
23820
+ const out = git(cwd, ["config", "--get-regexp", "^prim\\.(active|demopause)$"]) ?? "";
23821
+ for (const line of out.split("\n")) {
23822
+ const space = line.indexOf(" ");
23823
+ const key = line.slice(0, space).toLowerCase();
23824
+ const value = line.slice(space + 1);
23825
+ if (key === "prim.active") active = value === "true" || value === "false" ? value : void 0;
23826
+ if (key === "prim.demopause") pause = parsePause(value);
23827
+ }
23828
+ return { active, pause };
23829
+ }
23830
+ function resumeCapture(cwd, pause) {
23831
+ setLocal(cwd, "prim.active", pause.previous === "unset" ? null : pause.previous);
23832
+ setLocal(cwd, PAUSE_KEY, null);
23833
+ }
23834
+ function healDemoPause(cwd, pause, options = {}) {
23835
+ if (pause.until > (options.now ?? Date.now()) && !(pause.ending && options.userPrompt))
23836
+ return false;
23837
+ try {
23838
+ resumeCapture(cwd, pause);
23839
+ return true;
23840
+ } catch {
23841
+ return false;
23842
+ }
23843
+ }
23844
+
23845
+ // src/lib/git.ts
23846
+ import { execFileSync as execFileSync2 } from "child_process";
23786
23847
  import { createHash as createHash5 } from "crypto";
23787
23848
  import { lstatSync as lstatSync2, realpathSync } from "fs";
23788
23849
  import { basename as basename2, dirname as dirname7, isAbsolute as isAbsolute3, relative, resolve as resolve2, sep } from "path";
23789
- var GIT_TIMEOUT_MS = 1e3;
23850
+ var GIT_TIMEOUT_MS2 = 1e3;
23790
23851
  var GITHUB_OWNER_PATTERN = /^(?![A-Za-z0-9-]*--)[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u;
23791
23852
  var GITHUB_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]{1,100}$/u;
23792
23853
  function gitToplevel(cwd) {
23793
23854
  try {
23794
- return execFileSync("git", ["rev-parse", "--show-toplevel"], {
23855
+ return execFileSync2("git", ["rev-parse", "--show-toplevel"], {
23795
23856
  cwd,
23796
23857
  encoding: "utf-8",
23797
23858
  stdio: ["ignore", "pipe", "ignore"],
23798
- timeout: GIT_TIMEOUT_MS
23859
+ timeout: GIT_TIMEOUT_MS2
23799
23860
  }).trim();
23800
23861
  } catch {
23801
23862
  return null;
@@ -23803,11 +23864,11 @@ function gitToplevel(cwd) {
23803
23864
  }
23804
23865
  function gitValue(cwd, args) {
23805
23866
  try {
23806
- const value = execFileSync("git", args, {
23867
+ const value = execFileSync2("git", args, {
23807
23868
  cwd,
23808
23869
  encoding: "utf-8",
23809
23870
  stdio: ["ignore", "pipe", "ignore"],
23810
- timeout: GIT_TIMEOUT_MS
23871
+ timeout: GIT_TIMEOUT_MS2
23811
23872
  }).trim();
23812
23873
  return value || void 0;
23813
23874
  } catch {
@@ -23834,17 +23895,17 @@ var PRIM_ACTIVE_KEY = "prim.active";
23834
23895
  var PRIM_REPO_SYNC_ID_KEY = "prim.repoSyncId";
23835
23896
  var PRIM_REPO_SYNC_REPOSITORY_KEY = "prim.repoSyncRepository";
23836
23897
  var PRIM_REPO_BINDING_STATE_KEY = "prim.repoBindingState";
23837
- var GIT_TIMEOUT_MS2 = 1e3;
23898
+ var GIT_TIMEOUT_MS3 = 1e3;
23838
23899
  var REPO_SYNC_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
23839
23900
  var PROJECT_INSTALL_FILES = [".claude/settings.json", ".codex/hooks.json", ".cursor/hooks.json"];
23840
23901
  var PRIM_HOOK_BINS = ["prim-hook", "prim-pre-tool-use", "prim-post-tool-use"];
23841
23902
  function repoActiveFlag(cwd, strict = false) {
23842
23903
  try {
23843
- const value = execFileSync2("git", ["config", "--get", PRIM_ACTIVE_KEY], {
23904
+ const value = execFileSync3("git", ["config", "--get", PRIM_ACTIVE_KEY], {
23844
23905
  cwd,
23845
23906
  encoding: "utf-8",
23846
23907
  stdio: ["ignore", "pipe", "ignore"],
23847
- timeout: GIT_TIMEOUT_MS2
23908
+ timeout: GIT_TIMEOUT_MS3
23848
23909
  }).trim();
23849
23910
  if (value === "true") return "true";
23850
23911
  if (value === "false") return "false";
@@ -23861,11 +23922,11 @@ function isValidRepoSyncId(value) {
23861
23922
  }
23862
23923
  function localGitConfigValue(cwd, key) {
23863
23924
  try {
23864
- const value = execFileSync2("git", ["config", "--local", "--get", key], {
23925
+ const value = execFileSync3("git", ["config", "--local", "--get", key], {
23865
23926
  cwd,
23866
23927
  encoding: "utf-8",
23867
23928
  stdio: ["ignore", "pipe", "ignore"],
23868
- timeout: GIT_TIMEOUT_MS2
23929
+ timeout: GIT_TIMEOUT_MS3
23869
23930
  }).trim();
23870
23931
  return value || void 0;
23871
23932
  } catch {
@@ -23873,10 +23934,10 @@ function localGitConfigValue(cwd, key) {
23873
23934
  }
23874
23935
  }
23875
23936
  function setLocalGitConfigValue(cwd, key, value) {
23876
- execFileSync2("git", ["config", "--local", key, value], {
23937
+ execFileSync3("git", ["config", "--local", key, value], {
23877
23938
  cwd,
23878
23939
  stdio: ["ignore", "ignore", "pipe"],
23879
- timeout: GIT_TIMEOUT_MS2
23940
+ timeout: GIT_TIMEOUT_MS3
23880
23941
  });
23881
23942
  }
23882
23943
  function repoSyncId(cwd) {
@@ -23909,8 +23970,9 @@ function hasProjectPrimInstall(cwd) {
23909
23970
  }
23910
23971
  return false;
23911
23972
  }
23912
- function isRepoActiveForCapture(cwd) {
23913
- const flag = repoActiveFlag(cwd);
23973
+ function isRepoActiveForCapture(cwd, options = {}) {
23974
+ let { active: flag, pause } = readCaptureConfig(cwd);
23975
+ if (pause && healDemoPause(cwd, pause, options)) flag = repoActiveFlag(cwd);
23914
23976
  if (flag === "true") return true;
23915
23977
  if (flag === "false") return false;
23916
23978
  return hasProjectPrimInstall(cwd);