supbuddy 3.0.1 → 3.0.2

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
@@ -9251,11 +9251,11 @@ var require_mime_types = __commonJS({
9251
9251
  }
9252
9252
  return exts[0];
9253
9253
  }
9254
- function lookup(path11) {
9255
- if (!path11 || typeof path11 !== "string") {
9254
+ function lookup(path12) {
9255
+ if (!path12 || typeof path12 !== "string") {
9256
9256
  return false;
9257
9257
  }
9258
- var extension2 = extname("x." + path11).toLowerCase().substr(1);
9258
+ var extension2 = extname("x." + path12).toLowerCase().substr(1);
9259
9259
  if (!extension2) {
9260
9260
  return false;
9261
9261
  }
@@ -12630,11 +12630,11 @@ var require_server = __commonJS({
12630
12630
  * @protected
12631
12631
  */
12632
12632
  _computePath(options) {
12633
- let path11 = (options.path || "/engine.io").replace(/\/$/, "");
12633
+ let path12 = (options.path || "/engine.io").replace(/\/$/, "");
12634
12634
  if (options.addTrailingSlash !== false) {
12635
- path11 += "/";
12635
+ path12 += "/";
12636
12636
  }
12637
- return path11;
12637
+ return path12;
12638
12638
  }
12639
12639
  /**
12640
12640
  * Returns a list of available transports for upgrade given a certain transport.
@@ -13133,10 +13133,10 @@ var require_server = __commonJS({
13133
13133
  * @param {Object} options
13134
13134
  */
13135
13135
  attach(server, options = {}) {
13136
- const path11 = this._computePath(options);
13136
+ const path12 = this._computePath(options);
13137
13137
  const destroyUpgradeTimeout = options.destroyUpgradeTimeout || 1e3;
13138
13138
  function check(req) {
13139
- return path11 === req.url.slice(0, path11.length);
13139
+ return path12 === req.url.slice(0, path12.length);
13140
13140
  }
13141
13141
  const listeners = server.listeners("request").slice(0);
13142
13142
  server.removeAllListeners("request");
@@ -13144,7 +13144,7 @@ var require_server = __commonJS({
13144
13144
  server.on("listening", this.init.bind(this));
13145
13145
  server.on("request", (req, res) => {
13146
13146
  if (check(req)) {
13147
- debug('intercepting request for path "%s"', path11);
13147
+ debug('intercepting request for path "%s"', path12);
13148
13148
  this.handleRequest(req, res);
13149
13149
  } else {
13150
13150
  let i = 0;
@@ -13983,8 +13983,8 @@ var require_userver = __commonJS({
13983
13983
  * @param options
13984
13984
  */
13985
13985
  attach(app, options = {}) {
13986
- const path11 = this._computePath(options);
13987
- app.any(path11, this.handleRequest.bind(this)).ws(path11, {
13986
+ const path12 = this._computePath(options);
13987
+ app.any(path12, this.handleRequest.bind(this)).ws(path12, {
13988
13988
  compression: options.compression,
13989
13989
  idleTimeout: options.idleTimeout,
13990
13990
  maxBackpressure: options.maxBackpressure,
@@ -18397,7 +18397,7 @@ var require_dist2 = __commonJS({
18397
18397
  var zlib_1 = __require("zlib");
18398
18398
  var accepts = require_accepts();
18399
18399
  var stream_1 = __require("stream");
18400
- var path11 = __require("path");
18400
+ var path12 = __require("path");
18401
18401
  var engine_io_1 = require_engine_io();
18402
18402
  var client_1 = require_client();
18403
18403
  var events_1 = __require("events");
@@ -18592,7 +18592,7 @@ var require_dist2 = __commonJS({
18592
18592
  res.writeHeader("cache-control", "public, max-age=0");
18593
18593
  res.writeHeader("content-type", "application/" + (isMap ? "json" : "javascript") + "; charset=utf-8");
18594
18594
  res.writeHeader("etag", expectedEtag);
18595
- const filepath = path11.join(__dirname, "../client-dist/", filename);
18595
+ const filepath = path12.join(__dirname, "../client-dist/", filename);
18596
18596
  (0, uws_1.serveFile)(res, filepath);
18597
18597
  });
18598
18598
  }
@@ -18674,7 +18674,7 @@ var require_dist2 = __commonJS({
18674
18674
  * @private
18675
18675
  */
18676
18676
  static sendFile(filename, req, res) {
18677
- const readStream = (0, fs_1.createReadStream)(path11.join(__dirname, "../client-dist/", filename));
18677
+ const readStream = (0, fs_1.createReadStream)(path12.join(__dirname, "../client-dist/", filename));
18678
18678
  const encoding = accepts(req).encodings(["br", "gzip", "deflate"]);
18679
18679
  const onError = (err) => {
18680
18680
  if (err) {
@@ -19599,6 +19599,33 @@ var init_state_dir = __esm({
19599
19599
  }
19600
19600
  });
19601
19601
 
19602
+ // src/caddy-resolve.ts
19603
+ import { createRequire } from "module";
19604
+ import path4 from "path";
19605
+ function caddyPackageName(platform = process.platform, arch = process.arch) {
19606
+ if (platform === "darwin") {
19607
+ return arch === "arm64" ? "@supbuddy/caddy-darwin-arm64" : "@supbuddy/caddy-darwin-amd64";
19608
+ }
19609
+ return null;
19610
+ }
19611
+ function resolvePackagedCaddyDir(deps = {}) {
19612
+ const pkgName = deps.pkgName !== void 0 ? deps.pkgName : caddyPackageName();
19613
+ if (!pkgName) return null;
19614
+ const resolve = deps.resolve ?? ((id) => requireFromHere.resolve(id));
19615
+ try {
19616
+ return path4.dirname(resolve(`${pkgName}/package.json`));
19617
+ } catch {
19618
+ return null;
19619
+ }
19620
+ }
19621
+ var requireFromHere;
19622
+ var init_caddy_resolve = __esm({
19623
+ "src/caddy-resolve.ts"() {
19624
+ "use strict";
19625
+ requireFromHere = createRequire(import.meta.url);
19626
+ }
19627
+ });
19628
+
19602
19629
  // ../../packages/shared/types/isolation.ts
19603
19630
  var init_isolation = __esm({
19604
19631
  "../../packages/shared/types/isolation.ts"() {
@@ -20281,8 +20308,8 @@ var init_parseUtil = __esm({
20281
20308
  init_errors();
20282
20309
  init_en();
20283
20310
  makeIssue = (params) => {
20284
- const { data, path: path11, errorMaps, issueData } = params;
20285
- const fullPath = [...path11, ...issueData.path || []];
20311
+ const { data, path: path12, errorMaps, issueData } = params;
20312
+ const fullPath = [...path12, ...issueData.path || []];
20286
20313
  const fullIssue = {
20287
20314
  ...issueData,
20288
20315
  path: fullPath
@@ -20593,11 +20620,11 @@ var init_types2 = __esm({
20593
20620
  init_parseUtil();
20594
20621
  init_util();
20595
20622
  ParseInputLazyPath = class {
20596
- constructor(parent, value, path11, key) {
20623
+ constructor(parent, value, path12, key) {
20597
20624
  this._cachedPath = [];
20598
20625
  this.parent = parent;
20599
20626
  this.data = value;
20600
- this._path = path11;
20627
+ this._path = path12;
20601
20628
  this._key = key;
20602
20629
  }
20603
20630
  get path() {
@@ -24770,7 +24797,7 @@ var init_shared = __esm({
24770
24797
  import { spawn as spawn2 } from "child_process";
24771
24798
  import { fileURLToPath } from "url";
24772
24799
  import fs4 from "fs";
24773
- import path4 from "path";
24800
+ import path5 from "path";
24774
24801
  function resolveWorkerEntry(deps = {}) {
24775
24802
  const binDir = deps.binDir ?? __dirname2;
24776
24803
  const repoRoot = deps.repoRoot ?? REPO_ROOT;
@@ -24778,27 +24805,32 @@ function resolveWorkerEntry(deps = {}) {
24778
24805
  const exists = deps.exists ?? fs4.existsSync;
24779
24806
  const bundle = env2.SUPBUDDY_WORKER_BUNDLE;
24780
24807
  if (bundle) {
24781
- return { cmd: process.execPath, args: [bundle], workerEntry: bundle, cwd: path4.dirname(bundle) };
24808
+ return { cmd: process.execPath, args: [bundle], workerEntry: bundle, cwd: path5.dirname(bundle), mode: "host" };
24782
24809
  }
24783
- const pkgWorker = path4.join(binDir, "daemon", "worker.cjs");
24810
+ const pkgWorker = path5.join(binDir, "daemon", "worker.cjs");
24784
24811
  if (exists(pkgWorker)) {
24785
- return { cmd: process.execPath, args: [pkgWorker], workerEntry: pkgWorker, cwd: path4.dirname(pkgWorker) };
24812
+ return { cmd: process.execPath, args: [pkgWorker], workerEntry: pkgWorker, cwd: path5.dirname(pkgWorker), mode: "npm" };
24786
24813
  }
24787
- const bootstrap = path4.join(repoRoot, "apps", "cli", "src", "worker-bootstrap.ts");
24814
+ const bootstrap = path5.join(repoRoot, "apps", "cli", "src", "worker-bootstrap.ts");
24788
24815
  if (exists(bootstrap)) {
24789
- const workerEntry = path4.join(repoRoot, "packages", "core", "index.ts");
24790
- return { cmd: process.execPath, args: ["--import", "tsx", bootstrap], workerEntry, cwd: repoRoot };
24816
+ const workerEntry = path5.join(repoRoot, "packages", "core", "index.ts");
24817
+ return { cmd: process.execPath, args: ["--import", "tsx", bootstrap], workerEntry, cwd: repoRoot, mode: "dev" };
24791
24818
  }
24792
24819
  throw new WorkerUnavailableError();
24793
24820
  }
24794
24821
  async function startDaemon(opts = {}) {
24795
24822
  const { stateDir, workerPort, assumeYes, quiet } = opts;
24796
24823
  const effectiveStateDir = stateDir ?? defaultStateDir();
24797
- const { cmd, args, workerEntry, cwd } = resolveWorkerEntry();
24824
+ const { cmd, args, workerEntry, cwd, mode } = resolveWorkerEntry();
24798
24825
  const env2 = { ...process.env, NODE_ENV: process.env.NODE_ENV ?? "development" };
24799
24826
  env2.SUPBUDDY_WORKER_ENTRY = workerEntry;
24800
24827
  env2.SUPBUDDY_STATE_DIR = effectiveStateDir;
24801
24828
  if (workerPort) env2.WORKER_PORT = String(workerPort);
24829
+ if (mode === "npm" && !env2.SUPBUDDY_BIN_DIR) {
24830
+ const caddyDir = resolvePackagedCaddyDir();
24831
+ if (!caddyDir) throw new CaddyUnavailableError();
24832
+ env2.SUPBUDDY_BIN_DIR = caddyDir;
24833
+ }
24802
24834
  const child = spawn2(cmd, args, { stdio: ["ignore", "pipe", "pipe", "ipc"], env: env2, cwd });
24803
24835
  const startedAt = (/* @__PURE__ */ new Date()).toISOString();
24804
24836
  const baseSocketPort = workerPort ?? DEFAULT_WORKER_PORT;
@@ -24950,7 +24982,7 @@ async function runDaemonDetached(opts = {}) {
24950
24982
  }
24951
24983
  const entry = process.argv[1];
24952
24984
  const isTsEntry = entry.endsWith(".ts");
24953
- const execPath = isTsEntry ? path4.join(REPO_ROOT, "node_modules", ".bin", "tsx") : process.execPath;
24985
+ const execPath = isTsEntry ? path5.join(REPO_ROOT, "node_modules", ".bin", "tsx") : process.execPath;
24954
24986
  const args = [entry, "daemon"];
24955
24987
  if (opts.stateDir) args.push(`--state-dir=${opts.stateDir}`);
24956
24988
  if (opts.workerPort) args.push(`--worker-port=${opts.workerPort}`);
@@ -24967,7 +24999,7 @@ async function runDaemonDetached(opts = {}) {
24967
24999
  console.error("[daemon] detached start did not produce daemon.json in time");
24968
25000
  return 1;
24969
25001
  }
24970
- var __dirname2, REPO_ROOT, WorkerUnavailableError;
25002
+ var __dirname2, REPO_ROOT, WorkerUnavailableError, CaddyUnavailableError;
24971
25003
  var init_daemon = __esm({
24972
25004
  "src/daemon.ts"() {
24973
25005
  "use strict";
@@ -24977,9 +25009,10 @@ var init_daemon = __esm({
24977
25009
  init_relay_server();
24978
25010
  init_network_monitor();
24979
25011
  init_state_dir();
25012
+ init_caddy_resolve();
24980
25013
  init_shared();
24981
- __dirname2 = path4.dirname(fileURLToPath(import.meta.url));
24982
- REPO_ROOT = path4.resolve(__dirname2, "..", "..", "..");
25014
+ __dirname2 = path5.dirname(fileURLToPath(import.meta.url));
25015
+ REPO_ROOT = path5.resolve(__dirname2, "..", "..", "..");
24983
25016
  WorkerUnavailableError = class extends Error {
24984
25017
  constructor() {
24985
25018
  super(
@@ -24988,6 +25021,17 @@ var init_daemon = __esm({
24988
25021
  this.name = "WorkerUnavailableError";
24989
25022
  }
24990
25023
  };
25024
+ CaddyUnavailableError = class extends Error {
25025
+ constructor() {
25026
+ const pkg = caddyPackageName();
25027
+ super(
25028
+ pkg ? `The standalone daemon needs its bundled Caddy (${pkg}), which is not installed.
25029
+ Reinstall the CLI so npm can fetch it: npm install -g supbuddy
25030
+ (if your npm skipped optional dependencies, run it without --no-optional).` : `The standalone daemon has no bundled Caddy for your platform yet (${process.platform}/${process.arch}). Install the Supbuddy desktop app, or run from a source checkout.`
25031
+ );
25032
+ this.name = "CaddyUnavailableError";
25033
+ }
25034
+ };
24991
25035
  }
24992
25036
  });
24993
25037
 
@@ -25756,10 +25800,10 @@ __export(install_exports, {
25756
25800
  });
25757
25801
  import { spawnSync } from "child_process";
25758
25802
  import readline2 from "readline";
25759
- import path5 from "path";
25803
+ import path6 from "path";
25760
25804
  function isEphemeralNpx() {
25761
25805
  const argv1 = process.argv[1] || "";
25762
- if (argv1.includes(`${path5.sep}_npx${path5.sep}`) || argv1.includes("/_npx/")) return true;
25806
+ if (argv1.includes(`${path6.sep}_npx${path6.sep}`) || argv1.includes("/_npx/")) return true;
25763
25807
  if (process.env.npm_command === "exec") return true;
25764
25808
  return false;
25765
25809
  }
@@ -25834,7 +25878,7 @@ import net from "net";
25834
25878
  import http from "http";
25835
25879
  import fs5 from "fs/promises";
25836
25880
  import os4 from "os";
25837
- import path6 from "path";
25881
+ import path7 from "path";
25838
25882
  function getFreePort() {
25839
25883
  return new Promise((resolve, reject) => {
25840
25884
  const srv = net.createServer();
@@ -25918,7 +25962,7 @@ async function main() {
25918
25962
  const workerPort = await getFreePort();
25919
25963
  let mcpPort = await getFreePort();
25920
25964
  if (mcpPort === workerPort) mcpPort = await getFreePort();
25921
- const stateDir = await fs5.mkdtemp(path6.join(os4.tmpdir(), "supbuddy-selftest-"));
25965
+ const stateDir = await fs5.mkdtemp(path7.join(os4.tmpdir(), "supbuddy-selftest-"));
25922
25966
  const seed = {
25923
25967
  projects: [],
25924
25968
  mappings: [],
@@ -25928,7 +25972,7 @@ async function main() {
25928
25972
  mcp: { enabled: true, port: mcpPort, audit_cap: 5e3, trash_ttl_days: 7 }
25929
25973
  }
25930
25974
  };
25931
- await fs5.writeFile(path6.join(stateDir, "state.json"), JSON.stringify(seed, null, 2));
25975
+ await fs5.writeFile(path7.join(stateDir, "state.json"), JSON.stringify(seed, null, 2));
25932
25976
  console.log(`isolated state dir: ${stateDir}`);
25933
25977
  console.log(`worker (Socket.IO) port: ${workerPort} MCP port: ${mcpPort}
25934
25978
  `);
@@ -25980,7 +26024,7 @@ import https from "https";
25980
26024
  import fs6 from "fs/promises";
25981
26025
  import { createWriteStream } from "fs";
25982
26026
  import os5 from "os";
25983
- import path7 from "path";
26027
+ import path8 from "path";
25984
26028
  import crypto from "crypto";
25985
26029
  import readline3 from "readline";
25986
26030
  import { execFile, execFileSync as execFileSync2, spawn as spawn3 } from "child_process";
@@ -26106,7 +26150,7 @@ function sq(p) {
26106
26150
  return `'${p.replace(/'/g, "'\\''")}'`;
26107
26151
  }
26108
26152
  async function swapApp(newApp) {
26109
- const dir = path7.dirname(INSTALLED_APP);
26153
+ const dir = path8.dirname(INSTALLED_APP);
26110
26154
  if (await canWrite(dir)) {
26111
26155
  const bak = `${INSTALLED_APP}.bak-${process.pid}`;
26112
26156
  if (await fs6.stat(INSTALLED_APP).then(() => true).catch(() => false)) {
@@ -26181,10 +26225,10 @@ supbuddy update: could not reach the release server \u2014 ${e.message}`);
26181
26225
  return 0;
26182
26226
  }
26183
26227
  }
26184
- const tmp = await fs6.mkdtemp(path7.join(os5.tmpdir(), "supbuddy-update-"));
26185
- const tar = path7.join(tmp, TAR_ASSET);
26186
- const shaFile = path7.join(tmp, SHA_ASSET);
26187
- const extractDir = path7.join(tmp, "extracted");
26228
+ const tmp = await fs6.mkdtemp(path8.join(os5.tmpdir(), "supbuddy-update-"));
26229
+ const tar = path8.join(tmp, TAR_ASSET);
26230
+ const shaFile = path8.join(tmp, SHA_ASSET);
26231
+ const extractDir = path8.join(tmp, "extracted");
26188
26232
  try {
26189
26233
  console.log("Downloading\u2026");
26190
26234
  await downloadAsset(pick.tarUrl, tar);
@@ -26198,7 +26242,7 @@ supbuddy update: could not reach the release server \u2014 ${e.message}`);
26198
26242
  }
26199
26243
  await fs6.mkdir(extractDir, { recursive: true });
26200
26244
  execFileSync2("tar", ["-xzf", tar, "-C", extractDir]);
26201
- const newApp = path7.join(extractDir, "Supbuddy.app");
26245
+ const newApp = path8.join(extractDir, "Supbuddy.app");
26202
26246
  if (!await fs6.stat(newApp).then(() => true).catch(() => false)) {
26203
26247
  console.error("supbuddy update: the archive did not contain Supbuddy.app.");
26204
26248
  return 1;
@@ -26321,11 +26365,11 @@ __export(run_exports, {
26321
26365
  });
26322
26366
  import { spawn as spawn4, execSync } from "child_process";
26323
26367
  import fs7 from "fs";
26324
- import path8 from "path";
26368
+ import path9 from "path";
26325
26369
  function readMetaLoopbackIp(startDir) {
26326
26370
  let dir = startDir;
26327
26371
  for (; ; ) {
26328
- const metaPath = path8.join(dir, ".supbuddy", "meta.json");
26372
+ const metaPath = path9.join(dir, ".supbuddy", "meta.json");
26329
26373
  if (fs7.existsSync(metaPath)) {
26330
26374
  try {
26331
26375
  return JSON.parse(fs7.readFileSync(metaPath, "utf-8")).loopbackIp;
@@ -26333,7 +26377,7 @@ function readMetaLoopbackIp(startDir) {
26333
26377
  return void 0;
26334
26378
  }
26335
26379
  }
26336
- const parent = path8.dirname(dir);
26380
+ const parent = path9.dirname(dir);
26337
26381
  if (parent === dir) return void 0;
26338
26382
  dir = parent;
26339
26383
  }
@@ -26413,7 +26457,7 @@ __export(service_exports, {
26413
26457
  });
26414
26458
  import fs8 from "fs/promises";
26415
26459
  import os6 from "os";
26416
- import path9 from "path";
26460
+ import path10 from "path";
26417
26461
  import { fileURLToPath as fileURLToPath2 } from "url";
26418
26462
  import { spawnSync as spawnSync2 } from "child_process";
26419
26463
  function launchdPlist(o) {
@@ -26436,9 +26480,9 @@ function launchdPlist(o) {
26436
26480
  <key>KeepAlive</key>
26437
26481
  <true/>
26438
26482
  <key>StandardOutPath</key>
26439
- <string>${path9.join(o.logDir, "daemon.log")}</string>
26483
+ <string>${path10.join(o.logDir, "daemon.log")}</string>
26440
26484
  <key>StandardErrorPath</key>
26441
- <string>${path9.join(o.logDir, "daemon-error.log")}</string>
26485
+ <string>${path10.join(o.logDir, "daemon-error.log")}</string>
26442
26486
  </dict>
26443
26487
  </plist>
26444
26488
  `;
@@ -26458,16 +26502,16 @@ WantedBy=default.target
26458
26502
  `;
26459
26503
  }
26460
26504
  function launchdPlistPath() {
26461
- return path9.join(os6.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
26505
+ return path10.join(os6.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
26462
26506
  }
26463
26507
  function systemdUnitPath() {
26464
- const configHome = process.env.XDG_CONFIG_HOME ?? path9.join(os6.homedir(), ".config");
26465
- return path9.join(configHome, "systemd", "user", SYSTEMD_SERVICE);
26508
+ const configHome = process.env.XDG_CONFIG_HOME ?? path10.join(os6.homedir(), ".config");
26509
+ return path10.join(configHome, "systemd", "user", SYSTEMD_SERVICE);
26466
26510
  }
26467
26511
  function resolveBinPath() {
26468
- const __dirname3 = path9.dirname(fileURLToPath2(import.meta.url));
26469
- const repoRoot = path9.resolve(__dirname3, "..", "..", "..");
26470
- return path9.join(repoRoot, "apps", "cli", "dist", "bin.js");
26512
+ const __dirname3 = path10.dirname(fileURLToPath2(import.meta.url));
26513
+ const repoRoot = path10.resolve(__dirname3, "..", "..", "..");
26514
+ return path10.join(repoRoot, "apps", "cli", "dist", "bin.js");
26471
26515
  }
26472
26516
  async function installService(opts = {}, run = defaultRunner) {
26473
26517
  const platform = process.platform;
@@ -26487,11 +26531,11 @@ Run \`yarn workspace supbuddy build\` first.`
26487
26531
  return 1;
26488
26532
  }
26489
26533
  const stateDir = opts.stateDir ?? defaultStateDir();
26490
- const logDir = path9.join(stateDir, "logs");
26534
+ const logDir = path10.join(stateDir, "logs");
26491
26535
  await fs8.mkdir(logDir, { recursive: true });
26492
26536
  if (platform === "darwin") {
26493
26537
  const plistPath = launchdPlistPath();
26494
- await fs8.mkdir(path9.dirname(plistPath), { recursive: true });
26538
+ await fs8.mkdir(path10.dirname(plistPath), { recursive: true });
26495
26539
  const content2 = launchdPlist({ label: LAUNCHD_LABEL, nodePath, binPath, stateDir, logDir });
26496
26540
  await fs8.writeFile(plistPath, content2, { encoding: "utf8", mode: 420 });
26497
26541
  run("launchctl", ["unload", plistPath]);
@@ -26504,7 +26548,7 @@ Run \`yarn workspace supbuddy build\` first.`
26504
26548
  return 0;
26505
26549
  }
26506
26550
  const unitPath = systemdUnitPath();
26507
- await fs8.mkdir(path9.dirname(unitPath), { recursive: true });
26551
+ await fs8.mkdir(path10.dirname(unitPath), { recursive: true });
26508
26552
  const content = systemdUnit({ label: LAUNCHD_LABEL, nodePath, binPath, stateDir, logDir });
26509
26553
  await fs8.writeFile(unitPath, content, { encoding: "utf8", mode: 420 });
26510
26554
  const reload = run("systemctl", ["--user", "daemon-reload"]);
@@ -26620,7 +26664,7 @@ init_state_dir();
26620
26664
  import { realpathSync } from "fs";
26621
26665
  import { spawnSync as spawnSync3 } from "child_process";
26622
26666
  import { fileURLToPath as fileURLToPath3 } from "url";
26623
- import path10 from "path";
26667
+ import path11 from "path";
26624
26668
 
26625
26669
  // src/commands.ts
26626
26670
  init_client();
@@ -27660,12 +27704,12 @@ async function runCommand(argv, flags, clientFactory) {
27660
27704
  return 0;
27661
27705
  }
27662
27706
  if (sub === "env-read") {
27663
- const path11 = rest[0];
27664
- if (!path11) {
27707
+ const path12 = rest[0];
27708
+ if (!path12) {
27665
27709
  console.error("usage: supbuddy project env-read <path> [--key K]");
27666
27710
  return 1;
27667
27711
  }
27668
- const args = { path: path11 };
27712
+ const args = { path: path12 };
27669
27713
  if (typeof flags.key === "string") args.key = flags.key;
27670
27714
  print(await client.call("read_env_file", args), flags);
27671
27715
  return 0;
@@ -27913,8 +27957,8 @@ async function runCommand(argv, flags, clientFactory) {
27913
27957
  return 0;
27914
27958
  }
27915
27959
  if (sub === "write") {
27916
- const [path11, ...pairs] = rest;
27917
- if (!path11 || pairs.length === 0) {
27960
+ const [path12, ...pairs] = rest;
27961
+ if (!path12 || pairs.length === 0) {
27918
27962
  console.error("usage: supbuddy env write <path> <key=val>...");
27919
27963
  return 1;
27920
27964
  }
@@ -27929,7 +27973,7 @@ async function runCommand(argv, flags, clientFactory) {
27929
27973
  const v = pair.slice(eqIdx + 1);
27930
27974
  patch[k] = v === "" ? null : v;
27931
27975
  }
27932
- print(await client.call("write_env_file", { path: path11, patch }), flags);
27976
+ print(await client.call("write_env_file", { path: path12, patch }), flags);
27933
27977
  return 0;
27934
27978
  }
27935
27979
  console.error("usage: supbuddy env copy|write ...");
@@ -28429,9 +28473,9 @@ async function runShell(opts, stateDir, module) {
28429
28473
  const os7 = await import("os");
28430
28474
  const fs9 = await import("fs");
28431
28475
  const shellEntry = fileURLToPath3(new URL("../../tui/src/shell/bin.tsx", import.meta.url));
28432
- const REPO_ROOT2 = path10.resolve(fileURLToPath3(import.meta.url), "..", "..", "..", "..");
28433
- const tsxBin = path10.join(REPO_ROOT2, "node_modules", ".bin", "tsx");
28434
- const resultFile = path10.join(os7.tmpdir(), `supbuddy-shell-${process.pid}-${Date.now()}.json`);
28476
+ const REPO_ROOT2 = path11.resolve(fileURLToPath3(import.meta.url), "..", "..", "..", "..");
28477
+ const tsxBin = path11.join(REPO_ROOT2, "node_modules", ".bin", "tsx");
28478
+ const resultFile = path11.join(os7.tmpdir(), `supbuddy-shell-${process.pid}-${Date.now()}.json`);
28435
28479
  const env2 = { ...process.env, SUPBUDDY_SHELL_RESULT: resultFile };
28436
28480
  if (stateDir) env2.SUPBUDDY_STATE_DIR = stateDir;
28437
28481
  if (module) env2.SUPBUDDY_SHELL_MODULE = module;
@@ -28528,8 +28572,8 @@ async function dispatch(argv, opts) {
28528
28572
  case "tui":
28529
28573
  case "dash": {
28530
28574
  const tuiEntry = fileURLToPath3(new URL("../../tui/src/bin.tsx", import.meta.url));
28531
- const REPO_ROOT2 = path10.resolve(fileURLToPath3(import.meta.url), "..", "..", "..", "..");
28532
- const tsxBin = path10.join(REPO_ROOT2, "node_modules", ".bin", "tsx");
28575
+ const REPO_ROOT2 = path11.resolve(fileURLToPath3(import.meta.url), "..", "..", "..", "..");
28576
+ const tsxBin = path11.join(REPO_ROOT2, "node_modules", ".bin", "tsx");
28533
28577
  const env2 = { ...process.env };
28534
28578
  if (typeof flags["state-dir"] === "string") env2.SUPBUDDY_STATE_DIR = flags["state-dir"];
28535
28579
  if (typeof flags["url"] === "string") env2.SUPBUDDY_DAEMON_URL = flags["url"];