@appchy/jarvis 0.1.99 → 0.1.100

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.
package/dist/bin.js CHANGED
@@ -10260,7 +10260,7 @@ import { createRequire as createRequire2 } from "module";
10260
10260
  var _require = createRequire2(import.meta.url);
10261
10261
  var VERSION2 = _require("../package.json").version ?? "0.0.0";
10262
10262
  var IS_DEV = String(_require("../package.json").name ?? "").endsWith("-dev");
10263
- var SHA = "dd93b07";
10263
+ var SHA = "07085df";
10264
10264
  var BUILT = "2026-09-11";
10265
10265
  var BUILD = SHA ?? "source";
10266
10266
  var BUILD_LABEL = `${SHA ? `${VERSION2} (${SHA}${BUILT ? ` ${BUILT}` : ""})` : `${VERSION2} (source)`}${IS_DEV ? " \u2014 development build" : ""}`;
@@ -11408,19 +11408,36 @@ async function runBuild(cwd, argv = []) {
11408
11408
  if (argv.includes("--rebuild")) process.env.JARVIS_DATA_REBUILD = "1";
11409
11409
  else process.env.JARVIS_DATA_REFRESH = "1";
11410
11410
  if (argv.includes("--label")) process.env.JARVIS_DATA_LABEL = "1";
11411
- const lock = acquireBuildLock(cwd);
11411
+ const gate = argv.includes("--gate");
11412
+ const lock = gate ? await awaitBuildLock(cwd) : acquireBuildLock(cwd);
11412
11413
  if (!lock) {
11414
+ if (gate) {
11415
+ process.stderr.write(
11416
+ "[data] another build held the lock for the whole wait, so this gate measured NOTHING. Reporting that rather than a pass \u2014 re-run it once the other build is done.\n"
11417
+ );
11418
+ return 1;
11419
+ }
11413
11420
  process.stderr.write(
11414
11421
  "[data] a build is already running for this repo \u2014 skipping (it will refresh the graph).\n"
11415
11422
  );
11416
11423
  return 0;
11417
11424
  }
11418
11425
  try {
11419
- return await build(cwd, argv.includes("--gate"));
11426
+ return await build(cwd, gate);
11420
11427
  } finally {
11421
11428
  lock.release();
11422
11429
  }
11423
11430
  }
11431
+ var GATE_LOCK_WAIT_MS = 5 * 6e4;
11432
+ async function awaitBuildLock(cwd, timeoutMs = GATE_LOCK_WAIT_MS) {
11433
+ const deadline = Date.now() + timeoutMs;
11434
+ for (; ; ) {
11435
+ const lock = acquireBuildLock(cwd);
11436
+ if (lock) return lock;
11437
+ if (Date.now() >= deadline) return null;
11438
+ await new Promise((done) => setTimeout(done, 500));
11439
+ }
11440
+ }
11424
11441
  async function build(cwd, gate = false) {
11425
11442
  const config2 = await loadConfig2(cwd);
11426
11443
  if (config2.backend?.name === "graphify") await ensureGraphify();
@@ -11497,7 +11514,7 @@ function acquireBuildLock(repoRoot, options = {}) {
11497
11514
  }
11498
11515
  function isStale(lockPath, staleMs) {
11499
11516
  try {
11500
- return Date.now() - statSync3(lockPath).mtimeMs >= staleMs;
11517
+ return Math.max(0, Date.now() - statSync3(lockPath).mtimeMs) >= staleMs;
11501
11518
  } catch {
11502
11519
  return true;
11503
11520
  }