@swmansion/argent 0.16.1 → 0.16.2-next.1

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/cli-cmds.mjs CHANGED
@@ -204,7 +204,7 @@ function generateAuthToken() {
204
204
  return generateToken();
205
205
  }
206
206
  function findFreePort() {
207
- return new Promise((resolve6, reject) => {
207
+ return new Promise((resolve7, reject) => {
208
208
  const srv = net.createServer();
209
209
  srv.listen(0, "127.0.0.1", () => {
210
210
  const addr = srv.address();
@@ -215,7 +215,7 @@ function findFreePort() {
215
215
  const port = addr.port;
216
216
  srv.close((err) => {
217
217
  if (err) reject(err);
218
- else resolve6(port);
218
+ else resolve7(port);
219
219
  });
220
220
  });
221
221
  srv.on("error", reject);
@@ -316,7 +316,7 @@ function killSpawnedChild(child, pid) {
316
316
  }
317
317
  }
318
318
  function spawnToolsServer(paths, port, options = {}) {
319
- return new Promise((resolve6, reject) => {
319
+ return new Promise((resolve7, reject) => {
320
320
  let logFd;
321
321
  try {
322
322
  fs.mkdirSync(STATE_DIR, { recursive: true });
@@ -353,7 +353,7 @@ function spawnToolsServer(paths, port, options = {}) {
353
353
  rl.close();
354
354
  child.stdout?.resume();
355
355
  child.stdout?.unref?.();
356
- settle(() => resolve6({ port: actualPort, pid }));
356
+ settle(() => resolve7({ port: actualPort, pid }));
357
357
  }
358
358
  });
359
359
  child.on("error", (err) => {
@@ -742,8 +742,8 @@ function parseLinkTarget(input) {
742
742
  const host = u3.hostname.startsWith("[") ? u3.hostname.slice(1, -1) : u3.hostname;
743
743
  if (!host) throw new Error(`URL "${input}" is missing a host.`);
744
744
  const port = u3.port ? Number(u3.port) : u3.protocol === "https:" ? 443 : 80;
745
- const path14 = u3.pathname === "/" ? "" : u3.pathname.replace(/\/+$/, "");
746
- const url = `${u3.protocol}//${u3.host}${path14}`;
745
+ const path15 = u3.pathname === "/" ? "" : u3.pathname.replace(/\/+$/, "");
746
+ const url = `${u3.protocol}//${u3.host}${path15}`;
747
747
  const token = u3.username ? decodeURIComponent(u3.username) : void 0;
748
748
  return { url, host, port, ...token ? { token } : {} };
749
749
  }
@@ -879,9 +879,9 @@ async function tarball(sourcePath) {
879
879
  return tarPath;
880
880
  }
881
881
  function sha256File(filePath) {
882
- return new Promise((resolve6, reject) => {
882
+ return new Promise((resolve7, reject) => {
883
883
  const hash = createHash2("sha256");
884
- createReadStream(filePath).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve6(hash.digest("hex"))).on("error", reject);
884
+ createReadStream(filePath).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve7(hash.digest("hex"))).on("error", reject);
885
885
  });
886
886
  }
887
887
  async function uploadTar(tarPath, endpoint) {
@@ -1254,8 +1254,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname4(proce
1254
1254
  return decodedFile;
1255
1255
  };
1256
1256
  }
1257
- function normalizeWindowsPath(path14) {
1258
- return path14.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
1257
+ function normalizeWindowsPath(path15) {
1258
+ return path15.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
1259
1259
  }
1260
1260
 
1261
1261
  // ../../node_modules/@posthog/core/dist/featureFlagUtils.mjs
@@ -2889,13 +2889,13 @@ var DEFAULT_EXCEPTION_STEPS_CONFIG = {
2889
2889
  enabled: true,
2890
2890
  max_bytes: 32768
2891
2891
  };
2892
- function resolveExceptionStepsConfig(config) {
2893
- if (!config) return {
2892
+ function resolveExceptionStepsConfig(config2) {
2893
+ if (!config2) return {
2894
2894
  ...DEFAULT_EXCEPTION_STEPS_CONFIG
2895
2895
  };
2896
2896
  return {
2897
- enabled: config.enabled ?? DEFAULT_EXCEPTION_STEPS_CONFIG.enabled,
2898
- max_bytes: normalizePositiveInteger(config.max_bytes, DEFAULT_EXCEPTION_STEPS_CONFIG.max_bytes)
2897
+ enabled: config2.enabled ?? DEFAULT_EXCEPTION_STEPS_CONFIG.enabled,
2898
+ max_bytes: normalizePositiveInteger(config2.max_bytes, DEFAULT_EXCEPTION_STEPS_CONFIG.max_bytes)
2899
2899
  };
2900
2900
  }
2901
2901
  function stripReservedExceptionStepFields(properties) {
@@ -2918,13 +2918,13 @@ function stripReservedExceptionStepFields(properties) {
2918
2918
  };
2919
2919
  }
2920
2920
  var ExceptionStepsBuffer = class {
2921
- constructor(config) {
2921
+ constructor(config2) {
2922
2922
  this._entries = [];
2923
2923
  this._totalBytes = 0;
2924
- this._config = resolveExceptionStepsConfig(config);
2924
+ this._config = resolveExceptionStepsConfig(config2);
2925
2925
  }
2926
- setConfig(config) {
2927
- this._config = resolveExceptionStepsConfig(config);
2926
+ setConfig(config2) {
2927
+ this._config = resolveExceptionStepsConfig(config2);
2928
2928
  this._trimToMaxBytes();
2929
2929
  }
2930
2930
  add(step) {
@@ -3807,15 +3807,15 @@ async function addSourceContext(frames) {
3807
3807
  LRU_FILE_CONTENTS_CACHE.reduce();
3808
3808
  return frames;
3809
3809
  }
3810
- function getContextLinesFromFile(path14, ranges, output) {
3811
- return new Promise((resolve6) => {
3812
- const stream = createReadStream2(path14);
3810
+ function getContextLinesFromFile(path15, ranges, output) {
3811
+ return new Promise((resolve7) => {
3812
+ const stream = createReadStream2(path15);
3813
3813
  const lineReaded = createInterface2({
3814
3814
  input: stream
3815
3815
  });
3816
3816
  function destroyStreamAndResolve() {
3817
3817
  stream.destroy();
3818
- resolve6();
3818
+ resolve7();
3819
3819
  }
3820
3820
  let lineNumber = 0;
3821
3821
  let currentRangeIndex = 0;
@@ -3824,7 +3824,7 @@ function getContextLinesFromFile(path14, ranges, output) {
3824
3824
  let rangeStart = range[0];
3825
3825
  let rangeEnd = range[1];
3826
3826
  function onStreamError() {
3827
- LRU_FILE_CONTENTS_FS_READ_FAILED.set(path14, 1);
3827
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(path15, 1);
3828
3828
  lineReaded.close();
3829
3829
  lineReaded.removeAllListeners();
3830
3830
  destroyStreamAndResolve();
@@ -3885,8 +3885,8 @@ function clearLineContext(frame) {
3885
3885
  delete frame.context_line;
3886
3886
  delete frame.post_context;
3887
3887
  }
3888
- function shouldSkipContextLinesForFile(path14) {
3889
- return path14.startsWith("node:") || path14.endsWith(".min.js") || path14.endsWith(".min.cjs") || path14.endsWith(".min.mjs") || path14.startsWith("data:");
3888
+ function shouldSkipContextLinesForFile(path15) {
3889
+ return path15.startsWith("node:") || path15.endsWith(".min.js") || path15.endsWith(".min.cjs") || path15.endsWith(".min.mjs") || path15.startsWith("data:");
3890
3890
  }
3891
3891
  function shouldSkipContextLinesForFrame(frame) {
3892
3892
  if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
@@ -5112,9 +5112,9 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
5112
5112
  if (!waitUntil) return;
5113
5113
  if (this.disabled || this.optedOut) return;
5114
5114
  if (!this._waitUntilCycle) {
5115
- let resolve6;
5115
+ let resolve7;
5116
5116
  const promise = new Promise((r2) => {
5117
- resolve6 = r2;
5117
+ resolve7 = r2;
5118
5118
  });
5119
5119
  try {
5120
5120
  waitUntil(promise);
@@ -5122,7 +5122,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
5122
5122
  return;
5123
5123
  }
5124
5124
  this._waitUntilCycle = {
5125
- resolve: resolve6,
5125
+ resolve: resolve7,
5126
5126
  startedAt: Date.now(),
5127
5127
  timer: void 0
5128
5128
  };
@@ -5146,12 +5146,12 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
5146
5146
  return cycle?.resolve;
5147
5147
  }
5148
5148
  async resolveWaitUntilFlush() {
5149
- const resolve6 = this._consumeWaitUntilCycle();
5149
+ const resolve7 = this._consumeWaitUntilCycle();
5150
5150
  try {
5151
5151
  await super.flush();
5152
5152
  } catch {
5153
5153
  } finally {
5154
- resolve6?.();
5154
+ resolve7?.();
5155
5155
  }
5156
5156
  }
5157
5157
  getPersistedProperty(key) {
@@ -5272,15 +5272,15 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
5272
5272
  async waitForLocalEvaluationReady(timeoutMs = THIRTY_SECONDS) {
5273
5273
  if (this.isLocalEvaluationReady()) return true;
5274
5274
  if (void 0 === this.featureFlagsPoller) return false;
5275
- return new Promise((resolve6) => {
5275
+ return new Promise((resolve7) => {
5276
5276
  const timeout = setTimeout(() => {
5277
5277
  cleanup();
5278
- resolve6(false);
5278
+ resolve7(false);
5279
5279
  }, timeoutMs);
5280
5280
  const cleanup = this._events.on("localEvaluationFlagsLoaded", (count) => {
5281
5281
  clearTimeout(timeout);
5282
5282
  cleanup();
5283
- resolve6(count > 0);
5283
+ resolve7(count > 0);
5284
5284
  });
5285
5285
  });
5286
5286
  }
@@ -5735,14 +5735,14 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
5735
5735
  this.context?.enter(data, options);
5736
5736
  }
5737
5737
  async _shutdown(shutdownTimeoutMs) {
5738
- const resolve6 = this._consumeWaitUntilCycle();
5738
+ const resolve7 = this._consumeWaitUntilCycle();
5739
5739
  await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
5740
5740
  this.errorTracking.shutdown();
5741
5741
  try {
5742
5742
  return await super._shutdown(shutdownTimeoutMs);
5743
5743
  } finally {
5744
5744
  this.distinctIdHasSentFlagCalls = {};
5745
- resolve6?.();
5745
+ resolve7?.();
5746
5746
  }
5747
5747
  }
5748
5748
  async _requestRemoteConfigPayload(flagKey) {
@@ -6090,8 +6090,8 @@ function resolveConfig() {
6090
6090
  var client;
6091
6091
  function getClient() {
6092
6092
  if (client !== void 0) return client;
6093
- const config = resolveConfig();
6094
- if (!config.isUsable) {
6093
+ const config2 = resolveConfig();
6094
+ if (!config2.isUsable) {
6095
6095
  client = null;
6096
6096
  return null;
6097
6097
  }
@@ -6104,7 +6104,7 @@ function getClient() {
6104
6104
  fetchRetryCount: 0
6105
6105
  };
6106
6106
  try {
6107
- client = new PostHog(config.key, opts);
6107
+ client = new PostHog(config2.key, opts);
6108
6108
  } catch {
6109
6109
  client = null;
6110
6110
  return null;
@@ -6711,9 +6711,9 @@ function isReplitAgent(env) {
6711
6711
  }
6712
6712
  var DEVIN_MARKER_PATH = "/opt/.devin";
6713
6713
  var JULES_MARKER_PATH = "/opt/environment_summary.sh";
6714
- function safeExists(fileExists, path14) {
6714
+ function safeExists(fileExists, path15) {
6715
6715
  try {
6716
- return fileExists(path14);
6716
+ return fileExists(path15);
6717
6717
  } catch {
6718
6718
  return false;
6719
6719
  }
@@ -7200,18 +7200,20 @@ function getFlagDefinition(name, registry = FLAG_REGISTRY) {
7200
7200
  return registry.find((def) => def.name === name);
7201
7201
  }
7202
7202
  var PROJECT_MARKERS = [".argent", ".git", "package.json"];
7203
- function resolveProjectRoot(startDir) {
7204
- const initial = path4.resolve(startDir);
7205
- let current = initial;
7203
+ function findProjectRoot(startDir) {
7204
+ let current = path4.resolve(startDir);
7206
7205
  while (true) {
7207
7206
  for (const marker of PROJECT_MARKERS) {
7208
7207
  if (fs2.existsSync(path4.join(current, marker))) return current;
7209
7208
  }
7210
7209
  const parent = path4.dirname(current);
7211
- if (parent === current) return initial;
7210
+ if (parent === current) return null;
7212
7211
  current = parent;
7213
7212
  }
7214
7213
  }
7214
+ function resolveProjectRoot(startDir) {
7215
+ return findProjectRoot(startDir) ?? path4.resolve(startDir);
7216
+ }
7215
7217
  function getFlagsPath(scope, options = {}) {
7216
7218
  const home = options.homeDir ?? homedir3();
7217
7219
  if (scope === "global") {
@@ -7296,33 +7298,91 @@ function argentHomeDir() {
7296
7298
  const home = process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
7297
7299
  return path5.join(home, ".argent");
7298
7300
  }
7299
- function configFilePath() {
7300
- return path5.join(argentHomeDir(), "config.json");
7301
+ function configDir(scope = "global", options = {}) {
7302
+ if (scope === "global") {
7303
+ return options.homeDir ? path5.join(options.homeDir, ".argent") : argentHomeDir();
7304
+ }
7305
+ const cwd = options.cwd ?? process.cwd();
7306
+ return path5.join(resolveProjectRoot(cwd), ".argent");
7307
+ }
7308
+ function configFilePath(scope = "global", options = {}) {
7309
+ return path5.join(configDir(scope, options), "config.json");
7301
7310
  }
7302
7311
 
7303
7312
  // ../configuration-core/src/config.ts
7304
7313
  import * as crypto from "node:crypto";
7305
7314
  import * as fs3 from "node:fs";
7306
7315
  import * as path6 from "node:path";
7307
- function readConfigObject() {
7316
+ function readConfigObject(scope = "global", options = {}) {
7308
7317
  try {
7309
- const raw = fs3.readFileSync(configFilePath(), "utf8");
7318
+ const raw = fs3.readFileSync(configFilePath(scope, options), "utf8");
7310
7319
  const json = JSON.parse(raw);
7311
- if (json && typeof json === "object") {
7320
+ if (json && typeof json === "object" && !Array.isArray(json)) {
7312
7321
  return json;
7313
7322
  }
7314
7323
  } catch {
7315
7324
  }
7316
7325
  return {};
7317
7326
  }
7327
+ var FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
7328
+ function splitKey(dottedKey) {
7329
+ const parts = dottedKey.split(".");
7330
+ if (parts.length === 0 || parts.some((p) => p === "")) {
7331
+ throw new Error(`Invalid config key "${dottedKey}": empty path segment`);
7332
+ }
7333
+ for (const p of parts) {
7334
+ if (FORBIDDEN_SEGMENTS.has(p)) {
7335
+ throw new Error(`Invalid config key "${dottedKey}": forbidden segment "${p}"`);
7336
+ }
7337
+ }
7338
+ return parts;
7339
+ }
7340
+ function isPlainObject2(value) {
7341
+ return !!value && typeof value === "object" && !Array.isArray(value);
7342
+ }
7343
+ function getAtPath(obj, dottedKey) {
7344
+ const parts = splitKey(dottedKey);
7345
+ let cur = obj;
7346
+ for (const part of parts) {
7347
+ if (!isPlainObject2(cur)) return void 0;
7348
+ cur = cur[part];
7349
+ }
7350
+ return cur;
7351
+ }
7352
+ function setAtPath(obj, dottedKey, value) {
7353
+ const parts = splitKey(dottedKey);
7354
+ let cur = obj;
7355
+ for (let i2 = 0; i2 < parts.length - 1; i2++) {
7356
+ const part = parts[i2];
7357
+ const next = cur[part];
7358
+ if (!isPlainObject2(next)) {
7359
+ cur[part] = {};
7360
+ }
7361
+ cur = cur[part];
7362
+ }
7363
+ cur[parts[parts.length - 1]] = value;
7364
+ }
7365
+ function deleteAtPath(obj, dottedKey) {
7366
+ const parts = splitKey(dottedKey);
7367
+ let cur = obj;
7368
+ for (let i2 = 0; i2 < parts.length - 1; i2++) {
7369
+ const next = cur[parts[i2]];
7370
+ if (!isPlainObject2(next)) return false;
7371
+ cur = next;
7372
+ }
7373
+ const leaf = parts[parts.length - 1];
7374
+ if (!Object.hasOwn(cur, leaf)) return false;
7375
+ delete cur[leaf];
7376
+ return true;
7377
+ }
7318
7378
  var LOCK_STALE_MS2 = 1e4;
7319
7379
  var LOCK_MAX_WAIT_MS = 2e3;
7320
7380
  var LOCK_RETRY_MS = 25;
7321
7381
  function sleepSync(ms) {
7322
7382
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
7323
7383
  }
7324
- function acquireConfigLock() {
7325
- const lockPath = configFilePath() + ".lock";
7384
+ function acquireConfigLock(finalPath) {
7385
+ const lockPath = finalPath + ".lock";
7326
7386
  const deadline = Date.now() + LOCK_MAX_WAIT_MS;
7327
7387
  for (; ; ) {
7328
7388
  try {
@@ -7357,14 +7417,15 @@ function releaseConfigLock(lock) {
7357
7417
  } catch {
7358
7418
  }
7359
7419
  }
7360
- function updateConfig(mutate) {
7361
- fs3.mkdirSync(argentHomeDir(), { recursive: true });
7362
- const lock = acquireConfigLock();
7420
+ function updateConfig(mutate, scope = "global", options = {}) {
7421
+ const dir = configDir(scope, options);
7422
+ fs3.mkdirSync(dir, { recursive: true });
7423
+ const finalPath = configFilePath(scope, options);
7424
+ const lock = acquireConfigLock(finalPath);
7363
7425
  try {
7364
- const next = readConfigObject();
7426
+ const next = readConfigObject(scope, options);
7365
7427
  mutate(next);
7366
- const finalPath = configFilePath();
7367
- const tmpPath = path6.join(argentHomeDir(), `.config.tmp.${process.pid}.${crypto.randomUUID()}`);
7428
+ const tmpPath = path6.join(dir, `.config.tmp.${process.pid}.${crypto.randomUUID()}`);
7368
7429
  const fd = fs3.openSync(tmpPath, "wx", 384);
7369
7430
  try {
7370
7431
  fs3.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
@@ -7385,27 +7446,215 @@ function updateConfig(mutate) {
7385
7446
  if (lock) releaseConfigLock(lock);
7386
7447
  }
7387
7448
  }
7388
- function readLensConfig() {
7389
- const lens2 = readConfigObject().lens;
7390
- return lens2 && typeof lens2 === "object" ? lens2 : {};
7449
+
7450
+ // ../configuration-core/src/merge.ts
7451
+ function mergeRestrictive(local, global2) {
7452
+ if (local === void 0) return global2;
7453
+ if (global2 === void 0) return local;
7454
+ if (typeof local === "boolean" && typeof global2 === "boolean") {
7455
+ return local && global2;
7456
+ }
7457
+ if (typeof local === "number" && typeof global2 === "number") {
7458
+ return Math.min(local, global2);
7459
+ }
7460
+ return local;
7461
+ }
7462
+ function toArray(value) {
7463
+ return Array.isArray(value) ? value : null;
7464
+ }
7465
+ function mergeUnion(local, global2) {
7466
+ const l2 = toArray(local);
7467
+ const g = toArray(global2);
7468
+ if (l2 === null && g === null) return local ?? global2;
7469
+ const merged = [...g ?? [], ...l2 ?? []];
7470
+ return Array.from(new Set(merged));
7471
+ }
7472
+ function mergeIntersection(local, global2) {
7473
+ const l2 = toArray(local);
7474
+ const g = toArray(global2);
7475
+ if (l2 === null && g === null) return local ?? global2;
7476
+ if (l2 === null) return global2;
7477
+ if (g === null) return local;
7478
+ const globalSet = new Set(g);
7479
+ return l2.filter((item) => globalSet.has(item));
7480
+ }
7481
+ function applyMergePolicy(policy, local, global2) {
7482
+ if (typeof policy === "function") return policy({ local, global: global2 });
7483
+ switch (policy) {
7484
+ case "prioritize-local":
7485
+ return local ?? global2;
7486
+ case "prioritize-global":
7487
+ return global2 ?? local;
7488
+ case "prioritize-restrictive":
7489
+ return mergeRestrictive(local, global2);
7490
+ case "union":
7491
+ return mergeUnion(local, global2);
7492
+ case "intersection":
7493
+ return mergeIntersection(local, global2);
7494
+ default: {
7495
+ const _exhaustive = policy;
7496
+ return _exhaustive;
7497
+ }
7498
+ }
7499
+ }
7500
+
7501
+ // ../configuration-core/src/config-schema.ts
7502
+ function asBoolean(raw) {
7503
+ return typeof raw === "boolean" ? raw : void 0;
7504
+ }
7505
+ function asString(raw) {
7506
+ if (typeof raw !== "string") return void 0;
7507
+ const trimmed = raw.trim();
7508
+ return trimmed === "" ? void 0 : trimmed;
7391
7509
  }
7392
- function getRememberedAgent() {
7393
- const agent = readLensConfig().agent;
7394
- return typeof agent === "string" && agent.trim() ? agent : null;
7510
+ var CONFIG_SCHEMA = [
7511
+ {
7512
+ key: "telemetry.enabled",
7513
+ description: "Whether anonymous opt-out telemetry is enabled (on by default; environment opt-outs like DO_NOT_TRACK are not reflected here \u2014 `argent telemetry status` shows effective consent).",
7514
+ scopes: ["global"],
7515
+ parse: asBoolean,
7516
+ // A committed project file must never re-enable telemetry a user disabled
7517
+ // globally, so the more-restrictive (opt-out) value always wins.
7518
+ merge: "prioritize-restrictive",
7519
+ // Telemetry is opt-out: with nothing stored, consent.ts treats it as
7520
+ // enabled, and the config surface must report the same instead of "(unset)".
7521
+ default: true,
7522
+ // Read-only under `argent config`: opt-in/out goes through the dedicated
7523
+ // command so the live client is drained/reset, not just the file rewritten.
7524
+ manageCommand: "argent telemetry"
7525
+ },
7526
+ {
7527
+ key: "lens.agent",
7528
+ description: "Coding-agent id remembered by `argent lens` to skip the picker.",
7529
+ scopes: ["project", "global"],
7530
+ parse: asString,
7531
+ // A repo can pin the agent its screenshots should use; falls back to the
7532
+ // user's global remembered choice.
7533
+ merge: "prioritize-local",
7534
+ example: "claude"
7535
+ }
7536
+ ];
7537
+ function getConfigDefinition(key, registry = CONFIG_SCHEMA) {
7538
+ return registry.find((def) => def.key === key);
7395
7539
  }
7396
- function setRememberedAgent(agentId) {
7397
- updateConfig((config) => {
7398
- const lens2 = config.lens && typeof config.lens === "object" ? config.lens : {};
7399
- lens2.agent = agentId;
7400
- config.lens = lens2;
7401
- });
7540
+
7541
+ // ../configuration-core/src/config-access.ts
7542
+ function readScopeValue(def, scope, options) {
7543
+ if (!def.scopes.includes(scope)) return void 0;
7544
+ const raw = getAtPath(readConfigObject(scope, options), def.key);
7545
+ return raw === void 0 ? void 0 : def.parse(raw);
7402
7546
  }
7403
- function clearRememberedAgent() {
7404
- updateConfig((config) => {
7405
- if (config.lens && typeof config.lens === "object") {
7406
- delete config.lens.agent;
7407
- }
7408
- });
7547
+ function getConfigValue(def, options = {}) {
7548
+ const local = readScopeValue(def, "project", options);
7549
+ const global2 = readScopeValue(def, "global", options);
7550
+ const merged = applyMergePolicy(def.merge, local, global2);
7551
+ return merged ?? def.default;
7552
+ }
7553
+ function getConfigValueAtScope(key, scope, options = {}, registry = CONFIG_SCHEMA) {
7554
+ const def = requireDefinition(key, registry);
7555
+ return readScopeValue(def, scope, options);
7556
+ }
7557
+ function getConfigValueByKey(key, options = {}, registry = CONFIG_SCHEMA) {
7558
+ const def = requireDefinition(key, registry);
7559
+ return getConfigValue(def, options);
7560
+ }
7561
+ function requireDefinition(key, registry = CONFIG_SCHEMA) {
7562
+ const def = getConfigDefinition(key, registry);
7563
+ if (!def) {
7564
+ throw new UnknownConfigKeyError(key);
7565
+ }
7566
+ return def;
7567
+ }
7568
+ var UnknownConfigKeyError = class extends Error {
7569
+ constructor(key) {
7570
+ super(`Unknown configuration key "${key}".`);
7571
+ this.key = key;
7572
+ this.name = "UnknownConfigKeyError";
7573
+ }
7574
+ key;
7575
+ };
7576
+ var ConfigScopeError = class extends Error {
7577
+ constructor(key, scope, allowed) {
7578
+ super(`Config key "${key}" cannot be set at ${scope} scope (allowed: ${allowed.join(", ")}).`);
7579
+ this.key = key;
7580
+ this.scope = scope;
7581
+ this.allowed = allowed;
7582
+ this.name = "ConfigScopeError";
7583
+ }
7584
+ key;
7585
+ scope;
7586
+ allowed;
7587
+ };
7588
+ var ConfigValidationError = class extends Error {
7589
+ constructor(key) {
7590
+ super(`Invalid value for config key "${key}".`);
7591
+ this.key = key;
7592
+ this.name = "ConfigValidationError";
7593
+ }
7594
+ key;
7595
+ };
7596
+ var ConfigManagedElsewhereError = class extends Error {
7597
+ constructor(key, command) {
7598
+ super(`Config key "${key}" is managed by \`${command}\`.`);
7599
+ this.key = key;
7600
+ this.command = command;
7601
+ this.name = "ConfigManagedElsewhereError";
7602
+ }
7603
+ key;
7604
+ command;
7605
+ };
7606
+ function setConfigValue(key, rawValue, scope = "global", options = {}, registry = CONFIG_SCHEMA) {
7607
+ const def = requireDefinition(key, registry);
7608
+ if (def.manageCommand) throw new ConfigManagedElsewhereError(key, def.manageCommand);
7609
+ if (!def.scopes.includes(scope)) throw new ConfigScopeError(key, scope, def.scopes);
7610
+ const parsed = def.parse(rawValue);
7611
+ if (parsed === void 0) throw new ConfigValidationError(key);
7612
+ updateConfig((config2) => setAtPath(config2, key, parsed), scope, options);
7613
+ return parsed;
7614
+ }
7615
+ function unsetConfigValue(key, scope = "global", options = {}, registry = CONFIG_SCHEMA) {
7616
+ const def = requireDefinition(key, registry);
7617
+ if (def.manageCommand) throw new ConfigManagedElsewhereError(key, def.manageCommand);
7618
+ if (!def.scopes.includes(scope)) throw new ConfigScopeError(key, scope, def.scopes);
7619
+ if (getAtPath(readConfigObject(scope, options), key) === void 0) return false;
7620
+ let removed = false;
7621
+ updateConfig(
7622
+ (config2) => {
7623
+ removed = deleteAtPath(config2, key);
7624
+ },
7625
+ scope,
7626
+ options
7627
+ );
7628
+ return removed;
7629
+ }
7630
+ function listConfig(options = {}, registry = CONFIG_SCHEMA) {
7631
+ return registry.map((def) => ({
7632
+ key: def.key,
7633
+ description: def.description,
7634
+ scopes: def.scopes,
7635
+ ...def.manageCommand ? { manageCommand: def.manageCommand } : {},
7636
+ effective: getConfigValue(def, options),
7637
+ project: readScopeValue(def, "project", options),
7638
+ global: readScopeValue(def, "global", options)
7639
+ }));
7640
+ }
7641
+ function coerceCliValue(raw) {
7642
+ try {
7643
+ return JSON.parse(raw);
7644
+ } catch {
7645
+ return raw;
7646
+ }
7647
+ }
7648
+ var LENS_AGENT_KEY = "lens.agent";
7649
+ function getRememberedAgent(options = {}) {
7650
+ const value = getConfigValueByKey(LENS_AGENT_KEY, options);
7651
+ return typeof value === "string" && value.trim() ? value : null;
7652
+ }
7653
+ function setRememberedAgent(agentId, options = {}) {
7654
+ setConfigValue(LENS_AGENT_KEY, agentId, "global", options);
7655
+ }
7656
+ function clearRememberedAgent(options = {}) {
7657
+ unsetConfigValue(LENS_AGENT_KEY, "global", options);
7409
7658
  }
7410
7659
 
7411
7660
  // ../telemetry/src/paths.ts
@@ -7652,16 +7901,20 @@ function hostPlatformKey() {
7652
7901
  }
7653
7902
  return process.platform;
7654
7903
  }
7904
+ function simulatorServerBinaryName() {
7905
+ return process.platform === "win32" ? "simulator-server.exe" : "simulator-server";
7906
+ }
7655
7907
  function platformBinDir() {
7656
7908
  return path9.join(BIN_DIR, hostPlatformKey());
7657
7909
  }
7658
7910
  function simulatorServerBinaryPath() {
7659
- const p = path9.join(platformBinDir(), "simulator-server");
7911
+ const binaryName = simulatorServerBinaryName();
7912
+ const p = path9.join(platformBinDir(), binaryName);
7660
7913
  if (!fs5.existsSync(p)) {
7661
- const flat = path9.join(BIN_DIR, "simulator-server");
7914
+ const flat = path9.join(BIN_DIR, binaryName);
7662
7915
  const migrationHint = fs5.existsSync(flat) ? ` Found a binary at the old flat path ${flat}; move it to ${p} or update ARGENT_SIMULATOR_SERVER_DIR to point at the parent of the platform subdirectory.` : "";
7663
7916
  throw new Error(
7664
- `simulator-server binary not found for platform "${hostPlatformKey()}" at ${p}. Supported hosts today: darwin, linux (x86_64 and arm64).${migrationHint}`
7917
+ `simulator-server binary not found for platform "${hostPlatformKey()}" at ${p}. Supported hosts today: darwin, linux (x86_64 and arm64), win32.${migrationHint}`
7665
7918
  );
7666
7919
  }
7667
7920
  return p;
@@ -7692,12 +7945,12 @@ function resolveHostFingerprint() {
7692
7945
  }
7693
7946
  }
7694
7947
  function resolveHostFingerprintAsync() {
7695
- return new Promise((resolve6) => {
7948
+ return new Promise((resolve7) => {
7696
7949
  let binary;
7697
7950
  try {
7698
7951
  binary = simulatorServerBinaryPath();
7699
7952
  } catch {
7700
- resolve6(null);
7953
+ resolve7(null);
7701
7954
  return;
7702
7955
  }
7703
7956
  let settled = false;
@@ -7710,7 +7963,7 @@ function resolveHostFingerprintAsync() {
7710
7963
  child?.kill("SIGKILL");
7711
7964
  } catch {
7712
7965
  }
7713
- resolve6(value);
7966
+ resolve7(value);
7714
7967
  };
7715
7968
  const watchdog = setTimeout(() => finish(null), FINGERPRINT_TIMEOUT_MS);
7716
7969
  watchdog.unref?.();
@@ -7822,9 +8075,9 @@ function isEnabled(env = process.env) {
7822
8075
  return getConsentState(env).enabled;
7823
8076
  }
7824
8077
  function writeConsentFlag(enabled) {
7825
- updateConfig((config) => {
7826
- const telemetryBlock = typeof config.telemetry === "object" && config.telemetry ? config.telemetry : {};
7827
- config.telemetry = { ...telemetryBlock, enabled };
8078
+ updateConfig((config2) => {
8079
+ const telemetryBlock = typeof config2.telemetry === "object" && config2.telemetry ? config2.telemetry : {};
8080
+ config2.telemetry = { ...telemetryBlock, enabled };
7828
8081
  });
7829
8082
  cache.current = null;
7830
8083
  }
@@ -7952,7 +8205,7 @@ async function shutdown(timeoutMs = SHORT_FLUSH_TIMEOUT_MS) {
7952
8205
  try {
7953
8206
  await Promise.race([
7954
8207
  client2.shutdown(timeoutMs),
7955
- new Promise((resolve6) => setTimeout(resolve6, timeoutMs + 250).unref())
8208
+ new Promise((resolve7) => setTimeout(resolve7, timeoutMs + 250).unref())
7956
8209
  ]);
7957
8210
  } catch (err) {
7958
8211
  emitDebugError("shutdown failed", err);
@@ -7972,7 +8225,7 @@ async function markDisabled() {
7972
8225
  try {
7973
8226
  await Promise.race([
7974
8227
  client2.shutdown(SHORT_FLUSH_TIMEOUT_MS),
7975
- new Promise((resolve6) => setTimeout(resolve6, SHORT_FLUSH_TIMEOUT_MS).unref())
8228
+ new Promise((resolve7) => setTimeout(resolve7, SHORT_FLUSH_TIMEOUT_MS).unref())
7976
8229
  ]);
7977
8230
  } catch {
7978
8231
  }
@@ -7988,14 +8241,14 @@ function status() {
7988
8241
  const anonId = peekAnonId();
7989
8242
  const hasAnonIdOnDisk = anonId !== null;
7990
8243
  const anonIdPrefix = anonId ? anonId.slice(0, 8) : null;
7991
- const config = resolveConfig();
8244
+ const config2 = resolveConfig();
7992
8245
  return {
7993
8246
  enabled: consent.enabled,
7994
8247
  source: consent.source,
7995
8248
  anonIdPrefix,
7996
8249
  hasAnonIdOnDisk,
7997
8250
  host: POSTHOG_HOST,
7998
- isKeyConfigured: config.isUsable
8251
+ isKeyConfigured: config2.isUsable
7999
8252
  };
8000
8253
  }
8001
8254
 
@@ -8214,13 +8467,13 @@ function splitOptions(argv) {
8214
8467
  return { json, outPath, argvForFlags: rest };
8215
8468
  }
8216
8469
  async function readStdin() {
8217
- return new Promise((resolve6, reject) => {
8470
+ return new Promise((resolve7, reject) => {
8218
8471
  let data = "";
8219
8472
  process.stdin.setEncoding("utf8");
8220
8473
  process.stdin.on("data", (chunk) => {
8221
8474
  data += chunk;
8222
8475
  });
8223
- process.stdin.on("end", () => resolve6(data));
8476
+ process.stdin.on("end", () => resolve7(data));
8224
8477
  process.stdin.on("error", reject);
8225
8478
  });
8226
8479
  }
@@ -8582,7 +8835,7 @@ function resolveArtifactDisplayPaths(report) {
8582
8835
  }
8583
8836
  function exitAfterFlush(code, streams = [process.stdout, process.stderr]) {
8584
8837
  return Promise.all(
8585
- streams.map((s) => new Promise((resolve6) => s.write("", () => resolve6())))
8838
+ streams.map((s) => new Promise((resolve7) => s.write("", () => resolve7())))
8586
8839
  ).then(() => process.exit(code));
8587
8840
  }
8588
8841
  function renderReport(report) {
@@ -9467,7 +9720,7 @@ function ptyInjectBeats(text2) {
9467
9720
  ];
9468
9721
  }
9469
9722
  function sleep(ms) {
9470
- return new Promise((resolve6) => setTimeout(resolve6, ms));
9723
+ return new Promise((resolve7) => setTimeout(resolve7, ms));
9471
9724
  }
9472
9725
  var DEFAULT_COLS = 80;
9473
9726
  var DEFAULT_ROWS = 24;
@@ -9688,7 +9941,7 @@ var SPAWN_GRACE_MS = 8e3;
9688
9941
  var DEATH_CONFIRMATIONS = 3;
9689
9942
  var SSE_RECONNECT_MS = 1e3;
9690
9943
  function sleep2(ms) {
9691
- return new Promise((resolve6) => setTimeout(resolve6, ms));
9944
+ return new Promise((resolve7) => setTimeout(resolve7, ms));
9692
9945
  }
9693
9946
  var TRUST_PROMPT_RE = /trust this folder|do you trust|yes,? i trust|trust the files in this/i;
9694
9947
  async function dismissTrustPrompt(session) {
@@ -10334,8 +10587,8 @@ Options:
10334
10587
  console.log("Feature flags (project overrides global):");
10335
10588
  const maxName = registryView.reduce((m, f) => Math.max(m, f.name.length), 0);
10336
10589
  for (const f of registryView) {
10337
- const scopeLabel = f.scope ? ` (${f.scope})` : "";
10338
- console.log(` ${f.name.padEnd(maxName, " ")} ${colorState(f.enabled)}${scopeLabel}`);
10590
+ const scopeLabel2 = f.scope ? ` (${f.scope})` : "";
10591
+ console.log(` ${f.name.padEnd(maxName, " ")} ${colorState(f.enabled)}${scopeLabel2}`);
10339
10592
  console.log(` ${" ".repeat(maxName)} ${f.description}`);
10340
10593
  }
10341
10594
  }
@@ -10351,6 +10604,254 @@ Options:
10351
10604
  console.log(` Project: ${getFlagsPath("project")}`);
10352
10605
  }
10353
10606
 
10607
+ // ../argent-cli/src/config.ts
10608
+ var import_picocolors2 = __toESM(require_picocolors(), 1);
10609
+ import * as path14 from "node:path";
10610
+ function config(argv) {
10611
+ if (argv.length === 0 || argv[0] === "--help" || argv[0] === "-h") {
10612
+ printUsage();
10613
+ return;
10614
+ }
10615
+ const [sub, ...rest] = argv;
10616
+ switch (sub) {
10617
+ case "list":
10618
+ return cmdList(rest);
10619
+ case "get":
10620
+ return cmdGet(rest);
10621
+ case "set":
10622
+ return cmdSet(rest);
10623
+ case "unset":
10624
+ return cmdUnset(rest);
10625
+ default:
10626
+ console.error(`Error: unknown subcommand "config ${sub}". Try \`argent config --help\`.`);
10627
+ process.exit(2);
10628
+ }
10629
+ }
10630
+ function cmdList(argv) {
10631
+ if (wantsHelp(argv)) {
10632
+ console.log(`Usage: argent config list [--json]
10633
+
10634
+ Show every recognized configuration value, its effective (merged) value, and
10635
+ the raw value stored at each scope.`);
10636
+ return;
10637
+ }
10638
+ const json = argv.includes("--json");
10639
+ const entries = listConfig();
10640
+ if (json) {
10641
+ console.log(JSON.stringify({ config: entries }, null, 2));
10642
+ return;
10643
+ }
10644
+ if (entries.length === 0) {
10645
+ console.log("No configurations are defined.");
10646
+ return;
10647
+ }
10648
+ console.log("Configuration (project overrides global unless noted):\n");
10649
+ const maxKey = entries.reduce((m, e) => Math.max(m, e.key.length), 0);
10650
+ for (const e of entries) {
10651
+ const managed = e.manageCommand ? import_picocolors2.default.dim(` [managed by \`${e.manageCommand}\`]`) : "";
10652
+ console.log(` ${e.key.padEnd(maxKey)} ${formatValue(e.effective)}${managed}`);
10653
+ console.log(` ${" ".repeat(maxKey)} ${import_picocolors2.default.dim(e.description)}`);
10654
+ console.log(` ${" ".repeat(maxKey)} ${import_picocolors2.default.dim(scopeDetail(e))}`);
10655
+ }
10656
+ }
10657
+ function scopeDetail(e) {
10658
+ const parts = [`scopes: ${e.scopes.join(", ")}`];
10659
+ if (e.project !== void 0) parts.push(`project=${formatValuePlain(e.project)}`);
10660
+ if (e.global !== void 0) parts.push(`global=${formatValuePlain(e.global)}`);
10661
+ return parts.join(" \xB7 ");
10662
+ }
10663
+ function cmdGet(argv) {
10664
+ if (wantsHelp(argv)) {
10665
+ console.log(`Usage: argent config get <key> [--scope global|project] [--json]
10666
+
10667
+ Print a configuration value. Without --scope, prints the effective value after
10668
+ merging project and global. With --scope, prints only that scope's stored value.`);
10669
+ return;
10670
+ }
10671
+ const { positionals, scope, json } = parseArgs2(argv);
10672
+ const key = positionals[0];
10673
+ if (!key) {
10674
+ console.error("Error: `argent config get` requires a <key>.");
10675
+ process.exit(2);
10676
+ }
10677
+ if (positionals.length > 1) {
10678
+ console.error(`Error: unexpected extra argument "${positionals[1]}".`);
10679
+ process.exit(2);
10680
+ }
10681
+ try {
10682
+ const value = scope ? getConfigValueAtScope(key, scope) : getConfigValueByKey(key);
10683
+ if (json) {
10684
+ console.log(
10685
+ JSON.stringify({ key, scope: scope ?? "effective", value: value ?? null }, null, 2)
10686
+ );
10687
+ } else if (value === void 0) {
10688
+ console.log("(unset)");
10689
+ } else {
10690
+ console.log(formatValuePlain(value));
10691
+ }
10692
+ } catch (err) {
10693
+ reportError(err);
10694
+ }
10695
+ }
10696
+ function cmdSet(argv) {
10697
+ if (wantsHelp(argv)) {
10698
+ console.log(`Usage: argent config set <key> <value> [--scope global|project]
10699
+
10700
+ Set a configuration value. Default scope is global; pass --scope project to
10701
+ write <project-root>/.argent/config.json. Booleans, numbers, and JSON arrays are
10702
+ parsed (e.g. \`true\`, \`42\`, \`["a","b"]\`); anything else is stored as a string.`);
10703
+ return;
10704
+ }
10705
+ const { positionals, scope } = parseArgs2(argv);
10706
+ const key = positionals[0];
10707
+ const rawValue = positionals[1];
10708
+ if (!key || rawValue === void 0) {
10709
+ console.error("Error: `argent config set` requires a <key> and a <value>.");
10710
+ process.exit(2);
10711
+ }
10712
+ if (positionals.length > 2) {
10713
+ console.error(`Error: unexpected extra argument "${positionals[2]}".`);
10714
+ process.exit(2);
10715
+ }
10716
+ const targetScope = scope ?? "global";
10717
+ const warning = degenerateProjectScopeWarning(targetScope);
10718
+ try {
10719
+ const stored = setConfigValue(key, coerceCliValue(rawValue), targetScope);
10720
+ if (warning) console.error(import_picocolors2.default.yellow(warning));
10721
+ console.log(`Set ${import_picocolors2.default.bold(key)} = ${formatValuePlain(stored)} (${scopeLabel(targetScope)}).`);
10722
+ } catch (err) {
10723
+ reportError(err);
10724
+ }
10725
+ }
10726
+ function cmdUnset(argv) {
10727
+ if (wantsHelp(argv)) {
10728
+ console.log(`Usage: argent config unset <key> [--scope global|project]
10729
+
10730
+ Remove a configuration value at a scope (default global). Falls back to the
10731
+ other scope / the default on the next read.`);
10732
+ return;
10733
+ }
10734
+ const { positionals, scope } = parseArgs2(argv);
10735
+ const key = positionals[0];
10736
+ if (!key) {
10737
+ console.error("Error: `argent config unset` requires a <key>.");
10738
+ process.exit(2);
10739
+ }
10740
+ if (positionals.length > 1) {
10741
+ console.error(`Error: unexpected extra argument "${positionals[1]}".`);
10742
+ process.exit(2);
10743
+ }
10744
+ const targetScope = scope ?? "global";
10745
+ const warning = degenerateProjectScopeWarning(targetScope);
10746
+ try {
10747
+ const removed = unsetConfigValue(key, targetScope);
10748
+ if (removed && warning) console.error(import_picocolors2.default.yellow(warning));
10749
+ console.log(
10750
+ removed ? `Unset ${import_picocolors2.default.bold(key)} (${scopeLabel(targetScope)}).` : import_picocolors2.default.dim(`${key} was not set at ${targetScope} scope.`)
10751
+ );
10752
+ } catch (err) {
10753
+ reportError(err);
10754
+ }
10755
+ }
10756
+ function parseArgs2(argv) {
10757
+ const positionals = [];
10758
+ let scope = null;
10759
+ let json = false;
10760
+ for (let i2 = 0; i2 < argv.length; i2++) {
10761
+ const tok = argv[i2];
10762
+ if (tok === "--json") {
10763
+ json = true;
10764
+ continue;
10765
+ }
10766
+ if (tok === "--scope") {
10767
+ scope = parseScope2(argv[++i2]);
10768
+ continue;
10769
+ }
10770
+ if (tok.startsWith("--scope=")) {
10771
+ scope = parseScope2(tok.slice("--scope=".length));
10772
+ continue;
10773
+ }
10774
+ if (tok.startsWith("--")) {
10775
+ console.error(`Error: unknown flag "${tok}".`);
10776
+ process.exit(2);
10777
+ }
10778
+ positionals.push(tok);
10779
+ }
10780
+ return { positionals, scope, json };
10781
+ }
10782
+ function parseScope2(raw) {
10783
+ if (raw === "global" || raw === "project") return raw;
10784
+ console.error(`Error: --scope must be "global" or "project"${raw ? `, got "${raw}"` : ""}.`);
10785
+ process.exit(2);
10786
+ }
10787
+ function wantsHelp(argv) {
10788
+ return argv.includes("--help") || argv.includes("-h");
10789
+ }
10790
+ function scopeLabel(scope) {
10791
+ if (scope === "global") return "global";
10792
+ return `project: ${path14.dirname(configDir("project"))}`;
10793
+ }
10794
+ function degenerateProjectScopeWarning(scope) {
10795
+ if (scope !== "project") return null;
10796
+ const projDir = configDir("project");
10797
+ if (path14.resolve(projDir) === path14.resolve(configDir("global"))) {
10798
+ return `WARNING: no project found between ${process.cwd()} and your home directory \u2014 "project" scope resolved to the home directory, so this writes the GLOBAL config file (${path14.join(projDir, "config.json")}).`;
10799
+ }
10800
+ if (findProjectRoot(process.cwd()) === null) {
10801
+ return `WARNING: no project markers (.argent, .git, package.json) found above ${process.cwd()} \u2014 treating it as the project root and creating ${path14.join(projDir, "config.json")}.`;
10802
+ }
10803
+ return null;
10804
+ }
10805
+ function formatValuePlain(value) {
10806
+ if (typeof value === "string") return value;
10807
+ return JSON.stringify(value);
10808
+ }
10809
+ function formatValue(value) {
10810
+ if (value === void 0) return import_picocolors2.default.dim("(unset)");
10811
+ if (typeof value === "boolean" && process.stdout.isTTY) {
10812
+ return value ? import_picocolors2.default.green("true") : import_picocolors2.default.red("false");
10813
+ }
10814
+ return formatValuePlain(value);
10815
+ }
10816
+ function reportError(err) {
10817
+ if (err instanceof ConfigManagedElsewhereError) {
10818
+ console.error(`Error: ${err.message} Use \`${err.command}\` instead.`);
10819
+ } else if (err instanceof UnknownConfigKeyError || err instanceof ConfigScopeError || err instanceof ConfigValidationError) {
10820
+ console.error(`Error: ${err.message}`);
10821
+ if (err instanceof UnknownConfigKeyError) {
10822
+ console.error(`Run \`argent config list\` to see available keys.`);
10823
+ }
10824
+ } else {
10825
+ console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
10826
+ }
10827
+ process.exit(2);
10828
+ }
10829
+ function printUsage() {
10830
+ const keys = CONFIG_SCHEMA.map((d) => d.key);
10831
+ const maxKey = keys.reduce((m, k) => Math.max(m, k.length), 0);
10832
+ const keyLines = CONFIG_SCHEMA.map((d) => {
10833
+ const managed = d.manageCommand ? import_picocolors2.default.dim(` [managed by \`${d.manageCommand}\`]`) : "";
10834
+ return ` ${d.key.padEnd(maxKey)} ${d.description}${managed}`;
10835
+ });
10836
+ console.log(`Usage: argent config <command> [options]
10837
+
10838
+ Manage argent configuration. Values are stored at two scopes and merged per the
10839
+ configuration's policy:
10840
+ ~/.argent/config.json (global, default)
10841
+ <project-root>/.argent/config.json (project, with --scope project)
10842
+
10843
+ Commands:
10844
+ list Show all configurations and their values
10845
+ get <key> Print a value (effective, or --scope <scope>)
10846
+ set <key> <value> Set a value (--scope global|project, default global)
10847
+ unset <key> Remove a value at a scope (default global)
10848
+
10849
+ Recognized keys:
10850
+ ${keyLines.join("\n")}
10851
+
10852
+ Run \`argent config <command> --help\` for command-specific help.`);
10853
+ }
10854
+
10354
10855
  // ../../node_modules/@clack/core/dist/index.mjs
10355
10856
  import { styleText } from "node:util";
10356
10857
  import { stdout, stdin } from "node:process";
@@ -11071,7 +11572,7 @@ import { styleText as styleText2, stripVTControlCharacters } from "node:util";
11071
11572
  import process$1 from "node:process";
11072
11573
  var import_sisteransi2 = __toESM(require_src(), 1);
11073
11574
  import { existsSync as existsSync7, lstatSync as lstatSync3, readdirSync as readdirSync3 } from "node:fs";
11074
- import { dirname as dirname8, join as join16 } from "node:path";
11575
+ import { dirname as dirname9, join as join17 } from "node:path";
11075
11576
  function isUnicodeSupported() {
11076
11577
  if (process$1.platform !== "win32") {
11077
11578
  return process$1.env.TERM !== "linux";
@@ -11508,7 +12009,7 @@ ${r2}
11508
12009
  }).prompt();
11509
12010
 
11510
12011
  // ../argent-cli/src/link.ts
11511
- var import_picocolors2 = __toESM(require_picocolors(), 1);
12012
+ var import_picocolors3 = __toESM(require_picocolors(), 1);
11512
12013
  var WILDCARD_HOSTS = /* @__PURE__ */ new Set(["0.0.0.0", "::", "::0", ""]);
11513
12014
  function isLoopback2(host) {
11514
12015
  return host === "127.0.0.1" || host === "localhost" || host === "::1";
@@ -11766,7 +12267,7 @@ async function preflightHealth(url, token) {
11766
12267
  }
11767
12268
  function printRestartHint() {
11768
12269
  console.log(
11769
- import_picocolors2.default.dim("Restart your editor to apply the change to any running `argent mcp` session.")
12270
+ import_picocolors3.default.dim("Restart your editor to apply the change to any running `argent mcp` session.")
11770
12271
  );
11771
12272
  }
11772
12273
  function printSecurityCaveat(host, token, url) {
@@ -11775,7 +12276,7 @@ function printSecurityCaveat(host, token, url) {
11775
12276
  if (tls) {
11776
12277
  if (!token) {
11777
12278
  process.stderr.write(
11778
- import_picocolors2.default.yellow(
12279
+ import_picocolors3.default.yellow(
11779
12280
  `WARNING: ${host} is reached over HTTPS but with NO token \u2014 anyone who can reach the URL can drive the server. Pair with a token.
11780
12281
  `
11781
12282
  )
@@ -11785,7 +12286,7 @@ function printSecurityCaveat(host, token, url) {
11785
12286
  }
11786
12287
  if (token) {
11787
12288
  process.stderr.write(
11788
- import_picocolors2.default.dim(
12289
+ import_picocolors3.default.dim(
11789
12290
  `Note: ${host} is reached over plain HTTP (bearer-token auth, no TLS). Keep this link to a trusted network or VPN, or front it with an https:// tunnel.
11790
12291
  `
11791
12292
  )
@@ -11793,7 +12294,7 @@ function printSecurityCaveat(host, token, url) {
11793
12294
  return;
11794
12295
  }
11795
12296
  process.stderr.write(
11796
- import_picocolors2.default.yellow(
12297
+ import_picocolors3.default.yellow(
11797
12298
  `WARNING: linked target ${host} is non-loopback and has NO token \u2014 tool calls travel over plain HTTP with no auth. Treat this link as trusted-network-only, or pair with a token (start the server without --no-auth).
11798
12299
  `
11799
12300
  )
@@ -11826,9 +12327,9 @@ async function link(argv) {
11826
12327
  if (flags2.host !== null) {
11827
12328
  host = flags2.host;
11828
12329
  } else {
11829
- intro(import_picocolors2.default.bgCyan(import_picocolors2.default.black(" argent link ")));
12330
+ intro(import_picocolors3.default.bgCyan(import_picocolors3.default.black(" argent link ")));
11830
12331
  if (existing) {
11831
- log.info(`Current link: ${import_picocolors2.default.cyan(existing.url)} (${existing.createdAt})`);
12332
+ log.info(`Current link: ${import_picocolors3.default.cyan(existing.url)} (${existing.createdAt})`);
11832
12333
  }
11833
12334
  host = await promptHost(existing);
11834
12335
  }
@@ -11844,12 +12345,12 @@ async function link(argv) {
11844
12345
  let url = flags2.url ?? formatUrl(host, port);
11845
12346
  if (!flags2.yes && existing) {
11846
12347
  if (existing.url === url) {
11847
- log.info(`Already linked to ${import_picocolors2.default.cyan(url)}.`);
12348
+ log.info(`Already linked to ${import_picocolors3.default.cyan(url)}.`);
11848
12349
  outro("No changes.");
11849
12350
  return;
11850
12351
  }
11851
12352
  const overwrite = await confirm({
11852
- message: `Replace existing link ${import_picocolors2.default.dim(existing.url)} with ${import_picocolors2.default.cyan(url)}?`,
12353
+ message: `Replace existing link ${import_picocolors3.default.dim(existing.url)} with ${import_picocolors3.default.cyan(url)}?`,
11853
12354
  initialValue: true
11854
12355
  });
11855
12356
  if (isCancel(overwrite) || !overwrite) {
@@ -11867,10 +12368,10 @@ async function link(argv) {
11867
12368
  }
11868
12369
  const result = await preflightHealth(url, token);
11869
12370
  if (result.ok) {
11870
- if (spinner2) spinner2.stop(import_picocolors2.default.green("Tool-server reachable."));
12371
+ if (spinner2) spinner2.stop(import_picocolors3.default.green("Tool-server reachable."));
11871
12372
  break;
11872
12373
  }
11873
- if (spinner2) spinner2.stop(import_picocolors2.default.red("Verification failed."));
12374
+ if (spinner2) spinner2.stop(import_picocolors3.default.red("Verification failed."));
11874
12375
  const detail = result.error ? ` (${result.error})` : "";
11875
12376
  if (flags2.yes) {
11876
12377
  console.error(
@@ -11910,15 +12411,15 @@ async function link(argv) {
11910
12411
  };
11911
12412
  await writeLinkConfig(cfg);
11912
12413
  if (existing && existing.url !== url) {
11913
- console.log(`${import_picocolors2.default.green("\u2713")} Link updated: ${import_picocolors2.default.dim(existing.url)} \u2192 ${import_picocolors2.default.cyan(url)}`);
12414
+ console.log(`${import_picocolors3.default.green("\u2713")} Link updated: ${import_picocolors3.default.dim(existing.url)} \u2192 ${import_picocolors3.default.cyan(url)}`);
11914
12415
  } else {
11915
- console.log(`${import_picocolors2.default.green("\u2713")} Linked: ${import_picocolors2.default.cyan(url)}`);
12416
+ console.log(`${import_picocolors3.default.green("\u2713")} Linked: ${import_picocolors3.default.cyan(url)}`);
11916
12417
  }
11917
- if (token) console.log(import_picocolors2.default.dim(" auth: token stored in ~/.argent/link.json (0600)"));
12418
+ if (token) console.log(import_picocolors3.default.dim(" auth: token stored in ~/.argent/link.json (0600)"));
11918
12419
  printSecurityCaveat(host, token, url);
11919
12420
  if (process.env.ARGENT_TOOLS_URL) {
11920
12421
  console.log(
11921
- import_picocolors2.default.yellow(
12422
+ import_picocolors3.default.yellow(
11922
12423
  `Note: ARGENT_TOOLS_URL=${process.env.ARGENT_TOOLS_URL} is set in your environment and takes precedence over the link.`
11923
12424
  )
11924
12425
  );
@@ -11949,7 +12450,7 @@ async function unlink3(argv) {
11949
12450
  }
11950
12451
  if (!flags2.yes) {
11951
12452
  const confirmed = await confirm({
11952
- message: `Remove link to ${import_picocolors2.default.cyan(existing.url)}?`,
12453
+ message: `Remove link to ${import_picocolors3.default.cyan(existing.url)}?`,
11953
12454
  initialValue: true
11954
12455
  });
11955
12456
  if (isCancel(confirmed) || !confirmed) {
@@ -11958,10 +12459,10 @@ async function unlink3(argv) {
11958
12459
  }
11959
12460
  }
11960
12461
  await clearLinkConfig();
11961
- console.log(`${import_picocolors2.default.green("\u2713")} Unlinked from ${import_picocolors2.default.dim(existing.url)}.`);
12462
+ console.log(`${import_picocolors3.default.green("\u2713")} Unlinked from ${import_picocolors3.default.dim(existing.url)}.`);
11962
12463
  if (process.env.ARGENT_TOOLS_URL) {
11963
12464
  console.log(
11964
- import_picocolors2.default.yellow(
12465
+ import_picocolors3.default.yellow(
11965
12466
  `The env var ARGENT_TOOLS_URL is also set in your shell (=${process.env.ARGENT_TOOLS_URL}) and takes precedence \u2014 unset it manually if you want fully local behaviour.`
11966
12467
  )
11967
12468
  );
@@ -11970,13 +12471,13 @@ async function unlink3(argv) {
11970
12471
  }
11971
12472
 
11972
12473
  // ../argent-cli/src/telemetry.ts
11973
- var import_picocolors3 = __toESM(require_picocolors(), 1);
12474
+ var import_picocolors4 = __toESM(require_picocolors(), 1);
11974
12475
  async function telemetry(args) {
11975
12476
  const sub = args[0];
11976
12477
  init("cli");
11977
12478
  switch (sub) {
11978
12479
  case void 0:
11979
- printUsage();
12480
+ printUsage2();
11980
12481
  await shutdown();
11981
12482
  return;
11982
12483
  case "status":
@@ -11991,7 +12492,7 @@ async function telemetry(args) {
11991
12492
  return;
11992
12493
  case "--help":
11993
12494
  case "-h":
11994
- printUsage();
12495
+ printUsage2();
11995
12496
  await shutdown();
11996
12497
  return;
11997
12498
  default:
@@ -12000,7 +12501,7 @@ async function telemetry(args) {
12000
12501
  process.exit(1);
12001
12502
  }
12002
12503
  }
12003
- function printUsage() {
12504
+ function printUsage2() {
12004
12505
  console.log(`Usage:
12005
12506
  argent telemetry status Show telemetry state and device id
12006
12507
  argent telemetry enable Enable telemetry
@@ -12018,25 +12519,26 @@ async function cmdEnable() {
12018
12519
  const wasEnabled = isEnabled();
12019
12520
  markEnabled();
12020
12521
  if (wasEnabled) {
12021
- console.log(import_picocolors3.default.dim("Telemetry was already enabled."));
12522
+ console.log(import_picocolors4.default.dim("Telemetry was already enabled."));
12022
12523
  } else {
12023
- console.log(import_picocolors3.default.green("Telemetry enabled."));
12524
+ console.log(import_picocolors4.default.green("Telemetry enabled."));
12024
12525
  }
12025
12526
  await shutdown();
12026
12527
  }
12027
12528
  async function cmdDisable() {
12028
12529
  const wasEnabled = isEnabled();
12029
12530
  if (!wasEnabled) {
12030
- console.log(import_picocolors3.default.dim("Telemetry was already disabled."));
12531
+ console.log(import_picocolors4.default.dim("Telemetry was already disabled."));
12031
12532
  await shutdown();
12032
12533
  return;
12033
12534
  }
12034
12535
  await markDisabled();
12035
- console.log(import_picocolors3.default.red("Telemetry disabled."));
12536
+ console.log(import_picocolors4.default.red("Telemetry disabled."));
12036
12537
  await shutdown();
12037
12538
  }
12038
12539
  export {
12039
12540
  FLAG_REGISTRY,
12541
+ config,
12040
12542
  disable,
12041
12543
  enable,
12042
12544
  flags,