@exodus/xqa 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.cjs +389 -289
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1194,7 +1194,7 @@ var require_command = __commonJS({
1194
1194
  "../../node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/command.js"(exports2) {
1195
1195
  var EventEmitter = require("node:events").EventEmitter;
1196
1196
  var childProcess = require("node:child_process");
1197
- var path14 = require("node:path");
1197
+ var path16 = require("node:path");
1198
1198
  var fs = require("node:fs");
1199
1199
  var process6 = require("node:process");
1200
1200
  var { Argument: Argument2, humanReadableArgName } = require_argument();
@@ -1621,9 +1621,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
1621
1621
  if (fn) {
1622
1622
  this._exitCallback = fn;
1623
1623
  } else {
1624
- this._exitCallback = (err13) => {
1625
- if (err13.code !== "commander.executeSubCommandAsync") {
1626
- throw err13;
1624
+ this._exitCallback = (err14) => {
1625
+ if (err14.code !== "commander.executeSubCommandAsync") {
1626
+ throw err14;
1627
1627
  } else {
1628
1628
  }
1629
1629
  };
@@ -1699,12 +1699,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
1699
1699
  _callParseArg(target, value, previous, invalidArgumentMessage) {
1700
1700
  try {
1701
1701
  return target.parseArg(value, previous);
1702
- } catch (err13) {
1703
- if (err13.code === "commander.invalidArgument") {
1704
- const message = `${invalidArgumentMessage} ${err13.message}`;
1705
- this.error(message, { exitCode: err13.exitCode, code: err13.code });
1702
+ } catch (err14) {
1703
+ if (err14.code === "commander.invalidArgument") {
1704
+ const message = `${invalidArgumentMessage} ${err14.message}`;
1705
+ this.error(message, { exitCode: err14.exitCode, code: err14.code });
1706
1706
  }
1707
- throw err13;
1707
+ throw err14;
1708
1708
  }
1709
1709
  }
1710
1710
  /**
@@ -2207,9 +2207,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2207
2207
  let launchWithNode = false;
2208
2208
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
2209
2209
  function findFile(baseDir, baseName) {
2210
- const localBin = path14.resolve(baseDir, baseName);
2210
+ const localBin = path16.resolve(baseDir, baseName);
2211
2211
  if (fs.existsSync(localBin)) return localBin;
2212
- if (sourceExt.includes(path14.extname(baseName))) return void 0;
2212
+ if (sourceExt.includes(path16.extname(baseName))) return void 0;
2213
2213
  const foundExt = sourceExt.find(
2214
2214
  (ext) => fs.existsSync(`${localBin}${ext}`)
2215
2215
  );
@@ -2227,17 +2227,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
2227
2227
  } catch {
2228
2228
  resolvedScriptPath = this._scriptPath;
2229
2229
  }
2230
- executableDir = path14.resolve(
2231
- path14.dirname(resolvedScriptPath),
2230
+ executableDir = path16.resolve(
2231
+ path16.dirname(resolvedScriptPath),
2232
2232
  executableDir
2233
2233
  );
2234
2234
  }
2235
2235
  if (executableDir) {
2236
2236
  let localFile = findFile(executableDir, executableFile);
2237
2237
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
2238
- const legacyName = path14.basename(
2238
+ const legacyName = path16.basename(
2239
2239
  this._scriptPath,
2240
- path14.extname(this._scriptPath)
2240
+ path16.extname(this._scriptPath)
2241
2241
  );
2242
2242
  if (legacyName !== this._name) {
2243
2243
  localFile = findFile(
@@ -2248,7 +2248,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2248
2248
  }
2249
2249
  executableFile = localFile || executableFile;
2250
2250
  }
2251
- launchWithNode = sourceExt.includes(path14.extname(executableFile));
2251
+ launchWithNode = sourceExt.includes(path16.extname(executableFile));
2252
2252
  let proc;
2253
2253
  if (process6.platform !== "win32") {
2254
2254
  if (launchWithNode) {
@@ -2293,14 +2293,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
2293
2293
  );
2294
2294
  }
2295
2295
  });
2296
- proc.on("error", (err13) => {
2297
- if (err13.code === "ENOENT") {
2296
+ proc.on("error", (err14) => {
2297
+ if (err14.code === "ENOENT") {
2298
2298
  this._checkForMissingExecutable(
2299
2299
  executableFile,
2300
2300
  executableDir,
2301
2301
  subcommand._name
2302
2302
  );
2303
- } else if (err13.code === "EACCES") {
2303
+ } else if (err14.code === "EACCES") {
2304
2304
  throw new Error(`'${executableFile}' not executable`);
2305
2305
  }
2306
2306
  if (!exitCallback) {
@@ -2311,7 +2311,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2311
2311
  "commander.executeSubCommandAsync",
2312
2312
  "(error)"
2313
2313
  );
2314
- wrappedError.nestedError = err13;
2314
+ wrappedError.nestedError = err14;
2315
2315
  exitCallback(wrappedError);
2316
2316
  }
2317
2317
  });
@@ -3163,7 +3163,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3163
3163
  * @return {Command}
3164
3164
  */
3165
3165
  nameFromFilename(filename) {
3166
- this._name = path14.basename(filename, path14.extname(filename));
3166
+ this._name = path16.basename(filename, path16.extname(filename));
3167
3167
  return this;
3168
3168
  }
3169
3169
  /**
@@ -3177,9 +3177,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
3177
3177
  * @param {string} [path]
3178
3178
  * @return {(string|null|Command)}
3179
3179
  */
3180
- executableDir(path15) {
3181
- if (path15 === void 0) return this._executableDir;
3182
- this._executableDir = path15;
3180
+ executableDir(path17) {
3181
+ if (path17 === void 0) return this._executableDir;
3182
+ this._executableDir = path17;
3183
3183
  return this;
3184
3184
  }
3185
3185
  /**
@@ -3688,8 +3688,8 @@ var require_index_cjs = __commonJS({
3688
3688
  return new Ok(res.value);
3689
3689
  })));
3690
3690
  }
3691
- match(ok14, _err) {
3692
- return this._promise.then((res) => res.match(ok14, _err));
3691
+ match(ok15, _err) {
3692
+ return this._promise.then((res) => res.match(ok15, _err));
3693
3693
  }
3694
3694
  unwrapOr(t) {
3695
3695
  return this._promise.then((res) => res.unwrapOr(t));
@@ -3728,17 +3728,17 @@ var require_index_cjs = __commonJS({
3728
3728
  function okAsync8(value) {
3729
3729
  return new ResultAsync7(Promise.resolve(new Ok(value)));
3730
3730
  }
3731
- function errAsync8(err14) {
3732
- return new ResultAsync7(Promise.resolve(new Err(err14)));
3731
+ function errAsync8(err15) {
3732
+ return new ResultAsync7(Promise.resolve(new Err(err15)));
3733
3733
  }
3734
3734
  var fromPromise = ResultAsync7.fromPromise;
3735
3735
  var fromSafePromise2 = ResultAsync7.fromSafePromise;
3736
3736
  var fromAsyncThrowable9 = ResultAsync7.fromThrowable;
3737
3737
  var combineResultList = (resultList) => {
3738
- let acc = ok13([]);
3738
+ let acc = ok14([]);
3739
3739
  for (const result of resultList) {
3740
3740
  if (result.isErr()) {
3741
- acc = err13(result.error);
3741
+ acc = err14(result.error);
3742
3742
  break;
3743
3743
  } else {
3744
3744
  acc.map((list) => list.push(result.value));
@@ -3748,12 +3748,12 @@ var require_index_cjs = __commonJS({
3748
3748
  };
3749
3749
  var combineResultAsyncList = (asyncResultList) => ResultAsync7.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultList);
3750
3750
  var combineResultListWithAllErrors = (resultList) => {
3751
- let acc = ok13([]);
3751
+ let acc = ok14([]);
3752
3752
  for (const result of resultList) {
3753
3753
  if (result.isErr() && acc.isErr()) {
3754
3754
  acc.error.push(result.error);
3755
3755
  } else if (result.isErr() && acc.isOk()) {
3756
- acc = err13([result.error]);
3756
+ acc = err14([result.error]);
3757
3757
  } else if (result.isOk() && acc.isOk()) {
3758
3758
  acc.value.push(result.value);
3759
3759
  }
@@ -3767,9 +3767,9 @@ var require_index_cjs = __commonJS({
3767
3767
  return (...args) => {
3768
3768
  try {
3769
3769
  const result = fn(...args);
3770
- return ok13(result);
3770
+ return ok14(result);
3771
3771
  } catch (e3) {
3772
- return err13(errorFn ? errorFn(e3) : e3);
3772
+ return err14(errorFn ? errorFn(e3) : e3);
3773
3773
  }
3774
3774
  };
3775
3775
  }
@@ -3783,11 +3783,11 @@ var require_index_cjs = __commonJS({
3783
3783
  }
3784
3784
  Result.combineWithAllErrors = combineWithAllErrors;
3785
3785
  })(exports2.Result || (exports2.Result = {}));
3786
- function ok13(value) {
3786
+ function ok14(value) {
3787
3787
  return new Ok(value);
3788
3788
  }
3789
- function err13(err14) {
3790
- return new Err(err14);
3789
+ function err14(err15) {
3790
+ return new Err(err15);
3791
3791
  }
3792
3792
  function safeTry(body) {
3793
3793
  const n3 = body().next();
@@ -3807,11 +3807,11 @@ var require_index_cjs = __commonJS({
3807
3807
  return !this.isOk();
3808
3808
  }
3809
3809
  map(f6) {
3810
- return ok13(f6(this.value));
3810
+ return ok14(f6(this.value));
3811
3811
  }
3812
3812
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
3813
3813
  mapErr(_f) {
3814
- return ok13(this.value);
3814
+ return ok14(this.value);
3815
3815
  }
3816
3816
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3817
3817
  andThen(f6) {
@@ -3826,14 +3826,14 @@ var require_index_cjs = __commonJS({
3826
3826
  f6(this.value);
3827
3827
  } catch (e3) {
3828
3828
  }
3829
- return ok13(this.value);
3829
+ return ok14(this.value);
3830
3830
  }
3831
3831
  orTee(_f) {
3832
- return ok13(this.value);
3832
+ return ok14(this.value);
3833
3833
  }
3834
3834
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3835
3835
  orElse(_f) {
3836
- return ok13(this.value);
3836
+ return ok14(this.value);
3837
3837
  }
3838
3838
  asyncAndThen(f6) {
3839
3839
  return f6(this.value);
@@ -3850,8 +3850,8 @@ var require_index_cjs = __commonJS({
3850
3850
  return this.value;
3851
3851
  }
3852
3852
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
3853
- match(ok14, _err) {
3854
- return ok14(this.value);
3853
+ match(ok15, _err) {
3854
+ return ok15(this.value);
3855
3855
  }
3856
3856
  safeUnwrap() {
3857
3857
  const value = this.value;
@@ -3882,27 +3882,27 @@ var require_index_cjs = __commonJS({
3882
3882
  }
3883
3883
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
3884
3884
  map(_f) {
3885
- return err13(this.error);
3885
+ return err14(this.error);
3886
3886
  }
3887
3887
  mapErr(f6) {
3888
- return err13(f6(this.error));
3888
+ return err14(f6(this.error));
3889
3889
  }
3890
3890
  andThrough(_f) {
3891
- return err13(this.error);
3891
+ return err14(this.error);
3892
3892
  }
3893
3893
  andTee(_f) {
3894
- return err13(this.error);
3894
+ return err14(this.error);
3895
3895
  }
3896
3896
  orTee(f6) {
3897
3897
  try {
3898
3898
  f6(this.error);
3899
3899
  } catch (e3) {
3900
3900
  }
3901
- return err13(this.error);
3901
+ return err14(this.error);
3902
3902
  }
3903
3903
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3904
3904
  andThen(_f) {
3905
- return err13(this.error);
3905
+ return err14(this.error);
3906
3906
  }
3907
3907
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3908
3908
  orElse(f6) {
@@ -3922,13 +3922,13 @@ var require_index_cjs = __commonJS({
3922
3922
  unwrapOr(v2) {
3923
3923
  return v2;
3924
3924
  }
3925
- match(_ok, err14) {
3926
- return err14(this.error);
3925
+ match(_ok, err15) {
3926
+ return err15(this.error);
3927
3927
  }
3928
3928
  safeUnwrap() {
3929
3929
  const error48 = this.error;
3930
3930
  return (function* () {
3931
- yield err13(error48);
3931
+ yield err14(error48);
3932
3932
  throw new Error("Do not use this generator out of `safeTry`");
3933
3933
  })();
3934
3934
  }
@@ -3948,13 +3948,13 @@ var require_index_cjs = __commonJS({
3948
3948
  exports2.Err = Err;
3949
3949
  exports2.Ok = Ok;
3950
3950
  exports2.ResultAsync = ResultAsync7;
3951
- exports2.err = err13;
3951
+ exports2.err = err14;
3952
3952
  exports2.errAsync = errAsync8;
3953
3953
  exports2.fromAsyncThrowable = fromAsyncThrowable9;
3954
3954
  exports2.fromPromise = fromPromise;
3955
3955
  exports2.fromSafePromise = fromSafePromise2;
3956
3956
  exports2.fromThrowable = fromThrowable10;
3957
- exports2.ok = ok13;
3957
+ exports2.ok = ok14;
3958
3958
  exports2.okAsync = okAsync8;
3959
3959
  exports2.safeTry = safeTry;
3960
3960
  }
@@ -5052,15 +5052,15 @@ var require_route = __commonJS({
5052
5052
  };
5053
5053
  }
5054
5054
  function wrapConversion(toModel, graph) {
5055
- const path14 = [graph[toModel].parent, toModel];
5055
+ const path16 = [graph[toModel].parent, toModel];
5056
5056
  let fn = conversions[graph[toModel].parent][toModel];
5057
5057
  let cur = graph[toModel].parent;
5058
5058
  while (graph[cur].parent) {
5059
- path14.unshift(graph[cur].parent);
5059
+ path16.unshift(graph[cur].parent);
5060
5060
  fn = link(conversions[graph[cur].parent][cur], fn);
5061
5061
  cur = graph[cur].parent;
5062
5062
  }
5063
- fn.conversion = path14;
5063
+ fn.conversion = path16;
5064
5064
  return fn;
5065
5065
  }
5066
5066
  module2.exports = function(fromModel) {
@@ -11117,12 +11117,12 @@ var require_lib2 = __commonJS({
11117
11117
  var detectFile = (filepath, opts = {}) => new Promise((resolve, reject) => {
11118
11118
  let fd;
11119
11119
  const fs = (0, node_1.default)();
11120
- const handler = (err13, buffer) => {
11120
+ const handler = (err14, buffer) => {
11121
11121
  if (fd) {
11122
11122
  fs.closeSync(fd);
11123
11123
  }
11124
- if (err13) {
11125
- reject(err13);
11124
+ if (err14) {
11125
+ reject(err14);
11126
11126
  } else if (buffer) {
11127
11127
  resolve((0, exports2.detect)(buffer));
11128
11128
  } else {
@@ -11133,9 +11133,9 @@ var require_lib2 = __commonJS({
11133
11133
  if (sampleSize > 0) {
11134
11134
  fd = fs.openSync(filepath, "r");
11135
11135
  let sample = Buffer.allocUnsafe(sampleSize);
11136
- fs.read(fd, sample, 0, sampleSize, opts.offset, (err13, bytesRead) => {
11137
- if (err13) {
11138
- handler(err13, null);
11136
+ fs.read(fd, sample, 0, sampleSize, opts.offset, (err14, bytesRead) => {
11137
+ if (err14) {
11138
+ handler(err14, null);
11139
11139
  } else {
11140
11140
  if (bytesRead < sampleSize) {
11141
11141
  sample = sample.subarray(0, bytesRead);
@@ -15026,7 +15026,7 @@ var require_package = __commonJS({
15026
15026
  var require_main = __commonJS({
15027
15027
  "../../node_modules/.pnpm/dotenv@16.6.1/node_modules/dotenv/lib/main.js"(exports2, module2) {
15028
15028
  var fs = require("fs");
15029
- var path14 = require("path");
15029
+ var path16 = require("path");
15030
15030
  var os3 = require("os");
15031
15031
  var crypto = require("crypto");
15032
15032
  var packageJson = require_package();
@@ -15057,9 +15057,9 @@ var require_main = __commonJS({
15057
15057
  options.path = vaultPath;
15058
15058
  const result = DotenvModule.configDotenv(options);
15059
15059
  if (!result.parsed) {
15060
- const err13 = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
15061
- err13.code = "MISSING_DATA";
15062
- throw err13;
15060
+ const err14 = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
15061
+ err14.code = "MISSING_DATA";
15062
+ throw err14;
15063
15063
  }
15064
15064
  const keys = _dotenvKey(options).split(",");
15065
15065
  const length = keys.length;
@@ -15102,30 +15102,30 @@ var require_main = __commonJS({
15102
15102
  uri = new URL(dotenvKey);
15103
15103
  } catch (error48) {
15104
15104
  if (error48.code === "ERR_INVALID_URL") {
15105
- const err13 = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
15106
- err13.code = "INVALID_DOTENV_KEY";
15107
- throw err13;
15105
+ const err14 = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
15106
+ err14.code = "INVALID_DOTENV_KEY";
15107
+ throw err14;
15108
15108
  }
15109
15109
  throw error48;
15110
15110
  }
15111
15111
  const key = uri.password;
15112
15112
  if (!key) {
15113
- const err13 = new Error("INVALID_DOTENV_KEY: Missing key part");
15114
- err13.code = "INVALID_DOTENV_KEY";
15115
- throw err13;
15113
+ const err14 = new Error("INVALID_DOTENV_KEY: Missing key part");
15114
+ err14.code = "INVALID_DOTENV_KEY";
15115
+ throw err14;
15116
15116
  }
15117
15117
  const environment = uri.searchParams.get("environment");
15118
15118
  if (!environment) {
15119
- const err13 = new Error("INVALID_DOTENV_KEY: Missing environment part");
15120
- err13.code = "INVALID_DOTENV_KEY";
15121
- throw err13;
15119
+ const err14 = new Error("INVALID_DOTENV_KEY: Missing environment part");
15120
+ err14.code = "INVALID_DOTENV_KEY";
15121
+ throw err14;
15122
15122
  }
15123
15123
  const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
15124
15124
  const ciphertext = result.parsed[environmentKey];
15125
15125
  if (!ciphertext) {
15126
- const err13 = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
15127
- err13.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
15128
- throw err13;
15126
+ const err14 = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
15127
+ err14.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
15128
+ throw err14;
15129
15129
  }
15130
15130
  return { ciphertext, key };
15131
15131
  }
@@ -15142,7 +15142,7 @@ var require_main = __commonJS({
15142
15142
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
15143
15143
  }
15144
15144
  } else {
15145
- possibleVaultPath = path14.resolve(process.cwd(), ".env.vault");
15145
+ possibleVaultPath = path16.resolve(process.cwd(), ".env.vault");
15146
15146
  }
15147
15147
  if (fs.existsSync(possibleVaultPath)) {
15148
15148
  return possibleVaultPath;
@@ -15150,7 +15150,7 @@ var require_main = __commonJS({
15150
15150
  return null;
15151
15151
  }
15152
15152
  function _resolveHome(envPath) {
15153
- return envPath[0] === "~" ? path14.join(os3.homedir(), envPath.slice(1)) : envPath;
15153
+ return envPath[0] === "~" ? path16.join(os3.homedir(), envPath.slice(1)) : envPath;
15154
15154
  }
15155
15155
  function _configVault(options) {
15156
15156
  const debug = Boolean(options && options.debug);
@@ -15167,7 +15167,7 @@ var require_main = __commonJS({
15167
15167
  return { parsed };
15168
15168
  }
15169
15169
  function configDotenv(options) {
15170
- const dotenvPath = path14.resolve(process.cwd(), ".env");
15170
+ const dotenvPath = path16.resolve(process.cwd(), ".env");
15171
15171
  let encoding = "utf8";
15172
15172
  const debug = Boolean(options && options.debug);
15173
15173
  const quiet = options && "quiet" in options ? options.quiet : true;
@@ -15191,13 +15191,13 @@ var require_main = __commonJS({
15191
15191
  }
15192
15192
  let lastError;
15193
15193
  const parsedAll = {};
15194
- for (const path15 of optionPaths) {
15194
+ for (const path17 of optionPaths) {
15195
15195
  try {
15196
- const parsed = DotenvModule.parse(fs.readFileSync(path15, { encoding }));
15196
+ const parsed = DotenvModule.parse(fs.readFileSync(path17, { encoding }));
15197
15197
  DotenvModule.populate(parsedAll, parsed, options);
15198
15198
  } catch (e3) {
15199
15199
  if (debug) {
15200
- _debug(`Failed to load ${path15} ${e3.message}`);
15200
+ _debug(`Failed to load ${path17} ${e3.message}`);
15201
15201
  }
15202
15202
  lastError = e3;
15203
15203
  }
@@ -15212,7 +15212,7 @@ var require_main = __commonJS({
15212
15212
  const shortPaths = [];
15213
15213
  for (const filePath of optionPaths) {
15214
15214
  try {
15215
- const relative = path14.relative(process.cwd(), filePath);
15215
+ const relative = path16.relative(process.cwd(), filePath);
15216
15216
  shortPaths.push(relative);
15217
15217
  } catch (e3) {
15218
15218
  if (debug) {
@@ -15255,13 +15255,13 @@ var require_main = __commonJS({
15255
15255
  const invalidKeyLength = error48.message === "Invalid key length";
15256
15256
  const decryptionFailed = error48.message === "Unsupported state or unable to authenticate data";
15257
15257
  if (isRange || invalidKeyLength) {
15258
- const err13 = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
15259
- err13.code = "INVALID_DOTENV_KEY";
15260
- throw err13;
15258
+ const err14 = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
15259
+ err14.code = "INVALID_DOTENV_KEY";
15260
+ throw err14;
15261
15261
  } else if (decryptionFailed) {
15262
- const err13 = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
15263
- err13.code = "DECRYPTION_FAILED";
15264
- throw err13;
15262
+ const err14 = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
15263
+ err14.code = "DECRYPTION_FAILED";
15264
+ throw err14;
15265
15265
  } else {
15266
15266
  throw error48;
15267
15267
  }
@@ -15271,9 +15271,9 @@ var require_main = __commonJS({
15271
15271
  const debug = Boolean(options && options.debug);
15272
15272
  const override = Boolean(options && options.override);
15273
15273
  if (typeof parsed !== "object") {
15274
- const err13 = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
15275
- err13.code = "OBJECT_REQUIRED";
15276
- throw err13;
15274
+ const err14 = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
15275
+ err14.code = "OBJECT_REQUIRED";
15276
+ throw err14;
15277
15277
  }
15278
15278
  for (const key of Object.keys(parsed)) {
15279
15279
  if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
@@ -16355,12 +16355,22 @@ var StepOrderBuffer = class {
16355
16355
  this.onFlush = onFlush;
16356
16356
  }
16357
16357
  enqueue(event) {
16358
+ if (this.phase === "cleanup") {
16359
+ this.onFlush(event, this.phase);
16360
+ return;
16361
+ }
16358
16362
  this.pending.set(event.stepIndex, event);
16359
16363
  this.flush();
16360
16364
  }
16361
16365
  setCleanupPhase() {
16362
16366
  this.phase = "cleanup";
16363
- this.flush();
16367
+ const sorted = [...this.pending.values()].toSorted(
16368
+ (event1, event2) => event1.stepIndex - event2.stepIndex
16369
+ );
16370
+ for (const event of sorted) {
16371
+ this.onFlush(event, this.phase);
16372
+ }
16373
+ this.pending.clear();
16364
16374
  }
16365
16375
  flush() {
16366
16376
  for (; ; ) {
@@ -17436,10 +17446,10 @@ function mergeDefs(...defs) {
17436
17446
  function cloneDef(schema2) {
17437
17447
  return mergeDefs(schema2._zod.def);
17438
17448
  }
17439
- function getElementAtPath(obj, path14) {
17440
- if (!path14)
17449
+ function getElementAtPath(obj, path16) {
17450
+ if (!path16)
17441
17451
  return obj;
17442
- return path14.reduce((acc, key) => acc?.[key], obj);
17452
+ return path16.reduce((acc, key) => acc?.[key], obj);
17443
17453
  }
17444
17454
  function promiseAllObject(promisesObj) {
17445
17455
  const keys = Object.keys(promisesObj);
@@ -17822,11 +17832,11 @@ function aborted(x, startIndex = 0) {
17822
17832
  }
17823
17833
  return false;
17824
17834
  }
17825
- function prefixIssues(path14, issues) {
17835
+ function prefixIssues(path16, issues) {
17826
17836
  return issues.map((iss) => {
17827
17837
  var _a3;
17828
17838
  (_a3 = iss).path ?? (_a3.path = []);
17829
- iss.path.unshift(path14);
17839
+ iss.path.unshift(path16);
17830
17840
  return iss;
17831
17841
  });
17832
17842
  }
@@ -18009,7 +18019,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
18009
18019
  }
18010
18020
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
18011
18021
  const result = { errors: [] };
18012
- const processError = (error49, path14 = []) => {
18022
+ const processError = (error49, path16 = []) => {
18013
18023
  var _a3, _b2;
18014
18024
  for (const issue2 of error49.issues) {
18015
18025
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -18019,7 +18029,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
18019
18029
  } else if (issue2.code === "invalid_element") {
18020
18030
  processError({ issues: issue2.issues }, issue2.path);
18021
18031
  } else {
18022
- const fullpath = [...path14, ...issue2.path];
18032
+ const fullpath = [...path16, ...issue2.path];
18023
18033
  if (fullpath.length === 0) {
18024
18034
  result.errors.push(mapper(issue2));
18025
18035
  continue;
@@ -18051,8 +18061,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
18051
18061
  }
18052
18062
  function toDotPath(_path) {
18053
18063
  const segs = [];
18054
- const path14 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
18055
- for (const seg of path14) {
18064
+ const path16 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
18065
+ for (const seg of path16) {
18056
18066
  if (typeof seg === "number")
18057
18067
  segs.push(`[${seg}]`);
18058
18068
  else if (typeof seg === "symbol")
@@ -30029,13 +30039,13 @@ function resolveRef(ref, ctx) {
30029
30039
  if (!ref.startsWith("#")) {
30030
30040
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
30031
30041
  }
30032
- const path14 = ref.slice(1).split("/").filter(Boolean);
30033
- if (path14.length === 0) {
30042
+ const path16 = ref.slice(1).split("/").filter(Boolean);
30043
+ if (path16.length === 0) {
30034
30044
  return ctx.rootSchema;
30035
30045
  }
30036
30046
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
30037
- if (path14[0] === defsKey) {
30038
- const key = path14[1];
30047
+ if (path16[0] === defsKey) {
30048
+ const key = path16[1];
30039
30049
  if (!key || !ctx.defs[key]) {
30040
30050
  throw new Error(`Reference not found: ${ref}`);
30041
30051
  }
@@ -33786,9 +33796,9 @@ var tq = k((oq) => {
33786
33796
  });
33787
33797
  var sq = k((aq) => {
33788
33798
  Object.defineProperty(aq, "__esModule", { value: true });
33789
- var ok13 = Q$(), tk = { keyword: "not", schemaType: ["object", "boolean"], trackErrors: true, code($) {
33799
+ var ok14 = Q$(), tk = { keyword: "not", schemaType: ["object", "boolean"], trackErrors: true, code($) {
33790
33800
  let { gen: X, schema: J, it: Q } = $;
33791
- if ((0, ok13.alwaysValidSchema)(Q, J)) {
33801
+ if ((0, ok14.alwaysValidSchema)(Q, J)) {
33792
33802
  $.fail();
33793
33803
  return;
33794
33804
  }
@@ -48584,6 +48594,17 @@ async function resolveDisallowedTools(allowedTools) {
48584
48594
  const allowedSet = new Set(allowedTools);
48585
48595
  return allTools.filter((tool2) => !allowedSet.has(tool2));
48586
48596
  }
48597
+ function buildLinkedController(signal) {
48598
+ const controller2 = new AbortController();
48599
+ signal.addEventListener(
48600
+ "abort",
48601
+ () => {
48602
+ controller2.abort(signal.reason);
48603
+ },
48604
+ { once: true }
48605
+ );
48606
+ return controller2;
48607
+ }
48587
48608
  function buildQueryOptions({
48588
48609
  config: config3,
48589
48610
  outputTools,
@@ -48591,7 +48612,7 @@ function buildQueryOptions({
48591
48612
  allowedTools,
48592
48613
  disallowedTools
48593
48614
  }) {
48594
- return {
48615
+ const base = {
48595
48616
  mcpServers: {
48596
48617
  ...config3.mcpServers,
48597
48618
  output: outputTools.server,
@@ -48602,6 +48623,10 @@ function buildQueryOptions({
48602
48623
  settingSources: ["user"],
48603
48624
  spawnClaudeCodeProcess: spawnDetached
48604
48625
  };
48626
+ if (!config3.signal) {
48627
+ return base;
48628
+ }
48629
+ return { ...base, abortController: buildLinkedController(config3.signal) };
48605
48630
  }
48606
48631
  function buildSendMessageFunction(inputQueue) {
48607
48632
  return (content) => {
@@ -49374,15 +49399,15 @@ async function makeRequest(url2, fetchOptions, fetchFn = fetch) {
49374
49399
  return response;
49375
49400
  }
49376
49401
  function handleResponseError(e3, url2) {
49377
- let err13 = e3;
49378
- if (err13.name === "AbortError") {
49379
- err13 = new GoogleGenerativeAIAbortError(`Request aborted when fetching ${url2.toString()}: ${e3.message}`);
49380
- err13.stack = e3.stack;
49402
+ let err14 = e3;
49403
+ if (err14.name === "AbortError") {
49404
+ err14 = new GoogleGenerativeAIAbortError(`Request aborted when fetching ${url2.toString()}: ${e3.message}`);
49405
+ err14.stack = e3.stack;
49381
49406
  } else if (!(e3 instanceof GoogleGenerativeAIFetchError || e3 instanceof GoogleGenerativeAIRequestInputError)) {
49382
- err13 = new GoogleGenerativeAIError(`Error fetching from ${url2.toString()}: ${e3.message}`);
49383
- err13.stack = e3.stack;
49407
+ err14 = new GoogleGenerativeAIError(`Error fetching from ${url2.toString()}: ${e3.message}`);
49408
+ err14.stack = e3.stack;
49384
49409
  }
49385
- throw err13;
49410
+ throw err14;
49386
49411
  }
49387
49412
  async function handleResponseNotOk(response, url2) {
49388
49413
  let message = "";
@@ -49629,14 +49654,14 @@ function getResponseStream(inputStream) {
49629
49654
  }
49630
49655
  return pump();
49631
49656
  }).catch((e3) => {
49632
- let err13 = e3;
49633
- err13.stack = e3.stack;
49634
- if (err13.name === "AbortError") {
49635
- err13 = new GoogleGenerativeAIAbortError("Request aborted when reading from the stream");
49657
+ let err14 = e3;
49658
+ err14.stack = e3.stack;
49659
+ if (err14.name === "AbortError") {
49660
+ err14 = new GoogleGenerativeAIAbortError("Request aborted when reading from the stream");
49636
49661
  } else {
49637
- err13 = new GoogleGenerativeAIError("Error reading from the stream");
49662
+ err14 = new GoogleGenerativeAIError("Error reading from the stream");
49638
49663
  }
49639
- throw err13;
49664
+ throw err14;
49640
49665
  });
49641
49666
  }
49642
49667
  }
@@ -50232,15 +50257,15 @@ async function makeRequest2(url2, fetchOptions, fetchFn = fetch) {
50232
50257
  return response;
50233
50258
  }
50234
50259
  function handleResponseError2(e3, url2) {
50235
- let err13 = e3;
50236
- if (err13.name === "AbortError") {
50237
- err13 = new GoogleGenerativeAIAbortError2(`Request aborted when fetching ${url2.toString()}: ${e3.message}`);
50238
- err13.stack = e3.stack;
50260
+ let err14 = e3;
50261
+ if (err14.name === "AbortError") {
50262
+ err14 = new GoogleGenerativeAIAbortError2(`Request aborted when fetching ${url2.toString()}: ${e3.message}`);
50263
+ err14.stack = e3.stack;
50239
50264
  } else if (!(e3 instanceof GoogleGenerativeAIFetchError2 || e3 instanceof GoogleGenerativeAIRequestInputError2)) {
50240
- err13 = new GoogleGenerativeAIError2(`Error fetching from ${url2.toString()}: ${e3.message}`);
50241
- err13.stack = e3.stack;
50265
+ err14 = new GoogleGenerativeAIError2(`Error fetching from ${url2.toString()}: ${e3.message}`);
50266
+ err14.stack = e3.stack;
50242
50267
  }
50243
- throw err13;
50268
+ throw err14;
50244
50269
  }
50245
50270
  async function handleResponseNotOk2(response, url2) {
50246
50271
  let message = "";
@@ -50279,8 +50304,8 @@ var ServerRequestUrl = class {
50279
50304
  this.apiKey = apiKey;
50280
50305
  this.requestOptions = requestOptions;
50281
50306
  }
50282
- appendPath(path14) {
50283
- this._url.pathname = this._url.pathname + `/${path14}`;
50307
+ appendPath(path16) {
50308
+ this._url.pathname = this._url.pathname + `/${path16}`;
50284
50309
  }
50285
50310
  appendParam(key, value) {
50286
50311
  this._url.searchParams.append(key, value);
@@ -50836,34 +50861,34 @@ var uuid42 = function() {
50836
50861
  };
50837
50862
 
50838
50863
  // ../../node_modules/.pnpm/@anthropic-ai+sdk@0.87.0_zod@4.3.6/node_modules/@anthropic-ai/sdk/internal/errors.mjs
50839
- function isAbortError(err13) {
50840
- return typeof err13 === "object" && err13 !== null && // Spec-compliant fetch implementations
50841
- ("name" in err13 && err13.name === "AbortError" || // Expo fetch
50842
- "message" in err13 && String(err13.message).includes("FetchRequestCanceledException"));
50843
- }
50844
- var castToError = (err13) => {
50845
- if (err13 instanceof Error)
50846
- return err13;
50847
- if (typeof err13 === "object" && err13 !== null) {
50864
+ function isAbortError(err14) {
50865
+ return typeof err14 === "object" && err14 !== null && // Spec-compliant fetch implementations
50866
+ ("name" in err14 && err14.name === "AbortError" || // Expo fetch
50867
+ "message" in err14 && String(err14.message).includes("FetchRequestCanceledException"));
50868
+ }
50869
+ var castToError = (err14) => {
50870
+ if (err14 instanceof Error)
50871
+ return err14;
50872
+ if (typeof err14 === "object" && err14 !== null) {
50848
50873
  try {
50849
- if (Object.prototype.toString.call(err13) === "[object Error]") {
50850
- const error48 = new Error(err13.message, err13.cause ? { cause: err13.cause } : {});
50851
- if (err13.stack)
50852
- error48.stack = err13.stack;
50853
- if (err13.cause && !error48.cause)
50854
- error48.cause = err13.cause;
50855
- if (err13.name)
50856
- error48.name = err13.name;
50874
+ if (Object.prototype.toString.call(err14) === "[object Error]") {
50875
+ const error48 = new Error(err14.message, err14.cause ? { cause: err14.cause } : {});
50876
+ if (err14.stack)
50877
+ error48.stack = err14.stack;
50878
+ if (err14.cause && !error48.cause)
50879
+ error48.cause = err14.cause;
50880
+ if (err14.name)
50881
+ error48.name = err14.name;
50857
50882
  return error48;
50858
50883
  }
50859
50884
  } catch {
50860
50885
  }
50861
50886
  try {
50862
- return new Error(JSON.stringify(err13));
50887
+ return new Error(JSON.stringify(err14));
50863
50888
  } catch {
50864
50889
  }
50865
50890
  }
50866
- return new Error(err13);
50891
+ return new Error(err14);
50867
50892
  };
50868
50893
 
50869
50894
  // ../../node_modules/.pnpm/@anthropic-ai+sdk@0.87.0_zod@4.3.6/node_modules/@anthropic-ai/sdk/core/error.mjs
@@ -50993,7 +51018,7 @@ var validatePositiveInteger = (name, n3) => {
50993
51018
  var safeJSON = (text) => {
50994
51019
  try {
50995
51020
  return JSON.parse(text);
50996
- } catch (err13) {
51021
+ } catch (err14) {
50997
51022
  return void 0;
50998
51023
  }
50999
51024
  };
@@ -51557,8 +51582,8 @@ var Stream = class _Stream {
51557
51582
  return ctrl.close();
51558
51583
  const bytes = encodeUTF8(JSON.stringify(value) + "\n");
51559
51584
  ctrl.enqueue(bytes);
51560
- } catch (err13) {
51561
- ctrl.error(err13);
51585
+ } catch (err14) {
51586
+ ctrl.error(err14);
51562
51587
  }
51563
51588
  },
51564
51589
  async cancel() {
@@ -52106,12 +52131,12 @@ function encodeURIPath(str2) {
52106
52131
  return str2.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
52107
52132
  }
52108
52133
  var EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
52109
- var createPathTagFunction = (pathEncoder = encodeURIPath) => function path14(statics, ...params) {
52134
+ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path16(statics, ...params) {
52110
52135
  if (statics.length === 1)
52111
52136
  return statics[0];
52112
52137
  let postPath = false;
52113
52138
  const invalidSegments = [];
52114
- const path15 = statics.reduce((previousValue, currentValue, index) => {
52139
+ const path17 = statics.reduce((previousValue, currentValue, index) => {
52115
52140
  if (/[?#]/.test(currentValue)) {
52116
52141
  postPath = true;
52117
52142
  }
@@ -52128,7 +52153,7 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path14(sta
52128
52153
  }
52129
52154
  return previousValue + currentValue + (index === params.length ? "" : encoded);
52130
52155
  }, "");
52131
- const pathOnly = path15.split(/[?#]/, 1)[0];
52156
+ const pathOnly = path17.split(/[?#]/, 1)[0];
52132
52157
  const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
52133
52158
  let match;
52134
52159
  while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
@@ -52149,10 +52174,10 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path14(sta
52149
52174
  }, "");
52150
52175
  throw new AnthropicError(`Path parameters result in path with invalid segments:
52151
52176
  ${invalidSegments.map((e3) => e3.error).join("\n")}
52152
- ${path15}
52177
+ ${path17}
52153
52178
  ${underline}`);
52154
52179
  }
52155
- return path15;
52180
+ return path17;
52156
52181
  };
52157
52182
  var path5 = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
52158
52183
 
@@ -53465,8 +53490,8 @@ var BetaMessageStream = class _BetaMessageStream {
53465
53490
  if (jsonBuf) {
53466
53491
  try {
53467
53492
  newContent.input = partialParse(jsonBuf);
53468
- } catch (err13) {
53469
- const error48 = new AnthropicError(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${err13}. JSON: ${jsonBuf}`);
53493
+ } catch (err14) {
53494
+ const error48 = new AnthropicError(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${err14}. JSON: ${jsonBuf}`);
53470
53495
  __classPrivateFieldGet(this, _BetaMessageStream_handleError, "f").call(this, error48);
53471
53496
  }
53472
53497
  }
@@ -53528,17 +53553,17 @@ var BetaMessageStream = class _BetaMessageStream {
53528
53553
  }
53529
53554
  readQueue.length = 0;
53530
53555
  });
53531
- this.on("abort", (err13) => {
53556
+ this.on("abort", (err14) => {
53532
53557
  done = true;
53533
53558
  for (const reader of readQueue) {
53534
- reader.reject(err13);
53559
+ reader.reject(err14);
53535
53560
  }
53536
53561
  readQueue.length = 0;
53537
53562
  });
53538
- this.on("error", (err13) => {
53563
+ this.on("error", (err14) => {
53539
53564
  done = true;
53540
53565
  for (const reader of readQueue) {
53541
- reader.reject(err13);
53566
+ reader.reject(err14);
53542
53567
  }
53543
53568
  readQueue.length = 0;
53544
53569
  });
@@ -55781,17 +55806,17 @@ var MessageStream = class _MessageStream {
55781
55806
  }
55782
55807
  readQueue.length = 0;
55783
55808
  });
55784
- this.on("abort", (err13) => {
55809
+ this.on("abort", (err14) => {
55785
55810
  done = true;
55786
55811
  for (const reader of readQueue) {
55787
- reader.reject(err13);
55812
+ reader.reject(err14);
55788
55813
  }
55789
55814
  readQueue.length = 0;
55790
55815
  });
55791
- this.on("error", (err13) => {
55816
+ this.on("error", (err14) => {
55792
55817
  done = true;
55793
55818
  for (const reader of readQueue) {
55794
- reader.reject(err13);
55819
+ reader.reject(err14);
55795
55820
  }
55796
55821
  readQueue.length = 0;
55797
55822
  });
@@ -56240,9 +56265,9 @@ var BaseAnthropic = class {
56240
56265
  makeStatusError(status, error48, message, headers) {
56241
56266
  return APIError.generate(status, error48, message, headers);
56242
56267
  }
56243
- buildURL(path14, query, defaultBaseURL) {
56268
+ buildURL(path16, query, defaultBaseURL) {
56244
56269
  const baseURL = !__classPrivateFieldGet(this, _BaseAnthropic_instances, "m", _BaseAnthropic_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
56245
- const url2 = isAbsoluteURL(path14) ? new URL(path14) : new URL(baseURL + (baseURL.endsWith("/") && path14.startsWith("/") ? path14.slice(1) : path14));
56270
+ const url2 = isAbsoluteURL(path16) ? new URL(path16) : new URL(baseURL + (baseURL.endsWith("/") && path16.startsWith("/") ? path16.slice(1) : path16));
56246
56271
  const defaultQuery = this.defaultQuery();
56247
56272
  const pathQuery = Object.fromEntries(url2.searchParams);
56248
56273
  if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
@@ -56274,24 +56299,24 @@ var BaseAnthropic = class {
56274
56299
  */
56275
56300
  async prepareRequest(request, { url: url2, options }) {
56276
56301
  }
56277
- get(path14, opts) {
56278
- return this.methodRequest("get", path14, opts);
56302
+ get(path16, opts) {
56303
+ return this.methodRequest("get", path16, opts);
56279
56304
  }
56280
- post(path14, opts) {
56281
- return this.methodRequest("post", path14, opts);
56305
+ post(path16, opts) {
56306
+ return this.methodRequest("post", path16, opts);
56282
56307
  }
56283
- patch(path14, opts) {
56284
- return this.methodRequest("patch", path14, opts);
56308
+ patch(path16, opts) {
56309
+ return this.methodRequest("patch", path16, opts);
56285
56310
  }
56286
- put(path14, opts) {
56287
- return this.methodRequest("put", path14, opts);
56311
+ put(path16, opts) {
56312
+ return this.methodRequest("put", path16, opts);
56288
56313
  }
56289
- delete(path14, opts) {
56290
- return this.methodRequest("delete", path14, opts);
56314
+ delete(path16, opts) {
56315
+ return this.methodRequest("delete", path16, opts);
56291
56316
  }
56292
- methodRequest(method, path14, opts) {
56317
+ methodRequest(method, path16, opts) {
56293
56318
  return this.request(Promise.resolve(opts).then((opts2) => {
56294
- return { method, path: path14, ...opts2 };
56319
+ return { method, path: path16, ...opts2 };
56295
56320
  }));
56296
56321
  }
56297
56322
  request(options, remainingRetries = null) {
@@ -56371,7 +56396,7 @@ var BaseAnthropic = class {
56371
56396
  }
56372
56397
  const retryMessage = shouldRetry ? `error; no more retries left` : `error; not retryable`;
56373
56398
  loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
56374
- const errText = await response.text().catch((err14) => castToError(err14).message);
56399
+ const errText = await response.text().catch((err15) => castToError(err15).message);
56375
56400
  const errJSON = safeJSON(errText);
56376
56401
  const errMessage = errJSON ? void 0 : errText;
56377
56402
  loggerFor(this).debug(`[${requestLogID}] response error (${retryMessage})`, formatRequestDetails({
@@ -56382,8 +56407,8 @@ var BaseAnthropic = class {
56382
56407
  message: errMessage,
56383
56408
  durationMs: Date.now() - startTime
56384
56409
  }));
56385
- const err13 = this.makeStatusError(response.status, errJSON, errMessage, response.headers);
56386
- throw err13;
56410
+ const err14 = this.makeStatusError(response.status, errJSON, errMessage, response.headers);
56411
+ throw err14;
56387
56412
  }
56388
56413
  loggerFor(this).info(responseInfo);
56389
56414
  loggerFor(this).debug(`[${requestLogID}] response start`, formatRequestDetails({
@@ -56395,8 +56420,8 @@ var BaseAnthropic = class {
56395
56420
  }));
56396
56421
  return { response, options, controller: controller2, requestLogID, retryOfRequestLogID, startTime };
56397
56422
  }
56398
- getAPIList(path14, Page2, opts) {
56399
- return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path14, ...opts2 })) : { method: "get", path: path14, ...opts });
56423
+ getAPIList(path16, Page2, opts) {
56424
+ return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path16, ...opts2 })) : { method: "get", path: path16, ...opts });
56400
56425
  }
56401
56426
  requestAPIList(Page2, options) {
56402
56427
  const request = this.makeRequest(options, null, void 0);
@@ -56484,8 +56509,8 @@ var BaseAnthropic = class {
56484
56509
  }
56485
56510
  async buildRequest(inputOptions, { retryCount = 0 } = {}) {
56486
56511
  const options = { ...inputOptions };
56487
- const { method, path: path14, query, defaultBaseURL } = options;
56488
- const url2 = this.buildURL(path14, query, defaultBaseURL);
56512
+ const { method, path: path16, query, defaultBaseURL } = options;
56513
+ const url2 = this.buildURL(path16, query, defaultBaseURL);
56489
56514
  if ("timeout" in options)
56490
56515
  validatePositiveInteger("timeout", options.timeout);
56491
56516
  options.timeout = options.timeout ?? this.timeout;
@@ -57720,7 +57745,7 @@ var directiveHandlers = {
57720
57745
  }
57721
57746
  try {
57722
57747
  prefix = decodeURIComponent(prefix);
57723
- } catch (err13) {
57748
+ } catch (err14) {
57724
57749
  throwError(state, "tag prefix is malformed: " + prefix);
57725
57750
  }
57726
57751
  state.tagMap[handle] = prefix;
@@ -58401,7 +58426,7 @@ function readTagProperty(state) {
58401
58426
  }
58402
58427
  try {
58403
58428
  tagName = decodeURIComponent(tagName);
58404
- } catch (err13) {
58429
+ } catch (err14) {
58405
58430
  throwError(state, "tag name is malformed: " + tagName);
58406
58431
  }
58407
58432
  if (isVerbatim) {
@@ -60740,9 +60765,8 @@ function resolveLastPath(argument, stateContent) {
60740
60765
  function lastPathFilePath(xqaDirectoryectory) {
60741
60766
  return import_node_path8.default.join(xqaDirectoryectory, "last-findings-path");
60742
60767
  }
60743
- function writeLastPath(xqaDirectory2, findingsPath) {
60744
- (0, import_node_fs4.mkdirSync)(xqaDirectory2, { recursive: true });
60745
- (0, import_node_fs4.writeFileSync)(lastPathFilePath(xqaDirectory2), findingsPath);
60768
+ function writeLastPath(xqaDirectory, findingsPath) {
60769
+ (0, import_node_fs4.writeFileSync)(lastPathFilePath(xqaDirectory), findingsPath);
60746
60770
  }
60747
60771
 
60748
60772
  // src/hints/exodus-navigation.ts
@@ -60820,13 +60844,18 @@ function buildExplorerConfig2(input, config3) {
60820
60844
  buildEnv: config3.QA_BUILD_ENV
60821
60845
  };
60822
60846
  }
60823
- function buildPipelineConfig({ input, config: config3, explorer }) {
60847
+ function buildPipelineConfig({
60848
+ input,
60849
+ config: config3,
60850
+ xqaDirectory,
60851
+ explorer
60852
+ }) {
60824
60853
  const base = {
60825
- outputDir: config3.QA_OUTPUT_DIR,
60854
+ outputDir: import_node_path9.default.join(xqaDirectory, "output"),
60826
60855
  runId: config3.QA_RUN_ID,
60827
60856
  onEvent: createConsoleObserver(input.verbose ? { verbose: true } : void 0),
60828
60857
  signal: input.signal,
60829
- inspector: { designsDirectory: config3.QA_DESIGNS_DIR },
60858
+ inspector: { designsDirectory: import_node_path9.default.join(xqaDirectory, "designs") },
60830
60859
  explorer
60831
60860
  };
60832
60861
  if (!config3.GOOGLE_GENERATIVE_AI_API_KEY) {
@@ -60843,35 +60872,58 @@ function buildSuccessMessage(output) {
60843
60872
  return `${base}${String(output.findings.length)} finding${output.findings.length === 1 ? "" : "s"} \u2014 run \`xqa review\` to triage.
60844
60873
  `;
60845
60874
  }
60846
- function runExploreCommand(input, config3) {
60847
- const explorerConfig = buildExplorerConfig2(input, config3);
60848
- if (explorerConfig === void 0) {
60849
- process.stderr.write("QA_STARTUP_STATE is restore-wallet but QA_WALLET_MNEMONIC is not set.\n");
60850
- process.exit(1);
60851
- return;
60852
- }
60853
- void runPipeline2(buildPipelineConfig({ input, config: config3, explorer: explorerConfig })).match(
60854
- (output) => {
60855
- writeLastPath(import_node_path9.default.join(process.cwd(), ".xqa"), output.findingsPath);
60875
+ function handlePipelineResult(input, xqaDirectory) {
60876
+ return {
60877
+ onSuccess: (output) => {
60878
+ writeLastPath(xqaDirectory, output.findingsPath);
60856
60879
  process.stdout.write(buildSuccessMessage(output));
60857
60880
  if (output.aborted) {
60858
60881
  process.exit(input.signal?.reason ?? DEFAULT_ABORT_EXIT_CODE);
60859
60882
  }
60860
60883
  process.exit(0);
60861
60884
  },
60862
- (error48) => {
60885
+ onError: (error48) => {
60863
60886
  const cause = error48.cause instanceof Error ? error48.cause.message : JSON.stringify(error48.cause);
60864
60887
  process.stderr.write(`Pipeline failed: ${error48.type}
60865
60888
  ${cause}
60866
60889
  `);
60867
60890
  process.exit(1);
60868
60891
  }
60869
- );
60892
+ };
60893
+ }
60894
+ function runExploreCommand(input, options) {
60895
+ const { config: config3, xqaDirectory } = options;
60896
+ const explorerConfig = buildExplorerConfig2(input, config3);
60897
+ if (explorerConfig === void 0) {
60898
+ process.stderr.write("QA_STARTUP_STATE is restore-wallet but QA_WALLET_MNEMONIC is not set.\n");
60899
+ process.exit(1);
60900
+ return;
60901
+ }
60902
+ const { onSuccess, onError } = handlePipelineResult(input, xqaDirectory);
60903
+ void runPipeline2(
60904
+ buildPipelineConfig({ input, config: config3, xqaDirectory, explorer: explorerConfig })
60905
+ ).match(onSuccess, onError);
60870
60906
  }
60871
60907
 
60872
- // src/commands/review-command.ts
60908
+ // src/commands/init-command.ts
60873
60909
  var import_node_fs5 = require("node:fs");
60874
- var import_node_path11 = __toESM(require("node:path"), 1);
60910
+ var import_node_path10 = __toESM(require("node:path"), 1);
60911
+ function runInitCommand() {
60912
+ const xqaDirectory = import_node_path10.default.join(process.cwd(), ".xqa");
60913
+ if ((0, import_node_fs5.existsSync)(xqaDirectory)) {
60914
+ process.stderr.write(`xqa already initialized: ${xqaDirectory}
60915
+ `);
60916
+ process.exit(1);
60917
+ return;
60918
+ }
60919
+ (0, import_node_fs5.mkdirSync)(xqaDirectory);
60920
+ process.stdout.write(`Initialized xqa project: ${xqaDirectory}
60921
+ `);
60922
+ }
60923
+
60924
+ // src/commands/review-command.ts
60925
+ var import_node_fs6 = require("node:fs");
60926
+ var import_node_path12 = __toESM(require("node:path"), 1);
60875
60927
  var import_neverthrow34 = __toESM(require_index_cjs(), 1);
60876
60928
 
60877
60929
  // ../../node_modules/.pnpm/@inquirer+core@10.3.2_@types+node@22.19.15/node_modules/@inquirer/core/dist/esm/lib/key.js
@@ -62210,7 +62262,7 @@ var esm_default2 = createPrompt((config3, done) => {
62210
62262
  var import_chardet = __toESM(require_lib2(), 1);
62211
62263
  var import_child_process3 = require("child_process");
62212
62264
  var import_fs3 = require("fs");
62213
- var import_node_path10 = __toESM(require("node:path"), 1);
62265
+ var import_node_path11 = __toESM(require("node:path"), 1);
62214
62266
  var import_node_os3 = __toESM(require("node:os"), 1);
62215
62267
  var import_node_crypto2 = require("node:crypto");
62216
62268
  var import_iconv_lite = __toESM(require_lib3(), 1);
@@ -62254,9 +62306,9 @@ var RemoveFileError = class extends Error {
62254
62306
  // ../../node_modules/.pnpm/@inquirer+external-editor@1.0.3_@types+node@22.19.15/node_modules/@inquirer/external-editor/dist/esm/index.js
62255
62307
  function editAsync(text = "", callback, fileOptions) {
62256
62308
  const editor = new ExternalEditor(text, fileOptions);
62257
- editor.runAsync((err13, result) => {
62258
- if (err13) {
62259
- setImmediate(callback, err13, void 0);
62309
+ editor.runAsync((err14, result) => {
62310
+ if (err14) {
62311
+ setImmediate(callback, err14, void 0);
62260
62312
  } else {
62261
62313
  try {
62262
62314
  editor.cleanup();
@@ -62346,8 +62398,8 @@ var ExternalEditor = class {
62346
62398
  const prefix = sanitizeAffix(this.fileOptions.prefix);
62347
62399
  const postfix = sanitizeAffix(this.fileOptions.postfix);
62348
62400
  const filename = `${prefix}${id}${postfix}`;
62349
- const candidate = import_node_path10.default.resolve(baseDir, filename);
62350
- const baseResolved = import_node_path10.default.resolve(baseDir) + import_node_path10.default.sep;
62401
+ const candidate = import_node_path11.default.resolve(baseDir, filename);
62402
+ const baseResolved = import_node_path11.default.resolve(baseDir) + import_node_path11.default.sep;
62351
62403
  if (!candidate.startsWith(baseResolved)) {
62352
62404
  throw new Error("Resolved temporary file escaped the base directory");
62353
62405
  }
@@ -63436,16 +63488,13 @@ var safeRunInteractiveLoop = (0, import_neverthrow33.fromAsyncThrowable)(
63436
63488
  );
63437
63489
 
63438
63490
  // src/commands/review-command.ts
63439
- var safeReadFile2 = (0, import_neverthrow34.fromThrowable)((filePath) => (0, import_node_fs5.readFileSync)(filePath, "utf8"));
63491
+ var safeReadFile2 = (0, import_neverthrow34.fromThrowable)((filePath) => (0, import_node_fs6.readFileSync)(filePath, "utf8"));
63440
63492
  var safeParseJson2 = (0, import_neverthrow34.fromThrowable)(JSON.parse);
63441
63493
  var safeWrite = (0, import_neverthrow34.fromThrowable)((filePath, content) => {
63442
- (0, import_node_fs5.writeFileSync)(filePath, content);
63494
+ (0, import_node_fs6.writeFileSync)(filePath, content);
63443
63495
  });
63444
- function xqaDirectory() {
63445
- return import_node_path11.default.join(process.cwd(), ".xqa");
63446
- }
63447
- function readLastPath() {
63448
- const result = safeReadFile2(lastPathFilePath(xqaDirectory()));
63496
+ function readLastPath(xqaDirectory) {
63497
+ const result = safeReadFile2(lastPathFilePath(xqaDirectory));
63449
63498
  return result.isOk() ? result.value : void 0;
63450
63499
  }
63451
63500
  function isPipelineOutput(data) {
@@ -63530,8 +63579,8 @@ function applyLoopResult({ result, findings, existing, dismissalsFilePath }) {
63530
63579
  totalFindings: findings.length
63531
63580
  });
63532
63581
  }
63533
- function resolveAndReadFindings(findingsPath) {
63534
- const resolvedPathResult = resolveLastPath(findingsPath, readLastPath());
63582
+ function resolveAndReadFindings(findingsPath, xqaDirectory) {
63583
+ const resolvedPathResult = resolveLastPath(findingsPath, readLastPath(xqaDirectory));
63535
63584
  if (resolvedPathResult.isErr()) {
63536
63585
  process.stderr.write(
63537
63586
  "No findings path provided and no last path found. Run: xqa review <findings-path>\n"
@@ -63567,35 +63616,44 @@ async function runReviewLoop({
63567
63616
  }
63568
63617
  applyLoopResult({ result: loopResult.value, findings, existing, dismissalsFilePath });
63569
63618
  }
63570
- async function runReviewCommand(findingsPath) {
63571
- if (!process.stdout.isTTY || !process.stdin.isTTY) {
63572
- process.stdout.write("Review requires an interactive terminal. Run locally after a CI run.\n");
63573
- process.exit(0);
63574
- return;
63575
- }
63576
- const readResult = resolveAndReadFindings(findingsPath);
63577
- if (readResult.isErr()) {
63578
- return;
63579
- }
63580
- const { resolvedPath, output } = readResult.value;
63581
- writeLastPath(xqaDirectory(), resolvedPath);
63619
+ async function executeReview({
63620
+ xqaDirectory,
63621
+ resolvedPath,
63622
+ output
63623
+ }) {
63624
+ writeLastPath(xqaDirectory, resolvedPath);
63582
63625
  const { findings } = output;
63583
63626
  if (findings.length === 0) {
63584
63627
  process.stdout.write("No findings to review.\n");
63585
63628
  process.exit(0);
63586
63629
  return;
63587
63630
  }
63588
- const dismissalsFilePath = dismissalsPath(process.cwd(), process.env.QA_DISMISSALS_PATH);
63631
+ const dismissalsFilePath = dismissalsPath(
63632
+ import_node_path12.default.dirname(xqaDirectory),
63633
+ process.env.QA_DISMISSALS_PATH
63634
+ );
63589
63635
  await runReviewLoop({
63590
63636
  findings,
63591
63637
  dismissalsFilePath,
63592
63638
  existing: loadExistingDismissals(dismissalsFilePath)
63593
63639
  });
63594
63640
  }
63641
+ async function runReviewCommand(findingsPath, xqaDirectory) {
63642
+ if (!process.stdout.isTTY || !process.stdin.isTTY) {
63643
+ process.stdout.write("Review requires an interactive terminal. Run locally after a CI run.\n");
63644
+ process.exit(0);
63645
+ return;
63646
+ }
63647
+ const readResult = resolveAndReadFindings(findingsPath, xqaDirectory);
63648
+ if (readResult.isErr()) {
63649
+ return;
63650
+ }
63651
+ await executeReview({ xqaDirectory, ...readResult.value });
63652
+ }
63595
63653
 
63596
63654
  // src/commands/spec-command.ts
63597
- var import_node_fs6 = require("node:fs");
63598
- var import_node_path13 = __toESM(require("node:path"), 1);
63655
+ var import_node_fs7 = require("node:fs");
63656
+ var import_node_path14 = __toESM(require("node:path"), 1);
63599
63657
  var import_neverthrow36 = __toESM(require_index_cjs(), 1);
63600
63658
 
63601
63659
  // src/spec-frontmatter.ts
@@ -63655,10 +63713,10 @@ function parseYamlFields(block) {
63655
63713
  }
63656
63714
 
63657
63715
  // src/spec-slug.ts
63658
- var import_node_path12 = __toESM(require("node:path"), 1);
63716
+ var import_node_path13 = __toESM(require("node:path"), 1);
63659
63717
  var SPECS_DIR = "specs";
63660
63718
  function deriveSpecSlug(specFilePath) {
63661
- const parts = specFilePath.split(import_node_path12.default.sep);
63719
+ const parts = specFilePath.split(import_node_path13.default.sep);
63662
63720
  const specsIndex = parts.lastIndexOf(SPECS_DIR);
63663
63721
  if (specsIndex !== -1) {
63664
63722
  const relativeParts = parts.slice(specsIndex + 1);
@@ -63666,14 +63724,14 @@ function deriveSpecSlug(specFilePath) {
63666
63724
  relativeParts[relativeParts.length - 1] = stripExtensions(last);
63667
63725
  return relativeParts.join("__");
63668
63726
  }
63669
- return stripExtensions(import_node_path12.default.basename(specFilePath));
63727
+ return stripExtensions(import_node_path13.default.basename(specFilePath));
63670
63728
  }
63671
63729
  function stripExtensions(filename) {
63672
63730
  return filename.replace(/\.test\.md$/, "").replace(/\.[^.]+$/, "");
63673
63731
  }
63674
63732
 
63675
63733
  // src/commands/spec-command.ts
63676
- var safeReadFile3 = (0, import_neverthrow36.fromThrowable)((filePath) => (0, import_node_fs6.readFileSync)(filePath, "utf8"));
63734
+ var safeReadFile3 = (0, import_neverthrow36.fromThrowable)((filePath) => (0, import_node_fs7.readFileSync)(filePath, "utf8"));
63677
63735
  function buildSpecExplorer(input, context) {
63678
63736
  return {
63679
63737
  mode: "spec",
@@ -63686,10 +63744,10 @@ function buildSpecExplorer(input, context) {
63686
63744
  }
63687
63745
  function buildPipelineConfig2(input, context) {
63688
63746
  return {
63689
- outputDir: import_node_path13.default.join(context.config.QA_OUTPUT_DIR, context.slug),
63747
+ outputDir: import_node_path14.default.join(context.xqaDirectory, "output", context.slug),
63690
63748
  signal: input.signal,
63691
63749
  onEvent: createConsoleObserver(input.verbose ? { verbose: true } : void 0),
63692
- inspector: { designsDirectory: context.config.QA_DESIGNS_DIR },
63750
+ inspector: { designsDirectory: import_node_path14.default.join(context.xqaDirectory, "designs") },
63693
63751
  explorer: buildSpecExplorer(input, context)
63694
63752
  };
63695
63753
  }
@@ -63721,34 +63779,42 @@ function buildSuccessMessage2(output) {
63721
63779
  return `${base}${String(output.findings.length)} finding${output.findings.length === 1 ? "" : "s"} \u2014 run \`xqa review\` to triage.
63722
63780
  `;
63723
63781
  }
63724
- async function runSpecCommand(input, config3) {
63725
- const absolutePath = import_node_path13.default.resolve(input.specFile);
63782
+ function handleSpecSuccess(xqaDirectory, output) {
63783
+ writeLastPath(xqaDirectory, output.findingsPath);
63784
+ process.stdout.write(buildSuccessMessage2(output));
63785
+ process.exit(0);
63786
+ }
63787
+ function handleSpecError(error48) {
63788
+ const cause = error48.cause instanceof Error ? error48.cause.message : JSON.stringify(error48.cause);
63789
+ process.stderr.write(`Pipeline failed: ${error48.type}
63790
+ ${cause}
63791
+ `);
63792
+ process.exit(1);
63793
+ }
63794
+ async function runSpecCommand(input, options) {
63795
+ const { config: config3, xqaDirectory } = options;
63796
+ const absolutePath = import_node_path14.default.resolve(input.specFile);
63726
63797
  const frontmatter = readAndParseSpec(absolutePath);
63727
63798
  if (frontmatter === void 0) {
63728
63799
  return;
63729
63800
  }
63730
63801
  const slug = deriveSpecSlug(absolutePath);
63731
63802
  const result = await runPipeline2(
63732
- buildPipelineConfig2(input, { config: config3, absolutePath, entry: frontmatter.entry, slug })
63733
- );
63734
- result.match(
63735
- (output) => {
63736
- writeLastPath(import_node_path13.default.join(process.cwd(), ".xqa"), output.findingsPath);
63737
- process.stdout.write(buildSuccessMessage2(output));
63738
- process.exit(0);
63739
- },
63740
- (error48) => {
63741
- const cause = error48.cause instanceof Error ? error48.cause.message : JSON.stringify(error48.cause);
63742
- process.stderr.write(`Pipeline failed: ${error48.type}
63743
- ${cause}
63744
- `);
63745
- process.exit(1);
63746
- }
63803
+ buildPipelineConfig2(input, {
63804
+ config: config3,
63805
+ xqaDirectory,
63806
+ absolutePath,
63807
+ entry: frontmatter.entry,
63808
+ slug
63809
+ })
63747
63810
  );
63811
+ result.match((output) => {
63812
+ handleSpecSuccess(xqaDirectory, output);
63813
+ }, handleSpecError);
63748
63814
  }
63749
63815
 
63750
63816
  // src/config.ts
63751
- var import_node_path14 = __toESM(require("node:path"), 1);
63817
+ var import_node_path15 = __toESM(require("node:path"), 1);
63752
63818
  var import_node_url = require("node:url");
63753
63819
  var import_dotenv = __toESM(require_main(), 1);
63754
63820
  var import_neverthrow37 = __toESM(require_index_cjs(), 1);
@@ -64231,8 +64297,8 @@ function getErrorMap2() {
64231
64297
 
64232
64298
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
64233
64299
  var makeIssue = (params) => {
64234
- const { data, path: path14, errorMaps, issueData } = params;
64235
- const fullPath = [...path14, ...issueData.path || []];
64300
+ const { data, path: path16, errorMaps, issueData } = params;
64301
+ const fullPath = [...path16, ...issueData.path || []];
64236
64302
  const fullIssue = {
64237
64303
  ...issueData,
64238
64304
  path: fullPath
@@ -64348,11 +64414,11 @@ var errorUtil;
64348
64414
 
64349
64415
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
64350
64416
  var ParseInputLazyPath = class {
64351
- constructor(parent, value, path14, key) {
64417
+ constructor(parent, value, path16, key) {
64352
64418
  this._cachedPath = [];
64353
64419
  this.parent = parent;
64354
64420
  this.data = value;
64355
- this._path = path14;
64421
+ this._path = path16;
64356
64422
  this._key = key;
64357
64423
  }
64358
64424
  get path() {
@@ -64491,8 +64557,8 @@ var ZodType2 = class {
64491
64557
  } : {
64492
64558
  issues: ctx.common.issues
64493
64559
  };
64494
- } catch (err13) {
64495
- if (err13?.message?.toLowerCase()?.includes("encountered")) {
64560
+ } catch (err14) {
64561
+ if (err14?.message?.toLowerCase()?.includes("encountered")) {
64496
64562
  this["~standard"].async = true;
64497
64563
  }
64498
64564
  ctx.common = {
@@ -67796,21 +67862,19 @@ var NEVER2 = INVALID;
67796
67862
 
67797
67863
  // src/config-schema.ts
67798
67864
  var configSchema = external_exports2.object({
67799
- ANTHROPIC_API_KEY: external_exports2.string().optional(),
67865
+ ANTHROPIC_API_KEY: external_exports2.string().min(1),
67800
67866
  GOOGLE_GENERATIVE_AI_API_KEY: external_exports2.string().optional(),
67801
- QA_OUTPUT_DIR: external_exports2.string().default("./.xqa/output"),
67802
67867
  QA_RUN_ID: external_exports2.string().optional(),
67803
67868
  QA_EXPLORE_TIMEOUT_SECONDS: external_exports2.coerce.number().int().positive().optional(),
67804
67869
  QA_WALLET_MNEMONIC: external_exports2.string().optional(),
67805
67870
  QA_BUILD_ENV: external_exports2.enum(["dev", "prod"]).default("prod"),
67806
- QA_STARTUP_STATE: external_exports2.enum(["portfolio", "new-wallet", "restore-wallet"]).optional(),
67807
- QA_DESIGNS_DIR: external_exports2.string().default("./.xqa/designs")
67871
+ QA_STARTUP_STATE: external_exports2.enum(["portfolio", "new-wallet", "restore-wallet"]).optional()
67808
67872
  });
67809
67873
 
67810
67874
  // src/config.ts
67811
- var packageDirectory = import_node_path14.default.dirname((0, import_node_url.fileURLToPath)(__importMetaUrl));
67875
+ var packageDirectory = import_node_path15.default.dirname((0, import_node_url.fileURLToPath)(__importMetaUrl));
67812
67876
  function loadConfig() {
67813
- (0, import_dotenv.config)({ path: import_node_path14.default.resolve(packageDirectory, "..", ".env.local") });
67877
+ (0, import_dotenv.config)({ path: import_node_path15.default.resolve(packageDirectory, "..", ".env.local") });
67814
67878
  const result = configSchema.safeParse(process.env);
67815
67879
  if (!result.success) {
67816
67880
  const messages = result.error.issues.map(
@@ -67823,7 +67887,7 @@ ${messages.join("\n")}` });
67823
67887
  }
67824
67888
 
67825
67889
  // src/pid-lock.ts
67826
- var import_node_fs7 = require("node:fs");
67890
+ var import_node_fs8 = require("node:fs");
67827
67891
  var import_neverthrow38 = __toESM(require_index_cjs(), 1);
67828
67892
  var PID_FILE = "/tmp/xqa.pid";
67829
67893
  var SIGINT_EXIT_CODE = 130;
@@ -67831,7 +67895,7 @@ var SIGTERM_EXIT_CODE = 143;
67831
67895
  var SIGHUP_EXIT_CODE = 129;
67832
67896
  var HARD_TIMEOUT_MS = 1e4;
67833
67897
  var cleanup = () => {
67834
- (0, import_node_fs7.rmSync)(PID_FILE, { force: true });
67898
+ (0, import_node_fs8.rmSync)(PID_FILE, { force: true });
67835
67899
  };
67836
67900
  var checkProcessRunning = (0, import_neverthrow38.fromThrowable)(
67837
67901
  (pid) => {
@@ -67841,10 +67905,10 @@ var checkProcessRunning = (0, import_neverthrow38.fromThrowable)(
67841
67905
  (cause) => cause
67842
67906
  );
67843
67907
  function checkExistingLock() {
67844
- if (!(0, import_node_fs7.existsSync)(PID_FILE)) {
67908
+ if (!(0, import_node_fs8.existsSync)(PID_FILE)) {
67845
67909
  return;
67846
67910
  }
67847
- const existingPid = Number.parseInt((0, import_node_fs7.readFileSync)(PID_FILE, "utf8").trim(), 10);
67911
+ const existingPid = Number.parseInt((0, import_node_fs8.readFileSync)(PID_FILE, "utf8").trim(), 10);
67848
67912
  const running = checkProcessRunning(existingPid);
67849
67913
  if (running.isOk() || running.error.code !== "ESRCH") {
67850
67914
  process.stderr.write(
@@ -67890,12 +67954,31 @@ function registerSignalHandlers(controller2) {
67890
67954
  }
67891
67955
  function acquireLock() {
67892
67956
  checkExistingLock();
67893
- (0, import_node_fs7.writeFileSync)(PID_FILE, String(process.pid));
67957
+ (0, import_node_fs8.writeFileSync)(PID_FILE, String(process.pid));
67894
67958
  const controller2 = new AbortController();
67895
67959
  registerSignalHandlers(controller2);
67896
67960
  return controller2;
67897
67961
  }
67898
67962
 
67963
+ // src/shell/xqa-directory.ts
67964
+ var import_node_fs9 = require("node:fs");
67965
+ var import_node_path16 = __toESM(require("node:path"), 1);
67966
+ var import_neverthrow39 = __toESM(require_index_cjs(), 1);
67967
+ function findXqaDirectory(startDirectory) {
67968
+ let current = startDirectory;
67969
+ for (; ; ) {
67970
+ const candidate = import_node_path16.default.join(current, ".xqa");
67971
+ if ((0, import_node_fs9.existsSync)(candidate)) {
67972
+ return (0, import_neverthrow39.ok)(candidate);
67973
+ }
67974
+ const parent = import_node_path16.default.dirname(current);
67975
+ if (parent === current) {
67976
+ return (0, import_neverthrow39.err)({ type: "XQA_NOT_INITIALIZED" });
67977
+ }
67978
+ current = parent;
67979
+ }
67980
+ }
67981
+
67899
67982
  // src/index.ts
67900
67983
  process.title = "xqa";
67901
67984
  var controller = acquireLock();
@@ -67905,10 +67988,25 @@ if (configResult.isErr()) {
67905
67988
  process.exit(1);
67906
67989
  }
67907
67990
  var config2 = configResult.value;
67991
+ function resolveXqaDirectory() {
67992
+ const result = findXqaDirectory(process.cwd());
67993
+ if (result.isErr()) {
67994
+ process.stderr.write("Not in an xqa project. Run `xqa init` to initialize.\n");
67995
+ process.exit(1);
67996
+ }
67997
+ return result.value;
67998
+ }
67908
67999
  var program2 = new Command();
67909
68000
  program2.name("xqa").description("AI-powered QA agent CLI");
68001
+ program2.command("init").description("Initialize a new xqa project in the current directory").action(() => {
68002
+ runInitCommand();
68003
+ });
67910
68004
  program2.command("explore").description("Run the explorer agent; omit prompt for a full breadth-first sweep").argument("[prompt]", "Optional focus hint for the explorer; omit for a full breadth-first sweep").option("--verbose", "Log tool call results").action((prompt, options) => {
67911
- runExploreCommand({ prompt, verbose: options.verbose, signal: controller.signal }, config2);
68005
+ const xqaDirectory = resolveXqaDirectory();
68006
+ runExploreCommand(
68007
+ { prompt, verbose: options.verbose, signal: controller.signal },
68008
+ { config: config2, xqaDirectory }
68009
+ );
67912
68010
  });
67913
68011
  program2.command("analyse").description("Analyse a session recording with Gemini").argument("[video-path]", "Path to video file").action((videoPath) => {
67914
68012
  void runAnalyseCommand(videoPath, config2);
@@ -67917,12 +68015,14 @@ program2.command("completion").description("Output shell completion script").arg
67917
68015
  runCompletionCommand(program2, shell);
67918
68016
  });
67919
68017
  program2.command("review").description("Review findings and mark false positives").argument("[findings-path]", "Path to the findings JSON file; defaults to last used path").action((findingsPath) => {
67920
- void runReviewCommand(findingsPath);
68018
+ const xqaDirectory = resolveXqaDirectory();
68019
+ void runReviewCommand(findingsPath, xqaDirectory);
67921
68020
  });
67922
68021
  program2.command("spec").description("Run the explorer agent against a spec file").argument("<spec-file>", "Path to the spec markdown file").option("--verbose", "Log tool call results").action((specFile, options) => {
68022
+ const xqaDirectory = resolveXqaDirectory();
67923
68023
  void runSpecCommand(
67924
68024
  { specFile, verbose: options.verbose ?? false, signal: controller.signal },
67925
- config2
68025
+ { config: config2, xqaDirectory }
67926
68026
  );
67927
68027
  });
67928
68028
  void program2.parseAsync(process.argv);