gipity 1.1.29 → 1.1.30

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.
@@ -1,5 +1,6 @@
1
1
  import { Command } from 'commander';
2
2
  import { runCheck } from '../updater/check.js';
3
+ import { PKG_ROOT } from '../updater/state.js';
3
4
  import { success, warning, info, dim } from '../colors.js';
4
5
  export const updateCommand = new Command('update')
5
6
  .description('Update the CLI')
@@ -15,9 +16,10 @@ export const updateCommand = new Command('update')
15
16
  upToDate: result.reason === 'up-to-date',
16
17
  from: result.from ?? null,
17
18
  to: result.to ?? null,
18
- reason: result.updated || result.reason === 'up-to-date' ? null : result.reason ?? null,
19
+ devLink: result.reason === 'dev-link',
20
+ reason: result.updated || result.reason === 'up-to-date' || result.reason === 'dev-link' ? null : result.reason ?? null,
19
21
  }));
20
- if (!result.updated && result.reason !== 'up-to-date')
22
+ if (!result.updated && result.reason !== 'up-to-date' && result.reason !== 'dev-link')
21
23
  process.exitCode = 1;
22
24
  return;
23
25
  }
@@ -26,6 +28,10 @@ export const updateCommand = new Command('update')
26
28
  console.log(success(`Updated ${result.from} → ${result.to}`));
27
29
  console.log(dim(`Installed. This command ran on ${result.from}; everything from here on uses ${result.to}.`));
28
30
  }
31
+ else if (result.reason === 'dev-link') {
32
+ console.log(info(`This gipity is linked to a source checkout (${PKG_ROOT}) and runs its build, so it never auto-updates.`));
33
+ console.log(dim('To update it, pull that checkout and run `just cli-link` there.'));
34
+ }
29
35
  else if (result.reason === 'up-to-date') {
30
36
  console.log(success('Already on the latest version.'));
31
37
  }
package/dist/index.js CHANGED
@@ -3979,10 +3979,10 @@ function prompt(question, output = process.stdout) {
3979
3979
  return Promise.reject(new Error(`prompt() called without a TTY: ${question.trim()}`));
3980
3980
  }
3981
3981
  const rl2 = createInterface({ input: process.stdin, output });
