@primitive.ai/prim 0.1.0-alpha.116 → 0.1.0-alpha.118

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 (47) hide show
  1. package/README.md +21 -21
  2. package/SKILL.md +3 -3
  3. package/dist/{chunk-XG7S3LIL.js → chunk-3NJ4FUPK.js} +889 -919
  4. package/dist/{chunk-J5HBSRAV.js → chunk-4HEWA4IO.js} +1 -1
  5. package/dist/{chunk-LEUZDTNT.js → chunk-B3FVP7VQ.js} +1 -1
  6. package/dist/{chunk-4OEJ2ONG.js → chunk-C2AEY4AI.js} +2 -13
  7. package/dist/{chunk-S55JKCHQ.js → chunk-C2AJBMP2.js} +2 -2
  8. package/dist/{chunk-D3ZDZZYS.js → chunk-CHRICRVE.js} +17 -10
  9. package/dist/{chunk-HMD5K6W7.js → chunk-ECP7EGOD.js} +2 -2
  10. package/dist/{chunk-FTW4ZCBA.js → chunk-FPDOBG3H.js} +1 -1
  11. package/dist/{chunk-3TIKBQHV.js → chunk-JGOFEG6T.js} +6 -4
  12. package/dist/chunk-JSBRDJBE.js +30 -0
  13. package/dist/{chunk-KGBMU76T.js → chunk-JXQVXU2K.js} +1 -1
  14. package/dist/chunk-KZB4ABIB.js +13 -0
  15. package/dist/{chunk-I3J344DF.js → chunk-L3NUFCOD.js} +5 -5
  16. package/dist/{chunk-6IRAGUYK.js → chunk-LEEWUN74.js} +2 -2
  17. package/dist/{chunk-JKJ22ONL.js → chunk-OHLVHT6R.js} +6 -6
  18. package/dist/{chunk-RLBASQJD.js → chunk-OIXHRN32.js} +4 -4
  19. package/dist/{chunk-LLKJAET2.js → chunk-PYIIYC3A.js} +8 -16
  20. package/dist/{chunk-NEQI2VLM.js → chunk-Q4CWXKNV.js} +5 -5
  21. package/dist/{chunk-4SN5BCIG.js → chunk-QX7QFMLF.js} +2 -2
  22. package/dist/{chunk-CXMLAWC2.js → chunk-SCOEPFOV.js} +2 -2
  23. package/dist/{chunk-6JHKKLA2.js → chunk-UMSJ4DU2.js} +46 -46
  24. package/dist/{chunk-JKO6PZWQ.js → chunk-VEI7KUOU.js} +26 -48
  25. package/dist/hook-runtime/daemon/server.js +1 -0
  26. package/dist/hook-runtime/hooks/post-commit.js +1 -0
  27. package/dist/hook-runtime/hooks/post-rewrite.js +1 -0
  28. package/dist/hook-runtime/hooks/post-tool-use.js +29 -29
  29. package/dist/hook-runtime/hooks/pre-commit.js +1 -0
  30. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +34746 -0
  31. package/dist/hook-runtime/hooks/pre-tool-use.js +82 -35549
  32. package/dist/hook-runtime/hooks/prim-hook.js +22 -22
  33. package/dist/hook-runtime/hooks/session-end.js +14 -14
  34. package/dist/hook-runtime/hooks/session-start.js +100 -100
  35. package/dist/hook-runtime/index.js +244 -256
  36. package/dist/hook-runtime/statusline-main.js +1 -0
  37. package/dist/hooks/post-commit.js +8 -7
  38. package/dist/hooks/post-rewrite.js +7 -6
  39. package/dist/hooks/post-tool-use.js +25 -22
  40. package/dist/hooks/pre-commit.js +5 -4
  41. package/dist/hooks/pre-tool-use-worker.js +222 -0
  42. package/dist/hooks/pre-tool-use.js +73 -257
  43. package/dist/hooks/prim-hook.js +25 -22
  44. package/dist/hooks/session-end.js +10 -7
  45. package/dist/hooks/session-start.js +22 -19
  46. package/dist/index.js +54 -53
  47. package/package.json +3 -3
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire as __primCreateRequire } from "node:module"; const require = __primCreateRequire(import.meta.url);
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -4963,7 +4964,7 @@ var require_rc = __commonJS({
4963
4964
  "node_modules/.pnpm/rc@1.2.8/node_modules/rc/index.js"(exports, module) {
4964
4965
  "use strict";
4965
4966
  var cc = require_utils();
4966
- var join40 = __require("path").join;
4967
+ var join39 = __require("path").join;
4967
4968
  var deepExtend = require_deep_extend();
4968
4969
  var etc = "/etc";
4969
4970
  var win = process.platform === "win32";
@@ -4988,15 +4989,15 @@ var require_rc = __commonJS({
4988
4989
  }
4989
4990
  if (!win)
4990
4991
  [
4991
- join40(etc, name2, "config"),
4992
- join40(etc, name2 + "rc")
4992
+ join39(etc, name2, "config"),
4993
+ join39(etc, name2 + "rc")
4993
4994
  ].forEach(addConfigFile);
4994
4995
  if (home)
4995
4996
  [
4996
- join40(home, ".config", name2, "config"),
4997
- join40(home, ".config", name2),
4998
- join40(home, "." + name2, "config"),
4999
- join40(home, "." + name2 + "rc")
4997
+ join39(home, ".config", name2, "config"),
4998
+ join39(home, ".config", name2),
4999
+ join39(home, "." + name2, "config"),
5000
+ join39(home, "." + name2 + "rc")
5000
5001
  ].forEach(addConfigFile);
5001
5002
  addConfigFile(cc.find("." + name2 + "rc"));
5002
5003
  if (env4.config) addConfigFile(env4.config);
@@ -12575,7 +12576,7 @@ var require_websocket_server = __commonJS({
12575
12576
  });
12576
12577
 
12577
12578
  // src/index.ts
12578
- import { readFileSync as readFileSync31 } from "fs";
12579
+ import { readFileSync as readFileSync30 } from "fs";
12579
12580
  import { dirname as dirname22, resolve as resolve14 } from "path";
12580
12581
  import { fileURLToPath as fileURLToPath8 } from "url";
12581
12582
 
@@ -40876,6 +40877,7 @@ var HOOK_RUNTIME_ENTRIES = {
40876
40877
  "prim-pre-commit": "dist/hooks/pre-commit.js",
40877
40878
  "prim-post-commit": "dist/hooks/post-commit.js",
40878
40879
  "prim-post-rewrite": "dist/hooks/post-rewrite.js",
40880
+ "prim-pre-tool-use-worker": "dist/hooks/pre-tool-use-worker.js",
40879
40881
  "prim-pre-tool-use": "dist/hooks/pre-tool-use.js",
40880
40882
  "prim-post-tool-use": "dist/hooks/post-tool-use.js",
40881
40883
  "prim-session-start": "dist/hooks/session-start.js",
@@ -44239,20 +44241,18 @@ function registerActivationCommands(program3) {
44239
44241
  }
44240
44242
 
44241
44243
  // src/commands/claude-install.ts
44242
- import { existsSync as existsSync9, readFileSync as readFileSync13 } from "fs";
44244
+ import { existsSync as existsSync9, readFileSync as readFileSync12 } from "fs";
44243
44245
  import { homedir as homedir5 } from "os";
44244
- import { join as join15 } from "path";
44246
+ import { join as join14 } from "path";
44245
44247
 
44246
44248
  // src/lib/preflight-host.ts
44247
44249
  import { execFileSync as execFileSync6 } from "child_process";
44248
- import { readFileSync as readFileSync12 } from "fs";
44249
- import { join as join14 } from "path";
44250
44250
  function inspectFailureProtection(host) {
44251
44251
  if (host === "codex")
44252
44252
  return {
44253
44253
  host,
44254
- status: "limited",
44255
- detail: "Codex accepts Primitive's explicit deny before the 240-second deadline, but does not provide a documented fail-closed policy for a killed, crashed, or timed-out hook. The installed hook timeout is 300 seconds; this host boundary is not guaranteed."
44254
+ status: "supported",
44255
+ detail: "Codex gates wait at most two seconds. Confirmed conflicts retain explicit denial; crashed or timed-out checks permit the tool without a Primitive notice."
44256
44256
  };
44257
44257
  let output;
44258
44258
  try {
@@ -44266,47 +44266,26 @@ function inspectFailureProtection(host) {
44266
44266
  return {
44267
44267
  host,
44268
44268
  status: "unknown",
44269
- detail: `Cannot inspect ${host}; install or expose the host on PATH, then run prim doctor. Host failure protection is not verified.`
44269
+ detail: `Cannot inspect ${host}; install or expose the host on PATH, then run prim doctor. Host timeout behavior is not verified.`
44270
44270
  };
44271
44271
  }
44272
44272
  const version = /\b(\d+\.\d+\.\d+(?:-[\w.-]+)?)\b/u.exec(output)?.[1];
44273
44273
  if (host === "hermes") {
44274
- const project = /^\s*Project:\s*(.+?)\s*$/mu.exec(output)?.[1];
44275
- try {
44276
- if (project) {
44277
- const source = readFileSync12(join14(project, "agent", "shell_hooks.py"), "utf8");
44278
- if (/fail_closed\s*:\s*bool/u.test(source) && /["']fail_closed["']/u.test(source)) {
44279
- return {
44280
- host,
44281
- version,
44282
- status: "supported",
44283
- detail: "Installed Hermes exposes fail_closed shell hooks; Primitive configures fail_closed: true and the 300-second maximum timeout."
44284
- };
44285
- }
44286
- return {
44287
- host,
44288
- version,
44289
- status: "unsupported",
44290
- detail: "Installed Hermes does not expose fail_closed shell hooks. Upgrade Hermes before relying on host timeout/crash protection; then run prim hermes install and prim doctor."
44291
- };
44292
- }
44293
- } catch {
44294
- }
44295
44274
  return {
44296
44275
  host,
44297
44276
  version,
44298
- status: "unknown",
44299
- detail: "Cannot verify installed Hermes fail_closed support. Upgrade to a version supporting fail_closed, expose its Project path through hermes version, then run prim doctor."
44277
+ status: "supported",
44278
+ detail: "Hermes gates use a two-second timeout and fail_closed: false. Only confirmed conflicts stop a tool."
44300
44279
  };
44301
44280
  }
44302
- const minimum = host === "claude" ? "2.1.295" : "3.24.9";
44281
+ const minimum = host === "claude" ? "2.1.284" : "3.24.9";
44303
44282
  const comparison = compareSemver(version, minimum);
44304
44283
  const status2 = comparison === void 0 ? "unknown" : comparison < 0 ? "unsupported" : "supported";
44305
44284
  return {
44306
44285
  host,
44307
44286
  version,
44308
44287
  status: status2,
44309
- detail: status2 === "supported" ? `${host} ${version} supports the configured ${host === "claude" ? 'onFailure: "block"' : "failClosed: true"} policy and 300-second timeout.` : `${host} ${version ?? "version unknown"}: upgrade to ${minimum} or newer ${host === "cursor" ? "(Primitive's verified failure-protection baseline) " : ""}before relying on host timeout/crash protection; then run prim ${host} install and prim doctor.`
44288
+ detail: status2 === "supported" ? `${host} ${version} supports the configured ${host === "claude" ? "default fail-open" : "failClosed: false"} policy and two-second timeout.` : `${host} ${version ?? "version unknown"}: upgrade to ${minimum} or newer ${host === "cursor" ? "(Primitive's verified host compatibility baseline) " : ""}before relying on host timeout behavior; then run prim ${host} install and prim doctor.`
44310
44289
  };
44311
44290
  }
44312
44291
  function reportFailureProtection(host) {
@@ -44314,7 +44293,7 @@ function reportFailureProtection(host) {
44314
44293
  console.error(`[prim] ${protection.detail}`);
44315
44294
  if (protection.status === "unsupported" || protection.status === "unknown") {
44316
44295
  console.error(
44317
- "[prim] Conflict Gate host failure protection is not ready; installed settings alone do not establish readiness."
44296
+ "[prim] Conflict Gate host compatibility is not verified; installed settings alone do not establish readiness."
44318
44297
  );
44319
44298
  }
44320
44299
  return protection;
@@ -44338,11 +44317,11 @@ var PRIM_BINS = [
44338
44317
  SESSION_END_BIN
44339
44318
  ];
44340
44319
  var JSON_INDENT = 2;
44341
- var USER_SCOPE_PATH = join15(homedir5(), ".claude", "settings.json");
44320
+ var USER_SCOPE_PATH = join14(homedir5(), ".claude", "settings.json");
44342
44321
  function projectRoot() {
44343
44322
  return gitToplevel() ?? process.cwd();
44344
44323
  }
44345
- var projectScopePath = () => join15(projectRoot(), ".claude", "settings.json");
44324
+ var projectScopePath = () => join14(projectRoot(), ".claude", "settings.json");
44346
44325
  var CAPTURE_EVENTS = [
44347
44326
  "SessionStart",
44348
44327
  "UserPromptSubmit",
@@ -44359,7 +44338,7 @@ function makeRegistration(event, matcher, bin, args = "") {
44359
44338
  matcher,
44360
44339
  bin,
44361
44340
  command: stableHookCommand(bin, args),
44362
- ...bin === GATE_BIN ? { timeout: 300, ...args.includes("--agent codex") ? {} : { onFailure: "block" } } : {}
44341
+ ...bin === GATE_BIN ? { timeout: 2 } : {}
44363
44342
  };
44364
44343
  }
44365
44344
  function makeDetachedRegistration(event, matcher, bin, args = "") {
@@ -44397,7 +44376,7 @@ function readSettings(path9) {
44397
44376
  if (!existsSync9(path9)) {
44398
44377
  return {};
44399
44378
  }
44400
- const raw = readFileSync13(path9, "utf-8");
44379
+ const raw = readFileSync12(path9, "utf-8");
44401
44380
  try {
44402
44381
  return JSON.parse(raw);
44403
44382
  } catch (err) {
@@ -44778,13 +44757,13 @@ ${line("project", result.project)}`);
44778
44757
 
44779
44758
  // src/commands/codex-install.ts
44780
44759
  import { homedir as homedir7 } from "os";
44781
- import { join as join17 } from "path";
44760
+ import { join as join16 } from "path";
44782
44761
 
44783
44762
  // src/lib/codex-host.ts
44784
44763
  import { lstatSync as lstatSync6, realpathSync as realpathSync4 } from "fs";
44785
44764
  import { connect } from "net";
44786
44765
  import { homedir as homedir6 } from "os";
44787
- import { isAbsolute as isAbsolute7, join as join16 } from "path";
44766
+ import { isAbsolute as isAbsolute7, join as join15 } from "path";
44788
44767
 
44789
44768
  // node_modules/.pnpm/ws@8.21.0/node_modules/ws/wrapper.mjs
44790
44769
  var import_stream = __toESM(require_stream(), 1);
@@ -44808,9 +44787,9 @@ async function inspectCodexHost(reload = false) {
44808
44787
  reload: reload ? "unavailable" : "not-requested",
44809
44788
  reason
44810
44789
  });
44811
- const root = process.env.CODEX_HOME ?? join16(homedir6(), ".codex");
44790
+ const root = process.env.CODEX_HOME ?? join15(homedir6(), ".codex");
44812
44791
  if (!isAbsolute7(root)) return unavailable("invalid-codex-home");
44813
- let socketPath = join16(root, "app-server-control", "app-server-control.sock");
44792
+ let socketPath = join15(root, "app-server-control", "app-server-control.sock");
44814
44793
  try {
44815
44794
  const alias = lstatSync6(socketPath);
44816
44795
  if (process.getuid && alias.uid !== process.getuid()) return unavailable("unsafe-host-socket");
@@ -44934,8 +44913,8 @@ var CODEX_REGISTRATIONS = [
44934
44913
  makeRegistration("PostToolUse", CODEX_POST_TOOL_MATCHER, POST_TOOL_USE_BIN2, CODEX_ARGS),
44935
44914
  makeRegistration("SessionStart", "*", SESSION_START_BIN2, CODEX_ARGS)
44936
44915
  ];
44937
- var userScopePath = () => join17(process.env.CODEX_HOME ?? join17(homedir7(), ".codex"), "hooks.json");
44938
- var projectScopePath2 = () => join17(projectRoot(), ".codex", "hooks.json");
44916
+ var userScopePath = () => join16(process.env.CODEX_HOME ?? join16(homedir7(), ".codex"), "hooks.json");
44917
+ var projectScopePath2 = () => join16(projectRoot(), ".codex", "hooks.json");
44939
44918
  function settingsPathFor2(scope) {
44940
44919
  return scope === "user" ? userScopePath() : projectScopePath2();
44941
44920
  }
@@ -45046,7 +45025,7 @@ function uncoveredWorktreeHooks(status2) {
45046
45025
  if (status2.user.present || status2.project.present) return null;
45047
45026
  const main = mainWorktreeRoot();
45048
45027
  if (main === null) return null;
45049
- const path9 = join17(main, ".codex", "hooks.json");
45028
+ const path9 = join16(main, ".codex", "hooks.json");
45050
45029
  return hasAnyHookRegistration2(readSettings(path9)) ? path9 : null;
45051
45030
  }
45052
45031
  function uncoveredWorktreeAdvice(path9) {
@@ -45129,9 +45108,9 @@ ${line("project", result.project)}`);
45129
45108
  }
45130
45109
 
45131
45110
  // src/commands/cursor-install.ts
45132
- import { existsSync as existsSync10, readFileSync as readFileSync14 } from "fs";
45111
+ import { existsSync as existsSync10, readFileSync as readFileSync13 } from "fs";
45133
45112
  import { homedir as homedir8 } from "os";
45134
- import { isAbsolute as isAbsolute8, join as join18 } from "path";
45113
+ import { isAbsolute as isAbsolute8, join as join17 } from "path";
45135
45114
  var CAPTURE_BIN3 = "prim-hook";
45136
45115
  var GATE_BIN3 = "prim-pre-tool-use";
45137
45116
  var POST_TOOL_BIN = "prim-post-tool-use";
@@ -45152,7 +45131,7 @@ var CURSOR_EVENTS = [
45152
45131
  ];
45153
45132
  var REGISTRATIONS2 = [
45154
45133
  ...CURSOR_EVENTS.map((event) => ({ event, bin: CAPTURE_BIN3 })),
45155
- { event: "preToolUse", bin: GATE_BIN3, matcher: "Write|Delete|Shell", timeout: 300 },
45134
+ { event: "preToolUse", bin: GATE_BIN3, matcher: "Write|Delete|Shell", timeout: 2 },
45156
45135
  { event: "postToolUse", bin: POST_TOOL_BIN },
45157
45136
  { event: "postToolUseFailure", bin: POST_TOOL_BIN },
45158
45137
  { event: "sessionStart", bin: SESSION_START_BIN3 },
@@ -45162,14 +45141,14 @@ function cursorConfigDirectory(env4 = process.env, home = homedir8(), platform2
45162
45141
  const explicit = env4.CURSOR_CONFIG_DIR?.trim();
45163
45142
  if (explicit && isAbsolute8(explicit)) return explicit;
45164
45143
  const xdg = env4.XDG_CONFIG_HOME?.trim();
45165
- if (platform2 !== "darwin" && xdg && isAbsolute8(xdg)) return join18(xdg, "cursor");
45166
- return join18(home, ".cursor");
45144
+ if (platform2 !== "darwin" && xdg && isAbsolute8(xdg)) return join17(xdg, "cursor");
45145
+ return join17(home, ".cursor");
45167
45146
  }
45168
45147
  function cursorHooksPath(scope, root = projectRoot()) {
45169
- return scope === "user" ? join18(cursorConfigDirectory(), "hooks.json") : join18(root, ".cursor", "hooks.json");
45148
+ return scope === "user" ? join17(cursorConfigDirectory(), "hooks.json") : join17(root, ".cursor", "hooks.json");
45170
45149
  }
45171
45150
  function cursorCliConfigPath() {
45172
- return join18(cursorConfigDirectory(), "cli-config.json");
45151
+ return join17(cursorConfigDirectory(), "cli-config.json");
45173
45152
  }
45174
45153
  function plainObject(value) {
45175
45154
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -45178,7 +45157,7 @@ function readCursorHooks(path9) {
45178
45157
  if (!existsSync10(path9)) return {};
45179
45158
  let parsed;
45180
45159
  try {
45181
- parsed = JSON.parse(readFileSync14(path9, "utf8"));
45160
+ parsed = JSON.parse(readFileSync13(path9, "utf8"));
45182
45161
  } catch {
45183
45162
  throw new Error(`invalid Cursor hooks JSON at ${path9}`);
45184
45163
  }
@@ -45200,7 +45179,7 @@ function readObject(path9) {
45200
45179
  if (!existsSync10(path9)) return {};
45201
45180
  let parsed;
45202
45181
  try {
45203
- parsed = JSON.parse(readFileSync14(path9, "utf8"));
45182
+ parsed = JSON.parse(readFileSync13(path9, "utf8"));
45204
45183
  } catch {
45205
45184
  throw new Error(`invalid Cursor CLI config JSON at ${path9}`);
45206
45185
  }
@@ -45234,7 +45213,7 @@ function hookFor(registration, scope) {
45234
45213
  command: commandFor(registration, scope),
45235
45214
  ...registration.matcher ? { matcher: registration.matcher } : {},
45236
45215
  ...registration.timeout ? { timeout: registration.timeout } : {},
45237
- ...registration.bin === GATE_BIN3 ? { failClosed: true } : {}
45216
+ ...registration.bin === GATE_BIN3 ? { failClosed: false } : {}
45238
45217
  };
45239
45218
  }
45240
45219
  function exactHook(entry, registration, scope) {
@@ -45421,12 +45400,12 @@ function registerCursorCommands(program3) {
45421
45400
 
45422
45401
  // src/commands/daemon.ts
45423
45402
  import { spawn as spawn3 } from "child_process";
45424
- import { closeSync as closeSync4, existsSync as existsSync12, mkdirSync as mkdirSync10, openSync as openSync4, readFileSync as readFileSync16, unlinkSync as unlinkSync4 } from "fs";
45425
- import { join as join21 } from "path";
45403
+ import { closeSync as closeSync4, existsSync as existsSync12, mkdirSync as mkdirSync10, openSync as openSync4, readFileSync as readFileSync15, unlinkSync as unlinkSync4 } from "fs";
45404
+ import { join as join20 } from "path";
45426
45405
 
45427
45406
  // src/daemon/latest-bootstrap.ts
45428
45407
  import { spawn as spawn2 } from "child_process";
45429
- import { join as join19 } from "path";
45408
+ import { join as join18 } from "path";
45430
45409
  var LATEST_BOOTSTRAP_TIMEOUT_MS = 45e3;
45431
45410
  var LATEST_BOOTSTRAP_LOCK_NAME = "daemon-latest.lock";
45432
45411
  async function runPinnedEnsure(options) {
@@ -45467,7 +45446,7 @@ async function runPinnedEnsure(options) {
45467
45446
  });
45468
45447
  }
45469
45448
  async function runLatestDaemonBootstrap(ensureCurrent, options = {}) {
45470
- const lockPath = options.lockPath ?? join19(
45449
+ const lockPath = options.lockPath ?? join18(
45471
45450
  primConfigDirectory({ env: options.env, homeDir: options.homeDir }),
45472
45451
  LATEST_BOOTSTRAP_LOCK_NAME
45473
45452
  );
@@ -45501,7 +45480,7 @@ import {
45501
45480
  lstatSync as lstatSync8,
45502
45481
  mkdirSync as mkdirSync9,
45503
45482
  mkdtempSync as mkdtempSync2,
45504
- readFileSync as readFileSync15,
45483
+ readFileSync as readFileSync14,
45505
45484
  readdirSync as readdirSync4,
45506
45485
  readlinkSync,
45507
45486
  realpathSync as realpathSync5,
@@ -45512,7 +45491,7 @@ import {
45512
45491
  writeFileSync as writeFileSync7
45513
45492
  } from "fs";
45514
45493
  import { homedir as homedir9 } from "os";
45515
- import { basename as basename3, dirname as dirname10, isAbsolute as isAbsolute9, join as join20, resolve as resolve7 } from "path";
45494
+ import { basename as basename3, dirname as dirname10, isAbsolute as isAbsolute9, join as join19, resolve as resolve7 } from "path";
45516
45495
 
45517
45496
  // src/lib/bounded-file.ts
45518
45497
  import { constants as constants4, closeSync as closeSync3, fstatSync, lstatSync as lstatSync7, openSync as openSync3, readSync } from "fs";
@@ -45594,31 +45573,31 @@ var LaunchctlError = class extends Error {
45594
45573
  function xdgDataHome(options) {
45595
45574
  const home = options.homeDir ?? homedir9();
45596
45575
  const configured = (options.env ?? process.env).XDG_DATA_HOME;
45597
- return configured && isAbsolute9(configured) ? configured : join20(home, ".local", "share");
45576
+ return configured && isAbsolute9(configured) ? configured : join19(home, ".local", "share");
45598
45577
  }
45599
45578
  function runtimePaths(options = {}) {
45600
- const dataDir = join20(xdgDataHome(options), "prim");
45601
- const runtimeDir = join20(dataDir, "runtime");
45602
- const currentLink = join20(runtimeDir, "current");
45579
+ const dataDir = join19(xdgDataHome(options), "prim");
45580
+ const runtimeDir = join19(dataDir, "runtime");
45581
+ const currentLink = join19(runtimeDir, "current");
45603
45582
  return {
45604
45583
  dataDir,
45605
45584
  runtimeDir,
45606
- releasesDir: join20(runtimeDir, "releases"),
45585
+ releasesDir: join19(runtimeDir, "releases"),
45607
45586
  currentLink,
45608
- statuslineLauncher: join20(runtimeDir, "prim-statusline"),
45609
- disabledMarker: join20(dataDir, "daemon.disabled"),
45610
- lifecycleLockDir: join20(dataDir, "daemon.lifecycle.lock")
45587
+ statuslineLauncher: join19(runtimeDir, "prim-statusline"),
45588
+ disabledMarker: join19(dataDir, "daemon.disabled"),
45589
+ lifecycleLockDir: join19(dataDir, "daemon.lifecycle.lock")
45611
45590
  };
45612
45591
  }
45613
45592
  function daemonControlPaths(options = {}) {
45614
45593
  const configDir = primConfigDirectory(options);
45615
45594
  const legacy = runtimePaths(options);
45616
45595
  return {
45617
- launcher: join20(configDir, `prim-daemon-launcher-v${LAUNCHER_SCHEMA_VERSION}`),
45618
- disabledMarker: join20(configDir, "daemon.disabled"),
45619
- driftHealMarker: join20(configDir, DRIFT_HEAL_MARKER),
45620
- driftHealClaim: join20(configDir, "daemon-drift-heal.lock"),
45621
- lifecycleLockDir: join20(configDir, "daemon.lifecycle.lock"),
45596
+ launcher: join19(configDir, `prim-daemon-launcher-v${LAUNCHER_SCHEMA_VERSION}`),
45597
+ disabledMarker: join19(configDir, "daemon.disabled"),
45598
+ driftHealMarker: join19(configDir, DRIFT_HEAL_MARKER),
45599
+ driftHealClaim: join19(configDir, "daemon-drift-heal.lock"),
45600
+ lifecycleLockDir: join19(configDir, "daemon.lifecycle.lock"),
45622
45601
  legacyDisabledMarker: legacy.disabledMarker,
45623
45602
  legacyLifecycleLockDir: legacy.lifecycleLockDir
45624
45603
  };
@@ -45626,10 +45605,10 @@ function daemonControlPaths(options = {}) {
45626
45605
  function findPackageVersion(entryFile) {
45627
45606
  let dir = dirname10(resolve7(entryFile));
45628
45607
  for (let depth = 0; depth < 6; depth++) {
45629
- const packagePath = join20(dir, "package.json");
45608
+ const packagePath = join19(dir, "package.json");
45630
45609
  if (existsSync11(packagePath)) {
45631
45610
  try {
45632
- const manifest = JSON.parse(readFileSync15(packagePath, "utf8"));
45611
+ const manifest = JSON.parse(readFileSync14(packagePath, "utf8"));
45633
45612
  if (manifest.name === "@primitive.ai/prim" && manifest.version) {
45634
45613
  return manifest.version;
45635
45614
  }
@@ -45644,7 +45623,7 @@ function findPackageVersion(entryFile) {
45644
45623
  }
45645
45624
  function readRuntimeManifest(path9) {
45646
45625
  try {
45647
- const parsed = JSON.parse(readFileSync15(path9, "utf8"));
45626
+ const parsed = JSON.parse(readFileSync14(path9, "utf8"));
45648
45627
  if (parsed.schemaVersion !== RUNTIME_SCHEMA_VERSION || typeof parsed.version !== "string" || typeof parsed.nodePath !== "string" || parsed.daemonFile !== "prim-daemon-server" || typeof parsed.daemonSha256 !== "string" || !/^[a-f0-9]{64}$/u.test(parsed.daemonSha256)) {
45649
45628
  return null;
45650
45629
  }
@@ -45660,10 +45639,10 @@ function exactKeys2(value, expected) {
45660
45639
  return actual.length === wanted.length && actual.every((key, index) => key === wanted[index]);
45661
45640
  }
45662
45641
  function readOwnedRuntimeManifest(releaseDir) {
45663
- const manifestPath = join20(releaseDir, "manifest.json");
45664
- const daemonPath = join20(releaseDir, "prim-daemon-server");
45642
+ const manifestPath = join19(releaseDir, "manifest.json");
45643
+ const daemonPath = join19(releaseDir, "prim-daemon-server");
45665
45644
  try {
45666
- const raw = readFileSync15(manifestPath, "utf8");
45645
+ const raw = readFileSync14(manifestPath, "utf8");
45667
45646
  const parsed = JSON.parse(raw);
45668
45647
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
45669
45648
  if (!exactKeys2(parsed, [
@@ -45707,7 +45686,7 @@ function sameRuntime(current, desired, daemonPath) {
45707
45686
  }
45708
45687
  }
45709
45688
  function sha256File(path9) {
45710
- return createHash8("sha256").update(readFileSync15(path9)).digest("hex");
45689
+ return createHash8("sha256").update(readFileSync14(path9)).digest("hex");
45711
45690
  }
45712
45691
  function atomicSymlink(target, linkPath) {
45713
45692
  const tempLink = `${linkPath}.tmp-${process.pid}-${createHash8("sha256").update(`${target}\0${Date.now()}\0${Math.random()}`).digest("hex").slice(0, 12)}`;
@@ -45740,8 +45719,8 @@ function stageRuntime(options = {}) {
45740
45719
  currentRelease = realpathSync5(paths.currentLink);
45741
45720
  } catch {
45742
45721
  }
45743
- const current = currentRelease ? readRuntimeManifest(join20(currentRelease, "manifest.json")) : null;
45744
- const currentDaemon = currentRelease ? join20(currentRelease, desired.daemonFile) : "";
45722
+ const current = currentRelease ? readRuntimeManifest(join19(currentRelease, "manifest.json")) : null;
45723
+ const currentDaemon = currentRelease ? join19(currentRelease, desired.daemonFile) : "";
45745
45724
  if (currentRelease && sameRuntime(current, desired, currentDaemon)) {
45746
45725
  const manifest = current;
45747
45726
  atomicWrite4(
@@ -45759,17 +45738,17 @@ function stageRuntime(options = {}) {
45759
45738
  mkdirSync9(paths.releasesDir, { recursive: true, mode: RUNTIME_DIR_MODE });
45760
45739
  chmodSync5(paths.runtimeDir, RUNTIME_DIR_MODE);
45761
45740
  chmodSync5(paths.releasesDir, RUNTIME_DIR_MODE);
45762
- const stagingDir = mkdtempSync2(join20(paths.releasesDir, ".stage-"));
45741
+ const stagingDir = mkdtempSync2(join19(paths.releasesDir, ".stage-"));
45763
45742
  chmodSync5(stagingDir, RUNTIME_DIR_MODE);
45764
45743
  let releaseDir;
45765
45744
  try {
45766
- const daemonTarget = join20(stagingDir, desired.daemonFile);
45745
+ const daemonTarget = join19(stagingDir, desired.daemonFile);
45767
45746
  copyFileSync2(daemonSource, daemonTarget);
45768
45747
  chmodSync5(daemonTarget, RUNTIME_FILE_MODE);
45769
45748
  if (sha256File(daemonTarget) !== desired.daemonSha256) {
45770
45749
  throw new Error("cannot stage runtime: daemon bundle changed while it was copied");
45771
45750
  }
45772
- const manifestTarget = join20(stagingDir, "manifest.json");
45751
+ const manifestTarget = join19(stagingDir, "manifest.json");
45773
45752
  writeFileSync7(manifestTarget, `${JSON.stringify(desired, null, 2)}
45774
45753
  `, {
45775
45754
  encoding: "utf8",
@@ -45777,10 +45756,10 @@ function stageRuntime(options = {}) {
45777
45756
  flag: "wx"
45778
45757
  });
45779
45758
  const releaseName = `release-${createHash8("sha256").update(`${version}\0${nodePath}\0${desired.stagedAt}\0${process.pid}\0${Math.random()}`).digest("hex").slice(0, 16)}`;
45780
- releaseDir = join20(paths.releasesDir, releaseName);
45759
+ releaseDir = join19(paths.releasesDir, releaseName);
45781
45760
  renameSync4(stagingDir, releaseDir);
45782
45761
  releaseDir = realpathSync5(releaseDir);
45783
- atomicSymlink(join20("releases", releaseName), paths.currentLink);
45762
+ atomicSymlink(join19("releases", releaseName), paths.currentLink);
45784
45763
  atomicWrite4(
45785
45764
  paths.statuslineLauncher,
45786
45765
  statuslineLauncherContent(desired.version, options),
@@ -45794,14 +45773,14 @@ function stageRuntime(options = {}) {
45794
45773
  changed: true,
45795
45774
  manifest: desired,
45796
45775
  paths,
45797
- daemonPath: join20(releaseDir, desired.daemonFile)
45776
+ daemonPath: join19(releaseDir, desired.daemonFile)
45798
45777
  };
45799
45778
  }
45800
45779
  function shellQuote2(value) {
45801
45780
  return `'${value.replaceAll("'", `'"'"'`)}'`;
45802
45781
  }
45803
45782
  function statuslineLauncherContent(version, options = {}) {
45804
- const socketPath = join20(primConfigDirectory(options), "sock");
45783
+ const socketPath = join19(primConfigDirectory(options), "sock");
45805
45784
  const fallback = `primitive ${version} (daemon: down)`;
45806
45785
  return `#!/bin/sh
45807
45786
  response=$(
@@ -45833,7 +45812,7 @@ function lstatIfPresent3(path9) {
45833
45812
  }
45834
45813
  function driftHealMarkerTemporaries(configDir) {
45835
45814
  try {
45836
- return readdirSync4(configDir).filter((entry) => DRIFT_HEAL_MARKER_TEMPORARY_RE.test(entry)).map((entry) => join20(configDir, entry));
45815
+ return readdirSync4(configDir).filter((entry) => DRIFT_HEAL_MARKER_TEMPORARY_RE.test(entry)).map((entry) => join19(configDir, entry));
45837
45816
  } catch (error) {
45838
45817
  const code = error.code;
45839
45818
  if (code === "ENOENT" || code === "ENOTDIR") return [];
@@ -45846,12 +45825,12 @@ function assertDriftHealClaim(path9) {
45846
45825
  if (!claim.isDirectory() || readdirSync4(path9).some((entry) => entry !== DRIFT_HEAL_CLAIM_OWNER)) {
45847
45826
  throw new Error(`refusing to remove unrecognized daemon drift-heal claim at ${path9}`);
45848
45827
  }
45849
- assertRegularFile(join20(path9, DRIFT_HEAL_CLAIM_OWNER), "daemon drift-heal claim owner");
45828
+ assertRegularFile(join19(path9, DRIFT_HEAL_CLAIM_OWNER), "daemon drift-heal claim owner");
45850
45829
  }
45851
45830
  function assertExactFile(path9, expected, label2) {
45852
45831
  if (!lstatIfPresent3(path9)) return;
45853
45832
  assertRegularFile(path9, label2);
45854
- if (readFileSync15(path9, "utf8") !== expected) {
45833
+ if (readFileSync14(path9, "utf8") !== expected) {
45855
45834
  throw new Error(`refusing to remove unrecognized ${label2} at ${path9}`);
45856
45835
  }
45857
45836
  }
@@ -45860,12 +45839,12 @@ function assertOwnedDaemonRuntime(options) {
45860
45839
  const control = daemonControlPaths(options);
45861
45840
  const configDir = primConfigDirectory(options);
45862
45841
  const service = process.platform === "darwin" ? launchdPaths(options) : void 0;
45863
- const logPath = service?.logPath ?? join20(configDir, "daemon.log");
45842
+ const logPath = service?.logPath ?? join19(configDir, "daemon.log");
45864
45843
  for (const activeArtifact of [
45865
- join20(configDir, "daemon.pid"),
45866
- join20(configDir, "sock"),
45867
- join20(configDir, "daemon.lock"),
45868
- join20(configDir, "client-instance.lock")
45844
+ join19(configDir, "daemon.pid"),
45845
+ join19(configDir, "sock"),
45846
+ join19(configDir, "daemon.lock"),
45847
+ join19(configDir, "client-instance.lock")
45869
45848
  ]) {
45870
45849
  if (lstatIfPresent3(activeArtifact)) {
45871
45850
  throw new Error(`refusing runtime removal while daemon state remains at ${activeArtifact}`);
@@ -45891,11 +45870,11 @@ function assertOwnedDaemonRuntime(options) {
45891
45870
  assertRegularFile(temporary, "daemon drift-heal marker temporary");
45892
45871
  }
45893
45872
  assertDriftHealClaim(control.driftHealClaim);
45894
- assertRegularFile(join20(configDir, "daemon-health.json"), "daemon health snapshot");
45895
- assertRegularFile(join20(configDir, "client_instance_id"), "daemon client instance id");
45873
+ assertRegularFile(join19(configDir, "daemon-health.json"), "daemon health snapshot");
45874
+ assertRegularFile(join19(configDir, "client_instance_id"), "daemon client instance id");
45896
45875
  if (service && lstatIfPresent3(service.plistPath)) {
45897
45876
  assertRegularFile(service.plistPath, "launchd property list");
45898
- if (readFileSync15(service.plistPath, "utf8") !== ownedLaunchAgentPlist(options, logPath)) {
45877
+ if (readFileSync14(service.plistPath, "utf8") !== ownedLaunchAgentPlist(options, logPath)) {
45899
45878
  throw new Error(
45900
45879
  `refusing to remove unrecognized launchd property list at ${service.plistPath}`
45901
45880
  );
@@ -45920,7 +45899,7 @@ function assertOwnedDaemonRuntime(options) {
45920
45899
  throw new Error(`refusing to remove non-directory daemon releases at ${runtime.releasesDir}`);
45921
45900
  }
45922
45901
  for (const entry of readdirSync4(runtime.releasesDir, { withFileTypes: true })) {
45923
- const releaseDir = join20(runtime.releasesDir, entry.name);
45902
+ const releaseDir = join19(runtime.releasesDir, entry.name);
45924
45903
  const manifest = entry.isDirectory() && RUNTIME_RELEASE_RE.test(entry.name) ? readOwnedRuntimeManifest(releaseDir) : null;
45925
45904
  if (!manifest) {
45926
45905
  throw new Error(`refusing to remove unrecognized daemon release ${releaseDir}`);
@@ -45938,7 +45917,7 @@ function assertOwnedDaemonRuntime(options) {
45938
45917
  }
45939
45918
  const target = readlinkSync(runtime.currentLink);
45940
45919
  const releaseName = basename3(target);
45941
- if (target !== join20("releases", releaseName) || !RUNTIME_RELEASE_RE.test(releaseName)) {
45920
+ if (target !== join19("releases", releaseName) || !RUNTIME_RELEASE_RE.test(releaseName)) {
45942
45921
  throw new Error(
45943
45922
  `refusing to remove malformed daemon runtime selector ${runtime.currentLink}`
45944
45923
  );
@@ -45966,7 +45945,7 @@ async function removeDaemonRuntime(options = {}) {
45966
45945
  const control = daemonControlPaths(options);
45967
45946
  const configDir = primConfigDirectory(options);
45968
45947
  const service = process.platform === "darwin" ? launchdPaths(options) : void 0;
45969
- const logPath = service?.logPath ?? join20(configDir, "daemon.log");
45948
+ const logPath = service?.logPath ?? join19(configDir, "daemon.log");
45970
45949
  const ownedArtifacts = [
45971
45950
  runtime.runtimeDir,
45972
45951
  control.launcher,
@@ -45977,8 +45956,8 @@ async function removeDaemonRuntime(options = {}) {
45977
45956
  control.driftHealClaim,
45978
45957
  ...service ? [service.plistPath] : [],
45979
45958
  logPath,
45980
- join20(configDir, "daemon-health.json"),
45981
- join20(configDir, "client_instance_id")
45959
+ join19(configDir, "daemon-health.json"),
45960
+ join19(configDir, "client_instance_id")
45982
45961
  ];
45983
45962
  if (!ownedArtifacts.some((path9) => lstatIfPresent3(path9))) {
45984
45963
  return { changed: false, runtimePaths: runtime };
@@ -46058,7 +46037,7 @@ function readDaemonLauncherFile(path9) {
46058
46037
  function readUsableDaemonConfig(path9) {
46059
46038
  const config = readDaemonLauncher(path9);
46060
46039
  if (!config) return null;
46061
- const manifest = readRuntimeManifest(join20(dirname10(config.daemonPath), "manifest.json"));
46040
+ const manifest = readRuntimeManifest(join19(dirname10(config.daemonPath), "manifest.json"));
46062
46041
  try {
46063
46042
  accessSync2(config.nodePath, constants5.X_OK);
46064
46043
  return manifest?.version === config.runtimeVersion && manifest.nodePath === config.nodePath && manifest.daemonSha256 === sha256File(config.daemonPath) ? config : null;
@@ -46111,8 +46090,8 @@ function launchdPaths(options = {}) {
46111
46090
  return {
46112
46091
  domainTarget: `gui/${uid}`,
46113
46092
  serviceTarget: `gui/${uid}/${label2}`,
46114
- plistPath: join20(home, "Library", "LaunchAgents", `${label2}.plist`),
46115
- logPath: join20(configDir, "daemon.log")
46093
+ plistPath: join19(home, "Library", "LaunchAgents", `${label2}.plist`),
46094
+ logPath: join19(configDir, "daemon.log")
46116
46095
  };
46117
46096
  }
46118
46097
  var runLaunchctl = (args, timeoutMs2 = COMMAND_TIMEOUT_MS) => {
@@ -46145,7 +46124,7 @@ function getLaunchdService(options = {}) {
46145
46124
  }
46146
46125
  function atomicWrite4(path9, content2, mode, validate4) {
46147
46126
  try {
46148
- if (readFileSync15(path9, "utf8") === content2) {
46127
+ if (readFileSync14(path9, "utf8") === content2) {
46149
46128
  chmodSync5(path9, mode);
46150
46129
  validate4?.(path9, COMMAND_TIMEOUT_MS);
46151
46130
  return false;
@@ -46194,7 +46173,7 @@ function canonicalProspectivePath(path9) {
46194
46173
  ancestor = parent;
46195
46174
  }
46196
46175
  try {
46197
- return join20(realpathSync5(ancestor), ...suffix);
46176
+ return join19(realpathSync5(ancestor), ...suffix);
46198
46177
  } catch {
46199
46178
  return resolve7(path9);
46200
46179
  }
@@ -46209,10 +46188,10 @@ async function withDaemonLifecycleLock(operation, options = {}) {
46209
46188
  );
46210
46189
  }
46211
46190
  async function stopVerifiedLegacyDaemon(options, deadlineMs, nowMs, sleep2) {
46212
- const pidPath = join20(primConfigDirectory(options), "daemon.pid");
46191
+ const pidPath = join19(primConfigDirectory(options), "daemon.pid");
46213
46192
  let pid;
46214
46193
  try {
46215
- pid = Number(readFileSync15(pidPath, "utf8").trim());
46194
+ pid = Number(readFileSync14(pidPath, "utf8").trim());
46216
46195
  } catch {
46217
46196
  throw new Error("an unsupervised daemon answered, but it has no verifiable pidfile");
46218
46197
  }
@@ -46501,7 +46480,7 @@ async function ensureMacDaemonLocked(options) {
46501
46480
  const configuredApiUrl = (options.env ?? process.env).PRIM_API_URL;
46502
46481
  const apiUrl = configuredApiUrl ? normalizeApiUrl(configuredApiUrl) || void 0 : void 0;
46503
46482
  const configDir = primConfigDirectory(options);
46504
- const legacyDefaultConfigDir = join20(options.homeDir ?? homedir9(), ".config", "prim");
46483
+ const legacyDefaultConfigDir = join19(options.homeDir ?? homedir9(), ".config", "prim");
46505
46484
  const launcherConfigDir = configDir === legacyDefaultConfigDir ? void 0 : configDir;
46506
46485
  if (retainSelected && selected) {
46507
46486
  const usable = readUsableDaemonConfig(control.launcher);
@@ -46808,9 +46787,9 @@ function formatStatusline(version, snapshot, resolveIngestionStatus, options = {
46808
46787
  // src/commands/daemon.ts
46809
46788
  var DAEMON_BIN = "prim-daemon-server";
46810
46789
  var CONFIG_DIR = primConfigDirectory();
46811
- var PID_PATH = join21(CONFIG_DIR, "daemon.pid");
46812
- var SOCK_PATH2 = join21(CONFIG_DIR, "sock");
46813
- var LOG_PATH = join21(CONFIG_DIR, "daemon.log");
46790
+ var PID_PATH = join20(CONFIG_DIR, "daemon.pid");
46791
+ var SOCK_PATH2 = join20(CONFIG_DIR, "sock");
46792
+ var LOG_PATH = join20(CONFIG_DIR, "daemon.log");
46814
46793
  var CONFIG_DIR_MODE2 = 448;
46815
46794
  var LOG_FILE_MODE = 384;
46816
46795
  var STOP_TIMEOUT_MS = 5e3;
@@ -46855,7 +46834,7 @@ function readPidfile() {
46855
46834
  if (!existsSync12(PID_PATH)) {
46856
46835
  return null;
46857
46836
  }
46858
- const raw = readFileSync16(PID_PATH, "utf-8").trim();
46837
+ const raw = readFileSync15(PID_PATH, "utf-8").trim();
46859
46838
  const pid = Number(raw);
46860
46839
  if (!Number.isInteger(pid) || pid <= 0) {
46861
46840
  return null;
@@ -46883,7 +46862,7 @@ function openDaemonLog(configDir = CONFIG_DIR) {
46883
46862
  if (!existsSync12(configDir)) {
46884
46863
  mkdirSync10(configDir, { recursive: true, mode: CONFIG_DIR_MODE2 });
46885
46864
  }
46886
- return openSync4(join21(configDir, "daemon.log"), "a", LOG_FILE_MODE);
46865
+ return openSync4(join20(configDir, "daemon.log"), "a", LOG_FILE_MODE);
46887
46866
  }
46888
46867
  async function waitForReady() {
46889
46868
  const deadline = Date.now() + READY_TIMEOUT_MS;
@@ -49502,8 +49481,8 @@ import { setTimeout as delay2 } from "timers/promises";
49502
49481
  import { Buffer as Buffer2 } from "buffer";
49503
49482
 
49504
49483
  // src/hooks/redact.ts
49505
- import { existsSync as existsSync13, readFileSync as readFileSync17, statSync as statSync4 } from "fs";
49506
- import { join as join22 } from "path";
49484
+ import { existsSync as existsSync13, readFileSync as readFileSync16, statSync as statSync4 } from "fs";
49485
+ import { join as join21 } from "path";
49507
49486
  import { Worker } from "worker_threads";
49508
49487
  var USER_HOME_RULES = [
49509
49488
  {
@@ -58192,6 +58171,14 @@ function hasCompleteCoverage(response) {
58192
58171
  }
58193
58172
  return coverage.status === "completed" && coverage.discoveryComplete && coverage.candidateCount === coverage.evaluatedCount + coverage.bypassedCount && coverage.submittedCount === coverage.evaluatedCount && coverage.semanticBatchCount === coverage.completedSemanticBatchCount;
58194
58173
  }
58174
+ function hasConfirmedConflict(response) {
58175
+ const coverage = response.evaluationCoverage;
58176
+ return (response.state === "completed" || response.state === "processing" || response.state === "paused") && response.conflicts.length > 0 && coverage.discoveryComplete && (response.state !== "completed" || hasCompleteCoverage(response)) && coverage.evaluatedCount <= coverage.candidateCount && coverage.evaluatedCount > 0 && coverage.completedSemanticBatchCount > 0 && (coverage.status === "partial" || coverage.status === "completed") && ["ask", "block", "warn"].includes(response.verdict) && [
58177
+ "high_confidence_contradiction",
58178
+ "aged_high_confidence_contradiction",
58179
+ "provisional_or_uncertain_contradiction"
58180
+ ].includes(response.reasonCode);
58181
+ }
58195
58182
  function isNoTargetsSkip(response) {
58196
58183
  const coverage = response.evaluationCoverage;
58197
58184
  return response.state === "completed" && response.verdict === "allow" && response.reasonCode === "no_targets_skipped" && response.checkId === void 0 && response.evaluationId === void 0 && response.conflicts.length === 0 && response.bypassed.length === 0 && coverage.status === "completed" && coverage.discoveryComplete && coverage.candidateCount === 0 && coverage.submittedCount === 0 && coverage.evaluatedCount === 0 && coverage.bypassedCount === 0 && coverage.semanticBatchCount === 0 && coverage.completedSemanticBatchCount === 0;
@@ -58271,7 +58258,8 @@ async function waitForPreflight(operation, options = {}) {
58271
58258
  );
58272
58259
  checkId = response.checkId;
58273
58260
  evaluationId = response.evaluationId;
58274
- if (response.state !== "processing") return response;
58261
+ if (response.state !== "processing" || options.stopOnConflict && hasConfirmedConflict(response))
58262
+ return response;
58275
58263
  const progress = JSON.stringify(response.evaluationCoverage);
58276
58264
  if (progress !== lastProgress) options.onProgress?.(response);
58277
58265
  lastProgress = progress;
@@ -59001,7 +58989,7 @@ Diff.prototype = {
59001
58989
  tokenize: function tokenize(value) {
59002
58990
  return value.split("");
59003
58991
  },
59004
- join: function join23(chars) {
58992
+ join: function join22(chars) {
59005
58993
  return chars.join("");
59006
58994
  }
59007
58995
  };
@@ -59360,22 +59348,22 @@ function validate3(value) {
59360
59348
 
59361
59349
  // src/demo/diagnostics.ts
59362
59350
  import { existsSync as existsSync15 } from "fs";
59363
- import { join as join25 } from "path";
59351
+ import { join as join24 } from "path";
59364
59352
 
59365
59353
  // src/demo/state.ts
59366
59354
  import { createHash as createHash10, randomUUID as randomUUID3 } from "crypto";
59367
- import { existsSync as existsSync14, lstatSync as lstatSync9, readFileSync as readFileSync18, readdirSync as readdirSync5 } from "fs";
59368
- import { join as join24, resolve as resolve8 } from "path";
59355
+ import { existsSync as existsSync14, lstatSync as lstatSync9, readFileSync as readFileSync17, readdirSync as readdirSync5 } from "fs";
59356
+ import { join as join23, resolve as resolve8 } from "path";
59369
59357
  var RUN_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
59370
- var demoDirectory = () => join24(primConfigDirectory(), "demo");
59358
+ var demoDirectory = () => join23(primConfigDirectory(), "demo");
59371
59359
  var runPath = (id2) => {
59372
59360
  if (!RUN_ID.test(id2)) throw new Error("invalid demo run ID");
59373
- return join24(demoDirectory(), "runs", `${id2}.json`);
59361
+ return join23(demoDirectory(), "runs", `${id2}.json`);
59374
59362
  };
59375
59363
  function readDemoJson(path9) {
59376
59364
  const stat = lstatSync9(path9);
59377
59365
  if (!stat.isFile() || stat.size > 16384) throw new Error(`invalid demo state: ${path9}`);
59378
- return JSON.parse(readFileSync18(path9, "utf8"));
59366
+ return JSON.parse(readFileSync17(path9, "utf8"));
59379
59367
  }
59380
59368
  function saveDemoJson(path9, value) {
59381
59369
  atomicWriteFile(path9, `${JSON.stringify(value)}
@@ -59444,7 +59432,7 @@ function demoResumeCommand(run) {
59444
59432
  return [process.execPath, resolve8(process.argv[1]), "demo", "resume", run.id].map(quote).join(" ");
59445
59433
  }
59446
59434
  function onboardingFinished() {
59447
- const path9 = join24(demoDirectory(), "onboarding.json");
59435
+ const path9 = join23(demoDirectory(), "onboarding.json");
59448
59436
  if (!existsSync14(path9)) return false;
59449
59437
  const value = readDemoJson(path9);
59450
59438
  if (value.outcome !== "completed" && value.outcome !== "skipped") {
@@ -59453,10 +59441,10 @@ function onboardingFinished() {
59453
59441
  return true;
59454
59442
  }
59455
59443
  function finishOnboarding(outcome) {
59456
- saveDemoJson(join24(demoDirectory(), "onboarding.json"), { outcome });
59444
+ saveDemoJson(join23(demoDirectory(), "onboarding.json"), { outcome });
59457
59445
  }
59458
59446
  function pendingRuns() {
59459
- const path9 = join24(demoDirectory(), "runs");
59447
+ const path9 = join23(demoDirectory(), "runs");
59460
59448
  if (!existsSync14(path9)) return [];
59461
59449
  return readdirSync5(path9).filter((name2) => name2.endsWith(".json") && RUN_ID.test(name2.slice(0, -5))).map((name2) => name2.slice(0, -5)).filter((id2) => !["completed", "skipped"].includes(readRun(id2).stage));
59462
59450
  }
@@ -59465,12 +59453,12 @@ function sessionKey(agent, session) {
59465
59453
  }
59466
59454
  function exclusionPath(key) {
59467
59455
  if (!/^[0-9a-f]{64}$/u.test(key)) throw new Error("invalid demo session identity");
59468
- return join24(demoDirectory(), "excluded-sessions", `${key}.json`);
59456
+ return join23(demoDirectory(), "excluded-sessions", `${key}.json`);
59469
59457
  }
59470
59458
  var lockRunAsync = (id2, action) => withFileLock(`${runPath(id2)}.lock`, () => action(readRun(id2)), { timeoutMs: 500 });
59471
59459
 
59472
59460
  // src/demo/diagnostics.ts
59473
- var observationPath = (id2) => join25(demoDirectory(), "observations", `${id2}.json`);
59461
+ var observationPath = (id2) => join24(demoDirectory(), "observations", `${id2}.json`);
59474
59462
  function isolationDiagnostics(run) {
59475
59463
  let observation;
59476
59464
  let observationError;
@@ -59516,14 +59504,14 @@ import {
59516
59504
  existsSync as existsSync16,
59517
59505
  lstatSync as lstatSync10,
59518
59506
  mkdtempSync as mkdtempSync3,
59519
- readFileSync as readFileSync19,
59507
+ readFileSync as readFileSync18,
59520
59508
  readdirSync as readdirSync6,
59521
59509
  realpathSync as realpathSync6,
59522
59510
  rmdirSync,
59523
59511
  unlinkSync as unlinkSync5
59524
59512
  } from "fs";
59525
59513
  import { tmpdir } from "os";
59526
- import { basename as basename4, dirname as dirname11, join as join26 } from "path";
59514
+ import { basename as basename4, dirname as dirname11, join as join25 } from "path";
59527
59515
 
59528
59516
  // src/demo/scenario.ts
59529
59517
  var SAMPLE_NOTE = [
@@ -59601,9 +59589,9 @@ function inspectSandbox(run) {
59601
59589
  }
59602
59590
  const allowed = allowedFiles(run);
59603
59591
  for (const name2 of readdirSync6(sandbox.path)) {
59604
- const path9 = join26(sandbox.path, name2);
59592
+ const path9 = join25(sandbox.path, name2);
59605
59593
  const file = lstatSync10(path9);
59606
- if (!Object.hasOwn(allowed, name2) || !file.isFile() || file.nlink !== 1 || file.size > 16384 || !allowed[name2].includes(readFileSync19(path9, "utf8"))) {
59594
+ if (!Object.hasOwn(allowed, name2) || !file.isFile() || file.nlink !== 1 || file.size > 16384 || !allowed[name2].includes(readFileSync18(path9, "utf8"))) {
59607
59595
  throw new Error(`unexpected demo contents; retained ${sandbox.path}`);
59608
59596
  }
59609
59597
  }
@@ -59611,7 +59599,7 @@ function inspectSandbox(run) {
59611
59599
  }
59612
59600
  function createSandbox(run) {
59613
59601
  if (!run.sandbox) {
59614
- const path9 = mkdtempSync3(join26(realpathSync6(tmpdir()), "prim-demo-"));
59602
+ const path9 = mkdtempSync3(join25(realpathSync6(tmpdir()), "prim-demo-"));
59615
59603
  const stat = lstatSync10(path9);
59616
59604
  run.sandbox = { path: path9, device: stat.dev, inode: stat.ino };
59617
59605
  saveRun(run);
@@ -59624,17 +59612,17 @@ function createSandbox(run) {
59624
59612
  "decisions.json": decisionBytes(false)
59625
59613
  };
59626
59614
  for (const [name2, content2] of Object.entries(files)) {
59627
- const path9 = join26(root, name2);
59615
+ const path9 = join25(root, name2);
59628
59616
  if (!existsSync16(path9)) atomicWriteFile(path9, content2, { mode: 384 });
59629
59617
  }
59630
59618
  }
59631
59619
  function writeSample(run, name2, bytes) {
59632
59620
  const root = inspectSandbox(run);
59633
59621
  if (!allowedFiles(run)[name2].includes(bytes)) throw new Error("unsupported demo edit");
59634
- atomicWriteFile(join26(root, name2), bytes, { mode: 384 });
59622
+ atomicWriteFile(join25(root, name2), bytes, { mode: 384 });
59635
59623
  }
59636
59624
  function readSample(run, name2) {
59637
- return readFileSync19(join26(inspectSandbox(run), name2), "utf8");
59625
+ return readFileSync18(join25(inspectSandbox(run), name2), "utf8");
59638
59626
  }
59639
59627
  function cleanSandbox(run) {
59640
59628
  if (!run.sandbox) return;
@@ -59648,7 +59636,7 @@ function cleanSandbox(run) {
59648
59636
  const root = inspectSandbox(run);
59649
59637
  for (const name2 of readdirSync6(root)) {
59650
59638
  inspectSandbox(run);
59651
- unlinkSync5(join26(root, name2));
59639
+ unlinkSync5(join25(root, name2));
59652
59640
  }
59653
59641
  rmdirSync(root);
59654
59642
  run.sandbox = void 0;
@@ -60281,22 +60269,22 @@ import {
60281
60269
  mkdirSync as mkdirSync11,
60282
60270
  openSync as openSync5,
60283
60271
  opendirSync,
60284
- readFileSync as readFileSync21,
60272
+ readFileSync as readFileSync20,
60285
60273
  readSync as readSync2,
60286
60274
  readdirSync as readdirSync8
60287
60275
  } from "fs";
60288
- import { dirname as dirname13, join as join28 } from "path";
60276
+ import { dirname as dirname13, join as join27 } from "path";
60289
60277
 
60290
60278
  // src/drain-progress.ts
60291
60279
  import {
60292
60280
  chmodSync as chmodSync6,
60293
60281
  existsSync as existsSync17,
60294
- readFileSync as readFileSync20,
60282
+ readFileSync as readFileSync19,
60295
60283
  readdirSync as readdirSync7,
60296
60284
  rmSync as rmSync6,
60297
60285
  rmdirSync as rmdirSync2
60298
60286
  } from "fs";
60299
- import { basename as basename5, dirname as dirname12, join as join27 } from "path";
60287
+ import { basename as basename5, dirname as dirname12, join as join26 } from "path";
60300
60288
  var DIRECTORY_MODE3 = 448;
60301
60289
  var FILE_MODE2 = 384;
60302
60290
  var DRAIN_PROGRESS_DIRNAME = "drain-progress";
@@ -60305,10 +60293,10 @@ function rotationIdentity(stat) {
60305
60293
  return { size: stat.size, ino: stat.ino, dev: stat.dev };
60306
60294
  }
60307
60295
  function drainProgressDirectory(flushingPath) {
60308
- return join27(dirname12(flushingPath), DRAIN_PROGRESS_DIRNAME);
60296
+ return join26(dirname12(flushingPath), DRAIN_PROGRESS_DIRNAME);
60309
60297
  }
60310
60298
  function drainProgressPath(flushingPath) {
60311
- return join27(drainProgressDirectory(flushingPath), `${basename5(flushingPath)}.json`);
60299
+ return join26(drainProgressDirectory(flushingPath), `${basename5(flushingPath)}.json`);
60312
60300
  }
60313
60301
  function isByteCount(value) {
60314
60302
  return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
@@ -60316,7 +60304,7 @@ function isByteCount(value) {
60316
60304
  function drainResumeOffset(flushingPath, rotation) {
60317
60305
  let parsed;
60318
60306
  try {
60319
- parsed = JSON.parse(readFileSync20(drainProgressPath(flushingPath), "utf8"));
60307
+ parsed = JSON.parse(readFileSync19(drainProgressPath(flushingPath), "utf8"));
60320
60308
  } catch {
60321
60309
  return 0;
60322
60310
  }
@@ -60353,7 +60341,7 @@ function removeDrainCheckpoint(flushingPath) {
60353
60341
  removeEmptyDirectory(drainProgressDirectory(flushingPath));
60354
60342
  }
60355
60343
  function sweepOrphanedDrainCheckpoints(bucketDirectory) {
60356
- const directory = join27(bucketDirectory, DRAIN_PROGRESS_DIRNAME);
60344
+ const directory = join26(bucketDirectory, DRAIN_PROGRESS_DIRNAME);
60357
60345
  let names;
60358
60346
  try {
60359
60347
  names = readdirSync7(directory);
@@ -60362,11 +60350,11 @@ function sweepOrphanedDrainCheckpoints(bucketDirectory) {
60362
60350
  }
60363
60351
  for (const name2 of names) {
60364
60352
  const rotation = CHECKPOINT_NAME.exec(name2)?.[1];
60365
- if (rotation === void 0 || existsSync17(join27(bucketDirectory, rotation))) {
60353
+ if (rotation === void 0 || existsSync17(join26(bucketDirectory, rotation))) {
60366
60354
  continue;
60367
60355
  }
60368
60356
  try {
60369
- rmSync6(join27(directory, name2), { force: true });
60357
+ rmSync6(join26(directory, name2), { force: true });
60370
60358
  } catch {
60371
60359
  }
60372
60360
  }
@@ -60377,7 +60365,7 @@ function sweepOrphanedDrainCheckpoints(bucketDirectory) {
60377
60365
  }
60378
60366
 
60379
60367
  // src/journal.ts
60380
- var JOURNAL_DIR = join28(primConfigDirectory(), "moves");
60368
+ var JOURNAL_DIR = join27(primConfigDirectory(), "moves");
60381
60369
  var JOURNAL_BASENAME = "journal.ndjson";
60382
60370
  var JOURNAL_STATS_SAMPLE_BYTES = 64 * 1024;
60383
60371
  var PENDING_STATS_MAX_FILES = 128;
@@ -60389,7 +60377,7 @@ function envSlug(apiUrl) {
60389
60377
  return slug;
60390
60378
  }
60391
60379
  function currentEnvDir() {
60392
- return join28(JOURNAL_DIR, envSlug(getSiteUrl()));
60380
+ return join27(JOURNAL_DIR, envSlug(getSiteUrl()));
60393
60381
  }
60394
60382
  function parseMoves(content2) {
60395
60383
  const moves = [];
@@ -60408,7 +60396,7 @@ function readMovesFromPath(path9) {
60408
60396
  if (!existsSync18(path9)) {
60409
60397
  return [];
60410
60398
  }
60411
- return parseMoves(readFileSync21(path9, "utf-8"));
60399
+ return parseMoves(readFileSync20(path9, "utf-8"));
60412
60400
  }
60413
60401
  function listBuckets() {
60414
60402
  const out = [];
@@ -60420,7 +60408,7 @@ function listBuckets() {
60420
60408
  if (!entry.isDirectory()) {
60421
60409
  continue;
60422
60410
  }
60423
- const path9 = join28(envDir, entry.name, JOURNAL_BASENAME);
60411
+ const path9 = join27(envDir, entry.name, JOURNAL_BASENAME);
60424
60412
  if (existsSync18(path9)) {
60425
60413
  out.push({ bucket: entry.name, path: path9 });
60426
60414
  }
@@ -60497,7 +60485,7 @@ function listFlushingInDir(dir, bucket, options = {}) {
60497
60485
  entry = entries.readSync();
60498
60486
  continue;
60499
60487
  }
60500
- const path9 = join28(dir, entry.name);
60488
+ const path9 = join27(dir, entry.name);
60501
60489
  let sample;
60502
60490
  try {
60503
60491
  sample = sampleJournalFile(path9, remainingBytes, { fromDrainCheckpoint: true });
@@ -60535,7 +60523,7 @@ function listFlushing(options = {}) {
60535
60523
  break;
60536
60524
  }
60537
60525
  if (entry.isDirectory()) {
60538
- const found = listFlushingInDir(join28(envDir, entry.name), entry.name, {
60526
+ const found = listFlushingInDir(join27(envDir, entry.name), entry.name, {
60539
60527
  sampleBytes: remainingBytes,
60540
60528
  maxFiles: maxFiles - out.length
60541
60529
  });
@@ -60555,7 +60543,7 @@ function sweepOrphanedDrainProgress() {
60555
60543
  }
60556
60544
  for (const entry of readdirSync8(envDir, { withFileTypes: true })) {
60557
60545
  if (entry.isDirectory()) {
60558
- sweepOrphanedDrainCheckpoints(join28(envDir, entry.name));
60546
+ sweepOrphanedDrainCheckpoints(join27(envDir, entry.name));
60559
60547
  }
60560
60548
  }
60561
60549
  }
@@ -60604,9 +60592,9 @@ function pendingJournalStats() {
60604
60592
  }
60605
60593
 
60606
60594
  // src/commands/hermes-install.ts
60607
- import { existsSync as existsSync19, readFileSync as readFileSync22, rmSync as rmSync7, statSync as statSync5 } from "fs";
60595
+ import { existsSync as existsSync19, readFileSync as readFileSync21, rmSync as rmSync7, statSync as statSync5 } from "fs";
60608
60596
  import { homedir as homedir10 } from "os";
60609
- import { join as join29 } from "path";
60597
+ import { join as join28 } from "path";
60610
60598
 
60611
60599
  // node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/nodes/identity.js
60612
60600
  var ALIAS = /* @__PURE__ */ Symbol.for("yaml.alias");
@@ -66885,13 +66873,13 @@ var JSON_INDENT3 = 2;
66885
66873
  var CONFIG_MODE = 384;
66886
66874
  var PRIM_BINS4 = [CAPTURE_BIN4, GATE_BIN4, POST_TOOL_USE_BIN3, SESSION_START_BIN4, SESSION_END_BIN3];
66887
66875
  function hermesHome() {
66888
- return process.env.HERMES_HOME ?? join29(homedir10(), ".hermes");
66876
+ return process.env.HERMES_HOME ?? join28(homedir10(), ".hermes");
66889
66877
  }
66890
66878
  function configPath() {
66891
- return join29(hermesHome(), "config.yaml");
66879
+ return join28(hermesHome(), "config.yaml");
66892
66880
  }
66893
66881
  function legacyShimPath() {
66894
- return join29(hermesHome(), "agent-hooks", "prim-shim.sh");
66882
+ return join28(hermesHome(), "agent-hooks", "prim-shim.sh");
66895
66883
  }
66896
66884
  function commandFor2(bin) {
66897
66885
  return stableHookCommand(bin, HERMES_ARGS);
@@ -66911,7 +66899,7 @@ var CAPTURE_EVENTS2 = [
66911
66899
  "on_session_end",
66912
66900
  "subagent_stop"
66913
66901
  ];
66914
- var GATE_TIMEOUT_SECONDS = 300;
66902
+ var GATE_TIMEOUT_SECONDS = 2;
66915
66903
  var REGISTRATIONS3 = [
66916
66904
  ...CAPTURE_EVENTS2.map((event) => ({ event, bin: CAPTURE_BIN4 })),
66917
66905
  { event: "pre_tool_call", matcher: EDIT_MATCHER, bin: GATE_BIN4, timeout: GATE_TIMEOUT_SECONDS },
@@ -66933,7 +66921,7 @@ function entryFor(reg) {
66933
66921
  if (reg.timeout !== void 0) {
66934
66922
  entry.timeout = reg.timeout;
66935
66923
  }
66936
- if (reg.bin === GATE_BIN4) entry.fail_closed = true;
66924
+ if (reg.bin === GATE_BIN4) entry.fail_closed = false;
66937
66925
  return entry;
66938
66926
  }
66939
66927
  function stripBin(list, bin) {
@@ -67007,7 +66995,7 @@ function hookRuntimeResolutions3(hooks) {
67007
66995
  function inspectHookRuntimeResolutions4() {
67008
66996
  const path9 = configPath();
67009
66997
  if (!existsSync19(path9)) return [];
67010
- return hookRuntimeResolutions3(readHooks(parseHermesDocument(readFileSync22(path9, "utf8"))));
66998
+ return hookRuntimeResolutions3(readHooks(parseHermesDocument(readFileSync21(path9, "utf8"))));
67011
66999
  }
67012
67000
  function entryMatchesRegistration3(owned, registration) {
67013
67001
  const expected = entryFor(registration);
@@ -67280,7 +67268,7 @@ function readConfigSnapshot(path9) {
67280
67268
  return {
67281
67269
  exists: true,
67282
67270
  mode: statSync5(path9).mode & 511,
67283
- raw: readFileSync22(path9, "utf8")
67271
+ raw: readFileSync21(path9, "utf8")
67284
67272
  };
67285
67273
  }
67286
67274
  var CONCURRENT_CONFIG_MESSAGE = "Hermes config changed during update; concurrent changes were preserved, retry the command";
@@ -67289,7 +67277,7 @@ function writeHermesConfigSnapshot(path9, before, after, expectedHooks) {
67289
67277
  ensureParent: true,
67290
67278
  mode: before.mode,
67291
67279
  validate(temporaryPath) {
67292
- const flushed = readFileSync22(temporaryPath, "utf8");
67280
+ const flushed = readFileSync21(temporaryPath, "utf8");
67293
67281
  if (!mergePreservesHermesSemantics(before.raw, flushed, expectedHooks)) {
67294
67282
  throw new Error(INVALID_MERGE_MESSAGE);
67295
67283
  }
@@ -67367,7 +67355,7 @@ function performUninstall4() {
67367
67355
  }
67368
67356
  function performStatus4() {
67369
67357
  const path9 = configPath();
67370
- const raw = existsSync19(path9) ? readFileSync22(path9, "utf8") : "";
67358
+ const raw = existsSync19(path9) ? readFileSync21(path9, "utf8") : "";
67371
67359
  const hooks = raw ? readHooks(parseHermesDocument(raw)) : {};
67372
67360
  return {
67373
67361
  path: path9,
@@ -68206,7 +68194,7 @@ function checkPreflightHosts() {
68206
68194
  return hosts.map((host) => {
68207
68195
  const protection = inspectFailureProtection(host);
68208
68196
  return {
68209
- name: `${host} gate failure protection`,
68197
+ name: `${host} gate timeout and failure behavior`,
68210
68198
  status: protection.status === "supported" ? "ok" : protection.status === "limited" ? "warn" : "fail",
68211
68199
  detail: protection.detail
68212
68200
  };
@@ -68276,9 +68264,9 @@ function registerDoctorCommands(program3, dependencies = {}) {
68276
68264
 
68277
68265
  // src/commands/gameplan.ts
68278
68266
  import { createHash as createHash12 } from "crypto";
68279
- import { existsSync as existsSync21, lstatSync as lstatSync11, readFileSync as readFileSync23, readdirSync as readdirSync9, rmdirSync as rmdirSync3, unlinkSync as unlinkSync6 } from "fs";
68267
+ import { existsSync as existsSync21, lstatSync as lstatSync11, readFileSync as readFileSync22, readdirSync as readdirSync9, rmdirSync as rmdirSync3, unlinkSync as unlinkSync6 } from "fs";
68280
68268
  import { homedir as homedir11 } from "os";
68281
- import { dirname as dirname14, join as join30, resolve as resolve10 } from "path";
68269
+ import { dirname as dirname14, join as join29, resolve as resolve10 } from "path";
68282
68270
  import { fileURLToPath as fileURLToPath4 } from "url";
68283
68271
  var __dirname4 = dirname14(fileURLToPath4(import.meta.url));
68284
68272
  var SKILL_NAME = "primitive-gameplan";
@@ -68297,13 +68285,13 @@ ${END}`;
68297
68285
  function packageRoot2() {
68298
68286
  let directory = __dirname4;
68299
68287
  while (directory !== dirname14(directory)) {
68300
- if (existsSync21(join30(directory, "assets", SKILL_NAME, "SKILL.md"))) return directory;
68288
+ if (existsSync21(join29(directory, "assets", SKILL_NAME, "SKILL.md"))) return directory;
68301
68289
  directory = dirname14(directory);
68302
68290
  }
68303
68291
  throw new Error("Primitive gameplan assets are missing from this CLI package");
68304
68292
  }
68305
68293
  function packageVersion2(root) {
68306
- const parsed = JSON.parse(readFileSync23(join30(root, "package.json"), "utf8"));
68294
+ const parsed = JSON.parse(readFileSync22(join29(root, "package.json"), "utf8"));
68307
68295
  if (typeof parsed.version !== "string") throw new Error("CLI package version is missing");
68308
68296
  return parsed.version;
68309
68297
  }
@@ -68313,15 +68301,15 @@ function sha2563(content2) {
68313
68301
  function pathsFor(cwd) {
68314
68302
  const root = gitToplevel(cwd);
68315
68303
  if (root === null) throw new Error("Run prim gameplan from a Git worktree");
68316
- const skillDir = join30(root, ".agents", "skills", SKILL_NAME);
68317
- const codexHome = process.env.CODEX_HOME?.trim() ? resolve10(process.env.CODEX_HOME) : join30(homedir11(), ".codex");
68304
+ const skillDir = join29(root, ".agents", "skills", SKILL_NAME);
68305
+ const codexHome = process.env.CODEX_HOME?.trim() ? resolve10(process.env.CODEX_HOME) : join29(homedir11(), ".codex");
68318
68306
  return {
68319
68307
  root,
68320
68308
  skillDir,
68321
- manifest: join30(skillDir, MANIFEST_NAME),
68322
- agents: join30(root, "AGENTS.md"),
68323
- agentsOverride: join30(root, "AGENTS.override.md"),
68324
- userHooks: join30(codexHome, "hooks.json")
68309
+ manifest: join29(skillDir, MANIFEST_NAME),
68310
+ agents: join29(root, "AGENTS.md"),
68311
+ agentsOverride: join29(root, "AGENTS.override.md"),
68312
+ userHooks: join29(codexHome, "hooks.json")
68325
68313
  };
68326
68314
  }
68327
68315
  function readRegularFile(path9) {
@@ -68333,7 +68321,7 @@ function readRegularFile(path9) {
68333
68321
  throw error;
68334
68322
  }
68335
68323
  if (!entry.isFile()) throw new Error(`Refusing non-regular file at ${path9}`);
68336
- return readFileSync23(path9, "utf8");
68324
+ return readFileSync22(path9, "utf8");
68337
68325
  }
68338
68326
  function readManifest(path9) {
68339
68327
  const content2 = readRegularFile(path9);
@@ -68386,13 +68374,13 @@ function removeBlock(content2, separator) {
68386
68374
  function publicSkillPath(paths) {
68387
68375
  const codexHome = dirname14(paths.userHooks);
68388
68376
  const candidates = [
68389
- join30(paths.root, ".agents", "skills", "write-gameplan", "SKILL.md"),
68390
- join30(codexHome, "skills", "write-gameplan", "SKILL.md"),
68391
- join30(homedir11(), ".agents", "skills", "write-gameplan", "SKILL.md")
68377
+ join29(paths.root, ".agents", "skills", "write-gameplan", "SKILL.md"),
68378
+ join29(codexHome, "skills", "write-gameplan", "SKILL.md"),
68379
+ join29(homedir11(), ".agents", "skills", "write-gameplan", "SKILL.md")
68392
68380
  ];
68393
68381
  for (const path9 of candidates) {
68394
68382
  try {
68395
- const content2 = readFileSync23(path9, "utf8");
68383
+ const content2 = readFileSync22(path9, "utf8");
68396
68384
  if (/^name:\s*write-gameplan\s*$/mu.test(content2)) return path9;
68397
68385
  } catch {
68398
68386
  }
@@ -68402,7 +68390,7 @@ function publicSkillPath(paths) {
68402
68390
  function assetContents() {
68403
68391
  const root = packageRoot2();
68404
68392
  return Object.fromEntries(
68405
- ASSET_FILES.map((file) => [file, readFileSync23(join30(root, "assets", SKILL_NAME, file), "utf8")])
68393
+ ASSET_FILES.map((file) => [file, readFileSync22(join29(root, "assets", SKILL_NAME, file), "utf8")])
68406
68394
  );
68407
68395
  }
68408
68396
  function markedHookCommands(settings) {
@@ -68451,7 +68439,7 @@ function checkOwnedFiles(paths, manifest) {
68451
68439
  }
68452
68440
  if (manifest === null) return;
68453
68441
  for (const file of ASSET_FILES) {
68454
- const path9 = join30(paths.skillDir, file);
68442
+ const path9 = join29(paths.skillDir, file);
68455
68443
  const current = readRegularFile(path9);
68456
68444
  if (current !== null && sha2563(current) !== manifest.files[file] && sha2563(current) !== manifest.previousFiles?.[file]) {
68457
68445
  throw new Error(`Refusing modified companion file at ${path9}`);
@@ -68500,7 +68488,7 @@ function install(cwd) {
68500
68488
  ensureParent: true
68501
68489
  });
68502
68490
  for (const file of ASSET_FILES) {
68503
- const path9 = join30(paths.skillDir, file);
68491
+ const path9 = join29(paths.skillDir, file);
68504
68492
  if (readRegularFile(path9) !== assets[file]) {
68505
68493
  atomicWriteFile(path9, assets[file], { ensureParent: true });
68506
68494
  }
@@ -68520,7 +68508,7 @@ function status(cwd) {
68520
68508
  const publicSkill = publicSkillPath(paths);
68521
68509
  const files = Object.fromEntries(
68522
68510
  ASSET_FILES.map((file) => {
68523
- const current = readRegularFile(join30(paths.skillDir, file));
68511
+ const current = readRegularFile(join29(paths.skillDir, file));
68524
68512
  return [
68525
68513
  file,
68526
68514
  current !== null && manifest !== null && sha2563(current) === manifest.files[file]
@@ -68554,7 +68542,7 @@ function uninstall(cwd, removeSharedHook) {
68554
68542
  checkOwnedFiles(paths, manifest);
68555
68543
  const expected = /* @__PURE__ */ new Set(["SKILL.md", "claude-hooks.json", "scripts", MANIFEST_NAME]);
68556
68544
  const extras = readdirSync9(paths.skillDir).filter((entry) => !expected.has(entry));
68557
- const scriptsPath = join30(paths.skillDir, "scripts");
68545
+ const scriptsPath = join29(paths.skillDir, "scripts");
68558
68546
  if (existsSync21(scriptsPath)) {
68559
68547
  extras.push(...readdirSync9(scriptsPath).filter((entry) => entry !== "activate.mjs"));
68560
68548
  }
@@ -68573,7 +68561,7 @@ function uninstall(cwd, removeSharedHook) {
68573
68561
  }
68574
68562
  }
68575
68563
  for (const file of ASSET_FILES) {
68576
- const path9 = join30(paths.skillDir, file);
68564
+ const path9 = join29(paths.skillDir, file);
68577
68565
  if (existsSync21(path9)) unlinkSync6(path9);
68578
68566
  }
68579
68567
  unlinkSync6(paths.manifest);
@@ -68631,11 +68619,11 @@ function registerGameplanCommands(program3) {
68631
68619
 
68632
68620
  // src/commands/moves.ts
68633
68621
  import { existsSync as existsSync23, mkdirSync as mkdirSync13, unlinkSync as unlinkSync8, writeFileSync as writeFileSync9 } from "fs";
68634
- import { join as join33 } from "path";
68622
+ import { join as join32 } from "path";
68635
68623
 
68636
68624
  // src/flusher.ts
68637
68625
  import { createReadStream, renameSync as renameSync6, statSync as statSync6, unlinkSync as unlinkSync7 } from "fs";
68638
- import { dirname as dirname16, join as join32 } from "path";
68626
+ import { dirname as dirname16, join as join31 } from "path";
68639
68627
 
68640
68628
  // src/dead-letter.ts
68641
68629
  import { createHash as createHash13, randomBytes as randomBytes7 } from "crypto";
@@ -68652,16 +68640,16 @@ import {
68652
68640
  rmSync as rmSync8,
68653
68641
  writeFileSync as writeFileSync8
68654
68642
  } from "fs";
68655
- import { dirname as dirname15, join as join31 } from "path";
68643
+ import { dirname as dirname15, join as join30 } from "path";
68656
68644
  var DIRECTORY_MODE4 = 448;
68657
68645
  var FILE_MODE3 = 384;
68658
68646
  var DEAD_LETTER_DIRNAME = "dead-letter";
68659
68647
  function deadLetterDirectoryForRotation(flushingPath) {
68660
- return join31(dirname15(flushingPath), DEAD_LETTER_DIRNAME);
68648
+ return join30(dirname15(flushingPath), DEAD_LETTER_DIRNAME);
68661
68649
  }
68662
68650
  function deadLetterPathForRawLine(flushingPath, rawLine) {
68663
68651
  const quarantineId = createHash13("sha256").update(rawLine).digest("hex");
68664
- return join31(deadLetterDirectoryForRotation(flushingPath), `raw-${quarantineId}.json`);
68652
+ return join30(deadLetterDirectoryForRotation(flushingPath), `raw-${quarantineId}.json`);
68665
68653
  }
68666
68654
  function ensureDeadLetterDirectory(flushingPath, persistDirectory) {
68667
68655
  const directory = deadLetterDirectoryForRotation(flushingPath);
@@ -68675,7 +68663,7 @@ function persistDeadLetter(directory, path9, quarantineId, record3, persistDirec
68675
68663
  persistDirectory(directory);
68676
68664
  return;
68677
68665
  }
68678
- const temporaryPath = join31(
68666
+ const temporaryPath = join30(
68679
68667
  directory,
68680
68668
  `.${quarantineId}.${String(process.pid)}.${randomBytes7(8).toString("hex")}.tmp`
68681
68669
  );
@@ -68707,7 +68695,7 @@ function quarantineMove(flushingPath, move, reason, now = Date.now, options = {}
68707
68695
  reason,
68708
68696
  move
68709
68697
  };
68710
- const path9 = join31(directory, `${record3.quarantineId}.json`);
68698
+ const path9 = join30(directory, `${record3.quarantineId}.json`);
68711
68699
  persistDeadLetter(directory, path9, record3.quarantineId, record3, persistDirectory);
68712
68700
  return record3;
68713
68701
  }
@@ -69131,7 +69119,7 @@ async function flushOnce() {
69131
69119
  return inspection.retainedBuckets.length > 0 ? { flushed: total, quarantined, retained: inspection.retainedBuckets } : { flushed: total, quarantined };
69132
69120
  }
69133
69121
  var flushInFlight;
69134
- var FLUSH_LOCK_PATH = join32(dirname16(JOURNAL_DIR), ".flush.lock");
69122
+ var FLUSH_LOCK_PATH = join31(dirname16(JOURNAL_DIR), ".flush.lock");
69135
69123
  var FLUSH_LOCK_TIMEOUT_MS = 250;
69136
69124
  function isFlushLockContended(error) {
69137
69125
  return error instanceof Error && error.message.startsWith("timed out waiting for file lock");
@@ -69263,18 +69251,18 @@ function registerMovesCommands(program3) {
69263
69251
  }
69264
69252
  });
69265
69253
  moves.command("bind").description("Pin the current directory to an org via .prim/workspace.json").requiredOption("--orgId <orgId>", "Convex organization id").action((opts) => {
69266
- const dir = join33(process.cwd(), ".prim");
69254
+ const dir = join32(process.cwd(), ".prim");
69267
69255
  if (!existsSync23(dir)) {
69268
69256
  mkdirSync13(dir, { recursive: true, mode: DIR_MODE });
69269
69257
  }
69270
- const file = join33(process.cwd(), WORKSPACE_FILE);
69258
+ const file = join32(process.cwd(), WORKSPACE_FILE);
69271
69259
  writeFileSync9(file, JSON.stringify({ orgId: opts.orgId, boundAt: Date.now() }, null, 2), {
69272
69260
  mode: FILE_MODE4
69273
69261
  });
69274
69262
  console.log(`[prim] bound ${process.cwd()} to org ${opts.orgId}`);
69275
69263
  });
69276
69264
  moves.command("drop").description("Remove the .prim/workspace.json binding from the cwd").action(() => {
69277
- const file = join33(process.cwd(), WORKSPACE_FILE);
69265
+ const file = join32(process.cwd(), WORKSPACE_FILE);
69278
69266
  if (!existsSync23(file)) {
69279
69267
  console.log("[prim] no workspace binding in cwd");
69280
69268
  return;
@@ -69355,18 +69343,18 @@ function registerReconcileCommands(program3) {
69355
69343
  import {
69356
69344
  existsSync as existsSync25,
69357
69345
  mkdirSync as mkdirSync14,
69358
- readFileSync as readFileSync25,
69346
+ readFileSync as readFileSync24,
69359
69347
  readdirSync as readdirSync10,
69360
69348
  unlinkSync as unlinkSync9,
69361
69349
  writeFileSync as writeFileSync10
69362
69350
  } from "fs";
69363
- import { join as join35 } from "path";
69351
+ import { join as join34 } from "path";
69364
69352
 
69365
69353
  // src/binding.ts
69366
- import { existsSync as existsSync24, readFileSync as readFileSync24 } from "fs";
69367
- import { dirname as dirname17, join as join34 } from "path";
69354
+ import { existsSync as existsSync24, readFileSync as readFileSync23 } from "fs";
69355
+ import { dirname as dirname17, join as join33 } from "path";
69368
69356
  var PRIM_CONFIG_DIR = primConfigDirectory();
69369
- var SESSIONS_DIR = join34(PRIM_CONFIG_DIR, "sessions");
69357
+ var SESSIONS_DIR = join33(PRIM_CONFIG_DIR, "sessions");
69370
69358
 
69371
69359
  // src/commands/session.ts
69372
69360
  var DIR_MODE2 = 448;
@@ -69377,7 +69365,7 @@ function ensureDir() {
69377
69365
  }
69378
69366
  }
69379
69367
  function markerPath(sessionId) {
69380
- return join35(SESSIONS_DIR, `${sessionId}.json`);
69368
+ return join34(SESSIONS_DIR, `${sessionId}.json`);
69381
69369
  }
69382
69370
  function registerSessionCommands(program3) {
69383
69371
  const session = program3.command("session").description("Decision Event Pipeline \u2014 session binding markers");
@@ -69405,7 +69393,7 @@ function registerSessionCommands(program3) {
69405
69393
  for (const f of files) {
69406
69394
  const sessionId = f.replace(/\.json$/, "");
69407
69395
  try {
69408
- const m = JSON.parse(readFileSync25(join35(SESSIONS_DIR, f), "utf-8"));
69396
+ const m = JSON.parse(readFileSync24(join34(SESSIONS_DIR, f), "utf-8"));
69409
69397
  console.log(`${sessionId} org=${m.orgId}`);
69410
69398
  } catch {
69411
69399
  }
@@ -69424,8 +69412,8 @@ function registerSessionCommands(program3) {
69424
69412
 
69425
69413
  // src/commands/setup.ts
69426
69414
  import { spawnSync as spawnSync2 } from "child_process";
69427
- import { existsSync as existsSync26, readFileSync as readFileSync26 } from "fs";
69428
- import { join as join36 } from "path";
69415
+ import { existsSync as existsSync26, readFileSync as readFileSync25 } from "fs";
69416
+ import { join as join35 } from "path";
69429
69417
  var EXIT_INCOMPLETE = 1;
69430
69418
  var EXIT_USAGE3 = 2;
69431
69419
  var SETUP_ORCHESTRATOR_ENV = "PRIM_SETUP_ORCHESTRATOR";
@@ -69563,8 +69551,8 @@ function detectProjectConflicts(agent, run, globalHooksActive) {
69563
69551
  let preCommit;
69564
69552
  try {
69565
69553
  const root = gitToplevel();
69566
- const path9 = root && join36(root, ".git", "hooks", "pre-commit");
69567
- if (path9 && existsSync26(path9)) preCommit = readFileSync26(path9, "utf-8");
69554
+ const path9 = root && join35(root, ".git", "hooks", "pre-commit");
69555
+ if (path9 && existsSync26(path9)) preCommit = readFileSync25(path9, "utf-8");
69568
69556
  } catch {
69569
69557
  }
69570
69558
  if (projectHooksConflict(globalHooksActive, preCommit)) conflicts.push(CONFLICT_HOOKS);
@@ -69833,14 +69821,14 @@ import {
69833
69821
  fstatSync as fstatSync4,
69834
69822
  lstatSync as lstatSync13,
69835
69823
  openSync as openSync8,
69836
- readFileSync as readFileSync28,
69824
+ readFileSync as readFileSync27,
69837
69825
  readSync as readSync4,
69838
69826
  readdirSync as readdirSync12,
69839
69827
  rmdirSync as rmdirSync5,
69840
69828
  unlinkSync as unlinkSync10
69841
69829
  } from "fs";
69842
69830
  import { homedir as homedir13 } from "os";
69843
- import { dirname as dirname19, join as join38, resolve as resolve12 } from "path";
69831
+ import { dirname as dirname19, join as join37, resolve as resolve12 } from "path";
69844
69832
  import { fileURLToPath as fileURLToPath6 } from "url";
69845
69833
 
69846
69834
  // src/commands/claude-plugin.ts
@@ -69853,7 +69841,7 @@ import {
69853
69841
  lstatSync as lstatSync12,
69854
69842
  mkdirSync as mkdirSync15,
69855
69843
  openSync as openSync7,
69856
- readFileSync as readFileSync27,
69844
+ readFileSync as readFileSync26,
69857
69845
  readSync as readSync3,
69858
69846
  readdirSync as readdirSync11,
69859
69847
  realpathSync as realpathSync7,
@@ -69861,15 +69849,15 @@ import {
69861
69849
  rmdirSync as rmdirSync4
69862
69850
  } from "fs";
69863
69851
  import { homedir as homedir12 } from "os";
69864
- import { dirname as dirname18, isAbsolute as isAbsolute11, join as join37, relative as relative4, resolve as resolve11, sep as sep4 } from "path";
69852
+ import { dirname as dirname18, isAbsolute as isAbsolute11, join as join36, relative as relative4, resolve as resolve11, sep as sep4 } from "path";
69865
69853
  import { fileURLToPath as fileURLToPath5 } from "url";
69866
69854
  var __dirname5 = dirname18(fileURLToPath5(import.meta.url));
69867
69855
  var PLUGIN_DESCRIPTION = "Primitive decision-graph guidance for the prim CLI \u2014 a model-invoked skill installed by prim skill install.";
69868
69856
  var MAX_MANIFEST_BYTES2 = 64 * 1024;
69869
69857
  var MAX_SKILL_BYTES = 1024 * 1024;
69870
69858
  function pluginDirFor(cwd, scope) {
69871
- const base = scope === "user" ? join37(homedir12(), ".claude") : join37(gitToplevel(cwd) ?? cwd, ".claude");
69872
- return join37(base, "skills", "prim");
69859
+ const base = scope === "user" ? join36(homedir12(), ".claude") : join36(gitToplevel(cwd) ?? cwd, ".claude");
69860
+ return join36(base, "skills", "prim");
69873
69861
  }
69874
69862
  function resolvePluginDir(cwd, scope) {
69875
69863
  if (scope && scope !== "user" && scope !== "project") {
@@ -69882,7 +69870,7 @@ function packageVersion3() {
69882
69870
  let dir = __dirname5;
69883
69871
  while (dir !== dirname18(dir)) {
69884
69872
  const p = resolve11(dir, "package.json");
69885
- if (existsSync27(p)) return JSON.parse(readFileSync27(p, "utf-8")).version;
69873
+ if (existsSync27(p)) return JSON.parse(readFileSync26(p, "utf-8")).version;
69886
69874
  dir = dirname18(dir);
69887
69875
  }
69888
69876
  return "0.0.0";
@@ -69901,8 +69889,8 @@ function removeDirIfEmpty(dir) {
69901
69889
  }
69902
69890
  function pluginPaths(dir) {
69903
69891
  return {
69904
- manifestPath: join37(dir, ".claude-plugin", "plugin.json"),
69905
- skillPath: join37(dir, "SKILL.md")
69892
+ manifestPath: join36(dir, ".claude-plugin", "plugin.json"),
69893
+ skillPath: join36(dir, "SKILL.md")
69906
69894
  };
69907
69895
  }
69908
69896
  function installClaudePlugin(cwd, opts) {
@@ -69910,8 +69898,8 @@ function installClaudePlugin(cwd, opts) {
69910
69898
  if (dir === null) return 1;
69911
69899
  const { manifestPath, skillPath } = pluginPaths(dir);
69912
69900
  const { manifest, skill } = renderClaudePlugin();
69913
- const manifestCurrent = existsSync27(manifestPath) ? readFileSync27(manifestPath, "utf-8") : null;
69914
- const skillCurrent = existsSync27(skillPath) ? readFileSync27(skillPath, "utf-8") : null;
69901
+ const manifestCurrent = existsSync27(manifestPath) ? readFileSync26(manifestPath, "utf-8") : null;
69902
+ const skillCurrent = existsSync27(skillPath) ? readFileSync26(skillPath, "utf-8") : null;
69915
69903
  if (manifestCurrent === manifest && skillCurrent === skill) {
69916
69904
  console.log("No changes \u2014 prim skill plugin already up to date.");
69917
69905
  return 0;
@@ -69920,7 +69908,7 @@ function installClaudePlugin(cwd, opts) {
69920
69908
  console.log(`Would write plugin to ${dir} (.claude-plugin/plugin.json + SKILL.md)`);
69921
69909
  return 0;
69922
69910
  }
69923
- mkdirSync15(join37(dir, ".claude-plugin"), { recursive: true });
69911
+ mkdirSync15(join36(dir, ".claude-plugin"), { recursive: true });
69924
69912
  atomicWrite5(manifestPath, manifest);
69925
69913
  atomicWrite5(skillPath, skill);
69926
69914
  console.log(`Installed prim skill plugin at ${dir}`);
@@ -69940,7 +69928,7 @@ function uninstallClaudePlugin(cwd, opts) {
69940
69928
  }
69941
69929
  rmSync9(manifestPath, { force: true });
69942
69930
  rmSync9(skillPath, { force: true });
69943
- removeDirIfEmpty(join37(dir, ".claude-plugin"));
69931
+ removeDirIfEmpty(join36(dir, ".claude-plugin"));
69944
69932
  removeDirIfEmpty(dir);
69945
69933
  console.log(`Removed prim skill plugin from ${dir}`);
69946
69934
  return 0;
@@ -69991,19 +69979,19 @@ function sha2564(content2) {
69991
69979
  }
69992
69980
  function cursorSkillDirectory(cwd, scope) {
69993
69981
  const base = scope === "user" ? cursorConfigDirectory() : gitToplevel(cwd) ?? cwd;
69994
- return join38(base, scope === "user" ? "skills" : ".cursor/skills", "prim");
69982
+ return join37(base, scope === "user" ? "skills" : ".cursor/skills", "prim");
69995
69983
  }
69996
69984
  function cursorSkillPaths(cwd, scope) {
69997
69985
  const directory = cursorSkillDirectory(cwd, scope);
69998
69986
  return {
69999
69987
  directory,
70000
- skill: join38(directory, "SKILL.md"),
70001
- manifest: join38(directory, CURSOR_SKILL_MANIFEST)
69988
+ skill: join37(directory, "SKILL.md"),
69989
+ manifest: join37(directory, CURSOR_SKILL_MANIFEST)
70002
69990
  };
70003
69991
  }
70004
69992
  function readCursorSkillManifest(path9) {
70005
69993
  try {
70006
- const value = JSON.parse(readFileSync28(path9, "utf8"));
69994
+ const value = JSON.parse(readFileSync27(path9, "utf8"));
70007
69995
  if (!value || typeof value !== "object" || Array.isArray(value)) return;
70008
69996
  const record3 = value;
70009
69997
  if (record3.version !== 1 || record3.owner !== CURSOR_SKILL_OWNER || typeof record3.contentSha256 !== "string" || !/^[0-9a-f]{64}$/u.test(record3.contentSha256)) {
@@ -70017,7 +70005,7 @@ function readCursorSkillManifest(path9) {
70017
70005
  function cursorSkillStatus(cwd, scope) {
70018
70006
  const paths = cursorSkillPaths(cwd, scope);
70019
70007
  const manifest = readCursorSkillManifest(paths.manifest);
70020
- const content2 = existsSync28(paths.skill) ? readFileSync28(paths.skill, "utf8") : void 0;
70008
+ const content2 = existsSync28(paths.skill) ? readFileSync27(paths.skill, "utf8") : void 0;
70021
70009
  const owned = manifest !== void 0;
70022
70010
  const installed = owned && content2 !== void 0 && sha2564(content2) === manifest.contentSha256;
70023
70011
  return {
@@ -70047,12 +70035,12 @@ function installCursorSkill(cwd, opts) {
70047
70035
  owner: CURSOR_SKILL_OWNER,
70048
70036
  contentSha256: sha2564(content2)
70049
70037
  };
70050
- if (status2.installed && readFileSync28(paths.skill, "utf8") === content2) {
70038
+ if (status2.installed && readFileSync27(paths.skill, "utf8") === content2) {
70051
70039
  console.log(`No changes \u2014 Cursor skill already up to date at ${paths.skill}`);
70052
70040
  return 0;
70053
70041
  }
70054
70042
  if (opts.dryRun) {
70055
- const existing = skillExists ? readFileSync28(paths.skill, "utf8") : "";
70043
+ const existing = skillExists ? readFileSync27(paths.skill, "utf8") : "";
70056
70044
  process.stdout.write(createPatch(paths.skill, existing, content2, "current", "proposed"));
70057
70045
  return 0;
70058
70046
  }
@@ -70083,10 +70071,10 @@ function uninstallCursorSkill(cwd, scope) {
70083
70071
  return 0;
70084
70072
  }
70085
70073
  function userTargetFor(agent) {
70086
- if (agent === "claude") return join38(homedir13(), ".claude", "CLAUDE.md");
70087
- if (agent === "codex") return join38(homedir13(), ".codex", "AGENTS.md");
70074
+ if (agent === "claude") return join37(homedir13(), ".claude", "CLAUDE.md");
70075
+ if (agent === "codex") return join37(homedir13(), ".codex", "AGENTS.md");
70088
70076
  if (agent === "hermes") {
70089
- return join38(process.env.HERMES_HOME ?? join38(homedir13(), ".hermes"), ".hermes.md");
70077
+ return join37(process.env.HERMES_HOME ?? join37(homedir13(), ".hermes"), ".hermes.md");
70090
70078
  }
70091
70079
  return null;
70092
70080
  }
@@ -70094,7 +70082,7 @@ function loadSkill() {
70094
70082
  let dir = __dirname6;
70095
70083
  while (dir !== dirname19(dir)) {
70096
70084
  const p = resolve12(dir, "SKILL.md");
70097
- if (existsSync28(p)) return readFileSync28(p, "utf-8");
70085
+ if (existsSync28(p)) return readFileSync27(p, "utf-8");
70098
70086
  dir = dirname19(dir);
70099
70087
  }
70100
70088
  throw new Error("SKILL.md not found in package");
@@ -70166,7 +70154,7 @@ function runInstall(cwd, opts) {
70166
70154
  }
70167
70155
  const target = resolveTarget(cwd, opts);
70168
70156
  if (target === null) return 1;
70169
- const existing = existsSync28(target) ? readFileSync28(target, "utf-8") : "";
70157
+ const existing = existsSync28(target) ? readFileSync27(target, "utf-8") : "";
70170
70158
  const eol = existing ? detectNewline(existing) : "\n";
70171
70159
  const block = composeBlock(loadSkill(), eol);
70172
70160
  const next = applyBlock(existing, block, eol);
@@ -70194,7 +70182,7 @@ function runUninstall(cwd, opts) {
70194
70182
  console.log(`Skill block not present at ${target}`);
70195
70183
  return 0;
70196
70184
  }
70197
- const existing = readFileSync28(target, "utf-8");
70185
+ const existing = readFileSync27(target, "utf-8");
70198
70186
  const next = removeBlock2(existing);
70199
70187
  if (next === null) {
70200
70188
  console.log(`Skill block not present at ${target}`);
@@ -70221,7 +70209,7 @@ function runStatus(cwd, opts) {
70221
70209
  const fileExists = existsSync28(target);
70222
70210
  let installed = false;
70223
70211
  if (fileExists) {
70224
- const content2 = readFileSync28(target, "utf-8");
70212
+ const content2 = readFileSync27(target, "utf-8");
70225
70213
  installed = content2.includes(SKILL_BEGIN) && content2.includes(SKILL_END);
70226
70214
  }
70227
70215
  if (opts.json) {
@@ -70258,7 +70246,7 @@ function registerSkillCommands(program3) {
70258
70246
  }
70259
70247
 
70260
70248
  // src/commands/statusline.ts
70261
- import { readFileSync as readFileSync29 } from "fs";
70249
+ import { readFileSync as readFileSync28 } from "fs";
70262
70250
  import { dirname as dirname20, resolve as resolve13 } from "path";
70263
70251
  import { fileURLToPath as fileURLToPath7 } from "url";
70264
70252
  var STATUSLINE_TIMEOUT_MS = 200;
@@ -70274,7 +70262,7 @@ function readPackageVersion() {
70274
70262
  ];
70275
70263
  for (const path9 of candidates) {
70276
70264
  try {
70277
- const pkg2 = JSON.parse(readFileSync29(path9, "utf-8"));
70265
+ const pkg2 = JSON.parse(readFileSync28(path9, "utf-8"));
70278
70266
  if (pkg2.version) {
70279
70267
  return pkg2.version;
70280
70268
  }
@@ -70838,13 +70826,13 @@ function healDaemonDrift(options = {}) {
70838
70826
 
70839
70827
  // src/lib/background-flush.ts
70840
70828
  import { spawn as spawn5 } from "child_process";
70841
- import { readFileSync as readFileSync30 } from "fs";
70829
+ import { readFileSync as readFileSync29 } from "fs";
70842
70830
 
70843
70831
  // src/daemon/health.ts
70844
70832
  import { chmodSync as chmodSync8, existsSync as existsSync29, mkdirSync as mkdirSync16, renameSync as renameSync7, writeFileSync as writeFileSync11 } from "fs";
70845
- import { dirname as dirname21, join as join39 } from "path";
70833
+ import { dirname as dirname21, join as join38 } from "path";
70846
70834
  var HEARTBEAT_FRESH_MS = 9e4;
70847
- var DAEMON_HEALTH_PATH = join39(primConfigDirectory(), "daemon-health.json");
70835
+ var DAEMON_HEALTH_PATH = join38(primConfigDirectory(), "daemon-health.json");
70848
70836
 
70849
70837
  // src/lib/background-flush.ts
70850
70838
  function record2(value) {
@@ -70855,7 +70843,7 @@ function daemonOwnsDrain(options = {}) {
70855
70843
  const expectedVersion = options.expectedVersion === void 0 ? packageVersion() : options.expectedVersion;
70856
70844
  if (!expectedVersion) return false;
70857
70845
  const health = record2(
70858
- JSON.parse(readFileSync30(options.healthPath ?? DAEMON_HEALTH_PATH, "utf8"))
70846
+ JSON.parse(readFileSync29(options.healthPath ?? DAEMON_HEALTH_PATH, "utf8"))
70859
70847
  );
70860
70848
  const heartbeat = record2(health?.heartbeat);
70861
70849
  const ingestion = record2(health?.ingestion);
@@ -70972,7 +70960,7 @@ function runStartupBackgroundWork(argv, env4, work) {
70972
70960
 
70973
70961
  // src/index.ts
70974
70962
  var __dirname7 = dirname22(fileURLToPath8(import.meta.url));
70975
- var pkg = JSON.parse(readFileSync31(resolve14(__dirname7, "../package.json"), "utf-8"));
70963
+ var pkg = JSON.parse(readFileSync30(resolve14(__dirname7, "../package.json"), "utf-8"));
70976
70964
  runStartupBackgroundWork(process.argv.slice(2), process.env, {
70977
70965
  notify: () => updateNotifier({ pkg }).notify(),
70978
70966
  flush: () => startBackgroundFlush(),