@swmansion/argent 0.35.1-next.4 → 0.35.1-next.6

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.
@@ -15331,7 +15331,19 @@ function getWhatsNewSeenVersion(options = {}) {
15331
15331
  return typeof value === "string" ? value : null;
15332
15332
  }
15333
15333
  function setWhatsNewSeenVersion(version, options = {}) {
15334
- updateConfig((config) => setAtPath(config, WHATS_NEW_SEEN_KEY, version), "global", options);
15334
+ let recorded = false;
15335
+ updateConfig(
15336
+ (config) => {
15337
+ const value = getAtPath(config, WHATS_NEW_SEEN_KEY);
15338
+ const seen = typeof value === "string" ? value : null;
15339
+ if (options.ifSeen !== void 0 && options.ifSeen !== seen) return;
15340
+ setAtPath(config, WHATS_NEW_SEEN_KEY, version);
15341
+ recorded = true;
15342
+ },
15343
+ "global",
15344
+ options
15345
+ );
15346
+ return recorded;
15335
15347
  }
15336
15348
 
15337
15349
  // ../configuration-core/src/secrets.ts
@@ -15339,6 +15351,57 @@ var import_dotenv = __toESM(require_dist(), 1);
15339
15351
  import * as fs5 from "node:fs";
15340
15352
  import * as path5 from "node:path";
15341
15353
 
15354
+ // ../configuration-core/src/merge.ts
15355
+ function mergeRestrictive(local, global2) {
15356
+ if (local === void 0) return global2;
15357
+ if (global2 === void 0) return local;
15358
+ if (typeof local === "boolean" && typeof global2 === "boolean") {
15359
+ return local && global2;
15360
+ }
15361
+ if (typeof local === "number" && typeof global2 === "number") {
15362
+ return Math.min(local, global2);
15363
+ }
15364
+ return local;
15365
+ }
15366
+ function toArray(value) {
15367
+ return Array.isArray(value) ? value : null;
15368
+ }
15369
+ function mergeUnion(local, global2) {
15370
+ const l2 = toArray(local);
15371
+ const g = toArray(global2);
15372
+ if (l2 === null && g === null) return local ?? global2;
15373
+ const merged = [...g ?? [], ...l2 ?? []];
15374
+ return Array.from(new Set(merged));
15375
+ }
15376
+ function mergeIntersection(local, global2) {
15377
+ const l2 = toArray(local);
15378
+ const g = toArray(global2);
15379
+ if (l2 === null && g === null) return local ?? global2;
15380
+ if (l2 === null) return global2;
15381
+ if (g === null) return local;
15382
+ const globalSet = new Set(g);
15383
+ return l2.filter((item) => globalSet.has(item));
15384
+ }
15385
+ function applyMergePolicy(policy, local, global2) {
15386
+ if (typeof policy === "function") return policy({ local, global: global2 });
15387
+ switch (policy) {
15388
+ case "prioritize-local":
15389
+ return local ?? global2;
15390
+ case "prioritize-global":
15391
+ return global2 ?? local;
15392
+ case "prioritize-restrictive":
15393
+ return mergeRestrictive(local, global2);
15394
+ case "union":
15395
+ return mergeUnion(local, global2);
15396
+ case "intersection":
15397
+ return mergeIntersection(local, global2);
15398
+ default: {
15399
+ const _exhaustive = policy;
15400
+ return _exhaustive;
15401
+ }
15402
+ }
15403
+ }
15404
+
15342
15405
  // ../configuration-core/src/config-schema.ts
15343
15406
  import { isAbsolute } from "node:path";
