@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
@@ -2081,24 +2081,24 @@ function getClient() {
2081
2081
  }
2082
2082
 
2083
2083
  // src/commands/claude-plugin.ts
2084
- import { createHash as createHash6 } from "crypto";
2084
+ import { createHash as createHash7 } from "crypto";
2085
2085
  import {
2086
2086
  constants as constants4,
2087
2087
  closeSync as closeSync3,
2088
- existsSync as existsSync8,
2088
+ existsSync as existsSync9,
2089
2089
  fstatSync as fstatSync2,
2090
- lstatSync as lstatSync5,
2090
+ lstatSync as lstatSync6,
2091
2091
  mkdirSync as mkdirSync5,
2092
2092
  openSync as openSync3,
2093
- readFileSync as readFileSync10,
2093
+ readFileSync as readFileSync11,
2094
2094
  readSync as readSync2,
2095
- readdirSync as readdirSync3,
2095
+ readdirSync as readdirSync4,
2096
2096
  realpathSync as realpathSync3,
2097
2097
  rmSync as rmSync5,
2098
- rmdirSync as rmdirSync2
2098
+ rmdirSync as rmdirSync3
2099
2099
  } from "fs";
2100
- import { homedir as homedir5 } from "os";
2101
- import { dirname as dirname9, isAbsolute as isAbsolute6, join as join12, relative as relative2, resolve as resolve5, sep as sep2 } from "path";
2100
+ import { homedir as homedir6 } from "os";
2101
+ import { dirname as dirname10, isAbsolute as isAbsolute6, join as join13, relative as relative2, resolve as resolve5, sep as sep2 } from "path";
2102
2102
  import { fileURLToPath as fileURLToPath3 } from "url";
2103
2103
 
2104
2104
  // node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/identity.js
@@ -8369,22 +8369,22 @@ function parse(src, reviver, options) {
8369
8369
  }
8370
8370
 
8371
8371
  // src/commands/skill.ts
8372
- import { createHash as createHash5 } from "crypto";
8372
+ import { createHash as createHash6 } from "crypto";
8373
8373
  import {
8374
8374
  constants as constants3,
8375
8375
  closeSync as closeSync2,
8376
- existsSync as existsSync7,
8376
+ existsSync as existsSync8,
8377
8377
  fstatSync,
8378
- lstatSync as lstatSync4,
8378
+ lstatSync as lstatSync5,
8379
8379
  openSync as openSync2,
8380
- readFileSync as readFileSync9,
8380
+ readFileSync as readFileSync10,
8381
8381
  readSync,
8382
- readdirSync as readdirSync2,
8383
- rmdirSync,
8384
- unlinkSync
8382
+ readdirSync as readdirSync3,
8383
+ rmdirSync as rmdirSync2,
8384
+ unlinkSync as unlinkSync2
8385
8385
  } from "fs";
8386
- import { homedir as homedir4 } from "os";
8387
- import { dirname as dirname8, join as join11, resolve as resolve4 } from "path";
8386
+ import { homedir as homedir5 } from "os";
8387
+ import { dirname as dirname9, join as join12, resolve as resolve4 } from "path";
8388
8388
  import { fileURLToPath as fileURLToPath2 } from "url";
8389
8389
 
8390
8390
  // node_modules/.pnpm/diff@5.2.2/node_modules/diff/lib/index.mjs
@@ -8738,8 +8738,15 @@ arrayDiff.join = arrayDiff.removeEmpty = function(value) {
8738
8738
  return value;
8739
8739
  };
8740
8740
 
8741
+ // src/commands/welcome-skill.ts
8742
+ import { createHash as createHash5 } from "crypto";
8743
+ import { existsSync as existsSync7, lstatSync as lstatSync4, readFileSync as readFileSync9, readdirSync as readdirSync2, rmdirSync, unlinkSync } from "fs";
8744
+ import { homedir as homedir4 } from "os";
8745
+ import { dirname as dirname8, join as join11 } from "path";
8746
+ var WELCOME_SKILL_SOURCE = join11("skills", "prim-welcome", "SKILL.md");
8747
+
8741
8748
  // src/commands/skill.ts
8742
- var __dirname = dirname8(fileURLToPath2(import.meta.url));
8749
+ var __dirname = dirname9(fileURLToPath2(import.meta.url));
8743
8750
  var SKILL_BEGIN = "<!-- BEGIN PRIM SKILL v1 -->";
8744
8751
  var SKILL_END = "<!-- END PRIM SKILL v1 -->";
8745
8752
  var CODEX_GUIDANCE_LIMIT_BYTES = 1024 * 1024;
@@ -8748,7 +8755,7 @@ var SKILL_BEGIN_BUFFER = Buffer.from(SKILL_BEGIN);
8748
8755
  var SKILL_END_BUFFER = Buffer.from(SKILL_END);