3982
- return new Promise((resolve20) => {
3982
+ return new Promise((resolve21) => {
3983
3983
  rl2.question(question, (answer) => {
3984
3984
  rl2.close();
3985
- resolve20(answer.trim());
3985
+ resolve21(answer.trim());
3986
3986
  });
3987
3987
  });
3988
3988
  }
@@ -4013,7 +4013,7 @@ async function confirm(question, opts = {}) {
4013
4013
  const wasRaw = stdin.isRaw ?? false;
4014
4014
  stdin.setRawMode(true);
4015
4015
  stdin.resume();
4016
- return new Promise((resolve20) => {
4016
+ return new Promise((resolve21) => {
4017
4017
  stdin.once("data", (key) => {
4018
4018
  stdin.setRawMode(wasRaw);
4019
4019
  stdin.pause();
@@ -4028,12 +4028,12 @@ async function confirm(question, opts = {}) {
4028
4028
  else if (k7 === "n") answer = false;
4029
4029
  else answer = defaultYes;
4030
4030
  console.log(answer ? "y" : "n");
4031
- resolve20(answer);
4031
+ resolve21(answer);
4032
4032
  });
4033
4033
  });
4034
4034
  }
4035
4035
  function pickOne(label2, max, defaultIdx = 1) {
4036
- return new Promise((resolve20, reject) => {
4036
+ return new Promise((resolve21, reject) => {
4037
4037
  process.stdout.write(` ${bold(label2)} (1-${max}) [${bold(String(defaultIdx))}]: `);
4038
4038
  const { stdin } = process;
4039
4039
  const wasRaw = stdin.isRaw ?? false;
@@ -4055,13 +4055,13 @@ function pickOne(label2, max, defaultIdx = 1) {
4055
4055
  if (ch === "\r" || ch === "\n") {
4056
4056
  cleanup();
4057
4057
  console.log(String(defaultIdx));
4058
- return resolve20(defaultIdx);
4058
+ return resolve21(defaultIdx);
4059
4059
  }
4060
4060
  const n = parseInt(ch, 10);
4061
4061
  if (n >= 1 && n <= max) {
4062
4062
  cleanup();
4063
4063
  console.log(String(n));
4064
- return resolve20(n);
4064
+ return resolve21(n);
4065
4065
  }
4066
4066
  };
4067
4067
  const onEnd = () => {
@@ -5420,8 +5420,8 @@ var require_streamx = __commonJS({
5420
5420
  return this;
5421
5421
  },
5422
5422
  next() {
5423
- return new Promise(function(resolve20, reject) {
5424
- promiseResolve = resolve20;
5423
+ return new Promise(function(resolve21, reject) {
5424
+ promiseResolve = resolve21;
5425
5425
  promiseReject = reject;
5426
5426
  const data = stream.read();
5427
5427
  if (data !== null) ondata(data);
@@ -5451,11 +5451,11 @@ var require_streamx = __commonJS({
5451
5451
  }
5452
5452
  function destroy(err) {
5453
5453
  stream.destroy(err);
5454
- return new Promise((resolve20, reject) => {
5455
- if (stream._duplexState & DESTROYED) return resolve20({ value: void 0, done: true });
5454
+ return new Promise((resolve21, reject) => {
5455
+ if (stream._duplexState & DESTROYED) return resolve21({ value: void 0, done: true });
5456
5456
  stream.once("close", function() {
5457
5457
  if (err) reject(err);
5458
- else resolve20({ value: void 0, done: true });
5458
+ else resolve21({ value: void 0, done: true });
5459
5459
  });
5460
5460
  });
5461
5461
  }
@@ -5499,8 +5499,8 @@ var require_streamx = __commonJS({
5499
5499
  const writes = pending + (ws2._duplexState & WRITE_WRITING ? 1 : 0);
5500
5500
  if (writes === 0) return Promise.resolve(true);
5501
5501
  if (state.drains === null) state.drains = [];
5502
- return new Promise((resolve20) => {
5503
- state.drains.push({ writes, resolve: resolve20 });
5502
+ return new Promise((resolve21) => {
5503
+ state.drains.push({ writes, resolve: resolve21 });
5504
5504
  });
5505
5505
  }
5506
5506
  write(data) {
@@ -5605,10 +5605,10 @@ var require_streamx = __commonJS({
5605
5605
  cb2(null);
5606
5606
  }
5607
5607
  function pipelinePromise(...streams) {
5608
- return new Promise((resolve20, reject) => {
5608
+ return new Promise((resolve21, reject) => {
5609
5609
  return pipeline(...streams, (err) => {
5610
5610
  if (err) return reject(err);
5611
- resolve20();
5611
+ resolve21();
5612
5612
  });
5613
5613
  });
5614
5614
  }
@@ -6263,16 +6263,16 @@ var require_extract = __commonJS({
6263
6263
  entryCallback = null;
6264
6264
  cb2(err);
6265
6265
  }
6266
- function onnext(resolve20, reject) {
6266
+ function onnext(resolve21, reject) {
6267
6267
  if (error2) {
6268
6268
  return reject(error2);
6269
6269
  }
6270
6270
  if (entryStream) {
6271
- resolve20({ value: entryStream, done: false });
6271
+ resolve21({ value: entryStream, done: false });
6272
6272
  entryStream = null;
6273
6273
  return;
6274
6274
  }
6275
- promiseResolve = resolve20;
6275
+ promiseResolve = resolve21;
6276
6276
  promiseReject = reject;
6277
6277
  consumeCallback(null);
6278
6278
  if (extract3._finished && promiseResolve) {
@@ -6300,11 +6300,11 @@ var require_extract = __commonJS({
6300
6300
  function destroy(err) {
6301
6301
  extract3.destroy(err);
6302
6302
  consumeCallback(err);
6303
- return new Promise((resolve20, reject) => {
6304
- if (extract3.destroyed) return resolve20({ value: void 0, done: true });
6303
+ return new Promise((resolve21, reject) => {
6304
+ if (extract3.destroyed) return resolve21({ value: void 0, done: true });
6305
6305
  extract3.once("close", function() {
6306
6306
  if (err) reject(err);
6307
- else resolve20({ value: void 0, done: true });
6307
+ else resolve21({ value: void 0, done: true });
6308
6308
  });
6309
6309
  });
6310
6310
  }
@@ -6705,13 +6705,13 @@ function claudeAuthStatus() {
6705
6705
  }
6706
6706
  }
6707
6707
  function claudeAuthStatusAsync() {
6708
- return new Promise((resolve20) => {
6708
+ return new Promise((resolve21) => {
6709
6709
  let out = "";
6710
6710
  let settled = false;
6711
6711
  const done = (v7) => {
6712
6712
  if (!settled) {
6713
6713
  settled = true;
6714
- resolve20(v7);
6714
+ resolve21(v7);
6715
6715
  }
6716
6716
  };
6717
6717
  let child;
@@ -9232,7 +9232,7 @@ async function postForTarEntries(path5, body, retried = false) {
9232
9232
  }
9233
9233
  const extract3 = tar.extract();
9234
9234
  const entries = [];
9235
- const done = new Promise((resolve20, reject) => {
9235
+ const done = new Promise((resolve21, reject) => {
9236
9236
  extract3.on("entry", (header, stream, next) => {
9237
9237
  const chunks = [];
9238
9238
  stream.on("data", (c) => chunks.push(c));
@@ -9243,7 +9243,7 @@ async function postForTarEntries(path5, body, retried = false) {
9243
9243
  stream.on("error", reject);
9244
9244
  stream.resume();
9245
9245
  });
9246
- extract3.on("finish", () => resolve20());
9246
+ extract3.on("finish", () => resolve21());
9247
9247
  extract3.on("error", reject);
9248
9248
  });
9249
9249
  return read(async () => {
@@ -34369,8 +34369,8 @@ init_config();
34369
34369
  init_setup();
34370
34370
  init_utils();
34371
34371
  import { readFileSync as readFileSync32 } from "fs";
34372
- import { fileURLToPath as fileURLToPath4 } from "url";
34373
- import { dirname as dirname16, resolve as resolve19 } from "path";
34372
+ import { fileURLToPath as fileURLToPath5 } from "url";
34373
+ import { dirname as dirname17, resolve as resolve20 } from "path";
34374
34374
 
34375
34375
  // src/helpers/output.ts
34376
34376
  var frameOpen = false;
@@ -34798,25 +34798,25 @@ async function hashFile(path5) {
34798
34798
  const hash = createHash("sha256");
34799
34799
  let size = 0;
34800
34800
  const stream = createReadStream(path5);
34801
- await new Promise((resolve20, reject) => {
34801
+ await new Promise((resolve21, reject) => {
34802
34802
  stream.on("data", (chunk) => {
34803
34803
  const buf = chunk;
34804
34804
  hash.update(buf);
34805
34805
  size += buf.length;
34806
34806
  });
34807
- stream.on("end", () => resolve20());
34807
+ stream.on("end", () => resolve21());
34808
34808
  stream.on("error", reject);
34809
34809
  });
34810
34810
  return { sha256: hash.digest("hex"), size };
34811
34811
  }
34812
34812
  function readRange(path5, start, end) {
34813
- return new Promise((resolve20, reject) => {
34813
+ return new Promise((resolve21, reject) => {
34814
34814
  const chunks = [];
34815
34815
  const stream = createReadStream(path5, { start, end });
34816
34816
  stream.on("data", (c) => {
34817
34817
  chunks.push(c);
34818
34818
  });
34819
- stream.on("end", () => resolve20(Buffer.concat(chunks)));
34819
+ stream.on("end", () => resolve21(Buffer.concat(chunks)));
34820
34820
  stream.on("error", reject);
34821
34821
  });
34822
34822
  }
@@ -35207,7 +35207,7 @@ async function fetchRemote(projectGuid2) {
35207
35207
  function extractTarToMap(stream, idleMs, onBytes, keep) {
35208
35208
  const extract3 = tar2.extract();
35209
35209
  const files = /* @__PURE__ */ new Map();
35210
- return new Promise((resolve20, reject) => {
35210
+ return new Promise((resolve21, reject) => {
35211
35211
  let settled = false;
35212
35212
  let idle;
35213
35213
  const arm = () => {
@@ -35243,7 +35243,7 @@ function extractTarToMap(stream, idleMs, onBytes, keep) {
35243
35243
  });
35244
35244
  entryStream.resume();
35245
35245
  });
35246
- extract3.on("finish", () => done(resolve20, files));
35246
+ extract3.on("finish", () => done(resolve21, files));
35247
35247
  extract3.on("error", (e) => done(reject, e));
35248
35248
  stream.on("error", (e) => done(reject, e));
35249
35249
  arm();
@@ -40536,7 +40536,7 @@ function printStepRuns(steps, emptyNote) {
40536
40536
  }
40537
40537
  }
40538
40538
  var TERMINAL_RUN_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
40539
- var sleep2 = (ms2) => new Promise((resolve20) => setTimeout(resolve20, ms2));
40539
+ var sleep2 = (ms2) => new Promise((resolve21) => setTimeout(resolve21, ms2));
40540
40540
  async function waitForRun(wfGuid, prevGuid, timeoutSec) {
40541
40541
  const deadline = Date.now() + timeoutSec * 1e3;
40542
40542
  let runGuid;
@@ -44675,9 +44675,9 @@ jobCommand.command("cancel <runGuid>").description("Cancel a queued or running j
44675
44675
  }));
44676
44676
  jobCommand.command("run-local <name>").description("Run the job in a local Docker container against your local filesystem (no platform round-trip)").option("--image <image>", "Docker image to run inside", "easyclaw/sandbox:latest").option("--no-deps", "Skip pip/npm install even if a deps file is present").option("--json", "Capture the job's output and print one JSON result (exitCode, stdout, stderr) instead of streaming it").action(async (name, opts) => {
44677
44677
  const { existsSync: existsSync27, statSync: statSync12 } = await import("node:fs");
44678
- const { resolve: resolve20, join: join32 } = await import("node:path");
44678
+ const { resolve: resolve21, join: join32 } = await import("node:path");
44679
44679
  const { spawnCommand: spawnCommand2, spawnSyncCommand: spawnSyncCommand2 } = await Promise.resolve().then(() => (init_platform(), platform_exports));
44680
- const jobDir = resolve20(process.cwd(), "jobs", name);
44680
+ const jobDir = resolve21(process.cwd(), "jobs", name);
44681
44681
  if (!existsSync27(jobDir) || !statSync12(jobDir).isDirectory()) {
44682
44682
  console.error(error(`jobs/${name}/ not found in current directory`));
44683
44683
  process.exit(1);
@@ -45013,10 +45013,10 @@ async function waitForGenerations(projectGuid2, initial, opts = {}) {
45013
45013
  return gens;
45014
45014
  }
45015
45015
  function sleepUnlessInterrupted(ms2, stop) {
45016
- return new Promise((resolve20) => {
45016
+ return new Promise((resolve21) => {
45017
45017
  const started = Date.now();
45018
45018
  const tick = () => {
45019
- if (stop() || Date.now() - started >= ms2) return resolve20();
45019
+ if (stop() || Date.now() - started >= ms2) return resolve21();
45020
45020
  setTimeout(tick, Math.min(100, ms2));
45021
45021
  };
45022
45022
  tick();
@@ -46271,7 +46271,7 @@ async function pollTestStatus(projectGuid2, runGuid, opts) {
46271
46271
  }
46272
46272
  }
46273
46273
  }
46274
- await new Promise((resolve20) => setTimeout(resolve20, getPollInterval()));
46274
+ await new Promise((resolve21) => setTimeout(resolve21, getPollInterval()));
46275
46275
  }
46276
46276
  }
46277
46277
  var testCommand = new Command("test").description("Run tests").argument("[path]", 'Test path filter (e.g. "api", "e2e/portal")').option("--filter <path>", "Alias for the positional test path filter").option("--timeout <ms>", "Per-test timeout in ms", "30000").option("--retry <n>", "Retry failed tests N times", "0").option("--no-sync", "Skip sync-up before tests").option("--json", "Output as JSON").action((pathFilter, opts) => run("Test", async () => {
@@ -46500,13 +46500,14 @@ var locationCommand = new Command("location").description("Show location").argum
46500
46500
 
46501
46501
  // src/commands/doctor.ts
46502
46502
  import { existsSync as existsSync21, readFileSync as readFileSync26, statSync as statSync9 } from "fs";
46503
- import { join as join25, resolve as resolve16 } from "path";
46503
+ import { join as join25, resolve as resolve17 } from "path";
46504
46504
  import { homedir as homedir17 } from "os";
46505
46505
 
46506
46506
  // src/updater/state.ts
46507
46507
  import { readFileSync as readFileSync25, writeFileSync as writeFileSync17, mkdirSync as mkdirSync16, existsSync as existsSync20 } from "fs";
46508
- import { join as join24 } from "path";
46508
+ import { dirname as dirname15, join as join24, resolve as resolve16 } from "path";
46509
46509
  import { homedir as homedir16 } from "os";
46510
+ import { fileURLToPath as fileURLToPath4 } from "url";
46510
46511
  var GIPITY_DIR = join24(homedir16(), ".gipity");
46511
46512
  var LOCAL_DIR = join24(GIPITY_DIR, "local");
46512
46513
  var LOCAL_PKG_DIR = join24(LOCAL_DIR, "node_modules", "gipity");
@@ -46514,6 +46515,22 @@ var LOCAL_ENTRY = join24(LOCAL_PKG_DIR, "dist", "index.js");
46514
46515
  var STATE_FILE = join24(GIPITY_DIR, "update-state.json");
46515
46516
  var SETTINGS_FILE = join24(GIPITY_DIR, "settings.json");
46516
46517
  var UPDATE_LOG = join24(GIPITY_DIR, "update.log");
46518
+ function findPkgRoot() {
46519
+ let dir = dirname15(fileURLToPath4(import.meta.url));
46520
+ for (; ; ) {
46521
+ try {
46522
+ if (JSON.parse(readFileSync25(join24(dir, "package.json"), "utf-8")).name === "gipity") return dir;
46523
+ } catch {
46524
+ }
46525
+ const up2 = dirname15(dir);
46526
+ if (up2 === dir) return resolve16(dirname15(fileURLToPath4(import.meta.url)), "..", "..");
46527
+ dir = up2;
46528
+ }
46529
+ }
46530
+ var PKG_ROOT = findPkgRoot();
46531
+ function isDevLink() {
46532
+ return existsSync20(join24(PKG_ROOT, "src"));
46533
+ }
46517
46534
  var DEFAULT_STATE = {
46518
46535
  installedVersion: null,
46519
46536
  lastCheckAt: 0,
@@ -46676,7 +46693,7 @@ var doctorCommand = new Command("doctor").description("Check install + environme
46676
46693
  if (env.claude.installed && !env.claude.authenticated) {
46677
46694
  console.log(`${muted(" ")} ${warning("Claude Code is not logged in. Run `claude auth login` and sign in.")}`);
46678
46695
  }
46679
- if (existsSync21(resolve16(process.cwd(), ".codex", "hooks.json"))) {
46696
+ if (existsSync21(resolve17(process.cwd(), ".codex", "hooks.json"))) {
46680
46697
  console.log(`${muted("codex hooks ")} ${warning("written")} - session capture needs a one-time approval: run /hooks inside Codex in this project`);
46681
46698
  }
46682
46699
  const buildReady = env.node.ok && env.gipity.logged_in;
@@ -46707,11 +46724,12 @@ import { appendFileSync } from "fs";
46707
46724
 
46708
46725
  // src/updater/install.ts
46709
46726
  import { existsSync as existsSync22, mkdirSync as mkdirSync17, rmSync as rmSync2, statSync as statSync10, unlinkSync as unlinkSync6, writeFileSync as writeFileSync18 } from "fs";
46710
- import { dirname as dirname15, join as join26 } from "path";
46727
+ import { dirname as dirname16, join as join26 } from "path";
46711
46728
  init_platform();
46712
46729
  var UPDATE_LOCK = join26(GIPITY_DIR, "update.lock");
46713
46730
  var LOCK_STALE_MS2 = 10 * 60 * 1e3;
46714
46731
  function npmInstallGipity(version) {
46732
+ ensureLocalTree();
46715
46733
  const res = spawnSyncCommand(resolveCommand("npm"), ["install", "--no-audit", "--no-fund", "--ignore-scripts", `gipity@${version}`], {
46716
46734
  cwd: LOCAL_DIR,
46717
46735
  stdio: ["ignore", "ignore", "pipe"],
@@ -46728,6 +46746,13 @@ var WEDGE_CODES = /\b(ENOTEMPTY|EEXIST|ENOTDIR|EISDIR|EJSONPARSE)\b/;
46728
46746
  function isWedged(stderr) {
46729
46747
  return WEDGE_CODES.test(stderr);
46730
46748
  }
46749
+ function ensureLocalTree(dir = LOCAL_DIR) {
46750
+ mkdirSync17(dir, { recursive: true });
46751
+ const pkgJson = join26(dir, "package.json");
46752
+ if (!existsSync22(pkgJson)) {
46753
+ writeFileSync18(pkgJson, JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
46754
+ }
46755
+ }
46731
46756
  function resetLocalTree(dir = LOCAL_DIR) {
46732
46757
  mkdirSync17(dir, { recursive: true });
46733
46758
  rmSync2(join26(dir, "node_modules"), { recursive: true, force: true });
@@ -46735,7 +46760,7 @@ function resetLocalTree(dir = LOCAL_DIR) {
46735
46760
  writeFileSync18(join26(dir, "package.json"), JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
46736
46761
  }
46737
46762
  function acquireUpdateLock(lockPath2 = UPDATE_LOCK) {
46738
- mkdirSync17(dirname15(lockPath2), { recursive: true });
46763
+ mkdirSync17(dirname16(lockPath2), { recursive: true });
46739
46764
  try {
46740
46765
  writeFileSync18(lockPath2, String(process.pid), { flag: "wx" });
46741
46766
  return true;
@@ -46807,6 +46832,7 @@ ${res.stderr.trim().slice(-2e3)}`);
46807
46832
  return { ok: false, detail: firstLine.length > 160 ? firstLine.slice(0, 157) + "..." : firstLine };
46808
46833
  }
46809
46834
  async function runCheck(opts = {}) {
46835
+ if (isDevLink()) return { updated: false, reason: "dev-link" };
46810
46836
  const state = readState();
46811
46837
  if (!opts.force) {
46812
46838
  const dis = updatesDisabled();
@@ -46879,15 +46905,19 @@ var updateCommand = new Command("update").description("Update the CLI").option("
46879
46905
  upToDate: result.reason === "up-to-date",
46880
46906
  from: result.from ?? null,
46881
46907
  to: result.to ?? null,
46882
- reason: result.updated || result.reason === "up-to-date" ? null : result.reason ?? null
46908
+ devLink: result.reason === "dev-link",
46909
+ reason: result.updated || result.reason === "up-to-date" || result.reason === "dev-link" ? null : result.reason ?? null
46883
46910
  }));
46884
- if (!result.updated && result.reason !== "up-to-date") process.exitCode = 1;
46911
+ if (!result.updated && result.reason !== "up-to-date" && result.reason !== "dev-link") process.exitCode = 1;
46885
46912
  return;
46886
46913
  }
46887
46914
  console.log("");
46888
46915
  if (result.updated) {
46889
46916
  console.log(success(`Updated ${result.from} \u2192 ${result.to}`));
46890
46917
  console.log(dim(`Installed. This command ran on ${result.from}; everything from here on uses ${result.to}.`));
46918
+ } else if (result.reason === "dev-link") {
46919
+ console.log(info(`This gipity is linked to a source checkout (${PKG_ROOT}) and runs its build, so it never auto-updates.`));
46920
+ console.log(dim("To update it, pull that checkout and run `just cli-link` there."));
46891
46921
  } else if (result.reason === "up-to-date") {
46892
46922
  console.log(success("Already on the latest version."));
46893
46923
  } else {
@@ -47680,13 +47710,13 @@ function parseVersion(out) {
47680
47710
  return m ? m[0] : void 0;
47681
47711
  }
47682
47712
  function runProbe(cmd, args) {
47683
- return new Promise((resolve20) => {
47713
+ return new Promise((resolve21) => {
47684
47714
  let out = "";
47685
47715
  let settled = false;
47686
47716
  const done = (s) => {
47687
47717
  if (!settled) {
47688
47718
  settled = true;
47689
- resolve20(s);
47719
+ resolve21(s);
47690
47720
  }
47691
47721
  };
47692
47722
  let child;
@@ -47825,13 +47855,13 @@ function agentUpdateInProgress() {
47825
47855
  return inProgress;
47826
47856
  }
47827
47857
  function execCapture(argv2, timeoutMs, signal) {
47828
- return new Promise((resolve20) => {
47858
+ return new Promise((resolve21) => {
47829
47859
  let output = "";
47830
47860
  let settled = false;
47831
47861
  const done = (ok) => {
47832
47862
  if (!settled) {
47833
47863
  settled = true;
47834
- resolve20({ ok, output });
47864
+ resolve21({ ok, output });
47835
47865
  }
47836
47866
  };
47837
47867
  let child;
@@ -48032,8 +48062,8 @@ var SessionPool = class {
48032
48062
  const done = new Promise((r) => {
48033
48063
  markDone = r;
48034
48064
  });
48035
- return new Promise((resolve20, reject) => {
48036
- const turn = { onMessage: p.onMessage, resolve: resolve20, reject, interruptRequested: false, wasHot, done, markDone };
48065
+ return new Promise((resolve21, reject) => {
48066
+ const turn = { onMessage: p.onMessage, resolve: resolve21, reject, interruptRequested: false, wasHot, done, markDone };
48037
48067
  session.current = turn;
48038
48068
  session.state = "running";
48039
48069
  session.lastActivityAt = Date.now();
@@ -48488,10 +48518,10 @@ async function heartbeatLoop(ctx) {
48488
48518
  }
48489
48519
  await Promise.race([
48490
48520
  sleep4(HEARTBEAT_INTERVAL_MS, ctx.abort.signal),
48491
- new Promise((resolve20) => {
48521
+ new Promise((resolve21) => {
48492
48522
  heartbeatPoke = () => {
48493
48523
  heartbeatPoke = null;
48494
- resolve20();
48524
+ resolve21();
48495
48525
  };
48496
48526
  })
48497
48527
  ]);
@@ -48535,9 +48565,9 @@ async function dispatchLoop(ctx, opts) {
48535
48565
  while (inflight.size >= MAX_CONCURRENT_DISPATCHES && !ctx.abort.signal.aborted) {
48536
48566
  await Promise.race([
48537
48567
  ...inflight,
48538
- new Promise((resolve20) => {
48539
- if (ctx.abort.signal.aborted) return resolve20();
48540
- ctx.abort.signal.addEventListener("abort", () => resolve20(), { once: true });
48568
+ new Promise((resolve21) => {
48569
+ if (ctx.abort.signal.aborted) return resolve21();
48570
+ ctx.abort.signal.addEventListener("abort", () => resolve21(), { once: true });
48541
48571
  })
48542
48572
  ]);
48543
48573
  }
@@ -49326,7 +49356,7 @@ async function killRunningForConv(convGuid) {
49326
49356
  }
49327
49357
  }
49328
49358
  const graceTimers = [];
49329
- const escalate = new Promise((resolve20) => {
49359
+ const escalate = new Promise((resolve21) => {
49330
49360
  const t = setTimeout(() => {
49331
49361
  for (const e of matches) {
49332
49362
  log2("warn", "previous dispatch ignored SIGTERM - escalating to SIGKILL", { conv: convGuid });
@@ -49335,7 +49365,7 @@ async function killRunningForConv(convGuid) {
49335
49365
  } catch {
49336
49366
  }
49337
49367
  }
49338
- resolve20();
49368
+ resolve21();
49339
49369
  }, KILL_GRACE_MS);
49340
49370
  graceTimers.push(t);
49341
49371
  });
@@ -49346,7 +49376,7 @@ async function killRunningForConv(convGuid) {
49346
49376
  }
49347
49377
  async function spawnSync2(cwd, timeoutMs, onSpawn) {
49348
49378
  const cmd = process.env.GIPITY_RELAY_CLAUDE_CMD || resolveCommand("gipity");
49349
- return new Promise((resolve20, reject) => {
49379
+ return new Promise((resolve21, reject) => {
49350
49380
  const child = spawnCommand(cmd, ["sync", "--json"], {
49351
49381
  cwd,
49352
49382
  env: childEnv(),
@@ -49386,7 +49416,7 @@ async function spawnSync2(cwd, timeoutMs, onSpawn) {
49386
49416
  child.on("exit", (code) => finish(() => {
49387
49417
  if (code === 0) {
49388
49418
  log2("info", "sync done", { cwd, stdoutLen });
49389
- resolve20();
49419
+ resolve21();
49390
49420
  } else {
49391
49421
  reject(new Error(`gipity sync exited ${code}${stderrBuf ? `: ${stderrBuf.trim().slice(0, 300)}` : ""}`));
49392
49422
  }
@@ -49398,7 +49428,7 @@ async function spawnGipityClaude(args, cwd, d, queue, meta) {
49398
49428
  const cmd = process.env.GIPITY_RELAY_CLAUDE_CMD || resolveCommand("gipity");
49399
49429
  const fullArgs = streamJson ? [...args, "--output-format", "stream-json", "--verbose", "--include-partial-messages"] : [...args];
49400
49430
  const env = streamJson ? childEnv({ GIPITY_CONVERSATION_GUID: d.conversation_guid, GIPITY_CAPTURE: "off" }) : childEnv({ GIPITY_CONVERSATION_GUID: d.conversation_guid });
49401
- return new Promise((resolve20, reject) => {
49431
+ return new Promise((resolve21, reject) => {
49402
49432
  const child = spawnCommand(cmd, fullArgs, { cwd, env, stdio: ["ignore", "pipe", "pipe"] });
49403
49433
  let resolveExited = () => {
49404
49434
  };
@@ -49585,7 +49615,7 @@ async function spawnGipityClaude(args, cwd, d, queue, meta) {
49585
49615
  void postProgress(d.conversation_guid, buildProgressPayload(false));
49586
49616
  if (ownQueue) await q.close();
49587
49617
  cleanup();
49588
- resolve20({
49618
+ resolve21({
49589
49619
  exitCode: code ?? 1,
49590
49620
  killed,
49591
49621
  runtimeLimit,
@@ -49600,10 +49630,10 @@ async function runDispatchSync(d, cwd) {
49600
49630
  let killed = false;
49601
49631
  try {
49602
49632
  await spawnSync2(cwd, PROJECT_SYNC_TIMEOUT_MS, (child) => {
49603
- const exited = new Promise((resolve20) => {
49633
+ const exited = new Promise((resolve21) => {
49604
49634
  child.once("exit", (_code, signal) => {
49605
49635
  if (signal === "SIGTERM") killed = true;
49606
- resolve20();
49636
+ resolve21();
49607
49637
  });
49608
49638
  });
49609
49639
  running.set(d.short_guid, { child, convGuid: d.conversation_guid, exited });
@@ -49634,18 +49664,18 @@ function killDispatch(shortGuid) {
49634
49664
  return false;
49635
49665
  }
49636
49666
  function sleep4(ms2, signal) {
49637
- return new Promise((resolve20) => {
49638
- if (signal?.aborted) return resolve20();
49667
+ return new Promise((resolve21) => {
49668
+ if (signal?.aborted) return resolve21();
49639
49669
  let onAbort = null;
49640
49670
  const t = setTimeout(() => {
49641
49671
  if (onAbort && signal) signal.removeEventListener("abort", onAbort);
49642
- resolve20();
49672
+ resolve21();
49643
49673
  }, ms2);
49644
49674
  if (signal) {
49645
49675
  onAbort = () => {
49646
49676
  clearTimeout(t);
49647
49677
  signal.removeEventListener("abort", onAbort);
49648
- resolve20();
49678
+ resolve21();
49649
49679
  };
49650
49680
  signal.addEventListener("abort", onAbort, { once: true });
49651
49681
  }
@@ -50165,7 +50195,7 @@ init_utils();
50165
50195
  init_colors();
50166
50196
  import { existsSync as existsSync26, rmSync as rmSync4, unlinkSync as unlinkSync10, readFileSync as readFileSync30, writeFileSync as writeFileSync20 } from "fs";
50167
50197
  import { homedir as homedir20, platform as osPlatform4 } from "os";
50168
- import { join as join30, resolve as resolve18 } from "path";
50198
+ import { join as join30, resolve as resolve19 } from "path";
50169
50199
  init_agents();
50170
50200
  function removeInstallerPathLines() {
50171
50201
  if (osPlatform4() === "win32") return [];
@@ -50198,7 +50228,7 @@ function tildify2(p) {
50198
50228
  return p === home || p.startsWith(home + "/") ? "~" + p.slice(home.length) : p;
50199
50229
  }
50200
50230
  function resolveCliPath2() {
50201
- return resolve18(process.argv[1] ?? "gipity");
50231
+ return resolve19(process.argv[1] ?? "gipity");
50202
50232
  }
50203
50233
  async function stopDaemon() {
50204
50234
  if (!isDaemonRunning()) return;
@@ -50934,13 +50964,13 @@ function installOutputTrace(label2) {
50934
50964
 
50935
50965
  // src/index.ts
50936
50966
  installOutputTrace("index");
50937
- var __dirname = dirname16(fileURLToPath4(import.meta.url));
50967
+ var __dirname = dirname17(fileURLToPath5(import.meta.url));
50938
50968
  installNetworking();
50939
- var pkg = JSON.parse(readFileSync32(resolve19(__dirname, "../package.json"), "utf-8"));
50969
+ var pkg = JSON.parse(readFileSync32(resolve20(__dirname, "../package.json"), "utf-8"));
50940
50970
  function versionLabel() {
50941
50971
  const base = `v${pkg.version}`;
50942
50972
  try {
50943
- const info2 = JSON.parse(readFileSync32(resolve19(__dirname, "build-info.json"), "utf-8"));
50973
+ const info2 = JSON.parse(readFileSync32(resolve20(__dirname, "build-info.json"), "utf-8"));
50944
50974
  if (info2?.sha) return `${base} (dev ${info2.sha}${info2.dirty ? ", modified" : ""})`;
50945
50975
  } catch {
50946
50976
  }
@@ -1,7 +1,6 @@
1
- import { existsSync, mkdirSync, writeFileSync } from 'fs';
2
- import { join } from 'path';
3
- import { LOCAL_DIR, LOCAL_ENTRY, LOCAL_PKG_DIR, writeState, readState } from './state.js';
4
- import { npmInstallGipity, isWedged, resetLocalTree, acquireUpdateLock, releaseUpdateLock } from './install.js';
1
+ import { existsSync } from 'fs';
2
+ import { LOCAL_ENTRY, LOCAL_PKG_DIR, writeState, readState } from './state.js';
3
+ import { ensureLocalTree, npmInstallGipity, isWedged, resetLocalTree, acquireUpdateLock, releaseUpdateLock } from './install.js';
5
4
  export function isBootstrapped() {
6
5
  return existsSync(LOCAL_ENTRY);
7
6
  }
@@ -15,11 +14,7 @@ export function isBootstrapped() {
15
14
  * `gipity`, `gipity claude`, and `gipity --version`.
16
15
  */
17
16
  export function bootstrap(version, quiet = false) {
18
- mkdirSync(LOCAL_DIR, { recursive: true });
19
- const pkgJsonPath = join(LOCAL_DIR, 'package.json');
20
- if (!existsSync(pkgJsonPath)) {
21
- writeFileSync(pkgJsonPath, JSON.stringify({ name: 'gipity-local', private: true, version: '0.0.0' }, null, 2));
22
- }
17
+ ensureLocalTree();
23
18
  if (!acquireUpdateLock()) {
24
19
  // A background updater is mid-install; run from the current build now and
25
20
  // pick up the local install on a later invocation.
@@ -7,8 +7,9 @@ import { appendFileSync } from "fs";
7
7
 
8
8
  // src/updater/state.ts
9
9
  import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
10
- import { join } from "path";
10
+ import { dirname, join, resolve } from "path";
11
11
  import { homedir } from "os";
12
+ import { fileURLToPath } from "url";
12
13
  var GIPITY_DIR = join(homedir(), ".gipity");
13
14
  var LOCAL_DIR = join(GIPITY_DIR, "local");
14
15
  var LOCAL_PKG_DIR = join(LOCAL_DIR, "node_modules", "gipity");
@@ -16,6 +17,22 @@ var LOCAL_ENTRY = join(LOCAL_PKG_DIR, "dist", "index.js");
16
17
  var STATE_FILE = join(GIPITY_DIR, "update-state.json");
17
18
  var SETTINGS_FILE = join(GIPITY_DIR, "settings.json");
18
19
  var UPDATE_LOG = join(GIPITY_DIR, "update.log");
20
+ function findPkgRoot() {
21
+ let dir = dirname(fileURLToPath(import.meta.url));
22
+ for (; ; ) {
23
+ try {
24
+ if (JSON.parse(readFileSync(join(dir, "package.json"), "utf-8")).name === "gipity") return dir;
25
+ } catch {
26
+ }
27
+ const up = dirname(dir);
28
+ if (up === dir) return resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
29
+ dir = up;
30
+ }
31
+ }
32
+ var PKG_ROOT = findPkgRoot();
33
+ function isDevLink() {
34
+ return existsSync(join(PKG_ROOT, "src"));
35
+ }
19
36
  var DEFAULT_STATE = {
20
37
  installedVersion: null,
21
38
  lastCheckAt: 0,
@@ -57,7 +74,7 @@ function updatesDisabled() {
57
74
 
58
75
  // src/updater/install.ts
59
76
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, rmSync, statSync, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
60
- import { dirname, join as join2 } from "path";
77
+ import { dirname as dirname2, join as join2 } from "path";
61
78
 
62
79
  // src/platform.ts
63
80
  import { execSync, spawn, spawnSync } from "child_process";
@@ -91,6 +108,7 @@ function spawnSyncCommand(cmd, args = [], options = {}) {
91
108
  var UPDATE_LOCK = join2(GIPITY_DIR, "update.lock");
92
109
  var LOCK_STALE_MS = 10 * 60 * 1e3;
93
110
  function npmInstallGipity(version) {
111
+ ensureLocalTree();
94
112
  const res = spawnSyncCommand(resolveCommand("npm"), ["install", "--no-audit", "--no-fund", "--ignore-scripts", `gipity@${version}`], {
95
113
  cwd: LOCAL_DIR,
96
114
  stdio: ["ignore", "ignore", "pipe"],
@@ -107,6 +125,13 @@ var WEDGE_CODES = /\b(ENOTEMPTY|EEXIST|ENOTDIR|EISDIR|EJSONPARSE)\b/;
107
125
  function isWedged(stderr) {
108
126
  return WEDGE_CODES.test(stderr);
109
127
  }
128
+ function ensureLocalTree(dir = LOCAL_DIR) {
129
+ mkdirSync2(dir, { recursive: true });
130
+ const pkgJson = join2(dir, "package.json");
131
+ if (!existsSync2(pkgJson)) {
132
+ writeFileSync2(pkgJson, JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
133
+ }
134
+ }
110
135
  function resetLocalTree(dir = LOCAL_DIR) {
111
136
  mkdirSync2(dir, { recursive: true });
112
137
  rmSync(join2(dir, "node_modules"), { recursive: true, force: true });
@@ -114,7 +139,7 @@ function resetLocalTree(dir = LOCAL_DIR) {
114
139
  writeFileSync2(join2(dir, "package.json"), JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
115
140
  }
116
141
  function acquireUpdateLock(lockPath = UPDATE_LOCK) {
117
- mkdirSync2(dirname(lockPath), { recursive: true });
142
+ mkdirSync2(dirname2(lockPath), { recursive: true });
118
143
  try {
119
144
  writeFileSync2(lockPath, String(process.pid), { flag: "wx" });
120
145
  return true;
@@ -186,6 +211,7 @@ ${res.stderr.trim().slice(-2e3)}`);
186
211
  return { ok: false, detail: firstLine.length > 160 ? firstLine.slice(0, 157) + "..." : firstLine };
187
212
  }
188
213
  async function runCheck(opts = {}) {
214
+ if (isDevLink()) return { updated: false, reason: "dev-link" };
189
215
  const state = readState();
190
216
  if (!opts.force) {
191
217
  const dis = updatesDisabled();
@@ -17,6 +17,10 @@ const LOCK_STALE_MS = 10 * 60 * 1000;
17
17
  * precompiled (dist/) and its deps need no build step, so nothing is lost.
18
18
  */
19
19
  export function npmInstallGipity(version) {
20
+ // A missing cwd makes spawnSync fail with "spawnSync npm ENOENT", which reads
21
+ // as "npm is not installed". The tree can be gone because the user deleted it
22
+ // (our own recovery hint says to), so create it rather than mislead.
23
+ ensureLocalTree();
20
24
  const res = spawnSyncCommand(resolveCommand('npm'), ['install', '--no-audit', '--no-fund', '--ignore-scripts', `gipity@${version}`], {
21
25
  cwd: LOCAL_DIR,
22
26
  stdio: ['ignore', 'ignore', 'pipe'],
@@ -39,6 +43,15 @@ const WEDGE_CODES = /\b(ENOTEMPTY|EEXIST|ENOTDIR|EISDIR|EJSONPARSE)\b/;
39
43
  export function isWedged(stderr) {
40
44
  return WEDGE_CODES.test(stderr);
41
45
  }
46
+ /** Make sure the local install dir and its package.json exist.
47
+ * `dir` is overridable for tests only. */
48
+ export function ensureLocalTree(dir = LOCAL_DIR) {
49
+ mkdirSync(dir, { recursive: true });
50
+ const pkgJson = join(dir, 'package.json');
51
+ if (!existsSync(pkgJson)) {
52
+ writeFileSync(pkgJson, JSON.stringify({ name: 'gipity-local', private: true, version: '0.0.0' }, null, 2));
53
+ }
54
+ }
42
55
  /** Wipe the local install tree back to a pristine, installable state.
43
56
  * `dir` is overridable for tests only. */
44
57
  export function resetLocalTree(dir = LOCAL_DIR) {
@@ -38,14 +38,15 @@ function spawnSyncCommand(cmd, args = [], options = {}) {
38
38
  }
39
39
 
40
40
  // src/updater/shim.ts
41
- import { existsSync as existsSync4, readFileSync as readFileSync2 } from "fs";
42
- import { fileURLToPath, pathToFileURL } from "url";
43
- import { dirname as dirname2, resolve, join as join5 } from "path";
41
+ import { readFileSync as readFileSync2 } from "fs";
42
+ import { fileURLToPath as fileURLToPath2, pathToFileURL } from "url";
43
+ import { dirname as dirname3, resolve as resolve2, join as join4 } from "path";
44
44
 
45
45
  // src/updater/state.ts
46
46
  import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
47
- import { join } from "path";
47
+ import { dirname, join, resolve } from "path";
48
48
  import { homedir } from "os";
49
+ import { fileURLToPath } from "url";
49
50
  var GIPITY_DIR = join(homedir(), ".gipity");
50
51
  var LOCAL_DIR = join(GIPITY_DIR, "local");
51
52
  var LOCAL_PKG_DIR = join(LOCAL_DIR, "node_modules", "gipity");
@@ -53,6 +54,22 @@ var LOCAL_ENTRY = join(LOCAL_PKG_DIR, "dist", "index.js");
53
54
  var STATE_FILE = join(GIPITY_DIR, "update-state.json");
54
55
  var SETTINGS_FILE = join(GIPITY_DIR, "settings.json");
55
56
  var UPDATE_LOG = join(GIPITY_DIR, "update.log");
57
+ function findPkgRoot() {
58
+ let dir = dirname(fileURLToPath(import.meta.url));
59
+ for (; ; ) {
60
+ try {
61
+ if (JSON.parse(readFileSync(join(dir, "package.json"), "utf-8")).name === "gipity") return dir;
62
+ } catch {
63
+ }
64
+ const up = dirname(dir);
65
+ if (up === dir) return resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
66
+ dir = up;
67
+ }
68
+ }
69
+ var PKG_ROOT = findPkgRoot();
70
+ function isDevLink() {
71
+ return existsSync(join(PKG_ROOT, "src"));
72
+ }
56
73
  var DEFAULT_STATE = {
57
74
  installedVersion: null,
58
75
  lastCheckAt: 0,
@@ -76,15 +93,15 @@ function writeState(state) {
76
93
  }
77
94
 
78
95
  // src/updater/bootstrap.ts
79
- import { existsSync as existsSync3, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
80
- import { join as join3 } from "path";
96
+ import { existsSync as existsSync3 } from "fs";
81
97
 
82
98
  // src/updater/install.ts
83
99
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, rmSync, statSync, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
84
- import { dirname, join as join2 } from "path";
100
+ import { dirname as dirname2, join as join2 } from "path";
85
101
  var UPDATE_LOCK = join2(GIPITY_DIR, "update.lock");
86
102
  var LOCK_STALE_MS = 10 * 60 * 1e3;
87
103
  function npmInstallGipity(version) {
104
+ ensureLocalTree();
88
105
  const res = spawnSyncCommand(resolveCommand("npm"), ["install", "--no-audit", "--no-fund", "--ignore-scripts", `gipity@${version}`], {
89
106
  cwd: LOCAL_DIR,
90
107
  stdio: ["ignore", "ignore", "pipe"],
@@ -101,6 +118,13 @@ var WEDGE_CODES = /\b(ENOTEMPTY|EEXIST|ENOTDIR|EISDIR|EJSONPARSE)\b/;
101
118
  function isWedged(stderr) {
102
119
  return WEDGE_CODES.test(stderr);
103
120
  }
121
+ function ensureLocalTree(dir = LOCAL_DIR) {
122
+ mkdirSync2(dir, { recursive: true });
123
+ const pkgJson = join2(dir, "package.json");
124
+ if (!existsSync2(pkgJson)) {
125
+ writeFileSync2(pkgJson, JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
126
+ }
127
+ }
104
128
  function resetLocalTree(dir = LOCAL_DIR) {
105
129
  mkdirSync2(dir, { recursive: true });
106
130
  rmSync(join2(dir, "node_modules"), { recursive: true, force: true });
@@ -108,7 +132,7 @@ function resetLocalTree(dir = LOCAL_DIR) {
108
132
  writeFileSync2(join2(dir, "package.json"), JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
109
133
  }
110
134
  function acquireUpdateLock(lockPath = UPDATE_LOCK) {
111
- mkdirSync2(dirname(lockPath), { recursive: true });
135
+ mkdirSync2(dirname2(lockPath), { recursive: true });
112
136
  try {
113
137
  writeFileSync2(lockPath, String(process.pid), { flag: "wx" });
114
138
  return true;
@@ -136,11 +160,7 @@ function isBootstrapped() {
136
160
  return existsSync3(LOCAL_ENTRY);
137
161
  }
138
162
  function bootstrap(version, quiet = false) {
139
- mkdirSync3(LOCAL_DIR, { recursive: true });
140
- const pkgJsonPath = join3(LOCAL_DIR, "package.json");
141
- if (!existsSync3(pkgJsonPath)) {
142
- writeFileSync3(pkgJsonPath, JSON.stringify({ name: "gipity-local", private: true, version: "0.0.0" }, null, 2));
143
- }
163
+ ensureLocalTree();
144
164
  if (!acquireUpdateLock()) {
145
165
  if (!quiet) process.stderr.write(`gipity: another update is in progress - using the currently installed build.
146
166
  `);
@@ -182,8 +202,8 @@ function bootstrap(version, quiet = false) {
182
202
  }
183
203
 
184
204
  // src/trace.ts
185
- import { openSync, writeSync, mkdirSync as mkdirSync4 } from "fs";
186
- import { join as join4 } from "path";
205
+ import { openSync, writeSync, mkdirSync as mkdirSync3 } from "fs";
206
+ import { join as join3 } from "path";
187
207
  import { homedir as homedir2 } from "os";
188
208
  var TRACE_KEY = /* @__PURE__ */ Symbol.for("gipity.traceOutput");
189
209
  function installOutputTrace(label) {
@@ -195,10 +215,10 @@ function installOutputTrace(label) {
195
215
  existing.emit({ event: "reenter", label });
196
216
  return;
197
217
  }
198
- const dir = join4(process.env.GIPITY_DIR || join4(homedir2(), ".gipity"), "trace");
199
- mkdirSync4(dir, { recursive: true });
218
+ const dir = join3(process.env.GIPITY_DIR || join3(homedir2(), ".gipity"), "trace");
219
+ mkdirSync3(dir, { recursive: true });
200
220
  const stamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", "_").replace(/:/g, "-");
201
- const fd = openSync(join4(dir, `${stamp}-pid${process.pid}.jsonl`), "a");
221
+ const fd = openSync(join3(dir, `${stamp}-pid${process.pid}.jsonl`), "a");
202
222
  const emit = (rec) => {
203
223
  try {
204
224
  writeSync(fd, JSON.stringify({ t: (/* @__PURE__ */ new Date()).toISOString(), ...rec }) + "\n");
@@ -233,12 +253,12 @@ function installOutputTrace(label) {
233
253
 
234
254
  // src/updater/shim.ts
235
255
  installOutputTrace("shim");
236
- var __dirname = dirname2(fileURLToPath(import.meta.url));
237
- var pkgRoot = resolve(__dirname, "..", "..");
238
- var shimPkg = JSON.parse(readFileSync2(join5(pkgRoot, "package.json"), "utf-8"));
239
- var isDevLink = existsSync4(join5(pkgRoot, "src"));
256
+ var __dirname = dirname3(fileURLToPath2(import.meta.url));
257
+ var pkgRoot = resolve2(__dirname, "..", "..");
258
+ var shimPkg = JSON.parse(readFileSync2(join4(pkgRoot, "package.json"), "utf-8"));
259
+ var devLink = isDevLink();
240
260
  function startBackgroundUpdater() {
241
- const checkScript = join5(__dirname, "check.js");
261
+ const checkScript = join4(__dirname, "check.js");
242
262
  try {
243
263
  const child = spawnCommand(process.execPath, [checkScript], {
244
264
  detached: true,
@@ -260,11 +280,11 @@ async function runEntry(entry) {
260
280
  }
261
281
  }
262
282
  var execLocal = () => runEntry(LOCAL_ENTRY);
263
- var execSelf = () => runEntry(resolve(__dirname, "..", "index.js"));
283
+ var execSelf = () => runEntry(resolve2(__dirname, "..", "index.js"));
264
284
  var rawArgs = process.argv.slice(2);
265
285
  var firstArg = rawArgs[0];
266
286
  var isLoud = rawArgs.length === 0 || firstArg === "claude" || firstArg === "--version" || firstArg === "-v" || firstArg === "version";
267
- if (isDevLink) {
287
+ if (devLink) {
268
288
  await execSelf();
269
289
  } else if (!isBootstrapped() && !bootstrap(shimPkg.version, !isLoud)) {
270
290
  await execSelf();
@@ -1,6 +1,7 @@
1
1
  import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';
2
- import { join } from 'path';
2
+ import { dirname, join, resolve } from 'path';
3
3
  import { homedir } from 'os';
4
+ import { fileURLToPath } from 'url';
4
5
  export const GIPITY_DIR = join(homedir(), '.gipity');
5
6
  export const LOCAL_DIR = join(GIPITY_DIR, 'local');
6
7
  export const LOCAL_PKG_DIR = join(LOCAL_DIR, 'node_modules', 'gipity');
@@ -8,6 +9,31 @@ export const LOCAL_ENTRY = join(LOCAL_PKG_DIR, 'dist', 'index.js');
8
9
  export const STATE_FILE = join(GIPITY_DIR, 'update-state.json');
9
10
  export const SETTINGS_FILE = join(GIPITY_DIR, 'settings.json');
10
11
  export const UPDATE_LOG = join(GIPITY_DIR, 'update.log');
12
+ /** Root of the gipity package this code runs from. Walks up to its
13
+ * package.json because the depth differs: dist/updater/*.js are separate
14
+ * files, while dist/index.js is a bundle that inlines this module. */
15
+ function findPkgRoot() {
16
+ let dir = dirname(fileURLToPath(import.meta.url));
17
+ for (;;) {
18
+ try {
19
+ if (JSON.parse(readFileSync(join(dir, 'package.json'), 'utf-8')).name === 'gipity')
20
+ return dir;
21
+ }
22
+ catch { /* no package.json here */ }
23
+ const up = dirname(dir);
24
+ if (up === dir)
25
+ return resolve(dirname(fileURLToPath(import.meta.url)), '..', '..');
26
+ dir = up;
27
+ }
28
+ }
29
+ export const PKG_ROOT = findPkgRoot();
30
+ /** Published tarballs ship `dist/**` only (package.json `files`), so a sibling
31
+ * `src/` means `gipity` was `npm link`ed from a source checkout. A dev link
32
+ * runs that checkout's own build and never auto-updates: installing a
33
+ * published copy into ~/.gipity/local would be pointless (nothing runs it). */
34
+ export function isDevLink() {
35
+ return existsSync(join(PKG_ROOT, 'src'));
36
+ }
11
37
  const DEFAULT_STATE = {
12
38
  installedVersion: null,
13
39
  lastCheckAt: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gipity",
3
- "version": "1.1.29",
3
+ "version": "1.1.30",
4
4
  "description": "The full-stack platform tuned for AI agents. Database, storage, auth, functions, deploy, and drop-in kits - all agent-tuned. Pair with Claude Code or use standalone.",
5
5
  "bin": {
6
6
  "gipity": "dist/updater/shim.js",