15344
15407
  function asBoolean(raw) {
@@ -15376,6 +15439,15 @@ var CONFIG_SCHEMA = [
15376
15439
  // drained/reset, not just the file rewritten.
15377
15440
  manageCommand: "argent telemetry"
15378
15441
  },
15442
+ {
15443
+ key: "autoUpdate.enabled",
15444
+ description: "Automatically update the global Argent installation. Project-local installs require confirmation.",
15445
+ scopes: ["global"],
15446
+ parse: asBoolean,
15447
+ merge: "prioritize-local",
15448
+ default: true,
15449
+ example: "false"
15450
+ },
15379
15451
  {
15380
15452
  key: "lens.agent",
15381
15453
  description: "Coding-agent id remembered by `argent lens` to skip the picker.",
@@ -15459,9 +15531,42 @@ var CONFIG_SCHEMA = [
15459
15531
  example: "512"
15460
15532
  }
15461
15533
  ];
15534
+ function getConfigDefinition(key, registry = CONFIG_SCHEMA) {
15535
+ return registry.find((def) => def.key === key);
15536
+ }
15462
15537
 
15463
15538
  // ../configuration-core/src/config-access.ts
15464
15539
  import * as path6 from "node:path";
15540
+ function readScopeValue(def, scope, options) {
15541
+ if (!def.scopes.includes(scope)) return void 0;
15542
+ const raw = getAtPath(readConfigObject(scope, options), def.key);
15543
+ return raw === void 0 ? void 0 : def.parse(raw);
15544
+ }
15545
+ function getConfigValue(def, options = {}) {
15546
+ const local = readScopeValue(def, "project", options);
15547
+ const global2 = readScopeValue(def, "global", options);
15548
+ const merged = applyMergePolicy(def.merge, local, global2);
15549
+ return merged ?? def.default;
15550
+ }
15551
+ function getConfigValueByKey(key, options = {}, registry = CONFIG_SCHEMA) {
15552
+ const def = requireDefinition(key, registry);
15553
+ return getConfigValue(def, options);
15554
+ }
15555
+ function requireDefinition(key, registry = CONFIG_SCHEMA) {
15556
+ const def = getConfigDefinition(key, registry);
15557
+ if (!def) {
15558
+ throw new UnknownConfigKeyError(key);
15559
+ }
15560
+ return def;
15561
+ }
15562
+ var UnknownConfigKeyError = class extends Error {
15563
+ constructor(key) {
15564
+ super(`Unknown configuration key "${key}".`);
15565
+ this.key = key;
15566
+ this.name = "UnknownConfigKeyError";
15567
+ }
15568
+ key;
15569
+ };
15465
15570
 
15466
15571
  // ../telemetry/src/paths.ts
15467
15572
  function identityFilePath() {
@@ -16998,7 +17103,7 @@ function isCi(env = process.env) {
16998
17103
  var SESSION_ID = randomUUID4();
16999
17104
  function readCliVersion() {
17000
17105
  if (true) {
17001
- return "0.35.1-next.4";
17106
+ return "0.35.1-next.6";
17002
17107
  }
17003
17108
  return "0.0.0";
17004
17109
  }
@@ -17636,7 +17741,7 @@ async function shutdown(timeoutMs = SHORT_FLUSH_TIMEOUT_MS) {
17636
17741
  // ../argent-installer/src/mcp-configs.ts
17637
17742
  import * as fs18 from "node:fs";
17638
17743
  import * as path19 from "node:path";
17639
- import { execFileSync as execFileSync4 } from "node:child_process";
17744
+ import { execFileSync as execFileSync5 } from "node:child_process";
17640
17745
  import { homedir as homedir5 } from "node:os";
17641
17746
 
17642
17747
  // ../argent-installer/src/constants.ts
@@ -17655,7 +17760,7 @@ import * as path18 from "node:path";
17655
17760
  import * as dns from "node:dns";
17656
17761
  import { createHash as createHash2 } from "node:crypto";
17657
17762
  import * as os3 from "node:os";
17658
- import { execFileSync as execFileSync3, execSync } from "node:child_process";
17763
+ import { execFileSync as execFileSync4, execSync } from "node:child_process";
17659
17764
 
17660
17765
  // ../../node_modules/smol-toml/dist/error.js
17661
17766
  function getLineColFromPtr(string, ptr) {
@@ -19987,6 +20092,7 @@ function resolvePackageRoot(dirname20) {
19987
20092
  }
19988
20093
 
19989
20094
  // ../argent-installer/src/package-manager.ts
20095
+ import { execFileSync as execFileSync3 } from "node:child_process";
19990
20096
  import * as fs15 from "node:fs";
19991
20097
  import * as os2 from "node:os";
19992
20098
  import * as path16 from "node:path";
@@ -20376,6 +20482,42 @@ function globalCommandOptions(pm) {
20376
20482
  const { npm_config_prefix: _npmPrefix, ...env } = process.env;
20377
20483
  return { ...cwd, env };
20378
20484
  }
20485
+ var globalLocationArgs = {
20486
+ npm: ["root", "-g"],
20487
+ pnpm: ["list", "-g", "--depth", "0", "--json", PACKAGE_NAME],
20488
+ yarn: ["global", "dir"],
20489
+ bun: ["pm", "ls", "-g"]
20490
+ };
20491
+ function isRegistrySpec(spec) {
20492
+ return typeof spec === "string" && spec.length > 0 && !spec.includes(":") && !spec.includes("/");
20493
+ }
20494
+ function ownsGlobalInstall(pm, runningRoot) {
20495
+ try {
20496
+ const output = execFileSync3(pm, globalLocationArgs[pm], {
20497
+ ...globalCommandOptions(pm),
20498
+ encoding: "utf8",
20499
+ stdio: ["ignore", "pipe", "ignore"],
20500
+ shell: process.platform === "win32",
20501
+ timeout: 5e3
20502
+ }).trim();
20503
+ let pkg;
20504
+ let localBuild;
20505
+ if (pm === "pnpm") {
20506
+ const listings = JSON.parse(output);
20507
+ const dependency = listings[0]?.dependencies?.[PACKAGE_NAME];
20508
+ pkg = dependency?.path;
20509
+ localBuild = !isRegistrySpec(dependency?.version);
20510
+ } else {
20511
+ const dir = pm === "bun" ? /^([^\r\n]+) node_modules \(/.exec(output)?.[1] : output;
20512
+ if (!dir || !path16.isAbsolute(dir)) return false;
20513
+ pkg = pm === "npm" ? path16.join(dir, PACKAGE_NAME) : path16.join(dir, "node_modules", PACKAGE_NAME);
20514
+ localBuild = fs15.lstatSync(pkg).isSymbolicLink();
20515
+ }
20516
+ return !localBuild && !!pkg && path16.isAbsolute(pkg) && fs15.realpathSync(pkg) === runningRoot;
20517
+ } catch {
20518
+ return false;
20519
+ }
20520
+ }
20379
20521
  function globalUninstallCommand(pm, pkg) {
20380
20522
  switch (pm) {
20381
20523
  case "yarn":
@@ -20905,7 +21047,7 @@ var PROBE_TIMEOUT_MS = 3e3;
20905
21047
  function getLatestVersion() {
20906
21048
  const args = ["view", PACKAGE_NAME, "version", "--registry", NPM_REGISTRY];
20907
21049
  const opts = { encoding: "utf8", timeout: PROBE_TIMEOUT_MS };
20908
- const result = process.platform === "win32" ? execSync(["npm", ...args].join(" "), opts) : execFileSync3("npm", args, opts);
21050
+ const result = process.platform === "win32" ? execSync(["npm", ...args].join(" "), opts) : execFileSync4("npm", args, opts);
20909
21051
  return result.trim();
20910
21052
  }
20911
21053
  function isNewerVersion(candidate, current) {
@@ -20964,7 +21106,7 @@ function escapeStringRegexp(string) {
20964
21106
  // ../argent-installer/src/mcp-configs.ts
20965
21107
  var TOOL_SERVER_BUNDLE = path19.join(import.meta.dirname, "tool-server.cjs");
20966
21108
  function getAvailableToolIds() {
20967
- const out = execFileSync4("node", [TOOL_SERVER_BUNDLE, "-t"], { encoding: "utf8" });
21109
+ const out = execFileSync5("node", [TOOL_SERVER_BUNDLE, "-t"], { encoding: "utf8" });
20968
21110
  const tools = JSON.parse(out);
20969
21111
  return tools.map((t2) => t2.id);
20970
21112
  }
@@ -21998,7 +22140,7 @@ var OPENCODE_GLOBAL_FILES = ["opencode.jsonc", "opencode.json", "config.json"];
21998
22140
  function hasOpenCodeBinary() {
21999
22141
  try {
22000
22142
  const cmd = process.platform === "win32" ? "where" : "which";
22001
- execFileSync4(cmd, [OPENCODE_BINARY], { stdio: ["ignore", "ignore", "ignore"] });
22143
+ execFileSync5(cmd, [OPENCODE_BINARY], { stdio: ["ignore", "ignore", "ignore"] });
22002
22144
  return true;
22003
22145
  } catch {
22004
22146
  return false;
@@ -22573,7 +22715,7 @@ function printFirstRunNotice() {
22573
22715
  markFirstRunNoticeShown();
22574
22716
  }
22575
22717
  function seedWhatsNewVersion(version) {
22576
- if (getWhatsNewSeenVersion() === null) setWhatsNewSeenVersion(version);
22718
+ if (getWhatsNewSeenVersion() === null) setWhatsNewSeenVersion(version, { ifSeen: null });
22577
22719
  }
22578
22720
  async function resolveTelemetryConsent(opts) {
22579
22721
  if (opts.disableFlag) {
@@ -22778,7 +22920,7 @@ import * as fs22 from "node:fs";
22778
22920
  import * as path24 from "node:path";
22779
22921
 
22780
22922
  // ../argent-installer/src/shell.ts
22781
- import { execFileSync as execFileSync5, spawn as spawn2 } from "node:child_process";
22923
+ import { execFileSync as execFileSync6, spawn as spawn2 } from "node:child_process";
22782
22924
  async function runTrustingDisk(execute, landedOnDisk) {
22783
22925
  let exitError = null;
22784
22926
  try {
@@ -22789,7 +22931,7 @@ async function runTrustingDisk(execute, landedOnDisk) {
22789
22931
  return { landed: landedOnDisk(), exitError };
22790
22932
  }
22791
22933
  function execShellCommandSync(cmd, opts = {}) {
22792
- execFileSync5(cmd.bin, cmd.args, {
22934
+ execFileSync6(cmd.bin, cmd.args, {
22793
22935
  stdio: "inherit",
22794
22936
  shell: process.platform === "win32",
22795
22937
  ...opts.cwd ? { cwd: opts.cwd } : {},
@@ -22838,13 +22980,13 @@ function runShellCommand(cmd, opts = {}) {
22838
22980
  }
22839
22981
 
22840
22982
  // ../argent-installer/src/skills.ts
22841
- import { execFileSync as execFileSync7 } from "node:child_process";
22983
+ import { execFileSync as execFileSync8 } from "node:child_process";
22842
22984
  import * as fs21 from "node:fs";
22843
22985
  import * as path23 from "node:path";
22844
22986
  var import_picocolors3 = __toESM(require_picocolors(), 1);
22845
22987
 
22846
22988
  // ../argent-installer/src/skills-runner.ts
22847
- import { execFileSync as execFileSync6 } from "node:child_process";
22989
+ import { execFileSync as execFileSync7 } from "node:child_process";
22848
22990
  import * as fs20 from "node:fs";
22849
22991
  import * as path22 from "node:path";
22850
22992
  var WIN32_DEFAULT_PATHEXT = ".COM;.EXE;.BAT;.CMD";
@@ -22878,7 +23020,7 @@ function yarnSupportsDlx(bin, platform) {
22878
23020
  try {
22879
23021
  const probe = { kind: "yarn", bin, buildArgs: (args) => args, label: "yarn" };
22880
23022
  const command = skillsCommand(probe, ["--version"], platform);
22881
- const out = execFileSync6(command.file, command.args, {
23023
+ const out = execFileSync7(command.file, command.args, {
22882
23024
  stdio: ["ignore", "pipe", "ignore"],
22883
23025
  timeout: YARN_VERSION_TIMEOUT_MS,
22884
23026
  shell: command.shell,
@@ -22940,7 +23082,7 @@ function isSkillsCliCached(runner, cwd, platform = process.platform) {
22940
23082
  if (runner.kind !== "npx") return false;
22941
23083
  try {
22942
23084
  const command = skillsCommand(runner, ["--no-install", "skills", "--version"], platform);
22943
- execFileSync6(command.file, command.args, {
23085
+ execFileSync7(command.file, command.args, {
22944
23086
  env: npxChildEnv(),
22945
23087
  stdio: ["ignore", "ignore", "ignore"],
22946
23088
  timeout: OFFLINE_PROBE_TIMEOUT_MS,
@@ -22971,7 +23113,7 @@ function getScopeSpecs(projectRoot) {
22971
23113
  }
22972
23114
  ];
22973
23115
  }
22974
- function refreshArgentSkills(projectRoot) {
23116
+ function refreshArgentSkills(projectRoot, scopes = "all") {
22975
23117
  const bundled = new Set(listBundledSkills());
22976
23118
  if (bundled.size === 0) return [];
22977
23119
  const results = [];
@@ -22985,9 +23127,12 @@ function refreshArgentSkills(projectRoot) {
22985
23127
  const runSkills = (skillsArgs) => {
22986
23128
  if (!runner) throw new Error(NO_SKILLS_RUNNER_MESSAGE);
22987
23129
  const command = skillsCommand(runner, skillsArgs);
22988
- execFileSync7(command.file, command.args, { ...execOpts, shell: command.shell });
23130
+ execFileSync8(command.file, command.args, { ...execOpts, shell: command.shell });
22989
23131
  };
22990
- for (const spec of getScopeSpecs(projectRoot)) {
23132
+ const specs = getScopeSpecs(projectRoot).filter(
23133
+ (spec) => scopes === "all" || spec.scope === "global"
23134
+ );
23135
+ for (const spec of specs) {
22991
23136
  const tracked = listArgentSkillsInLock(spec.lockPath);
22992
23137
  if (tracked.length === 0) continue;
22993
23138
  const orphaned = tracked.filter((name) => !bundled.has(name) && ARGENT_SKILL_NAME.test(name));
@@ -23125,8 +23270,8 @@ function summarizeSkillRefreshForTelemetry(results) {
23125
23270
  failed_count: results.filter((result) => result.syncError || result.pruneError).length
23126
23271
  };
23127
23272
  }
23128
- function reportSkillRefresh(projectRoot, stage) {
23129
- const results = refreshArgentSkills(projectRoot);
23273
+ function reportSkillRefresh(projectRoot, stage, scopes = "all") {
23274
+ const results = refreshArgentSkills(projectRoot, scopes);
23130
23275
  if (results.some((r2) => r2.syncError === NO_SKILLS_RUNNER_MESSAGE)) {
23131
23276
  log.warn(noSkillsRunnerHelp("argent update"));
23132
23277
  }
@@ -24391,6 +24536,7 @@ function printBanner() {
24391
24536
  var import_picocolors12 = __toESM(require_picocolors(), 1);
24392
24537
  var import_semver5 = __toESM(require_semver2(), 1);
24393
24538
  import * as fs24 from "node:fs";
24539
+ import * as os5 from "node:os";
24394
24540
  import * as path31 from "node:path";
24395
24541
 
24396
24542
  // ../argent-installer/src/install-targets.ts
@@ -24441,11 +24587,18 @@ async function promptInstallTargets(verb) {
24441
24587
 
24442
24588
  // ../argent-installer/src/update-target.ts
24443
24589
  var import_update_core = __toESM(require_dist3(), 1);
24444
- async function resolveInstallableUpdateTarget(pm, current, cwd) {
24590
+ async function resolveInstallableUpdateTarget(pm, current, cwd, candidate) {
24445
24591
  const info = await (0, import_update_core.fetchRegistryInfo)(`${NPM_REGISTRY}/${PACKAGE_NAME}`);
24446
24592
  if (info === null) return null;
24447
24593
  const minReleaseAgeMs = await (0, import_update_core.detectMinReleaseAgeMsForPm)(pm, cwd);
24448
- const target = (0, import_update_core.pickInstallableTarget)(info.latest, info.times, current, minReleaseAgeMs);
24594
+ let { latest, times } = info;
24595
+ if (candidate) {
24596
+ const publishedAt = times[candidate] ?? null;
24597
+ latest = { version: candidate, publishedAt };
24598
+ times = publishedAt ? { [candidate]: publishedAt } : {};
24599
+ if (candidate !== info.latest.version && !publishedAt) return null;
24600
+ }
24601
+ const target = (0, import_update_core.pickInstallableTarget)(latest, times, current, minReleaseAgeMs);
24449
24602
  return {
24450
24603
  latestVersion: info.latest.version,
24451
24604
  latestPublishedAt: info.latest.publishedAt,
@@ -24460,7 +24613,7 @@ import * as fs23 from "node:fs";
24460
24613
  import * as path26 from "node:path";
24461
24614
  import * as readline from "node:readline";
24462
24615
  import { homedir as homedir7 } from "node:os";
24463
- import { spawn as spawn4, execFileSync as execFileSync8 } from "node:child_process";
24616
+ import { spawn as spawn4, execFileSync as execFileSync9 } from "node:child_process";
24464
24617
  import { createHash as createHash3, randomBytes } from "node:crypto";
24465
24618
  import { mkdir, writeFile, readFile, readdir as readdir2, unlink, rename, chmod } from "node:fs/promises";
24466
24619
  var STATE_DIR = path26.join(homedir7(), ".argent");
@@ -24601,7 +24754,7 @@ var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs23.existsSync(p)) ?? "ps";
24601
24754
  var PS_WIDTH_FLAGS = ["-ww"];
24602
24755
  var PS_LOCALE = process.platform === "darwin" ? "en_US.UTF-8" : "C.UTF-8";
24603
24756
  function readProcessCommandLine(pid, flags = PS_WIDTH_FLAGS, env = { ...process.env, LC_ALL: PS_LOCALE }) {
24604
- return execFileSync8(PS_BIN, [...flags, "-p", String(pid), "-o", "command="], {
24757
+ return execFileSync9(PS_BIN, [...flags, "-p", String(pid), "-o", "command="], {
24605
24758
  env,
24606
24759
  encoding: "utf8",
24607
24760
  timeout: 2e3,
@@ -24709,7 +24862,7 @@ import {
24709
24862
  } from "node:fs/promises";
24710
24863
  import { constants as fsConstants } from "node:fs";
24711
24864
  import { tmpdir as tmpdir2 } from "node:os";
24712
- import { basename as basename8, dirname as dirname18, extname as extname2, isAbsolute as isAbsolute9, join as join29, normalize as normalize2, resolve as resolve19, sep as sep7 } from "node:path";
24865
+ import { basename as basename8, dirname as dirname18, extname as extname2, isAbsolute as isAbsolute10, join as join29, normalize as normalize2, resolve as resolve19, sep as sep7 } from "node:path";
24713
24866
  import { createHash as createHash5 } from "node:crypto";
24714
24867
  var ALLOWED_SAVE_DIRS = /* @__PURE__ */ new Set([normalize2(".argent/recordings")]);
24715
24868
  var RECORDINGS_SAVE_DIR = normalize2(".argent/recordings");
@@ -24786,11 +24939,142 @@ function resolveUpdatePackageAction(trigger, installed) {
24786
24939
  function isLivePinnedEntry(entry) {
24787
24940
  return entry !== null && isPinnedGlobalEntry(entry) && fs24.existsSync(entry.command) && fs24.existsSync(entry.args[0]);
24788
24941
  }
24942
+ async function refreshConfiguration({
24943
+ projectRoot,
24944
+ installMode,
24945
+ nonInteractive,
24946
+ globalOnly
24947
+ }) {
24948
+ const spinner2 = spinner();
24949
+ spinner2.start("Refreshing workspace configuration...");
24950
+ const results = [];
24951
+ const localCmdMode = installMode === "local" ? resolveLocalCommandMode(projectRoot) : null;
24952
+ const globalCmdMode = resolveGlobalCommandMode();
24953
+ const globalInstallOnPath = isGlobalInstallFirstOnPath();
24954
+ const skipEntryRewrite = localCmdMode?.kind === "local-npx";
24955
+ const entryFor = (scope) => getMcpEntryForScope(installMode, scope, localCmdMode, globalCmdMode);
24956
+ const configuredScopes = findConfiguredAdapterScopes(ALL_ADAPTERS, projectRoot).filter(
24957
+ ({ scope }) => !globalOnly || scope !== "project"
24958
+ );
24959
+ const adaptersByScope = /* @__PURE__ */ new Map([
24960
+ ["local", /* @__PURE__ */ new Set()],
24961
+ ["global", /* @__PURE__ */ new Set()]
24962
+ ]);
24963
+ for (const { adapter, scope, configPath } of configuredScopes) {
24964
+ const normScope = scope === "project" ? "local" : "global";
24965
+ adaptersByScope.get(normScope).add(adapter);
24966
+ if (skipEntryRewrite && normScope === "local") continue;
24967
+ let existing;
24968
+ try {
24969
+ existing = adapter.getArgentEntry(configPath);
24970
+ } catch {
24971
+ continue;
24972
+ }
24973
+ const isUnreadableSentinel = existing !== null && existing.command === "" && existing.args.length === 0;
24974
+ if (existing !== null && !isUnreadableSentinel && !isArgentManagedEntry(existing)) {
24975
+ results.push(
24976
+ `${import_picocolors12.default.yellow("!")} ${adapter.name} left a customized entry untouched ${import_picocolors12.default.dim(configPath)}`
24977
+ );
24978
+ continue;
24979
+ }
24980
+ const entry = entryFor(normScope);
24981
+ const replacesLivePin = isLivePinnedEntry(existing) && !isPinnedGlobalEntry(entry);
24982
+ if (replacesLivePin && normScope === "local") continue;
24983
+ if (replacesLivePin && !globalInstallOnPath) {
24984
+ results.push(
24985
+ `${import_picocolors12.default.yellow("!")} ${adapter.name} kept its absolute-path entry (no global install found first on PATH) ${import_picocolors12.default.dim(configPath)}`
24986
+ );
24987
+ continue;
24988
+ }
24989
+ try {
24990
+ adapter.write(configPath, entry);
24991
+ results.push(
24992
+ replacesLivePin ? `${import_picocolors12.default.yellow("!")} ${adapter.name} now runs the bare argent command (the global install on PATH has no node beside it to pin) ${import_picocolors12.default.dim(configPath)}` : `${import_picocolors12.default.green("+")} ${adapter.name} ${import_picocolors12.default.dim(configPath)}`
24993
+ );
24994
+ } catch {
24995
+ }
24996
+ }
24997
+ if (skipEntryRewrite && configuredScopes.some(({ scope }) => scope === "project")) {
24998
+ log.info(
24999
+ import_picocolors12.default.dim(
25000
+ "Left project MCP entries unchanged \u2014 the repo-local argent binary can't be resolved right now (fresh checkout: run your package manager's install; after an out-of-band version bump, just re-run argent update)."
25001
+ )
25002
+ );
25003
+ }
25004
+ for (const [scope, adapters] of adaptersByScope) {
25005
+ for (const adapter of adapters) {
25006
+ if (!adapter.refreshAllowlist) continue;
25007
+ try {
25008
+ adapter.refreshAllowlist(projectRoot, scope);
25009
+ } catch {
25010
+ }
25011
+ }
25012
+ }
25013
+ const localAdapters = [...adaptersByScope.get("local")];
25014
+ const globalAdapters = [...adaptersByScope.get("global")];
25015
+ const ruleResults = [
25016
+ ...copyRulesAndAgents(globalAdapters, projectRoot, "global", RULES_DIR, AGENTS_DIR),
25017
+ ...copyRulesAndAgents(localAdapters, projectRoot, "local", RULES_DIR, AGENTS_DIR)
25018
+ ];
25019
+ spinner2.stop("Configuration refreshed.");
25020
+ if (results.length > 0) {
25021
+ note(results.join("\n"), "MCP Configs Updated");
25022
+ }
25023
+ if (!globalOnly) {
25024
+ const staleCleanup = await cleanupStaleMcpConfigs({
25025
+ writtenAdapters: [.../* @__PURE__ */ new Set([...localAdapters, ...globalAdapters])],
25026
+ detectedAdapters: detectAdapters(),
25027
+ installMode,
25028
+ scope: localAdapters.length > 0 ? "local" : "global",
25029
+ effectiveRoot: projectRoot,
25030
+ // Same one-shot confirmation init uses for cross-project removals.
25031
+ // --yes passes no confirmer (the sweep goes report-only) — the
25032
+ // agent-triggered `update --yes` must never delete cross-project state
25033
+ // on a fallible PATH probe.
25034
+ confirmCrossProjectRemovals: nonInteractive ? void 0 : async (items) => {
25035
+ log.warn(
25036
+ `Dead argent entries from a previous global install were found in
25037
+ global (cross-project) config files:
25038
+ ` + items.map((item) => ` ${import_picocolors12.default.cyan(item)}`).join("\n")
25039
+ );
25040
+ const choice = await confirm({
25041
+ message: "Remove these dead global entries? - recommended",
25042
+ initialValue: true
25043
+ });
25044
+ return !isCancel(choice) && choice === true;
25045
+ }
25046
+ });
25047
+ if (staleCleanup.lines.length > 0) {
25048
+ note(staleCleanup.lines.join("\n"), "Stale Config Cleanup");
25049
+ track("installation:stale_config_cleanup", {
25050
+ removed_count: staleCleanup.removedCount,
25051
+ warned_count: staleCleanup.warnedCount
25052
+ });
25053
+ }
25054
+ }
25055
+ if (ruleResults.length > 0) {
25056
+ note(ruleResults.join("\n"), "Rules Updated");
25057
+ }
25058
+ await reportRetiredFiles(
25059
+ findRetiredRulesAndAgents(
25060
+ [
25061
+ { adapters: globalAdapters, scope: "global" },
25062
+ { adapters: localAdapters, scope: "local" }
25063
+ ],
25064
+ projectRoot,
25065
+ RULES_DIR,
25066
+ AGENTS_DIR
25067
+ ),
25068
+ !nonInteractive
25069
+ );
25070
+ reportSkillRefresh(projectRoot, "installer_update_skills_refresh", globalOnly ? "global" : "all");
25071
+ }
24789
25072
  async function update(args) {
24790
25073
  const nonInteractive = args.includes("--yes") || args.includes("-y");
24791
25074
  const noTelemetry = args.includes("--no-telemetry");
24792
25075
  const requestedVersion = getRequestedVersion(args);
24793
25076
  const trigger = getUpdateTriggerFromEnv();
25077
+ const automatic = process.env.ARGENT_AUTOMATIC_UPDATE === "1";
24794
25078
  init("installer");
24795
25079
  const updateStartTime = performance.now();
24796
25080
  let telemetryFinalized = false;
@@ -24883,16 +25167,23 @@ async function update(args) {
24883
25167
  const spinner2 = spinner();
24884
25168
  spinner2.start("Checking for updates...");
24885
25169
  const pm = mode === "local" ? detectProjectPackageManager(projectRoot) : detectGlobalPackageManager();
25170
+ if (automatic) {
25171
+ const globalRoot = getGloballyInstalledPackageRoot();
25172
+ if (!globallyInstalled || !globalRoot || fs24.realpathSync(globalRoot) !== projectRoot || getConfigValueByKey("autoUpdate.enabled") !== true || !ownsGlobalInstall(pm, projectRoot)) {
25173
+ spinner2.stop("Could not confirm an automatic update for this installation.");
25174
+ return "noop";
25175
+ }
25176
+ }
24886
25177
  const runIn = mode === "local" ? { cwd: projectRoot } : globalCommandOptions(pm);
24887
25178
  let latest = null;
24888
25179
  let target;
24889
25180
  let minReleaseAgeMs = 0;
24890
- if (requestedVersion !== null) {
25181
+ if (requestedVersion !== null && !automatic) {
24891
25182
  target = requestedVersion;
24892
25183
  } else {
24893
25184
  let resolved;
24894
25185
  try {
24895
- resolved = await resolveInstallableUpdateTarget(pm, installed, runIn.cwd);
25186
+ resolved = automatic && requestedVersion ? await resolveInstallableUpdateTarget(pm, installed, runIn.cwd, requestedVersion) : await resolveInstallableUpdateTarget(pm, installed, runIn.cwd);
24896
25187
  } catch (err) {
24897
25188
  spinner2.stop(import_picocolors12.default.red("Could not reach registry."));
24898
25189
  await trackPackageAction(
@@ -24915,6 +25206,10 @@ async function update(args) {
24915
25206
  log.error("Failed to determine the latest Argent release from the registry.");
24916
25207
  return { failed: UPDATE_REGISTRY_CHECK_FAILED };
24917
25208
  }
25209
+ if (automatic && resolved.targetVersion !== requestedVersion) {
25210
+ spinner2.stop("The eligible version has changed.");
25211
+ return "noop";
25212
+ }
24918
25213
  latest = resolved.latestVersion;
24919
25214
  target = resolved.targetVersion;
24920
25215
  minReleaseAgeMs = resolved.minReleaseAgeMs;
@@ -24959,22 +25254,24 @@ async function update(args) {
24959
25254
  }
24960
25255
  }
24961
25256
  log.info(`Running: ${import_picocolors12.default.dim(cmdStr)}`);
24962
- const installDirToStop = mode === "local" ? localProbe.packageDir : getGloballyInstalledPackageRoot();
24963
- try {
24964
- if (installDirToStop) {
24965
- await killToolServerForInstallDir(installDirToStop);
24966
- } else if (mode === "global") {
24967
- await killToolServer();
25257
+ if (!automatic) {
25258
+ const installDirToStop = mode === "local" ? localProbe.packageDir : getGloballyInstalledPackageRoot();
25259
+ try {
25260
+ if (installDirToStop) {
25261
+ await killToolServerForInstallDir(installDirToStop);
25262
+ } else if (mode === "global") {
25263
+ await killToolServer();
25264
+ }
25265
+ } catch (err) {
25266
+ await trackPackageAction(
25267
+ "update_failed",
25268
+ updateStartTime,
25269
+ false,
25270
+ UPDATE_TOOLSERVER_STOP_FAILED
25271
+ );
25272
+ log.error(`Could not stop the running tool server: ${err}`);
25273
+ return { failed: UPDATE_TOOLSERVER_STOP_FAILED };
24968
25274
  }
24969
- } catch (err) {
24970
- await trackPackageAction(
24971
- "update_failed",
24972
- updateStartTime,
24973
- false,
24974
- UPDATE_TOOLSERVER_STOP_FAILED
24975
- );
24976
- log.error(`Could not stop the running tool server: ${err}`);
24977
- return { failed: UPDATE_TOOLSERVER_STOP_FAILED };
24978
25275
  }
24979
25276
  const packageAction = resolveUpdatePackageAction(
24980
25277
  trigger,
@@ -25072,6 +25369,29 @@ async function update(args) {
25072
25369
  log.error(`Requested version is not a stable semver: ${requestedVersion}`);
25073
25370
  process.exit(1);
25074
25371
  }
25372
+ if (automatic) {
25373
+ const runningRoot = fs24.realpathSync(resolvePackageRoot(import.meta.dirname));
25374
+ const result = requestedVersion ? await applyUpdateForTarget("global", runningRoot) : "noop";
25375
+ if (result === "updated" && requestedVersion) {
25376
+ writeCliRecord({
25377
+ mode: "global",
25378
+ projectRoot: runningRoot,
25379
+ version: getGloballyInstalledVersion() ?? requestedVersion
25380
+ });
25381
+ await refreshConfiguration({
25382
+ projectRoot: os5.homedir(),
25383
+ installMode: "global",
25384
+ nonInteractive: true,
25385
+ globalOnly: true
25386
+ });
25387
+ await completeUpdateTelemetry();
25388
+ } else {
25389
+ process.exitCode = 1;
25390
+ if (typeof result === "object") await failUpdateTelemetry(result.failed);
25391
+ else await completeUpdateTelemetry();
25392
+ }
25393
+ return;
25394
+ }
25075
25395
  const rootOverride = getProjectRootOverride(args);
25076
25396
  const projectRoot = rootOverride ? path31.resolve(rootOverride) : resolveProjectRoot2(process.cwd());
25077
25397
  installMode = resolveInstallMode(projectRoot);
@@ -25136,127 +25456,7 @@ async function update(args) {
25136
25456
  outro(import_picocolors12.default.red("Update failed."));
25137
25457
  process.exit(1);
25138
25458
  }
25139
- {
25140
- const spinner2 = spinner();
25141
- spinner2.start("Refreshing workspace configuration...");
25142
- const results = [];
25143
- const localCmdMode = installMode === "local" ? resolveLocalCommandMode(projectRoot) : null;
25144
- const globalCmdMode = resolveGlobalCommandMode();
25145
- const globalInstallOnPath = isGlobalInstallFirstOnPath();
25146
- const skipEntryRewrite = localCmdMode?.kind === "local-npx";
25147
- const entryFor = (scope) => getMcpEntryForScope(installMode, scope, localCmdMode, globalCmdMode);
25148
- const configuredScopes = findConfiguredAdapterScopes(ALL_ADAPTERS, projectRoot);
25149
- const adaptersByScope = /* @__PURE__ */ new Map([
25150
- ["local", /* @__PURE__ */ new Set()],
25151
- ["global", /* @__PURE__ */ new Set()]
25152
- ]);
25153
- for (const { adapter, scope, configPath } of configuredScopes) {
25154
- const normScope = scope === "project" ? "local" : "global";
25155
- adaptersByScope.get(normScope).add(adapter);
25156
- if (skipEntryRewrite && normScope === "local") continue;
25157
- let existing;
25158
- try {
25159
- existing = adapter.getArgentEntry(configPath);
25160
- } catch {
25161
- continue;
25162
- }
25163
- const isUnreadableSentinel = existing !== null && existing.command === "" && existing.args.length === 0;
25164
- if (existing !== null && !isUnreadableSentinel && !isArgentManagedEntry(existing)) {
25165
- results.push(
25166
- `${import_picocolors12.default.yellow("!")} ${adapter.name} left a customized entry untouched ${import_picocolors12.default.dim(configPath)}`
25167
- );
25168
- continue;
25169
- }
25170
- const entry = entryFor(normScope);
25171
- const replacesLivePin = isLivePinnedEntry(existing) && !isPinnedGlobalEntry(entry);
25172
- if (replacesLivePin && normScope === "local") continue;
25173
- if (replacesLivePin && !globalInstallOnPath) {
25174
- results.push(
25175
- `${import_picocolors12.default.yellow("!")} ${adapter.name} kept its absolute-path entry (no global install found first on PATH) ${import_picocolors12.default.dim(configPath)}`
25176
- );
25177
- continue;
25178
- }
25179
- try {
25180
- adapter.write(configPath, entry);
25181
- results.push(
25182
- replacesLivePin ? `${import_picocolors12.default.yellow("!")} ${adapter.name} now runs the bare argent command (the global install on PATH has no node beside it to pin) ${import_picocolors12.default.dim(configPath)}` : `${import_picocolors12.default.green("+")} ${adapter.name} ${import_picocolors12.default.dim(configPath)}`
25183
- );
25184
- } catch {
25185
- }
25186
- }
25187
- if (skipEntryRewrite && configuredScopes.some(({ scope }) => scope === "project")) {
25188
- log.info(
25189
- import_picocolors12.default.dim(
25190
- "Left project MCP entries unchanged \u2014 the repo-local argent binary can't be resolved right now (fresh checkout: run your package manager's install; after an out-of-band version bump, just re-run argent update)."
25191
- )
25192
- );
25193
- }
25194
- for (const [scope, adapters] of adaptersByScope) {
25195
- for (const adapter of adapters) {
25196
- if (!adapter.refreshAllowlist) continue;
25197
- try {
25198
- adapter.refreshAllowlist(projectRoot, scope);
25199
- } catch {
25200
- }
25201
- }
25202
- }
25203
- const localAdapters = [...adaptersByScope.get("local")];
25204
- const globalAdapters = [...adaptersByScope.get("global")];
25205
- const ruleResults = [
25206
- ...copyRulesAndAgents(globalAdapters, projectRoot, "global", RULES_DIR, AGENTS_DIR),
25207
- ...copyRulesAndAgents(localAdapters, projectRoot, "local", RULES_DIR, AGENTS_DIR)
25208
- ];
25209
- spinner2.stop("Configuration refreshed.");
25210
- if (results.length > 0) {
25211
- note(results.join("\n"), "MCP Configs Updated");
25212
- }
25213
- const staleCleanup = await cleanupStaleMcpConfigs({
25214
- writtenAdapters: [.../* @__PURE__ */ new Set([...localAdapters, ...globalAdapters])],
25215
- detectedAdapters: detectAdapters(),
25216
- installMode,
25217
- scope: localAdapters.length > 0 ? "local" : "global",
25218
- effectiveRoot: projectRoot,
25219
- // Same one-shot confirmation init uses for cross-project removals.
25220
- // --yes passes no confirmer (the sweep goes report-only) — the
25221
- // agent-triggered `update --yes` must never delete cross-project state
25222
- // on a fallible PATH probe.
25223
- confirmCrossProjectRemovals: nonInteractive ? void 0 : async (items) => {
25224
- log.warn(
25225
- `Dead argent entries from a previous global install were found in
25226
- global (cross-project) config files:
25227
- ` + items.map((item) => ` ${import_picocolors12.default.cyan(item)}`).join("\n")
25228
- );
25229
- const choice = await confirm({
25230
- message: "Remove these dead global entries? - recommended",
25231
- initialValue: true
25232
- });
25233
- return !isCancel(choice) && choice === true;
25234
- }
25235
- });
25236
- if (staleCleanup.lines.length > 0) {
25237
- note(staleCleanup.lines.join("\n"), "Stale Config Cleanup");
25238
- track("installation:stale_config_cleanup", {
25239
- removed_count: staleCleanup.removedCount,
25240
- warned_count: staleCleanup.warnedCount
25241
- });
25242
- }
25243
- if (ruleResults.length > 0) {
25244
- note(ruleResults.join("\n"), "Rules Updated");
25245
- }
25246
- await reportRetiredFiles(
25247
- findRetiredRulesAndAgents(
25248
- [
25249
- { adapters: globalAdapters, scope: "global" },
25250
- { adapters: localAdapters, scope: "local" }
25251
- ],
25252
- projectRoot,
25253
- RULES_DIR,
25254
- AGENTS_DIR
25255
- ),
25256
- !nonInteractive
25257
- );
25258
- reportSkillRefresh(projectRoot, "installer_update_skills_refresh");
25259
- }
25459
+ await refreshConfiguration({ projectRoot, installMode, nonInteractive, globalOnly: false });
25260
25460
  if (firstFailure) {
25261
25461
  await failUpdateTelemetry(firstFailure);
25262
25462
  outro(import_picocolors12.default.yellow("Update finished with errors \u2014 see above."));