8749
8756
  function readCodexGuidance(path) {
8750
8757
  try {
8751
- const entry = lstatSync4(path);
8758
+ const entry = lstatSync5(path);
8752
8759
  if (entry.isSymbolicLink() || !entry.isFile()) return null;
8753
8760
  const fd = openSync2(path, constants3.O_RDONLY | constants3.O_NOFOLLOW);
8754
8761
  try {
@@ -8771,10 +8778,10 @@ function readCodexGuidance(path) {
8771
8778
  }
8772
8779
  }
8773
8780
  function effectiveCodexGuidance(scope) {
8774
- const override = readCodexGuidance(join11(scope, "AGENTS.override.md"));
8781
+ const override = readCodexGuidance(join12(scope, "AGENTS.override.md"));
8775
8782
  if (override === null) return null;
8776
8783
  if (override !== void 0 && override.toString("utf8").trim().length > 0) return override;
8777
- const base = readCodexGuidance(join11(scope, "AGENTS.md"));
8784
+ const base = readCodexGuidance(join12(scope, "AGENTS.md"));
8778
8785
  return base ?? null;
8779
8786
  }
8780
8787
  function hasUsablePrimBlock(content, visibleBytes) {
@@ -8797,7 +8804,7 @@ function hasUsablePrimBlock(content, visibleBytes) {
8797
8804
  }
8798
8805
  function hasUsableCodexGuidance(projectRoot2) {
8799
8806
  try {
8800
- const codexHome = process.env.CODEX_HOME?.trim() ? resolve4(process.env.CODEX_HOME) : join11(homedir4(), ".codex");
8807
+ const codexHome = process.env.CODEX_HOME?.trim() ? resolve4(process.env.CODEX_HOME) : join12(homedir5(), ".codex");
8801
8808
  const scopes = [
8802
8809
  { path: codexHome, visibleBytes: CODEX_GUIDANCE_LIMIT_BYTES },
8803
8810
  { path: projectRoot2, visibleBytes: CODEX_DEFAULT_PROJECT_GUIDANCE_BYTES }
@@ -8813,23 +8820,23 @@ function hasUsableCodexGuidance(projectRoot2) {
8813
8820
  var CURSOR_SKILL_OWNER = "@primitive.ai/prim";
8814
8821
  var CURSOR_SKILL_MANIFEST = ".prim-owned.json";
8815
8822
  function sha256(content) {
8816
- return createHash5("sha256").update(content).digest("hex");
8823
+ return createHash6("sha256").update(content).digest("hex");
8817
8824
  }
8818
8825
  function cursorSkillDirectory(cwd, scope) {
8819
8826
  const base = scope === "user" ? cursorConfigDirectory() : gitToplevel(cwd) ?? cwd;
8820
- return join11(base, scope === "user" ? "skills" : ".cursor/skills", "prim");
8827
+ return join12(base, scope === "user" ? "skills" : ".cursor/skills", "prim");
8821
8828
  }
8822
8829
  function cursorSkillPaths(cwd, scope) {
8823
8830
  const directory = cursorSkillDirectory(cwd, scope);
8824
8831
  return {
8825
8832
  directory,
8826
- skill: join11(directory, "SKILL.md"),
8827
- manifest: join11(directory, CURSOR_SKILL_MANIFEST)
8833
+ skill: join12(directory, "SKILL.md"),
8834
+ manifest: join12(directory, CURSOR_SKILL_MANIFEST)
8828
8835
  };
8829
8836
  }
8830
8837
  function readCursorSkillManifest(path) {
8831
8838
  try {
8832
- const value = JSON.parse(readFileSync9(path, "utf8"));
8839
+ const value = JSON.parse(readFileSync10(path, "utf8"));
8833
8840
  if (!value || typeof value !== "object" || Array.isArray(value)) return;
8834
8841
  const record = value;
8835
8842
  if (record.version !== 1 || record.owner !== CURSOR_SKILL_OWNER || typeof record.contentSha256 !== "string" || !/^[0-9a-f]{64}$/u.test(record.contentSha256)) {
@@ -8843,7 +8850,7 @@ function readCursorSkillManifest(path) {
8843
8850
  function cursorSkillStatus(cwd, scope) {
8844
8851
  const paths = cursorSkillPaths(cwd, scope);
8845
8852
  const manifest = readCursorSkillManifest(paths.manifest);
8846
- const content = existsSync7(paths.skill) ? readFileSync9(paths.skill, "utf8") : void 0;
8853
+ const content = existsSync8(paths.skill) ? readFileSync10(paths.skill, "utf8") : void 0;
8847
8854
  const owned = manifest !== void 0;
8848
8855
  const installed = owned && content !== void 0 && sha256(content) === manifest.contentSha256;
8849
8856
  return {
@@ -8856,36 +8863,36 @@ function cursorSkillStatus(cwd, scope) {
8856
8863
  function hasUsableCursorSkill(projectRoot2) {
8857
8864
  return cursorSkillStatus(projectRoot2, "project").installed || cursorSkillStatus(projectRoot2, "user").installed;
8858
8865
  }
8859
- function loadSkill() {
8866
+ function loadSkill(file = "SKILL.md") {
8860
8867
  let dir = __dirname;
8861
- while (dir !== dirname8(dir)) {
8862
- const p = resolve4(dir, "SKILL.md");
8863
- if (existsSync7(p)) return readFileSync9(p, "utf-8");
8864
- dir = dirname8(dir);
8868
+ while (dir !== dirname9(dir)) {
8869
+ const p = resolve4(dir, file);
8870
+ if (existsSync8(p)) return readFileSync10(p, "utf-8");
8871
+ dir = dirname9(dir);
8865
8872
  }
8866
- throw new Error("SKILL.md not found in package");
8873
+ throw new Error(`${file} not found in package`);
8867
8874
  }
8868
8875
  function atomicWrite3(target, content) {
8869
- atomicWriteFile(target, content);
8876
+ atomicWriteFile(target, content, { ensureParent: true });
8870
8877
  }
8871
8878
 
8872
8879
  // src/commands/claude-plugin.ts
8873
- var __dirname2 = dirname9(fileURLToPath3(import.meta.url));
8880
+ var __dirname2 = dirname10(fileURLToPath3(import.meta.url));
8874
8881
  var PLUGIN_DESCRIPTION = "Primitive decision-graph guidance for the prim CLI \u2014 a model-invoked skill installed by prim skill install.";
8875
8882
  var MAX_MANIFEST_BYTES2 = 64 * 1024;
8876
8883
  var MAX_SKILL_BYTES = 1024 * 1024;
8877
8884
  var REFRESH_LOCK_TIMEOUT_MS = 150;
8878
8885
  var REFRESH_LOCK_POLL_MS = 10;
8879
8886
  function pluginDirFor(cwd, scope) {
8880
- const base = scope === "user" ? join12(homedir5(), ".claude") : join12(gitToplevel(cwd) ?? cwd, ".claude");
8881
- return join12(base, "skills", "prim");
8887
+ const base = scope === "user" ? join13(homedir6(), ".claude") : join13(gitToplevel(cwd) ?? cwd, ".claude");
8888
+ return join13(base, "skills", "prim");
8882
8889
  }
8883
8890
  function packageVersion2() {
8884
8891
  let dir = __dirname2;
8885
- while (dir !== dirname9(dir)) {
8892
+ while (dir !== dirname10(dir)) {
8886
8893
  const p = resolve5(dir, "package.json");
8887
- if (existsSync8(p)) return JSON.parse(readFileSync10(p, "utf-8")).version;
8888
- dir = dirname9(dir);
8894
+ if (existsSync9(p)) return JSON.parse(readFileSync11(p, "utf-8")).version;
8895
+ dir = dirname10(dir);
8889
8896
  }
8890
8897
  return "0.0.0";
8891
8898
  }
@@ -8900,8 +8907,8 @@ function renderClaudePlugin() {
8900
8907
  }
8901
8908
  function pluginPaths(dir) {
8902
8909
  return {
8903
- manifestPath: join12(dir, ".claude-plugin", "plugin.json"),
8904
- skillPath: join12(dir, "SKILL.md")
8910
+ manifestPath: join13(dir, ".claude-plugin", "plugin.json"),
8911
+ skillPath: join13(dir, "SKILL.md")
8905
8912
  };
8906
8913
  }
8907
8914
  function pathIsInside(root, path) {
@@ -8911,7 +8918,7 @@ function pathIsInside(root, path) {
8911
8918
  function managedPathsAreSafe(paths, projectRoot2) {
8912
8919
  try {
8913
8920
  const managed = [paths.manifestPath, paths.skillPath];
8914
- if (managed.some((path) => !lstatSync5(path).isFile())) return false;
8921
+ if (managed.some((path) => !lstatSync6(path).isFile())) return false;
8915
8922
  if (projectRoot2 === void 0) return true;
8916
8923
  const realRoot = realpathSync3(projectRoot2);
8917
8924
  return managed.every((path) => pathIsInside(realRoot, realpathSync3(path)));
@@ -8952,7 +8959,7 @@ function hasUsablePrimFrontmatter(skill) {
8952
8959
  }
8953
8960
  }
8954
8961
  function inspectRecognizedInstallation(paths, projectRoot2) {
8955
- if (!existsSync8(paths.manifestPath) || !existsSync8(paths.skillPath)) return;
8962
+ if (!existsSync9(paths.manifestPath) || !existsSync9(paths.skillPath)) return;
8956
8963
  if (!managedPathsAreSafe(paths, projectRoot2)) return;
8957
8964
  const manifest = readBoundedRegularFile(paths.manifestPath, MAX_MANIFEST_BYTES2);
8958
8965
  const parsed = JSON.parse(manifest);
@@ -8966,9 +8973,9 @@ function inspectRecognizedInstallation(paths, projectRoot2) {
8966
8973
  };
8967
8974
  }
8968
8975
  function refreshLockDir(physicalPluginDir) {
8969
- const cacheRoot = process.env.XDG_CACHE_HOME || join12(homedir5(), ".cache");
8970
- const identity = createHash6("sha256").update(physicalPluginDir).digest("hex");
8971
- return join12(cacheRoot, "prim", "skill-refresh-locks", `${identity}.lock`);
8976
+ const cacheRoot = process.env.XDG_CACHE_HOME || join13(homedir6(), ".cache");
8977
+ const identity = createHash7("sha256").update(physicalPluginDir).digest("hex");
8978
+ return join13(cacheRoot, "prim", "skill-refresh-locks", `${identity}.lock`);
8972
8979
  }
8973
8980
  async function refreshClaudePlugins(cwd, options = {}) {
8974
8981
  const result = { installed: 0, refreshed: 0 };
@@ -8976,7 +8983,7 @@ async function refreshClaudePlugins(cwd, options = {}) {
8976
8983
  if (options.includeProject !== false) {
8977
8984
  const projectRoot2 = options.projectRoot ?? gitToplevel(cwd);
8978
8985
  if (projectRoot2 !== null && isAbsolute6(projectRoot2)) {
8979
- candidates.push({ dir: join12(projectRoot2, ".claude", "skills", "prim"), projectRoot: projectRoot2 });
8986
+ candidates.push({ dir: join13(projectRoot2, ".claude", "skills", "prim"), projectRoot: projectRoot2 });
8980
8987
  }
8981
8988
  }
8982
8989
  candidates.push({ dir: pluginDirFor(cwd, "user") });
@@ -9024,7 +9031,7 @@ async function refreshClaudePlugins(cwd, options = {}) {
9024
9031
  };
9025
9032
  try {
9026
9033
  const paths = pluginPaths(dir);
9027
- if (!existsSync8(paths.manifestPath) || !existsSync8(paths.skillPath)) continue;
9034
+ if (!existsSync9(paths.manifestPath) || !existsSync9(paths.skillPath)) continue;
9028
9035
  const physicalPluginDir = realpathSync3(dir);
9029
9036
  if (seen.has(physicalPluginDir)) continue;
9030
9037
  seen.add(physicalPluginDir);
@@ -9039,13 +9046,13 @@ async function refreshClaudePlugins(cwd, options = {}) {
9039
9046
  }
9040
9047
 
9041
9048
  // src/daemon/principal.ts
9042
- import { createHash as createHash7 } from "crypto";
9049
+ import { createHash as createHash8 } from "crypto";
9043
9050
  var PRINCIPAL_COMPONENT_MAX_LENGTH = 512;
9044
9051
  function boundedClaim(value) {
9045
9052
  return typeof value === "string" && value.length > 0 && value.length <= PRINCIPAL_COMPONENT_MAX_LENGTH ? value : void 0;
9046
9053
  }
9047
9054
  function sha2562(value) {
9048
- return createHash7("sha256").update(value).digest("hex");
9055
+ return createHash8("sha256").update(value).digest("hex");
9049
9056
  }
9050
9057
  function resolveDaemonPrincipal(token = resolveAuthCredential()?.token) {
9051
9058
  if (!token) return void 0;
@@ -9089,8 +9096,8 @@ function parseDaemonResponseEnvelope(value) {
9089
9096
 
9090
9097
  // src/daemon/client.ts
9091
9098
  import { createConnection } from "net";
9092
- import { join as join13 } from "path";
9093
- var SOCK_PATH = join13(primConfigDirectory(), "sock");
9099
+ import { join as join14 } from "path";
9100
+ var SOCK_PATH = join14(primConfigDirectory(), "sock");
9094
9101
  var DEFAULT_TIMEOUT_MS2 = 250;
9095
9102
  var nextRequestId = 1;
9096
9103
  function daemonRequest(method, params = {}, opts = {}) {
@@ -9397,25 +9404,88 @@ async function acknowledgeDecisionFeedback(input, dependencies = {}) {
9397
9404
  }
9398
9405
 
9399
9406
  // src/lib/activation.ts
9407
+ import { execFileSync as execFileSync4 } from "child_process";
9408
+ import { existsSync as existsSync10, readFileSync as readFileSync12 } from "fs";
9409
+ import { homedir as homedir7 } from "os";
9410
+ import { join as join15 } from "path";
9411
+
9412
+ // src/lib/demo-pause.ts
9400
9413
  import { execFileSync as execFileSync3 } from "child_process";
9401
- import { existsSync as existsSync9, readFileSync as readFileSync11 } from "fs";
9402
- import { homedir as homedir6 } from "os";
9403
- import { join as join14 } from "path";
9414
+ var DEMO_PAUSE_MS = 30 * 6e4;
9415
+ var PAUSE_KEY = "prim.demoPause";
9416
+ var GIT_TIMEOUT_MS2 = 1e3;
9417
+ function git(cwd, args) {
9418
+ try {
9419
+ return execFileSync3("git", args, {
9420
+ cwd,
9421
+ encoding: "utf-8",
9422
+ stdio: ["ignore", "pipe", "ignore"],
9423
+ timeout: GIT_TIMEOUT_MS2
9424
+ });
9425
+ } catch {
9426
+ return void 0;
9427
+ }
9428
+ }
9429
+ function setLocal(cwd, key, value) {
9430
+ try {
9431
+ execFileSync3(
9432
+ "git",
9433
+ value === null ? ["config", "--local", "--unset", key] : ["config", "--local", key, value],
9434
+ { cwd, stdio: ["ignore", "ignore", "pipe"], timeout: GIT_TIMEOUT_MS2 }
9435
+ );
9436
+ } catch (error) {
9437
+ if (value !== null || error.status !== 5) throw error;
9438
+ }
9439
+ }
9440
+ function parsePause(value) {
9441
+ const [runId = "", until, previous, state] = value.trim().split(" ");
9442
+ const flag = previous === "true" || previous === "false" ? previous : "unset";
9443
+ return { runId, until: Number(until) || 0, previous: flag, ending: state !== "active" };
9444
+ }
9445
+ function readCaptureConfig(cwd) {
9446
+ let active;
9447
+ let pause;
9448
+ const out = git(cwd, ["config", "--get-regexp", "^prim\\.(active|demopause)$"]) ?? "";
9449
+ for (const line of out.split("\n")) {
9450
+ const space = line.indexOf(" ");
9451
+ const key = line.slice(0, space).toLowerCase();
9452
+ const value = line.slice(space + 1);
9453
+ if (key === "prim.active") active = value === "true" || value === "false" ? value : void 0;
9454
+ if (key === "prim.demopause") pause = parsePause(value);
9455
+ }
9456
+ return { active, pause };
9457
+ }
9458
+ function resumeCapture(cwd, pause) {
9459
+ setLocal(cwd, "prim.active", pause.previous === "unset" ? null : pause.previous);
9460
+ setLocal(cwd, PAUSE_KEY, null);
9461
+ }
9462
+ function healDemoPause(cwd, pause, options = {}) {
9463
+ if (pause.until > (options.now ?? Date.now()) && !(pause.ending && options.userPrompt))
9464
+ return false;
9465
+ try {
9466
+ resumeCapture(cwd, pause);
9467
+ return true;
9468
+ } catch {
9469
+ return false;
9470
+ }
9471
+ }
9472
+
9473
+ // src/lib/activation.ts
9404
9474
  var PRIM_ACTIVE_KEY = "prim.active";
9405
9475
  var PRIM_REPO_SYNC_ID_KEY = "prim.repoSyncId";
9406
9476
  var PRIM_REPO_SYNC_REPOSITORY_KEY = "prim.repoSyncRepository";
9407
9477
  var PRIM_REPO_BINDING_STATE_KEY = "prim.repoBindingState";
9408
- var GIT_TIMEOUT_MS2 = 1e3;
9478
+ var GIT_TIMEOUT_MS3 = 1e3;
9409
9479
  var REPO_SYNC_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
9410
9480
  var PROJECT_INSTALL_FILES = [".claude/settings.json", ".codex/hooks.json", ".cursor/hooks.json"];
9411
9481
  var PRIM_HOOK_BINS = ["prim-hook", "prim-pre-tool-use", "prim-post-tool-use"];
9412
9482
  function repoActiveFlag(cwd, strict = false) {
9413
9483
  try {
9414
- const value = execFileSync3("git", ["config", "--get", PRIM_ACTIVE_KEY], {
9484
+ const value = execFileSync4("git", ["config", "--get", PRIM_ACTIVE_KEY], {
9415
9485
  cwd,
9416
9486
  encoding: "utf-8",
9417
9487
  stdio: ["ignore", "pipe", "ignore"],
9418
- timeout: GIT_TIMEOUT_MS2
9488
+ timeout: GIT_TIMEOUT_MS3
9419
9489
  }).trim();
9420
9490
  if (value === "true") return "true";
9421
9491
  if (value === "false") return "false";
@@ -9428,10 +9498,10 @@ function repoActiveFlag(cwd, strict = false) {
9428
9498
  }
9429
9499
  }
9430
9500
  function setRepoActive(cwd, active) {
9431
- execFileSync3("git", ["config", "--local", PRIM_ACTIVE_KEY, active ? "true" : "false"], {
9501
+ execFileSync4("git", ["config", "--local", PRIM_ACTIVE_KEY, active ? "true" : "false"], {
9432
9502
  cwd,
9433
9503
  stdio: ["ignore", "ignore", "pipe"],
9434
- timeout: GIT_TIMEOUT_MS2
9504
+ timeout: GIT_TIMEOUT_MS3
9435
9505
  });
9436
9506
  }
9437
9507
  function isValidRepoSyncId(value) {
@@ -9439,11 +9509,11 @@ function isValidRepoSyncId(value) {
9439
9509
  }
9440
9510
  function localGitConfigValue(cwd, key) {
9441
9511
  try {
9442
- const value = execFileSync3("git", ["config", "--local", "--get", key], {
9512
+ const value = execFileSync4("git", ["config", "--local", "--get", key], {
9443
9513
  cwd,
9444
9514
  encoding: "utf-8",
9445
9515
  stdio: ["ignore", "pipe", "ignore"],
9446
- timeout: GIT_TIMEOUT_MS2
9516
+ timeout: GIT_TIMEOUT_MS3
9447
9517
  }).trim();
9448
9518
  return value || void 0;
9449
9519
  } catch {
@@ -9451,10 +9521,10 @@ function localGitConfigValue(cwd, key) {
9451
9521
  }
9452
9522
  }
9453
9523
  function setLocalGitConfigValue(cwd, key, value) {
9454
- execFileSync3("git", ["config", "--local", key, value], {
9524
+ execFileSync4("git", ["config", "--local", key, value], {
9455
9525
  cwd,
9456
9526
  stdio: ["ignore", "ignore", "pipe"],
9457
- timeout: GIT_TIMEOUT_MS2
9527
+ timeout: GIT_TIMEOUT_MS3
9458
9528
  });
9459
9529
  }
9460
9530
  function repoSyncId(cwd) {
@@ -9467,25 +9537,25 @@ function setRepoSyncId(cwd, value, repositoryFullName) {
9467
9537
  if (!isValidRepoSyncId(value)) {
9468
9538
  throw new Error("invalid repository binding returned by server");
9469
9539
  }
9470
- execFileSync3("git", ["config", "--local", PRIM_REPO_SYNC_ID_KEY, value], {
9540
+ execFileSync4("git", ["config", "--local", PRIM_REPO_SYNC_ID_KEY, value], {
9471
9541
  cwd,
9472
9542
  stdio: ["ignore", "ignore", "pipe"],
9473
- timeout: GIT_TIMEOUT_MS2
9543
+ timeout: GIT_TIMEOUT_MS3
9474
9544
  });
9475
- execFileSync3("git", ["config", "--local", PRIM_REPO_SYNC_REPOSITORY_KEY, repositoryFullName], {
9545
+ execFileSync4("git", ["config", "--local", PRIM_REPO_SYNC_REPOSITORY_KEY, repositoryFullName], {
9476
9546
  cwd,
9477
9547
  stdio: ["ignore", "ignore", "pipe"],
9478
- timeout: GIT_TIMEOUT_MS2
9548
+ timeout: GIT_TIMEOUT_MS3
9479
9549
  });
9480
9550
  }
9481
9551
  function setRepositoryBindingState(cwd, state) {
9482
9552
  if (state !== "connected" && state !== "unbound" && state !== "invalid") {
9483
9553
  throw new Error("invalid repository binding state");
9484
9554
  }
9485
- execFileSync3("git", ["config", "--local", PRIM_REPO_BINDING_STATE_KEY, state], {
9555
+ execFileSync4("git", ["config", "--local", PRIM_REPO_BINDING_STATE_KEY, state], {
9486
9556
  cwd,
9487
9557
  stdio: ["ignore", "ignore", "pipe"],
9488
- timeout: GIT_TIMEOUT_MS2
9558
+ timeout: GIT_TIMEOUT_MS3
9489
9559
  });
9490
9560
  }
9491
9561
  function repositoryBindingState(cwd) {
@@ -9499,12 +9569,12 @@ function repositoryBindingState(cwd) {
9499
9569
  }
9500
9570
  function hasProjectPrimInstall(cwd) {
9501
9571
  const root = gitToplevel(cwd);
9502
- if (root === null || root === homedir6()) return false;
9572
+ if (root === null || root === homedir7()) return false;
9503
9573
  for (const rel of PROJECT_INSTALL_FILES) {
9504
- const path = join14(root, rel);
9505
- if (existsSync9(path)) {
9574
+ const path = join15(root, rel);
9575
+ if (existsSync10(path)) {
9506
9576
  try {
9507
- const content = readFileSync11(path, "utf-8");
9577
+ const content = readFileSync12(path, "utf-8");
9508
9578
  if (PRIM_HOOK_BINS.some((bin) => content.includes(bin))) return true;
9509
9579
  } catch {
9510
9580
  }
@@ -9512,8 +9582,9 @@ function hasProjectPrimInstall(cwd) {
9512
9582
  }
9513
9583
  return false;
9514
9584
  }
9515
- function isRepoActiveForCapture(cwd) {
9516
- const flag = repoActiveFlag(cwd);
9585
+ function isRepoActiveForCapture(cwd, options = {}) {
9586
+ let { active: flag, pause } = readCaptureConfig(cwd);
9587
+ if (pause && healDemoPause(cwd, pause, options)) flag = repoActiveFlag(cwd);
9517
9588
  if (flag === "true") return true;
9518
9589
  if (flag === "false") return false;
9519
9590
  return hasProjectPrimInstall(cwd);
@@ -9524,14 +9595,14 @@ function decisionIngestionStatus(cwd) {
9524
9595
 
9525
9596
  // src/lib/bin-cache.ts
9526
9597
  import { chmodSync as chmodSync4, mkdirSync as mkdirSync6 } from "fs";
9527
- import { homedir as homedir7 } from "os";
9528
- import { join as join15 } from "path";
9598
+ import { homedir as homedir8 } from "os";
9599
+ import { join as join16 } from "path";
9529
9600
  var GIT_HOOK_CACHE_SHELL_DIR = "${XDG_CACHE_HOME:-$HOME/.cache}/prim/bin";
9530
9601
  var GIT_HOOK_CACHE_TTL_MINUTES = 1440;
9531
9602
  var GIT_HOOK_CACHED_BINS = ["prim-post-commit", "prim-post-rewrite"];
9532
9603
  function binCacheDir() {
9533
- const base = process.env.XDG_CACHE_HOME || join15(homedir7(), ".cache");
9534
- return join15(base, "prim", "bin");
9604
+ const base = process.env.XDG_CACHE_HOME || join16(homedir8(), ".cache");
9605
+ return join16(base, "prim", "bin");
9535
9606
  }
9536
9607
  function writeAtomic(path, content) {
9537
9608
  atomicWriteFile(path, content, { mode: 384 });
@@ -9544,11 +9615,11 @@ function warmBinCache() {
9544
9615
  const dir = binCacheDir();
9545
9616
  mkdirSync6(dir, { recursive: true, mode: 448 });
9546
9617
  chmodSync4(dir, 448);
9547
- writeAtomic(join15(dir, "node"), process.execPath);
9618
+ writeAtomic(join16(dir, "node"), process.execPath);
9548
9619
  for (const bin of GIT_HOOK_CACHED_BINS) {
9549
9620
  const file = binFile(bin);
9550
9621
  if (file) {
9551
- writeAtomic(join15(dir, bin), file);
9622
+ writeAtomic(join16(dir, bin), file);
9552
9623
  }
9553
9624
  }
9554
9625
  } catch {
@@ -31855,25 +31926,25 @@ async function fetchAndCacheCollectScope(cwd, dependencies = defaultDependencies
31855
31926
  }
31856
31927
 
31857
31928
  // src/lib/commit-heartbeat.ts
31858
- import { execFileSync as execFileSync4 } from "child_process";
31859
- import { mkdirSync as mkdirSync7, readFileSync as readFileSync12, readdirSync as readdirSync4, unlinkSync as unlinkSync2 } from "fs";
31860
- import { dirname as dirname10, join as join16, resolve as resolve6 } from "path";
31929
+ import { execFileSync as execFileSync5 } from "child_process";
31930
+ import { mkdirSync as mkdirSync7, readFileSync as readFileSync13, readdirSync as readdirSync5, unlinkSync as unlinkSync3 } from "fs";
31931
+ import { dirname as dirname11, join as join17, resolve as resolve6 } from "path";
31861
31932
  var WIRED_PATH = "prim/git-hooks-wired";
31862
- var GIT_TIMEOUT_MS3 = 1e3;
31933
+ var GIT_TIMEOUT_MS4 = 1e3;
31863
31934
  var MAX_STAMP_BYTES = 1024;
31864
31935
  function commonPath(cwd, relative4) {
31865
- const value = execFileSync4("git", ["rev-parse", "--git-common-dir"], {
31936
+ const value = execFileSync5("git", ["rev-parse", "--git-common-dir"], {
31866
31937
  cwd,
31867
31938
  encoding: "utf8",
31868
31939
  stdio: ["ignore", "pipe", "ignore"],
31869
- timeout: GIT_TIMEOUT_MS3
31940
+ timeout: GIT_TIMEOUT_MS4
31870
31941
  }).replace(/\r?\n$/u, "");
31871
31942
  if (value === "" || /[\0\r\n]/u.test(value)) throw new Error("Git returned an unsafe path");
31872
- return join16(resolve6(cwd, value), relative4);
31943
+ return join17(resolve6(cwd, value), relative4);
31873
31944
  }
31874
31945
  function ensurePrivateParent(path) {
31875
- mkdirSync7(dirname10(dirname10(path)), { recursive: true, mode: 448 });
31876
- mkdirSync7(dirname10(path), { recursive: true, mode: 448 });
31946
+ mkdirSync7(dirname11(dirname11(path)), { recursive: true, mode: 448 });
31947
+ mkdirSync7(dirname11(path), { recursive: true, mode: 448 });
31877
31948
  }
31878
31949
  function writeStamp(path, at) {
31879
31950
  ensurePrivateParent(path);
@@ -31882,7 +31953,7 @@ function writeStamp(path, at) {
31882
31953
  }
31883
31954
  function readStampAt(path) {
31884
31955
  try {
31885
- const raw = readFileSync12(path, "utf8");
31956
+ const raw = readFileSync13(path, "utf8");
31886
31957
  if (raw.length > MAX_STAMP_BYTES) return void 0;
31887
31958
  const parsed = JSON.parse(raw);
31888
31959
  return typeof parsed.at === "number" && Number.isSafeInteger(parsed.at) && parsed.at > 0 ? parsed.at : void 0;
@@ -31900,30 +31971,30 @@ function recordHooksWired(cwd, options = {}) {
31900
31971
  }
31901
31972
  function clearHooksWired(cwd) {
31902
31973
  try {
31903
- unlinkSync2(commonPath(cwd, WIRED_PATH));
31974
+ unlinkSync3(commonPath(cwd, WIRED_PATH));
31904
31975
  } catch {
31905
31976
  }
31906
31977
  }
31907
31978
 
31908
31979
  // src/lib/git-hooks.ts
31909
- import { execFileSync as execFileSync5 } from "child_process";
31910
- import { createHash as createHash8, randomUUID as randomUUID2 } from "crypto";
31980
+ import { execFileSync as execFileSync6 } from "child_process";
31981
+ import { createHash as createHash9, randomUUID as randomUUID2 } from "crypto";
31911
31982
  import {
31912
31983
  constants as constants5,
31913
31984
  closeSync as closeSync4,
31914
- existsSync as existsSync10,
31985
+ existsSync as existsSync11,
31915
31986
  fchmodSync as fchmodSync2,
31916
31987
  fsyncSync as fsyncSync2,
31917
- lstatSync as lstatSync6,
31988
+ lstatSync as lstatSync7,
31918
31989
  mkdirSync as mkdirSync8,
31919
31990
  openSync as openSync4,
31920
- readFileSync as readFileSync13,
31991
+ readFileSync as readFileSync14,
31921
31992
  realpathSync as realpathSync4,
31922
31993
  renameSync as renameSync3,
31923
- unlinkSync as unlinkSync3,
31994
+ unlinkSync as unlinkSync4,
31924
31995
  writeFileSync as writeFileSync4
31925
31996
  } from "fs";
31926
- import { basename as basename2, dirname as dirname11, isAbsolute as isAbsolute8, join as join17, relative as relative3, resolve as resolve7, sep as sep3 } from "path";
31997
+ import { basename as basename2, dirname as dirname12, isAbsolute as isAbsolute8, join as join18, relative as relative3, resolve as resolve7, sep as sep3 } from "path";
31927
31998
 
31928
31999
  // src/lib/git-hook-legacy.ts
31929
32000
  import { isAbsolute as isAbsolute7 } from "path";
@@ -32102,7 +32173,7 @@ var LEGACY_PRIM_CREATED_MARK = "prim-created-hook";
32102
32173
  var LEGACY_PRIM_OWNED_HEADER = "# prim post-commit hook \u2014 installed by: prim hooks install (prim-managed-hook)";
32103
32174
  var LEGACY_GLOBAL_OWNED_HEADER = "# prim global post-commit hook (core.hooksPath) \u2014 managed by prim; do not edit.";
32104
32175
  var MAX_HOOK_BYTES = 1048576;
32105
- var GIT_TIMEOUT_MS4 = 1e3;
32176
+ var GIT_TIMEOUT_MS5 = 1e3;
32106
32177
  var SUPPORTED_SHEBANGS = /* @__PURE__ */ new Set([
32107
32178
  "#!/bin/sh",
32108
32179
  "#!/usr/bin/env sh",
@@ -32145,14 +32216,14 @@ function managedHookSpec(hookName) {
32145
32216
  }
32146
32217
  function gitHooksMode(options = {}) {
32147
32218
  try {
32148
- const value = execFileSync5(
32219
+ const value = execFileSync6(
32149
32220
  "git",
32150
32221
  ["config", ...options.global ? ["--global"] : [], "--get", "prim.gitHooks"],
32151
32222
  {
32152
32223
  cwd: options.cwd,
32153
32224
  encoding: "utf8",
32154
32225
  stdio: ["ignore", "pipe", "ignore"],
32155
- timeout: GIT_TIMEOUT_MS4
32226
+ timeout: GIT_TIMEOUT_MS5
32156
32227
  }
32157
32228
  ).trim();
32158
32229
  return value === "manual" ? "manual" : "auto";
@@ -32232,9 +32303,9 @@ function realpathLoose(path) {
32232
32303
  let current = resolve7(path);
32233
32304
  for (; ; ) {
32234
32305
  try {
32235
- return join17(realpathSync4.native(current), ...missing);
32306
+ return join18(realpathSync4.native(current), ...missing);
32236
32307
  } catch {
32237
- const parent = dirname11(current);
32308
+ const parent = dirname12(current);
32238
32309
  if (parent === current) return resolve7(path);
32239
32310
  missing.unshift(basename2(current));
32240
32311
  current = parent;
@@ -32247,7 +32318,7 @@ function isWithin(path, directory) {
32247
32318
  }
32248
32319
  function primGitHooksDirectory() {
32249
32320
  try {
32250
- return join17(primConfigDirectory(), "git-hooks");
32321
+ return join18(primConfigDirectory(), "git-hooks");
32251
32322
  } catch {
32252
32323
  return void 0;
32253
32324
  }
@@ -32255,11 +32326,11 @@ function primGitHooksDirectory() {
32255
32326
  function otherWorktreeRoots(gitRoot) {
32256
32327
  try {
32257
32328
  const self = realpathLoose(gitRoot);
32258
- return execFileSync5("git", ["worktree", "list", "--porcelain"], {
32329
+ return execFileSync6("git", ["worktree", "list", "--porcelain"], {
32259
32330
  cwd: gitRoot,
32260
32331
  encoding: "utf8",
32261
32332
  stdio: ["ignore", "pipe", "ignore"],
32262
- timeout: GIT_TIMEOUT_MS4
32333
+ timeout: GIT_TIMEOUT_MS5
32263
32334
  }).split("\n").flatMap((line) => line.startsWith("worktree ") ? [realpathLoose(line.slice(9))] : []).filter((root) => root !== self);
32264
32335
  } catch {
32265
32336
  return [];
@@ -32286,14 +32357,14 @@ function safeGitPath(root, value) {
32286
32357
  function resolveEffectiveGitHook(hookName, cwd = process.cwd()) {
32287
32358
  const gitRoot = gitToplevel(cwd);
32288
32359
  if (!gitRoot) throw new Error("not a git repository");
32289
- const lines = execFileSync5(
32360
+ const lines = execFileSync6(
32290
32361
  "git",
32291
32362
  ["rev-parse", "--git-path", "hooks", "--absolute-git-dir", "--git-common-dir"],
32292
32363
  {
32293
32364
  cwd: gitRoot,
32294
32365
  encoding: "utf8",
32295
32366
  stdio: ["ignore", "pipe", "ignore"],
32296
- timeout: GIT_TIMEOUT_MS4
32367
+ timeout: GIT_TIMEOUT_MS5
32297
32368
  }
32298
32369
  ).replace(/\r?\n$/u, "").split(/\r?\n/u);
32299
32370
  if (lines.length !== 3) throw new Error("Git returned unexpected repository paths");
@@ -32304,8 +32375,8 @@ function resolveEffectiveGitHook(hookName, cwd = process.cwd()) {
32304
32375
  gitDir: safeGitPath(gitRoot, gitDirValue),
32305
32376
  commonDir: safeGitPath(gitRoot, commonDirValue)
32306
32377
  };
32307
- if (basename2(hooksDir) === "_" && basename2(dirname11(hooksDir)) === ".husky") {
32308
- const hookPath2 = resolve7(dirname11(hooksDir), hookName);
32378
+ if (basename2(hooksDir) === "_" && basename2(dirname12(hooksDir)) === ".husky") {
32379
+ const hookPath2 = resolve7(dirname12(hooksDir), hookName);
32309
32380
  return {
32310
32381
  gitRoot,
32311
32382
  hooksDir,
@@ -32325,8 +32396,8 @@ function resolveEffectiveGitHook(hookName, cwd = process.cwd()) {
32325
32396
  };
32326
32397
  }
32327
32398
  function assertSafeFile(path, spec) {
32328
- if (!existsSync10(path)) return void 0;
32329
- const stat = lstatSync6(path);
32399
+ if (!existsSync11(path)) return void 0;
32400
+ const stat = lstatSync7(path);
32330
32401
  if (!stat.isFile() || stat.isSymbolicLink() || stat.size > MAX_HOOK_BYTES) {
32331
32402
  throw new Error(`unsafe ${spec.hookName} hook target: ${path}`);
32332
32403
  }
@@ -32347,16 +32418,16 @@ function assertUsableHuskyDispatcher(target, spec) {
32347
32418
  if (!HUSKY_V9_DISPATCHERS.has(normalizedDispatcher)) {
32348
32419
  throw new Error(`unrecognized Husky ${spec.hookName} dispatcher: ${target.dispatcherPath}`);
32349
32420
  }
32350
- const huskyRuntime = resolve7(dirname11(target.dispatcherPath), "h");
32421
+ const huskyRuntime = resolve7(dirname12(target.dispatcherPath), "h");
32351
32422
  const runtimeStat = assertSafeFile(huskyRuntime, spec);
32352
32423
  const runtime = runtimeStat ? readHookFile(huskyRuntime) : void 0;
32353
- const runtimeHash = runtime ? createHash8("sha256").update(runtime).digest("hex") : void 0;
32424
+ const runtimeHash = runtime ? createHash9("sha256").update(runtime).digest("hex") : void 0;
32354
32425
  if (!runtimeHash || !HUSKY_V9_RUNTIME_HASHES.has(runtimeHash)) {
32355
32426
  throw new Error(`unrecognized Husky v9 hook runtime: ${huskyRuntime}`);
32356
32427
  }
32357
32428
  }
32358
32429
  function readHookFile(path) {
32359
- const value = readFileSync13(path);
32430
+ const value = readFileSync14(path);
32360
32431
  return Buffer.isBuffer(value) ? value : Buffer.from(value);
32361
32432
  }
32362
32433
  function decodeHookText(content, spec) {
@@ -32428,11 +32499,11 @@ function blockInsertionPoint(content, spec, huskyV8) {
32428
32499
  var HUSKY_SPEC_MAJOR_RE = /^\s*[~^]?=?\s*v?([0-9]+)(?:\.(?:[0-9]+|[xX*])){0,2}(?:-[0-9A-Za-z.-]+)?\s*$/u;
32429
32500
  function declaredHuskyMajor(dir) {
32430
32501
  for (let current = resolve7(dir); ; ) {
32431
- const manifest = join17(current, "package.json");
32432
- if (existsSync10(manifest)) {
32502
+ const manifest = join18(current, "package.json");
32503
+ if (existsSync11(manifest)) {
32433
32504
  try {
32434
- if (lstatSync6(manifest).size > MAX_HOOK_BYTES) return void 0;
32435
- const parsed = JSON.parse(readFileSync13(manifest, "utf8"));
32505
+ if (lstatSync7(manifest).size > MAX_HOOK_BYTES) return void 0;
32506
+ const parsed = JSON.parse(readFileSync14(manifest, "utf8"));
32436
32507
  const range = parsed.devDependencies?.husky ?? parsed.dependencies?.husky;
32437
32508
  const major = typeof range === "string" ? HUSKY_SPEC_MAJOR_RE.exec(range)?.[1] : void 0;
32438
32509
  return major === void 0 ? void 0 : Number(major);
@@ -32440,20 +32511,20 @@ function declaredHuskyMajor(dir) {
32440
32511
  return void 0;
32441
32512
  }
32442
32513
  }
32443
- const parent = dirname11(current);
32444
- if (parent === current || existsSync10(join17(current, ".git"))) return void 0;
32514
+ const parent = dirname12(current);
32515
+ if (parent === current || existsSync11(join18(current, ".git"))) return void 0;
32445
32516
  current = parent;
32446
32517
  }
32447
32518
  }
32448
32519
  function isHuskyV8Hook(hookPath) {
32449
- const runtime = join17(dirname11(hookPath), "_", "husky.sh");
32520
+ const runtime = join18(dirname12(hookPath), "_", "husky.sh");
32450
32521
  try {
32451
- const stat = lstatSync6(runtime);
32452
- return stat.isFile() && stat.size <= MAX_HOOK_BYTES && readFileSync13(runtime, "utf8").includes("husky_skip_init");
32522
+ const stat = lstatSync7(runtime);
32523
+ return stat.isFile() && stat.size <= MAX_HOOK_BYTES && readFileSync14(runtime, "utf8").includes("husky_skip_init");
32453
32524
  } catch (error) {
32454
32525
  if (errorCode(error) !== "ENOENT") return false;
32455
32526
  }
32456
- const major = declaredHuskyMajor(dirname11(dirname11(hookPath)));
32527
+ const major = declaredHuskyMajor(dirname12(dirname12(hookPath)));
32457
32528
  return major !== void 0 && major <= 8;
32458
32529
  }
32459
32530
  var TERMINAL_LINE_RE = /^(?:exit|return)(?:\s|;|$)/u;
@@ -32590,7 +32661,7 @@ function errorCode(error) {
32590
32661
  function assertTargetUnchanged(path, expected, spec, stat) {
32591
32662
  let current;
32592
32663
  try {
32593
- current = lstatSync6(path);
32664
+ current = lstatSync7(path);
32594
32665
  } catch (error) {
32595
32666
  if (expected === void 0 && errorCode(error) === "ENOENT") return;
32596
32667
  throw new Error(`${spec.hookName} hook changed concurrently: ${path}`);
@@ -32603,7 +32674,7 @@ function assertTargetUnchanged(path, expected, spec, stat) {
32603
32674
  }
32604
32675
  }
32605
32676
  function rewriteHookAtomically(path, next, expected, spec, stat) {
32606
- const parent = dirname11(path);
32677
+ const parent = dirname12(path);
32607
32678
  mkdirSync8(parent, { recursive: true });
32608
32679
  const temporary = resolve7(
32609
32680
  parent,
@@ -32631,7 +32702,7 @@ function rewriteHookAtomically(path, next, expected, spec, stat) {
32631
32702
  }
32632
32703
  }
32633
32704
  try {
32634
- unlinkSync3(temporary);
32705
+ unlinkSync4(temporary);
32635
32706
  } catch (error) {
32636
32707
  if (errorCode(error) !== "ENOENT") {
32637
32708
  }
@@ -32755,7 +32826,7 @@ async function bindRepository(root, options) {
32755
32826
  }
32756
32827
 
32757
32828
  // src/lib/workspace-id.ts
32758
- import { execFileSync as execFileSync6 } from "child_process";
32829
+ import { execFileSync as execFileSync7 } from "child_process";
32759
32830
  import { randomUUID as randomUUID3 } from "crypto";
32760
32831
  import {
32761
32832
  constants as constants6,
@@ -32764,16 +32835,16 @@ import {
32764
32835
  fchmodSync as fchmodSync3,
32765
32836
  fsyncSync as fsyncSync3,
32766
32837
  linkSync,
32767
- lstatSync as lstatSync7,
32838
+ lstatSync as lstatSync8,
32768
32839
  mkdirSync as mkdirSync9,
32769
32840
  openSync as openSync5,
32770
- readFileSync as readFileSync14,
32841
+ readFileSync as readFileSync15,
32771
32842
  statSync as statSync3,
32772
- unlinkSync as unlinkSync4,
32843
+ unlinkSync as unlinkSync5,
32773
32844
  writeFileSync as writeFileSync5
32774
32845
  } from "fs";
32775
- import { dirname as dirname12, isAbsolute as isAbsolute9, join as join18, resolve as resolve8 } from "path";
32776
- var WORKSPACE_ID_RELATIVE_PATH = join18("prim", "workspace-id");
32846
+ import { dirname as dirname13, isAbsolute as isAbsolute9, join as join19, resolve as resolve8 } from "path";
32847
+ var WORKSPACE_ID_RELATIVE_PATH = join19("prim", "workspace-id");
32777
32848
  var MAX_ANCESTORS = 64;
32778
32849
  var MAX_GIT_FILE_BYTES = 4096;
32779
32850
  var MAX_ID_FILE_BYTES = 128;
@@ -32801,7 +32872,7 @@ function resolveWorkspaceIdPath(cwd) {
32801
32872
  if (fromFilesystem) return { status: "resolved", path: fromFilesystem };
32802
32873
  }
32803
32874
  try {
32804
- const output = execFileSync6(
32875
+ const output = execFileSync7(
32805
32876
  "git",
32806
32877
  ["rev-parse", "--is-inside-work-tree", "--git-path", WORKSPACE_ID_RELATIVE_PATH],
32807
32878
  {
@@ -32832,19 +32903,19 @@ function resolveWorkspaceIdPath(cwd) {
32832
32903
  function resolveFromFilesystem(cwd) {
32833
32904
  let current = resolve8(cwd);
32834
32905
  for (let depth = 0; depth < MAX_ANCESTORS; depth += 1) {
32835
- const dotGit = join18(current, ".git");
32906
+ const dotGit = join19(current, ".git");
32836
32907
  try {
32837
- const stat = lstatSync7(dotGit);
32908
+ const stat = lstatSync8(dotGit);
32838
32909
  if (stat.isDirectory() && isGitDirectory(dotGit)) {
32839
- return join18(dotGit, WORKSPACE_ID_RELATIVE_PATH);
32910
+ return join19(dotGit, WORKSPACE_ID_RELATIVE_PATH);
32840
32911
  }
32841
32912
  if (stat.isFile() && stat.size <= MAX_GIT_FILE_BYTES) {
32842
- const contents = readFileSync14(dotGit, "utf8");
32913
+ const contents = readFileSync15(dotGit, "utf8");
32843
32914
  const match = /^gitdir: (.+?)(?:\r?\n)?$/.exec(contents);
32844
32915
  if (match?.[1]) {
32845
32916
  const gitDirectory = isAbsolute9(match[1]) ? resolve8(match[1]) : resolve8(current, match[1]);
32846
32917
  if (isGitDirectory(gitDirectory)) {
32847
- return join18(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
32918
+ return join19(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
32848
32919
  }
32849
32920
  }
32850
32921
  }
@@ -32855,7 +32926,7 @@ function resolveFromFilesystem(cwd) {
32855
32926
  return null;
32856
32927
  }
32857
32928
  }
32858
- const parent = dirname12(current);
32929
+ const parent = dirname13(current);
32859
32930
  if (parent === current) break;
32860
32931
  current = parent;
32861
32932
  }
@@ -32863,7 +32934,7 @@ function resolveFromFilesystem(cwd) {
32863
32934
  }
32864
32935
  function isGitDirectory(path) {
32865
32936
  try {
32866
- return statSync3(join18(path, "HEAD")).isFile();
32937
+ return statSync3(join19(path, "HEAD")).isFile();
32867
32938
  } catch {
32868
32939
  return false;
32869
32940
  }
@@ -32871,7 +32942,7 @@ function isGitDirectory(path) {
32871
32942
  function inspectPath(path) {
32872
32943
  let stat;
32873
32944
  try {
32874
- stat = lstatSync7(path);
32945
+ stat = lstatSync8(path);
32875
32946
  } catch (error) {
32876
32947
  const code = errorCode2(error);
32877
32948
  if (code === "ENOENT" || code === "ENOTDIR") return { status: "missing", path };
@@ -32882,7 +32953,7 @@ function inspectPath(path) {
32882
32953
  return { status: "corrupt", path, reason: "invalid_content" };
32883
32954
  }
32884
32955
  try {
32885
- const contents = readFileSync14(path, "utf8");
32956
+ const contents = readFileSync15(path, "utf8");
32886
32957
  const workspaceId = contents.endsWith("\n") ? contents.slice(0, -1) : contents;
32887
32958
  if ((contents === workspaceId || contents === `${workspaceId}
32888
32959
  `) && isCanonicalWorkspaceId(workspaceId)) {
@@ -32899,9 +32970,9 @@ function inspectPath(path) {
32899
32970
  }
32900
32971
  }
32901
32972
  function createWorkspaceId(path) {
32902
- const parent = dirname12(path);
32973
+ const parent = dirname13(path);
32903
32974
  const workspaceId = randomUUID3();
32904
- const temporaryPath = join18(parent, `.workspace-id-${process.pid}-${randomUUID3()}.tmp`);
32975
+ const temporaryPath = join19(parent, `.workspace-id-${process.pid}-${randomUUID3()}.tmp`);
32905
32976
  let temporaryCreated = false;
32906
32977
  let publishing = false;
32907
32978
  try {
@@ -32935,7 +33006,7 @@ function createWorkspaceId(path) {
32935
33006
  } finally {
32936
33007
  if (temporaryCreated) {
32937
33008
  try {
32938
- unlinkSync4(temporaryPath);
33009
+ unlinkSync5(temporaryPath);
32939
33010
  } catch {
32940
33011
  }
32941
33012
  }
@@ -32961,20 +33032,20 @@ function errorCode2(error) {
32961
33032
  }
32962
33033
 
32963
33034
  // src/hooks/codex-context.ts
32964
- import { createHash as createHash9, randomBytes as randomBytes5 } from "crypto";
33035
+ import { createHash as createHash10, randomBytes as randomBytes5 } from "crypto";
32965
33036
  import {
32966
33037
  chmodSync as chmodSync6,
32967
- existsSync as existsSync11,
33038
+ existsSync as existsSync12,
32968
33039
  mkdirSync as mkdirSync10,
32969
- readFileSync as readFileSync15,
32970
- readdirSync as readdirSync5,
33040
+ readFileSync as readFileSync16,
33041
+ readdirSync as readdirSync6,
32971
33042
  renameSync as renameSync4,
32972
33043
  rmSync as rmSync6,
32973
33044
  statSync as statSync4,
32974
- unlinkSync as unlinkSync5,
33045
+ unlinkSync as unlinkSync6,
32975
33046
  writeFileSync as writeFileSync6
32976
33047
  } from "fs";
32977
- import { join as join19 } from "path";
33048
+ import { join as join20 } from "path";
32978
33049
 
32979
33050
  // src/daemon/decision-digest-cache.ts
32980
33051
  import { randomBytes as randomBytes4 } from "crypto";
@@ -33127,10 +33198,10 @@ var STATE_VERSION = 1;
33127
33198
  var DRAFT_STATE_VERSION = 2;
33128
33199
  var NO_CURSOR = -1;
33129
33200
  function stateRoot(namespace) {
33130
- return join19(primConfigDirectory(), namespace, "decision-digests");
33201
+ return join20(primConfigDirectory(), namespace, "decision-digests");
33131
33202
  }
33132
33203
  function draftStateRoot(namespace) {
33133
- return join19(primConfigDirectory(), namespace, "decision-draft-deliveries");
33204
+ return join20(primConfigDirectory(), namespace, "decision-draft-deliveries");
33134
33205
  }
33135
33206
  function workspaceFor(cwd) {
33136
33207
  try {
@@ -33141,13 +33212,13 @@ function workspaceFor(cwd) {
33141
33212
  }
33142
33213
  function statePath(args) {
33143
33214
  const identity = `${args.siteUrl}\0${workspaceFor(args.cwd)}\0${args.sessionId}`;
33144
- const key = createHash9("sha256").update(identity).digest("hex");
33145
- return join19(stateRoot(args.namespace), `${key}.json`);
33215
+ const key = createHash10("sha256").update(identity).digest("hex");
33216
+ return join20(stateRoot(args.namespace), `${key}.json`);
33146
33217
  }
33147
33218
  function draftStatePath(args) {
33148
33219
  const identity = `${args.siteUrl}\0${workspaceFor(args.cwd)}\0${args.sessionId}\0${args.principalId}\0${args.organizationId}\0${args.credentialFingerprint}`;
33149
- const key = createHash9("sha256").update(identity).digest("hex");
33150
- return join19(draftStateRoot(args.namespace), `${key}.json`);
33220
+ const key = createHash10("sha256").update(identity).digest("hex");
33221
+ return join20(draftStateRoot(args.namespace), `${key}.json`);
33151
33222
  }
33152
33223
  function parseState(value) {
33153
33224
  if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
@@ -33186,17 +33257,17 @@ function parseDraftState(value) {
33186
33257
  };
33187
33258
  }
33188
33259
  function readState(path) {
33189
- if (!existsSync11(path)) return void 0;
33260
+ if (!existsSync12(path)) return void 0;
33190
33261
  try {
33191
- return parseState(JSON.parse(readFileSync15(path, "utf8")));
33262
+ return parseState(JSON.parse(readFileSync16(path, "utf8")));
33192
33263
  } catch {
33193
33264
  return void 0;
33194
33265
  }
33195
33266
  }
33196
33267
  function readDraftState(path) {
33197
- if (!existsSync11(path)) return void 0;
33268
+ if (!existsSync12(path)) return void 0;
33198
33269
  try {
33199
- return parseDraftState(JSON.parse(readFileSync15(path, "utf8")));
33270
+ return parseDraftState(JSON.parse(readFileSync16(path, "utf8")));
33200
33271
  } catch {
33201
33272
  return void 0;
33202
33273
  }
@@ -33204,7 +33275,7 @@ function readDraftState(path) {
33204
33275
  function writeStateFile(path, directory, state) {
33205
33276
  mkdirSync10(directory, { recursive: true, mode: 448 });
33206
33277
  chmodSync6(directory, 448);
33207
- const temporary = join19(
33278
+ const temporary = join20(
33208
33279
  directory,
33209
33280
  `.${path.slice(directory.length + 1)}.tmp-${process.pid}-${randomBytes5(8).toString("hex")}`
33210
33281
  );
@@ -33219,23 +33290,23 @@ function writeStateFile(path, directory, state) {
33219
33290
  renameSync4(temporary, path);
33220
33291
  } finally {
33221
33292
  try {
33222
- unlinkSync5(temporary);
33293
+ unlinkSync6(temporary);
33223
33294
  } catch {
33224
33295
  }
33225
33296
  }
33226
33297
  }
33227
33298
  function cleanupStateFiles(directory, now) {
33228
- if (!existsSync11(directory)) return;
33299
+ if (!existsSync12(directory)) return;
33229
33300
  let names;
33230
33301
  try {
33231
- names = readdirSync5(directory);
33302
+ names = readdirSync6(directory);
33232
33303
  } catch {
33233
33304
  return;
33234
33305
  }
33235
33306
  const files = [];
33236
33307
  const residue = [];
33237
33308
  for (const name of names) {
33238
- const path = join19(directory, name);
33309
+ const path = join20(directory, name);
33239
33310
  try {
33240
33311
  const mtimeMs = statSync4(path).mtimeMs;
33241
33312
  if (name.endsWith(".json")) {
@@ -33250,7 +33321,7 @@ function cleanupStateFiles(directory, now) {
33250
33321
  const excess = files.filter((file) => !stale.some((candidate) => candidate.path === file.path)).sort((a, b) => a.mtimeMs - b.mtimeMs).slice(0, Math.max(0, files.length - CODEX_DIGEST_STATE_MAX_FILES));
33251
33322
  for (const file of [...stale, ...excess]) {
33252
33323
  try {
33253
- unlinkSync5(file.path);
33324
+ unlinkSync6(file.path);
33254
33325
  } catch {
33255
33326
  }
33256
33327
  }
@@ -33540,7 +33611,7 @@ async function prepareCodexContext(options) {
33540
33611
  }
33541
33612
 
33542
33613
  // src/hooks/normalize.ts
33543
- import { createHash as createHash10 } from "crypto";
33614
+ import { createHash as createHash11 } from "crypto";
33544
33615
  import { realpathSync as realpathSync5 } from "fs";
33545
33616
  import { isAbsolute as isAbsolute10, resolve as resolve9 } from "path";
33546
33617
  var HERMES_EVENT_MAP = {
@@ -33585,7 +33656,7 @@ function requiredId(value, field) {
33585
33656
  }
33586
33657
  function cursorToolUseId(value) {
33587
33658
  if (SAFE_CORRELATION_ID_RE.test(value)) return value;
33588
- return `cursor:tool:v1:${createHash10("sha256").update(value).digest("hex")}`;
33659
+ return `cursor:tool:v1:${createHash11("sha256").update(value).digest("hex")}`;
33589
33660
  }
33590
33661
  function workspaceCandidates(value) {
33591
33662
  if (!Array.isArray(value)) return [];
@@ -33682,7 +33753,7 @@ function normalizeEnvelope(parsed, agent) {
33682
33753
  ]);
33683
33754
  return {
33684
33755
  ...parsed,
33685
- tool_use_id: `codex:fallback:v1:${createHash10("sha256").update(stableToolIdentity).digest("hex")}`
33756
+ tool_use_id: `codex:fallback:v1:${createHash11("sha256").update(stableToolIdentity).digest("hex")}`
33686
33757
  };
33687
33758
  }
33688
33759
  return parsed;