@primitive.ai/prim 0.1.0-alpha.79 → 0.1.0-alpha.80

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.
@@ -3035,7 +3035,7 @@ var require_commander = __commonJS({
3035
3035
  var require_polyfills = __commonJS({
3036
3036
  "node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js"(exports, module) {
3037
3037
  "use strict";
3038
- var constants9 = __require("constants");
3038
+ var constants8 = __require("constants");
3039
3039
  var origCwd = process.cwd;
3040
3040
  var cwd = null;
3041
3041
  var platform2 = process.env.GRACEFUL_FS_PLATFORM || process.platform;
@@ -3059,7 +3059,7 @@ var require_polyfills = __commonJS({
3059
3059
  var chdir;
3060
3060
  module.exports = patch;
3061
3061
  function patch(fs5) {
3062
- if (constants9.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
3062
+ if (constants8.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
3063
3063
  patchLchmod(fs5);
3064
3064
  }
3065
3065
  if (!fs5.lutimes) {
@@ -3161,7 +3161,7 @@ var require_polyfills = __commonJS({
3161
3161
  fs6.lchmod = function(path9, mode, callback) {
3162
3162
  fs6.open(
3163
3163
  path9,
3164
- constants9.O_WRONLY | constants9.O_SYMLINK,
3164
+ constants8.O_WRONLY | constants8.O_SYMLINK,
3165
3165
  mode,
3166
3166
  function(err, fd) {
3167
3167
  if (err) {
@@ -3177,7 +3177,7 @@ var require_polyfills = __commonJS({
3177
3177
  );
3178
3178
  };
3179
3179
  fs6.lchmodSync = function(path9, mode) {
3180
- var fd = fs6.openSync(path9, constants9.O_WRONLY | constants9.O_SYMLINK, mode);
3180
+ var fd = fs6.openSync(path9, constants8.O_WRONLY | constants8.O_SYMLINK, mode);
3181
3181
  var threw = true;
3182
3182
  var ret;
3183
3183
  try {
@@ -3197,9 +3197,9 @@ var require_polyfills = __commonJS({
3197
3197
  };
3198
3198
  }
3199
3199
  function patchLutimes(fs6) {
3200
- if (constants9.hasOwnProperty("O_SYMLINK") && fs6.futimes) {
3200
+ if (constants8.hasOwnProperty("O_SYMLINK") && fs6.futimes) {
3201
3201
  fs6.lutimes = function(path9, at, mt, cb) {
3202
- fs6.open(path9, constants9.O_SYMLINK, function(er, fd) {
3202
+ fs6.open(path9, constants8.O_SYMLINK, function(er, fd) {
3203
3203
  if (er) {
3204
3204
  if (cb) cb(er);
3205
3205
  return;
@@ -3212,7 +3212,7 @@ var require_polyfills = __commonJS({
3212
3212
  });
3213
3213
  };
3214
3214
  fs6.lutimesSync = function(path9, at, mt) {
3215
- var fd = fs6.openSync(path9, constants9.O_SYMLINK);
3215
+ var fd = fs6.openSync(path9, constants8.O_SYMLINK);
3216
3216
  var ret;
3217
3217
  var threw = true;
3218
3218
  try {
@@ -3495,14 +3495,14 @@ var require_graceful_fs = __commonJS({
3495
3495
  return close;
3496
3496
  })(fs5.close);
3497
3497
  fs5.closeSync = (function(fs$closeSync) {
3498
- function closeSync9(fd) {
3498
+ function closeSync8(fd) {
3499
3499
  fs$closeSync.apply(fs5, arguments);
3500
3500
  resetQueue();
3501
3501
  }
3502
- Object.defineProperty(closeSync9, previousSymbol, {
3502
+ Object.defineProperty(closeSync8, previousSymbol, {
3503
3503
  value: fs$closeSync
3504
3504
  });
3505
- return closeSync9;
3505
+ return closeSync8;
3506
3506
  })(fs5.closeSync);
3507
3507
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
3508
3508
  process.on("exit", function() {
@@ -4963,7 +4963,7 @@ var require_rc = __commonJS({
4963
4963
  "node_modules/.pnpm/rc@1.2.8/node_modules/rc/index.js"(exports, module) {
4964
4964
  "use strict";
4965
4965
  var cc = require_utils();
4966
- var join28 = __require("path").join;
4966
+ var join27 = __require("path").join;
4967
4967
  var deepExtend = require_deep_extend();
4968
4968
  var etc = "/etc";
4969
4969
  var win = process.platform === "win32";
@@ -4988,15 +4988,15 @@ var require_rc = __commonJS({
4988
4988
  }
4989
4989
  if (!win)
4990
4990
  [
4991
- join28(etc, name, "config"),
4992
- join28(etc, name + "rc")
4991
+ join27(etc, name, "config"),
4992
+ join27(etc, name + "rc")
4993
4993
  ].forEach(addConfigFile);
4994
4994
  if (home)
4995
4995
  [
4996
- join28(home, ".config", name, "config"),
4997
- join28(home, ".config", name),
4998
- join28(home, "." + name, "config"),
4999
- join28(home, "." + name + "rc")
4996
+ join27(home, ".config", name, "config"),
4997
+ join27(home, ".config", name),
4998
+ join27(home, "." + name, "config"),
4999
+ join27(home, "." + name + "rc")
5000
5000
  ].forEach(addConfigFile);
5001
5001
  addConfigFile(cc.find("." + name + "rc"));
5002
5002
  if (env4.config) addConfigFile(env4.config);
@@ -5014,7 +5014,7 @@ var require_rc = __commonJS({
5014
5014
  var require_polyfills2 = __commonJS({
5015
5015
  "node_modules/.pnpm/graceful-fs@4.2.10/node_modules/graceful-fs/polyfills.js"(exports, module) {
5016
5016
  "use strict";
5017
- var constants9 = __require("constants");
5017
+ var constants8 = __require("constants");
5018
5018
  var origCwd = process.cwd;
5019
5019
  var cwd = null;
5020
5020
  var platform2 = process.env.GRACEFUL_FS_PLATFORM || process.platform;
@@ -5038,7 +5038,7 @@ var require_polyfills2 = __commonJS({
5038
5038
  var chdir;
5039
5039
  module.exports = patch;
5040
5040
  function patch(fs5) {
5041
- if (constants9.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
5041
+ if (constants8.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
5042
5042
  patchLchmod(fs5);
5043
5043
  }
5044
5044
  if (!fs5.lutimes) {
@@ -5140,7 +5140,7 @@ var require_polyfills2 = __commonJS({
5140
5140
  fs6.lchmod = function(path9, mode, callback) {
5141
5141
  fs6.open(
5142
5142
  path9,
5143
- constants9.O_WRONLY | constants9.O_SYMLINK,
5143
+ constants8.O_WRONLY | constants8.O_SYMLINK,
5144
5144
  mode,
5145
5145
  function(err, fd) {
5146
5146
  if (err) {
@@ -5156,7 +5156,7 @@ var require_polyfills2 = __commonJS({
5156
5156
  );
5157
5157
  };
5158
5158
  fs6.lchmodSync = function(path9, mode) {
5159
- var fd = fs6.openSync(path9, constants9.O_WRONLY | constants9.O_SYMLINK, mode);
5159
+ var fd = fs6.openSync(path9, constants8.O_WRONLY | constants8.O_SYMLINK, mode);
5160
5160
  var threw = true;
5161
5161
  var ret;
5162
5162
  try {
@@ -5176,9 +5176,9 @@ var require_polyfills2 = __commonJS({
5176
5176
  };
5177
5177
  }
5178
5178
  function patchLutimes(fs6) {
5179
- if (constants9.hasOwnProperty("O_SYMLINK") && fs6.futimes) {
5179
+ if (constants8.hasOwnProperty("O_SYMLINK") && fs6.futimes) {
5180
5180
  fs6.lutimes = function(path9, at, mt, cb) {
5181
- fs6.open(path9, constants9.O_SYMLINK, function(er, fd) {
5181
+ fs6.open(path9, constants8.O_SYMLINK, function(er, fd) {
5182
5182
  if (er) {
5183
5183
  if (cb) cb(er);
5184
5184
  return;
@@ -5191,7 +5191,7 @@ var require_polyfills2 = __commonJS({
5191
5191
  });
5192
5192
  };
5193
5193
  fs6.lutimesSync = function(path9, at, mt) {
5194
- var fd = fs6.openSync(path9, constants9.O_SYMLINK);
5194
+ var fd = fs6.openSync(path9, constants8.O_SYMLINK);
5195
5195
  var ret;
5196
5196
  var threw = true;
5197
5197
  try {
@@ -5474,14 +5474,14 @@ var require_graceful_fs2 = __commonJS({
5474
5474
  return close;
5475
5475
  })(fs5.close);
5476
5476
  fs5.closeSync = (function(fs$closeSync) {
5477
- function closeSync9(fd) {
5477
+ function closeSync8(fd) {
5478
5478
  fs$closeSync.apply(fs5, arguments);
5479
5479
  resetQueue();
5480
5480
  }
5481
- Object.defineProperty(closeSync9, previousSymbol, {
5481
+ Object.defineProperty(closeSync8, previousSymbol, {
5482
5482
  value: fs$closeSync
5483
5483
  });
5484
- return closeSync9;
5484
+ return closeSync8;
5485
5485
  })(fs5.closeSync);
5486
5486
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
5487
5487
  process.on("exit", function() {
@@ -6340,11 +6340,11 @@ var require_util = __commonJS({
6340
6340
  if (files.includes("node_modules") || files.includes("package.json") || files.includes("package.json5") || files.includes("package.yaml") || files.includes("pnpm-workspace.yaml")) {
6341
6341
  return name2;
6342
6342
  }
6343
- const dirname20 = path9.dirname(name2);
6344
- if (dirname20 === name2) {
6343
+ const dirname19 = path9.dirname(name2);
6344
+ if (dirname19 === name2) {
6345
6345
  return original;
6346
6346
  }
6347
- return find(dirname20, original);
6347
+ return find(dirname19, original);
6348
6348
  } catch (error) {
6349
6349
  if (name2 === original) {
6350
6350
  if (error.code === "ENOENT") {
@@ -8313,7 +8313,7 @@ var require_semver2 = __commonJS({
8313
8313
  "node_modules/.pnpm/semver@7.7.4/node_modules/semver/index.js"(exports, module) {
8314
8314
  "use strict";
8315
8315
  var internalRe = require_re();
8316
- var constants9 = require_constants();
8316
+ var constants8 = require_constants();
8317
8317
  var SemVer = require_semver();
8318
8318
  var identifiers = require_identifiers();
8319
8319
  var parse = require_parse();
@@ -8395,8 +8395,8 @@ var require_semver2 = __commonJS({
8395
8395
  re: internalRe.re,
8396
8396
  src: internalRe.src,
8397
8397
  tokens: internalRe.t,
8398
- SEMVER_SPEC_VERSION: constants9.SEMVER_SPEC_VERSION,
8399
- RELEASE_TYPES: constants9.RELEASE_TYPES,
8398
+ SEMVER_SPEC_VERSION: constants8.SEMVER_SPEC_VERSION,
8399
+ RELEASE_TYPES: constants8.RELEASE_TYPES,
8400
8400
  compareIdentifiers: identifiers.compareIdentifiers,
8401
8401
  rcompareIdentifiers: identifiers.rcompareIdentifiers
8402
8402
  };
@@ -16223,8 +16223,8 @@ var require_dist3 = __commonJS({
16223
16223
  });
16224
16224
 
16225
16225
  // src/index.ts
16226
- import { readFileSync as readFileSync22 } from "fs";
16227
- import { dirname as dirname19, resolve as resolve11 } from "path";
16226
+ import { readFileSync as readFileSync21 } from "fs";
16227
+ import { dirname as dirname18, resolve as resolve10 } from "path";
16228
16228
  import { fileURLToPath as fileURLToPath7 } from "url";
16229
16229
 
16230
16230
  // node_modules/.pnpm/commander@12.1.0/node_modules/commander/esm.mjs
@@ -16325,7 +16325,7 @@ var retryifyAsync = (fn, options) => {
16325
16325
  throw error;
16326
16326
  const delay2 = Math.round(interval * Math.random());
16327
16327
  if (delay2 > 0) {
16328
- const delayPromise = new Promise((resolve12) => setTimeout(resolve12, delay2));
16328
+ const delayPromise = new Promise((resolve11) => setTimeout(resolve11, delay2));
16329
16329
  return delayPromise.then(() => attempt.apply(void 0, args));
16330
16330
  } else {
16331
16331
  return attempt.apply(void 0, args);
@@ -17891,14 +17891,14 @@ var TimeoutError = class extends Error {
17891
17891
 
17892
17892
  // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/timeout.js
17893
17893
  async function timeout(request2, init, abortController, options) {
17894
- return new Promise((resolve12, reject) => {
17894
+ return new Promise((resolve11, reject) => {
17895
17895
  const timeoutId = setTimeout(() => {
17896
17896
  if (abortController) {
17897
17897
  abortController.abort();
17898
17898
  }
17899
17899
  reject(new TimeoutError(request2));
17900
17900
  }, options.timeout);
17901
- void options.fetch(request2, init).then(resolve12).catch(reject).then(() => {
17901
+ void options.fetch(request2, init).then(resolve11).catch(reject).then(() => {
17902
17902
  clearTimeout(timeoutId);
17903
17903
  });
17904
17904
  });
@@ -17906,7 +17906,7 @@ async function timeout(request2, init, abortController, options) {
17906
17906
 
17907
17907
  // node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/delay.js
17908
17908
  async function delay(ms, { signal }) {
17909
- return new Promise((resolve12, reject) => {
17909
+ return new Promise((resolve11, reject) => {
17910
17910
  if (signal) {
17911
17911
  signal.throwIfAborted();
17912
17912
  signal.addEventListener("abort", abortHandler, { once: true });
@@ -17917,7 +17917,7 @@ async function delay(ms, { signal }) {
17917
17917
  }
17918
17918
  const timeoutId = setTimeout(() => {
17919
17919
  signal?.removeEventListener("abort", abortHandler);
17920
- resolve12();
17920
+ resolve11();
17921
17921
  }, ms);
17922
17922
  });
17923
17923
  }
@@ -19891,7 +19891,7 @@ function providerError(value) {
19891
19891
  return exactString(error, "error", MAX_USER_CODE_LENGTH);
19892
19892
  }
19893
19893
  async function defaultSleep(milliseconds, signal) {
19894
- await new Promise((resolve12, reject) => {
19894
+ await new Promise((resolve11, reject) => {
19895
19895
  if (signal.aborted) {
19896
19896
  reject(signal.reason);
19897
19897
  return;
@@ -19902,7 +19902,7 @@ async function defaultSleep(milliseconds, signal) {
19902
19902
  };
19903
19903
  const timer = setTimeout(() => {
19904
19904
  signal.removeEventListener("abort", abort);
19905
- resolve12();
19905
+ resolve11();
19906
19906
  }, milliseconds);
19907
19907
  signal.addEventListener("abort", abort, { once: true });
19908
19908
  });
@@ -20147,7 +20147,7 @@ function daemonRequest(method, params = {}, opts = {}) {
20147
20147
  ...caller ? { caller } : {}
20148
20148
  };
20149
20149
  const timeoutMs2 = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
20150
- return new Promise((resolve12) => {
20150
+ return new Promise((resolve11) => {
20151
20151
  let settled = false;
20152
20152
  let socket;
20153
20153
  let buffer = Buffer.alloc(0);
@@ -20162,7 +20162,7 @@ function daemonRequest(method, params = {}, opts = {}) {
20162
20162
  } catch {
20163
20163
  }
20164
20164
  }
20165
- resolve12(value);
20165
+ resolve11(value);
20166
20166
  };
20167
20167
  const timer = setTimeout(() => settle(null), timeoutMs2);
20168
20168
  timer.unref();
@@ -21618,14 +21618,14 @@ function throwIfAborted(signal) {
21618
21618
  }
21619
21619
  async function defaultSleep2(ms, signal) {
21620
21620
  if (!signal) {
21621
- await new Promise((resolve12) => setTimeout(resolve12, ms));
21621
+ await new Promise((resolve11) => setTimeout(resolve11, ms));
21622
21622
  return;
21623
21623
  }
21624
21624
  throwIfAborted(signal);
21625
- await new Promise((resolve12, reject) => {
21625
+ await new Promise((resolve11, reject) => {
21626
21626
  const timer = setTimeout(() => {
21627
21627
  signal.removeEventListener("abort", onAbort);
21628
- resolve12();
21628
+ resolve11();
21629
21629
  }, ms);
21630
21630
  const onAbort = () => {
21631
21631
  clearTimeout(timer);
@@ -35007,8 +35007,8 @@ ${verificationUrl}`);
35007
35007
  const state = base64url(randomBytes3(16));
35008
35008
  const redirectUri = `http://${LOCALHOST}:${CALLBACK_PORT}/callback`;
35009
35009
  let settle;
35010
- const outcome = new Promise((resolve12) => {
35011
- settle = resolve12;
35010
+ const outcome = new Promise((resolve11) => {
35011
+ settle = resolve11;
35012
35012
  });
35013
35013
  const server = createServer((req, res) => {
35014
35014
  const url = new URL(req.url ?? "/", `http://${LOCALHOST}`);
@@ -35022,12 +35022,12 @@ ${verificationUrl}`);
35022
35022
  res.end(page.html, () => settle(page.result));
35023
35023
  });
35024
35024
  try {
35025
- await new Promise((resolve12, reject) => {
35025
+ await new Promise((resolve11, reject) => {
35026
35026
  const onError = (err) => reject(err);
35027
35027
  server.once("error", onError);
35028
35028
  server.listen(CALLBACK_PORT, LOCALHOST, () => {
35029
35029
  server.removeListener("error", onError);
35030
- resolve12();
35030
+ resolve11();
35031
35031
  });
35032
35032
  });
35033
35033
  } catch (err) {
@@ -35925,11 +35925,7 @@ async function applyActivation(active, globals = {}) {
35925
35925
  process.stderr.write(`[prim] Prim is enabled locally in ${root}
35926
35926
  `);
35927
35927
  process.stderr.write(
35928
- "[prim] repository is not connected to Primitive; Moves still ingest into the team graph without repository-specific file attribution, Conflict Gate verification, or commit correlation\n"
35929
- );
35930
- process.stderr.write(
35931
- `[prim] ask an organization owner or administrator to grant Primitive's GitHub App access to this repository through Primitive's GitHub App onboarding; binding retries automatically at the next agent SessionStart
35932
- `
35928
+ "[prim] GitHub repository binding is not connected \u2014 run `prim github connect` when you're ready\n"
35933
35929
  );
35934
35930
  } else {
35935
35931
  process.stderr.write(`[prim] prim ${active ? "enabled" : "disabled"} in ${root}
@@ -37123,7 +37119,7 @@ async function runPinnedEnsure(options) {
37123
37119
  npm_config_fetch_retry_maxtimeout: "5000",
37124
37120
  npm_config_fetch_timeout: "15000"
37125
37121
  };
37126
- return await new Promise((resolve12) => {
37122
+ return await new Promise((resolve11) => {
37127
37123
  let settled = false;
37128
37124
  let child;
37129
37125
  try {
@@ -37133,7 +37129,7 @@ async function runPinnedEnsure(options) {
37133
37129
  { env: env4, stdio: "ignore" }
37134
37130
  );
37135
37131
  } catch {
37136
- resolve12(false);
37132
+ resolve11(false);
37137
37133
  return;
37138
37134
  }
37139
37135
  const timer = setTimeout(() => {
@@ -37144,7 +37140,7 @@ async function runPinnedEnsure(options) {
37144
37140
  if (settled) return;
37145
37141
  settled = true;
37146
37142
  clearTimeout(timer);
37147
- resolve12(result);
37143
+ resolve11(result);
37148
37144
  };
37149
37145
  timer.unref();
37150
37146
  child.once("error", () => finish(false));
@@ -38358,7 +38354,7 @@ function clearStaleArtifacts() {
38358
38354
  }
38359
38355
  }
38360
38356
  function sleep(ms) {
38361
- return new Promise((resolve12) => setTimeout(resolve12, ms));
38357
+ return new Promise((resolve11) => setTimeout(resolve11, ms));
38362
38358
  }
38363
38359
  function spawnDaemon(options) {
38364
38360
  const file = binFile(DAEMON_BIN);
@@ -41234,153 +41230,11 @@ function pendingJournalStats() {
41234
41230
  };
41235
41231
  }
41236
41232
 
41237
- // src/lib/workspace-id.ts
41238
- import { execFileSync as execFileSync5 } from "child_process";
41239
- import { randomUUID as randomUUID3 } from "crypto";
41240
- import {
41241
- constants as constants5,
41242
- chmodSync as chmodSync5,
41243
- closeSync as closeSync5,
41244
- fchmodSync as fchmodSync3,
41245
- fsyncSync as fsyncSync3,
41246
- linkSync,
41247
- lstatSync as lstatSync6,
41248
- mkdirSync as mkdirSync11,
41249
- openSync as openSync5,
41250
- readFileSync as readFileSync14,
41251
- statSync as statSync3,
41252
- unlinkSync as unlinkSync4,
41253
- writeFileSync as writeFileSync8
41254
- } from "fs";
41255
- import { dirname as dirname12, isAbsolute as isAbsolute7, join as join17, resolve as resolve7 } from "path";
41256
- var WORKSPACE_ID_RELATIVE_PATH = join17("prim", "workspace-id");
41257
- var MAX_ANCESTORS = 64;
41258
- var MAX_GIT_FILE_BYTES = 4096;
41259
- var MAX_ID_FILE_BYTES = 128;
41260
- var GIT_FALLBACK_TIMEOUT_MS = 250;
41261
- var CANONICAL_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
41262
- var raceDelay = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
41263
- function isCanonicalWorkspaceId(value) {
41264
- return CANONICAL_UUID.test(value);
41265
- }
41266
- function inspectWorkspaceId(cwd = process.cwd()) {
41267
- const resolved = resolveWorkspaceIdPath(cwd);
41268
- if (resolved.status !== "resolved") return resolved;
41269
- return inspectPath(resolved.path);
41270
- }
41271
- function resolveWorkspaceIdPath(cwd) {
41272
- if (!process.env.GIT_DIR && !process.env.GIT_WORK_TREE) {
41273
- const fromFilesystem = resolveFromFilesystem(cwd);
41274
- if (fromFilesystem) return { status: "resolved", path: fromFilesystem };
41275
- }
41276
- try {
41277
- const output = execFileSync5(
41278
- "git",
41279
- ["rev-parse", "--is-inside-work-tree", "--git-path", WORKSPACE_ID_RELATIVE_PATH],
41280
- {
41281
- cwd,
41282
- encoding: "utf8",
41283
- maxBuffer: 4096,
41284
- stdio: ["ignore", "pipe", "ignore"],
41285
- timeout: GIT_FALLBACK_TIMEOUT_MS,
41286
- windowsHide: true
41287
- }
41288
- );
41289
- const [insideWorktree, gitPath, ...extra] = output.trim().split(/\r?\n/);
41290
- if (insideWorktree !== "true" || !gitPath || extra.length > 0 || gitPath.includes("\0")) {
41291
- return { status: "not_git" };
41292
- }
41293
- return {
41294
- status: "resolved",
41295
- path: isAbsolute7(gitPath) ? resolve7(gitPath) : resolve7(cwd, gitPath)
41296
- };
41297
- } catch (error) {
41298
- const code = errorCode2(error);
41299
- if (code === "ETIMEDOUT" || code === "EACCES" || code === "EPERM") {
41300
- return { status: "unavailable", operation: "resolve", errorCode: code };
41301
- }
41302
- return { status: "not_git" };
41303
- }
41304
- }
41305
- function resolveFromFilesystem(cwd) {
41306
- let current = resolve7(cwd);
41307
- for (let depth = 0; depth < MAX_ANCESTORS; depth += 1) {
41308
- const dotGit = join17(current, ".git");
41309
- try {
41310
- const stat = lstatSync6(dotGit);
41311
- if (stat.isDirectory() && isGitDirectory(dotGit)) {
41312
- return join17(dotGit, WORKSPACE_ID_RELATIVE_PATH);
41313
- }
41314
- if (stat.isFile() && stat.size <= MAX_GIT_FILE_BYTES) {
41315
- const contents = readFileSync14(dotGit, "utf8");
41316
- const match = /^gitdir: (.+?)(?:\r?\n)?$/.exec(contents);
41317
- if (match?.[1]) {
41318
- const gitDirectory = isAbsolute7(match[1]) ? resolve7(match[1]) : resolve7(current, match[1]);
41319
- if (isGitDirectory(gitDirectory)) {
41320
- return join17(gitDirectory, WORKSPACE_ID_RELATIVE_PATH);
41321
- }
41322
- }
41323
- }
41324
- return null;
41325
- } catch (error) {
41326
- const code = errorCode2(error);
41327
- if (code !== "ENOENT" && code !== "ENOTDIR") {
41328
- return null;
41329
- }
41330
- }
41331
- const parent = dirname12(current);
41332
- if (parent === current) break;
41333
- current = parent;
41334
- }
41335
- return null;
41336
- }
41337
- function isGitDirectory(path9) {
41338
- try {
41339
- return statSync3(join17(path9, "HEAD")).isFile();
41340
- } catch {
41341
- return false;
41342
- }
41343
- }
41344
- function inspectPath(path9) {
41345
- let stat;
41346
- try {
41347
- stat = lstatSync6(path9);
41348
- } catch (error) {
41349
- const code = errorCode2(error);
41350
- if (code === "ENOENT" || code === "ENOTDIR") return { status: "missing", path: path9 };
41351
- return { status: "unavailable", path: path9, operation: "read", errorCode: code };
41352
- }
41353
- if (!stat.isFile()) return { status: "corrupt", path: path9, reason: "not_file" };
41354
- if (stat.size > MAX_ID_FILE_BYTES) {
41355
- return { status: "corrupt", path: path9, reason: "invalid_content" };
41356
- }
41357
- try {
41358
- const contents = readFileSync14(path9, "utf8");
41359
- const workspaceId = contents.endsWith("\n") ? contents.slice(0, -1) : contents;
41360
- if ((contents === workspaceId || contents === `${workspaceId}
41361
- `) && isCanonicalWorkspaceId(workspaceId)) {
41362
- return { status: "ready", workspaceId, path: path9, created: false };
41363
- }
41364
- return { status: "corrupt", path: path9, reason: "invalid_content" };
41365
- } catch (error) {
41366
- return {
41367
- status: "unavailable",
41368
- path: path9,
41369
- operation: "read",
41370
- errorCode: errorCode2(error)
41371
- };
41372
- }
41373
- }
41374
- function errorCode2(error) {
41375
- if (typeof error !== "object" || error === null || !("code" in error)) return void 0;
41376
- return typeof error.code === "string" ? error.code : void 0;
41377
- }
41378
-
41379
41233
  // src/commands/hermes-install.ts
41380
41234
  var import_yaml = __toESM(require_dist3(), 1);
41381
- import { existsSync as existsSync13, readFileSync as readFileSync15, rmSync as rmSync6, statSync as statSync4 } from "fs";
41235
+ import { existsSync as existsSync13, readFileSync as readFileSync14, rmSync as rmSync6, statSync as statSync3 } from "fs";
41382
41236
  import { homedir as homedir8 } from "os";
41383
- import { join as join18 } from "path";
41237
+ import { join as join17 } from "path";
41384
41238
  var CAPTURE_BIN3 = "prim-hook";
41385
41239
  var GATE_BIN3 = "prim-pre-tool-use";
41386
41240
  var POST_TOOL_USE_BIN3 = "prim-post-tool-use";
@@ -41392,13 +41246,13 @@ var JSON_INDENT3 = 2;
41392
41246
  var CONFIG_MODE = 384;
41393
41247
  var PRIM_BINS3 = [CAPTURE_BIN3, GATE_BIN3, POST_TOOL_USE_BIN3, SESSION_START_BIN3, SESSION_END_BIN2];
41394
41248
  function hermesHome() {
41395
- return process.env.HERMES_HOME ?? join18(homedir8(), ".hermes");
41249
+ return process.env.HERMES_HOME ?? join17(homedir8(), ".hermes");
41396
41250
  }
41397
41251
  function configPath() {
41398
- return join18(hermesHome(), "config.yaml");
41252
+ return join17(hermesHome(), "config.yaml");
41399
41253
  }
41400
41254
  function legacyShimPath() {
41401
- return join18(hermesHome(), "agent-hooks", "prim-shim.sh");
41255
+ return join17(hermesHome(), "agent-hooks", "prim-shim.sh");
41402
41256
  }
41403
41257
  function commandFor(bin) {
41404
41258
  return stableHookCommand(bin, HERMES_ARGS);
@@ -41513,7 +41367,7 @@ function hookRuntimeResolutions3(hooks) {
41513
41367
  function inspectHookRuntimeResolutions3() {
41514
41368
  const path9 = configPath();
41515
41369
  if (!existsSync13(path9)) return [];
41516
- return hookRuntimeResolutions3(readHooks(parseHermesDocument(readFileSync15(path9, "utf8"))));
41370
+ return hookRuntimeResolutions3(readHooks(parseHermesDocument(readFileSync14(path9, "utf8"))));
41517
41371
  }
41518
41372
  function entryMatchesRegistration3(owned, registration) {
41519
41373
  const expected = entryFor(registration);
@@ -41785,8 +41639,8 @@ function readConfigSnapshot(path9) {
41785
41639
  if (!existsSync13(path9)) return { exists: false, mode: CONFIG_MODE, raw: "" };
41786
41640
  return {
41787
41641
  exists: true,
41788
- mode: statSync4(path9).mode & 511,
41789
- raw: readFileSync15(path9, "utf8")
41642
+ mode: statSync3(path9).mode & 511,
41643
+ raw: readFileSync14(path9, "utf8")
41790
41644
  };
41791
41645
  }
41792
41646
  var CONCURRENT_CONFIG_MESSAGE = "Hermes config changed during update; concurrent changes were preserved, retry the command";
@@ -41795,7 +41649,7 @@ function writeHermesConfigSnapshot(path9, before, after, expectedHooks) {
41795
41649
  ensureParent: true,
41796
41650
  mode: before.mode,
41797
41651
  validate(temporaryPath) {
41798
- const flushed = readFileSync15(temporaryPath, "utf8");
41652
+ const flushed = readFileSync14(temporaryPath, "utf8");
41799
41653
  if (!mergePreservesHermesSemantics(before.raw, flushed, expectedHooks)) {
41800
41654
  throw new Error(INVALID_MERGE_MESSAGE);
41801
41655
  }
@@ -41873,7 +41727,7 @@ function performUninstall3() {
41873
41727
  }
41874
41728
  function performStatus3() {
41875
41729
  const path9 = configPath();
41876
- const raw = existsSync13(path9) ? readFileSync15(path9, "utf8") : "";
41730
+ const raw = existsSync13(path9) ? readFileSync14(path9, "utf8") : "";
41877
41731
  const hooks = raw ? readHooks(parseHermesDocument(raw)) : {};
41878
41732
  return {
41879
41733
  path: path9,
@@ -42180,37 +42034,6 @@ async function checkJournalOrganization() {
42180
42034
  const inspection = await inspectJournalDelivery(buckets);
42181
42035
  return classifyJournalOrganization(new Set(buckets).size, inspection.retainedBuckets);
42182
42036
  }
42183
- function checkWorkspaceIdentity() {
42184
- const identity = inspectWorkspaceId();
42185
- switch (identity.status) {
42186
- case "ready":
42187
- return { name: "feedback-id", status: "ok", detail: "stable worktree identity ready" };
42188
- case "missing":
42189
- return {
42190
- name: "feedback-id",
42191
- status: "warn",
42192
- detail: "not initialized \u2014 the next active hook will create it"
42193
- };
42194
- case "not_git":
42195
- return {
42196
- name: "feedback-id",
42197
- status: "warn",
42198
- detail: "not in a Git worktree \u2014 capture falls back to legacy V1"
42199
- };
42200
- case "corrupt":
42201
- return {
42202
- name: "feedback-id",
42203
- status: "warn",
42204
- detail: "identity is corrupt \u2014 not rotated; capture falls back to legacy V1"
42205
- };
42206
- case "unavailable":
42207
- return {
42208
- name: "feedback-id",
42209
- status: "warn",
42210
- detail: `identity unavailable during ${identity.operation} \u2014 capture falls back to legacy V1`
42211
- };
42212
- }
42213
- }
42214
42037
  function classifyRepositoryBinding(value, current, active) {
42215
42038
  if (current.status === "unbound") {
42216
42039
  if (!active) {
@@ -42224,7 +42047,7 @@ function classifyRepositoryBinding(value, current, active) {
42224
42047
  return {
42225
42048
  name: "repo-binding",
42226
42049
  status: "warn",
42227
- detail: `${localDetail} \u2014 local capture is active, but file scoping, Conflict Gate verification, and commit correlation are unavailable; ask an organization owner/admin to grant the Primitive GitHub App access (retried automatically next SessionStart)`
42050
+ detail: `${localDetail} \u2014 local capture is active; run \`prim github connect\` to connect this GitHub repository`
42228
42051
  };
42229
42052
  }
42230
42053
  if (!isValidRepoSyncId(value)) {
@@ -42579,7 +42402,6 @@ async function collectChecks() {
42579
42402
  checkFeedbackHooks(),
42580
42403
  ...checkAgentHooks(),
42581
42404
  checkHookRuntime(),
42582
- checkWorkspaceIdentity(),
42583
42405
  await checkRepositoryBinding(),
42584
42406
  checkManagedHook("post-commit", inspectEffectivePostCommitHook),
42585
42407
  checkManagedHook("post-rewrite", inspectEffectivePostRewriteHook),
@@ -42607,51 +42429,51 @@ async function runDoctor() {
42607
42429
  }
42608
42430
  function registerDoctorCommands(program3) {
42609
42431
  program3.command("doctor").description(
42610
- "Check capture and feedback health end to end (auth, supervisor, delivery, worktree, server)"
42432
+ "Check capture and feedback health end to end (auth, supervisor, delivery, server)"
42611
42433
  ).action(async () => {
42612
42434
  await runDoctor();
42613
42435
  });
42614
42436
  }
42615
42437
 
42616
42438
  // src/commands/moves.ts
42617
- import { existsSync as existsSync16, mkdirSync as mkdirSync13, unlinkSync as unlinkSync6, writeFileSync as writeFileSync10 } from "fs";
42618
- import { join as join21 } from "path";
42439
+ import { existsSync as existsSync16, mkdirSync as mkdirSync12, unlinkSync as unlinkSync5, writeFileSync as writeFileSync9 } from "fs";
42440
+ import { join as join20 } from "path";
42619
42441
 
42620
42442
  // src/flusher.ts
42621
- import { createReadStream, renameSync as renameSync6, unlinkSync as unlinkSync5 } from "fs";
42622
- import { dirname as dirname14, join as join20 } from "path";
42443
+ import { createReadStream, renameSync as renameSync6, unlinkSync as unlinkSync4 } from "fs";
42444
+ import { dirname as dirname13, join as join19 } from "path";
42623
42445
 
42624
42446
  // src/dead-letter.ts
42625
42447
  import { createHash as createHash9, randomBytes as randomBytes6 } from "crypto";
42626
42448
  import {
42627
- constants as constants6,
42628
- chmodSync as chmodSync6,
42629
- closeSync as closeSync6,
42449
+ constants as constants5,
42450
+ chmodSync as chmodSync5,
42451
+ closeSync as closeSync5,
42630
42452
  existsSync as existsSync15,
42631
- fchmodSync as fchmodSync4,
42632
- fsyncSync as fsyncSync4,
42633
- mkdirSync as mkdirSync12,
42634
- openSync as openSync6,
42453
+ fchmodSync as fchmodSync3,
42454
+ fsyncSync as fsyncSync3,
42455
+ mkdirSync as mkdirSync11,
42456
+ openSync as openSync5,
42635
42457
  renameSync as renameSync5,
42636
42458
  rmSync as rmSync7,
42637
- writeFileSync as writeFileSync9
42459
+ writeFileSync as writeFileSync8
42638
42460
  } from "fs";
42639
- import { dirname as dirname13, join as join19 } from "path";
42461
+ import { dirname as dirname12, join as join18 } from "path";
42640
42462
  var DIRECTORY_MODE3 = 448;
42641
42463
  var FILE_MODE2 = 384;
42642
42464
  var DEAD_LETTER_DIRNAME = "dead-letter";
42643
42465
  function deadLetterDirectoryForRotation(flushingPath) {
42644
- return join19(dirname13(flushingPath), DEAD_LETTER_DIRNAME);
42466
+ return join18(dirname12(flushingPath), DEAD_LETTER_DIRNAME);
42645
42467
  }
42646
42468
  function deadLetterPathForRawLine(flushingPath, rawLine) {
42647
42469
  const quarantineId = createHash9("sha256").update(rawLine).digest("hex");
42648
- return join19(deadLetterDirectoryForRotation(flushingPath), `raw-${quarantineId}.json`);
42470
+ return join18(deadLetterDirectoryForRotation(flushingPath), `raw-${quarantineId}.json`);
42649
42471
  }
42650
42472
  function ensureDeadLetterDirectory(flushingPath, persistDirectory) {
42651
42473
  const directory = deadLetterDirectoryForRotation(flushingPath);
42652
- mkdirSync12(directory, { recursive: true, mode: DIRECTORY_MODE3 });
42653
- chmodSync6(directory, DIRECTORY_MODE3);
42654
- persistDirectory(dirname13(directory));
42474
+ mkdirSync11(directory, { recursive: true, mode: DIRECTORY_MODE3 });
42475
+ chmodSync5(directory, DIRECTORY_MODE3);
42476
+ persistDirectory(dirname12(directory));
42655
42477
  return directory;
42656
42478
  }
42657
42479
  function persistDeadLetter(directory, path9, quarantineId, record2, persistDirectory) {
@@ -42659,20 +42481,20 @@ function persistDeadLetter(directory, path9, quarantineId, record2, persistDirec
42659
42481
  persistDirectory(directory);
42660
42482
  return;
42661
42483
  }
42662
- const temporaryPath = join19(
42484
+ const temporaryPath = join18(
42663
42485
  directory,
42664
42486
  `.${quarantineId}.${String(process.pid)}.${randomBytes6(8).toString("hex")}.tmp`
42665
42487
  );
42666
- const flags = constants6.O_CREAT | constants6.O_EXCL | constants6.O_WRONLY | constants6.O_NOFOLLOW;
42488
+ const flags = constants5.O_CREAT | constants5.O_EXCL | constants5.O_WRONLY | constants5.O_NOFOLLOW;
42667
42489
  try {
42668
- const fd = openSync6(temporaryPath, flags, FILE_MODE2);
42490
+ const fd = openSync5(temporaryPath, flags, FILE_MODE2);
42669
42491
  try {
42670
- fchmodSync4(fd, FILE_MODE2);
42671
- writeFileSync9(fd, `${JSON.stringify(record2)}
42492
+ fchmodSync3(fd, FILE_MODE2);
42493
+ writeFileSync8(fd, `${JSON.stringify(record2)}
42672
42494
  `, "utf8");
42673
- fsyncSync4(fd);
42495
+ fsyncSync3(fd);
42674
42496
  } finally {
42675
- closeSync6(fd);
42497
+ closeSync5(fd);
42676
42498
  }
42677
42499
  renameSync5(temporaryPath, path9);
42678
42500
  persistDirectory(directory);
@@ -42691,7 +42513,7 @@ function quarantineMove(flushingPath, move, reason, now = Date.now, options = {}
42691
42513
  reason,
42692
42514
  move
42693
42515
  };
42694
- const path9 = join19(directory, `${record2.quarantineId}.json`);
42516
+ const path9 = join18(directory, `${record2.quarantineId}.json`);
42695
42517
  persistDeadLetter(directory, path9, record2.quarantineId, record2, persistDirectory);
42696
42518
  return record2;
42697
42519
  }
@@ -42771,11 +42593,11 @@ function deadLetterReason(error) {
42771
42593
  return "invalid_move";
42772
42594
  }
42773
42595
  if (error.status === 409 && typeof error.body === "object" && error.body !== null && !Array.isArray(error.body)) {
42774
- const errorCode3 = error.body.error;
42775
- if (errorCode3 === "move_id_conflict") {
42596
+ const errorCode2 = error.body.error;
42597
+ if (errorCode2 === "move_id_conflict") {
42776
42598
  return "move_id_conflict";
42777
42599
  }
42778
- if (errorCode3 === "capture_authority_mismatch") {
42600
+ if (errorCode2 === "capture_authority_mismatch") {
42779
42601
  return "tenant_mismatch";
42780
42602
  }
42781
42603
  }
@@ -42883,7 +42705,7 @@ async function drainFlushingPath(flushingPath, client, binding, options = {}) {
42883
42705
  } finally {
42884
42706
  input.destroy();
42885
42707
  }
42886
- unlinkSync5(flushingPath);
42708
+ unlinkSync4(flushingPath);
42887
42709
  return counts;
42888
42710
  }
42889
42711
  async function drainPath(path9, client, binding) {
@@ -42988,7 +42810,7 @@ async function flushOnce() {
42988
42810
  return inspection.retainedBuckets.length > 0 ? { flushed: total, quarantined, retained: inspection.retainedBuckets } : { flushed: total, quarantined };
42989
42811
  }
42990
42812
  var flushInFlight;
42991
- var FLUSH_LOCK_PATH = join20(dirname14(JOURNAL_DIR), ".flush.lock");
42813
+ var FLUSH_LOCK_PATH = join19(dirname13(JOURNAL_DIR), ".flush.lock");
42992
42814
  var FLUSH_LOCK_TIMEOUT_MS = 250;
42993
42815
  function isFlushLockContended(error) {
42994
42816
  return error instanceof Error && error.message.startsWith("timed out waiting for file lock");
@@ -43122,23 +42944,23 @@ function registerMovesCommands(program3) {
43122
42944
  }
43123
42945
  });
43124
42946
  moves.command("bind").description("Pin the current directory to an org via .prim/workspace.json").requiredOption("--orgId <orgId>", "Convex organization id").action((opts) => {
43125
- const dir = join21(process.cwd(), ".prim");
42947
+ const dir = join20(process.cwd(), ".prim");
43126
42948
  if (!existsSync16(dir)) {
43127
- mkdirSync13(dir, { recursive: true, mode: DIR_MODE });
42949
+ mkdirSync12(dir, { recursive: true, mode: DIR_MODE });
43128
42950
  }
43129
- const file = join21(process.cwd(), WORKSPACE_FILE);
43130
- writeFileSync10(file, JSON.stringify({ orgId: opts.orgId, boundAt: Date.now() }, null, 2), {
42951
+ const file = join20(process.cwd(), WORKSPACE_FILE);
42952
+ writeFileSync9(file, JSON.stringify({ orgId: opts.orgId, boundAt: Date.now() }, null, 2), {
43131
42953
  mode: FILE_MODE3
43132
42954
  });
43133
42955
  console.log(`[prim] bound ${process.cwd()} to org ${opts.orgId}`);
43134
42956
  });
43135
42957
  moves.command("drop").description("Remove the .prim/workspace.json binding from the cwd").action(() => {
43136
- const file = join21(process.cwd(), WORKSPACE_FILE);
42958
+ const file = join20(process.cwd(), WORKSPACE_FILE);
43137
42959
  if (!existsSync16(file)) {
43138
42960
  console.log("[prim] no workspace binding in cwd");
43139
42961
  return;
43140
42962
  }
43141
- unlinkSync6(file);
42963
+ unlinkSync5(file);
43142
42964
  console.log(`[prim] dropped workspace binding from ${process.cwd()}`);
43143
42965
  });
43144
42966
  }
@@ -43226,30 +43048,30 @@ function registerReconcileCommands(program3) {
43226
43048
  // src/commands/session.ts
43227
43049
  import {
43228
43050
  existsSync as existsSync18,
43229
- mkdirSync as mkdirSync14,
43230
- readFileSync as readFileSync17,
43051
+ mkdirSync as mkdirSync13,
43052
+ readFileSync as readFileSync16,
43231
43053
  readdirSync as readdirSync5,
43232
- unlinkSync as unlinkSync7,
43233
- writeFileSync as writeFileSync11
43054
+ unlinkSync as unlinkSync6,
43055
+ writeFileSync as writeFileSync10
43234
43056
  } from "fs";
43235
- import { join as join23 } from "path";
43057
+ import { join as join22 } from "path";
43236
43058
 
43237
43059
  // src/binding.ts
43238
- import { existsSync as existsSync17, readFileSync as readFileSync16 } from "fs";
43239
- import { dirname as dirname15, join as join22 } from "path";
43060
+ import { existsSync as existsSync17, readFileSync as readFileSync15 } from "fs";
43061
+ import { dirname as dirname14, join as join21 } from "path";
43240
43062
  var PRIM_CONFIG_DIR = primConfigDirectory();
43241
- var SESSIONS_DIR = join22(PRIM_CONFIG_DIR, "sessions");
43063
+ var SESSIONS_DIR = join21(PRIM_CONFIG_DIR, "sessions");
43242
43064
 
43243
43065
  // src/commands/session.ts
43244
43066
  var DIR_MODE2 = 448;
43245
43067
  var FILE_MODE4 = 384;
43246
43068
  function ensureDir() {
43247
43069
  if (!existsSync18(SESSIONS_DIR)) {
43248
- mkdirSync14(SESSIONS_DIR, { recursive: true, mode: DIR_MODE2 });
43070
+ mkdirSync13(SESSIONS_DIR, { recursive: true, mode: DIR_MODE2 });
43249
43071
  }
43250
43072
  }
43251
43073
  function markerPath(sessionId) {
43252
- return join23(SESSIONS_DIR, `${sessionId}.json`);
43074
+ return join22(SESSIONS_DIR, `${sessionId}.json`);
43253
43075
  }
43254
43076
  function registerSessionCommands(program3) {
43255
43077
  const session = program3.command("session").description("Decision Event Pipeline \u2014 session binding markers");
@@ -43259,7 +43081,7 @@ function registerSessionCommands(program3) {
43259
43081
  orgId: opts.orgId,
43260
43082
  startedAt: Date.now()
43261
43083
  };
43262
- writeFileSync11(markerPath(sessionId), JSON.stringify(marker, null, 2), {
43084
+ writeFileSync10(markerPath(sessionId), JSON.stringify(marker, null, 2), {
43263
43085
  mode: FILE_MODE4
43264
43086
  });
43265
43087
  console.log(`[prim] session ${sessionId} bound to org ${opts.orgId}`);
@@ -43277,7 +43099,7 @@ function registerSessionCommands(program3) {
43277
43099
  for (const f of files) {
43278
43100
  const sessionId = f.replace(/\.json$/, "");
43279
43101
  try {
43280
- const m = JSON.parse(readFileSync17(join23(SESSIONS_DIR, f), "utf-8"));
43102
+ const m = JSON.parse(readFileSync16(join22(SESSIONS_DIR, f), "utf-8"));
43281
43103
  console.log(`${sessionId} org=${m.orgId}`);
43282
43104
  } catch {
43283
43105
  }
@@ -43289,15 +43111,15 @@ function registerSessionCommands(program3) {
43289
43111
  console.log(`[prim] no marker for session ${sessionId}`);
43290
43112
  return;
43291
43113
  }
43292
- unlinkSync7(p);
43114
+ unlinkSync6(p);
43293
43115
  console.log(`[prim] dropped session marker ${sessionId}`);
43294
43116
  });
43295
43117
  }
43296
43118
 
43297
43119
  // src/commands/setup.ts
43298
43120
  import { spawnSync as spawnSync2 } from "child_process";
43299
- import { existsSync as existsSync19, readFileSync as readFileSync18 } from "fs";
43300
- import { join as join24 } from "path";
43121
+ import { existsSync as existsSync19, readFileSync as readFileSync17 } from "fs";
43122
+ import { join as join23 } from "path";
43301
43123
  var EXIT_INCOMPLETE = 1;
43302
43124
  var EXIT_USAGE3 = 2;
43303
43125
  var SESSION_LABELS = {
@@ -43378,8 +43200,8 @@ function detectProjectConflicts(agent, run) {
43378
43200
  }
43379
43201
  try {
43380
43202
  const root = gitToplevel();
43381
- const preCommit = root && join24(root, ".git", "hooks", "pre-commit");
43382
- if (preCommit && existsSync19(preCommit) && readFileSync18(preCommit, "utf-8").includes("prim-pre-commit")) {
43203
+ const preCommit = root && join23(root, ".git", "hooks", "pre-commit");
43204
+ if (preCommit && existsSync19(preCommit) && readFileSync17(preCommit, "utf-8").includes("prim-pre-commit")) {
43383
43205
  conflicts.push(CONFLICT_HOOKS);
43384
43206
  }
43385
43207
  } catch {
@@ -43541,17 +43363,17 @@ function registerSetupCommand(program3, dependencies = {}) {
43541
43363
 
43542
43364
  // src/commands/skill.ts
43543
43365
  import {
43544
- constants as constants8,
43545
- closeSync as closeSync8,
43366
+ constants as constants7,
43367
+ closeSync as closeSync7,
43546
43368
  existsSync as existsSync21,
43547
43369
  fstatSync as fstatSync3,
43548
- lstatSync as lstatSync8,
43549
- openSync as openSync8,
43550
- readFileSync as readFileSync20,
43370
+ lstatSync as lstatSync7,
43371
+ openSync as openSync7,
43372
+ readFileSync as readFileSync19,
43551
43373
  readSync as readSync3
43552
43374
  } from "fs";
43553
43375
  import { homedir as homedir10 } from "os";
43554
- import { dirname as dirname17, join as join27, resolve as resolve9 } from "path";
43376
+ import { dirname as dirname16, join as join26, resolve as resolve8 } from "path";
43555
43377
  import { fileURLToPath as fileURLToPath5 } from "url";
43556
43378
 
43557
43379
  // node_modules/.pnpm/diff@5.2.2/node_modules/diff/lib/index.mjs
@@ -43721,7 +43543,7 @@ Diff.prototype = {
43721
43543
  tokenize: function tokenize(value) {
43722
43544
  return value.split("");
43723
43545
  },
43724
- join: function join25(chars) {
43546
+ join: function join24(chars) {
43725
43547
  return chars.join("");
43726
43548
  }
43727
43549
  };
@@ -44063,14 +43885,14 @@ var import_yaml3 = __toESM(require_dist3(), 1);
44063
43885
  var import_yaml2 = __toESM(require_dist3(), 1);
44064
43886
  import { createHash as createHash10 } from "crypto";
44065
43887
  import {
44066
- constants as constants7,
44067
- closeSync as closeSync7,
43888
+ constants as constants6,
43889
+ closeSync as closeSync6,
44068
43890
  existsSync as existsSync20,
44069
43891
  fstatSync as fstatSync2,
44070
- lstatSync as lstatSync7,
44071
- mkdirSync as mkdirSync15,
44072
- openSync as openSync7,
44073
- readFileSync as readFileSync19,
43892
+ lstatSync as lstatSync6,
43893
+ mkdirSync as mkdirSync14,
43894
+ openSync as openSync6,
43895
+ readFileSync as readFileSync18,
44074
43896
  readSync as readSync2,
44075
43897
  readdirSync as readdirSync6,
44076
43898
  realpathSync as realpathSync4,
@@ -44078,15 +43900,15 @@ import {
44078
43900
  rmdirSync
44079
43901
  } from "fs";
44080
43902
  import { homedir as homedir9 } from "os";
44081
- import { dirname as dirname16, isAbsolute as isAbsolute8, join as join26, relative as relative2, resolve as resolve8, sep as sep2 } from "path";
43903
+ import { dirname as dirname15, isAbsolute as isAbsolute7, join as join25, relative as relative2, resolve as resolve7, sep as sep2 } from "path";
44082
43904
  import { fileURLToPath as fileURLToPath4 } from "url";
44083
- var __dirname4 = dirname16(fileURLToPath4(import.meta.url));
43905
+ var __dirname4 = dirname15(fileURLToPath4(import.meta.url));
44084
43906
  var PLUGIN_DESCRIPTION = "Primitive decision-graph guidance for the prim CLI \u2014 a model-invoked skill installed by prim skill install.";
44085
43907
  var MAX_MANIFEST_BYTES2 = 64 * 1024;
44086
43908
  var MAX_SKILL_BYTES = 1024 * 1024;
44087
43909
  function pluginDirFor(cwd, scope) {
44088
- const base = scope === "user" ? join26(homedir9(), ".claude") : join26(gitToplevel(cwd) ?? cwd, ".claude");
44089
- return join26(base, "skills", "prim");
43910
+ const base = scope === "user" ? join25(homedir9(), ".claude") : join25(gitToplevel(cwd) ?? cwd, ".claude");
43911
+ return join25(base, "skills", "prim");
44090
43912
  }
44091
43913
  function resolvePluginDir(cwd, scope) {
44092
43914
  if (scope && scope !== "user" && scope !== "project") {
@@ -44097,10 +43919,10 @@ function resolvePluginDir(cwd, scope) {
44097
43919
  }
44098
43920
  function packageVersion2() {
44099
43921
  let dir = __dirname4;
44100
- while (dir !== dirname16(dir)) {
44101
- const p = resolve8(dir, "package.json");
44102
- if (existsSync20(p)) return JSON.parse(readFileSync19(p, "utf-8")).version;
44103
- dir = dirname16(dir);
43922
+ while (dir !== dirname15(dir)) {
43923
+ const p = resolve7(dir, "package.json");
43924
+ if (existsSync20(p)) return JSON.parse(readFileSync18(p, "utf-8")).version;
43925
+ dir = dirname15(dir);
44104
43926
  }
44105
43927
  return "0.0.0";
44106
43928
  }
@@ -44118,8 +43940,8 @@ function removeDirIfEmpty(dir) {
44118
43940
  }
44119
43941
  function pluginPaths(dir) {
44120
43942
  return {
44121
- manifestPath: join26(dir, ".claude-plugin", "plugin.json"),
44122
- skillPath: join26(dir, "SKILL.md")
43943
+ manifestPath: join25(dir, ".claude-plugin", "plugin.json"),
43944
+ skillPath: join25(dir, "SKILL.md")
44123
43945
  };
44124
43946
  }
44125
43947
  function installClaudePlugin(cwd, opts) {
@@ -44127,8 +43949,8 @@ function installClaudePlugin(cwd, opts) {
44127
43949
  if (dir === null) return 1;
44128
43950
  const { manifestPath, skillPath } = pluginPaths(dir);
44129
43951
  const { manifest, skill } = renderClaudePlugin();
44130
- const manifestCurrent = existsSync20(manifestPath) ? readFileSync19(manifestPath, "utf-8") : null;
44131
- const skillCurrent = existsSync20(skillPath) ? readFileSync19(skillPath, "utf-8") : null;
43952
+ const manifestCurrent = existsSync20(manifestPath) ? readFileSync18(manifestPath, "utf-8") : null;
43953
+ const skillCurrent = existsSync20(skillPath) ? readFileSync18(skillPath, "utf-8") : null;
44132
43954
  if (manifestCurrent === manifest && skillCurrent === skill) {
44133
43955
  console.log("No changes \u2014 prim skill plugin already up to date.");
44134
43956
  return 0;
@@ -44137,7 +43959,7 @@ function installClaudePlugin(cwd, opts) {
44137
43959
  console.log(`Would write plugin to ${dir} (.claude-plugin/plugin.json + SKILL.md)`);
44138
43960
  return 0;
44139
43961
  }
44140
- mkdirSync15(join26(dir, ".claude-plugin"), { recursive: true });
43962
+ mkdirSync14(join25(dir, ".claude-plugin"), { recursive: true });
44141
43963
  atomicWrite4(manifestPath, manifest);
44142
43964
  atomicWrite4(skillPath, skill);
44143
43965
  console.log(`Installed prim skill plugin at ${dir}`);
@@ -44157,7 +43979,7 @@ function uninstallClaudePlugin(cwd, opts) {
44157
43979
  }
44158
43980
  rmSync8(manifestPath, { force: true });
44159
43981
  rmSync8(skillPath, { force: true });
44160
- removeDirIfEmpty(join26(dir, ".claude-plugin"));
43982
+ removeDirIfEmpty(join25(dir, ".claude-plugin"));
44161
43983
  removeDirIfEmpty(dir);
44162
43984
  console.log(`Removed prim skill plugin from ${dir}`);
44163
43985
  return 0;
@@ -44180,7 +44002,7 @@ function statusClaudePlugin(cwd, opts) {
44180
44002
  }
44181
44003
 
44182
44004
  // src/commands/skill.ts
44183
- var __dirname5 = dirname17(fileURLToPath5(import.meta.url));
44005
+ var __dirname5 = dirname16(fileURLToPath5(import.meta.url));
44184
44006
  var SKILL_BEGIN = "<!-- BEGIN PRIM SKILL v1 -->";
44185
44007
  var SKILL_END = "<!-- END PRIM SKILL v1 -->";
44186
44008
  var CODEX_GUIDANCE_LIMIT_BYTES = 1024 * 1024;
@@ -44202,24 +44024,24 @@ var AGENT_TARGET = {
44202
44024
  hermes: ".hermes.md"
44203
44025
  };
44204
44026
  function userTargetFor(agent) {
44205
- if (agent === "claude") return join27(homedir10(), ".claude", "CLAUDE.md");
44206
- if (agent === "codex") return join27(homedir10(), ".codex", "AGENTS.md");
44027
+ if (agent === "claude") return join26(homedir10(), ".claude", "CLAUDE.md");
44028
+ if (agent === "codex") return join26(homedir10(), ".codex", "AGENTS.md");
44207
44029
  if (agent === "hermes") {
44208
- return join27(process.env.HERMES_HOME ?? join27(homedir10(), ".hermes"), ".hermes.md");
44030
+ return join26(process.env.HERMES_HOME ?? join26(homedir10(), ".hermes"), ".hermes.md");
44209
44031
  }
44210
44032
  return null;
44211
44033
  }
44212
44034
  function loadSkill() {
44213
44035
  let dir = __dirname5;
44214
- while (dir !== dirname17(dir)) {
44215
- const p = resolve9(dir, "SKILL.md");
44216
- if (existsSync21(p)) return readFileSync20(p, "utf-8");
44217
- dir = dirname17(dir);
44036
+ while (dir !== dirname16(dir)) {
44037
+ const p = resolve8(dir, "SKILL.md");
44038
+ if (existsSync21(p)) return readFileSync19(p, "utf-8");
44039
+ dir = dirname16(dir);
44218
44040
  }
44219
44041
  throw new Error("SKILL.md not found in package");
44220
44042
  }
44221
44043
  function detectTargets(cwd) {
44222
- return TARGET_CANDIDATES.filter((p) => existsSync21(resolve9(cwd, p)));
44044
+ return TARGET_CANDIDATES.filter((p) => existsSync21(resolve8(cwd, p)));
44223
44045
  }
44224
44046
  function detectNewline(content) {
44225
44047
  return content.includes("\r\n") ? "\r\n" : "\n";
@@ -44253,7 +44075,7 @@ function resolveTarget(cwd, opts) {
44253
44075
  console.error(`Unknown --scope "${opts.scope}" (expected user or project)`);
44254
44076
  return null;
44255
44077
  }
44256
- if (opts.target) return resolve9(cwd, opts.target);
44078
+ if (opts.target) return resolve8(cwd, opts.target);
44257
44079
  if (opts.scope === "user") {
44258
44080
  if (!opts.agent) {
44259
44081
  console.error("--scope user requires --agent (claude, codex, or hermes)");
@@ -44266,13 +44088,13 @@ function resolveTarget(cwd, opts) {
44266
44088
  }
44267
44089
  if (opts.agent) {
44268
44090
  const mapped = AGENT_TARGET[opts.agent];
44269
- if (typeof mapped === "string") return resolve9(cwd, mapped);
44091
+ if (typeof mapped === "string") return resolve8(cwd, mapped);
44270
44092
  console.error(`Unknown --agent "${opts.agent}" (expected claude, codex, or hermes)`);
44271
44093
  return null;
44272
44094
  }
44273
44095
  const matches = detectTargets(cwd);
44274
- if (matches.length === 0) return resolve9(cwd, DEFAULT_TARGET);
44275
- if (matches.length === 1) return resolve9(cwd, matches[0]);
44096
+ if (matches.length === 0) return resolve8(cwd, DEFAULT_TARGET);
44097
+ if (matches.length === 1) return resolve8(cwd, matches[0]);
44276
44098
  console.error("Multiple rules files detected. Use --target to disambiguate:");
44277
44099
  for (const m of matches) console.error(` ${m}`);
44278
44100
  return null;
@@ -44281,7 +44103,7 @@ function runInstall(cwd, opts) {
44281
44103
  if (opts.agent === "claude" && !opts.target) return installClaudePlugin(cwd, opts);
44282
44104
  const target = resolveTarget(cwd, opts);
44283
44105
  if (target === null) return 1;
44284
- const existing = existsSync21(target) ? readFileSync20(target, "utf-8") : "";
44106
+ const existing = existsSync21(target) ? readFileSync19(target, "utf-8") : "";
44285
44107
  const eol = existing ? detectNewline(existing) : "\n";
44286
44108
  const block = composeBlock(loadSkill(), eol);
44287
44109
  const next = applyBlock(existing, block, eol);
@@ -44305,7 +44127,7 @@ function runUninstall(cwd, opts) {
44305
44127
  console.log(`Skill block not present at ${target}`);
44306
44128
  return 0;
44307
44129
  }
44308
- const existing = readFileSync20(target, "utf-8");
44130
+ const existing = readFileSync19(target, "utf-8");
44309
44131
  const next = removeBlock(existing);
44310
44132
  if (next === null) {
44311
44133
  console.log(`Skill block not present at ${target}`);
@@ -44322,7 +44144,7 @@ function runStatus(cwd, opts) {
44322
44144
  const fileExists = existsSync21(target);
44323
44145
  let installed = false;
44324
44146
  if (fileExists) {
44325
- const content = readFileSync20(target, "utf-8");
44147
+ const content = readFileSync19(target, "utf-8");
44326
44148
  installed = content.includes(SKILL_BEGIN) && content.includes(SKILL_END);
44327
44149
  }
44328
44150
  if (opts.json) {
@@ -44359,23 +44181,23 @@ function registerSkillCommands(program3) {
44359
44181
  }
44360
44182
 
44361
44183
  // src/commands/statusline.ts
44362
- import { readFileSync as readFileSync21 } from "fs";
44363
- import { dirname as dirname18, resolve as resolve10 } from "path";
44184
+ import { readFileSync as readFileSync20 } from "fs";
44185
+ import { dirname as dirname17, resolve as resolve9 } from "path";
44364
44186
  import { fileURLToPath as fileURLToPath6 } from "url";
44365
44187
  var STATUSLINE_TIMEOUT_MS = 200;
44366
44188
  function readPackageVersion() {
44367
44189
  try {
44368
- const here = dirname18(fileURLToPath6(import.meta.url));
44190
+ const here = dirname17(fileURLToPath6(import.meta.url));
44369
44191
  const candidates = [
44370
44192
  // Schema-v2 runtimes staged a manifest beside this standalone bundle.
44371
44193
  // Keep resolving it while those legacy launchers transition to schema v3.
44372
- resolve10(here, "manifest.json"),
44373
- resolve10(here, "../../package.json"),
44374
- resolve10(here, "../package.json")
44194
+ resolve9(here, "manifest.json"),
44195
+ resolve9(here, "../../package.json"),
44196
+ resolve9(here, "../package.json")
44375
44197
  ];
44376
44198
  for (const path9 of candidates) {
44377
44199
  try {
44378
- const pkg2 = JSON.parse(readFileSync21(path9, "utf-8"));
44200
+ const pkg2 = JSON.parse(readFileSync20(path9, "utf-8"));
44379
44201
  if (pkg2.version) {
44380
44202
  return pkg2.version;
44381
44203
  }
@@ -44794,8 +44616,8 @@ function runStartupBackgroundWork(argv, env4, work) {
44794
44616
  }
44795
44617
 
44796
44618
  // src/index.ts
44797
- var __dirname6 = dirname19(fileURLToPath7(import.meta.url));
44798
- var pkg = JSON.parse(readFileSync22(resolve11(__dirname6, "../package.json"), "utf-8"));
44619
+ var __dirname6 = dirname18(fileURLToPath7(import.meta.url));
44620
+ var pkg = JSON.parse(readFileSync21(resolve10(__dirname6, "../package.json"), "utf-8"));
44799
44621
  runStartupBackgroundWork(process.argv.slice(2), process.env, {
44800
44622
  notify: () => updateNotifier({ pkg }).notify(),
44801
44623
  flush: () => flushIfNeeded()